akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

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

    int D; cin >> D;
    vector<int> C(26); vector<vector<int>> S(D, vector<int>(26));
    REP(i, 0, 26) cin >> C[i];
    REP(i, 0, D) REP(j, 0, 26) cin >> S[i][j];


    vector<int> T(D);
    REP(i, 0, D) {
        int max_idx = 0;
        REP(j, 0, 26) {
            if (S[i][max_idx] < S[i][j]) max_idx = j;
        }
        T[i] = max_idx + 1;
    }

    vector<vector<int>> last(26, vector<int>(D, 0));
    vector<ll> ret(26, 0);
    REP(i, 0, D) {
        ret[T[i] - 1] += S[i][T[i] - 1];
        last[T[i] - 1][i] = i + 1;
        REP(j, 0, 26) {
            if (i > 0 && !last[j][i]) last[j][i] = last[j][i - 1];
            ret[j] -= C[j] * (i + 1 - last[j][i]);
        }
    }

    ll best = accumulate(ALL(ret), 0LL);
    mt19937_64 mt(random_device{}());
    REP(i, 0, 10000) {
        int d = mt() % D;
        int next = mt() % 26;
        int prev = T[d] - 1;
        T[d] = next + 1;
        last[prev].assign(D, 0);
        last[next].assign(D, 0);
        ret[prev] = 0;
        ret[next] = 0;
        REP(i, 0, D) {
            if (T[i] == prev + 1 || T[i] == next + 1) {
                ret[T[i] - 1] += S[i][T[i] - 1];
                last[T[i] - 1][i] = i + 1;
            }
            if (i > 0) {
                if (!last[prev][i]) last[prev][i] = last[prev][i - 1];
                if (!last[next][i]) last[next][i] = last[next][i - 1];
            }
            ret[prev] -= C[prev] * (i + 1 - last[prev][i]);
            ret[next] -= C[next] * (i + 1 - last[next][i]);
        }
        if (best >= accumulate(ALL(ret), 0LL)) {
            T[d] = prev + 1;
        } else {
            best = accumulate(ALL(ret), 0LL);
        }
    }
    
    for (auto t : T) cout << t << endl;
    return 0;
}

Measured memory_bytes: 3768
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;

int main()
{
int n,p,q;
p=0;q=0;
string str1,str2;
cin>>n;

for(int i=0;i<n;i++)
{
	cin>>str1>>str2;
if(str1==str2){p++;q++;}
else if(str1<str2){q+=3;}
else if(str1>str2){p+=3;}
}
cout<<p<<" "<<q<<endl;
return 0;
}

Measured memory_bytes: 1208
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String u = sc.next();

        if(u.equals(s)){
            a--;
        }else{
            b--;
        }
        System.out.println(a+" "+b);
    }
}

Measured memory_bytes: 23764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC132
{
    class A
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string ans = "No";
            char[] s = new char[4] { S[0], S[1], S[2], S[3] };
            Array.Sort(s);
            if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]){ ans = "Yes"; }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
// B - Picking Up
// 自分のコードが酷かったので、他を参考にして書き直し
#include <bits/stdc++.h>
using namespace std;

int N;
int A[55], B[55];
map<int, map<int, int>> m;
int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> A[i] >> B[i];
    }

    int cntMax = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i == j) continue;

            m[A[i] - A[j]][B[i] - B[j]]++;
            cntMax = max(cntMax, m[A[i] - A[j]][B[i] - B[j]]);
        }
    }

    cout << N - cntMax << endl;
    return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const double pi = acos(-1.0);
template <class A>ostream & operator<<(ostream & o, const vector<A> & p) { o << "{"; for (int i = 0; i < (int)p.size(); ++i)o << (i > 0 ? ", " : "") << p[i]; o << "}"; return o; }
template <class A, class B>ostream & operator<<(ostream & o, const pair<A, B> & p) { o << "{" << p.first << ", " << p.second << "}"; return o; }
template <class A, class B>ostream& operator<<(ostream & o, const map<A, B> & p) { o << "{"; for (auto it = p.begin(); it != p.end(); ++it) o << (it != p.begin() ? ", " : "") << *it; o << "}"; return o; }
template <class A>ostream & operator<<(ostream & o, const set<A> & p) { o << "{"; for (auto it = p.begin(); it != p.end(); ++it) o << (it != p.begin() ? ", " : "") << *it; o << "}"; return o; }
void print() { cerr << endl; }
template <class H> void print(H && h) { cerr << h << endl; }
template <class H, class... T> void print(H && h, T && ... t) { cerr << h << " "; print(forward<T>(t)...); }

//UnionFind木
class UnionFind {
public:
	vector<LL> par, sz;
	UnionFind(LL n = 1) {
		init(n);
	}
	void init(LL n) {
		par.resize(n); sz.resize(n);
		for (LL i = 0; i < n; i++)par[i] = i, sz[i] = 1;
	}
	LL root(LL x) {
		if (par[x] == x)return x;
		else return par[x] = root(par[x]);
	}
	bool same(LL x, LL y) {
		return root(x) == root(y);
	}
	LL size(LL x) {
		return sz[root(x)];
	}
	void unite(LL x, LL y) {
		x = root(x), y = root(y);
		if (x == y)return;
		par[y] = x;
		sz[x] += sz[y];
	}
	void Print() {
		print(par);
		print(sz);
	}
};


int main() {
	LL n, m; cin >> n >> m;
	VL a(m), b(m);
	rep(i, m)cin >> a[i] >> b[i];

	UnionFind u(n);
	VL out(m); out[m - 1] = n * (n - 1) / 2;

	for (LL i = m - 1; i > 0; i--) {
		if (u.same(a[i] - 1, b[i] - 1)) {
			out[i - 1] = out[i];
		}
		else {
			out[i - 1] = out[i] - u.size(a[i] - 1) * u.size(b[i] - 1);
		}
		u.unite(a[i] - 1, b[i] - 1);
	}

	rep(i, m)cout << out[i] << endl;
}

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

int main()
{
    string str,str1;
    cin>>str>>str1;
    int n=str.length();
    if(str1.substr(0,n)==str)
     {cout<<"Yes";
     }
    else
     {cout<<"No";
     }

    return 0;
}

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

int main()
{
    string S;
    cin >> S;
    if(S == "AAA" || S == "BBB"){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

}

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;


void solve() {
	//~ freopen("lca.out", "w", stdout);
	//~ freopen("lca.in", "r", stdin);
	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr);
	
	int n, w;
	cin >> n >> w;
	vector<int> weight(n), value(n);
	for (int i = 0; i < n; i++) 
		cin >> weight[i] >> value[i];
		
	int maxV = 0;
	for (int i = 0; i < n; i++)
		maxV += value[i];
	ll INF = 1e11;
	vector<ll> dp(maxV + 1, INF);
	dp[0] = 0;
	for (int i = 0; i < n; i++) 
		for (int v_already = maxV - value[i]; v_already >= 0; v_already--) {
			dp[v_already + value[i]] = min(dp[v_already + value[i]], 
													dp[v_already] + weight[i]);
		}
		
	for (int i = maxV; i >= 0; i--)
		if (dp[i] <= w) {
			cout << i;
			return;
		}
}

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




Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MOD = 1000000007;

struct Pony
{
    long a, b;
 
    Pony(long a_, long b_)
    {
        a = a_;
        b = b_;
    }
 
    bool operator<(const Pony &another) const
    {
        return b < another.b;
    };
};

int fac(int k){
    int sum = 0;
    for (int i = 1; i <= k; ++i)
    {
        sum += i;
    }
    return sum;
}

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

  int n;

  cin >> n;

  vector<long> a(n);

  fillLong(a, n);

  vector<long> c;
  int sz = 0;
  for(int i = n-1; i>=0; i--) {
      int u = ubv(c, a[i]);
      if (u == sz) {
        c.push_back(a[i]);
        sz++;
      } else {
        c[u] = a[i];
      }
  }

  cout << c.size() << endl;
}


Measured memory_bytes: 2800
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (((B - A > 0) && A < C && C < B) || ((A - B> 0) && A > C && C > B) ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

typedef long long ll;
const int maxn=2010;
ll n;
int ans[maxn], cnt, a[maxn];

vector<int> g;

int main(){

	scanf("%lld", &n);
	int tot=0;
	for(int i=50;i>=0;i--){
		if((1ll<<i)-1<=n){ tot=i; break; }
	}
	// printf("%lld\n", 1ll<<tot);
	n-=(1ll<<tot)-1;
	for(int i=1;i<=tot;i++) g.push_back(i);
	int m=tot;
	// printf("n = %lld\n", n);
	for(int i=(tot-1);i>=0;i--){
		if(!(n & (1ll<<i))) continue;
		m++;
		// g.insert(m,g.begin()+i);
		g.insert(g.begin()+i, m);
	}
	for(int i=1;i<=m;i++) g.push_back(i);
	printf("%d\n", 2*m);
	for(int i=0;i<m*2;i++) printf("%d ", g[i]);
	return 0;
}

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

int main() {
  int H,W;
  cin >> H>>W;
  vector<string> a(H);
  int i;
  for(i=0;i<H;i++){
    cin >> a.at(i);
  }
  //########
  for(i=0;i<W+2;i++){
    cout<<"#";
  }
  cout<<endl;
  //#akjhsdlj#
  for(i=0;i<H;i++){
    cout<<"#"<<a.at(i)<<"#"<<endl;
  }  
    //########
  for(i=0;i<W+2;i++){
    cout<<"#";
  }
  cout<<endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli n;
    cin>>n;
    out(180*(n-2));
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
   /* #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll n,m;
    cin>>n>>m;
    cout<<(n*(n-1))/2+(m*(m-1))/2<<endl;
}
return 0;
}

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

int main()
{
  int n, k, point = 0;
  double ans = 0.0, t_ans = 0.0;
  cin >> n >> k;

  for (int i = 0; i < n; i++)
  {
    point = i + 1;
    t_ans = 1.0 / n;
    while (point >= 1 and point <= k - 1)
    {
      point = point * 2;
      t_ans = t_ans / 2;
    }
    ans += t_ans;
  }
  cout << setprecision(9) << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn =1e6+10;
const int mod=1e9+7;
vector<vector<int> >d(maxn);
int h,w,k;
string s[maxn];
int sx,sy,ex,ey;
int xx[5]={58,0,0,1,-1};
int yy[5]={58,1,-1,0,0};
void bfs()
{
    queue<pair<int,int> >q;
    q.push({sx,sy});
    d[sx][sy]=0;
    while(!q.empty())
    {
        int x=q.front().first;
        int y=q.front().second;
        if(x==ex&&y==ey)
            return;
        q.pop();
        for(int i=1;i<=4;i++)
            for(int j=0;j<k;j++)
            {
                int tx=xx[i]+x;
                int ty=yy[i]+y;
                if(i==1)
                    ty+=j;
                if(i==2)
                    ty-=j;
                if(i==3)
                    tx+=j;
                if(i==4)
                    tx-=j;
                if(tx<0||ty<0||tx>h-1||ty>w-1||s[tx][ty]=='@'||d[tx][ty]<d[x][y]+1)
                    break;
                if(d[tx][ty]>d[x][y]+1)
                {
                    d[tx][ty]=d[x][y]+1;
                    q.push({tx,ty});
                }
            }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>h>>w>>k;
    cin>>sx>>sy>>ex>>ey;
    sx--,sy--,ex--,ey--;
    for(int i=0;i<h;i++)
        cin>>s[i];
    int g=1e9;
    for(int i=0;i<h+5;i++)
        for(int j=0;j<w+5;j++)
            d[i].pb(g);
    bfs();
    if(d[ex][ey]==1e9)
        cout<<-1<<endl;
    else
        cout<<d[ex][ey]<<endl;
}

Measured memory_bytes: 84480
/*input
atcoder

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define ll long long
#define ld long double
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


ll power(ll a,ll m,ll mod){
    ll ans=1;
    while(m){
        if(m%2){
            ans*=a;
            ans%=(mod);
        }
        a=(a*a)%(mod);
        m>>=1;
    }
    return ans;
}


void init(ll* a,ll n,ll val){
    for(ll i=0;i<n;i++)
        a[i]=val;
}


ll isPal(string &s){
	ll i;
	ll n=s.length();
	rep(i,0,n/2){
		if(s[i]!=s[n-i-1])return 0;
	}
	return 1;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    ll t=1,i,j;
    string s;
    cin>>s;
    ll n=s.length();
    if(!isPal(s)){
    	cout<<"No\n";
    	return 0;
    }
    string s1="";
    rep(i,0,(n-1)/2)s1+=s[i];
    if(!isPal(s1)){
    	cout<<"No\n";
    	return 0;
    }
    s1="";
    rep(i,(n+3)/2-1,n)s1+=s[i];
    if(!isPal(s1)){
    	cout<<"No\n";
    	return 0;
    }
    cout<<"Yes\n";
    return 0;
}




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

int main()
{
    int N;
    cin>>N;
    
    int H[N];
    int C[N];
    
    for(int i=0; i<N; i++)
        cin>>H[i];

    C[0]=0;
    C[1]=abs(H[1]-H[0]);
    for(int i=2; i<N; i++)
        C[i] = min( (C[i-1] + abs(H[i]-H[i-1])) , (C[i-2] + abs(H[i]-H[i-2])) );
    
    cout<<C[N-1]<<endl;    
        
}


Measured memory_bytes: 4372
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int prime[1000000];
bool is_prime[1000001];

int sieve(int n)
{
	int p = 0;
	rep(i, 0, n + 1)is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;
	rep(i, 2, n + 1)
	{
		if (is_prime[i])
		{
			prime[p++] = i;
			for (int j = i + i; j <= n; j += i)is_prime[j] = false;
		}
	}
	return p;
}

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

	sieve(1000000);
	int X;
	cin >> X;
	while (!is_prime[X])X++;

	cout << X << endl;

	return 0;
}

Measured memory_bytes: 1792
n, a, b = map(int, input().split())
#n = list(map(int, str(n)))
#print(n)
li = []

for i in range(1, n+1):
    tmp = list(map(int, str(i)))
    if a<=sum(tmp) and sum(tmp)<=b:
        li.append(i)
print(sum(li))

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

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int N = 1e5 + 5;
int p[N], l[N], r[N];

int main()
{
	int n = read();
	for (int i = 1; i <= n; ++i) p[read()] = i;
	for (int i = 1; i <= n; ++i) l[i] = i - 1, r[i] = i + 1;
	
	long long ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		int l1 = l[p[i]], l2 = l[l1];
		int r1 = r[p[i]], r2 = r[r1];
		if (l1 > 0) ans += 1LL * i * (l1 - l2) * (r1 - p[i]);
		if (r1 < n + 1) ans += 1LL * i * (r2 - r1) * (p[i] - l1);
		l[r1] = l1; r[l1] = r1; 
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<utility>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<queue>
#include<deque>
#include<sstream>
#include<bitset>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a;
	cin>>a;
	cout<<a/3;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

iA = [i+n for i, n in enumerate(A)]
jA = [i-n for i, n in enumerate(A)]
dict1 = Counter(iA)
dict2 = Counter(jA)

ans = 0
for key, value in dict1.items():
    ans += value * dict2[key]
print(ans)

Measured memory_bytes: 63560
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	int h,w;
	cin>>h>>w;
	vector<vector<char>>vec;
	for(int i=0;i<h;i++){
		string s;
		cin>>s;
		vector<char>v;
		for(int j=0;j<w;j++){
			v.push_back(s[j]);
		}
		vec.push_back(v);
		vec.push_back(v);
	}
	for(int i=0;i<2*h;i++){
		for(int j=0;j<w;j++){
			cout << vec[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	int K,X;
	cin >> K >> X;
	if(K*500>=X)cout<<"Yes" <<endl;else cout << "No"<<endl;
    return 0;
}


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

using namespace std;
int main(){
	int ck=1;
	long long a;
	long long b;
	cin>>a>>b;
	long long i,p,q;
	for(i=0 ; i<1000000000 ; i++){
		p=abs(a-i);
		q=abs(b-i);
		if(p==q){
			cout<<i<<endl;
			ck=0;
			break;		
		}
	}
	if(ck==1){
		cout<<"IMPOSSIBLE"<<endl;	
	}
}

Measured memory_bytes: 256
A=int(input())
B=int(input())
C=int(input())
X=int(input())

answer=0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if 500*a+100*b+50*c==X:
        answer+=1
        
print(answer)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	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;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s, t; cin >> s >> t;
	vector<char>a(26, '*'), b(26, '*');
	rep(i, s.size()) {
		if (a[s[i] - 'a'] == '*')a[s[i] - 'a'] = t[i];
		else if (a[s[i] - 'a'] != t[i]) {
			cout << "No" << endl; return 0;
		}
		if (b[t[i] - 'a'] == '*')b[t[i] - 'a'] = s[i];
		else if (b[t[i] - 'a'] != s[i]) {
			cout << "No" << endl; return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 916
tl=[int(input()) for i in range(5)]

import itertools

ansl=[]

for tup in itertools.permutations(tl):
    t=list(tup)
    c=0
    for i in range(4):
        c+=t[i]
        if c%10!=0:
            c=(c//10 +1)*10
    ansl.append(c+t[-1])

print(min(ansl))

Measured memory_bytes: 3064
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    usize n;
    std::cin >> n;
    vec<i32> a(n);
    for (i32& x: a) {
        std::cin >> x;
    }

    i32 sum = std::accumulate(ALL(a), 0);
    std::bitset<4'000'001> dp;
    dp.set(0);
    for (i32 x: a) {
        dp |= dp << x;
    }

    i32 ans;
    for (i32 i=(sum+1)/2; i<=sum; i++) {
        if (dp.test(i)) {
            ans = i;
            break;
        }
    }
    std::cout << ans << '\n';
}


Measured memory_bytes: 1792
N, M = map(int, input().split())
List = list(map(int, input().split()))

if M<=N:
    print(0)

else:
    diff = []
    List = sorted(List)
    for i in range(M-1):
        diff.append(List[i+1]-List[i])
    print(List[-1]-List[0]-sum(sorted(diff, reverse=True)[:N-1]))

Measured memory_bytes: 13968
import java.util.ArrayList;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	static final long INF = 100000000000000l;
    static final int WHITE = 0;
    static final int GRAY = 1;
    static final int BLACK = 2;
    static long[] d;
    static int N;
	static ArrayList<Edge>[] adj;
	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		int[] a = new int[N - 1];
		int[] b = new int[N - 1];
		long[] c = new long[N - 1];
		d = new long[N];
		for(int i = 0; i < N - 1; i++) {
			a[i] = sc.nextInt() - 1;
			b[i] = sc.nextInt() - 1;
			c[i] = sc.nextLong();
		}
		int Q = sc.nextInt();
		int K = sc.nextInt() - 1;
		int[] x = new int[Q];
		int[] y = new int[Q];
		for(int i = 0; i < Q; i++) {
			x[i] = sc.nextInt() - 1;
			y[i] = sc.nextInt() - 1;
		}
		sc.close();
		adj = new ArrayList[N];
		for(int i = 0; i < N; i++) {
			adj[i] = new ArrayList<Edge>();
		}
		for(int i = 0; i < N - 1; i++) {
			adj[a[i]].add(new Edge(a[i], b[i], c[i]));
			adj[b[i]].add(new Edge(b[i], a[i], c[i]));
		}
		dijkstra(K);
		for(int i = 0; i < Q; i++) {
			long ans = d[x[i]] + d[y[i]];
			System.out.println(ans);
		}
	}
	static void dijkstra(int K){
		Queue<Node> pq = new PriorityQueue<Node>(new MyComparator());
		int[] color = new int[N];
		for(int i = 0; i < N; i++) {
			d[i] = INF;
			color[i] = WHITE;
		}
		d[K] = 0;
		pq.add(new Node(K, 0l));
		while(!pq.isEmpty()) {
			Node f = pq.poll();
			int u = f.id;
			color[u] = BLACK;
			if(d[u] < f.cost) continue;
			for(int j = 0; j < adj[u].size(); j++) {
				int v = adj[u].get(j).to;
				if(color[v] == BLACK) continue;
				d[v] = d[u] + adj[u].get(j).cost;
				pq.add(new Node(v, d[v]));
				color[v] = GRAY;
			}
		}
	}
	static class Node{
		int id;
		long cost;
		public Node(int id, long cost) {
			this.id = id;
			this.cost = cost;
		}
	}
	static class MyComparator implements Comparator<Node>{
		@Override
        public int compare(Node v1, Node v2) {
			if(v1.cost < v2.cost) {
				return -1;
			}else if(v1.cost == v2.cost) {
				return 0;
			}else {
				return 1;
			}
		}
	}
	static class Edge{
		int from, to;
		long cost;
		public Edge(int from, int to, long cost) {
			this.from = from;
			this.to = to;
			this.cost = cost;
		}
	}
}

Measured memory_bytes: 170968
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int H,W;
	while(true){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) break;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
}



Measured memory_bytes: 2600
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<58;
 
int main(){
    ll N ,M, C;
  	cin >> N >> M >> C;
  	ll A[N][M];
  	vector<ll> B(M);
  	vector<ll> cal(N*M);
  	ll ans = 0;
  for(ll i = 0; i < M; ++i) cin >> B[i];
  for(ll i = 0; i < N; ++i) {
    for(ll j = 0; j < M; ++j) {
    	cin >> A[i][j];
  	}
  }
  ll in = 0;
  for(ll i = 0; i < M; ++i) {
    for(ll j = 0; j < N; ++j) {
    	cal[in] = A[j][i] * B[i];
      	in++;
  	}
  }
  for(ll i = 0; i < N; ++i){
    ll temp = 0;
    for(ll j = 0; j < M; ++j) {
      temp += cal[i + j * N];
  	}
    if(temp + C > 0) ans++; 
  }
  
  	cout << ans << endl;
  
}

Measured memory_bytes: 256
eval"H,W,D,*R="+`dd`.split*?,;d=[0]*-~D;x=[];0.upto(H*=W){|e|x[R[e]]=e};(D+1..H).map{|i|d[i]=d[i-D]+(x[i]/W-x[i-D]/W).abs+(x[i]%W-x[i-D]%W).abs};R[H+1..-1].each_slice(2){|a,b|puts d[b]-d[a]}

Measured memory_bytes: 59468
#include"bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = b - 1; i >= a; i--)
#define RREP(i, n) RFOR(i, 0, n)
#define rep(i, a, b) for (auto i = a; i < b; i++)
#define rrep(i, a, b) for (auto i = a; i > b; i--)
#define range(i, a, b) (a <= i && i < b)
#define fi first
#define fs first
#define se second
#define sc second
using namespace std;
using vec = vector<int>;
using mat = vector<vec>;
typedef pair<int, int> P;
#define ll long long
int dx[] = { 0, 0, 1, -1 };
int dy[] = { 1, -1, 0, 0 };

class state {
public:
	int now[6];
	state(int top, int down) {
		now[4] = top;
		now[0] = down;
		now[1] = 7 - down;
		now[3] = tmp[down - 1][top - 1];
		assert(now[3] != -1);
		now[2] = 7 - now[3];
		now[5] = 7 - now[4];
	}

	void up() {
		int t[6];
		t[1] = now[4], t[4] = now[0], t[2] = now[2], t[3] = now[3], t[0] = now[5], t[5] = now[1];
		rep(i, 0, 6) now[i] = t[i];
	}
	void down() {
		int t[6];
		t[1] = now[5], t[4] = now[1], t[2] = now[2], t[3] = now[3], t[0] = now[4], t[5] = now[0];
		rep(i, 0, 6) now[i] = t[i];
	}
	void right() {
		int t[6];
		t[1] = now[1], t[4] = now[3], t[2] = now[4], t[3] = now[5], t[0] = now[0], t[5] = now[2];
		rep(i, 0, 6) now[i] = t[i];
	}
	void left() {
		int t[6];
		t[1] = now[1], t[4] = now[2], t[2] = now[5], t[3] = now[4], t[0] = now[0], t[5] = now[3];
		rep(i, 0, 6) now[i] = t[i];
	}
private:
	int tmp[6][6] = { {-1, 3, 5, 2, 4, -1},{4, -1, 1, 6, -1, 3},
	{2, 6, -1, -1, 1, 5}, {5, 1, -1, -1, 6, 2}, {3, -1, 6, 1, -1, 4},
	{-1, 4, 2, 5, 3, -1} };
};

void solve(int &n) {
	int num[201][201];
	int height[201][201];
	rep(i, 0, 201) rep(j, 0, 201) {
		num[i][j] = 0;
		height[i][j] = 0;
	}
	rep(cnt, 0, n) {
		int t, f; cin >> t >> f;
		int nowi = 100, nowj = 100;
		bool update = true;
		state now(t, f);
		while (update) {
			update = false;
			int next = -1, _max = -1;
			rep(i, 0, 4) {
				int nexti = nowi + dy[i];
				int nextj = nowj + dx[i];
				if (height[nexti][nextj] < height[nowi][nowj] && (now.now[i] == 4 || now.now[i] == 5 || now.now[i] == 6) && _max < now.now[i]) {
					next = i;
					_max = now.now[i];
					update = true;
				}
			}
			if (next == 0) now.down();
			else if (next == 1) now.up();
			else if (next == 2) now.right();
			else if (next == 3) now.left();
			if (!update) {
				num[nowi][nowj] = now.now[4];
				height[nowi][nowj]++;
			}
			else {
				nowi = nowi + dy[next];
				nowj = nowj + dx[next];
			}
		}
	}
	int ans[7];
	fill(ans, ans + 7, 0);
	rep(i, 0, 201) rep(j, 0, 201) {
		ans[num[i][j]]++;
	}
	rep(i, 1, 7) {
		cout << ans[i];
		if (i == 6) cout << endl;
		else cout << " ";
	}
}

int main() {
	int n;
	while (cin >> n, n) solve(n);
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
typedef tuple<int, int, int> tiii;

int main() {
    int H, W; cin >> H >> W;
    vector<string> A(H);
    for (int i = 0; i < H; i++) cin >> A[i];
    int ans = 0;
    vector<vector<bool>> visited(H, vector<bool>(W, false));
    queue<tiii> q; 
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] == '#') {
                q.push(tiii(i, j, 0)); 
                visited[i][j] = true;
            }
        }
    }
    while (!q.empty()) {
        int h, w, a; tie(h, w, a) = q.front(); q.pop();
        ans = a;
        if (0 <= h-1 && !visited[h-1][w]) {q.push(tiii(h-1, w, a+1)); visited[h-1][ w ] = true;}
        if (h+1 < H && !visited[h+1][w]) {q.push(tiii(h+1, w, a+1)); visited[h+1][w] = true;}
        if (0 <= w-1 && !visited[h][w-1]) {q.push(tiii(h, w-1, a+1)); visited[h][w-1] = true;}
        if (w+1 < W && !visited[h][w+1]) {q.push(tiii(h, w+1, a+1)); visited[h][w+1] = true;}
    }
    cout << ans << endl;
}

Measured memory_bytes: 13584
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()

if n < m:
    x_distance = [abs(x[i + 1] - x[i]) for i in range(m - 1)]
    x_distance.sort()
    ans = 0
    for i in range (m - n):
        ans += x_distance[i]
    print(ans)
else:
    print(0)


Measured memory_bytes: 13968
#include<bits/stdc++.h>
using namespace std;
int main(){
  int cnt[3]={};
  string a;
  cin>>a;
  for(int i=0;i<3;i++){
    cnt[a[i]-'a']++;
  }
  if(cnt[0]==cnt[1]&&cnt[1]==cnt[2])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
    vector<bool>b(10);
bool check(int n)
{
    while(n>0)
    {
        
        int t = n%10;
        if(b[t])
        return true;
        n/=10;
    }
    return false;
}
int main()
{
    int n,k;
    cin >>n>>k;

    for(int i = 0;i<k;i++)
    {
        int d;
        cin >>d;
        b[d]= true;
    }
    while(check(n))
        ++n;
        cout << n<<endl;
        return 0;
    
}

Measured memory_bytes: 256
fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    let (n, a, b) = {
        let mut ws = s.split_whitespace(); // 空白区切りの単語に分解する
        let n: i64 = ws.next().unwrap().parse().unwrap(); // イテレータから値を取り出して整数に
        let m: i64 = ws.next().unwrap().parse().unwrap();
        let o: i64 = ws.next().unwrap().parse().unwrap();
        (n, m, o)
    };

    let r = n % (a + b);
    println!("{}", a * ((n - r) / (a + b)) + std::cmp::min(a, r));
}

// nをa+bで割って、商q 余りrとすると、a*q+min(a, r)


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
using namespace std;
static const int Max = 1000000;
int main(){
  long long N,Rt[Max];
  cin >> N;
  for(int j = 0; j < N; j++){
    cin >> Rt[j];
  }
  long long Maxv = -2000000000;
  long long Minv = Rt[0];

  for(int j = 1; j < N; j++){
    Maxv = max(Maxv, Rt[j]-Minv);
    Minv = min(Minv, Rt[j]);
  }

  cout << Maxv << endl;
  return 0;
}


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

int main(){
  int N;cin>>N;
  bool OK=false;
  for(int i=1;i<10;i++){
    if(N%i==0 && N/i<10)
      OK=true;
  }
  
  if(OK)
    cout<<"Yes";
  else
    cout<<"No";
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC096_B solver = new ABC096_B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC096_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int ans = 0;
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int k = in.nextInt();

            int doubled = Math.max(Math.max(a, b), c);
            for (int i = 0; i < k; i++) {
                doubled *= 2;
            }

            out.print(a + b + c + doubled - Math.max(Math.max(a, b), c));
        }

    }
}



Measured memory_bytes: 20680
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define all(v) v.begin(), v.end()
using namespace std;
int mypow(int a, int b, int c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	int z = mypow(a, b / 2, c);
	return z * z%c;
}
signed main() {
	string s;
	deque<char> d;
	int n, z = 0;
	cin >> s >> n;
	f(i, s.size()) {
		d.push_back(s[i]);
	}
	f(i, n) {
		int a;
		cin >> a;
		if (a == 1) {
			z = (z + 1) % 2;
		}
		else {
			int b;
			char c;
			cin >> b >> c;
			if ((z + b) % 2) d.push_front(c);
			else d.push_back(c);
		}
	}
	if (z) {
		f(i, d.size()) {
			cout << d[d.size() - i - 1];
		}
	}
	else {
		f(i, d.size()) {
			cout << d[i];
		}
	}
	cout << endl;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int K=26;
int a[K];

signed main()
{
    REP(i,K) a[i]=-1;

    string s,t; cin>>s>>t;
    REP(i,SZ(s)){
        int x=s[i]-'a';
        int y=t[i]-'a';
        if(a[x]==-1) a[x]=y;
        else if(a[x]!=y){
            cout<<"No"<<endl;
            return 0;
        }
    }
    REP(i,K-1) for(int j=i+1;j<K;j++){
        if(a[i]==-1 or a[j]==-1) continue;
        if(a[i]==a[j]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 776
#include<stdio.h>
int main(void){
int cards[128][14] = {{0}};
  int i, N;
  scanf("%d", &N);
  for(i = 0; i < N; i++) {
    char c; int cn;
    scanf("%c", &c); 
    scanf("%c %d", &c, &cn);
    
    cards[c][cn] = 1;
  }
  /* 'S'の不足カードを表示 */
  for(i = 1; i <= 13; i++) {
    if(cards['S'][i] == 0) printf("S %d\n", i);
  }
  
  for(i = 1; i <= 13; i++) {
    if(cards['H'][i] == 0) printf("H %d\n", i);
  }
  for(i = 1; i <= 13; i++) {
    if(cards['C'][i] == 0) printf("C %d\n", i);
  }
  for(i = 1; i <= 13; i++) {
    if(cards['D'][i] == 0) printf("D %d\n", i);
  }
  return 0;

}


Measured memory_bytes: 2052
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        int count = 0;
        for (int i = 0; i < S.length(); i++) {
        	if (S.charAt(i) != T.charAt(i)) {
        		count++;
        	}
        }
        System.out.println(count);
    }
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

#define fill(a,x) memset(a,x,sizeof(a)) 
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end() 
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const int mod = 1e9+7;
const int N = 4e3+10; 
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
int dp[N][N],mark[N][N];
int fac[10010],ifac[10010],inv[10010];
void FAC(int n){
  fac[0] = ifac[0] = inv[1] = 1;
  for(int i = 1; i < n; ++i)fac[i] = 1LL*i*fac[i-1] % mod;
  for(int i = 2; i < n; ++i)inv[i] = mod - ((mod/i)*1LL*inv[mod%i]) % mod;
  for(int i = 1; i < n; ++i)ifac[i] = 1LL*ifac[i-1]*inv[i] % mod;
}
inline int C(int n,int k){
  if(k > n)return 0;
  return  1LL * ifac[n-k]*( (1LL*fac[n]*ifac[k]) % mod ) % mod; 
}
int DP(int x,int y){
	if(x < 0 || y < 0)return 0;
	int &ret = dp[x][y];
	if(~ret)return ret;
	ret = 0;
	ret += mark[x][y];
	ret = add(ret,DP(x-1,y));
	ret = add(ret,DP(x,y-1));
	return ret;
}
int main(){
  fast;
  int n;cin >> n;
  vector<ii> v(n);
  FAC(10010);
  fill(mark,0);
  fill(dp,-1);
  FOR(i,0,n-1){
  	cin >> v[i].F >> v[i].S;
  	mark[2000-v[i].F][2000-v[i].S] += 1;
  }
  int ans = 0;
  FOR(i,0,n-1){
  	//cout << ans << " ";
  	ans = add(ans,DP(v[i].F + 2000,v[i].S + 2000));
  	//cout << ans << "\n";
  }
  //cout << ans << "\n";
  FOR(i,0,n-1){
  	//cout << C(2*v[i].F + 2*v[i].S,v[i].F + v[i].S) << "\n";
  	ans = add(ans,mod - C(2*v[i].F + 2*v[i].S,2*v[i].F));
  }
  ans = mul(ans,500000004);
  cout << ans << "\n";
  return 0;
}

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

int main(void){
    int n, a[100010];
    cin >> n;
    for(int i=0;i<n;++i) cin >> a[i];
    sort(a, a+n);
    int min = a[0];
    int p=0;
    while(1){
        for(int i=0;i<n;++i){
            if(i!=p) a[i] = a[i]%min;
        }
        sort(a, a+n);
        p = 0;
        while(a[p]==0) ++p;
        if(min==a[p]) break;
        else min = a[p];
        if(min==1) break;
    }
    cout << min << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
ll K; 
vector<int> A, F;
// 二分探索

bool is_large(ll X) {
  ll sum = 0ll;
  rep(i, N) sum += max(0ll, A[i]- (X/F[i]));
  return sum > K;
}

ll binary_search(ll l, ll r) {
  while(r-l>1) {
    ll mid = (r+l)/2;
    if (is_large(mid)) l = mid;
    else r = mid;
  }
  return r;
}

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

  cin >> N >> K;
  ll a;
  rep(i, N) {
    cin >> a;
    A.push_back(a);  
  }
  rep(i, N) {
    cin >> a;
    F.push_back(a);  
  }
  sort(ALL(A));
  sort(ALL(F),greater<ll>());

  ll ok = 1e13;
  ll ng = -1;
  cout << binary_search(ng, ok) << "\n";
  return 0;
}

Measured memory_bytes: 2548
import java.util.Scanner;

public class Main{
    public static void solve(){
        String t = null, w = null;
        int c = 0;
        Scanner scan = new Scanner(System.in);
        w = scan.next();
        while(true){
            t = scan.next();
            if(t.equals("END_OF_TEXT"))break;
            else if(t.equalsIgnoreCase(w)){
                c++;
            }
        }
        System.out.println(c);
    }

    public static void main(String[] args) {
        solve();
    }
    
}



Measured memory_bytes: 26124
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	in := bufio.NewScanner(os.Stdin)
	for in.Scan() {
		n, _ := strconv.Atoi(in.Text())
		for i := 1; i <= n; i++ {
			x := i
			if x%3 == 0 {
				fmt.Print(" ", i)
			} else if x%10 == 3 {
				fmt.Print(" ", i)
			} else {
				for x != 0 {
					x /= 10
					if x != 0 && x%10 == 3 {
						fmt.Print(" ", i)
						break
					}
				}
			}
		}
		break
	}
	fmt.Println()
}



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


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

	int sn = 0;
	sn += n / 1000000000;
	sn += (n%1000000000) / 100000000;
	sn += (n%100000000) / 10000000;
	sn += (n%10000000) / 1000000;
	sn += (n%1000000) / 100000;
	sn += (n%100000) / 10000;
	sn += (n%10000) / 1000;
	sn += (n%1000) / 100;
	sn += (n%100) / 10;
	sn += n%10;

	if(n % sn == 0) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define mod 1000000007
int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    long long sum=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(i==0)continue;
        sum+=a[i];
        sum%=mod;
    }
    long long ans=a[0]*sum;
    ans%=mod;
    for(int i=1;i<n;i++){
        sum-=a[i];
        if(sum-a[i]<0){
            sum+=mod;
        }
        sum%=mod;
        ans+=a[i]*sum;
        ans%=mod;
    }
    printf("%lld",ans);
    
    return 0;
}



Measured memory_bytes: 2508
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  int a = 0, w = 0, t = 0, r = 0;
  for(int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if(s[0] == 'A') {
      a++;
    } else if(s[0] == 'W') {
      w++;
    } else if(s[0] == 'T') {
      t++;
    } else {
      r++;
    }
    s.clear();
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << w << endl;
  cout << "TLE x " << t << endl;
  cout << "RE x " << r << endl;
  return 0;
}

Measured memory_bytes: 3628