akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};


template< typename T, typename F >
T boruvka(int N, F f) {
  vector< int > rev(N), belong(N);
  UnionFind uf(N);
  T ret = T();
  while(uf.size(0) != N) {
    int ptr = 0;
    for(int i = 0; i < N; i++) {
      if(uf.find(i) == i) {
        belong[i] = ptr++;
        rev[belong[i]] = i;
      }
    }
    for(int i = 0; i < N; i++) {
      belong[i] = belong[uf.find(i)];
    }
    auto v = f(ptr, belong);
    bool update = false;
    for(int i = 0; i < ptr; i++) {
      if(~v[i].second && uf.unite(rev[i], rev[v[i].second])) {
        ret += v[i].first;
        update = true;
      }
    }
    if(!update) return -1; // notice!!
  }
  return ret;
}


using int64 = long long;
const int64 INF = 1LL << 60;

int main() {
  int64 N, D, A[200000];
  cin >> N >> D;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }


  using pii = pair< pair< int64, int >, pair< int64, int > >;
  using pi = pair< int64, int >;
  auto f1 = [](pii a, const pi &p) {
    if(a.first.second == p.second) {
      a.first.first = min(a.first.first, p.first);
    } else if(a.second.second == p.second) {
      a.second.first = min(a.second.first, p.first);
      if(a.first > a.second) swap(a.first, a.second);
    } else {
      if(p < a.first) {
        a.second = a.first;
        a.first = p;
      } else if(p < a.second) {
        a.second = p;
      }
    }
    return a;
  };


  function< vector< pair< int64, int > >(int, vector< int >) > f = [&](int sz, vector< int > belong) {
    vector< pair< int64, int > > ret(sz, {INF, -1});

    {
      pii uku(make_pair(INF, -1), make_pair(INF, -1));
      for(int i = 0; i < N; i++) {
        auto e = uku.first.second == belong[i] ? uku.second : uku.first;
        e.first += A[i];
        e.first += i * D;
        ret[belong[i]] = min(ret[belong[i]], e);
        uku = f1(uku, pi(-i * D + A[i], belong[i]));
      }
    }
    {
      pii uku(make_pair(INF, -1), make_pair(INF, -1));
      for(int i = N - 1; i >= 0; i--) {
        auto e = uku.first.second == belong[i] ? uku.second : uku.first;
        e.first += A[i];
        e.first -= i * D;
        ret[belong[i]] = min(ret[belong[i]], e);
        uku = f1(uku, pi(i * D + A[i], belong[i]));
      }
    }
    return ret;
  };
  cout << boruvka< int64, decltype(f) >(N, f) << endl;
}









Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

int main(){
    int N, ai, i, ans=0;
    cin >> N;
    unordered_map<int, int> mp;

    for (i=0; i<N; i++) {
        cin >> ai;
        if (mp[ai] == 1) mp[ai] = 0;
        else mp[ai] = 1;
    }

    for (auto itr =mp.begin(); itr != mp.end(); ++itr) {
        ans += itr->second;
    } 

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


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

int gcd(int x, int y);

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int main() {
    int h, w;
    cin >> h >> w;
    vector<int> ver(h, 0);
    vector<int> heng(w, 0);
    vector<vector<int> > mozi(h, vector<int> (w));
    rep(i, h)rep(j, w) {
        char c;
        cin >> c;
        if (c == '#')
            mozi[i][j] = 0;
        else {
            mozi[i][j] = 1;
            ver[i]++;
            heng[j]++;
        }
    }

    rep(i, h) {
        if (ver[i] == w) continue;
        rep(j, w) {
            if (heng[j] == h) continue;
            if (mozi[i][j] == 0)
                cout << '#';
            else
                cout << '.';
        }
        cout << endl;
    }

    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

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

int F[45];

void Fibo(int n){
int i;
F[0] = 1;
F[1] = 1;
for(i=2 ; i<=n ; i++)F[i] = F[i-2] + F[i-1];


}

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

Fibo(n);

printf("%d\n",F[n]);
return 0;
}



Measured memory_bytes: 2052
n = int(input())
h = [int(i) for i in input().split()]
f = []
for i in range(n):
    if i == 0:
        f.append(0)
    elif i==1:
        f.append(abs(h[i]-h[i-1]))
    else:
        f.append(min(f[i-1]+abs(h[i]-h[i-1]),f[i-2]+abs(h[i]-h[i-2])))
print(f[n-1])

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

using namespace std;
 
typedef long long int ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector <string> vs;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pi;

//#define int ll
#define forl(i,a,b) for (int i = a; i < b; i++)
#define rfor(i,b,a) for (int i = b; i >= a; i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(), x.end())
#define sumup(x) accumulate(x.begin(), x.end(), 0)
#define PI 3.141592653589793238
#define MOD 1000000007
#define loop(n) for(int i = 0; i < n; i++)
#define rloop(n) for(int i = n-1; i >= 0; i--)

void io() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

void solve() {
    int n, a, b, c;
    cin>>n>>a>>b>>c;
    map <char,int> val;
    val['A']=a;
    val['B']=b;
    val['C']=c;
    bool flag =true;
    vector <char> chars;
    vs st(n);
    loop(n) {
        cin>>st[i];
    }
    loop(n) {
        if(flag) {
            if(val[st[i][0]]==0 && val[st[i][1]]==0) {
                flag=false;
                break;
            }
            else {
                if((val['A']+val['B']+val['C'])==2 && val[st[i][0]]==1 && val[st[i][1]]==1) {
                    if(i<n-1) {
                        if(st[i+1][0]==st[i][0] || st[i+1][1]==st[i][0]) {
                            val[st[i][1]]--;
                            val[st[i][0]]++;
                            chars.pb(st[i][0]);
                        }
                        else if(st[i+1][0]==st[i][1] || st[i+1][1]==st[i][1]) {
                            val[st[i][0]]--;
                            val[st[i][1]]++;
                            chars.pb(st[i][1]);
                        }
                    }
                    else {
                        val[st[i][1]]--;
                        val[st[i][0]]++;
                        chars.pb(st[i][0]);
                    }
                }
                else if(val[st[i][0]]>=val[st[i][1]]) {
                    val[st[i][0]]--;
                    val[st[i][1]]++;
                    chars.pb(st[i][1]);
                }
                else {
                    val[st[i][1]]--;
                    val[st[i][0]]++;
                    chars.pb(st[i][0]);
                }
            }
        }
    }
    if(!flag) cout<<"No\n";
    else {
        cout<<"Yes\n";
        for(auto &ch: chars) cout<<ch<<"\n";
    }
    return;
}
int32_t main() {
    io();
    int t=1;
    //cin>>t;
    while(t--) {
        solve();
    }
    return 0;
}

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

#define            read              freopen("in.txt", "r", stdin);
#define            ll                long long
#define            mx                100005

using namespace std;

struct info
{
	int v, c;
}ara[25];

int main()
{
	int n, x=0, y=0;

	cin >> n;

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

	//sort(ara, ara+n);

	for(int i = 0; i < n; i++)
	{
		if(ara[i].v-ara[i].c>0)
		{
			x+= ara[i].v;
			y+= ara[i].c;
		}
	}

	cout << (x-y) << endl;

	return 0;
}

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


long long N;
pair<long long, int> data[100001];

int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        long long a;
        cin >> a;
        data[i] = make_pair(a, i+1);
    }
    data[N] = make_pair(0, 0);
    sort(data, data+N+1, greater<pair<long long, long long> >());
    long long ans[100001] = {};
    int next = data[0].second;
    for(int i = 0; i < N; i++){
        ans[next] += (i+1) * (data[i].first - data[i+1].first);
        next = min(next, data[i+1].second);
    }
    for(int i = 1; i <= N; i++){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 3456
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N =  int(input())
divide = make_divisors(N)
divide.sort()
LEN = len(divide)
LENG = LEN//2

ans = divide[LENG]
an = N//ans
print(ans-1+an-1)

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

public class Main {
    private static IO io = new IO();
    public static void main(String[] args) {

        int ans[] = new int[51];
        for (int a = 0; a < 10; a++) for (int b = 0; b < 10; b++)
            for (int c = 0; c < 10; c++) for (int d = 0; d < 10; d++)
                ans[a+b+c+d]++;

        while (io.hasNext()) System.out.println(ans[io.nextInt()]);

    }

    static class IO extends PrintWriter {
        private final InputStream in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        IO() {
            this(System.in);
        }

        IO(InputStream source) {
            super(System.out);
            this.in = source;
        }

        boolean hasNextByte() {
            if (ptr < buflen) return true;
            else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) return false;
            }
            return true;
        }
        int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }
        boolean isPrintableChar(int c) {return 33<=c &&c <=126;}
        void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr]))ptr++;}
        boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }

        int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public void close() {
            super.close();
            try {
                in.close();
            } catch (IOException ignored) {
            }
        }
    }
}

Measured memory_bytes: 24044
#include <iostream>
using namespace std;
int main(){
    int A[9];
    cin >> A[0] >> A[1] >> A[2];
    cin >> A[3] >> A[4] >> A[5];
    cin >> A[6] >> A[7] >> A[8];
    int n;
    cin >> n;
    int b;
    for(int i = 0; i < n; i++){
        cin >> b;
        for(int j = 0; j < 9; j++){
            if(A[j] == b) A[j] = -1;
        }
    }
    for(int i = 0; i < 3; i++){
        bool f = true;
        for(int j = 0; j < 3; j++){
            if(A[3*i+j] != -1){
                f = false;
                break;
            }
        }
        if(f == true){
            cout << "Yes";
            return 0;
        }
    }
    for(int i = 0; i < 3; i++){
        bool f = true;
        for(int j = 0; j < 3; j++){
            if(A[i+3*j] != -1){
                f = false;
                break;
            }
        }
        if(f == true){
            cout << "Yes";
            return 0;
        }
    }
    if((A[0] == -1 && A[4] == -1 && A[8] == -1) || (A[2] == -1 && A[4] == -1 && A[6] == -1)){
        cout << "Yes";
        return 0;
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
   



int main(){
   IOS
   int n; cin>>n;
   cout<<(1000 - n % 1000)%1000;
   





}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
   if(b&1) res = res * a % mod;
        a = a * a % mod;
   b >>= 1;
    }

    return res;
}



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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll N;
    cin >> N;
    vector<double> v;
    REP(i, N)
    {
        ll n;
        cin >> n;
        v.push_back(n);
    }

    REP(i, N - 1)
    {
        sort(v.begin(), v.end());
        double n = (v[0] + v[1]) * 0.5;
        vector<double> u;
        FOR(j, v.size(), 2)
        {
            u.push_back(v[j]);
        }
        u.push_back(n);
        v = u;
    }

    cout << OF64 << v[0] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
const int MAXN = 100001;
const int MAXM = 100001;
ll dp[MAXN];
int main(){
    memset(dp,-1, sizeof(dp));
    int N,M; cin >> N >> M;
    int A[MAXM];
    dp[0] = 1;
    dp[1] = 1;
    rep(i,M){
        cin >> A[i];
        dp[A[i]] = 0;
    }
    for(int i=2;i<=N;i++){
        if(dp[i]!= 0)dp[i] = ((dp[i-1]%MOD) + (dp[i-2]%MOD))%MOD;
        dp[i] %= MOD;
    }
    cout << max((ll)0,dp[N]) << endl;
    return 0;
}

Measured memory_bytes: 4576
#!/usr/bin/env python3

def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n%i == 0:
            return False
    return True

x = int(input())
for i in range(x, 2*x+1):
    flg = is_prime(i)
    if flg == True:
        ans = i 
        break
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>

using namespace std;


int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    vector<int> dp(n,1<<30);
    dp[0] = 0;
    
    for(int i = 0; i < n;i++){
        for(int j = 0; j<k; j++){
            if(i+j+1<n) dp[i+j+1] = min(dp[i+j+1],dp[i]+abs(h[i]-h[i+j+1]));
        }
    }
    cout << dp[n-1];
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

template<class Pred>
int binsearch(const Pred &pred) {
    int val = 0;
    for(int bit = 17; bit >= 0; --bit) {
        const int next = val + (1<<bit);
        val = pred(next) ? next : val;
    }
    return val;
}

bool solve() {
    int W, N;
    scanf("%d %d", &W, &N);
    if(!W && !N) return false;

    vector<long long> sum(N+2, 0);
    TIMES(i, N) {
        int v;
        scanf("%d", &v);
        sum[i+1] = v;
        sum[i+1] += sum[i];
    }
    sum[N+1] = sum[N];

    vector<int> dp(N+3, 0);
    int ans = binsearch([&](long long x) {
        if(x > W) return false;
        fill(dp.begin(), dp.end(), 0);
        dp[N+2] = 0;
        dp[N+1] = 1;
        for(int i = N; i > 0; --i) {
            const int mink = binsearch([&](int k) {
                if(i+k > N) return false;
                const long long len = (sum[i+k] - sum[i-1]) + k*x;
                return len < W;
            }) + 2;
            const int maxk = binsearch([&](int k) {
                if(i+k > N) return false;
                const long long len = (sum[i+k] - sum[i-1]) + k;
                return len <= W;
            }) + 1;
            //cout << x << ' ' << i << ' ' << mink << ' ' << maxk << endl;
            dp[i] = (i+maxk == N+1) || (mink <= maxk && dp[i+mink] - dp[i+maxk+1] > 0);
            //cout << dp[i] << endl;
            dp[i] += dp[i+1];
        }
        return dp[1] - dp[2] == 0;
    }) + 1;
    printf("%d\n", ans);
    return true;
}

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

Measured memory_bytes: 1756
#include<stdio.h>
int main(void){
int a,b,c,d;
  scanf("%d%d%d",&a,&b,&c);
  d=b/a;
  if(d>=c){
  printf("%d",c);
  }else if(d<c){
  printf("%d",d);
  }
  return 0;
}


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

namespace {
    int N;
    vector<double> A;
    bool input() {
        cin >> N;
        if (N == 0) return false;
        A.clear();
        A.resize(N, 0);
        for (int i = 0; i < N; i++) {
            cin >> A[i];
        }
        return true;
    }
    void solve() {
        double avg = 0;
        for (int i = 0; i < N; i++) avg += A[i];
        avg /= N;
        int count = 0;
        const double eps = 1e-6;
        for (int i = 0; i < N; i++) {
            count += (A[i] <= avg + eps);
        }
        cout << count << endl;
    }
}

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



Measured memory_bytes: 3308
#include <iostream>
#include <string>

using namespace std;

int main() {
	int n;
	string b;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int out = 0;
		int sco = 0;
		int rui[3] = {0};
		while (out != 3) {
			cin >> b;
			if (b == "OUT") {
				out++;
			} else if (b == "HIT") {
				for (int j = 2; j >= 0; j--) {
					if (rui[j] == 1) {
						if (j == 2) {
							sco++;
							rui[j] = 0;
						} else {
							rui[j+1] = 1;
							rui[j] = 0;
						}
					}
				}
				rui[0] = 1;
			} else {
				sco++;
				for (int j = 0; j < 3; j++) {
					if (rui[j] == 1) {
						rui[j] = 0;
						sco++;
					}
				}
			}
		}
		cout << sco << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

int r, c, k;
ll dp[3005][3005][4];
v2<ll> g;

ll f(int i, int j, int k){
    if(i<0||j<0||k<0) return 0;
    if(dp[i][j][k] != -1) return dp[i][j][k];

    // dp[i][j][k] = max(f(i-1, j, k), f(i, j-1, k));
    // if(g[i][j]){
    //     dp[i][j][k] = max({dp[i][j][k], g[i][j]+f(i-1, j, k-1), g[i][j]+f(i, j-1, k-1)});
    // }
    // return dp[i][j][k];

    ll samerow = f(i, j-1, k);
    ll samecol = 0;
    for(int l = 0; l < 3; ++l){
        samecol = max(samecol, f(i-1, j, l));
    }
    dp[i][j][k] = max(samerow, samecol);

    if(g[i][j]){
        ll samerowtake = g[i][j] + f(i, j-1, k-1);
        ll samecoltake = 0;
        for(int l = 0; l < 3; ++l){
            samecoltake = max(samecoltake, g[i][j] + f(i-1, j, l));
        }
        dp[i][j][k] = max({dp[i][j][k], samerowtake, samecoltake});
    }

    return dp[i][j][k];
}

void solve(){
    cin >> r >> c >> k;
    g = fill(r, c, 0LL);
    for(int i = 0; i < k; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        g[a][b] = c;
    }

    for(int i = 0; i < r+1; ++i){
        for(int j = 0; j < c+1; ++j){
            for(int k = 0; k < 4; ++k){
                dp[i][j][k] = -1;
            }
        }
    }

    ll ans = 0;
    for(int i = 0; i < 3; ++i) ans = max(ans, f(r-1, c-1, i));
    cout << ans << '\n';
}

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

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	string s[3];
	cin >> s[0] >> s[1] >> s[2];
	cout << s[0][0] << s[1][0] << s[2][0] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>	
using namespace std;
#define ll long long 
vector<vector<int>> l(100001);
//int used[100001][100001];
int col[100001];
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;
}

int main() {
    int n,k;
    cin >> n >> k;
    // 前処理
    COMinit();
    ll res = 0;
    // 計算例
    for(int i = 1;i<k+1;i++){
      cout << COM(n-k+1,i)*COM(k-1,i-1) %MOD << endl;
  
    } 
}

Measured memory_bytes: 17488
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N,K = MI()
A = LI()

left = 0
right = max(A)  # 可能
while left + 1 < right:
    mid = (left + right)//2
    if sum((A[i]+mid-1)//mid - 1 for i in range(N)) <= K:
        right = mid
    else:
        left = mid
print(right)


Measured memory_bytes: 93964
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int main(){
  int n, t, a;cin>>n>>t>>a;
  double H=double(t-a)/0.006;
  double min_dif = INF;int ans=0;
  for(int i=0;i<n;i++){
    int h;cin>>h;
    if(abs(h-H)<min_dif){
      min_dif=abs(h-H);
      ans=i+1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;

int main() {
    int A, B, M;
    cin >> A >> B >> M;
    int a[A], b[B], mina = INF, minb = INF;
    for (int i = 0; i < A; i++) {
        cin >> a[i];
        mina = min(mina, a[i]);
    }
    for (int i = 0; i < B; i++) {
        cin >> b[i];
        minb = min(minb, b[i]);
    }
    int ans = mina + minb;
    for (int i = 0, x, y, c; i < M; i++) {
        cin >> x >> y >> c;
        x--; y--;
        ans = min(ans, a[x] + b[y] - c);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
class Node
  attr_accessor :left, :right, :parent, :value

  def initialize(value)
    @value = value
  end
end

class Tree
  def initialize
    @root = nil
  end

  def insert(node)
    parent = nil
    x = @root
    until x.nil?
      parent = x
      if node.value < x.value
        x = x.left
      else
        x = x.right
      end
    end

    node.parent = parent
    if parent.nil?
      @root = node
    elsif node.value < parent.value
      parent.left = node
    else
      parent.right = node
    end
  end

  def in_order(node = @root, arr = [])
    in_order(node.left, arr) if node.left
    arr << node.value
    in_order(node.right, arr) if node.right
    arr
  end

  def pre_order(node = @root, arr = [])
    arr << node.value
    pre_order(node.left, arr) if node.left
    pre_order(node.right, arr) if node.right
    arr
  end

  def find(value)
    x = @root
    until x.nil?
      return true if x.value == value

      if x.value > value
        x = x.left
        next
      end

      x = x.right if x.value < value
    end
    false
  end
end


tree = Tree.new
gets.to_i.times do
  command, value = gets.split

  case command
  when 'insert'
    tree.insert(Node.new(value.to_i))
  when 'find'
    puts tree.find(value.to_i) ? 'yes' : 'no'
  when 'print'
    puts "\s" + tree.in_order.join("\s")
    puts "\s" + tree.pre_order.join("\s")
  end
end



Measured memory_bytes: 55576
#include <stdio.h>
#include <stdlib.h>
 
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
 
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}
 
#define MAX_V 102
int  d[MAX_V], f[MAX_V];
int  hi[MAX_V], *to[MAX_V];
char mk[MAX_V];
int  tm;
 
void dfs(int u)
{
    int i, v;
 
    d[u] = tm++;
    mk[u] = 1;
    for (i = 0; i < hi[u]; i++) {
        v = to[u][i];
        if (!mk[v]) dfs(v);
    }
    f[u] = tm++;
}
 
int main()
{
    int n, i, j, k, u;
 
    n = in();
    for (i = 0; i < n; i++) {
        u = in()-1;
        hi[u] = k = in();
        to[u] = malloc(k<<2);
        for (j = 0; j < k; j++) to[u][j] = in()-1;
    }
 
    tm = 1;
    for (i = 0; i < n; i++) if (mk[i] == 0) dfs(i);
    for (i = 0; i < n; i++) printf("%d %d %d\n", i+1, d[i], f[i]);
    return 0;
}


Measured memory_bytes: 2116
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{   
    cin>>s;
    for(int i=0;s[i]!='\0';i++)
        if(s[i]=='A'&&s[i+1]=='C')
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <set>
#include <cstdlib>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i,k,n) for(int i=k;i<n;i++)
using namespace std;
int main()
{
  string s;
  set<string> v;
  cin >> s;
  int k;
  cin >> k;
  int n = s.size();
  rep(i,n) v.insert(s.substr(i,1));
  rep(i,n-1) v.insert(s.substr(i,2));
  rep(i,n-2) v.insert(s.substr(i,3));
  rep(i,n-3) v.insert(s.substr(i,4));
  rep(i,n-4) v.insert(s.substr(i,5));
  auto itr = v.begin();
  rep(i,k-1) ++itr;
  cout << *itr << endl;
  return 0;
}


Measured memory_bytes: 1664
n=int(input())
s=input()
ans=0
for i in range(n-2):
  for d in range(n):
    j=i+d
    k=i+2*d
    if k>=n:
      break
    if not (s[i]==s[j] or s[j]==s[k] or s[k]==s[i]):
      ans+=1
r=s.count('R')
g=s.count('G')
b=s.count('B')
ans+=r*(r-1)//2*g+r*(r-1)//2*b+g*(g-1)//2*r+g*(g-1)//2*b+b*(b-1)//2*r+b*(b-1)//2*g+r*(r-1)*(r-2)//6+g*(g-1)*(g-2)//6+b*(b-1)*(b-2)//6
print(n*(n-1)*(n-2)//6-ans)

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

int main() {
    int n, m;
    cin >> n >> m;
    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n,sum;
  scanf("%d",&n);
  if(n >= 10){
    sum = 9;
    if(n>=100){
      for(int i=100; i<=n; i++){
        if(i>=1000)break;
        sum++;
      }
      if(n>=10000){
        for(int j=10000;j<=n;j++){
          if(j>=100000)break;
          sum++;
        }
      }
    }
  }
  else sum = n;
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
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 int INF = 1000100100;

int main() {
    ll A, B, K;
    cin >> A >> B >> K;

    for(ll i = A; i <= min(A + K - 1, B); ++i) {
        cout << i << endl;
    }
    for(ll i = max(A + K, B - K + 1); i <= B; ++i) {
        cout << i << endl;
    }

    return 0;
}

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

int main(){
int cost;
int change =1000;
cin >> cost;

  if(1<= cost && cost<=999)
  {
    cout << 1000 - cost;
    return 0;
  }
  
  if(cost % 1000 == 0)
  {
    cout << 0;
    return 0;
  }
  
  
while(1)
{
    change =   1000 -cost;
    cost-= 1000;
    if(cost >= 0 && 1000>= cost)
    {
        cout << change + 1000;
        return 0;
    }
}

    return 0;
}

Measured memory_bytes: 3604
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

ll n;
vector<vector<ll>> edge;
vector<vector<ll>> dp;
vector<ll> dp2;
ll m;

ll dfs(ll w,ll p){
    dp[w].resize(edge[w].size(),1);
    ll sum=1;
    for(int i=0;i<edge[w].size();i++){
        if(edge[w][i]==p){continue;}
        dp[w][i]=dfs(edge[w][i],w);
        sum*=dp[w][i];
        sum%=m;
    }
    return dp2[w]=sum+1;
}

void dfs2(ll w,ll p,ll num){
    dp2[w]--;
    (dp2[w]*=num)%=m;
    vector<ll> A(edge[w].size(),1);
    for(int i=0;i<edge[w].size();i++){
        A[i]=dp[w][i];
        if(edge[w][i]==p){dp[w][i]=A[i]=num;}
    }
    for(int i=1;i<edge[w].size();i++){
        A[i]*=A[i-1];
        A[i]%=m;
    }
    for(int i=(int)edge[w].size()-2;i>=0;i--){
        dp[w][i]*=dp[w][i+1];
        dp[w][i]%=m;
    }
    for(int i=0;i<edge[w].size();i++){
        if(edge[w][i]==p){continue;}
        ll D=1;
        if(i!=0){D*=A[i-1];}
        if(i+1!=edge[w].size()){D*=dp[w][i+1];}
        D++;
        D%=m;
        dfs2(edge[w][i],w,D);
    }
}



int main(){
    cin>>n>>m;
    edge.resize(n);
    dp.resize(n);
    dp2.resize(n);
    for(int i=1;i<n;i++){
        ll x,y;
        cin>>x>>y;
        x--; y--;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }
    dfs(0,-1);
    dfs2(0,-1,1);
    for(int i=0;i<n;i++){
        cout<<dp2[i]%m<<endl;
    }
    
    return 0;
}


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


int main(){
  int a, b;
  cin >> a >> b;
  if(a+b >= a-b && a+b >= a*b){
    cout << a+b << endl;
  }else if(a-b >= a+b && a-b >= a*b){
    cout << a-b << endl;
  }else{
    cout << a*b << endl;
  }
  return 0;
}


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

int main(int argc, char const *argv[])
{
  int N,A[200],ans=0; // N,A : 問題文通りの定義 / ans : 答え
  cin >> N; // Nを格納

  for (int i = 0; i < N; ++i)
  {
    cin >> A[i]; // A_1～A_Nの入力をA[0]～A[N-1]に格納
  }

  ans=0; // 操作可能回数は0回からスタート
  while(1){
    bool allEven = true; // 全て偶数かどうかのフラグ

    for (int i = 0; i < N; ++i) // 黒板の数字すべてについて
    {
        if(A[i]%2==1){ // A[i]が奇数ならば終了
            allEven = false;
            break;
        }else{ // A[i]が偶数ならば2で割って再代入
            A[i] /= 2;
        }
    }

    if(!allEven){ // 奇数が含まれていた場合 => 操作可能回数を増やさず終了
        break;
    } else{
        ans++; // 全て偶数だった場合 => 操作可能回数を+1する
    }

  }

  cout << ans << endl; // 答えを出力
  return 0;
}

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

int main() {
  int H, W, N;
  cin >> H >> W >> N;

  cout << N / max(H, W) + min(1, N % max(H, W)) << endl;
  return 0;
}

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

using namespace std;

int group(int x) {
  if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x==10 || x == 12) {
    return 1;
  } else if (x == 4 || x == 6 || x == 9 || x == 11) {
    return 2;
  } else {
    return 3;
  }
}

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

  int x, y;
  cin >> x >> y;
  if (group(x) == group(y)) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


Measured memory_bytes: 256
A, B, C = map(int, input().split())
num = [A, B, C]
cnt =0

for i in range(2):
    multi = (max(num)-min(num))//2
    num[num.index(min(num))] += 2*multi
    cnt += multi

if len([i for i in num if i==max(num)]) ==1:
    cnt += 1
elif len([i for i in num if i==max(num)]) ==2:
    cnt += 2
print(cnt)



Measured memory_bytes: 9144
#include <iostream>

int main(){
    int A, B, C;

    std::cin >> A >> B >> C;

    if(A == B && A == C || A != B && A != C && B != C){
        std::cout << "No" << std::endl;
    }
    else{
        std::cout << "Yes" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 11;
const int f[11] = {0,1,2,4,7,12,20,29,38,52,73};
int n,p[N];
ll mx,a[N][N];

int main(){
	n=read();
	For(i,2,n){
		FOR(j,1,i) a[j][i]=a[i][j]=(mx+1)*f[j];
		For(j,1,i) p[j]=j;
		do {
			if (p[1]>p[i]) continue;
			ll ret=0;
			For(j,2,i) ret+=a[p[j-1]][p[j]];
			mx=max(mx,ret);
		}while (next_permutation(p+1,p+1+i));
	}
	For(i,1,n){
		For(j,1,n) printf("%lld ",a[i][j]);
		puts("");
	}
}

Measured memory_bytes: 3764
x, y, a,b,c =map(int,input().split())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
c_list = list(map(int,input().split()))
index_list = [0,0,0]
a_list.sort(reverse=True)
b_list.sort(reverse=True)
c_list.sort(reverse=True)

total = 0

for i in range(x+y):
    max_list = []
    try:
        if index_list[0] < x:
            max_list.append(a_list[index_list[0]])
        else:
            max_list.append(-1)
    except:
        max_list.append(-1)
    try:
        if index_list[1] < y:
            max_list.append(b_list[index_list[1]])
        else:
            max_list.append(-1)
    except:
        max_list.append(-1)
    try:
        max_list.append(c_list[index_list[2]])
    except:
        max_list.append(-1)
    max_value = max(max_list)
    max_index = max_list.index(max_value)
    total += max_value
    index_list[max_index] += 1

print(total)

Measured memory_bytes: 22720
import math

n = int(input())

def N(n, i, j):
    num = 0
    for x in range(1,n+1):
        low = int(x%10)
        high = int(x/(pow(10, int(math.log10(x)))))
        if((high == i)and(low == j)):
            num = num + 1
    return num

s = 0
for i in range(1,10):
    s = s + pow(N(n, i, i), 2)

for i in range(2,10):
    for j in range(1,i):
        s = s + 2*N(n, i, j)*N(n, j, i)

print(s)
        

    







Measured memory_bytes: 44548
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int desc(const void *a,const void *b){
    return *(int*)b-*(int*)a;
}
int main(void){
    int n,m,i,sum=0;
    scanf("%d%d",&n,&m);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    qsort(a,n,sizeof(int),desc);
    if(a[m-1]>=(int)(ceil(sum/(4.0*m)))) printf("Yes");
    else printf("No");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int M, N;
  cin >> M >> N;
  vector<int> city(M);
  vector<int> road(2*N);
  
  for (int i =0; i< 2*N ; i++){
    cin >> road.at(i);
    city.at(road.at(i)-1)++;
  }
  
  for (int i=0; i< M; i++){
    cout << city.at(i) << endl;
  }
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <complex>
#include <iterator>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define repfn(i, a, cont, next) \
  for(auto i = (a); [=](){return(cont);}(); i = [=](){return(next);}())
#define repby(i, a, b, step) repfn(i, a, i < b, i + step)
#define repab(i, a, b) repby(i, (a), (b), 1)
#define rep(i, n) repab(i, 0, (n))
#define pb push_back
#define sz(c) int((c).size())

int main(int argc, char **argv)
{
  stack<int> s;
  int tmp;
  while (cin >> tmp) {
    if (tmp)
      s.push(tmp);
    else {
      cout << s.top() << endl;
      s.pop();
    }
  }
  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    if (n > k) {
        ll diff = n - k;
        ll m = diff / k;
        n -= m * k;
    }
    if (n > k) {
        n -= k;
    }
    ll ans = (ll) 2e18;
    set<ll> visited;
    while (!visited.count(n)) {
        visited.insert(n);
        ans = min(ans, n);
        n = abs(n - k);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int ,int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int N, K;
	cin >> N >> K;
	rep(i,0,max(N, K)){
		cout << min(N, K);
	}
	cout << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 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;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<iomanip>
#include<set>
#include<unordered_map>
using namespace std ;

int len ;
int a[ 17 ] ;

bool ask ( int en ) {
    cout << "? " ;
    for ( int i = 0 ; i <= en ; ++ i ) {
        cout << a[ i ] ;
    }
    if ( en == len - 1 ) { cout << "0" ; }
    cout << "\n" ;
    fflush ( stdout ) ;
    char ret ;
    cin >> ret ;
    if ( en == len - 1 ) { return ( ret == 'N' ) ; }
    return ( ret == 'Y' ) ;
}

void input ( ) {

}

void solve ( ) {
    len = 0 ;
    while ( len < 15 ) {
        cout << "? 1" ;
        for ( int i = 0 ; i < len ; ++ i ) {
            cout << "0" ;
        }
        cout << "\n" ;
        fflush ( stdout ) ;
        char ret ;
        cin >> ret ;
        if ( ret == 'Y' ) {
            ++ len ;
        }
        else { break ; }
    }
    if ( len == 15 ) {
        len = 0 ;
        while ( 1 ) {
            cout << "? 2" ;
            for ( int i = 0 ; i < len ; ++ i ) {
                cout << "0" ;
            }
            cout << "\n" ;
            fflush ( stdout ) ;
            char ret ;
            cin >> ret ;
            if ( ret == 'N' ) {
                ++ len ;
            }
            else { break ; }
        }
        cout << "! 1" ;
        for ( int i = 0 ; i < len ; ++ i ) {
            cout << "0" ;
        }
        cout << "\n" ;
        fflush ( stdout ) ;
        return ;
    }
    for ( int i = 0 ; i < len ; ++ i ) {
        a[ i ] = 0 ;
    }
    for ( int i = 0 ; i < len ; ++ i ) {
        int l , r , mid ;
        l = 0 ; r = 9 ;
        if ( i == 0 ) { ++ l ; }
        while ( r - l > 2 ) {
            mid = ( l + r ) / 2 ;
            a[ i ] = mid ;
            if ( ask ( i ) == true ) { l = mid ; }
            else { r = mid - 1 ; }
        }
        while ( r >= 0 ) {
            a[ i ] = r ;
            if ( ask ( i ) == true ) { break ; }
            -- r ;
        }
        if ( i == len - 1 ) { ++ r ; ++ a[ i ] ; }
    }
    cout << "! " ;
    for ( int i = 0 ; i < len ; ++ i ) {
        cout << a[ i ] ;
    }
    cout << "\n" ;
    fflush ( stdout ) ;
}


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


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

int main(){
  ll n;
  cin >> n;
  vector<bool>ans(n,false);
  vector<ll>resist(1000005),a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
    resist[a[i]]++;
  }
  
  if(resist[1]==1){
    cout << 1 << endl;
    return 0;
  }
  if(resist[1]>1){
    cout << 0 << endl;
    return 0;
    
  }
  
  
  for(int i=0; i<n ;i++){
    ll x = pow(a[i],0.5);
    for(int j=2; j<=x; j++){
      if(a[i]%j==0){
        ll y=a[i]/j;
        if(resist[j]>0){
          ans[i]=true;
          break;
        }
        if(resist[y]>0){
          ans[i]=true;
          break;
          
        }
      }
    }
  }
  
  for(int i=0; i<n; i++){
    if(resist[a[i]]>1) ans[i]=true;
  }
  
  ll count=0;
  for(int i=0; i<n; i++){
    if(ans[i]==false)count++;
  }
  
  cout << count << endl;
  
  
  
  
  
}
  


Measured memory_bytes: 12932
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   char c;
   cin >> c;
   cout << char(c+1) << '\n';  
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>


#define FOR(i,m,M) for(int i = m;i<M;i++)

using namespace std;

int N;
double add = 0;
vector<double> x(8), y(8);

int fact(int n)
{
	if (n <= 1)
		return 1;
	else return n * fact(n - 1);
}

void sum(int i)
{
	
	FOR(k, 0, N)
	{
		double xdis = x[i] - x[k],ydis = y[i] - y[k];
		add +=sqrt(xdis * xdis + ydis * ydis);
	}
}

int main()
{
	cin >> N;
	FOR(i, 0, N)
	{
		cin >> x[i] >> y[i];
	}
	FOR(i, 0, N)
	{
		sum(i); //すべての(i,j)に対しての距離を足す
	}
	cout<<setprecision(20) << add / N;
}



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

int simulate(string S, char ch)
{
    int res = 0;
    //cout << "ch:" << ch << endl;
    //cout << S << endl;
    if(S.find(ch) == S.npos) { return 1000000; }
    do {
        bool flg = true;
        for(size_t i = 0; i < S.size()-1; ++i) {
            if(S[i] != ch && S[i+1] == ch) flg = false, S[i] = ch;
        }
        if(S.back() != ch) flg = false;
        if(flg) break;
        S.erase(S.end()-1);
        ++res;
        //cout << S << endl;
    } while(true);
    //cout << endl;
    return res;
}

int main() {
    string S;
    cin >> S;
    int res = 1000000;
    for(char ch = 'a'; ch <= 'z'; ++ch) {
        res = min(res, simulate(S,ch));
    }
    cout << res << endl;
    return 0;
}

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

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();

        System.out.print(a.charAt(0));
        System.out.print(b.charAt(1));
        System.out.print(c.charAt(2));
    }
}


Measured memory_bytes: 35628
def solve(n, s_list, t_list, x):
    k = s_list.index(x)
    res = 0
    for i in range(k + 1, n):
        res += t_list[i]
    return res


def main():
    n = int(input())
    s_list = []
    t_list = []
    for _ in range(n):
        s, t_s = input().split()
        s_list.append(s)
        t_list.append(int(t_s))
    x = input()
    res = solve(n, s_list, t_list, x)
    print(res)


def test():
    assert solve(3, ["dwango", "sixth", "prelims"], [2, 5, 25], "dwango") == 30
    assert solve(1, ["abcde"], [1000], "abcde") == 0


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


Measured memory_bytes: 3064