akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

void InsertionSort(int A[], int N)
{
    // 出力
    for (int i = 0; i < N; i++) {
        i == N - 1 ? cout << A[i] << endl : cout << A[i] << " ";
    }

    for (int i = 1; i <= N - 1; i++) {

        int v = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;

        // 出力
        for (int i = 0; i < N; i++) {
            i == N - 1 ? cout << A[i] << endl : cout << A[i] << " ";
        }
    }
}

int main()
{
    int size = 0;
    int* list = NULL;

    // 入力
    cin >> size;
    list = new int[size];
    for (int i = 0; i < size; i++) {
        int t = 0;
        cin >> t;
        list[i] = t;
    }

    // 挿入ソート
    InsertionSort(list, size);

    delete[] list;

    return 0;
}


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

int main() {
  int H,W;
  cin >> H >> W;
  string frame = "##";
  
  for(int i=0; i<W; i++){
    frame += '#';
  }
  
  cout << frame << endl;
  for(int i=0; i<H ; i++){
    string temp = "";
    cin >> temp;
    cout << '#' << temp << '#' << endl;
  }
  
  cout << frame << endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define las(v) v[v.size()-1]
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;

vector<int> vs[18];
int N,A,B;


void prbit(int n){
  rrep(i, 17){
    cout<<(n / (1<<i))%2;
  }
  cout<<endl;
}

int slide(int n, int k){
  int b = n%2;
  n>>=1;
  n^=(b<<(k-1));
  return n;
}

void showvec(vector<int> v){
  rep(i, v.size()){
    cout<<i<<" ";
    prbit(v[i]);
  }
  cout<<endl<<endl;
}

vector<int> calcvs(int n){
  if(n==1){
    vector<int> v;
    v.push_back(0);
    v.push_back(1);
    vs[n] = v;
    return vs[n];
  }
  else{
    vector<int> v;
    vector<int> v0 = calcvs(n-1);
    rep(i, v0.size()) v.push_back(v0[i]);
    v.push_back(las(v) ^ (1<<(n-1)));
    rep1(i, v0.size()-1){
      v.push_back( v[1<<(n-1)] ^ v0[i] );
    }
    vs[n] = v;
    // if(n==4) showvec(v);
    return v;
  }
}

int r[18];

vector<int> f(int n, int k){ //f(4,3)で0000-1110のvector返す。
  if(k==1) return vs[n];
  if(k%2==0){
    cout<<"error";
  }
  std::vector<int> v0 = f(n-1, k-2);
  vector<int> v;
  rep(i, v0.size()){
    v.push_back(slide(v0[i], n-1));
  }
  v.push_back(las(v) ^ (1<<(n-1)) );
  v0 = f(n-1, 1);
  rep1(i, v0.size()-1){
    v.push_back(v[1<<(n-1)] ^ v0[i]);
  }
  return v;
}

vector<int> a0, a1;
vector<int> ans[18];
vector<int> x;

int main()
{
  cin>>N>>A>>B;
  calcvs(17);
  rep1(i, N){
    r[i] = (A>>(i-1)) & 1;
  }
  B^=A;
  int cnt = 0;
  rep1(i,N){
    if((B>>(i-1) ) &1) a1.pb(i);
    else a0.pb(i);
  }
  if(a1.size()%2 ==0){
    puts("NO");
    return 0;
  }
  cnt = a0.size();
  vector<int> v = f(N, a1.size());
  rep(i, v.size()){
    rep1(j, N){
      ans[j].pb((v[i]>>(j-1)) & 1);
    }
  }
  rep(i, v.size()){
    x.pb(0);
    rep(j,a0.size()){
      x[i] += (ans[1+j][i]<<(a0[j]-1));
    }
    rep(j,a1.size()){
      x[i] += (ans[a0.size()+1+j][i]<<(a1[j]-1));
    }
  }
  rep(i,x.size()){
    x[i]^=A;
  }
  puts("YES");
  rep(i, x.size()){
    cout<<x[i]<<((i==x.size()-1)?"\n":" ");
  }
}


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

ll mod=1000000007;

ll modpow(ll a,ll b){
	ll c=1;
	while(b>0){
		if (b%2==0){
			b/=2;
			a=(a*a)%mod;
		}
		else {
			b--;
			c=(c*a)%mod;
		}
	}
	return c;
}

int main()
{
	//freopen("input16.txt","r",stdin);freopen("output16.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll i,j,k,t,n,a[100000]={0};
	cin>>n;
	bool q=true;
	for (i=0;i<n;i++){
		cin>>t;
		a[t]++;
	}
	for (i=(n+1)%2;i<n;i+=2){
		if (i==0&&a[i]!=1){
			q=false;
			break;
		}
		if (i>0&&a[i]!=2){
			q=false;
			break;
		}
	}
	if (q==false){
		cout<<"0";
	}
	else {
		n/=2;
		cout<<modpow(2,n);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

ll rec(int n, ll x){
    if(n == 0) return 1;
    ll len = (1LL<<(n+1)) - 3;//n-1の長さ
    ll niku = (1LL<<n) - 1;
    if(x == 1)return 0;
    else if(x <= len+1) return rec(n-1, x-1);
    else if(x == len+2) return niku+1;
    else if(x <= (len+1)*2) return niku+1+rec(n-1, x-len-2);
    else return niku*2+1;
}

int main(){
    int n;
    ll x; 
    cin >> n >> x;
    cout << rec(n, x) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-5;
const ll MOD=1e9+7;
int main(){
    ll n;ll W;cin>>n>>W;
    vector<ll> w(n),v(n);
    vector<ll> s1,s2,s3,s4;
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
        if(i==0){
            s1.push_back(v[i]);
        }else if(w[i]==w[0]){
            s1.push_back(v[i]);
        }else if(w[i]==w[0]+1){
            s2.push_back(v[i]);
        }else if(w[i]==w[0]+2){
            s3.push_back(v[i]);
        }else{
            s4.push_back(v[i]);
        }
    }
    sort(all(s1));
    reverse(all(s1));
    sort(all(s2));
    reverse(all(s2));
    sort(all(s3));
    reverse(all(s3));
    sort(all(s4));
    reverse(all(s4));
    for(int i=1;i<s1.size();i++){
        s1[i]+=s1[i-1];
    }
    for(int i=1;i<s2.size();i++){
        s2[i]+=s2[i-1];
    }
    for(int i=1;i<s3.size();i++){
        s3[i]+=s3[i-1];
    }
    for(int i=1;i<s4.size();i++){
        s4[i]+=s4[i-1];
    }
    ll ans=0;
    for(ll i=-1;i<(int)s1.size();i++){
        for(ll j=-1;j<(int)s2.size();j++){
            for(ll k=-1;k<(int)s3.size();k++){
                for(ll l=-1;l<(int)s4.size();l++){
                    ll ii=i+1;
                    ll jj=j+1;
                    ll kk=k+1;
                    ll lll=l+1;
                    if(w[0]*(ii+jj+kk+lll)+jj+2LL*kk+3LL*lll>W)continue;
                    ans=max(ans,(i>=0?s1[i]:0)+(j>=0?s2[j]:0)+(k>=0?s3[k]:0)+(l>=0?s4[l]:0));
                }
            }
        }
    }
    cout<<ans<<endl;
}   


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

const int N = 100007;

int n, a[N], b[N];
long long ans;

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

  cin>>n;
  for(i=1;i<=n + 1;i++) {
    cin>>a[i];
  }
  for(i=1;i<=n;i++) {
    cin>>b[i];
  }

  for(i=1;i<=n;i++) {
    int defeat = min(a[i], b[i]);

    ans += defeat;

    a[i] -= defeat;
    b[i] -= defeat;

    defeat = min(a[i + 1], b[i]);

    ans += defeat;

    a[i + 1] -= defeat;
    b[i] -= defeat;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,m,k;

int main()
{

    cin>>n>>m>>k;
    ll sm=0,v=0;
    int ans=0;
    ll a[n+5],b[m+5];
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        sm+=a[i];
    }
    for(int i=0; i<m; i++)
    {
        cin>>b[i];

    }
    ll bs = 0;
    int bp = 0;

    for(int i=n; i>=0; i--)
    {
        if(i<n) sm-=a[i];
        if(sm<=k)
        {
            while(bp<m && sm+bs+b[bp]<=k)
            {
                bs+=b[bp];
                bp++;
            }
            ans=max(ans,i+bp);
        }


    }

    cout<<ans<<endl;

}


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



int main(void){
	int H,W,N;
	cin >> H >> W;
	cin >> N;
	int a[N+100];
	int board[H+100][W+100];
	for(int i = 0; i < N; i++){
		cin >> a[i];
	}
	int k = 0;
	for(int i = 0; i < H; i++){
		if(i % 2 == 0){
			for(int j = 0; j < W; j++){
				board[i][j] = k + 1;
				a[k]--;
				if(a[k] == 0)k++;
			}
		}else{
			for(int j = W-1; j >= 0; j--){
				board[i][j] = k + 1;
				a[k]--;
				if(a[k] == 0)k++;
			}
		}
	}
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cout << board[i][j];
			if(j != W-1){
				cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 384
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,ans=0;
int par[100010];
vector <pair <pii,int> > v[2];
vector <pair <int,pii> > con;

inline int getval(pair <pii,int> a,pair <pii,int> b)
{
	return min(abs(a.fi.fi-b.fi.fi),abs(a.fi.se-b.fi.se));
}

int FIND(int pos)//dsu
{
	if(par[pos]!=pos) par[pos]=FIND(par[pos]);
	return par[pos];
}

inline void UNION(int pos1,int pos2)
{
	par[FIND(pos1)]=FIND(pos2);
}

int main()
{ 
	cin>>n;
	rep(i,100005) par[i]=i;
	rep(i,n)
	{
		LL x,y;
		scanf("%I64d%I64d",&x,&y);
		v[0].pb({{x,y},i});
		v[1].pb({{y,x},i});
	}
	sort(v[0].begin(),v[0].end());
	sort(v[1].begin(),v[1].end());
	repn(i,n-1)
	{
		con.pb({getval(v[0][i-1],v[0][i]),{v[0][i-1].se,v[0][i].se}});
		con.pb({getval(v[1][i-1],v[1][i]),{v[1][i-1].se,v[1][i].se}});
	}
	sort(con.begin(),con.end());
	rep(i,con.size())
	{
		if(FIND(con[i].se.fi)==FIND(con[i].se.se)) continue;
		UNION(con[i].se.fi,con[i].se.se);
		ans+=con[i].fi;
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 14244
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    S = input().strip()
    if len(S) != 6:
        return "No"
    if S[2] == S[3] and S[4] == S[5]:
        return "Yes"
    else:
        return "No"


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	string s, t;
	cin >> s >> t;
	FORR(i, 0, s.length() - t.length() + 1) {
		bool f = true;
		REP(j, t.length()) if (s[i + j] != '?' && s[i + j] != t[j]) f = false;
		if (f) {
			REP(j, i) cout << (s[j] == '?' ? 'a' : s[j]);
			cout << t;
			FOR(j, i + t.length(), s.length()) cout << (s[j] == '?' ? 'a' : s[j]);
			return 0;
		}
	}
	cout << "UNRESTORABLE" << endl;
	return 0;
}
 

Measured memory_bytes: 256
/* Author : fenwick123 */

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

int main(){
    
    int x , y;
    cin >> x >> y;
    for (int k1 = 0; k1 <= x; k1++){
        int k2 = x - k1;
        if (k1 * 2 + k2 * 4 == y){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3588
def gcd(x, y):
    if x < y:
        tmp = x
        x = y
        y = tmp

    while y > 0:
        r = x % y
        x = y
        y = r

    return x

if __name__ == "__main__":
    x, y = map(int, input().split())
    print(gcd(x, y))

Measured memory_bytes: 7728
#include "bits/stdc++.h"
using namespace std;

int main()
{
	int d, g;
	vector<int> p, c;
	cin >> d >> g;
	for (int i = 0; i < d; i++)
	{
		int pp, cc;
		cin >> pp >> cc;
		p.push_back(pp);
		c.push_back(cc);
	}
	int ans = 100000;
	for (int use = 0; use < (1 << d); use++)
	{
		int ansTmp = 0;
		int score = 0;
		int maxNoUse = -1;
		for (int i = 0; i < d; i++)
		{
			if ((use >> i) & 1 == 1)//use
			{
				score += (i + 1) * p[i] * 100 + c[i];
				ansTmp += p[i];
			}
			else
			{
				maxNoUse = i;
			}
		}
		if (maxNoUse >= 0 && score < g)
		{
			int cnt = (g - score + (maxNoUse + 1) * 100 - 1) /
				((maxNoUse + 1) * 100);
			if (cnt >= p[maxNoUse])
			{
				ansTmp = 100000;
				continue;
			}
			else if (cnt > 0)
			{
				ansTmp += cnt;
			}
		}
		//cout << use << "  " << score << "  " << ansTmp << endl; //comment out
		ans = min(ans, ansTmp);
	}
		
	cout << ans << endl;
	return 0;
}

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

typedef int i32;
typedef long long i64;
typedef unsigned int u32;
typedef unsigned long long u64;


template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};


#define debug(x)  cerr<<x<<"\n";
#define loop(i,n) for(i32 i = 0; i < n; ++i)
#define pi  pair<int,int>
#define ti  tuple<int,int,int>
#define mt  make_tuple
#define mk  make_pair
#define vi  vector<int>
#define vll vector<i64>
#define fastInOut ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pr(a) for(auto x:a) cout<<x<<" ";
#define prmap(m) for(auto x:m) cout<<x.first<<" "<<x.second<<"\n";
using namespace std;

i64 n,m,k; 
int main(){
	cin>>n>>m>>k; 
	if(k>=n){
		k=k-n;
		n=0;
		if(k>m){
			cout<<0<<" "<<0;
		}
		else 
			cout<<0<<" "<<(m-k);
	}
	else {
		cout<<(n-k)<<" "<<m;
	}
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef  vector<int> vi;
typedef  pair<int,int> pii;
typedef  pair<int,string> pis;
double   pi=3.1415926535898;
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define r0         return 0;
#define CC         continue;
#define bb(x)      cerr<< x <<endl;
#define F          first
#define S          second       //  __builtin_popcount;
//freopen("output.txt","w",stdout),freopen("input.txt","r",stdin);
const ll M  = 1e9+7 ;
const int N = 100100;
const int inf = 2e9+7;
const double eps = 1e-7;
//////////////////////    Hi    ^_^  hack me if you can :P

int n, m ;
int a, b ;

set < int > sta, stb ;

int main()
{
    speed;
    cin >> n >> m;
    lop(i,m)
    {
        cin >> a >> b;
        if (a == 1) sta.insert(b);
        if (b == 1) sta.insert(a);

        if (a == n) stb.insert(b);
        if (b == n) stb.insert(a);
    }


    for (auto x:sta)
    {
        if (x!=n)
        if (stb.count(x))
        {
            cout << "POSSIBLE\n";
            return 0;
        }
    }

    cout << "IMPOSSIBLE\n" ;

    return 0;
}


Measured memory_bytes: 9600
n = int(input())
L = list(map(int, input().split()))

count_num = dict()
for num in L:
  if num not in count_num:
    count_num[num] = 1
  else:
    count_num[num] += 1

removals = 0
for k, v in count_num.items():
  if k == v:
    continue
  elif k < v:
    removals += (v - k)
  else:
    removals += v

print(removals)


Measured memory_bytes: 67368
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

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

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

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

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//MAX

ll MIN(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//MIN

bool p_judge(ll p) {

	if (p == 1)return false;
	else if (p == 2)return true;
	else {

		bool flag = true;
		for (int i = 2; i <= sqrt(p); i++) {

			if (p%i == 0) {

				flag = false;
				break;

			}

		}
		return flag;

	}

}
//素数判定,素数=true,合成数=false

int main() {

	ll A, B, K;

	cin >> A >> B >> K;

	for (int i = A; i <= B&&i <= A + K - 1; i++) {

		cout << i << endl;

	}
	for (int i = MAX(A + K, B - K + 1); i <= B; i++) {

		cout << i << endl;

	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int>vi;
#define pb push_back
#define sc(n) scanf("%d",&n)
#define lsc(n) scanf("%lld",&n)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define rev1(i,n) for(i=n;i>0;i--)
#define in insert
#define IT ::iterator
#define pr(n) printf("%d\n",n)
#define lpr(n) printf("%lld\n",n);


int main()
{
	ll n,i;
	cin >> n;
	vector<pair<ll,ll> >v;
	for(i=1LL;i*i<=n;i++)
	{
		if(n%i==0LL)
		{
			v.pb({i,n/i});
		}
	}
	ll sz=v.size();
	ll ans=1e18;
	for(i=0;i<sz;i++)
	{
		ans=min(ans,(v[i].first+v[i].second-2LL));
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <memory.h>
using namespace std;
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define red(i, a, b) for(int i = (a); i >= (b); i--)
#define ll long long
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define abs ABS

const int N = 2200;
int n, z, w;
int a[N];
bool f[N][N];
bool s[2][N];

int abs(int x)
{
	return x < 0 ? -x : x;
}

bool check(int k)
{
	memset(f, 0, sizeof(f));
	memset(s, 0, sizeof(s));
	rep(i, 1, n - 1)
	{
		if (i == 2) f[i][n] = 0;
		else if (abs(a[i] - a[n]) >= k) f[i][n] = 1;
		else f[i][n] = 0;
		s[0][i] = f[i][n];
	}
	rep(i, 1, n - 1)
	{
		if (i == 1) f[n][i] = 0;
		else if (abs(a[i] - a[n]) < k) f[n][i] = 1;
		else f[n][i] = 0;
		s[1][i] = f[n][i];
	}
	red(i, n - 1, 1)
	{
		red(j, n - 1, 2)
		{
			if (i == j) continue;
			if (i < j)
			{
				f[i][j] = s[1][j] ^ 1;
				s[0][i] &= f[i][j];
			}
			else
			{
				f[i][j] = s[0][i] ^ 1;
				s[1][j] &= f[i][j];
			}
		}
	}
	return f[1][2];
}

int main()
{
	scanf("%d%d%d", &n, &z, &w);
	a[1] = z; a[2] = w;
	rep(i, 3, n + 2) scanf("%d", &a[i]);
	n += 2;
	int l = 0, r = 1e9;
	while(l + 1 < r)
	{
		int mid = (l + r) >> 1;
		if (check(mid)) l = mid;
		else r = mid;
	}
	printf("%d\n", l);
	return 0;
}

Measured memory_bytes: 5120
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	string s;cin>>s;
	string t;cin>>t;
	ll a;cin>>a;
	ll b;cin>>b;
	string u;cin>>u;
	if(u==s) a--;
	else b--;
	cout<<a<<" "<<b<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;


map<string, int> memo;

using P=pair<int, int>;




/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value,vector<ll> a)
{
	
	for (ll i = 0; i < a.size();i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}
ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}

void comb(vector<vector <long long int> >& v) {
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}


int main() {
	int n;
	cin >> n;
	if (n == 1)cout << "Hello World" << endl;
	else {
		int a, b; cin >> a >> b;
		cout << a + b << endl;
	}
	return 0;
}













Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define mp make_pair
#define pb push_back
using namespace std;

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

// hash struct for unordered_map
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

int MAXNUM = 5e3+5;
vector <int>vis(MAXNUM);
vector<int> pr;
void sieve() {
	pr.push_back(2);
	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
		pr.push_back(i);
		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
	}
}
//************************************************************************

void solve()
{
    ll x,n;
    cin >> x >> n;
    map<int,int> m;
    for(int i=0;i<n;i++)
    {
        ll v;
        cin >> v;
        m[v-x]=1;
    }
    ll ans=0;
    for(int i=0;i<=100;i++)
    {
        if(m.find(-i)==m.end())
        {
            ans=x-i;
            break;
        }
        if(m.find(i)==m.end())
        {
            ans=x+i;
            break;
        }
    }
    cout << ans << endl;
}   


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

	return 0;
}

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

const int maxN = 1e5 + 10;

using namespace std;

#define FORU(i, l, r) for (int i = l; i <= r; ++i)
#define FORD(i, r, l) for (int i = r; i >= l; --i)
#define REPU(i, r) for (int i = 0; i < r; ++i)
#define LL long long
#define ULL unsigned long long
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define PINT pair < int, int >
#define BIT(x, i) ((x >> i) & 1)
#define NUM_SET_BIT __builtin_popcountll

double res, f[maxN], g[maxN], p[maxN], t[maxN], v[maxN], n;
vector < double > a;

int main() {
    cin >> n;
    FORU(i, 1, n) cin >> t[i];
    FORU(i, 1, n) cin >> v[i];
    
    a.PB(0);
    FORU(i, 1, n) {
        a[a.size() - 1] = min(a[a.size() - 1], v[i]);
        FORU(j, 1, t[i]) a.PB(v[i]), a.PB(v[i]);
    }

    REPU(i, a.size()) 
        f[i] = (i == 0) ? 0 : min(f[i - 1] + 0.5, a[i]);
    FORD(i, a.size() - 1, 0)
        g[i] = (i == a.size() - 1) ? 0 : min(g[i + 1] + 0.5, a[i]);
    REPU(i, a.size()) {
        p[i] = min(f[i], g[i]);
        if (i) res += (1.0 * (p[i] + p[i - 1])) / 4;
    }

    printf("%.9lf\n", res);
}


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

clues = []
for i in range(n):
    clues.append(tuple(map(int, input().split())))

sam_x, sam_y, sam_h = next((x, y, h) for x, y, h in clues if h > 0)

centers = [(x, y) for x in range(101) for y in range(101)]
for cx, cy in centers:
    ch = sam_h + abs(sam_x - cx) + abs(sam_y - cy)
    identified = True
    for x, y, h in clues:
        if h != max(ch - abs(x - cx) - abs(y - cy), 0):
            identified = False
            break
    if identified:
        print(cx, cy, ch)
        exit()

Measured memory_bytes: 3700
import java.util.*;

class Main{

    static int gcd(int x, int y){
        if( x < y ){
            int t = x;
            x = y;
            y = t;
        }
        if(y == 0) return x;
        return gcd(x % y, y);
    }
    public static void main(String[] args) {       
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int a[] = new int [n];
    Arrays.setAll(a, i -> stdIn.nextInt());
    int l[] = new int [n];
    int r[] = new int [n];
    int ans = 1;
    for(int i = 1 ; i < n; i++) l[i] = gcd(l[i-1], a[i-1]);
    for(int i = n - 2; i >= 0; i--) r[i] = gcd(r[i+1], a[i+1]);

    for(int i = 0; i < n; i++) ans = Math.max(ans, gcd(l[i], r[i]));
    System.out.println(ans);
   }
}


Measured memory_bytes: 51084
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    int N, R;
    cin >> N >> R;
    if (N >= 10)
    {
        cout << R << endl;
    }
    else
    {
        cout << (R + 100 * (10 - N)) << endl;
    }
    return 0;
}

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

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

    for (int i = 0; i < s.length(); i++) {
        if (i % 2 == 0 && s[i] == 'L') {
            cout << "No" << endl;
            return 0;
        }
        if (i % 2 == 1 && s[i] == 'R') {
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
}

Measured memory_bytes: 3628
#define _LIBCPP_DEBUG 0

#include<bits/stdc++.h>

using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int waru(int a) {
    int ans = 0;
    while (a % 100 == 0 && a>0) {
        ans++;
        a /= 100;
    }
    return ans;
}

int main(void) {

    int D, N;
    cin >> D >> N;
    int cnt = 0, val = 0;
    while (cnt < N) {
        val++;
        if (waru(val) == D) {
            cnt++;
        }
    }
    cout<<val<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const ll mod = 998244353;

ll dp[301][310][310];

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


	string S;
	int K;

	int kosuu = 0;
	int k = 0;
	int A[301] = {};

	cin >> S >> K;
	rep(i, S.size()) {
		if (S[i] == '0') k++;
		else {
			A[k]++;
			kosuu++;
		}
	}

	dp[k + 1][0][0] = 1;
	for (int i = k; i >= 0; i--) {
		auto ne = dp[i];;
		auto ma = dp[i + 1];

		rep(j, kosuu + 1)  rep(k, kosuu + 1) {
			ma[j][k] %= mod;
			rep1(p, k) ne[j][k - p] += ma[j][k];
			rep(p, A[i] + 1) ne[j + p][k + p] += ma[j][k];
		}
	}

	ll kotae = 0;
	rep(i, min(K, kosuu) + 1) {
		kotae += dp[0][i][0] % mod;
	}
	co(kotae % mod);



	Would you please return 0;
}

Measured memory_bytes: 59892
#include <algorithm>
#include <cmath>
#include <ctype.h>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define ENDL '\n'
#define FOR(i, n) for (int i = 0; i < n; i++)
#define FOR_EACH(i, v) for (auto&& i : v);

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

	int number;
	int digit[4];
	cin >> number;
	FOR(i, 4) {
		digit[3 - i] = number % 10;
		number /= 10;
	}

	int ans = 0;
	FOR(i, 8) {
		int b = i & 0x1 ? -digit[1] : digit[1];
		int c = i & 0x2 ? -digit[2] : digit[2];
		int d = i & 0x4 ? -digit[3] : digit[3];
		if (digit[0] + b + c + d == 7) {
			ans = i;
			break;
		}
	}

	FOR(i, 3) {
		cout << digit[i] << (ans & 0x1 << i ? '-' : '+');
	}
	cout << digit[3] << "=7" << ENDL;

	return 0;
}

Measured memory_bytes: 256
x,n=map(int,input().split())
if n!=0:
  pp=list(map(int,input().split()))
else:
  pp=[]
q=True
r=True
i=0
a=0
b=0
while q:
  if x+i not in pp:
    a=x+i
    q=False
  else:
    i+=1
i=0
while r:
  if x-i not in pp:
    b=x-i
    r=False
  else:
    i+=1  

if a-x==x-b:
  print(b)
elif a-x<x-b:
  print(a)
else:
  print(b)

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

template <typename T>
struct Graph {
    int V, E;
    struct Edge {
        int from, to;
        T cost;
    };
    vector<vector<Edge>> edge;
    vector<vector<T>> dist;
    vector<Edge> es;

    Graph(int V, int E) : V(V), E(E) {
        edge.assign(V, vector<Edge>(0));
        dist.assign(V, vector<T>(0));
    }

    void input(bool is_direct = false, bool index0 = false) {
        int a, b;
        T c;
        for (int i = 0; i < E; i++) {
            cin >> a >> b;
            if (!index0) a--, b--;
            edge[a].push_back((Edge){a, b, 0}), es.push_back((Edge){a, b, 0});
            if (!is_direct) edge[b].push_back((Edge){b, a, 0}), es.push_back((Edge){b, a, 0});
        }
    }

    void add_edge(int from, int to, T cost) {
        edge[from].push_back({from, to, cost});
        es.push_back({from, to, cost});
        E++;
    }

    vector<int> depth;
    vector<int> topological_sort() {
        queue<int> q;
        vector<int> TG, indegree(V, 0);
        depth.assign(V, 0);
        for (const auto &e : es) {
            indegree[e.to]++;
        }

        for (int i = 0; i < V; i++) {
            if (!indegree[i]) {
                q.push(i);
            }
        }
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            TG.push_back(v);
            for (const auto &e : edge[v]) {
                int to = e.to;
                indegree[to]--;
                if (!indegree[to]) {
                    q.push(to);
                    depth[to] = depth[v] + 1;
                }
            }
        }
        if (TG.size() == V)
            return TG;
        else
            return {};
    }
};

int main() {
    int n;
    cin >> n;
    Graph<int> g(n * (n - 1) / 2, 0);
    auto f = [&](int i, int j) {
        if (i > j) swap(i, j);
        return i * n - i * (i + 1) / 2 + j - i - 1;
    };
    for (int i = 0; i < n; i++) {
        int a0;
        cin >> a0;
        a0--;
        for (int j = 1; j < n - 1; j++) {
            int a1;
            cin >> a1;
            a1--;
            g.add_edge(f(i, a0), f(i, a1), 0);
            a0 = a1;
        }
    }
    vector<int> v = g.topological_sort();
    if (v.size()) {
        int ans = 0;
        for (int i = 0; i < v.size(); i++) {
            ans = max(ans, g.depth[i] + 1);
        }
        cout << ans << endl;
    } else
        cout << -1 << endl;
    return 0;
}

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

#define  all(v)            v.begin(), v.end()
#define  sz(x)             (int)x.size()
#define  debug(x)          cout << #x << ':' << x << endl;
#define  rep(i,n)          for(long long i = 0; i <  n ; i++)
#define  reps(i,n)         for(long long i = 1; i <= n ; i++)
#define  make_unique(v)    sort(all(v));v.erase(unique(all(v)), v.end());
#define  REMOVE(v,a)       v.erase(remove(v.begin(),v.end(), a), v.end());
#define  pb                push_back
#define  mp                make_pair
#define  endl              '\n'
#define  fi                first
#define  se                second
#define  ajs(a)            (a<0)?(-1*a):a

using namespace std;
typedef long long          ll;
typedef vector<long long>  vll;
typedef pair<ll,ll>        pll;
const ll MOD = 1e9+7;
bool cmp(int X, int Y) {return X > Y;}
const double EPS = (1e-7);
int dcp(double A, double B){return fabs(A-B)<=EPS ? 0 : A<B ? -1:1;}
ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll lcm(ll a, ll b) {return (a / gcd(a, b)) * b;}
ll modpow(ll a, ll b, ll m=MOD){a %= m; ll res = 1; while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){if(b<0){return 0;}ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
 
const int N = 100005;
vll adj[N];




int main(){ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
string s;cin>>s;
ll n = s.length();
if(s[n-1]!='s'){
	s+='s';
	}else{
	s+='e';
	s+='s';
		}
	cout<<s;
}		
		
				




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

unsigned euclidean_gcd(unsigned a, unsigned b)
{
    if (a < b)
        return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

int main()
{
    long long N;
    cin >> N;
    vector<int> A(N, 0);

    for (int i = 0; i < N;i++)
        cin >> A[i];

    int num = 1;
    int ind = 0;
    while(ind < N){
        if(num == A[ind])
            num++;
        ind++;
    }
    int ans = -1;
    if(num != 1)
        ans = N - num + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <iomanip>
#include <cmath>
using namespace std;
#define mod (long)(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int main(){
    int N;
    cin >> N;
    double ans = 0;
    for(int i = 0; i < N; i++){
        double x;
        string u;
        cin >> x >> u;
        if(u == "BTC"){
            x *= 380000;
        }
        ans += x;
    }
    fcout << ans << endl;
}


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

int main() {
char b;
cin >> b;
if(b=='A'){
	cout << 'T';
}
else if(b=='T'){
	cout << 'A';
}
else if(b=='C'){
	cout << 'G';
}
else if(b=='G'){
	cout << 'C';
}
	return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val Array(l,r) = readLine.split(" ").map(_.toInt)
  val lm = l % 2019
  val rm = r - (l-lm)
  if(rm>=2019){
    println(0)
  }else{
    println((lm to rm).map{i =>
      (i+1 to rm).map{j => (i*j)%2019}.foldLeft(2019)(math.min(_,_))
    }.min)
  }
}

Measured memory_bytes: 49596
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef long long ll;

int main(void){
  ll n, k;
  cin >> n >> k;

  ll cnt = 0;
  if(k % 2 == 1){
    ll tmp1 = n / k;
    cout <<(ll)tmp1 * tmp1 * tmp1 << endl;
  }
  else {
    ll tmp2 = n / k;
    cnt += (ll)tmp2 * tmp2 * tmp2;
    ll tmp3 = 2 * n / k - tmp2;
    cnt += (ll)tmp3 * tmp3 * tmp3;
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        int n = sc.nextInt();
        String x = sc.next();

        StringBuilder sb = new StringBuilder();
        sb.append(x);

        if (x.length() <= n) {
            System.out.println(x);
        } else {
            System.out.println(x.substring(0, n) + "...");
        }

        sc.close();
    }

}


Measured memory_bytes: 38632
s=input()
f=int(s[:2])
b=int(s[2:])
if 0<f<13 and 0<b<13:
    print('AMBIGUOUS')
elif 0<b<13:
    print('YYMM')
elif 0<f<13:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 9124
#![allow(unused_macros)]
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(unused_imports)]
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => (::std::cmp::max($x, max!($($y),+)));
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => (::std::cmp::min($x, min!($($y),+)));
}

// solution 
use std::cmp;
use std::collections::{HashMap, HashSet, BTreeMap, BTreeSet, VecDeque};
fn main() {
    input! {
        H: usize,
        W: usize,
        map: [chars; H],
    }

    let mut mapp = vec![ vec![ false; W+2]; H+2];
    let mut count = 0;
    for row in 0..H {
        for col in 0..W {
            if map[row][col] == '.' {
                mapp[row+1][col+1] = true;
                count += 1;
            }
        }
    }

    let map = mapp;
    let mut searched_map = vec![ vec![ 0; W+2]; H+2];
    let mut queue = VecDeque::with_capacity(4*H*W);
    queue.push_back((1, 1, 1));
    while let Some((row, col, score)) = queue.pop_front() {
        if !map[row][col] || searched_map[row][col] > 0 {
            continue;
        }
        searched_map[row][col] = score;
        queue.push_back((row+1, col, score+1));
        queue.push_back((row-1, col, score+1));
        queue.push_back((row, col+1, score+1));
        queue.push_back((row, col-1, score+1));
    }

    if searched_map[H][W] == 0 {
        println!("-1");
    } else {
        println!("{}", count - searched_map[H][W])
    }
}


Measured memory_bytes: 4476
# 値を取得
num = int(input())
# 返す変数準備
ans = ''
# 一文字ずつリストに格納
n = list(str(num))
# 1 or 9か確かめ格納しなおす
for i in range(len(n)):
    if str(n[i]) == '1':
        (n[i]) = '9'
    elif str(n[i]) == '9':
        (n[i]) = '1'
    ans += n[i]
# 回答の出力
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_ss(void) {
	string s;
	cin >> s;
	int num = 1;

	for (int i = 1; i < s.size()-1; i++) {
		string sub_s = s.substr(0, s.size() - i);
		if ((sub_s.size() & 0x1) == 0x1)continue;
		int half = sub_s.size() >> 1;
		string sub_s_upper = sub_s.substr(0, half);
		string sub_s_lower = sub_s.substr(half, sub_s.size());
		if (sub_s_upper == sub_s_lower) {
			num = sub_s.size();
			break;
		}
	}

	cout << num << endl;
}

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

Measured memory_bytes: 3604
n = gets.to_i
h = gets.split.map(&:to_i)

dp = []
dp[0] = 0
dp[1] = (h[0] - h[1]).abs

2.upto(n-1) { |i|
  dp[i] = [dp[i-1] + (h[i] - h[i-1]).abs, dp[i-2] + (h[i] - h[i-2]).abs].min
}

puts dp[n-1]


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

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<ll>;
using vpii = vector<pii>;
using mpii = map<int, int>;
using mpci = map<char, int>;
using mpsi = map<string, int>;
using si = set<int>;
using sll = set<ll>;

#define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
const int MAX = 510000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

bool custom1 (pii a, pii b) {
  return (a.first < b.first);
}

bool custom2 (pii a, pii b) {
  return (a.second < b.second);
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<double> p(n);
  vector<long long> total(1001);
  for(int i=1;i<total.size();i++) {
    total[i] = total[i-1] + i;
  }
  for(int i=0;i<n;i++) cin >> p[i];
  vector<double> e(n);
  for(int i=0;i<n;i++) {
    e[i] = (double)total[p[i]] / p[i];
  }

  double ans = 0;
  double now = 0;
  for(int i=0;i<=n-k;i++) {
    if(i == 0) {
      for(int j=0;j<k;j++) {
        now += e[j];
      }
      ans = now;
    }
    else {
      now = now - e[i-1] + e[i+k-1];
      if(now > ans) ans = now;
    }
  }

  cout << setprecision(20) << ans << endl;
  return 0;
}

Measured memory_bytes: 3328
//2018.09.15 2min

#include <iostream>
using namespace std;

int main() {

    int N;
    cin >> N;

    if(N<105)cout << '0' << endl;
    else if(N==105) cout << '1' << endl;
    else{
        int ans=1;
        int i, j, num=0;

        for(i=107;i<=N;i+=2){
            for(j=1;j<=i;j++) {
                if (i % j == 0) num++;
            }
            if(num==8)ans++;
            num=0;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

int main(){
  int x,y,z;
  cin>>x>>y>>z;
  cout<<(x-z)/(y+z)<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String[] args){
  	Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int city[] = new int[n];
    for(int i = 0; i < n; i++){
      city[i] = sc.nextInt();
      city[i] = Math.abs(city[i] - x);
    }
    
    int max = city[0];
    for(int i = 0; i < n; i++)
    	max = max > city[i] ? gcd(max, city[i]) : gcd(city[i], max);
    System.out.println(max);
    
  }
  
  static int gcd(int a, int b){
	if (b == 0) return(a);
	return(gcd(b, a % b));
  }
}

Measured memory_bytes: 50608