akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}


/*
    Max_Prime以下の素数をprimes[]に格納
*/

const int Max_Prime = 1000000;
vector<int> tmp_primes;
vector<int> primes;

void PrimeInit() {
    rep(i,Max_Prime-1){
        tmp_primes.push_back(i+2);
    }

    int rem = Max_Prime - 1;
    int count = 0;
    while(rem>0){
        if(tmp_primes[0]*tmp_primes[0] > Max_Prime){
            rep(i,rem){
                primes.push_back(tmp_primes[i]);
                count++;
            }
            break;
        }
        primes.push_back(tmp_primes[0]);
        count++;
        int count2 = 0;
        srep(i,1,rem){
            if(tmp_primes[i] % primes[count-1] != 0){
                tmp_primes[count2] = tmp_primes[i];
                count2++;
            }
        }
        rem = count2;
    }
}

int main(){
    PrimeInit();

    int x;
    cin >> x;

    int ans = -1;

    rep(i,primes.size()){
        if(primes[i] >= x){
            ans = primes[i];
            break;
        }
    }

    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 6128
N,M,Q=map(int,input().split())
L = []
for i in range(Q):
  L.append(list(map(int, input().split())))
  L[i][0]-=1
  L[i][1]-=1
 
import itertools
l =list(range(1,M+1))
v=list(itertools.combinations_with_replacement(l,N))
ans=0
for arr in v:
  score=0
  for a,b,c,d in L:
    if (arr[b] - arr[a])==c:      
      score+=d
  ans=max(ans,score)
print(ans)

Measured memory_bytes: 84692
from numpy import cumsum
N=int(input())
A1=cumsum(list(map(int,input().split(' '))))
A2=cumsum(list(map(int,input().split(' '))))
ans = 0
for i in range(N):
    if i==0:
        tmp = A1[i]+A2[-1]
    else:
        tmp = A1[i]+A2[-1]-A2[i-1]
    ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 12508
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e3 + 100, INF = 1e9 + 10, MOD = 1e9 + 7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll n, a, b, c, d, dp[SIZE][2];
vector<ll> fact;

void input() {
    cin >> n >> a >> b >> c >> d;
}

ll pw(ll a, ll b, ll md) { ll res = 1; while (b) { if (b & 1) { res = (a*res) % md; }a = (a*a) % md; b >>= 1; }return(res); }

ll pick(ll mn, ll am) {
    return (fact[mn] * pw(fact[am], MOD - 2, MOD)) % MOD;
}
void sol() {
    dp[0][0] = 1;

    fact.push_back(1);
    for (int i = 1; i <= n + 2; i++) fact.push_back((fact.back() * i) % MOD);

    ll ind = 0;
    for (int cur = a; cur <= b; cur++) {
        ind = !ind;
        for (int i = 0; i <= n; i++) dp[i][ind] = dp[i][!ind];

        for (int j = c; j <= d; j++) {
            for (int i = n; i >= 0; i--) {
                ll amount = cur * j;
                if (i - amount >= 0) {
                    dp[i][ind] += ((dp[i - amount][!ind] * (pw(pw(fact[cur], MOD - 2, MOD), j, MOD)) % MOD) % MOD * pw(fact[j], MOD - 2, MOD)) % MOD;
                    dp[i][ind] %= MOD;
                }
                else {
                    break;
                }
            }
        }
    }

    cout << (dp[n][ind] * fact[n]) % MOD;
}

int main()
{
    fastInp;

    ll t = 1;

    while (t--) {
        input();
        sol();
    }

    return 0;
}

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

int main(){
    int cnt = 1;
    while (true) {
        int a, b; cin >> a >> b;
        if (a == 0 && b == 0) break;
        if (a > b) swap(a,b);
        cout << a << " " << b << endl;
    }
    return 0;

}


Measured memory_bytes: 2996
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()
a = ''

for i in range(len(s)):
    if s[i] == a:
        print('Bad')
        exit()
    a = s[i]

print('Good')

Measured memory_bytes: 38384
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm> // sort
#include <map> // pair

using namespace std;

int main(){
    int64_t N,Q;

    cin >> N;
    int64_t countnum[100002];
    int64_t sum=0;

    for(int i=0;i<100002;++i){
        countnum[i]=0;
    }

    for(int64_t i=0;i<N;i++){
        int64_t temp;
        cin >> temp;
        sum+=temp;
        countnum[temp]+=1;
    }

    cin >> Q;

    int64_t Bi[100001];
    int64_t Ci[100001];
    for(int64_t i=0;i<Q;i++){
        cin >> Bi[i]>>Ci[i];
    }


    for(int64_t i=0;i<Q;++i){
        sum += (Ci[i]-Bi[i])*countnum[Bi[i]];

        cout<<sum <<endl;
        countnum[Ci[i]] +=countnum[Bi[i]];
        countnum[Bi[i]] =0;

    }


}



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

typedef long long ll;
typedef vector<int> vi;

const double PI=acos(-1.0);
const ll MOD=1000000007;

string S; ll dp[100010][13];
int input()
{
    cin>>S;
}

int solve()
{
    int N=S.length();
    // for(int i=0;i<13;++i) dp[1][i]=0ll;
    // if(S[0]=='?'){
    //     for(int j=0;j<10;++j){
    //         dp[1][j]=1ll;
    //     }
    // } else {
    //     int j=S[1]-'0';
    //     dp[1][j]=1ll;
    // }
    dp[0][0]=1ll;

    for(int i=0;i<N;++i){
        if(S[i]=='?'){
            for(int j=0;j<13;++j){
                for(int k=0;k<10;++k){
                   dp[i+1][(j*10+k)%13]+=dp[i][j];
                   dp[i+1][(j*10+k)%13]%=MOD;
               }
           }
        } else {
            int k=S[i]-'0';
            for(int j=0;j<13;++j){
                dp[i+1][(j*10+k)%13]+=dp[i][j];
                dp[i+1][(j*10+k)%13]%=MOD;
            }
        }
    }
    cout<<dp[N][5]<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 10704
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
#include<atcoder/lazysegtree>
#include<atcoder/modint>
using namespace std;
using namespace atcoder;
using ll = modint998244353;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
struct S{
  ll v;
  int len;
};
struct F{
  int x;
  int t;
};
const int MAX = 2e5+5;
vector<ll> vls(MAX);
S op(S l,S r){
  ll tn = 10;
  return S{
    l.v*tn.pow(r.len)+r.v,l.len+r.len
  };
}
S e(){return S{0,0};}
S mapping(F l, S r){
  if(l.t==0){
    return r;
  }
  r.v = vls[r.len]*l.x;
  return r;
}
F composition(F l,F r){
  if(l.t<r.t) return r;
  else return l;
}
F id(){return F{1,0};}
signed main(){
  init_io();
  int n,q;
  cin >> n >> q;
  vector<int> l(q),r(q),d(q);
  for(int i=0;i<q;i++){
    cin >> l[i] >> r[i] >> d[i];
  }
  ll p = 1;
  for(int i=1;i<MAX;i++){
    vls[i] = p;
    p = p*10+1;
  }
  vector<S> tmp;
  for(int i=0;i<n;i++){
    tmp.push_back(S{1,1});
  }
  lazy_segtree<S, op, e, F, mapping, composition, id> seg(tmp);
  for(int i=0;i<q;i++){
    seg.apply(l[i]-1,r[i],F{d[i],i+1});
   cout << seg.all_prod().v.val() << endl;
  }
}


Measured memory_bytes: 14236
#include <stdio.h>
int main()
{
    int n, a[200001], i;
    scanf("%d", &n);
    for(i = 0; i < n; i++) scanf("%d", &a[i]);

    printf("%d", a[n-1]);

    for(i = n-3; i >= 0; i-=2) printf(" %d", a[i]);

    if(n&1) for (i = 1; i <= n-2; i+=2) printf(" %d", a[i]);
    else for(i = 0; i <= n-2; i+=2) printf(" %d", a[i]);
}


Measured memory_bytes: 2816
n=int(input())
a=list(map(int,input().split()))
j=0
c=0
s=a[0]
for i in range(n):
    if j<i:
        j=i
        s=a[i]
    if j<n-1:
        while s&a[j+1]==0:
            s|=a[j+1]
            j+=1
            if j==n-1:
                break
    c+=j-i+1
    s^=a[i]
print(c)

Measured memory_bytes: 24840
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#include <bitset>
#define INF 100000000000
#define N 1000000007
#define ll long long
using namespace std;

int main(){
    ll n; cin>>n;
    
    ll ans=1;
    map<ll,int> mp;
    
    for(ll i=0; i<n; i++){
        ll p; cin>>p;
        if(p==0) ans*=3-mp[0];
        else ans*=mp[p-1]-mp[p];
        mp[p]++;
        ans%=N;
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 9880
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int h,w;
  cin >> h >> w;
  
  int maze[h][w];
  char input;
  rep(i,h){
    rep(j,w){
      cin >> input;
      if(input=='.'){
        maze[i][j]=0;
      }
      else maze[i][j]=-1;
    }
  }
  
  int ans=0;
  rep(i,h){//各スタート地点に対して最大値を計算していく
    rep(j,w){
      if(maze[i][j]==-1)continue; //壁スタートはスキップ
      
      int target[h][w];
      memcpy(target, maze , sizeof(maze));//計算用迷路作成
      
      target[i][j]=1; // スタートは1にする、答えは-1して返すこと
      
      bool exist_zero = true;
      while(exist_zero){ //0がある限り全マス計算し続ける
        exist_zero = false;
        rep(i,h){
          rep(j,w){
            if(target[i][j]==0){//周囲のマスで数値を探す
              exist_zero = true;
              int nei = 99999;
              if(i!=0){
                if(target[i-1][j]>0)
                  nei = min(target[i-1][j]+1,nei);
              }
              if(i!=h-1){
                if(target[i+1][j]>0)
                  nei = min(target[i+1][j]+1,nei);
              }
              if(j!=0){
                if(target[i][j-1]>0)
                  nei = min(target[i][j-1]+1,nei);
              }
              if(j!=w-1){
                if(target[i][j+1]>0)
                  nei = min(target[i][j+1]+1,nei);
              }
              
              if(nei!=99999){
                target[i][j]=nei;
                ans = max(ans,nei);
              }
            }
          }
        }
      }
      
      /*デバッグ用配列表示プログラム
  rep(i,h){
    rep(j,w){
      cout << target[i][j];
    }
    cout << endl;
  }
  */
    }
  }
  cout << ans-1 << endl;
  
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

#define N_MAX 310

typedef long long int lli;

int N, M, L;
lli edge[N_MAX][N_MAX];
int refill_table[N_MAX][N_MAX];

void make_table(int start)
{
	int *refill = refill_table[start];
	fill(refill, refill + N_MAX, -1);

	priority_queue<pair<lli, int> > q;
	queue<pair<lli, int> > q_next;
	q.push(make_pair(0, start));
	int cnt = 0;
	while (true){
		while (!q.empty()){
			pair<lli, int> p = q.top(); q.pop();
			lli len = -p.first; int cur = p.second;
			if (-1 != refill[cur]) continue;
			refill[cur] = cnt;
			for (int i = 0; i < N_MAX; i++){
				if (-1 != edge[cur][i] && -1 == refill[i]){
					if (edge[cur][i] + len <= L){
						q.push(make_pair(-(edge[cur][i] + len), i));
					}
					else if (edge[cur][i] <= L) {
						q_next.push(make_pair(-edge[cur][i], i));
					}
				}
			}
		}

		if (q_next.empty()){
			break;
		}
		while (!q_next.empty()){
			q.push(q_next.front());
			q_next.pop();
		}
		cnt++;
	}


	return;
}


void solv()
{
	scanf("%d%d%d", &N, &M, &L);
	for (int i = 0; i < N_MAX; i++){
		fill(edge[i], edge[i] + N_MAX, -1);
	}
	for (int i = 0; i < M; i++){
		int A, B, C;
		scanf("%d%d%d", &A, &B, &C);
		edge[A][B] = edge[B][A] = C;
	}

	for (int i = 0; i <= N; i++){
		make_table(i);
	}

	int Q;
	scanf("%d", &Q);
	for (int i = 0; i < Q; i++){
		int s, t;
		scanf("%d%d", &s, &t);
		printf("%d\n", refill_table[s][t]);
	}

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
#define int long long
signed main(void){
    int a,b; cin>>a>>b;
    double x = (a+b)/2.0;
    int y = x;
    if(x != double(y)) cout<<"IMPOSSIBLE"<<endl;
    else cout<<y<<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;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  vector<int> sum(n + 1);
  sum[0] = 0;
  rep(i, n) {
    cin >> p[i];
    p[i]++;
    sum[i + 1] = sum[i] + p[i];
  }
  int mx = 0;
  for (int i = 0; i + k < n + 1; i++){
    mx = max(mx, sum[i + k]- sum[i]);
  }
  double ans = mx;
  ans /= 2;
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main
{

	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int a[]=new int[n];
		for (int i = 0; i < a.length; i++)
		{
			a[i]=in.nextInt();
		}
		for (int i = a.length-1; i >=0 ; i--)
		{
			
			if(i==0)
				System.out.print(a[i]);
			else
				System.out.print(a[i]+" ");
		}
		System.out.println("");
		
		

	}

}

Measured memory_bytes: 26268
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

sx, sy, tx, ty = MAP()

ans = []
for i in range(2):
	dx, dy = tx-sx, ty-sy
	if i==1: ans.append("L")
	ans.extend(["U"]*(dy+i)+["R"]*(dx+i))
	if i==1: ans.extend(["D","R"])
	ans.extend(["D"]*(dy+i)+["L"]*(dx+i))
	if i==1: ans.append("U")
	#print(ans)

print(''.join(ans))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> A(N);
  
  for (int i = 0; i < N; i++){
    string S;
    int P;
    cin >> S >> P;
    A.at(i) = make_tuple(S, 100-P, i+1);
  }
  
  sort(A.begin(), A.end());
  
  for (tuple<string, int, int> x : A){
    int ans = get<2>(x);
    cout << ans << endl;
  } 
}

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

int main() {
  int n; cin >> n;
  vector<int> v(n);
  vector<int> l(n);
  vector<int> r(n);

  for(int i=0;i<n;i++)
    cin >> v[i];

  l[0] = v[0];
  for(int i=1;i<n;i++){
    int a = l[i-1], b = v[i];
    while(1){
      if(a<b){
        int buf = a;
        a = b;
        b = buf;
      }
      if(b==0) break;
      a%=b;
    }
    l[i] = a;
  }

  r[n-1] = v[n-1];
  for(int i=1;i<n;i++){
    int a = r[n-i], b = v[n-i-1];
    while(1){
      if(a<b){
        int buf = a;
        a = b;
        b = buf;
      }
      if(b==0) break;
      a%=b;
    }
    r[n-i-1] = a;
  }

  int max = 0;
  for(int i=0;i<n;i++){
    if( i == 0 ){
      int a = r[i+1];
      if(max<a) max = a;
    }else if( i == n-1 ){
      int a = l[i-1];
      if(max<a) max = a;
    }else{
      int a = l[i-1], b = r[i+1];
      while(1){
        if(a<b){
          int buf = a;
          a = b;
          b = buf;
        }
        if(b==0) break;
        a%=b;
      }
      if(max<a) max = a;
    }
  }

  cout << max << endl;

  return 0;
}

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

int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	s+='?';
	int ans=0;
	for(int i=0;i<n;i++){
		if(s[i+1]!=s[i]) ans++; 
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    bool solve() {
        input();
        int max_D = 101;
        vector<int> v(max_D);
        int N, Q;
        cin >> N >> Q;
        if(N == 0) return false;
        for (int i = 0; i < N; ++i) {
            int M;
            cin >> M;
            for (int j = 0; j < M; ++j) {
                int tmp;
                cin >> tmp;
                v[tmp]++;
            }
        }
        int max_v = -1;
        int max_key = -1;

        for(int i = 0; i < max_D; ++i){
            if(v[i] > max_v){
                max_v = v[i];
                max_key = i;
            }
        }

        cout << (max_v < Q ? 0 : max_key) << endl;
        return true;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    while (Solve().solve()) {};


    return 0;
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
//const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll NN = N;
    vector<ll> prime;
    for(int i=2;i*i<=NN;i++){
        if(NN % i == 0){
            prime.push_back(i);
            while(NN % i == 0) NN /= i;
        }
    }
    if(NN != 1) prime.push_back(NN);

    int M = prime.size();
    ll ans = 0;
    for(int bits=0;bits<(1LL<<M);bits++){
        int cnt = __builtin_popcount(bits);
        ll tmp = 1;
        REP(j, M) if((bits >> j) & 1) tmp *= prime[j];
        if(cnt % 2 == 0) ans += N / tmp;
        else ans -= N / tmp;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;

constexpr int INF = 1 << 25;
constexpr int MOD = 1000000007;

int main() {
  int n, q;
  cin >> n;
  vector<int> S(n);
  REP(i, n) cin >> S[i];
  cin >> q;
  vector<int> T(q);
  REP(i, n) cin >> T[i];
  
  int cnt = 0;
  REP(i, q) {
    REP(j, n) {
      if (T[i] == S[j]) {
        ++cnt;
        break;
      }
    }
  }

  cout << cnt << endl;
}



Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <limits>
#include <algorithm>

int main()
{
  int H, W, h, w;
  std::cin >> H >> W >> h >> w;
  std::cout << (H - h) * (W - w) << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

constexpr int MAX_SIZE = 250 + 1;
int heap[MAX_SIZE];

int parent(int i) {return i / 2;}
int left(int i) {return 2 * i;}
int right(int i) {return 2 * i + 1;}

int main() {
    int n;
    std::cin >> n;
    for (int i = 1; i <= n; i++) {
        std::cin >> heap[i];
    }

    for(int i = 1; i <= n; i++) {
        std::printf("node %d: key = %d, ", i, heap[i]);
        if (parent(i) > 0) std::printf("parent key = %d, ", heap[parent(i)]);
        if (left(i) <= n) std::printf("left key = %d, ", heap[left(i)]);
        if (right(i) <= n) std::printf("right key = %d, ", heap[right(i)]);
        std::cout << std::endl;
    }


}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    multiset<int> s;
    rep(i, N){
        int A; cin >> A;
        s.insert(-A);
    }
    int ans = 0;
    multiset<int>::iterator it;
    for(it = s.begin(); sz(s);){
        int A = -(*it);
        s.erase(it);
        rep3(j, 29, 0){
            if(A & (1<<j)){
                int B = -((1<<(j+1))-A);
                if(s.count(B)){
                    s.erase(s.find(B));
                    ans++;
                }
                break;
            }
        }
        it = s.begin();
    }
    cout << ans << endl;
}

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

using namespace std;


int main()
{
    int n,a,ans=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        while(!(a%2))a/=2,ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int a[11],b;
	for(int y=0;y<10;y++){
		cin>>a[y];
	}
	for(int y=0;y<10;y++){
		for(int i=y+1;i<10;i++){
			if(a[y]<a[i]){
				b=a[y];
				a[y]=a[i];
				a[i]=b;
			}
		}
	}
	for(int y=0;y<3;y++){
		cout<<a[y]<<endl;
	}
return 0;
}


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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int ans=0;
	
	if(b<=c){
		c-=b;
		ans=ans+(b*2);
		b=0;
		
	}
	else
	{
		ans=ans+b+c;
		c=0;
		b=0;
	}
	if(c<=a+1){
		ans+=c;
		
		
	}
	else
	{
		
		ans=ans+a+1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back

#define N 101
#define M 1000100
#define MOD 1000000007

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

	int n, w;
	cin >> n >> w;

	pair<int, int> wv[n];

	for (int i = 0; i < n; ++i)
	{
		cin >> wv[i].ff >> wv[i].ss;
	}

	ll dp[2][100010];
	fill(dp[0], dp[0] + 100010, 1e10);
	sort(wv, wv + n);
	dp[0][wv[0].ss] = wv[0].ff;
	// for (int i = 0; i <= w; ++i)
	// {
	// 	cout << dp[0][i] << " \n"[i == w];
	// }
	ll INF = 1e10;
	int p = 0;
	for(int i = 1; i < n; ++i)
	{
		int l = i & 1;
		for(int j = 0; j < 100010; ++j)
		{
			dp[l][j] = min(dp[!l][j], (j >= wv[i].ss ? wv[i].ff + dp[!l][j - wv[i].ss] : INF));
		}

		// cout << "\n";
	}
	ll ans = 0;

	for(int i = 0; i < 100010; ++i)
	{
		if(dp[(n + 1) & 1][i] <= w)
		{
			ans = i;
		}
		
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
N = int(input())

CSF = [list(map(int, input().strip().split())) for _ in range(N-1)]

for i in range(N):  # 出発駅
  time = 0
  for j in range(i, N-1):
    if time < CSF[j][1]:  # 開通まで待つ
      time = CSF[j][1]
    else:
      for k in range(CSF[j][2]):
        if (time + k) % CSF[j][2] == 0:
          time = time + k
          break
    time += CSF[j][0]
  print(time)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#define rep(i, a, b) for(int i = a; i < b; i++)
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  int sum = 0;
  rep(i, 0, n) cin >> v[i];
  rep(i, 0, n) {
    rep(j, 0, n) {
      if(i == j) continue;
      sum += v[i]*v[j];
    }
  }
  cout << sum / 2 << "\n";
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  int p;
  cin>>s>>t;
  p=s.size();
  for(int i=0;i<p;i++){
    if(s.at(i)==t.at(i)){
      if(i==p-1){
       cout<<"Yes"<<endl;
      }
      continue;
    }
    else{
      cout<<"No"<<endl;
      break;
    }
   
  }

}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

ll gcd(ll p,ll q){
  if(q==0){return p;}
  else{return gcd(q,p%q);}
}

ll lcm(ll p,ll q){
  return p*q/gcd(p,q);
}

ll quo(ll p,ll q){
  if(p%q==0){return p/q;}
  else{return (p+q)/q;}
}

int main(){
  ll a,b,c,d; cin>>a>>b>>c>>d;
  ll g=lcm(c,d);
  ll ac,ad,ag,bc,bd,bg;
  ac=quo(a,c);ad=quo(a,d);ag=quo(a,g);
  bc=b/c;bd=b/d;bg=b/g;
  
  //cout<<ac<<ad<<ag<<bc<<bd<<bg;
  cout<<(b-a)-(bc+bd+ag-ac-ad-bg);
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

signed main(){

	lli n;
	cin>>n;
	vector<lli> a(n);
	
	lli cnt=0;
	REP(i,0,n){
		cin>>a[i];
		if(a[i]<0)cnt++;
	}

	lli sum=0;
	lli minA = INF;
	lli flag=cnt%2;

	REP(i,0,n){
		sum += abs(a[i]);
		minA = min(minA,abs(a[i]));
	}

	if(flag)sum -= 2*minA;
	cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn = 1e5 + 10;
struct stu {
	int num, cnt;
	bool operator <(const stu& b)const {
		return cnt < b.cnt;
	}
};
int main() {
	int n; cin >> n;
	vector<stu> p;
	stu temp;
	for (int i = 0; i < n; i++) {
		cin >> temp.cnt;
		temp.num = i+1;
		p.push_back(temp);
	}
	sort(p.begin(),p.end());
	for (int i = 0; i < n; i++) {
		cout << p[i].num << " ";
	}
	cout << endl;
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << max(0LL, a - 2 * b) << endl;
}

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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,ans; string str;

int solve(){
    int a,b; cin>>a>>b;
    if(a>=1&&a<=9&&b>=1&&b<=9) cout<<a*b;
    else cout<<-1;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

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

int main(){
   string s;
   cin >> s;
   vector<char> a;
   a = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
   vector<int> num(26);
   for (int i=0;i<s.size();i++){
      num.at(s.at(i)-97)++;
   }
   for(int i=0;i<num.size();i++){
      if(num.at(i)==0){
         cout << a.at(i) << endl;
         return 0;
      }
   }
   cout << "None" << endl;
}

Measured memory_bytes: 512
N,Q = map(int,input().split())
S = input()
X = [list(map(int,input().split())) for _ in range(Q)]

L = [0]
for i,s in enumerate(S[1:]):
    if s == 'C' and S[i] == 'A':
        L.append(L[i]+1)
    else:
        L.append(L[i])

for x in X:
    print(L[x[1]-1]-L[x[0]-1])


Measured memory_bytes: 30712
/**
 * Contest : AtCoder Beginner Contest 163
 * Contest URL : https://atcoder.jp/contests/abc163/tasks
 * Problem : B - HomeWork
 * Problem URL : https://atcoder.jp/contests/abc163/tasks/abc163_b
 */

#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
using pii = pair < int, int >;

// This section is for Policy Based Data Structure, more precisely Ordered Set.
// All Functions of set works here, in addition we have order_of_key() and find_by_order() function. find_by_order() returns iterator
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
using namespace __gnu_pbds;

// 1. Custom Set
template < class T, class COMP >
using custom_set = tree < T, null_type, COMP, rb_tree_tag, tree_order_statistics_node_update >;

// 2. Ordered Set
template < class T >
using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;

// 3. Ordered Multi Set
// For storing multiple occurance of same value we need to use pair. In pair first value is our key and second is useless count variable.
// order_of_key(make_pair(key, 0)) returns first occurance of a value, order_of_key(make_pair(key, INT_MAX)) returns last occurance.
template < class T >
using ordered_multiset = tree < pair < T, int >, null_type, less < pair < T, int > >, rb_tree_tag, tree_order_statistics_node_update >;

// 4. Ordered Map
template < class T, class U >
using ordered_map = tree < T, U, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
// Policy End

void solve() {
	long n; int m; cin >> n >> m;
	vector < int > a (m);
	for (int & x : a) cin >> x;
	long sum = 0L;
	for (int x : a) {
		sum += x;
	}
	if (sum > n) cout << -1 << endl;
	else cout << (n - sum) << endl;
}

int main() {
	ios_base::sync_with_stdio (false);
	cin.tie (0); cout.tie (0);
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1000000007;

ll pd[2000010];
ll rd[2000010];
ll Ep(int x, int y){
  if(y == 0) return 1;
  if(y == 1) return x;
  ll r = Ep(x,y/2);
  if(y%2 == 1) return r *r%MOD *x%MOD;
  else return r *r%MOD;
}
ll Ftl(ll x){
  if(x == 1 || x == 0) return 1;
  if(pd[x] != 0) return pd[x];
  return pd[x] = Ftl(x-1) *x%MOD;
}
ll rFtl(ll x){
  if(x == 1 || x == 0) return 1;
  if(rd[x] != 0) return rd[x];
  return rd[x] = rFtl(x-1)*Ep(x,MOD-2)%MOD;
}
ll comb(ll m, ll n){
  if(m < n) return 0;
  return Ftl(m) *rFtl(n)%MOD *rFtl(m-n)%MOD;
}

int main(){
  int k;
  string s;
  cin >> k >> s;
  int k2 = s.size();
  ll ans = 0;
  for(int i=0; i<=k; ++i){
    ans += Ep(26,k-i) *Ep(25,i)%MOD *comb(k2+i-1,i)%MOD;
    ans %= MOD;
    //cout << ans << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 59120
#include <stdio.h>
#include <string.h>

#define STRING_LEN 15
#define ARRAY_SIZE 300

typedef struct {
  char str[STRING_LEN+1];
  int cnt;
} Str;

Str array[ARRAY_SIZE];
int array_top = 0;

void search_str(const char* buf, int point)
{
  for(int i = 0; i < array_top; i++) {
    if(strcmp(buf, array[i].str) == 0) {
      array[i].cnt += point;
      return;
    }
  }
  strncpy(array[array_top].str, buf, STRING_LEN+1);
  array[array_top].cnt += point;
  array_top++;
}

int find_largest()
{
  int largest = 0;
  for(int i = 0; i < array_top; i++) {
    if(largest < array[i].cnt) {
      largest = array[i].cnt;
    }
  }
  return largest;
}

int main()
{
  int n;
  char lf;
  scanf("%d%c", &n, &lf);

  memset(array, 0, sizeof(array));
  char buf[STRING_LEN+1];
  for(int i = 0; i < n; i++) {
    fgets(buf, sizeof(buf), stdin);
    search_str(buf, 1);
  }

  int m;
  scanf("%d%c", &m, &lf);
  for(int i = 0; i < m; i++) {
    fgets(buf, sizeof(buf), stdin);
    search_str(buf, -1);
  }

  printf("%d\n", find_largest());
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t i64;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  SortDesc(A);
  int alice = 0, bob = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      alice += A.at(i);
    } else {
      bob += A.at(i);
    }
  }

  cout << alice - bob << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        for (String x = in.next(); !x.equals("0"); x = in.next()) {
            int sum = 0;
            for (int i = 0; i < x.length(); i++) {
                sum += (x.charAt(i) - '0');
            }
            System.out.println(sum);
        }
    }
}

Measured memory_bytes: 26204
values = input()
W, H, x, y, r = [int(x) for x in values.split()]
flag = True

if x - r < 0 or x + r > W:
    flag = False
if y - r < 0 or y + r > H:
    flag = False

if flag:
    print('Yes')
else:
    print('No')

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

int main(){
    int num,a;
    cin>>num;
    a = num%10;
    switch (a)
    {
    case 0:
        cout<<"pon";
        break;
    case 1:
        cout<<"pon";
        break;
    case 2:
        cout<<"hon";
        break;
    case 3:
        cout<<"bon";
        break;
    case 4:
        cout<<"hon";
        break;
    case 5:
        cout<<"hon";
        break;
    case 6:
        cout<<"pon";
        break;
    case 7:
        cout<<"hon";
        break;
    case 8:
        cout<<"pon";
        break;
    case 9:
        cout<<"hon";
        break;
    }
    return 0;
}

Measured memory_bytes: 3620
import re
S = input()

goal = 'AKIHABARA'
li = [0,4,6,8]
flag = False
N=4
for i in range(1<<N):
    exli = []
    s = ''
    for j in range(N):
        if((i>>j&1)==1):
            exli.append(li[j])
    for ind,c in enumerate(goal):
        if(ind not in exli):
            s+=c
    if(s==S):
        flag = True
        break
if(flag):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3188
#include<stdio.h>

int main(void){
	int i,n,t1,t2,j,m,e;
	while(0==0)
	{
		scanf("%d",&n);
		if(n==0)break;

		for(i=0;i<n;i++){
			scanf("%d %d %d",&m,&e,&j);
			t1=m+e;  t2=m+e+j;
			if((m==100 || e==100 || j==100) || (t1>=180) || (t2>=240))
				printf("A\n");
			else if((t2>=210) || (t2>=150 && ( m>=80 || e>=80)))
				printf("B\n");
			else printf("C\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1012
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int H,W;
  cin>>H>>W;
  vector<string> data(H);
  for(int i=0;i<H;i++){
    cin>>data[i];
  }
  //vector<vector<int>>dist(H,vector<int>(W,10000));
  queue<pair<int,int>> que;
  int dx[4]={1,-1,0,0};
  int dy[4]={0,0,1,-1};
  //初期状態
  int cnt=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(data[i][j]=='#'){
        que.push(make_pair(i,j));
        cnt++;
      }
    }
  }

  //BFS
  int next_turn=0;
  int ans=0;
  while(!que.empty()){
    auto v=que.front();
    que.pop();
    cnt--;
    for(int i=0;i<4;i++){
      int nx=v.second+dx[i];
      int ny=v.first+dy[i];
      if(nx<0||nx>=W||ny<0||ny>=H)continue;
      if(data[ny][nx]=='#')continue;
      data[ny][nx]='#';
      que.push(make_pair(ny,nx));
      next_turn++;
    }
          if(cnt==0){
        cnt=next_turn;
        next_turn=0;
        ans++;
      }
  }
  cout<<ans-1<<endl;
}

Measured memory_bytes: 9488
N = int(input())
flowers = list(map(int,input().split(" ")))
ans = 0

def is_clear(l):
    for ele in l:
        if(ele!=0):
            return False
    return True

while(not is_clear(flowers)):
    tmp_l = []
    #水やり範囲を決める処理
    for i,flower in enumerate(flowers):
        if(flower!=0):
            tmp_l.append(i)
        else:
            if(len(tmp_l)!=0):
                break


    if(len(tmp_l)>=2):
        water = min(flowers[tmp_l[0]:tmp_l[-1]+1])
        for i in tmp_l:
            flowers[i] -= water
    else:
        water = flowers[tmp_l[0]]
        flowers[tmp_l[0]] -= water

    ans += water

print(ans)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> 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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	map<int, int> odd, even;
	int odd_first = 0, odd_second = 0;
	int odd_first_num = -1, odd_second_num = -1;
	int even_first = 0, even_second = 0;
	int even_first_num = -1, even_second_num = -1;
	rep(i,n){
		int v;
		cin >> v;
		if(i%2){
			++even[v];
			if(even[v] > even_first){
				if(even_first_num != v){
					even_second = even_first;
					even_second_num = even_first_num;
				}
				even_first = even[v];
				even_first_num = v;
			}
			else if(even[v] > even_second){
				even_second = even[v];
				even_second_num = v;
			}
		}
		else{
			++odd[v];
			if(odd[v] > odd_first){
				if(odd_first_num != v){
					odd_second = odd_first;
					odd_second_num = odd_first_num;
				}
				odd_first = odd[v];
				odd_first_num = v;
			}
			else if(odd[v] > odd_second){
				odd_second = odd[v];
				odd_second_num = v;
			}
		}
	}
	/*
	cout << odd_first_num << " " << odd_first << endl;
	cout << even_first_num << " " << even_first << endl;
	cout << odd_second << endl;
	cout << even_second << endl;
	*/
	int ans = 1e9;
	if(odd_first_num != even_first_num){
		chmin(ans, n - odd_first - even_first);
	}
	else{
		chmin(ans, n - odd_first - even_second);
		chmin(ans, n - odd_second - even_first);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8244
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define W(x) cout<<x<<endl;
#define Debug(x) cout<<"#DEBUG "<<x<<endl;
using namespace std;

int main()
{
    int n;
    cin>>n;
    string s[n];
    rep(i,n)
    {
        cin>>s[i];
    }
    int m;
    cin>>m;
    string k[m];
    rep(i,m)
    {
        cin>>k[i];
    }
    int fl[n],cnt[n+m],flag=0;
    rep(i,n)
    {
        fl[i]=0;
    }
    rep(i,n+m)
    {
        cnt[i]=0;
    }
    rep(i,n)
    {
        if(fl[i]==0)
        {
            fl[i]=1;
            cnt[flag]++;
            Rep(j,i+1,n)
            {
                if(s[i]==s[j])
                {
                    fl[j]=1;
                    cnt[flag]++;
                }
            }
            rep(l,m)
            {
                if(s[i]==k[l])
                {
                    cnt[flag]--;
                }
            }
            flag++;
        }
    }
    sort(cnt,cnt+n+m);
    W(cnt[n+m-1])
    return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    string s; cin >> s;
    
    ll sum = 0;
    rep(i, s.length()) {
        sum += ll(s[i] - '0');
    }
    
    cout << (sum % 9 == 0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3736
# coding: utf-8
# Here your code !
def mcg(a,b):
    if a==b:
        return a
    else:
        
        while a%b !=0:
            x = a%b
            a = b
            b = x
        return x

num =sorted(list(map(int,input().split(" "))))
print(mcg(num[0],num[1]))

Measured memory_bytes: 7676
#include <bits/stdc++.h>
#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++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  set<int> s;
  REP(i,n){
    int a;
    cin >> a;
    s.insert(a);
  }
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string N;
    cin >> N;
    if(N[0]==N[2]){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    ll q;
    cin >> q;
    vector<p> vp;
    for(ll i = 0; i < q; i++){
        ll c, d;
        cin >> c >> d;
        vp.push_back(p(c, d));
    }
    vector<bool> a(100010, true);
    a[1] = false;
    for(ll i = 3; i <= 100000; i++){
        if(i%2==0) {
            a[i] = false; continue;
        }
        for(ll j = 3; j <= sqrt(i); j+=2){
            if(i%j==0) {
                a[i] = false; break;
            }
        }
    }
    vector<ll> c(100010, 0);
    for(ll i = 1; i <= 100000; i++){
        if(i%2==0){
            c[i]=c[i-1]; continue;
        }
        if(a[(i+1)/2]==true && a[i]==true) c[i] = c[i-1]+1;
        else c[i] = c[i-1];
    }
    //for(ll i = 1; i <= 100; i++)
      //  cout << i << " " << c[i] << endl;
    for(ll i = 0; i < q; i++){
        ll s = vp[i].first, t = vp[i].second;
        cout << c[t]-c[s-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 2928
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {

//    	File file = new File("src/in.txt");
//    	Scanner sc = new Scanner(file);

    	Scanner sc = new Scanner(System.in);

    	String S = sc.next();

    	if(S.equals("ABC")) {
    		System.out.println("ARC");
    	} else {
    		System.out.println("ABC");
    	}
    }
}

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

#define ll long long 
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

int is_prime(int x)
{
    for(int i=2;i*i<=x;i++)
    {
        if(x%i==0)
         return 0;
    }
    return 1;
}
int main()
{
      int x;
      cin>>x;
      for(int i=x;i<=200000;i++)
      {
          if(is_prime(i))
          {
              cout<<i;
              break;
          }
      }
      return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main (){
    int N;
    int sum = 0;
    vector<int> B(100001);
    vector<int> A(100001);
    cin >> N;

    for (int a = 1; a < N ; a++){
        cin >> B.at(a);
    }
    B.at(0)=100000000;

    for (int b = 1; b < N; b++){
        if(B.at(b-1)>=B.at(b) ){
            A.at(b) = B.at(b);
            A.at(b + 1) = B.at(b);
        }else if(B.at(b-1)<B.at(b)){
            A.at(b) = B.at(b-1);
            A.at(b + 1) = B.at(b);

        }
    }

    for (int c = 1; c < N+1; c++){
        sum += A.at(c);
    }

    cout << sum << endl;
}

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

int main(){
  int N,A,B;
  cin>>N>>A>>B;
  
  int sum=0;
  for(int i=0;i<N;i++){
    int num=0;
    int K=i+1;
    for(int j=0;j<5;j++){
      num+=K%10;
      K=K/10;
      if(K==0)
        break;
    }
    if(num>=A&&num<=B)
      sum+=i+1;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
def selectionSort( nums ):
	cnt = 0
	for i in range( 0, len( nums ) ):
		mini = i
		for j in range( i , len( nums ) ):
			if nums[j] < nums[ mini ]:
				mini = j
		if mini != i:
			cnt += 1
			nums[i], nums[ mini ] = nums[ mini ], nums[i]

	print( " ".join( map( str, nums) ) )
	print( cnt )


n = int( input( ) )
nums = [ int( val ) for val in input( ).split( " " ) ]
selectionSort( nums )

Measured memory_bytes: 6728
use std::cmp;
use std::io::{self, Read};

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock());

    let s: String = sc.read().unwrap();
    let t: String = sc.read().unwrap();

    let mut table1: [char; 0x7f] = ['\0'; 0x7f];
    let mut table2: [char; 0x7f] = ['\0'; 0x7f];
    for (cs, ct) in s.chars().zip(t.chars()) {
        let is = cs as usize;
        let it = ct as usize;

        if table1[is] != '\0' && table1[is] != ct {
            println!("No");
            return;
        }

        if table2[it] != '\0' && table2[it] != cs {
            println!("No");
            return;
        }

        if table1[is] == '\0' {
            table1[is] = ct;
        }

        if table2[it] == '\0' {
            table2[it] = cs;
        }
    }

    println!("Yes");
}

struct Scanner<R: Read> {
    reader: R,
}

impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: std::str::FromStr>(&mut self) -> Option<T> {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse()
            .ok()
    }

    fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Option<Vec<T>> {
        (0..n).map(|_| self.read()).collect()
    }

    fn read_vec2d<T: std::str::FromStr>(&mut self, m: usize, n: usize) -> Option<Vec<Vec<T>>> {
        (0..m).map(|_| self.read_vec(n)).collect()
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int[][] array = new int[a][b];
        int count = 0;
        for(int i = 0; i < a; i++){
            for(int j = 0; j < b; j++){
                array[i][j] = sc.nextInt();
            }
        }
        double ans = 0;
        for(int i = 0; i < a - 1; i++){
            for(int j = i + 1; j < a; j++){
                for(int k = 0; k < b; k++){
                    ans = ans + Math.pow(array[i][k] - array[j][k], 2);
                }
                ans = Math.sqrt(ans);
                if(ans == (int)ans){
                    count++;
                }
                ans = 0;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21844