akhauriyash/Code-Regression huggingface dataset:
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int X;
  cin >> X;
  
  if(X >= 30){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define SQ(x) ((x)*(x))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int n;
double cost[128][128];
double mincost[128];
bool used[128];

double prim(){
  rep(i, n){
    mincost[i] = INF;
    used[i] = false;
  }

  mincost[0] = 0;
  double res = 0;

  while(true){
    int v = -1;
    rep(u, n){
      if(!used[u] && (v == -1 || mincost[u] < mincost[v]))  v = u;
    }

    if(v == -1) break;
    used[v] = true;
    res += mincost[v];


    rep(u, n)
      mincost[u] = min(mincost[u], cost[v][u]);
  }
  return res;
}

int main(){
  while(scanf("%d", &n) && n){
    double x[128], y[128], z[128], r[128];
    rep(i, n){
      scanf("%lf%lf%lf%lf", x+i, y+i, z+i, r+i);
    }
    rep(i, n) rep(j, n) cost[i][j] = INF;

    rep(i, n) REP(j, i+1, n){
      double dis = sqrt(SQ(x[i]-x[j])+SQ(y[i]-y[j])+SQ(z[i]-z[j]));
      dis -= r[i] + r[j];
      dis = max(dis, 0.0);
      cost[i][j] = cost[j][i] = dis;
    }

    printf("%.3lf\n", prim());
  }
  return 0;
}

Measured memory_bytes: 1356
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#define mp make_pair
#define pb push_back
#define INF 100000005
#define rep(i,n) for(int i = 0;i < n;i++)
using namespace std;
int sa[200005],rk[200005],tmp[200005];

string S,T;
int kk;
int len;

int sg[2][1<<19];//[0]???????°???????[1]????????§????????????

bool compare_sa(int i,int j){
    if(rk[i]!=rk[j]){
        return rk[i]<rk[j];
    }else{
        int ri = (i+kk<len)?rk[i+kk]:-1;
        int rj = (j+kk<len)?rk[j+kk]:-1;
        return ri<rj;
    }
}

void construct_sa(){
    len=(int)S.length();
    rep(i,len+1){
        sa[i]=i;
        rk[i]=(i<len)?S[i]:-1;
    }
    for(kk=1;kk<=len;kk*=2){
        sort(sa,sa+len+1,compare_sa);
        tmp[sa[0]]=0;
        for(int i = 1;i<=len;i++){
            tmp[sa[i]]=tmp[sa[i-1]]+(compare_sa(sa[i-1],sa[i])?1:0);
        }
        rep(i,len+1){
            rk[i]=tmp[i];
        }
    }
}

void update(bool f,int p,int x){//sg[f]???p?????????x????????\
    p+=(1<<18)-1;
    sg[f][p]=x;
    while(p>0){
        p=(p-1)/2;
        sg[f][p]=(f?max(sg[f][p],x):min(sg[f][p],x));
    }
}

int query(bool f,int a,int b,int k,int l,int r){
    if(r<=a||b<=l)return f?-INF:INF;
    if(a<=l&&r<=b)return sg[f][k];
    else{
        int mid = (l+r)/2;
        int vl=query(f,a,b,k*2+1,l,mid);
        int vr=query(f,a,b,k*2+2,mid,r);
        int ret=(f?max(vl,vr):min(vl,vr));
        return ret;
    }
}

int query(bool f,int a,int b){
    return query(f,a,b,0,0,(1<<18));
}

int search(string t){
    int a=0,b=len+1;
    while(b-a>1){
        int c=(a+b)/2;
        if(S.compare(sa[c],T.length(),T)<0)a=c;
        else b=c;
    }
    return b;
}

int main(){
    cin>>S;
    rep(i,1<<19){
        sg[0][i]=INF;
        sg[1][i]=-INF;
    }
    construct_sa();
    rep(i,len+1){
        update(0,i,sa[i]);
        update(1,i,sa[i]);
    }

    int testcase;
    cin>>testcase;
    while(testcase--){
        int checkl;
        bool flag = 1;
        int ansl,ansr;
        int right,left;
        cin>>T;
        checkl=(int)T.length();
        left = search(T);
        T[T.length()-1]+=1;
        right=search(T);
        if(left==right)flag=0;
        ansl=query(0,left,right);

        cin>>T;
        left = search(T);
        T[T.length()-1]+=1;
        right=search(T);
        if(left==right)flag=0;
        ansr=query(1,left,right)+(int)T.length();
        if(ansl>len||ansl>=ansr)flag=0;
        if(ansr-ansl<checkl)flag=0;
        if(flag){
            cout<<ansr-ansl<<endl;
        }else{
            cout<<0<<endl;
        }
    }
}

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

int f[2][5][5][5], m1, a[27], m2, b[27];
int main() {
	int n, cnt = 1;
	while (scanf("%d", &n), n) {
		if (cnt != 1)printf("\n");
		rep(i, 5)rep(j, 5)rep(k, 5)scanf("%1d", &f[0][i][j][k]);
		scanf("%d", &m1); rep(i, m1)scanf("%d", &a[i]);
		scanf("%d", &m2); rep(i, m2)scanf("%d", &b[i]);
		rep(i, n) {
			int t = i & 1;
			rep(x, 5)rep(y, 5)rep(z, 5) {
				int cnt = 0;
				for (int j = -1; j <= 1; j++)
					for (int k = -1; k <= 1; k++)
						for (int l = -1; l <= 1; l++) {
							if (j == 0 && k == 0 && l == 0)continue;
							int nx = x + j, ny = y + k, nz = z + l;
							if (0 <= nx&&nx < 5 && 0 <= ny&&ny < 5 && 0 <= nz&&nz < 5 && f[t][nx][ny][nz])cnt++;
						}
				if (f[t][x][y][z]) {
					if (find(b, b + m2, cnt) == b + m2)f[!t][x][y][z] = 0;
					else f[!t][x][y][z] = 1;
				}
				else {
					if (find(a, a + m1, cnt) != a + m1)f[!t][x][y][z] = 1;
					else f[!t][x][y][z] = 0;
				}
			}
		}
		printf("Case %d:\n", cnt);
		rep(i, 5) {
			rep(j, 5) {
				rep(k, 5)printf("%d", f[n & 1][i][j][k]);
				printf("\n");
			}
			if (i < 4)printf("\n");
		}
		cnt++;
	}
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

struct BIT{
  int n;
  vector<ll> bit;
  BIT(int size):n(size),bit(size+1,0){}

  ll sum(int i){
    ll s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }

  void add(int i,ll v){
    if(i==0)return ;
    while(i<=n){
      bit[i]+=v;
      i+=i&-i;
    }
  }

  ll lower_bound(ll w){
    if(w<=0)return 0;
    ll x=0,r=1;
    while(r<n)r<<=1;
    for(ll k=r;k>0;k>>=1){
      if(x+k<=n&&bit[x+k]<w){
        w-=bit[x+k];
        x+=k;
      }
    }
    return x+1;
  }
};

vector<int> c;
vector<vector<int>> g;
vector<int> sz,par;
vector<int> vl,vr;
vector<int> dep;
int idx;
vector<vector<int>> vs;

void predfs(int v,int pre,int d){
  vl[v]=idx++;
  sz[v]=1;
  par[v]=pre;
  dep[v]=d;
  for(int nv : g[v]){
    if(nv==pre)continue;
    predfs(nv,v,d+1);
    sz[v]+=sz[nv];
  }
  vr[v]=idx;
}

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

  int N;
  cin>>N;
  g.resize(N); c.resize(N); vs.resize(N);
  dep.resize(N); sz.resize(N); par.resize(N);
  vl.resize(N); vr.resize(N);
  rep(i,N){
    cin>>c[i];
    c[i]--;
    vs[c[i]].push_back(i);
  }
  rep(i,N-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  predfs(0,-1,0);

  BIT bit(N);
  ll tot=N;
  tot=tot*(tot+1)/2;
  vector<ll> res(N,0);
  rep(k,N){
    sort(all(vs[k]),[&](const int& a,const int& b){
      return dep[a]>dep[b];
    });
    res[k]=tot;
    vector<P> rollback;
    for(int v : vs[k]){
      for(int nv : g[v]){
        if(nv==par[v])continue;
        ll rsz=sz[nv]-(bit.sum(vr[nv])-bit.sum(vl[nv]));
        res[k]-=rsz*(rsz+1)/2;
        bit.add(vl[nv]+1,rsz);
        rollback.push_back(P(vl[nv]+1,-rsz));
      }
      bit.add(vl[v]+1,1);
      rollback.push_back(P(vl[v]+1,-1));
    }
    if(c[0]==k){
      for(int nv : g[0]){
        ll rsz=sz[nv]-(bit.sum(vr[nv])-bit.sum(vl[nv]));
        res[k]-=rsz*(rsz+1)/2;
      }
    }else{
      ll rsz=sz[0]-(bit.sum(vr[0])-bit.sum(vl[0]));
      res[k]-=rsz*(rsz+1)/2;
    }
    for(P r : rollback)bit.add(r.fi,r.se);
    cout<<res[k]<<"\n";
  }

  return 0;
}


Measured memory_bytes: 49072
import math
n=int(input())
number=list(map(int,input().split()))
SUM=[]
sum=0
p=10**9 +7
x=math.factorial(n)%(10**9 +7)
for i in range(1,n+1):
  k=pow(i,p-2,p)
  sum+= (x*k)%p
  sum= sum%(p)
  SUM.append(sum)
ans=0
for i in range(n):
  ans+= number[i]*(SUM[n-1-i]+SUM[i]-x)
  ans=ans%(p)
print(ans)

Measured memory_bytes: 15148
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin>>n;
  
  vector<int> A(n);
  int x;
  rep(i,n){
    cin>>x;
    A[i]=x-i-1;
  }
  sort(ALL(A));
  int m=A[n/2];
  
  ll ans=0;
  rep(i,n){
    ans+=abs(A[i]-m);
  }
  cout<<ans<<endl;

  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> p;
  for (int i=0; i<n; i++) {
    int tmp;
    cin >> tmp;
    p.push_back(tmp);
  }

  int cnt=0;
  for (int i=0; i<n; i++) {
    if(i+1==p[i]) {
      cnt++;
      i++;
    }
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 892
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int a, b, c, d;

int main() {
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	int ans=0;
	int i=0;
	while(k>0&&i<n){
		ans+=a[i];
		i++;
		k--;
	}
	cout<<ans;
}

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

int main() {
  int N, t;
  cin >> N;
  t = N;
  
  int count = 0;
  for (int i = 0; ; i++) {
    count +=  N % 10;
    N /= 10;
    if (N > 0) {
      continue;
    } else if (t % count == 0) {
      cout << "Yes" << endl;
      break;
    } else {
      cout << "No" << endl;
      break;
    }
  }
}

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

int main(void) {
	int h, w, i, j;
	while (1) {
		cin >> h >> w;
		if (!h && !w)
			break;
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				if (i == 0 || j == 0 || i == h - 1 || j == w - 1)
					cout << '#';
				else
					cout << '.';
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

struct Person{
	Person(){
		lock_data = wait_data = -1;
		check = false;
	}
	int lock_data,wait_data;
	bool check;
};

struct Data{
	Data(){
		lock_person = -1;
	}
	int lock_person;
};

int main(){
	int n;

	Person person[101];
	Data data[101];

	char info[5];
	int left,right;

	scanf("%d",&n);

	for(int i = 0; i < n; i++){
		scanf("%d %s %d",&left,info,&right);

		if(info[0] == 'w'){
			person[left].wait_data = right;
		}else{
			person[left].lock_data = right;
			data[right].lock_person = left;
		}
	}

	bool FLG = false;
	int tmp;
	for(int i = 1; i <= 100; i++){
		if(person[i].wait_data != -1){ //?????£?????????????????????????????´???
			person[i].check = true;
			tmp = data[person[i].wait_data].lock_person;

			while(person[tmp].check == false && person[tmp].wait_data != -1){
				person[tmp].check = true;
				tmp = data[person[tmp].wait_data].lock_person;
			}

			if(person[tmp].check == true){
				FLG = true;
				break;
			}else{

				person[i].check = false;
				tmp = data[person[i].wait_data].lock_person;

				while(person[tmp].wait_data != -1){
					person[tmp].check = false;
					tmp = data[person[tmp].wait_data].lock_person;
				}
			}
		}
	}

	if(!FLG){
		printf("0\n");
	}else{
		printf("1\n");
	}
	return 0;
}

Measured memory_bytes: 2608
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=((ll)n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=((ll)a);i<((ll)n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vl p;
    rep(i,1001){
        ll t=1;
        rep(j,5)t*=i;
        p.push_back(t);
    }
    rep(i,1001)rep(j,1001){
        if(p[i]-p[j]==n){
            puta(i,j);
            return 0;
        }
        if(p[i]+p[j]==n){
            puta(i,-j);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>


using namespace std;



int main(){
    
    int card1, card2, card3;
    while(cin>>card1>>card2>>card3){
        int deck[11]={0};
        for(int i=1; i<=10; i++)deck[i]=1;
        int sum=card1+card2;
        deck[card1]=0;
        deck[card2]=0;
        deck[card3]=0;
        int yes=0;
        int no =0;
        for(int i=0; i<=10; i++){
            if(deck[i]==1){
                if(sum+i<=20)yes++;
                else no ++;
            }
        }
        if(yes>=no)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 1152
# Matrix Chain Multiplication
N, *A = map(int, open(0).read().split())
A = A[0::2]+[A[-1]]

INF = float('inf')
dp = [[INF]*(N) for _ in [0]*(N)]
# dp[i][j]: a_iからa_jまでの積に必要な最小の乗算回数

rg = range(N)

for i in rg:
    dp[i][i] = 0


for l in range(1, N):
    for i in rg:
        j = i + l
        if j >= N:
            continue
        for k in range(i, j):
            dp[i][j] = min(
                dp[i][j],
                dp[i][k] + dp[k+1][j] + A[i]*A[k+1]*A[j+1]
            )

print(dp[0][N-1])



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

using namespace std;

int main(void) {
  int n;
  while (cin >> n, n) {
    vector<char> c(n);
    for (int i = 0; i < n; i++) {
      cin >> c[i];
    }

    int cnt[26] = {}, maxc = -1;
    char ch;
    bool tie = true;
    for (int i = 0; i < n; i++) {
      if (++cnt[c[i] - 'A'] > maxc) {
        ch = c[i];
        maxc = cnt[ch - 'A'];
      }

      bool win = true;
      for (int j = 0; j < 26; j++) {
        if (j + 'A' == ch) continue;
        if (cnt[j] + n - i - 1 < maxc) continue;
        win = false;
        break;
      }

      if (!win) continue;
      cout << ch << " " << i + 1 << endl;
      tie = false;
      break;
    }

    if (tie) cout << "TIE\n";
  }

  return 0;
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main()
{
	ll a, b;
	cin >> a >> b;
	if((a+b)>9) {
		cout << "error" << endl;
	} else {
		cout << a + b << endl;
	}
}

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

int main(){
  int a,b;
  cin >>a >>b;
  string s[a + 1];
  for (int i = 1; i <= a; i++) {
    cin >> s[i];
  }
  for (int i = 0; i <= a + 1; i++) {
    for (int j = 0; j < b + 2; j++) {
      if (i == 0 || j == 0 || i == a + 1) cout << '#';
      else {
        cout << s[i] << '#';
        break;
      }
    }
    cout << endl;
  }
  return 0;
}


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

int main() {
  char a;
  cin >> a;
  if(a == 'A')
    cout << "T" << endl;
  else if(a == 'T')
    cout << "A" << endl;
  else if(a == 'C')
    cout << "G" << endl;
  else
    cout << "C" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    string S,T;
    cin >> S >> T;
    S = T + S;
    cout <<S<< "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
    int m;
    while (scanf("%d",&m)!=EOF){
        int k=0,s=0;
        while (++k){
            s+=k;
            if (s>=m){
                break;
            }

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long int ll;

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

int main(){
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	a--;
	cout << b - b / c - b / d + b / (c / gcd(c, d) * d) - (a - a / c - a / d + a / (c / gcd(c, d) * d)) << endl;
	return 0;
}


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

using namespace std;

double s[1000];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    int n;
    while(true) {
        double a=0, m=0;
        cin>>n;
        if(n==0) break;
        for(int i=0; i<n; i++) {
            cin>>s[i];
            m+=s[i];
        }
        m/=n;
        for(int i=0; i<n; i++) {
            a+=(s[i]-m)*(s[i]-m);
        }
        cout<<sqrt(a/n)<<'\n';
    }
    return 0;
}

Measured memory_bytes: 1308
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { //USE LONGS TO AVOID OVERFLOW THEN CAST
 
	public static void main(String[] args) { 
		FastScanner input = new FastScanner();
		PrintWriter w = new PrintWriter(System.out);
		int ans = 0;
		String S = input.next();
		String T = input.next();
		for (int i = 0; i < S.length(); i++) {
			if (S.charAt(i)!=T.charAt(i)) ans++;
		}
		//CODE
		w.println(ans);
		w.flush();
	}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 30836
#include<iostream>
#include <algorithm>
#include <string>
#define rep(i,n)for(i=0;i<n;i++)
using namespace std;
int main() {
	string a,b;
    cin >> a >> b;
    if (a == "H") {
        if (b == "H") {
            cout << "H" << endl;
        }
        else {
            cout << "D" << endl;
        }
    }
    else {
        if (b == "H") {
            cout << "D" << endl;
        }
        else {
            cout << "H" << endl;
        }
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
long long dp[100010];
long long h[100010];
const int MOD = 1000000007;

int main()
{
    string s; cin >> s;
    int a[4];
    rep(i, 4) a[i] = s[i] - '0';

    rep(i, 1 << 3)
    {
        int tmp = a[0];
        rep(j, 3)
        {
            if (i >> j & 1)
                tmp += a[j + 1];
            else
                tmp -= a[j + 1];
        }
        if (tmp == 7)
        {
            cout << a[0];
            rep(j, 3)
            {
                if (i >> j & 1)
                    cout << '+';
                else
                    cout << '-';
                cout << a[j + 1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
n,m = map(int,input().split())
l = list(map(int,input().split()))


S = sum(l)
ss = S / (4*m)
c = 0
for i in range(n):
    if l[i] >= ss:
        c = c+1
    
if c >= m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
n, m, x = map(int, input().split())
lst = []
for _ in range(n):
    lst.append(list(map(int, input().split())))
ans = 10**50
flg = 0

for i in range(2 ** n):
    achv = [0] * (m + 1)
    for j in range(n): 
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            achv = list(map(lambda x,y: x+y, achv, lst[j]))# フラグが立っていたら bag に果物を詰める
    if len([_ for _ in achv[1:m+1] if _ >= x]) == m and achv[0] > 0:

        ans = min(ans, achv[0])
        flg = 1

if flg:
    print(ans)
else:
    print(-1)
           


Measured memory_bytes: 9224
import math
def search(s,t):
    cnt=0
    s.sort()
    t.sort()
    for i in t:
        first=0
        last=len(s)
        mid=0
        while first<last:
            mid=(first+last)//2
            if s[mid] == i:
                cnt=cnt+1
                break
            elif s[mid]>i:
                last=mid
            else:
                first=mid+1
    return cnt
n=int(input())
s=list(map(int,input().split()))
q=int(input())
t=list(map(int,input().split()))
print(search(s,t))


Measured memory_bytes: 16772
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define MAX(p,q) (p>q)?p:q
#define MIN(p,q) (p<q)?p:q

#define REP(i,n) for(i=0;i<n;i++)

int main(void)
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);

  if(a*c <= b)
  {
    printf("%d",c);
  }
  else
  {
    printf("%d",b/a);
  }
  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
const int MAXN=505;
 
int H,W,h,w;
int arr[MAXN][MAXN];
 
int main()
{
	scanf("%d%d%d%d",&H,&W,&h,&w);
	if(h==1&&w==1)
	{
		puts("No");
		return 0;
	}
	long long sum=0;
	int k=999999999/(h*w-1);
	{
		sum=0;
		for(int i=1;i<=H;i++)
			for(int j=1;j<=W;j++)
			{
				if(i%h==0&&j%w==0)
					arr[i][j]=-k*(h*w-1)-1;
				else
					arr[i][j]=k;
				sum+=arr[i][j];
			}
		if(sum>0)
		{
			puts("Yes");
			for(int i=1;i<=H;i++)
			{
				for(int j=1;j<=W;j++)
					printf("%d ",arr[i][j]);
				puts("");
			}
			return 0;
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 3840
#include<iostream>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <algorithm>
using namespace std;
#include <cmath>
#include <string>

int main(){
  int N;
  cin>>N;
  int a[110]={0};
  rep(i,N){
    cin>>a[i];
  }
  sort(a,a+N,greater<int>() );
  int alice=0;
  int bob = 0;
  rep(i,N){
    if(i%2 == 0)alice+= a[i];
    else bob+=a[i];
  }
  cout<<alice-bob<<endl;

}


Measured memory_bytes: 256
//Simultaneous Equation

#include <iostream>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <cfloat>

namespace {

inline bool is_nearly_zero(double x)
{
  if (std::abs(x) < DBL_EPSILON)
    return true;
  else
    return false;
}

}

int main()
{
  while (1) {
    double x, y;
    double a, b, c, d, e, f;
    std::cin >> a >> b >> c >> d >> e >> f;
    if (std::cin.fail()) break;

    const double det = (a * e) - (b * d);
    assert(!is_nearly_zero(det));

    const double inv_mat[2][2] = {
    	{e, -b},
    	{-d, a}
    };

    x = ((inv_mat[0][0] * c) + (inv_mat[0][1] * f)) / det;
    y = ((inv_mat[1][0] * c) + (inv_mat[1][1] * f)) / det;

	if (is_nearly_zero(x)) x = 0.0;
	if (is_nearly_zero(y)) y = 0.0;
	
    printf("%.3f %.3f\n", x, y);
  }

  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int K,A,B;
cin >> K >> A >> B;
int AB = B / K * K;
  if(AB >= A){
    cout << "OK" << endl;
  }
  else{
    cout << "NG" << endl;
  }
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main() {
  int n;
  while(cin >> n && n) {
    set<int> st;
    int cnt[10000] = {};
    for(int i=0; i<n-1; i++) {
      st.insert( (i+1)*(i+1) % n );
    }
    
    int const size = st.size();
    
    vector<int> vec;
    set<int>::iterator it = st.begin();
    for(it; it!=st.end(); it++) vec.push_back(*it);
    
    for(int i=0; i<size-1; i++) {
      for(int j=i+1; j<size; j++) {
	int temp = vec[i] - vec[j];
	if(temp < 0) { temp += n; }
	if(temp > (n-1)/2) { temp = n - temp; }
	cnt[temp] ++;
      }
    }
    
    for(int i=1; i<=(n-1)/2; i++) {
      cout << cnt[i]*2 << endl;
    }
  }
  return 0;
}

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

#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(){
   int N,M,C;
   cin>>N>>M>>C;
   int B[M];
   REP(i,M){
       cin>>B[i];
   }
   int A[N][M];
   REP(i,N){
       REP(j,M){
           cin>>A[i][j];
       }
   }
   int ans=0,tmp=0;
   REP(i,N){
       tmp=0;
       REP(j,M){
           tmp+=A[i][j]*B[j];
       }
       tmp+=C;
       if(tmp>0){
           ans++;
       }
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 256
#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 INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
#define max_m 1e5

int main() {
  int n,m; cin>>n>>m;
  priority_queue<ll,vector<int>, greater<int>> que;

  REP(i,n){
    ll a; cin>>a;
    que.push(a);
  }

  vector<pair<ll,ll>> p(max_m); 
  REP(i,max_m){
    p[i].first=0;
    p[i].second=0;
  }

  REP(i,m){
    int b,c;
    cin>>b>>c;

    p[i].second=b;
    p[i].first=c;
    }
  sort(ALL(p)); //cを小さい順に整列
  reverse(ALL(p)); //ｃを大きい順にソート
  
//ｐ[i]の前半ｎ個のみ検証
 int j=0; 
 REP(i,n){
  //j番目の要素に対して
   ll q= que.top();
   
   if(p[j].second==0) j++;
   
   if(q>=p[j].first) break;
   else if(q<p[j].first&&p[j].second>0){
        que.pop();
        que.push(p[j].first);
        p[j].second--;
      }
 
 }

/*TLE
  rep(i,m){
    while(b[i]!=0){
      long long int q=que.top();
      if(q<c[i]){
        que.pop();
        que.push(c[i]);
         b[i]--;

      }else break;
    }

  }*/
  ll ans=0;

 while(!que.empty()){
    ans+=que.top();
    que.pop();
  }
    cout<<ans<<endl;
}


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

int main(){
    int n, e;
    cin >> n >> e;
    vector<char> c(n);
    for(int i = 0; i < n; i++) cin >> c[i];
    vector<int> v[n];
    while(e-- > 0){
	    int x, y;
	    cin >> x >> y;
	    v[x].push_back(y);
	    v[y].push_back(x);
    }
    for(int i = 0; i < n; i++){
	    if(c[i] != '?')	continue;
	    bool used[26] = {};
	    for(int j : v[i]){
	        if(c[j] != '?')	used[c[j]-'a'] = true;
	    }
	    for(int j = 0; j < 26; j++){
	        if(!used[j]){
		        c[i] = (char)('a' + j);
		        break;
	        }
        }
    }
    for(int i = 0; i < n; i++)	cout << c[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 9644
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
    WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#define _GLIBCXX_DEBUG
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100100;
const int MOD = 1000000007;
typedef pair<long long,long long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

char F[333][333];
bool already[333][333];

int main() {
    int N;cin >> N;
    int A,B;cin >> A >> B;
    int ans = 0;
    for(int i = 1;i<=N;i++){
        int digitsum = 0;
        int X = i;
        while(X > 0){
            digitsum += X%10;
            X /= 10;
        }
        if(digitsum >= A && digitsum <= B) ans += i;
    }
    cout << ans << endl;

    

    // PLEASE GIVE ME THE "ACCEPTED" !
}

Measured memory_bytes: 256
import bisect
N = int(input())
L = sorted([int(i) for i in input().split()])


ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        c = bisect.bisect_left(L, L[i]+L[j])

        ans += max(0, c-j-1)

        # print(i, j, c, c-j-1, ans)
print(ans)


Measured memory_bytes: 3188
#include <stdio.h>

int search(int A[], int n, int key)
{
    int i = 0;
    A[n] = key;
    while ( A[i] != key) {
        i++;
    }
    return i != n;
}

int main()
{
    int i, n, A[10000], q, key, sum = 0;
    scanf("%d", &n);
    for ( i = 0; i < n; i++){
        scanf("%d", &A[i]);
    }
    scanf("%d", &q);
    for ( i = 0; i < q; i++){
        scanf("%d", &key);
        if (search(A, n, key) == 1){
            sum++;
        }
    }
    printf("%d\n", sum);
    return 0;
}

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

int fibo(int n, int *A) {
  int ans;
  int n1, n2;

  if(n == 0 || n == 1) {
    ans = 1;
  } else {
    if(A[n-2] != 0) {
      n2 = A[n-2];
    } else {
      n2 = fibo(n-2, A);
    }
    if(A[n-1] != 0) {
      n1 = A[n-1];
    } else {
      n1 = fibo(n-1, A);
    }
    ans = n1+n2;
  }
  A[n] = ans;
  return ans;
}

int main() {
  int n, i;
  int ans;
  int *A;

  scanf("%d", &n);
  A = malloc(n*sizeof(int));

  for(i = 0; i < n; i++) {
    A[i] = 0;
  }

  ans = fibo(n, A);

  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 596
import java.util.*;
public class Main{
  public static void main(String [] args){
    Scanner sc = new Scanner(System.in);
    int a,b,i,c,d;
    while(sc.hasNext()){
      a = sc.nextInt();
      b = sc.nextInt();
      d = 1;
      for(i = 1;i <= Math.min(a,b);i++){
        if(a % i == 0 && b % i == 0)d = i;
      }
      c = a / d * b ;
      System.out.println(d + " " + c);
    }
  }
}

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

int main(void) {
  int n;
  cin >> n;

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

  sort(a.begin(), a.end());
  
  int res=a[0];
  while(true){
    for (int i = 1; i < n; i++) {
      if(a[i]%a[0]) {
	a[i]=a[i]%a[0];
      }
    }
    sort(a.begin(), a.end());
    if(res == a[0]) break;
    res = a[0];
  }

  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

/**
 * ABC044A
 */
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();

        int cost = 0;
        for (int i = 1; i <= N; i++) {
            if (i <= K) {
                cost += X;
            } else {
                cost += Y;
            }
        }

        System.out.println(cost);
        sc.close();
    }
}

Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n[] = sc.next().split("");
		for (int i = 0; i < n.length; i++)
			if (Integer.parseInt(n[i]) == 9) {
				System.out.println("Yes");
				return;
			}
		System.out.println("No");
	}
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define pb(a) push_back(a)
#define mp(x,y) make_pair(x,y)
#define ALL(a) a.begin(),a.end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,-1,sizeof(a))
#define len(a) sizeof(a)
#define ll long long
#define pii pair<int,int>
#define INF 1<<29
#define MAX 3010
using namespace std;

int n,t,s,a[MAX],b[MAX],dp[MAX][MAX];

void solve(){
 cin>>n>>t>>s;
 FOR(i,n) cin>>a[i]>>b[i];
 ZERO(dp);
 for(int i=n-1;i>=0;i--){
  for(int j=t;j>=0;j--){
   if(j+b[i]<=t){
    if(j<s&&s<j+b[i]){
     dp[i][j]=max(dp[i+1][j],dp[i][j+1]);
    }
    else{
     dp[i][j]=max(dp[i+1][j],dp[i+1][j+b[i]]+a[i]);
    }
   }
   else dp[i][j]=dp[i+1][j];
  }
 }
 cout<<dp[0][0]<<endl;
}

int main(){
 solve();
 return 0;
}

Measured memory_bytes: 38500
# coding=utf-8

if __name__ == '__main__':
    N = int(input())
    M = int(input())
    S = M
    for i in range(N):
        enter, exit = map(int, input().split())
        M += (enter-exit)
        if M < 0:
            print(0)
            break
        S = max(S, M)
    else:
        print(S)



Measured memory_bytes: 5612
#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
//#include <string.h>
#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define LL long long
#define pii pair<int,int>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a>b) cout<<a-1;
	else cout<<a;
    rt0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    ans += min(A[i], B[i])
    B[i] -= min(A[i], B[i])
    ans += min(A[i + 1], B[i])
    A[i + 1] -= min(A[i + 1], B[i])

print(ans)


Measured memory_bytes: 18624
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_3_C&lang=jp

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    while True:
        x, y = map(int, input().split())
        if x == 0 and y == 0:
            break
        if x > y:
            x, y = y, x
        print(x, y)


if __name__ == '__main__':
    main(sys.argv[1:])
    

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

const int MAXN = 200005;

int N, A[MAXN], nxt[MAXN], prv[MAXN], vis[MAXN];
long long K;

int main(){	
	scanf("%d %lld", &N, &K);
	for(int i = 0; i < N; i++)
		scanf("%d", &A[i]);
	
	memset(prv, -1, sizeof prv);
	for(int i = 0; i < 2 * N; i++){
		if(prv[A[i % N]] != -1){
			nxt[prv[A[i % N]]] = i % N;
		}
		prv[A[i % N]] = i % N;
	}
	/*
	for(int i = 0; i < N; i++)
		cout << nxt[i] << ' ';
	cout << endl;*/
	
	vector <int> ans;
	memset(vis, -1, sizeof vis);
	
	int j = 0, k = 0;
	while(k < K){
		if(nxt[j] > j){
			j = nxt[j] + 1;
			if(j >= N){
				j -= N;
				k++;
			}
		}else{
			if(k + 1 < K){
				j = nxt[j] + 1;
				k++;
				
				if(j >= N){
					j -= N;
					k++;
				}
			}else{
				ans.push_back(A[j]);
				
				j = j + 1;
				if(j >= N)break;
			}
		}
		
		if(vis[j] != -1){
			int d = k - vis[j];
			K = k + (K - k) % d;
		}
		vis[j] = k;
	}
	
	for(int i = 0; i < (int)ans.size(); i++){
		if(i > 0)printf(" ");
		printf("%d", ans[i]);
	}
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 5492
package main

import (
	"fmt"
	"math"
)

func main() {
	var a int
	poleList := make([]int, 6)
	for i := 0; i < 6; i++ {
		fmt.Scan(&a)
		poleList[i] = a
	}
	for i := 0; i < 5; i++ {
		nowViewPole := poleList[i]
		for j := i + 1; j < 5; j++ {
			subFloat := math.Abs(float64(nowViewPole - poleList[j]))
			if int(subFloat) > poleList[5] {
				fmt.Println(":(")
				return
			}
		}
	}
	fmt.Println("Yay!")
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=1e3+10;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,x[N],y[N];
bool check(int x,int y,int k) {
    if(k==-1) return x==0&&y==0;
    return (ll)abs(x)+abs(y)<(1<<(k+1));
}
void solve(int x,int y,int k) {
    if(k==-1) return;
    if(check(x-(1<<k),y,k-1)) { solve(x-(1<<k),y,k-1);putchar('R');return; }
    if(check(x+(1<<k),y,k-1)) { solve(x+(1<<k),y,k-1);putchar('L');return; }
    if(check(x,y-(1<<k),k-1)) { solve(x,y-(1<<k),k-1);putchar('U');return; }
    solve(x,y+(1<<k),k-1);putchar('D');return;
}
int main() {
    cin>>n;
    for(int i=1;i<=n;i++) {
        x[i]=gi(),y[i]=gi();
        if((abs(x[i]+y[i])&1)!=(abs(x[1]+y[1])&1)) return puts("-1"),0;
    }
    if(abs(x[1]+y[1])&1) {
        puts("31");
        for(int i=0;i<=30;i++) printf("%d ",1<<i);
        for(int i=1;i<=n;i++) puts(""),solve(x[i],y[i],30);
    }
    else {
        puts("32");
        printf("%d ",1);
        for(int i=0;i<=30;i++) printf("%d ",1<<i);
        for(int i=1;i<=n;i++) puts(""),putchar('R'),x[i]--,solve(x[i],y[i],30);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main() {
    int N;
    cin >> N;
    
    set<long long int> st;
    st.insert(2);
    for(int i=3; i<1382; i++) {
        bool flag=true;
        for(auto j=st.begin(); ((*j)*(*j)<=i || j!=st.end()); j++) {
            if(i%(*j)==0) {
                flag=false;
                break;
            }
        }
        if(flag) {
            st.insert(i);
        }
    }
    
    vector<long long int> ans;
    for(auto j=st.begin(); j!=st.end(); j++) {
        if(*j%5==1) {
            ans.push_back(*j);
        }
        if(ans.size()==N) break;
    }
    
    for(int n=0; n<N; n++) {
        cout << ans[n] << " ";
    }
    cout << endl;

    return 0;
    
}

Measured memory_bytes: 256
s = gets.chomp
def isYYMM(s)
    # 下2桁が01~12かどうか
    mm = s[2,2].to_i
    if mm > 0 && mm < 13
        true
    else
        false
    end
end

def isMMYY(s)
    #上2桁が01~12かどうか
    mm = s[0,2].to_i
    if mm > 0 && mm < 13
        true
    else
        false
    end
end

if isYYMM(s)
    if isMMYY(s)
        puts "AMBIGUOUS"
    else
        puts "YYMM"
    end
else
    if isMMYY(s)
        puts "MMYY"
    else
        puts "NA"
    end
end


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

using namespace std;

struct Point {
    int x, y;
};

int main() {

    int n, sx, sy;
    char line, graph[8][9];
    int vx[] = {0, 1, 0, -1};
    int vy[] = {-1, 0, 1, 0};

    cin >> n;

    for(int i = 1; i <= n; ++i) {

        // cin >> line;

        for(int j = 0; j < 8; ++j) {
            cin >> graph[j];
        }

        cin >> sx >> sy;

        queue<Point> q;
        q.push((Point){sx - 1, sy - 1});

        while(!q.empty()) {

            Point now = q.front(); q.pop();

            graph[now.y][now.x] = '0';

            for(int j = 0; j < 4; ++j) {
                for(int k = 1; k <= 3; ++k) {

                    Point next = now;
                    next.x = now.x + vx[j] * k;
                    next.y = now.y + vy[j] * k;

                    if(next.x >= 0 && next.x < 8 && next.y >= 0 && next.y < 8 && graph[next.y][next.x] == '1') {
                        q.push(next);
                    }

                }
            }

        }

        cout << "Data " << i << ":" << endl;

        for(int j = 0; j < 8; ++j) {
            cout << graph[j];
            cout << endl;
        }

    }

}

Measured memory_bytes: 1228
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
using namespace std;




int main() {

	int n,cop,coq;
	long long x, y,ss,tt;
	cin >> n;

	pair<long long, long long> p[51];
	for (int i = 0; i < n; i++) {
		cin >> x >> y;
		p[i] = make_pair(x, y);
		
	}
	int ans = n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j)continue;
			ss = p[i].first - p[j].first;
			tt = p[i].second - p[j].second;
			int t = n;
			for (int k = 0; k < n; k++) {
				
				for (int l = 0; l < n; l++) {

					if (p[k].first - p[l].first == ss && p[k].second - p[l].second == tt)
						t--;
				}
			}
			ans = min(ans, t);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	int[] list = new int[n];
		for(int i = 0; i < n; i++){
        	list[sc.nextInt()-1] = i+1;
        }
      	for(int i = 0; i < n; i++)
          System.out.print(list[i] + " ");
      	
    }
}

Measured memory_bytes: 62972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    ll a,b;
    cin>>a>>b;
    ll sum=0;
    if(a==1||b==1){
        cout<<1<<endl;
    }else{
    for(ll i=0;i<a;i++){
        if(i%2==0){
            sum+=(b+1)/2;
        }
        else{
            sum+=b/2;
        }
    }
    cout<<sum<<endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 7;
char str[maxn];
int N,M,P,X;
int s[maxn];
int main()
{
    while(~scanf("%d",&N))
    {
        for(int i = 1; i <= N; i++) cin>>s[i];
        scanf("%d",&M);
        while(M--)
        {
            int ans = 0;
            scanf("%d%d",&P,&X);
            for(int i = 1; i <= N; i++)
            {
                if(i == P) ans += X;
                else ans += s[i];
            }
            cout<<ans<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
//Author:- S_Aditya

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const ll mod=1e9+7;         
const int N=1e5+4;

ll dp[N]; //dp[i] stores the maximum profit to completely fill a knapsack of size i

int main()                  
{
    int n,w;
    
    scn(n); scn(w);
    
    int wt[n+1],cost[n+1];
    
    rep(i,1,n+1)
    {
        scn(wt[i]); scn(cost[i]);
    }
    
    rep(i,1,n+1)
    {
        //we iterate in reverse order to ensure that the same item is not considered multiple times
        for(int j=w-wt[i];j>=0;j--)
        {
            dp[j+wt[i]]=max(dp[j+wt[i]],dp[j]+1LL*cost[i]);
        }
    }
    
    ll ans=0;
    
    rep(i,0,w+1)
    ans=max(ans,dp[i]);
    
    lpri(ans);
} 


Measured memory_bytes: 1024
#include "stdio.h"
#include "string.h"

int c_key(char*S){
  if (strlen(S)!=7) {
    return -1;
  }
  char*K="keyence";
  for (size_t i = 0; i < 7; i++) {
    if (S[i]!=K[i]) {
      return -1;
    }
  }
  return 1;
}

int main(int argc, char const *argv[]) {
  char S[200];
  scanf("%s", S);
  int n=strlen(S);
  int i,j;
  char K[7];

  for (i = 0; i < 7; i++) {
    for (j = 0; j < i; j++) {
      K[j]=S[j];
    }
    for (j = i; j < 7; j++) {
      K[j]=S[n+j-7];
    }
    //printf("%s\n", K);
    if (c_key(K)==1) {
      printf("YES");
      return 0;
    }
  }
  printf("NO");
  return 0;
}

Measured memory_bytes: 128