akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define taskname "A"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
int sum[maxn] , sum1[maxn];
string s , t;
int q;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP" , "r"))
        freopen(taskname".INP","r",stdin),
        freopen(taskname".OUT","w",stdout);
    cin >> s >> t;
    for(int i = 0 ; i < (int)s.size() ; ++i){
        sum[i + 1] += sum[i];
        sum[i + 1] += (s[i] == 'A');
    }
    for(int i = 0 ; i < (int)t.size() ; ++i){
        sum1[i + 1] += sum1[i];
        sum1[i + 1] += (t[i] == 'A');
    }
    cin >> q;
    while(q--){
        int a , b , c , d;
        cin >> a >> b >> c >> d;
        int Col1 = sum[b] - sum[a - 1];int Col2 = b - a + 1 - Col1;
        int Col3 = sum1[d] - sum1[c - 1];int Col4 = d - c + 1 - Col3;
        if(((Col1 - Col2) % 3 + 3) % 3 == (((Col3 - Col4) % 3 + 3)) % 3){
            cout << "YES\n";
        }else cout << "NO\n";
    }
}


Measured memory_bytes: 1744
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long N = scan.nextLong();
    int count = 0;
    for (int i = 1;i <= N;i++) {
      int a = scan.nextInt();
      if (a % 2 == 1 && i % 2 == 1) {
        count += 1;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 35828
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x = 0,a = 0,i = 0;
    string S;
    cin >> S;
    for(i = 0;i < S.size();i++){
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
            x++;
            if(a < x){
                a = x;
            }
        }
        else{
            x = 0;
        }
    }
    cout << a << endl;
}

Measured memory_bytes: 3596
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a[] = new int[3];
		a[0] = sc.nextInt();
		a[1] = sc.nextInt();
		a[2] = sc.nextInt();

		// 計算
		int result = 0;
		Arrays.sort(a);
		result = a[0] + a[1];
		
		// 出力
		System.out.println(result);
		
	}
}


Measured memory_bytes: 21844
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using PLL = pair<LL,LL>;
using VPI = vector<PII>;
using VPL = vector<PLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
	//i=m -> n-1(昇順)
#define RREP(i,m,n) for(int i=(m);i>=(n);i--)
	//i=m -> n(降順)

int main(){
  string s;
  cin >> s;
  int n = s.size();
  
  if(s[n-1] == 's'){
    cout << s << "es" << endl;
  }
  else{
    cout << s << "s" << endl;
  }
  
  return 0;
}


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

int gcd(int m, int n) {
	if (n == 0) {
		return m;
	}
	else {
		return gcd(n, m%n);
	}
}

int main(){
	int n;
	cin >> n;
	vector<int>x(n + 1);
	for (int i = 0;i < n + 1;i++) {
		cin >> x[i];
	}

	sort(x.begin(), x.end());
	vector<int>diff;
	for (int i = 0;i < n;i++) {
		if (x[i + 1] - x[i] != 0) {
			diff.push_back(x[i + 1] - x[i]);
		}
	}
	int ans = diff[0];
	for (int i = 0;i < diff.size();i++) {
		ans = gcd(ans, diff[i]);
	}
	cout << ans << endl;






	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define mod 1000000007

using namespace std;

int main()
{
    IOS;
    long double n,k;
    cin>>n>>k;
    long double ans=0;
    long double score=1,prob=1;
//    int cnt=0,l=2;


//    cout<<score<<" "<<cnt<<"\n";
    for(int y=1;y<=n;y++)
    {
        score=y;
        prob=1;
        while(score<k)
        {
            score*=2;
            prob*=0.5;
        }
        ans+=(1./n)*prob;
    }
    cout<<fixed<<setprecision(12)<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int g[101][101],a[101],f[101],n,i,j,k=1,m=0,num,sum=0;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&g[i][j]);
    }
  }
   
  a[0]=0;
  f[0]=1; 
  for(i=1;i<n;i++) f[i]=0;
   
  while(1){
    num=2000;
    for(i=0;i<k;i++){
      for(j=0;j<n;j++){
    if(g[a[i]][j]<num && g[a[i]][j]!=-1 && f[j]!=1){
      num=g[a[i]][j];
      m=j;
    }
      }
    }
     
    if(k!=n){
      a[k]=m;
      f[m]=1;
      sum+=num;
      k++;
    }
    else break;
  }
  printf("%d\n",sum);
   
  return 0;
}

Measured memory_bytes: 1820
n = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

li = []

for i in range(1,n+1):
    li += prime_factorize(i)

from collections import Counter

C = Counter(li)

a = 0
b = 0
c = 0
d = 0
e = 0

for i,j in C.items():
    if j >= 74:
        e += 1
    elif 24 <= j < 74:
        d += 1
    elif 14 <= j < 24:
        c += 1
    elif 4 <= j < 14:
        b += 1
    elif 2 <= j < 4:
        a += 1

point = 0

#75
point += e
#25 3
point += (d+e)*(a+b+c)+(d+e-1)*(d+e)
#15 5
point += (c+d+e)*b+(c+d+e-1)*(c+d+e)
#2 5 5
f = b+c+d+e
point += a*f*(f-1)//2+f*(f-1)*(f-2)//2

print(point)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    string s;
    cin >> s;
    
    int count = 0, sum = 0;
    int n = s.length();
    rep(i, n){
        if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G'){
            count++;
        } else {
            count = 0;
        }
        sum = max(sum,count);
    }
    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
using namespace std;
typedef long long ll;



int main(void) {
	ll x; cin >> x;
	ll m = 100;
	int i=0;
	for (i; m < x; i++) {
		m *= 1.01;
	}
	cout << i << endl;
	return 0;

}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,s,c;
    cin>>n>>m;
    std::deque<int> S;
    std::deque<int> C;
    for (int i=0;i<m;i++) {
        cin>>s;
        S.emplace_back(s);
        cin>>c;
        C.emplace_back(c);
    }
    int flag=0;
    for (int j=0;j<pow(10,n);j++) {
        int count=0;
        string tmp=to_string(j);
        if (tmp.size()==n) {
            for (int k=0;k<m;k++) {
                char hoge=tmp.at(S[k]-1);
                int piyo=hoge-48;
                if (piyo==C[k]) {
                    count++;
                } else {
                    break;
                }
            }
            if (count==m) {
                cout<<j<<endl;
                flag=1;
                break;
            }
        }
        
    }
    if (flag==0) {
        cout<<-1<<endl;
    }
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
const int INF = 1e9 + 7;

using namespace std;

#define MAX_V 100000
typedef pair<int,int> P;
struct edge{
    int to,cost;
};
int V;
vector<edge> G[MAX_V];
bool used[MAX_V];

int prim(){
    ll res=0,s=0;
    priority_queue<P,vector<P>,greater<P>> que;
    memset(used,0,sizeof(used));
    que.push(P(0,s));

    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if(used[v]) continue;
        used[v] = true;
        res += p.first;
        REP(i,G[v].size()) que.push(P(G[v][i].cost, G[v][i].to));
    }
    return res;
}

int main(){
    cin.tie(0), ios::sync_with_stdio(false);
    cin >> V;
    vector<pair<int,int>> vx(V),vy(V);
    REP(i,V){
        cin >> vx[i].first >> vy[i].first;
        vx[i].second = vy[i].second = i;
    }
    sort(vx.begin(),vx.end());
    REP(i,V-1){
        G[vx[i].second].push_back(edge{vx[i+1].second,vx[i+1].first-vx[i].first});
        G[vx[i+1].second].push_back(edge{vx[i].second,vx[i+1].first-vx[i].first});
    }
    sort(vy.begin(),vy.end());
    REP(i,V-1){
        G[vy[i].second].push_back(edge{vy[i+1].second,vy[i+1].first-vy[i].first});
        G[vy[i+1].second].push_back(edge{vy[i].second,vy[i+1].first-vy[i].first});
    }

    cout << prim() << "\n";
    return 0;
}


Measured memory_bytes: 12024
def ii():
    return int(input())
def mi():
    return map(int, input().split())
def li():
    return list(mi())

N, x = mi()
a = li()
a.sort()
c = 0
for ai in a:
    if x < ai:
        break
    x -= ai
    c += 1
if c == N and x > 0:
    c -= 1
print(c)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    char* c = new char[4];
    bool f = false;
    cin >> c;
    for(int i = 0;i < 3;i++){
        if (c[i] == c[i+1]){
            f = true;
            break;
        }
    }
    if(f){
        cout << "Bad" << endl;
    }else {
        cout << "Good" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
using namespace std;

int main()
{
    int N;
    map<long long, long long> a;
    set<long long> st;

    cin >> N;
    for (int i = 0; i < N; i++)
    {
        long long tmp;
        cin >> tmp;
        st.insert(tmp);
        a[tmp]++;
    }

    long long ans = 0;
    for (auto x : st)
    {
        if (a[x] > x)
        {
            ans += abs(a[x] - x);
        }
        else if (a[x] < x)
        {
            ans += a[x];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 10752
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int n,m;
	long long a[50],b[50],c[50],d[50];
	cin>>n>>m;
	for (int i = 0; i < n; i++){
		cin>>a[i]>>b[i];
	}
	for (int i = 0; i < m; i++){
		cin>>c[i]>>d[i];
	}

	long long md,p;
	for (int i = 0; i < n; i++){
		long long mp=1e16;
		for (int j = 0; j < m; j++){
			md=abs(a[i]-c[j])+abs(b[i]-d[j]);
			if(mp>md){
				mp=md;
				p=j+1;
			}
		}
		cout<<p<<endl;
	}

}



Measured memory_bytes: 256
function main()
  
  S = chomp(readline())
  T = chomp(readline())
  N = length(S)

  dict1 = Dict()
  dict2 = Dict()
  
  for i in 1:N
    dict1[S[i]] = get(dict1, S[i], 0 + i)
  end
  
  for i in 1:N
    dict2[T[i]] = get(dict2, T[i], 0 + i)
  end
  
  check1 = []
  check2 = []
  
  for i in 1:N
    push!(check1, dict1[S[i]])
    push!(check2, dict2[T[i]])
  end

  if check1 == check2
    println("Yes")
  else
    println("No")
  end
  
end

main()

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

using namespace std;

using ll = long long;

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

    int a, b, w;
    cin >> w >> a >> b;
    if ((a <= b && b <= a + w) || (a <= b + w && b + w <= a + w))
        cout << "0\n";
    else
        cout << min({abs(a - b), abs(a + w - b),
                    abs(a - (b + w)), abs((a + w) - (b + w))}) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cassert>
#include<cmath>
using namespace std;
#define fi first
#define se second
#define rep(i,s,t) for(int i=(s),_t=(t);i<_t;++i)
#define per(i,s,t) for(int i=(t)-1,_s=(s);i>=_s;--i)
#define debug(x) cerr<<#x<<" == "<<(x)<<endl
#define bug(x) cerr<<#x<<" == "<<(x)<<" "
typedef long long ll;
typedef unsigned long long ull;
typedef long double db;
typedef pair<int,int> pii;
template<class T>inline void rd(T &x){
	x=0;char c;int f=1;
	while(c=getchar(),c<48)if(c=='-')f=-1;
	do x=x*10+(c&15);
	while(c=getchar(),c>47);
	x*=f;
}
template<class T>void pf(T x){
	if(x<0)putchar('-'),x=-x;
	else if(!x){
		putchar('0');
		return ;
	}
	static int stk[100],tp;
	for(tp=0;x;x/=10)stk[tp++]=x%10;
	while(tp)putchar(stk[--tp]^48);
}
template<class T>void ptn(T x){
	pf(x),putchar('\n');
}
template<class T>void ptk(T x){
	pf(x),putchar(' ');
}
template<class T>void Min(T &A,T B){
	if(A>B)A=B;
}
template<class T>void Max(T &A,T B){
	if(A<B)A=B;
}


const int N=(int)1e5+5;
int n,m,a[N],cnt[N<<1];
ll sum[N];
ll t[N<<1];
int main(){
	rd(n),rd(m);
	rep(i,1,n+1)rd(a[i]);
	ll ans=0;
	rep(i,1,n){
		if(a[i]>a[i+1])a[i+1]+=m;
		ans+=a[i+1]-a[i];
		if(a[i]+2<=a[i+1]){
			cnt[a[i]+2]--;
			cnt[a[i+1]+1]++;
			t[a[i+1]+1]+=a[i+1]-a[i]-1;
		}
		if(a[i+1]>m)a[i+1]-=m;
	}
	ll s=0,mi=0;
	rep(i,1,m<<1|1){
		
		cnt[i]+=cnt[i-1];
		s+=cnt[i]+t[i];
		sum[i%m]+=s;
	}
	rep(i,0,m)Min(mi,sum[i]);
	ptn(ans+mi);
	return 0;
}

Measured memory_bytes: 2944
#include <stdio.h>

int main(){
int a,b,c,i;
int g = 1;
int z = 0;
scanf("%d %d",&a,&b);
c = b - a ; 
for(i = 0;i < c;i++){
z = z + g;
g += 1;
}
printf("%d",z - b );
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
            using namespace std;
            #define rep(i,b) for(i=0;i<b;++i)
            #define repp(i,a,b) for(i=a;i<b;++i)
            #define endl "\n"
            #define LLONG_MAX 99999999999999
            typedef long long int lli;
            int main(){
                lli i,t,n,m,k;
                string s;
                cin>>s;
                k=0;
                for(i=0;i<s.length();i++){
                    if(i%2==0&&s[i]=='L'){
                        k=1;
                        break;
                    }
                    if(i%2==1&&s[i]=='R'){
                        k=1;
                        break;
                    }
                }
                if(k==0){
                    cout<<"Yes"<<endl;
                }
                else{
                    cout<<"No"<<endl;
                }

                return 0;
            }
















Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

template<class T> T umax(T a,T b) {return (a>b?a:b);}
template<class T> T umin(T a,T b) {return (a<b?a:b);}
template<class T,class P> T umax(T a,P b) {return (a>b?a:b);}
template<class T,class P> T umin(T a,P b) {return (a<b?a:b);}

typedef long long int ll;
const int maxn = 1e5+7;
const ll mod = 1e9+7;

bool compare(const pair<ll,ll>& x, const pair<ll,ll>& y) {
    if(x.second == y.second) return x.first < y.first;
    return x.second < y.second;
}

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

ll gcd(ll a,ll b) {
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll max_v = 10000;

ll N;
ll W;
ll wv[105][2];
ll dp [105][1000005];

int main() {
    cin >> N >> W;
    for(int i=0;i<N;i++) {
        cin >> wv[i][0] >> wv[i][1];
    }
    for(int i=0;i<=N;i++) {
        for(int j=0;j<=1000001;j++) {
            dp[i][j] = 2e15;
        }
    }
    dp[0][0] = 0;
    for(int i=1;i<=N;i++) {
        for(int j=0;j<=N*max_v;j++) {
            ll prevValue = j - wv[i-1][1];
            if(prevValue < 0) {
                dp[i][j] = dp[i-1][j];
            } else if(dp[i-1][prevValue]+wv[i-1][0] > W) {
                dp[i][j] = dp[i-1][j];
            } else {
                dp[i][j] = min(dp[i-1][j],dp[i-1][prevValue] + wv[i-1][0]);
            }
        }
    }
    ll ans = 0;
    for(int i=N*max_v;i>=0;i--) {
        if(dp[N][i] < 2e15) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 790784
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;

string str;
int cnt[11];

void solve(){
	rep(i,11) cnt[i] = 0;
	int t = 0;
	int ans = 0;
	rep(i,str.size()){
		int x = str[i]-'0';
		if(i%2 == 0) t = (t+x)%11;
		else t = (t+11-x)%11;
		cnt[t]++;
	}
	if(str[0] != '0') ans += cnt[0];
	t = 0;
	rep(i,str.size()-1){
		int x = str[i]-'0';
		if(i%2 == 0) t = (t+x)%11;
		else t = (t+11-x)%11;
		cnt[t]--;
		if(str[i+1]-'0' == 0) continue;
		ans += cnt[t];
	}
	cout << ans << endl;
}

int main(){
	while(true){
		cin >> str;
		if(str=="0") break;
		solve();
	}
}

Measured memory_bytes: 1316
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    long long int i,g;
    map<char,int>a;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        a[s[i]]++;
    }
    g=1;
    for(i=0;i<s.size();i++)
    {
        if(a[s[i]]%2!=0)
        {
            g=0;
            break;
        }
    }
    if(g)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}


Measured memory_bytes: 3564
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int main(){
  int n;
  string s,t;cin>>n>>s>>t;

  for(int i=n;i>=0;--i){
    if(s.substr(n-i)==t.substr(0,i)){
      cout<<2*n-i<<endl;
      return 0;
    }
  }


  return 0;
}





Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));    
    private static StringTokenizer st;

    public static void main ( String [] args ) throws IOException
    {
	new Main().cal();
    }

 
    private void cal() throws IOException 
    {
	int N = Integer.parseInt(br.readLine());
	int [] nums = new int [N];

	st = new StringTokenizer(br.readLine());
	for(int i = 0; i < N; i++) 
	    nums[i] = Integer.parseInt(st.nextToken());

	int count = 0;
	for(int i = 0; i < N; i++) {
	    int mini = i;
	    for(int j = i; j < N; j++) {
		if ( nums[j] < nums[mini] )
		    mini = j;
	    }
	    if ( i != mini ) {
		swap(nums, i, mini);
		count++;
	    }
	}

	for(int i = 0; i < N; i++) {
	    if ( i > 0 ) System.out.print(" ");
	    System.out.print(nums[i]);
	}
	System.out.println("");
	
	System.out.println(count);
	

    }

    private void swap(int [] n, final int i, final int j){
	int temp = n[i];
	n[i] = n[j];
	n[j] = temp;
    }

}

Measured memory_bytes: 9344
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
constexpr int INF = 1 << 30;

vector<set<int>> dijkstra(const vector<vector<int>>& edges, int start) {
    using pii = pair<int, int>;
    const int N = edges.size();
    vector<int> d(N, INF);
    priority_queue<pii, vector<pii>, greater<pii>> pq;
    d[start] = 0;
    pq.push({ 0,start });
    while (!pq.empty()) {
        int cost, pos;
        tie(cost, pos) = pq.top(); pq.pop();
        for (int next : edges[pos]) {
            if (d[next] != INF) {
                if (d[next] == cost - 1 || d[next] == cost + 1)continue;
                else return {};
            }
            d[next] = cost + 1;
            pq.push({ d[next],next });
        }
    }
    const int M = *max_element(d.begin(), d.end()) + 1;
    vector<set<int>> res(M);
    rep(i, M)res[d[i]].insert(i);

    return res;
}

int main()
{
    int N;
    cin >> N;
    vector<vector<int>> edges(N);
    vector<vector<bool>> matrix(N, vector<bool>(N, false));
    rep(i, N) {
        string s;
        cin >> s;
        rep(j, N)if (s[j] == '1') {
            edges[i].push_back(j);
            edges[j].push_back(i);
            matrix[i][j] = matrix[j][i] = true;
        }
    }

    int res = -1;
    rep(i, N) {
        auto clusters = dijkstra(edges, i);
        if (clusters.empty())continue;
        for (const auto& cluster : clusters) {
            for (const int& pos1 : cluster) {
                for (const int& pos2 : cluster) {
                    if (matrix[pos1][pos2])goto end;
                }
            }
        }
        res = max(res, (int)clusters.size());
end:;
    }
    cout << res << endl;
    return 0;
}


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

int main() {
  int A,B,C;
  int AA,BB,CC;
  int sum=0;
  cin >> A >> B >> C;
  if(A==B && B==C){
    if(A%2==0)cout << -1;
    else cout << 0;
  }
  else{
    while(A%2==0 && B%2==0 && C%2==0){
      AA=(B+C)/2;
      BB=(A+C)/2;
      CC=(A+B)/2;
      A=AA;
      B=BB;
      C=CC;
      sum++;
    }
    cout << sum;
  }
}



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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int a,b,c,d;
    cin>>a>>b>>c>>d;

    if(ceil(double(a)/double(d)) >= ceil(double(c)/double(b))){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }


    return 0;
}


Measured memory_bytes: 3652
from collections import deque

def dfs(v):
    global t
    
    d[v] = t
    visited[v] = True
    t += 1
    
    for u in graph[v]:
        if not visited[u]: dfs(u)
    f[v] = t
    t += 1
    
    
n = int(input())
graph = [deque() for i in range(n)]

visited = [False] * n
d = [0] * n
f = [0] * n
t = 1

for i in range(n):
    nums = list(map(int, input().split()))
    for j in nums[2:]:
        graph[i].append(j-1)
         
for i in range(n):
    if not visited[i]: dfs(i)

for idx, df in enumerate(zip(d, f)):
    print(idx+1, df[0], df[1])



Measured memory_bytes: 6096
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    deque<int> seq;
    loop(i, N){
        scanInt(ai);
        if (i % 2 == 1){
            seq.emplace_front(ai);
        }else{
            seq.emplace_back(ai);
        }
    }
    if (N % 2 == 1){
        loop(i, N - 1){
            printf("%d ", seq[N - 1 - i]);
        }
        printf("%d\n", seq.front());
    }else{
        loop(i, N - 1){
            printf("%d ", seq[i]);
        }
        printf("%d\n", seq.back());
    }
}


Measured memory_bytes: 2944
// Dmitry _kun_ Sayutin (2019)

#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;
using std::queue;

using std::pair;
using std::make_pair;

using std::tuple;
using std::make_tuple;
using std::get;

using std::min;
using std::abs;
using std::max;
using std::swap;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    // code here
    int64_t n, a, b;
    cin >> n >> a >> b;

    if ((b - a) % 2 == 0)
        cout << (b - a) / 2 << "\n";
    else
        cout << (1 + min((a - 1) + (b - 1), (n - b) + (n - a))) / 2 << "\n";

    return 0;
}


Measured memory_bytes: 892
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;

long n;

void calc_mm(  vector<long>& s, vector<pair<long,long> >& mm )
{
    long j_save = 0;
    long i;
    for(i=1; i<n; i++) {
        long j;
        for(j=j_save; j<i; j++) {
            if(s[j+1]>s[i+1]/2) {
                break;
            }
        }
        long tmp = abs((s[i+1]-s[j])-s[j]);
        j_save=j;
        mm[i].first=MIN(s[i+1]-s[j], s[j]);
        mm[i].second=MAX(s[i+1]-s[j], s[j]);
        if(tmp > abs((s[i+1]-s[j+1])-s[j+1])) {
            mm[i].first=MIN(s[i+1]-s[j+1], s[j+1]);
            mm[i].second=MAX(s[i+1]-s[j+1], s[j+1]);
            j_save=j+1;
        }
    }
    return;
}

int main(int argc, char* argv[])
{
    scanf("%ld", &n);

    vector<long> a(n);
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &a[i]);
    }

    vector<pair<long,long> > mm0(n);
    {
        vector<long> s0(n+1);
        s0[0]=0;
        for(i=0; i<n; i++) {
            s0[i+1]=s0[i]+a[i];
        }
        calc_mm( s0, mm0 );
    }

    vector<pair<long,long> > mm1(n);
    {
        vector<long> s1(n+1);
        s1[0]=0;
        for(i=0; i<n; i++) {
            s1[i+1]=s1[i]+a[n-1-i];
        }        
        calc_mm( s1, mm1 );
    }

    long ans=INF;
    for(i=1; i<n-2; i++) {
        long min = MIN(mm0[i].first, mm1[n-2-i].first);
        long max = MAX(mm0[i].second, mm1[n-2-i].second);
        ans = MIN(ans, max-min);
    }
    printf("%ld\n", ans);

    return 0;
}



Measured memory_bytes: 9572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9 + 7;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
const int mod = 1e9 + 7;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

ll kai[2 * 100001];
ll nck(ll n, ll k) {
    ll ret = kai[n];
    ret *= power(kai[k], mod - 2) % mod; ret %= mod;
    ret *= power(kai[n - k], mod - 2) % mod; ret %= mod;
    return ret;
}
ll calc(ll a, ll b, ll n, int i) {
    ll tmp = nck(n - 1 + i, n - 1);
    tmp *= power(a, n - 1) % mod; tmp %= mod;
    tmp *= power(b, i) % mod; tmp %= mod;
    tmp *= a; tmp %= mod;
    return tmp;
}
int main() {
    ll n, a, b, c; cin >> n >> a >> b >> c;
    a = a * (power(100, mod - 2) % mod); a %= mod;
    b = b * (power(100, mod - 2) % mod); b %= mod;
    c = c * (power(100, mod - 2) % mod); c %= mod;
    ll normalize = power((a + b) % mod, mod - 2) % mod;
    a *= normalize % mod; a %= mod;
    b *= normalize % mod; b %= mod;
    kai[0] = 1;
    rrep(i, 1, 2 * 100001) {kai[i] = kai[i - 1] * i; kai[i] %= mod;}
    ll ans = 0;
    rep(i, n) {
        ans += (calc(a, b, n, i) + calc(b, a, n, i)) * (n + i) % mod;
        ans %= mod;
    }
    cout << ans * power((mod + 1 - c) % mod, mod - 2) % mod << endl;
}


Measured memory_bytes: 1792
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
int ans=0;
int32_t main()
{
  #ifndef ONLINE_JUDGE
    freopen("in","r",stdin);
    freopen("out","w",stdout);
    #endif
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  for(int &i:a)cin>>i;

  for(int A=0;A<=min(n,k);A++)
    for(int B=0;B<=min(n,k);B++)
    {
      if(A+B>min(n,k))continue;
      int tmp=0;
      multiset<int> s;
      for(int i=0;i<A;i++){tmp+=a[i];s.insert(a[i]);}
      for(int i=0;i<B;i++){tmp+=a[n-1-i];s.insert(a[n-1-i]);}

      for(int i=0;i<k-(A+B);i++)
      {
        if(s.empty())break;
        int p=*s.begin();
        if(p<0){tmp-=p;s.erase(s.find(p));}
        else break;
      }
      ans=max(ans,tmp);

    }

  
 cout<<ans;
 

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    ll N, K;
    cin >> N >> K;

    vector<ll> A(N);
    
    for(ll i = 0; i < N; i++){
        cin >> A[i];
    }
    
    if(K >= N){
        cout << 0 << endl;
        return 0;
    }

    sort(A.begin(), A.end());

    ll sum = 0;
    for(ll i = 0; i < N-K; i++){
        sum += A[i];
    }

    cout << sum << endl;
}

Measured memory_bytes: 1792
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                long[] L = new long[45];
                L[0] = 1;
                L[1] = 1;
                for (int i = 2; i < 45; i++) {
                        L[i] = L[i - 1] + L[i - 2];
                }
                System.out.println(L[sc.nextInt()]);
        }
}

Measured memory_bytes: 26044
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int p[11] = {1};
char s[12];
char a[12];
long long sum;
long long add;
int len;

void get_ans(){
	for(int i = len ; i >= 1 ; i--){
		memset(a,0,12);
		strncpy(a, s + p[i] , p[i - 1] - p[i]);
		add = atoll(a); 
//		printf("p[%d] = %d p[%d]=%d a =%lld\n",i,p[i],i-1,p[i-1],add);

		sum += add;

	}
//	printf("\n");
}

void dfs(int num){
	if(num == 0){
		get_ans();
		return;
	}
	while(p[num] < len + 1- num){
		dfs(num - 1);
//		printf("now move %d\n",num);
		p[num]++;
//		printf("num = %d p[num]=%d\n",num , p[num]);
		int i = num;
		while(i > 1){
			p[i - 1] = p[i] + 1;
			i--;
		}
//		printf("%n");
	}
}

int	main(){
	scanf("%s", s);
	len = strlen(s);
	p[0] = len;
	dfs(len);
	printf("%lld",sum);
}	

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

const int mod = 1000000000 + 7;

int N;
ll A[410];
ll dp[410][410];
ll sums[410];

ll dfs(int from, int to){
    if(dp[from][to] >= 0) return dp[from][to];
    ll res = 1LL << 60;
    if(from == to) res = 0;
    else{
        for(int i = from; i < to; i++){
            // [from, i], (i, to] で分割
            res = min(res, dfs(from, i) + dfs(i + 1, to) + (sums[to + 1] - sums[from]));
        }
    }
    return dp[from][to] = res;
}

int main(){
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    memset(dp, -1, sizeof(dp));
    for(int i = 0; i < N; i++) sums[i + 1] = sums[i] + A[i];
    cout << dfs(0, N - 1) << endl;
    
    return 0;
}


Measured memory_bytes: 1536
#import <Foundation/Foundation.h>
#import <stdio.h>
int main(){
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  printf((ABS(a-c)<=d) || (MAX(ABS(a-b),ABS(b-c))<=d) ? "Yes":"No");
  return 0;
}


Measured memory_bytes: 2164
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)

int main() {
	int n,m,k;
	scanf("%d %d %d", &n, &m, &k);
	if (k == n * m) { printf("Yes"); return 0; }
	rep(i, n) {
		rep(j, m) {
			if (k - i * (m - j) - j * (n - i) == 0) { printf("Yes"); return 0; }
		}
	}
	printf("No");
}

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

int main(){
    int ans2[20],ans1[20];
    int n,f,e,cnt;
    bool sj,fj,judge,ze,ro;
    cin >> n;
    while(n--){
        cin >> f >> e;
        cnt = 1;
        sj = false;
        fj = false;
        ze = true;
        ro = true;
        judge = false;
        int sta = f;
        ans1[0] = sta;
        ans2[0] = sta;
        while(1){
            if(sta == e) break;
            if(f == e){
                judge = true;
                break;
            }
            if(f > 5 && f < 9) f = -100000;
            if(sta == 9 && !sj){
                sta = 5;
                sj = true;
            }
            else if(sta == 0 && sj) sj = false;
            else if(sj) sta--;
            else if(!sj) sta++;
            ans1[cnt] = sta;
            
            if(f == 0 && !fj) fj = true;
            else if(f == 9 && !fj){
                fj = false;
                f = 5;
            }
            else if(!fj) f--;
            else if(fj) f++;
            ans2[cnt] = f;
            cnt++;
        }
        if(judge){
            for(int i=0;i<cnt-1;i++){
                cout << ans2[i] << " ";
                if(ans2[i+1] == 0 && ans2[i] == 0) i++;
            }
            cout << ans2[cnt-1] << endl;
        }
        else {
            for(int i=0;i<cnt-1;i++){
                cout << ans1[i] << " ";
                if(ans1[i+1] == 0 && ans1[i] == 0) i++;
            }
            cout << ans1[cnt-1] << endl;
        }
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    if (S.size() % 2)
    {
        cout << "No" << endl;
        return 0;
    }
    else
    {
        for (int i = 0; i < S.size(); i += 2)
        {
            if (S.at(i) != 'h' || S.at(i + 1) != 'i')
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main(int argc, char const *argv[]) {
  string s;
  std::cin >> s;
  int i,j,pz;

  for(i=0; i<s.size(); i++){
    if(s[i]=='A') break;
  }

  for(j=i; j<s.size(); j++){
    if(s[j]=='Z') pz=j;
  }
  std::cout << pz - i + 1<< endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
const int MOD = 1000000007;

int main(){
    string S; cin >> S;

    int ans = 0;
    for(int i = 0; i < S.size(); i++){
        if (i >= S.size()-1-i) break;
        if (S[i] != S[S.size()-1-i]){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int dp[100010];
const int INF = 100000;

int main(){
    int N;
    cin >> N;
    
    for(int i = 1; i <= N; i++){
        dp[i] = INF;
    }
    
    for(int i = 1; i <= N; i++){
        dp[i] = dp[i - 1] + 1;
        
        int power = 1;
        while(power <= i){
            dp[i] = min(dp[i], dp[i - power] + 1);
            power *= 6;
        }
        
        power = 1;
        while(power <= i){
            dp[i] = min(dp[i], dp[i - power] + 1);
            power *= 9;
        }
    }
    
    cout << dp[N] << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n)                    \
  for (int i = 0; i < (int)(n); i++) \
    ;

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  string s;
  cin >> s;

  if (s == "ABC") {
    cout << "ARC" << endl;

  } else {
    cout << "ABC" << endl;
  }
}


Measured memory_bytes: 3628
function Main(inputData) {
	init(inputData);
	
	var a = inI();
	var b = inI();
	var c = inI();
	var d = inI();

	out(Math.max(a*b,c*d));
	
}

////////////////////////////////////////////////////////////////////////////////////
var input,inputCnt;

// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
	Main(document.getElementById("input").value);
}

function init(inputData){
    //配列inputに順番に代入
	input = inputData.replace( /\n/g , " " );
	input = input.split(" ");
	inputCnt = 0;
}
//output
const out = (output) => { console.log(output) }
const outln = (output) => { console.log(output+"\n") }

//input
const inS = () => {return input[inputCnt++]};
const inI = () => {return parseInt(inS(), 10)};
const inF = () => {return parseFloat(inS())};

//prototype
Array.prototype.rsort = function(){
  return this.sort(function(a,b){return (a<b ? 1:-1);});
}

Array.prototype.max = function(){
  return Math.max.apply(null, this);
}

Array.prototype.min = function(){
  return Math.min.apply(null, this);
}

//function
function values(array) {
    var values = [];
    if(array)for(var key in array)values.push(array[key]);
    return values;
};

function keys(array) {
    var keys = [];
    if(array)for(var key in array)keys.push(key);
    return keys;
};

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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


using namespace std;
typedef unsigned long long int ll;
vector<int> row,col;
const int maxn = 55;
int getrowID(int x){ return lower_bound(row.begin() , row.end() , x) - row.begin() + 1;}
int getcolID(int x){ return lower_bound(col.begin() , col.end() , x) - col.begin() + 1;}

int G[maxn][maxn];

const int INF =1e9+7;
int x[maxn];
int y[maxn];

int main()
{
    int n , k;
    scanf("%d%d",&n,&k);
    for(int i = 0 ; i < n ; i++){
        cin>>x[i]>>y[i];
        row.push_back(x[i]);
        col.push_back(y[i]);
    }
    sort(row.begin() , row.end());
    sort(col.begin() , col.end());
    row.erase( unique(row.begin() , row.end() ) , row.end());
    col.erase( unique( col.begin() , col.end()) , col.end());
    for(int i = 0 ; i < n ; i++){
        G[getrowID(x[i])][getcolID(y[i])] = 1;
     //   cout<<getrowID(x[i])<<" "<<getcolID(y[i])<<endl;
    }
    ll ans = 0;
    for(int i = 1 ; i < maxn  ; i++){
        for(int j = 1 ; j < maxn ; j++){
            G[i][j] += G[i][j-1];
        }
    }
    for(int j = 1 ; j < maxn ; j ++){
        for(int i = 1 ; i < maxn ; i++){
            G[i][j] += G[i-1][j];
        }
    }
//    for(int i = 0 ; i <= 4 ;i++){
//        for(int j = 0 ; j <= 4 ; j++){
//            cout<<G[i][j]<<" ";
//        }
//        cout<<endl;
//    }
    for(int i = 1 ;i < row.size()+1 ; i++){
        for(int ii = i+1 ; ii < row.size()+1 ; ii++){
            for(int j = 1 ; j < col.size()+1 ; j++){
                for(int jj = j+1 ; jj < col.size() +1 ; jj++){
                    int tans = G[ii][jj] - G[ii][j-1] - G[i-1][jj] + G[i-1][j-1];
                    if(tans >= k){
                    //    cout<<i<<" "<<j<<" "<<ii<<" "<<jj<<endl;
                        if(ans == 0) ans = ((ll)row[ii-1] - row[i-1]) * ((ll)col[jj-1] - col[j-1]);
                        else ans = min(ans , ((ll)row[ii-1] - row[i-1]) * ((ll)col[jj-1] - col[j-1]));
                    }
                }
            }
        }
    }
//    for(int i = 0 ; i < n ; i++){
//        for(int j = i + 1 ; j < n ; j++){
//            int x1 = getrowID(x[i]);
//            int x2 = getrowID(x[j]);
//            int y1 = getcolID(y[i]);
//            int y2 = getcolID(y[j]);
//            if(x1 > x2) swap(x1 , x2);
//            if(y1 > y2) swap(y1 , y2);
//            int tans = 0;
//            cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<endl;
//            for(int xx = x1 ; xx <= x2 ; xx++){
//                for(int yy = y1 ; yy <= y2 ; yy++){
//                    tans += G[xx][yy];
//                }
//            }
//            if(tans >= k){
//                if(ans == 0) ans = (ll)abs(x[i]-x[j]) * (ll)abs(y[i]-y[j]);
//                else ans = min(ans , (ll)1ll * abs(x[i]-x[j]) * abs(y[i]-y[j]));
//                cout<<(ll)abs(x[i]-x[j]) * (ll)abs(y[i]-y[j])<<endl;
//                cout<<x[i]<<" "<<y[i]<<" "<<x[j]<<" "<<y[j]<<endl;
//            }
//        }
//    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long 

signed main(void){ 
  
  int N,K; cin >> N >> K;
  vector<int> A(N),B(N);
  for(int i = 0; i < N; i++){
    cin >> A[i] >> B[i];
  } 
  int ans = 0;
  
  for(int i = 40; i >= 0; i--){ 
    // Kの上の桁から見て行って、1がないかを探す
    if( !(K >> i & 1) && i < 40) { continue;}
    
    
    int res = K;
    //この桁を0にして、それより下の桁を全て1にする
    
    if( i < 40 ){ res = (res>>i)<<i; res--;}
    
   
    int inst = 0;
   vector<int> row;
    
    for(int j = 0; j < N; j++){ 
      
      if( (A[j] | res) == res ){ inst+= B[j]; row.push_back(A[j]);}
      
    }
   
    ans = max(ans,inst);
  }
  
  cout << ans << endl;
  
  return 0;
}
    
    

Measured memory_bytes: 3600
//56
#include<iostream>
#include<vector>

using namespace std;

int main(){
  vector<int> prime;
  vector<int> psum(1,0);
  for(int i=2;prime.size()<10000;i++){
    int j;
    for(j=0;j<prime.size();j++){
      if(i%prime[j]==0)break;
    }
    if(!(j<prime.size())){
      prime.push_back(i);
      psum.push_back(psum.end()[-1]+i);
    }
  }
  for(int n;cin>>n,n;){
    cout<<psum[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 996
n, x = [int(i) for i in input().split(' ')]
l_list = [int(i) for i in input().split(' ')]

pos = 0
for i in range(n):
  pos += l_list[i]
  if pos > x:
    break
if pos <= x:
  i += 1
print(str(i + 1))

Measured memory_bytes: 38384
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long a = long.Parse(Console.ReadLine());

            long result = a + a*a + a*a*a;

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27292
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <bitset>

using namespace std;

typedef long long int ll;
typedef vector<long long> vll;
typedef vector<string> vs;

#define MAX(a,b) ((a)>(b) ? (a) : (b))
#define MIN(a,b) ((a)<(b) ? (a) : (b))
#define ABS(a) ((a)>0 ? (a) : (a * -1))


int A[1000000], n;
int binarySearch(int key) {
	int left = 0;
	int right = n;
	int mid;
	while (left < right ) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

int prime(int x) {
	if (x < 2) return 0;
	if (x == 2) return 1;
	if (x % 2 == 0) return 0;
	for (int i = 3; i*i <= x; i+=2) {
		if (x % i == 0) return 0;
	}
	return 1;
}

int gcd(int x, int y) {
	int r;
	if (x < y) swap(x, y);
	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

int main(){
	int n, m, k;
	ll dis, min, x, y;
	cin >> n >> m;
	vll a(n);
	vll b(n);
	vll c(m);
	vll d(m);
	vll ans;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> c[i] >> d[i];
	}

	for (int i = 0; i < n; i++) {
		min = 1000000001;
		for (int j = 0; j < m; j++) {
			x = c[j] - a[i];
			y = d[j] - b[i];
			
			dis = ABS(x) + ABS(y);
			if (min > dis) {
				min = dis;
				k = j;
			}
		}
		ans.push_back(k + 1);
	}


	for (int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void)
{
  int H, W, h, w;
  scanf("%d %d %d %d", &H, &W, &h, &w);

  int ans = H * W - (h * W + w * H - h * w);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int col, row, c, r, row_sum;
    int **matrix;

    scanf("%d%d", &col, &row);

    matrix = (int **)malloc(sizeof(int *) * (col+1));
    for (c=0; c<(col+1); c++) {
        matrix[c] = (int *)malloc(sizeof(int) * row);
    }

    for (c=0; c<col; c++) {
        for (r=0; r<row; r++) {
            scanf("%d", &matrix[c][r]);
        }
    }

    for (c=0; c<(col+1); c++) {
        row_sum = 0;
        for (r=0; r<row; r++) {
            printf("%d ", matrix[c][r]);
            row_sum += matrix[c][r];
            matrix[col][r] += matrix[c][r];
        }
        printf("%d\n", row_sum);
    }

    return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
#define MAX 1000000007

/*
void dfs(int v){
    印つける
    for(auto next_v:G[v]){
        探索済->continue
        dfs(next_v);
    }
}
*/

int main()
{
    int n;
    cin >> n;
    Graf d(n,vector<int>(2));
    rep(i,n)cin >> d[i][0] >> d[i][1];
    int count=0;
    int ans=0;
    bool flag=false;
    rep(i,n){
        if(d[i][1]==d[i][0]){
            count++;flag=true;
        }else{
            flag=false;ans=max(count,ans);
            count=0;
        }
    }
    ans=max(count,ans);
    if(ans>=3)
        Yes;
    else{
        No;
    }
}

Measured memory_bytes: 3628
#include<stdio.h>
int main(){
  int a,b,c,d;
  scanf("%d%d",&a,&b);
  if(a > b){
    d=a;
    a=b;
    b=d;
  }
  c=b%a;
  while(c!=0){
    b=a;
    a=c;
    c=b%a;
    }
    printf("%d\n",a);
  return 0;
}

Measured memory_bytes: 592