akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(),x.end()
#define pri 1000000007
#define nonod numberofnodes
#define pr pair <ll,ll>
#define mnx  1000001
#define inf 10000000000000000001
#define prin(x) cout<<setprecision(7)<<fixed<<x<<endl;
using namespace std;


void masterstroke(){
   ll n,a,b,c,d;
   cin>>n>>a>>b>>c>>d;
   string s;cin>>s;
   if(d<=b){cout<<"No";return;}
   for(ll i=a-1;i<max(c,d);i++){
   	if(s[i]=='#'&&s[i+1]=='#'){cout<<"No";return;}
   }
   if(d>c){
   	cout<<"Yes";
   }
   else{
   	for(ll i=b-1;i<=d-1;i++){
   		if(s[i]=='.'&&s[i+1]=='.'&&s[i-1]!='#'){cout<<"Yes";return;}
   	}
   	cout<<"No";
   }
   

}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)masterstroke();
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
#define mp make_pair
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

long long fac[COMMAX], finv[COMMAX], inv[COMMAX];

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcd(int a,int b){return a*b / gcd(a,b);}
// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};

const int MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, long long h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};

int main(){
  double a;
  cin >> a;
  printf("%.7f",pow((a/3),3));
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
using namespace std;
map<string, ll>mp; string a[114], b[114];
signed main() {
	ll n, m, inf = -1e9;
	cin >> n;
	rep(i, n)cin >> a[i];
	cin >> m;
	rep(i, m)cin >> b[i];
	rep(i, n)mp[a[i]]++;
	rep(i, m)mp[b[i]]--;
	for (auto x : mp) {
		if (inf < x.second)inf = x.second;
	}
	cout << max((ll)0, inf) << endl;
	getchar(); getchar(); return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};

vector<int> G[200000];
int color[200000];
 
bool dfs(int v,int c){
    color[v]=c;
    for(int i=0;i<G[v].size();i++){
        if(color[G[v][i]]==c) return false;
        if(color[G[v][i]]==0&&!dfs(G[v][i],-c)) return false;
    }
    return true;
}
 

int main(){
    int n;cin >> n;
    for (int i = 0; i < n-1; i++) {
        int a,b;cin >> a >> b;
        a--,b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    assert(dfs(0,1));
    int w=0,b=0;
    for (int i = 0; i < n; i++) {
        if(color[i] == 1) w++;
        else b++;
    }
    int aa = n / 3 + (1 <= n % 3), bb = n / 3 + (2 <= n % 3), cc = n / 3;
    if(b < w){
        swap(w, b);
        for (int i = 0; i < n; i++) {
            color[i] *= -1;
        }
    }
    vector<int> ans(n, 0);
    if(w <= cc){
        int p = 1, q = 0, r = 0;
        for (int i = 0; i < n; i++) {
            if(color[i] == 1){
                ans[i] = p * 3;
                p++;
            }
            else{
                if(q < aa){
                    ans[i] = q*3 + 1;
                    q++;
                }
                else if(r < bb){
                    ans[i] = r*3 + 2;
                    r++;
                }
                else{
                    ans[i] = p * 3;
                    p++;
                }
            }
        }
    }
    else{
        int p = 1, q = 0, r = 0;
        for (int i = 0; i < n; i++) {
            if(color[i] == 1){
                if(q < aa){
                    ans[i] = q * 3 + 1;
                    q++;
                }
                else{
                    ans[i] = p * 3;
                    p++;
                }
            }
            else{
                if(r < bb){
                    ans[i] = r * 3 + 2;
                    r++;
                }
                else{
                    ans[i] = p * 3;
                    p++;
                }
            }
        }
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i] << (i == n-1?"\n":" ");
    }
    return 0;
}


Measured memory_bytes: 19072
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

int main(int argc, char* argv[])
{
  double x1,y1,x2,y2;
  double distance;
  cin >> x1 >> y1 >> x2 >> y2;
  distance = sqrt(pow(x1-x2,2.0)+pow(y1-y2,2.0));
  printf("%.8lf\n",distance);
  return 0;
}

Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  string field[H];
  for (int i=0;i<H;i++){
    cin >> field[i];
  }
  vector<vector<int>> dist(H,vector<int>(W,-1));
  queue<pair<int,int>> que;
  int dh[4]={1,0,-1,0};
  int dw[4]={0,1,0,-1};
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      if (field[i][j]=='#'){
        dist[i][j]=0;
        que.push(make_pair(i,j));
      }
    }
  }
  while(!que.empty()){
    pair<int,int> current=que.front();
    int h=current.first;
    int w=current.second;
    que.pop();
    for (int i=0;i<4;i++){
      int nh=h+dh[i];
      int nw=w+dw[i];
      if (nh<0||nh>H-1||nw<0||nw>W-1){
        continue;
      }
      else if (dist[nh][nw]==-1){
        dist[nh][nw]=dist[h][w]+1;
        que.push(make_pair(nh,nw));
      }
    }
  }
  int ans=0;
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      ans=max(ans,dist[i][j]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 13456
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <deque>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    //input
    int h,w; cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));

    for(int i = 0;i < h; i++) {
        for(int j = 0; j < w ; j++){
            cin >> a[i][j];
    }
    }

    //compute
    int sum = 0;
    vector<int> c(h,0);
    for(int i = 0;i < h; i++) {
        for(int j = 0; j < w ; j++){
            if(a[i][j] == '#'){
                c[i] += 1;
            }
        }
    }

    for(int i = 0;i < h; i++) sum += c[i];

    //output
    if(sum == h + w -1){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 3588
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const int INF = 2e9;
ll n, K;
auto nC2 = [](ll a) { return a*(a-1)/2; };
vector<ll> Po,Ne;
bool is_nega; //負or正(≠0)

ll calc_count(ll X, vector<ll> &V, vector<ll> &W) {
  ll ret = 0ll;
  // t以上のものはWに何個あるかを求める
  rep(i, V.size()) {
    ll t = (X+V[i]-1)/V[i];
    int idx = lower_bound(ALL(W), t)-W.begin();
    if (!is_nega && i>=idx) ret += W.size()-i-1;
    else ret+=W.size()-idx;
  }
  return ret;
} 


int main() {
  INCANT;
  cin >> n >> K;
  ll a;
  rep(i, n) {
    cin >> a;
    if (a<0) Ne.push_back(-a); // 便宜上正にする
    else if (a>0) Po.push_back(a);
  }

  sort(ALL(Ne)); sort(ALL(Po));

  if (Ne.size()*Po.size()<K && K < nC2(n)-nC2(Po.size())-nC2(Ne.size())) {
    cout << 0 << "\n";
    return 0;
  }
  is_nega = Ne.size()*Po.size()>=K;
  ll ok = 0ll, ng = 1e18;
  ll base = is_nega?K-1:nC2(n)-K;
  while(ng-ok>1ll) {
    ll mid = (ok+ng)/2;
    ll r;
    if (is_nega) r = calc_count(mid, Ne,Po);
    else r = calc_count(mid, Ne, Ne)+calc_count(mid,Po, Po);
    if (r<=base) ng = mid;
    else ok = mid;
  } 
  if (is_nega) ok *= -1;

  cout << ok << "\n";
  return 0;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> A(n), B(n);
    for(int& i: A) cin >> i;
    B[0] = 0;
    for(int i = 1; i < n; i++) B[i] = A[i] - B[i - 1];
    int inc = abs(A[0] - B[n - 1]);
    for(int i = 0; i < n; i++){
        if(i % 2) B[i] -= inc / 2;
        else B[i] += inc / 2;
    }
    for(int& i: B) i *= 2;
    int temp = B[n - 1];
    for(int i = n - 1; i > 0; i--) B[i] = B[i - 1];
    B[0] = temp;
    for(int& i: B) cout << i << " ";
    cout << endl;
}

Measured memory_bytes: 2048
#from numpy import*
#from scipy import*
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby
from operator import mul
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial
from copy import deepcopy
import sys
#input=sys.stdin.readline  #危険！基本オフにしろ！
sys.setrecursionlimit(10**6)


def main():
    *a,=map(int,open(0).read().split())
    a.pop()
    a.pop()
    for j in [sorted(a[i:i+2])for i in range(0,len(a),2)]:
        print(*j)
if __name__ == '__main__':
    main()


Measured memory_bytes: 7732
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n, m, k;
    cin >> n >> m >> k;

    for ( int i = 0; i <= n; ++i ) {
        for ( int j = 0; j <= m; ++j ) {
            if ( i * ( m - j ) + j * ( n - i ) == k ) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <functional>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
using ll = unsigned long long;
const ll mod = 1000000007;
string al = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//bool less_sec(const pair<int, int>&a, const pair<int, int>&b) {
//	return a.second > b.second;
//}
int a, b, c, d;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
    cin >> a;
    int maxV = 1;
    for(int i=2; i<=a; ++i){
        int temp=i;
        while(true){
            if(temp*i>a) break;
            temp*=i;
            maxV = max(maxV, temp);
        }
    }
    cout << maxV << endl;
            
            
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x;
  int y;
  cin >> x >> y;

  if ((x + y) % 2 != 0) {
	cout << (x + y) / 2 + 1 << endl;
  }
  else {
    cout << (x + y) / 2 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 40005
#define eps 1e-12
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
const int MOD = 998244353;
char s[2005];
int sum[2005][2],N;
int dp[4005][4005];
int inc(int a,int b) {
	return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
	return 1LL * a * b % MOD;
}
void update(int &x,int y) {
	x = inc(x,y);
}
void Solve() {
	scanf("%s",s + 1);
	N = strlen(s + 1);
	for(int i = 1 ; i <= N ; ++i) {
		sum[i][0] = sum[i - 1][0];
		sum[i][1] = sum[i - 1][1];
		if(s[i] == '0') sum[i][0] += 2;
		if(s[i] == '1') {sum[i][0]++;sum[i][1]++;}
		if(s[i] == '2') sum[i][1] += 2;
	}
	dp[0][0] = 1;
	for(int i = 1 ; i <= 2 * N ; ++i) {
		int t = min(i,N);
		for(int j = 0 ; j <= i ; ++j) {
			int a = j,b = i - j;
			if(a <= sum[t][0] && b <= sum[t][1]) {
				if(a) update(dp[a][b],dp[a - 1][b]);
				if(b) update(dp[a][b],dp[a][b - 1]);
			}
		}
	}
	out(dp[sum[N][0]][sum[N][1]]);enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
}


Measured memory_bytes: 60416
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll D, G;
ll p[100], c[100];
map<ll, bool> m;

int main() {
  cin >> D >> G;
  repe(i, 1, D) { cin >> p[i] >> c[i]; }

  ll ans = INF;

  for (ll bit = 0; bit < (1 << D); ++bit) {
    ll score = 0;
    ll num = 0;
    repe(i, 0, 10) { m[i] = false; }
    for (ll i = 1; i <= D; i++) {
      if (bit & (1 << (i - 1))) {
        score += 100 * i * p[i] + c[i];
        num += p[i];
        m[i] = true;
      }
    }
    ll rest = G - score;
    if (rest <= 0) {
      chmin(ans, num);
      continue;
    }
    ll idx = 0;
    ll total = 0;
    for (ll i = D; i >= 1; --i) {
      if (m[i]) {
        continue;
      }
      if (p[i] * i >= total) {
        total = p[i] * 100 * i;
        idx = i;
      }
    }
    if (idx == 0) {
      continue;
    }
    if (rest % (idx * 100) == 0) {
      if (rest / (idx * 100) >= p[idx]) {
        continue;
      }
      num += rest / (idx * 100);
    } else {
      if (rest / (idx * 100) + 1 >= p[idx]) {
        continue;
      }
      num += rest / (idx * 100) + 1;
    }
    chmin(ans, num);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

   string s;
   cin>>s;
   int sum=0;
rep(i,3) if(s[i]=='1')sum++;

cout<<sum<<endl;


   
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>

/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/
using namespace std;
typedef long long int ll;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
// online submission
#endif
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int x=(a+d-1)/d;
	int y=(c+b-1)/b;
	if(x>=y){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace  std ;
typedef long long  ll;
typedef pair<ll, ll> Pll;
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define rad(X) cout << (X) << endl
#define ASH(X) cout << (X) << " "
#define debug(x) cout << #x << " " << x << endl;
#define debug2(x,y) cout << #x << " " << x << " " << #y << " " << y << endl;
#define FOR(I,A,B) for(int I = (A); I <= (B); I++)
#define cir(I,B,A) for(int I = (A); I >=(B); I--)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define SORT(c) (sort(c.begin(),c.end()))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASES int ___T; cin >> ___T; for(int cs=1;cs<=___T;cs++)
#define FAST()  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
template<typename T>T gcd(T x, T y){if(y==0)return x;else return gcd(y,x%y);}
ll fx[] = {1, 1, 0, -1, -1, -1, 0, 1};
ll fy[] = {0, 1, 1, 1, 0, -1, -1, -1};
vector<ll>a,b,c;
map<ll,ll>m1,m2,m3;

/************************************************/

void Execute()
{
      int n;
      cin >> n;
      std::vector<int> dp(3);
      FOR(day,1,n)
      {
        std::vector<int> v(3);
        std::vector<int> new_dp(3,0);
        FOR(i,0,2)
        {
          cin >> v[i];
        }



      FOR(i,0,2)
      {
        FOR(j,0,2)
        {
          if(i!=j)
          {
            new_dp[j] = max(new_dp[j],dp[i]+v[j]);
          }
        }
      }


      dp=new_dp;
    }
      cout << max({dp[0],dp[1],dp[2]}) << endl;

}

int32_t main()
{
  //  #ifndef ONLINE_JUDGE
    //freopen("atomm.txt", "r", stdin);
    //#endif

    FAST();
    //CASES

        Execute();

}


Measured memory_bytes: 256
fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let c: i32 = read();

    if a == b {
        println!("{}", c);
    } else if b == c {
        println!("{}", a);
    } else {
        println!("{}", b)
    }
}

// 以下関数

use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 10e9 as u64 + 7;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

ll extGCD(ll a, ll b, ll &x, ll &y){
    if(b == 0){
        x = 1;
        y = 0;
        return a;
    }
    ll g = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return g;
}

ll MOD = 998244353;

vector<ll> mfact(1,1);

ll minv(ll a){
    ll x;ll y;
    extGCD(a, MOD, x, y);
    if(x<0){
        x+= ((-x)/MOD+1)*MOD;
        x %= MOD;
    }
    return x;
}

ll mpow(ll a,ll b){
    ll res = 1;
    while(b > 0){
        if(b%2==1)res=(res*a)%MOD;
        b/=2;
        a = (a*a)%MOD;
    }
    return res;
}

ll mfactorial(ll a){
    if(mfact.size()-1 >= a)return mfact[a];
    for(ll i = mfact.size();i<=a;i++){
        mfact.push_back((i * mfact[i-1])%MOD);
    }
    return mfact[a];
}

ll mcomb(ll n, ll r){
    return (((mfactorial(n) * minv(mfactorial(r)))%MOD) * minv(mfactorial(n-r)))%MOD;
}

int main(){
    int N,M,K;
    cin>>N>>M>>K;
    ll res = 0;
    for(int n = 0;n <= K;n++){
        ll psN = N - n;
        ll add = (M * mpow(M-1,psN-1) % MOD) * mcomb(N-1,n) % MOD;
        res = (res + add) % MOD;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 5224
#include <iostream>
#include <vector>
using namespace std;

void printStar( int n )
{
    if ( n == 0 ) cout << "-";
    for ( int i = 0; i < n; i++ ) cout << "*";
    cout << endl;
}

int main( void )
{
    int n, k;

    while ( cin >> n && n )
    {
        vector <int> D( 10001, 0 );
        int maxK = 0;

        for ( int i = 0; i < n; i++ )
        {
            cin >> k;
            D[k]++;
            maxK = max( maxK, k );
        }

        for ( int i = 0; i <= maxK; i++ )
        {
            printStar( D[i] );
        }
    }

    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

ll cul[100005];
ll just[100005];

ll fastpow(ll a, ll n, ll mod = MOD) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  ll N, K;
  scanf("%lld %lld", &N, &K);

  for (ll i = 1; i <= K; i++) {
    ll v = fastpow(K / i, N);
    // cout << i << "," << v << endl;
    cul[i] = v;
  }

  ll ans = 0;
  for (ll i = K; i >= 1; i--) {
    ll just_count = cul[i];
    for (ll j = i * 2; j <= K; j += i) {
      just_count -= just[j];
    }
    just_count = ((just_count % MOD) + MOD) % MOD;
    ans = (ans + i * just_count) % MOD;
    just[i] = just_count;
  }

  cout << ans << endl;
}

// 3 2
// 9

// 3 200
// 10813692

// 100000 100000
// 742202979


Measured memory_bytes: 5328
#include <bits/stdc++.h>

using namespace std;

#define int long long

struct Dijkstra {
	struct E {
		int t; // to
		int c; // cost
		E(int t_, int c_) : t(t_), c(c_) {}
//		E(void) : t(0), c(0) {}
		inline bool operator<(const E a) const {
			return c < a.c;
		}
		inline bool operator>(const E a) const {
			return a < (*this);
		}
	};
	int n; // num of vertex
	vector<vector<E>> es; // edges list
	Dijkstra(int sz) : n(sz), es(sz) {}
    void add_edge(int s, int t, int cost) {
        es[s].push_back(E(t, cost));
    }
    auto calc(int s, int inf) {
        vector<int> res(es.size(), inf);
        priority_queue<E, vector<E>, greater<E>> q;
        q.emplace(s, 0);
        while (!q.empty()) {
            auto a = q.top();
            q.pop();
            if (a.c >= res[a.t]) continue;
            res[a.t] = a.c;
            for (auto& p : es[a.t]) {
                if (p.c == inf) continue;
                if (a.c + p.c < res[p.t]) q.emplace(p.t, a.c + p.c);
            }
        }
        return res;
    }
};

signed main()
{
	int n, m, S, T;
	cin >> n >> m >> S >> T;
	S--, T--;
	Dijkstra EN(n), SN(n);
	for (int i = 0; i < m; i++) {
		int v, u, x, y;
		cin >> v >> u >> x >> y;
		v--, u--;
		EN.add_edge(u, v, x);
		EN.add_edge(v, u, x);
		SN.add_edge(u, v, y);
		SN.add_edge(v, u, y);
	}
	auto en = EN.calc(S, LLONG_MAX);
	auto sn = SN.calc(T, LLONG_MAX);
	vector<int> res(n);
	for (int i = 0; i < n; i++) res[i] = en[i] + sn[i];
	for (int i = n - 2; i >= 0; i--) res[i] = min(res[i], res[i + 1]);
	for (int i = 0; i < n; i++) cout << (int)1e15 - res[i] << endl;
}
/*
	verified on 2018/5/13
	https://atcoder.jp/contests/soundhound2018-summer-qual/tasks/soundhound2018_summer_qual_d
*/

Measured memory_bytes: 19000
#include<bits/stdc++.h>
using namespace std;

int main(){
  long a,b;
  cin >> a >> b;
  long num = 1,result = 0;
  for(long i = 0;i < 50;i++){
    long m = b % (2*num),n = b;
    long d;
    if(m+1-num > 0){
      d = num*(n/num/2) + (m+1-num);
    }
    else{
      d  = num*(n/num/2);
    }
    
    m = a % (2*num);
    n = a;
    long c;
    if(m+1-num > 0){
      c = num*(n/num/2) + (m+1-num);
    }
    else{
      c = num*(n/num/2);
    }
    if(a>>i & 1){
      c--;
    }
    //cout << d << ' ' << c << ' ' << i+1 << endl;
    if((d-c) % 2 == 1){
      result += num;
    }
    num *= 2;
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

long long modnum = 1e9 + 7;

long long modinv(long long dividend, long long divisor){
    long long b = modnum, u = 1, v = 0;
    while (b) {
        long long t = divisor / b;
        divisor -= t * b; std::swap(divisor, b);
        u -= t * v; std::swap(u, v);
    }
    u %= modnum; 
    if (u < 0) u += modnum;
    long long ans = dividend * u % modnum;
    return ans;
}

int main(){
    int N, K;
    std::cin >> N >> K;
    std::vector< int > P;
    std::vector< int > M;
    int zero_cnt = 0;
    for(int i=0; i<N; i++){
        int tmp;
        std::cin >> tmp;
        if(tmp > 0){
            P.push_back(tmp);
        }else if(tmp < 0){
            M.push_back(tmp);
        }else{
            zero_cnt++;
        }
    }
    
    if(N - K < zero_cnt){
        std::cout << 0 << std::endl;
        return 0;
    }
    
    sort(P.begin(), P.end());
    sort(M.begin(), M.end());
    
    std::vector< int > new_A;
    std::vector< bool > new_A_pm;
    for(int i=0; i<(int)P.size(); i++){
        new_A.push_back(P[i]);
        new_A_pm.push_back(false);
    }
    for(int i=0; i<(int)M.size(); i++){
        new_A.push_back(M[i] * (-1));
        new_A_pm.push_back(true);
    }
    
    long long max = 1;
    bool max_pm = false;
    for(int i=0; i<K; i++){
        max = (max * new_A[i]) % modnum;
        max_pm = max_pm ^ new_A_pm[i];
    }
    
    int a_index = 0;
    int b_index = K;
    long long cur = max;
    bool cur_pm = max_pm;
    long long tmpa = 1;
    long long tmpb = 1;
    while(b_index < new_A.size()){
        tmpa = tmpa * new_A[a_index];
        tmpb = tmpb * new_A[b_index];
        cur_pm = cur_pm ^ new_A_pm[a_index] ^ new_A_pm[b_index];
        cur = modinv(cur, new_A[a_index]); a_index++;
        cur = (cur * new_A[b_index]) % modnum; b_index++;
        if(cur_pm == false && max_pm == false){
            if(tmpa < tmpb){
                max = cur;
                max_pm = cur_pm;
            }
            tmpa = 1;
            tmpb = 1;
        }else if(cur_pm == true && max_pm == false){
        }else if(cur_pm == false && max_pm == true){
            max = cur;
            max_pm = cur_pm;
            tmpa = 1;
            tmpb = 1;
        }else if(cur_pm == true && max_pm == true){
            if(tmpa > tmpb){
                max = cur;
                max_pm = cur_pm;
            }
            tmpa = 1;
            tmpb = 1;
        }
    }
    
    if(max_pm && zero_cnt){
        std::cout << 0 << std::endl;
    }else if(max_pm){
        std::cout << modnum - max << std::endl;
    }else{
        std::cout << max << std::endl;
    }
    
    return 0;
}



Measured memory_bytes: 5596
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here! 
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        
        // board[i][j]: 迷路
        char[][] board = new char[h][w];
        for (int i = 0; i < h; i++) {
            String str = sc.next();
            for (int j = 0; j < w; j++) {
                board[i][j] = str.charAt(j);
            }
        }
        
        
        // 上下左右
        int[] dx = new int[]{1, 0, -1, 0};
        int[] dy = new int[]{0, 1, 0, -1};
        
        int max = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (board[i][j] == '#') continue;
                
                // visited[i][j]: 当該マスを既に通ったか否か
                boolean[][] visited = new boolean[h][w];
                
                Queue<int[]> que = new ArrayDeque<int[]>();
                que.add(new int[]{i, j, 0});
                visited[i][j] = true;
                while (!que.isEmpty()) {
                    int[] cur = que.poll();
                    int x = cur[0];
                    int y = cur[1];
                    int depth = cur[2];
                    
                    // 移動可能ならそのマスに深さ+1を配ってキューに入れる
                    for (int k = 0; k < 4; k++) {
                        int nx = x + dx[k];
                        int ny = y + dy[k];
                        int ndepth = depth + 1;
                        
                        if (0 <= nx && nx < h && 0 <= ny && ny < w &&
                            board[nx][ny] == '.' && !visited[nx][ny]) {
                            que.add(new int[]{nx, ny, ndepth});
                            visited[nx][ny] = true;
                            max = Math.max(max, ndepth);
                        }
                    }
                }
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 26760
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include<bits/stdc++.h>
using namespace std;
	typedef long long ll;
	const int maxn=100050;
	ll po[maxn];
	map<ll,ll>m;
	int main() {
		IOS
		ll i;
		for(i=1;i*i*i*i*i<=1e18;i++){
			m[i*i*i*i*i]=i;
			po[i]=i*i*i*i*i;
		}
		ll n;
		cin>>n;
		ll a,b;
		for(i=0;;i++){
			ll t1=po[i],t2,t3;
			t2=t1-n;//n=t1-t2;
			t3=abs(t2);
			if(m[t3]){//Èç¹ût3ÊÇ¸öÎå´ÎÃÝ 
				cout<<i<<" ";
				if(t2>=0)
					cout<<m[t3];
				else
					cout<<-m[t3];
				cout<<endl;
				return 0;
			}
			t1=-po[i];
			t2=t1-n;
			t3=abs(t2);
			if(m[t3]){//Èç¹ût3ÊÇ¸öÎå´ÎÃÝ 
				cout<<-i<<" ";
				if(t2>=0)
					cout<<m[t3];
				else
					cout<<-m[t3];
				cout<<endl;
				return 0;
			}
		}
		return 0;
	}

Measured memory_bytes: 3960
#include <iostream>

using namespace std;

int main()
{
    int n, i, a, b, min=1000000, max=-1000000, t;
    long long sum=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>t;
        if(t>max){
            max=t;
        }
        if(t<min){
            min=t;
        }
        sum+=t;
    }
    cout<<min<<" "<<max<<" "<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int h,w;cin>>h>>w;
    map<char,int> mp;
    rep(i,h)rep(j,w){
        char c;
        cin>>c;
        mp[c]++;
    }
    if(h%2==0&&w%2==0){
        for(auto& p:mp){
            if(p.second%4!=0){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
        return 0;
    }else if(h%2==0||w%2==0){
        int buf=(h%2==0)? h/2:w/2;
        int cou=0;
        for(auto& p:mp){
            if(p.second%4!=0&&p.second%2==0)cou++;
            else if(p.second%2!=0){
                cout<<"No"<<endl;
                return 0;
            }
        }
        if(cou<=buf){
            cout<<"Yes"<<endl;
            return 0;
        }
        else{
            cout<<"No"<<endl;
            return 0;
        }
    }else{
        int cou1=0,cou2=0;
        for(auto& p:mp){
            if(p.second%4==0)continue;
            else if(p.second%2==0&&p.second%4!=0)cou1++;
            else cou2++;
        }
        if(cou1>(w/2+h/2)||cou2!=1){
            cout<<"No"<<endl;
            return 0;
        }
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long int
#define ff first
#define ss second
#define u128 __int128
#define pb push_back
 
#define N 200010
#define MOD 1000000007


int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	string s, t;
	int c = 0;
	cin >> s >> t;
	for (int i = 0; i < 3; ++i)
	{
		if(s[i] == t[i])
			c++;
	}

	cout << c;
 	return 0;
}

Measured memory_bytes: 256
r = []
ring = list(str(input()) * 2)
ch = str(input())
for i in range(int(len(ring) / 2)):
    if ring[i : i + len(list(ch))] == list(ch):
        r.append("1")
if len(r) >= 1:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 5564
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

actions = []
paths = []
for y in range(H):
    for x in range(W):
        if y%2 == 0:
            paths.append((y, x))
        else:
            paths.append((y, W-x-1))

for i in range(H*W-1):
    y, x = paths[i]
    if A[y][x]%2 == 1:
        actions.append((paths[i][0]+1, paths[i][1]+1, paths[i+1][0]+1, paths[i+1][1]+1))
        ny, nx = paths[i+1]
        A[ny][nx] += 1

print(len(actions))
for a in actions:
    print(*a)


Measured memory_bytes: 48400
import heapq
 
_x, _y, _z, k = map(int, input().split())
aa = list(reversed(sorted(map(int, input().split()))))
bb = list(reversed(sorted(map(int, input().split()))))
cc = list(reversed(sorted(map(int, input().split()))))
 
ar = []
history = set()
 
 
def push(x, y, z):
    if (x, y, z) in history:
        pass
    else:
        v = aa[x] + bb[y] + cc[z]
        heapq.heappush(ar, (-v, x, y, z))
        history.add((x, y, z))
 
 
def pop():
    (v, x, y, z) = heapq.heappop(ar)
    return (-v, x, y, z)
 
 
push(0, 0, 0)
for _ in range(k):
    (total, x, y, z) = pop()
    print(total)
    if x + 1 < len(aa):
        push(x + 1, y, z)
    if y + 1 < len(bb):
        push(x, y + 1, z)
    if z + 1 < len(cc):
        push(x, y, z + 1)

Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;

struct Edge {
  int v, cap, rev, id;
};
typedef vector<vector<Edge> > Graph;

const int INF = 1<<28;
const int MAXN = 333;
int N, M, S, T;
int C[MAXN][MAXN];
Graph G;
bool vis[MAXN];

void add_edge(int from, int to, bool bi_dir, int id) {
  G[from].push_back((Edge){to, 1, G[to].size(), 0});
  G[to].push_back((Edge){from, 1, G[from].size() - 1, bi_dir ? 0 : id});
}

int dfs(int v, int dst, int f) {
  vis[v] = true;
  if (v == dst) return f;
  for (int i = 0; i < G[v].size(); ++i) {
    Edge &e = G[v][i];
    if (vis[e.v]) continue;
    if (e.cap == 0) continue;
    int d = dfs(e.v, dst, min(f, e.cap));
    if (d) {
      e.cap -= d;
      G[e.v][e.rev].cap += d;
      return d;
    }
  }
  return 0;
}

int max_flow(int s, int t) {
  int f = 0;
  while (1) {
    memset(vis, 0, sizeof(vis));
    int d = dfs(s, t, INF);
    if (d == 0) return f;
    f += d;
  }
}

int main() {
  while (cin >> N >> M) {
    memset(C, 0, sizeof(C));
    for (int i = 0; i < M; ++i) {
      int x, y;
      cin >> x >> y;
      --x; --y;
      C[x][y] = i + 1;
    }
    cin >> S >> T;
    --S; --T;

    G = Graph(N);
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        if (C[i][j]) {
          add_edge(i, j, C[j][i], C[i][j]);
        }
      }
    }

    int res = max_flow(S, T);
    cout << res << endl;
    vector<int> ids;
    for (int v = 0; v < N; ++v) {
      for (int i = 0; i < G[v].size(); ++i) {
        const Edge &e = G[v][i];
        if (e.id > 0 && e.cap == 0) {
          ids.push_back(e.id);
        }
      }
    }
    cout << ids.size() << endl;
    for (int i = 0; i < ids.size(); ++i) {
      cout << ids[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1728
n,a=map(int,input().split())
x=list(map(int,input().split()))

xsum=max(max(x),a)*n
dp=[[[0]*(xsum+1) for i in range(n+1)] for ii in range(n+1)]

dp[0][0][0]=1

for j in range(1,n+1):
    for k in range(0,n+1):    
        for s in range(0,xsum+1):    
            if s<x[j-1] :
                dp[j][k][s]=dp[j-1][k][s]
            elif s>=x[j-1] and k>=1:
                dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-x[j-1]]
            else:
                dp[j][k][s]=0
dsum=0
for k in range(1,n+1):
    dsum=dsum+dp[n][k][k*a]
print(dsum)
    


Measured memory_bytes: 93276
#include<stdio.h>
#include<limits.h>
 
 
int A[2000000];
int n;
 
int parent(int i){
    return i/2;
}
int left(int i){
  return 2*i;
}
  
int right(int i){
  return 2*i+1;
}
 
 
void maxHeapify(int i){
int l = left(i);
int r = right(i);
 int largest,temp;
  if( l <= n && A[l] > A[i]){
    largest = l;
  }
  else{
    largest = i;
  }
  if(r <= n && A[r] > A[largest]){
    largest = r;
  }
  if (largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(largest);
  }
}
 
void buildMaxHeap(){
  int i;
  for( i = n/2;i>0;i--){
    maxHeapify(i);
  }
}
 
void maxHeapInsert(int key){
    n = n + 1;
    A[n] = INT_MIN;
    heapIncreaseKey(n,key);
}
 
 
void heapIncreaseKey(int i,int key){
  int tmp;
  if (key < A[i]){
    return;
  }
  A[i] = key;
  while (i > 1 && A[parent(i)] < A[i]){
    tmp = A[i];
    A[i] = A[parent(i)];
    A[parent(i)]= tmp;
    i = parent(i);
  }
}
 
int heapExtractMax(){
  int max;
  if ( n < 1){
    return;
  }
  max = A[1];
  A[1] = A[n];
  n = n - 1;
  maxHeapify(1);
  return max;
}
 
 
int main(){
  int takahiro;
  char sekine[10];
  while(1){
    scanf("%s",sekine);
    if(sekine[2]=='s'){
      scanf("%d",&takahiro);
      maxHeapInsert(takahiro);
    }
    if(sekine[2]=='t'){
      printf("%d\n",heapExtractMax());
    }
    if(sekine[2]=='d'){
      break;
    }
  }
    return 0;
}

Measured memory_bytes: 4696
#include<stdio.h>
#include<stdlib.h>
#define k 10000
int main(){
unsigned short *A,*B;
int C[k+1];
int n,i,j;
scanf("%d",&n);
A=malloc(sizeof(short)*(n+1));
B=malloc(sizeof(short)*(n+1));
for(i=0;i<=k;i++)C[i]=0;
for(i=0;i<n;i++){
  scanf("%hu",&A[i+1]);
  C[A[i+1]]++;
}
for(i=1;i<=k;i++)C[i]=C[i]+C[i-1];
for(j=1;j<=n;j++){
  B[C[A[j]]]=A[j];
  C[A[j]]--;
}
for(i=1;i<=n;i++){
if(i==n){
printf("%d\n",B[i]);
break;
}
  printf("%d ",B[i]);
}
return 0;
}



Measured memory_bytes: 9708
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int num[15];

int main()
{
	int n;cin >> n;
	vector<int> v;
	REP(i,n)
	{
		int tmp;cin >> tmp;
		v.PB(tmp);
		num[tmp]++;
	}
	
	n++;
	v.PB(0);
	
	if(n > 24 || num[0] > 0 || num[12]  > 1)
	{
		cout << 0 << endl;
		return 0;
	}
	for(int i = 1;i <= 11;i++)
	{
		if(num[i] > 2)
		{
			cout << 0 << endl;
			return 0;
		}
	}
	if(num[1] > 0 || (num[12] > 0 && num[11] > 0))
	{
		cout << 1 << endl;
		return 0;
	}
	for(int i = 1;i >= 11;i++)
	{
		if(num[i] = 2 &&(num[i+1] > 0 ||num[i-1] > 0))
		{
			cout << 1 << endl;
			return 0;
		}
	}
	int ans = 0;
	for(int now = 0;now < (1 << n);now++)
	{
		vector<int> vv;
		REP(i,n)
		{
			if(now & (1 << i))
			{
				vv.PB(24 - v[i]);
			}
			else
			{
				vv.PB(v[i]);
			}
		}
				
		int ret =100;
		REP(i,n)
		{
			REP(j,n)
			{
				if(i == j)continue;
				int tmp = abs(vv[i] - vv[j]);
				ret = min(ret,min(tmp,24-tmp));
			}
		}
		ans = max(ans,ret);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main
{
	public static void main (String[] args) throws Exception
	{
		BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
		int k=Integer.parseInt(bu.readLine());
		long ans=0;
		ans=1000l*(k/500);
		k=k%500;
		ans+=(k/5)*5;
		System.out.print(ans);
	}
}

Measured memory_bytes: 21332
n = int(input())
ans = [0 for _ in range(10001)]
for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            v = i*i+j*j+k*k+i*j+j*k+k*i
            if v < 10001:
                ans[v] += 1

for i in range(n):
    print(ans[i+1])


Measured memory_bytes: 9156
using System;
class Program
{
  static void Main(string[] args)
	{
      	// スペース区切りの整数の入力
        string S = Console.ReadLine();
        if (S == "AAA" || S == "BBB")
        {
            Console.Write("No");
        }
        else
        {
            Console.Write("Yes");
        }
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;

int main() {
    int s;
    cin >> s;
    int ans=1;
    int x=s;
    while(1){
        if(s==1) break;
        else if(s%2==0) s=s/2;
        else s=s*3+1;
        ans++;
    }
    if(x==2) ans+=1;
    if(x==1) ans+=2;
    cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 256
/******************
*  Author: BD747  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
#include<bits/stdc++.h>
using namespace std;

int n,m,root;
vector<int> son[100005],par[100005];
bool u[100005];
int d[100005];
int p[100005];
int TM;

int rt(int x){
	if(par[x].size()==0){
		return x;
	}else{
		return rt(par[x][0]);
	}
}

bool cmp(int i,int j){
	return d[i]>d[j];
}

void topo(int x){
	++TM;
	u[x]=true;
	for(int i=0;i<son[x].size();i++){
		int y=son[x][i];
		if(!u[y]){
			topo(y);
		}
	}
	d[x]=++TM;
}

void dfs(int x){
	u[x]=true;
	sort(son[x].begin(),son[x].end(),cmp);
	for(int i=0;i<son[x].size();i++){
		int y=son[x][i];
		if(!u[y]){
			p[y]=x;
			dfs(y);
		}
	}
}

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>m;
	for(int i=1;i<=n+m-1;i++){
		int a,b;
		cin>>a>>b;
		son[a].push_back(b);
		par[b].push_back(a);
	}
	
	root=rt(1);
	d[root]=0;
	
	topo(root);
	memset(u,false,sizeof(u));
	dfs(root);
	
	for(int i=1;i<=n;i++){
		cout<<p[i]<<endl;
	}

	return 0;
}


Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;

int main() {
  vector<int> x(3);
  for (int i = 0; i < 3; i++) {
    cin >> x.at(i);
  }
  sort(x.begin(), x.end());
  for (int i = 0; i < 3; i++) {
    cout << x.at(i);
    if (i == 2) {
      cout << endl;
    }
    else {
      cout << " ";
    }
  }
}



Measured memory_bytes: 3128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class ATransfer {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int a, b, c; cin >> a >> b >> c;
      int p = min(a-b, c);
      cout << c-p << endl;

    }
};

signed main() {
  ATransfer solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_by_types(*value_types, delim=" "):
    return tuple(
        [t(x) for t, x in zip(value_types, input().rstrip("\n").split(delim))])


def main():
    n, m = get_next_ints()
    ac_count = 0
    wa_count = 0

    from collections import defaultdict
    ac_cache = defaultdict(int)
    wa_cache = defaultdict(int)
    ac_count = 0
    wa_count = 0
    wa = 0
    for i in range(m):

        p, result = get_next_by_types(int, str)

        if ac_cache[p] == 0:
            if result == 'AC':

                ac_cache[p] = 1
                ac_count += 1
                wa_count += wa_cache[p]
                wa = 0
            else:
                wa_cache[p] += 1
    print(ac_count, wa_count)


if __name__ == '__main__':
    main()
if __name__ == '__jupyter__':
    import doctest
    print(doctest.testmod())

Measured memory_bytes: 21588