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

using namespace std;


const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

struct Union_Find_Tree {
private:
	vector< long long >par;
	vector< long long >Rank;
	int N;
public:
	void init(int n) {
		N = n;
		par.resize(N + 1);
		Rank.resize(N + 1);
		for (int i = 0;i <= N;i++)par[i] = i, Rank[i] = 0;
	}
	int find(int x) {
		if (par[x] == x)return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (Rank[x] < Rank[y])par[x] = y;
		else {
			par[y] = x;
			if (Rank[x] == Rank[y])Rank[x]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};


int n, m, k, a, b, c;
int d[100010], belong_par[1000010];
vector<int>v[100010];



int main() {
	cin >> n >> m >> k;
	Union_Find_Tree uf;
	uf.init(n);
	for (int i = 0;i < n;i++) {
		belong_par[i] = -1;
	}
	for (int i = 1;i <= k;i++) {
		cin >> a >> b >> c;
		a--;
		if (!a) {
			b--, c--;
			if (belong_par[uf.find(b)] == belong_par[uf.find(c)])uf.unite(b, c);
			else if (belong_par[uf.find(b)] == -1 && belong_par[uf.find(c)] == -1)uf.unite(b, c);
			else if (belong_par[uf.find(b)] == -1 && belong_par[uf.find(c)] != -1) {
				belong_par[uf.find(b)] = belong_par[uf.find(c)];
				uf.unite(b, c);
			}
			else if (belong_par[uf.find(b)] != -1 && belong_par[uf.find(c)] == -1) {
				belong_par[uf.find(c)] = belong_par[uf.find(b)];
				uf.unite(b, c);
			}
			else {
				cout << i << endl;
				return 0;
			}
		}
		else {
			b--;
			if (belong_par[uf.find(b)] == -1)belong_par[uf.find(b)] = c;
			else if (belong_par[uf.find(b)] != c) {
				cout << i << endl;
				return 0;
			}
		}
	}
	cout << 0 << endl;
	return 0;
}



Measured memory_bytes: 7068
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	int k,t;cin>>k>>t;
	int x = -1;
	for(int i = 0; i < t; i++) {
		int a;cin>>a;
		x = max(x,a);
	}
	cout << max(0,x - (k - x) - 1) << endl;
	return 0;
}

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

int q;
int n;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> q;
	while(q--){
		int n;
		cin >> n;
		int r = 0;
		set<int> s;
		for(r=0; n>9; ++r){
			int ma = -1;
			int tmp = n;
			int d = 0;
			while(tmp > 0){
				tmp /= 10;
				++d;
			}
//			cout << n << " " << d << "\n";
			for(int i=1; i<d; ++i){
				int a = 0, b = 0;
				int t = n;
				for(int j=0; j<d; ++j){
					if(j >= i){
						int m = t % 10;
						for(int k=0; k<j-i; ++k)
							m *= 10;
						b += m;
						t /= 10;
					}else{
						int m = t % 10;
						for(int k=0; k<j; ++k)
							m *= 10;
						a += m;
						t /= 10;
					}
				}
//				cout << n << " " << ma << " " << a*b << "\n";
				ma = max(ma, a*b);
			}
			if(s.find(ma) != s.end()){
				r = -1;
				break;
			}else{
				s.insert(ma);
			}
			n = ma;
		}
		cout << r << "\n";
	}
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    while(cin >> a >> b >> c >> d){
        if(abs(a-c)<=d)puts("Yes");
        else if(abs(a-b)<=d and abs(b-c)<=d)puts("Yes");
        else puts("No");
    }
}


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

int main (){
  int N;
  string S;
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> S;
    if (S == "Y"){
      cout << "Four" << endl;
      break;
    }else if (i + 1 == N)
      cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp1[105][105],dp2[105][105],h,w;
string s;
bitset<105>a[105];
int main()
{
	memset(dp1,0x3f,sizeof(dp1));
	memset(dp2,0x3f,sizeof(dp2));
	dp1[0][1]=0;
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++)
	{
		cin>>s;
		for(int j=1;j<=w;j++)a[i][j]=(s[j-1]=='#');
	}
	for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)if(a[i][j])dp2[i][j]=min(min(dp1[i-1][j],dp1[i][j-1])+1,min(dp2[i][j-1],dp2[i-1][j]));
	else dp1[i][j]=min(min(dp1[i-1][j],dp1[i][j-1]),min(dp2[i-1][j],dp2[i][j-1]));
	printf("%d",min(dp1[h][w],dp2[h][w]));
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#define MOD 1000000007
#define nCr(n, r) ((int64_t) fact[n] * inv[r] % MOD * inv[n - r] % MOD)
int main() {
	int fact[4001] = { 1 }, inv[4001];
	for (int i = 1; i <= 4000; i++) fact[i] = (int64_t) fact[i - 1] * i % MOD;
	inv[4000] = 1;
	for (int i = MOD - 2, j = fact[4000]; i; i >>= 1) {
		if (i & 1) inv[4000] = (int64_t) inv[4000] * j % MOD;
		j = (int64_t) j * j % MOD;
	}
	for (int i = 4000; i; i--) inv[i - 1] = (int64_t) inv[i] * i % MOD;
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= k; i++) {
		int red = n - k - (i - 1);
		int blue = k - i;
		int res = 0;
		if (red >= 0 && blue >= 0) res = nCr(blue + i - 1, blue) * nCr(red + i, red) % MOD;
		printf("%d\n", res);
	}
	return 0;
}



Measured memory_bytes: 256
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n,k,ans=0;
  cin>>n>>k;
  vector<ll>v(n,0);
  vector<ll>a(n,0);
  vector<ll>b(n,0);
  for(ll i=0;i<n;i++){
    cin>>v[i];
  }
  for(ll i=0;i<n;i++){
    for(ll j=0;j<n;j++){
      if(v[i]>v[j]){
        if(i<j)a[i]++;
        else b[i]++;
      }
    }
  }
  ll p=0,q=0;
  if(k%2==0){
    p=(k/2)%MOD;
    p=p*(k-1)%MOD;
    q=(k/2)%MOD;
    q=q*(k+1)%MOD;
  }
  else{
    p=((k-1)/2)%MOD;
    p=p*k%MOD;
    q=((k+1)/2)%MOD;
    q=q*k%MOD;
  }
  ll aa=0,bb=0;
  for(ll i=0;i<n;i++){
    aa=(aa+a[i])%MOD;
    bb=(bb+b[i])%MOD;
  }
  ans=((p*bb)%MOD+(q*aa)%MOD)%MOD;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > using vec = std::vector< T >;
template < class T = int > T in() {
  T x;
  cin >> x;
  return (x);
}
template < class T > void print(T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int nowmod = 1;
  int summod = 0;
  vec< int > a;
  REPR(i, (int)(S.size()) - 1) {
    if (S[i] == '?') {
      a.pb(nowmod);
    } else {
      summod += (S[i] - '0') * nowmod;
      summod %= 13;
    }
    nowmod *= 10;
    nowmod %= 13;
  }
  int sizeA = a.size();
  // DEBUG(summod);
  vec< vec< int > > dp(sizeA + 1, vec< int >(13, 0));
  dp[0][summod] = 1;
  REPS(i, sizeA) {
    REP(j, 13) {
      REP(k, 10) {
        int to = j + k * a[i - 1];
        to %= 13;
        dp[i][to] += dp[i - 1][j];
        dp[i][to] %= MOD;
      }
    }
  }
  // REP(i, 13) { cout << dp[sizeA][i] << " "; }
  // cout << "\n";
  cout << dp[sizeA][5] << endl;
  // print();
}

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

int main(){
  string S;
  cin >> S;
  if(S=="Sunny"){
    puts("Cloudy");
  }
  if(S=="Cloudy"){
    puts("Rainy");
  }if(S=="Rainy"){
    puts("Sunny");
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
   int n;
   cin >> n;
   vector<int> a(n);
   for(int i = 0; i < n; i++) cin >> a[i];
   std::sort(a.begin(), a.end());
   a.erase(std::unique(a.begin(), a.end()), a.end());
   if(a.size() == n) cout <<"YES";
   else cout << "NO";
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**7)

n,m=map(int,input().split())
g=[[] for _ in range(n)]
for _ in range(m):
    l,r,d=map(int,input().split())
    g[l-1].append([r-1,d])
    g[r-1].append([l-1,d*(-1)])
f=[False for _ in range(n)]

def dfs(s,x):
    f[s] = x
    for sg in g[s]:
        if type(f[sg[0]]) == bool:
            if not dfs(sg[0],sg[1]+x):
                return False
        else:
            if f[sg[0]] - f[s] != sg[1]:
                return False
    return True

def main():
    for i in range(n):
        if type(f[i]) == bool:
            if not dfs(i,1):
                return "No"
    return "Yes"

print(main())

Measured memory_bytes: 135240
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <bitset>

using ll = long long;
using ull = unsigned long long;

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

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

ll gcd(ll a, ll b)
{
    if (a > b)
        std::swap(a, b);

    while (true)
    {
        auto m = b % a;
        if (m == 0)
            return a;
        b = a;
        a = m;
    }
}

int main()
{
    using namespace std;

    int n;
    cin >> n;
    
    vec<pair<string, int>> p(n);
    map<int, int> ma;

    int i = 1;
    for (auto & e: p)
    {
        cin >> e.first >> e.second;
        e.second = 100 - e.second;
        ma[e.second] = i;
        ++i;
    }

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


    for (int i = 0; i < n; ++i)
    {
        //cout << p[i].first << " ";
        cout << ma[p[i].second] << endl;
    }

    return 0;
}


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

string s;

lint dfs(int n, lint sum, lint cur) {
  if (n == s.size()) {
    return sum + cur;
  }
  lint res = 0;
  res += dfs(n + 1, sum, cur * 10 + s[n] - '0');
  if (cur > 0) {
    res += dfs(n + 1, sum + cur, s[n] - '0');
  }

  return res;
}

int main() {
  cin >> s;
  cout << dfs(0, 0, 0) << "\n";
}

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

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        Strategy strategy = new MyStrategy();
        strategy.solve(out, sc);
        out.flush();
    }
}

class MyStrategy implements Strategy {
    @Override
    public void solve(PrintWriter out, FastScanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        if (a > b) {
            for (int i = 0; i<a; i++) {
                sb.append(b);
            }
        } else if (a < b) {
            for (int i = 0; i<b; i++) {
                sb.append(a);
            }
        } else {
            for (int i = 0; i<a; i++) {
                sb.append(b);
            }
        }
        out.println(sb.toString());
    }
}

interface Strategy {
    void solve(PrintWriter out, FastScanner sc);
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private 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;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public 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();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 21332
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll n, m, d;
  cin >> n >> m >> d;

  long double tmp = ((long double)(m-1))/(long double)n;
  if(d==0){
    //cout << tmp << "\n";
    printf("%.10Lf\n", tmp);
  }else{
    //cout << 2.0*tmp*(1.0-(long double)d/(long double)n) << "\n";
    printf("%.10Lf\n", 2.0*tmp*(1.0-(long double)d/(long double)n));
  }

  return 0;
}

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

int main() {
    ll N;
    cin >>N;
    vector<queue<ll>> vq(N);
    for(int i=0;i<N;i++)for(int j=0;j<N-1;j++){
        ll A;
        cin >> A;
        --A;
        vq[i].push(A);
    }

    ll remain = N*(N-1);
    ll ans =0;
    while(remain){
        vector<bool> skip(N,false);
        bool changed = false;
        for(int i=0;i<N;i++){
            if(skip[i]){
                continue;
            }
            if(!vq[i].empty()){

                ll t = vq[i].front();
                // cerr <<"i=" <<i <<" t = " << t << endl;
                if(vq[t].front() ==i && !skip[t]){
                    remain -=2;
                    changed = true;
                    skip[t] = true;
                    skip[i] = true;
                    vq[t].pop();
                    vq[i].pop();
                }
            }
        }
        if(!changed){
            cout <<-1 << endl;
            return 0;
        }

        ans++;
    }
    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 12312
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main()
{
  int n, m;
  scanf("%d%d", &n, &m);
  int c[n], s, tmp, ans = 0;
  for (int i = 0; i < n; i++)
    c[i] = -1;
  for (int i = 0; i < m; i++)
  {
    scanf("%d%d", &s, &tmp);
    s--;
    if (c[s] == -1)
      c[s] = tmp;
    else if (c[s] != tmp)
      ans = -1;
  }
  if (ans == -1)
    printf("-1\n");
  else if (n == 1) {
    if (c[0]==-1)
      printf("0\n");
    else
      printf("%d\n", c[0]);
  }
  else if (c[0] == 0)
    printf("-1\n");
  else
  {
    if (c[0] == -1)
      ans = 1;
    else
      ans = c[0];
    for (int i = 1; i < n; i++)
    {
      ans *= 10;
      if (c[i] != -1)
        ans += c[i];
    }
    printf("%d\n", ans);
  }
  return 0;
}


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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
   int a[5]; rep(i,0,5) cin >> a[i];
   rep(i,0,5){
       if(a[i] == 0){
           cout << i+1 << "\n";
           break;
       }
   }
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define INF (1<<29)

int dp[1001][1001];
int n, m, d[1000], c[1000];

int main() {
	cin >> n >> m;
	REP(i, n) scanf("%d", &d[i]);
	REP(i, m) scanf("%d", &c[i]);

	fill(dp[0], dp[1001], INF);
	dp[0][0] = 0;

	REP(i, m) {
		REP(j, n + 1) {
			if (j == 0)
				dp[i+1][j] = dp[i][j];
			else
				dp[i+1][j] = min(dp[i][j], dp[i][j-1] + d[j-1]*c[i]);
		}
	}

	cout << dp[m][n] << endl;

	return 0;
}

Measured memory_bytes: 5160
import sys
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
a,b=map(int,input().split())
tmp=gcd(a,b)
# print(tmp)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

ans=factorization(tmp)
# print(ans)
if tmp==1:
    print(1)
else:
    print(len(ans)+1)

Measured memory_bytes: 65132
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		int Q=sc.nextInt();
		int[] imos=new int[N+1];
		Arrays.fill(imos,0);
		for(int i=0; i<Q; i++) {
			int ans=sc.nextInt();
			if(ans==1) {
				imos[1]--;
				imos[N]++;
			}
			else if(ans==N) {
				imos[0]--;
				imos[N-1]++;
			}
			else {
				imos[0]--;
				imos[ans-1]++;
				imos[ans]--;
				imos[N]++;
			}
		}
		if(imos[0]+K>0) {
			p("Yes");
		}
		else {
			p("No");
		}
		for(int i=1; i<=N; i++) {
			imos[i]=imos[i]+imos[i-1];
			if(i<N && imos[i]+K>0) {
				p("Yes");
			}
			else if(i<N){
				p("No");
			}
		}
	}
	public static void p(Object o) {
		System.out.println(o);
	}
}

Measured memory_bytes: 70236
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include <iterator>

/*
#include <thread>
#include <exception>
*/

using namespace std;

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;



/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}

*/

/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/

/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; ++i) {
	for (int j = 0; j < w; ++j) {

	}
}

*/
#define index_of(as, x) distance(as.begin(), upper_bound(as.begin(), as.end(), x))

vector<int> lis_fast(const vector<int>& a) {
	const int n = a.size();
	vector<int> A(n, INF);
	vector<int> id(n);
	for (int i = 0; i < n; ++i) {
		id[i] = index_of(A, a[i]);
		A[id[i]] = a[i];
	}
	int m = *max_element(id.begin(), id.end());
	vector<int> b(m + 1);
	for (int i = n - 1; i >= 0; --i)
		if (id[i] == m) b[m--] = a[i];
	//cout << lower_bound(b.begin(),b.end(), INF) - b.begin() << endl;
	return b;
}

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

	vector<int> a(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	reverse(a.begin(), a.end());

	cout << lis_fast(a).size() << endl;



	return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long int
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define N 200009
#define M 15000007
#define mod 1000000007
#define debug cout<<"There There\n";
#define debug1(x) cout<<"\nValue is "<<x<<endl
#define debug2(x,y) cout<<"\nValue is "<<x<<" "<<y<<endl
#define debug3(x,y,z) cout<<"\nValue is "<<x<<" "<<y<<" "<<z<<endl  
#define pq priority_queue<int>
#define mpq priority_queue<int,vector<int>,greater<int>>
#define pr pair<int,int>
#define mx INT_MAX
#define lmx LLONG_MAX
#define err return 0
#define all(a) a.begin(),a.end()

int h1,w1;
string s[2009];

int32_t main()
{
     //IOS;
     cin>>h1>>w1;
     for(int i=0;i<h1;i++)
     {
          cin>>s[i];
     }
     vector<int> horiz[2009];
     vector<int> ver[2009];     
     for(int i=0;i<h1;i++)
     {
          horiz[i].pb(-1);
     }
     for(int i=0;i<w1;i++)
     {
          ver[i].pb(-1);
     }
     for(int i=0;i<h1;i++)
     {
          for(int j=0;j<w1;j++)
          {
               if(s[i][j]=='#')
               {
                    horiz[i].pb(j);
                    ver[j].pb(i);
               }
          }
     }
     for(int i=0;i<h1;i++)
     {
          horiz[i].pb(w1);
          sort(all(horiz[i]));
     }
     for(int i=0;i<w1;i++)
     {
          ver[i].pb(h1);
          sort(all(ver[i]));
     }
     int ans = 0;
     for(int i=0;i<h1;i++)
     {
          for(int j=0;j<w1;j++)
          {
               if(s[i][j]=='.')
               {
                    auto l =  lower_bound(horiz[i].begin(),horiz[i].end(),j);
                    int see = (int)(l-horiz[i].begin());
                    see--;
                    int see2 = see+1;
                    int ans1 = horiz[i][see2]-horiz[i][see]-1;
                    auto  r =  lower_bound(ver[j].begin(),ver[j].end(),i);
                    see = (int)(r-ver[j].begin());
                    see--;
                    see2 = see+1;
                    ans1+=(ver[j][see2]-ver[j][see]-2);
                    ans = max(ans,ans1);
                    //cout<<ans1<<" "<<i<<" "<<j<<endl;
               }
          }
     }
     cout<<ans<<endl;
}

Measured memory_bytes: 71296
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int n = 0;
  cin >> n;
  string s;
  cin >> s;
  vector<int> inf(n);
  for(int i = 0;i < n;i++){
    if(s[i] == 'o')inf[i] = 1;
    else inf[i] = -1;
  }
  for(int i = 0;i < 2;i++){
    for(int j = 0;j < 2;j++){
      vector<int> now(n);
      if(i == 0)now[0] = 1;
      else now[0] = -1;
      if(j == 0)now[1] = 1;
      else now[1] = -1;
      if(now[0] * inf[0] == 1)now[n - 1] = now[1];
      else now[n - 1] = -1 * now[1];
      //cout << now[0] << " " << now[1] << " " << now[n - 1] << endl;
      for(int k = 1;k <= n - 3;k++){
        if(now[k] * inf[k] == 1)now[k + 1] = now[k - 1];
        else now[k + 1] = -1 * now[k - 1];
      }
      bool ok = true;
      if(now[n - 1] * inf[n - 1] == 1 && now[0] != now[n - 2])ok = false;
      if(now[n - 1] * inf[n - 1] == -1 && now[0] == now[n - 2])ok = false;
      if(now[n - 2] * inf[n - 2] == 1 && now[n - 1] != now[n - 3])ok = false;
      if(now[n - 2] * inf[n - 2] == -1 && now[n - 1] == now[n - 3])ok = false;
      if(ok){
        for(int k = 0;k < n;k++){
          if(now[k] == 1)cout << "S";
          else cout << "W";
        }
        cout << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<vector<int>> a(n,vector<int>(n));
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      cin>>a.at(i).at(j);
  map<int,vector<int>> b;
  for(int i=1;i<(1<<n);i++){
    int x=i;
    int s=0;
    while(x>0){
      s+=x%2;
      x/=2;
    }
    b[s].push_back(i);
  }
  vector<int> dp((1<<n),0);
  dp[0]=1;
  for(int x=0;x<n;x++){
    for(int i:b.at(x+1)){
      int c=i;
      int d=1;
      for(int y=0;y<n;y++){
        if(c%2==1)
          dp[i]=(dp[i]+dp[i-d]*a.at(x).at(y))%1000000007;
        c/=2;
        d*=2;
      }
    }
  }
  cout<<dp[(1<<n)-1]<<endl;
}

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

#define ll long long
#define llu unsigned long long
#define ld long double
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(x) x.begin(),x.end()
#define foreach(it,v) for( __typeof((v).begin())it = (v).begin() ; it != (v).end() ; it++ )
#define present(v,x) (v).find(x) != (v).end()
#define cpresent(v,x) (find(all(v),x) != (v).end())
#define mset(x,v) memset(x, v, sizeof(x))
#define sz(x) (int)x.size()
#define shout()  {cout << "I'm Here...!!!" << endl;}
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }

inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int addmod(int a, int val, int p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline int submod(int a, int val, int p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

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

	int h, w;
	cin >> h >> w;
	string grid[h];
	for(int i=0; i<h; i++)
		cin >> grid[i];

	int dp[h][w];
	mset(dp, 0);

	for(int i=0; i<h; i++)
		for(int j=0; j<w; j++)
			if(i==0 and j==0){
				dp[i][j] = 1;
				continue;
			}
			else if(i==0){
				if(grid[i][j]=='.')
					dp[i][j] = dp[i][j-1];
			}
			else if(j==0){
				if(grid[i][j]=='.')
					dp[i][j] = dp[i-1][j];
			}
			else if(grid[i][j]=='.')
				dp[i][j] = addmod(dp[i][j-1], dp[i-1][j]);

	cout << dp[h-1][w-1] << endl;

	return 0;
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())

using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define INF 10101010

int main()
{
    int h1,h2,m1,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    if(h2<h1){
        h2+=24;
    }
    h2*=60;
    h1*=60;
    h2+=m2;
    h1+=m1;
    h2-=k;
    cout << h2-h1 << endl;

}

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

const int D_y[8] = { -1,-1,0,1,1,1,0,-1 };
const int D_x[8] = { 0,1,1,1,0,-1,-1,-1 };

void checkRange(int board[8][8], int X, int Y,int n) {
	board[Y][X] += n;
	for (int i = 0; i < 8; i++) {
		int x = X + D_x[i];
		int y = Y + D_y[i];
		while (x >= 0 && x < 8 && y >= 0 && y < 8) {
			board[y][x] += n;
			x += D_x[i];
			y += D_y[i];
		}
	}
}

bool solve(bool Qboard[8][8], int board[8][8], int n) {
	if (n == 0)return true;
	bool copyBoard[8][8];

	for (int i = 0; i < 8; i++) {
		for (int j = 0; j < 8; j++) {
			if (board[i][j] == 0) {

				Qboard[i][j] = true;
				checkRange(board, j, i, 1);

				if (solve(Qboard, board, n - 1))return true;

				Qboard[i][j] = false;
				checkRange(board, j, i, -1);
			}
		}
	}
	return false;
}

int main() {
	int k;
	int board[8][8] = { 0 };
	bool Qboard[8][8] = { false };

	cin >> k;
	for (int i = 0; i < k; i++) {
		int r, c;
		cin >> r >> c;
		Qboard[r][c] = true;
		checkRange(board, c, r, 1);
	}

	solve(Qboard, board, 8 - k);

	for (int i = 0; i < 8; i++) {
		for (int j = 0; j < 8; j++) {
			if (Qboard[i][j])cout << "Q";
			else cout << ".";
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define in(_n) int _n; cin >> _n
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    in(N);
    vector<int> X(N), Y(N);
    for (int i = 0; i < N; ++i) {
        cin >> X[i] >> Y[i];
    }
    double ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i == j) continue;
            ans += sqrt((X[i]-X[j])*(X[i]-X[j])+(Y[i]-Y[j])*(Y[i]-Y[j]));
        }
    }
    ans /= N;
    printf("%.10lf\n", ans);
    return 0;
}


Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

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

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

	int N, K;
	
	cin >> N >> K;
	int a[N+1]; 

	rep(i, N+1)
	{
		a[i] = 0;
	}
	
	rep(i, K)
	{
		int d;
		cin >> d;
		//int a[d];
		int c;
		rep(j, d)
		{
			cin >> c;
			a[c]++;
		}
	}

	int ret = 0;
	rep(i, N)
	{
		if (a[i+1] == 0)
		{
			ret++;
		}
	}

	cout << ret << endl;

	
	return 0;
}


Measured memory_bytes: 3648
try:
    a=""
    while True:
        S=input()
        if not S:
            break
        S=S.lower()
        a=a+S
except EOFError:
    pass
for i in range(97,97+26):
    
    b=a.count(chr(i))
    print(chr(i)+" : "+str(b))


          

Measured memory_bytes: 7400
num=list(map(int,input().split()))
#最大値はa*c,a*d,b*c,b*dのいずれかである
max_num=['a','b','c','d']
max_num[0]=num[0]*num[2]    #a*c
max_num[1]=num[0]*num[3]    #a*d
max_num[2]=num[1]*num[2]    #b*c
max_num[3]=num[1]*num[3]    #b*d

print(max(max_num))

Measured memory_bytes: 9212
// https://atcoder.jp/contests/abc118/tasks/abc118_c

// http://ctylim.hatenablog.com/entry/2015/08/30/191553
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cstdio>

#define ALL(a) (a).begin(), (a).end()
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define MAXINDEX(c) distance((c).begin(), max_element((c).begin(), (c).end()))
#define MININDEX(c) distance((c).begin(), min_element((c).begin(), (c).end()))
#define DEBUG(x) std::cerr << #x << " = " << (x) << " (" << __FILE__ << "::" << __LINE__ << ")" << std::endl;
#define ERROR(s) std::cerr << "Error::" << __FILE__ << "::" << __LINE__ << "::" << __FUNCTION__ << "::" << (s) << std::endl;
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)

#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

template <typename T>
T inputValue()
{
  T a;
  // std::cin >> a;
  scanf("%llu", &a);
  return a;
}

void inputArray(int *p, int a)
{
  rep(i, a)
  {
    std::cin >> p[i];
    // scanf("%d",p+i);
  }
}

template <typename T>
void inputVector(std::vector<T> *p, int a)
{
  rep(i, a)
  {
    T input;
    // std::cin >> input;
    scanf("%llu", &input);
    p->push_back(input);
  }
}

template <typename T>
void output(T a, int precision)
{
  if (precision > 0)
  {
    std::cout << std::setprecision(precision) << a << "\n";
  }
  else
  {
    std::cout << a << "\n";
  }
}

using namespace std;

int gcd(int a, int b)
{
  while (1)
  {
    if (a < b)
      swap(a, b);
    if (!b)
      break;
    a %= b;
  }
  return a;
}

typedef unsigned long long int ulli;
int main(int argc, char **argv)
{

  ulli N = inputValue<ulli>();
  ulli K = inputValue<ulli>();
  vector<ulli> v;
  inputVector<ulli>(&v, N);


  vector<ulli> bitSum(64,0);

  EACH(k, v)
  {
    ulli t = *k;
    for(int i=0; i<64&&t!=0; i++){
      bitSum[i] = bitSum[i] + (t&1) ;
      t = t >> 1;
    }
  }

  int flag = 0;

  ulli sum = 0;
  for (int i = 63; i >= 0; i--){
    ulli K_bit = (K >> i) & 1ll;
    ulli A_bit = (bitSum[i] > N / 2 ? 0 : 1); // 多数決
    ulli X_bit = A_bit;
    if (!flag) {// Kを超えないように調整:
      X_bit = K_bit && A_bit;
      flag = K_bit && (!A_bit);
      // K: kkkkkk1kkkkk 
      // A: aaaaaa0aaaaa
      // D: dddddddddddd
      // 1-0のパターンの左は D=K&A
      // 右は D=A
    }
    sum = sum + (((X_bit) ? N - bitSum[i] : bitSum[i]) << i);

  }
  cout << sum << endl;

}


Measured memory_bytes: 1400
<?php
list($a,$b,$c) = explode(" ",trim(fgets(STDIN)));
$i = 1;
$ans = 0;
while($i <= $b){
    if($a * $i % $b == $c){
        ++$ans;
        break;
    }else{
        ++$i;
    }
}

echo $ans != 0 ? "YES":"NO";

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

int main() {
  string s{'2'};
  int n;
  {
    string t; cin >> t;
    s += t;
    s += '3';
    n = s.size();
  }
  int l = (n + 1) / 2 - 1;
  int r = n - 1 - l;
  char c = s[l];
  for (; s[l] == s[r] && s[l] == c; l--, r++);
  cout << r-1 << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N, K;
  cin >> N >> K;

  int ans = 1;
  for (int i = 0; i < N; i++) {
    if (2 * ans < ans + K) {
      ans *= 2;
    } else {
      ans += K;
    }
  }

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
x, k, d = map(int, input().split())
x = abs(x)

if x - d*k >= 0:
  print(x-d*k)
else:
  if (k-x//d) % 2 == 0:
    print(x-(x//d)*d)
  else:
    print(abs(x-(x//d)*d-d))

Measured memory_bytes: 9176
#include <iostream>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

int main() {
	int a, b, k;
	cin >> a >> b >> k;

	vector<int> c_div;
	rep(i, 1, min(a, b) + 1) {
		if (a % i == 0 && b % i == 0) c_div.pb(i);
	}
	REV(c_div);

	cout << c_div[k - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
from decimal import *
import re
def solve2(m, n):
    maxreplen = 160
    PREC=200
    getcontext().prec = PREC
    x = Decimal(m) / Decimal(n)
    s = x.to_eng_string()
    if len(s) < PREC:
        return(s[2:],'')
    rep = 1
    while True:
        r = r'(.{%d})\1{%d,}' % (rep, int(maxreplen/rep)-1)
        #r = r'(.{%d})\1{%d,}' % (rep, 20)
                                         #ex. '(.{6})\\1{12,}'
        a=re.search(r, s)
        if a:
            break
        rep += 1
        if rep > maxreplen:
            raise ValueError('This cannot happen.')

    u = s[2:a.start()+len(a.group(1))]
    v = (' '*PREC + '^'*len(a.group(1)))[-len(u):]
    return(u,v)

while True:
    try:
        m,n = map(int, input().strip().split())
        s,t = solve2(m, n)
        print(s)
        if t!='':
            print(t)
    except EOFError:
        break

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;

int A,B;

// *********************************************************
int main(){

    cin >>  A>> B;

    cout << A*B << endl;




    return 0;
}

Measured memory_bytes: 3676
#pragma warning(disable: 4996)

#include <iostream>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <vector>
#include <bitset>
#include <numeric>
#include <string>
#include <set>
#include <tuple>
#include <utility>
#include <regex>
using namespace std;

int isprime(int x) {
	int a = 1, i;
	double root_x;
	if (x == 2) a = 1;
	else if (x < 2 or x % 2 == 0) a = 0;
	i = 3;
	root_x = pow(x, 0.5);
	while (i <= root_x) {
		if (x % i == 0) a = 0;
		i = i + 2;
	}
	return a;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int x;
	cin >> x;
	while (true) {
		if (isprime(x)) {
			cout << x;
			exit(0);
		}
		++x;
	}
	return 0;
}

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

int main(void){
    int n;
    cin >> n;
    
    int ans = 0;
    int input;
    int i;
    for(i = 1; i <= n; i++){
        cin >> input;
        ans += input - 1;
    }
    
    cout << ans << endl;
    
    return 0;
}


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

using namespace std;

const int maxn = 505;

int n, m;
char a[maxn][maxn];
char b[maxn][maxn];
char s[maxn];

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i)
	{
		a[i][1] = '#';
		b[i][1] = '.';
		a[i][m] = '.';
		b[i][m] = '#';
		for (int j = 2; j < m; ++j)
		{
			a[i][j] = (i & 1) ? '#' : '.';
			b[i][j] = (i & 1) ? '.' : '#';
		}
		scanf("%s", s + 1);
		for (int j = 1; j <= m; ++j)
			if (s[j] == '#')
				a[i][j] = b[i][j] = '#';
	}
	for (int i = 1; i <= n; ++i)
		puts(a[i] + 1);
	puts("");
	for (int i = 1; i <= n; ++i)
		puts(b[i] + 1);
	return 0;
}

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

struct Node {
  int key;
  struct Node *prev, *next;
};

Node *nil;

void initNode() {
  nil = (Node *)malloc(sizeof(Node));
  nil->prev = nil;
  nil->next = nil;
}

void insert(int key) {
  Node *node = (Node *)malloc(sizeof(Node));
  node->key = key;
  node->next = nil->next;
  node->next->prev = node;
  node->prev = nil;
  nil->next = node;
}

void deleteNode(Node *n) {
  if (n == nil)
    return;
  n->prev->next = n->next;
  n->next->prev = n->prev;
  free(n);
}

void deleteX(int key) {
  for (Node *n = nil->next; n != nil; n = n->next) {
    if (n->key == key) {
      deleteNode(n);
      return;
    }
  }
}

void deleteFirst() { deleteNode(nil->next); }

void deleteLast() { deleteNode(nil->prev); }

int main() {
  int n;
  int key;
  char command[10];
  initNode();
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%s%d", command, &key);
    if (command[0] == 'i') {
      insert(key);
    } else if (strlen(command) > 6) {
      if (command[6] == 'F')
        deleteFirst();
      if (command[6] == 'L')
        deleteLast();
    } else {
      deleteX(key);
    }
  }

  Node *node = nil->next;
  cout << node->key;
  node = node->next;
  for (; node != nil; node = node->next) {
    cout << " ";
    cout << node->key;
  }
  cout << endl;
}

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

namespace TYC
{
	const int N = 55, INF = 0x3f3f3f3f;

	int n, ans, FA[N], FB[N], Deg[N];
	vector<int> A[N], B[N], E[N];

	inline int read()
	{
		int x = 0, f = 0, ch = getchar();
		while (!isdigit(ch))
			f |= (ch == '-'), ch = getchar();
		while (isdigit(ch))
			x = x * 10 + ch - '0', ch = getchar();
		return f ? -x : x;
	}

	void dfs(const int u, const int f, vector<int> *T, int *fa)
	{
		fa[u] = f;
		for (int v : T[u])
			if (v != f)
				dfs(v, u, T, fa);
	}

	bool toposort(int tot)
	{
		static queue<int> q;
		for (int i = 1; i <= n; i++)
			if (FA[i] != FB[i] && !Deg[i])
				q.push(i);
		while (!q.empty())
		{
			int u = q.front();
			q.pop();
			tot--;
			for (int v : E[u])
				if (!--Deg[v])
					q.push(v);
		}
		return !tot;
	}

	inline int count(const int u, const int f)
	{
		int c = 1;
		for (int v : A[u])
			if (v != f && FB[v] == u)
				c += count(v, u);
		return c;
	}

	int solve(const int o)
	{
		dfs(o, 0, A, FA);
		dfs(o, 0, B, FB);
		for (int i = 1; i <= n; i++)
			E[i].clear(), Deg[i] = 0;
		int cnt = 0;
		for (int i = 1, a, b; i <= n; i++)
			if ((a = FA[i]) != (b = FB[i]))
			{
				cnt++;
				if (FA[a] != FB[a])
					E[i].push_back(a), Deg[a]++;
				if (FA[b] != FB[b])
					E[b].push_back(i), Deg[i]++;
			}
		return count(o, 0) == n - cnt && toposort(cnt) ? cnt : INF;  
	}

	void work()
	{
		int T = read();
		while (T--)
		{
			n = read();
			for (int i = 1; i < n; i++)
			{
				int u = read(), v = read();
				A[u].push_back(v);
				A[v].push_back(u);
			}
			for (int i = 1; i < n; i++)
			{
				int u = read(), v = read();
				B[u].push_back(v);
				B[v].push_back(u);
			}
			ans = INF;
			for (int i = 1; i <= n; i++)
				ans = min(ans, solve(i));
			for (int u = 1; u <= n; u++)
				if (int(A[u].size()) == 1)
				{
					int v = A[u][0];
					A[u].pop_back();
					A[v].erase(find(A[v].begin(), A[v].end(), u));
					for (int p = 1; p <= n; p++)
						if (p != u && p != v)
						{
							A[u].push_back(p);
							A[p].push_back(u);
							ans = min(ans, solve(u) + 1);
							A[u].pop_back();
							A[p].pop_back();
						}
					A[u].push_back(v);
					A[v].push_back(u);
				}
			printf("%d\n", ans == INF ? -1 : ans);
			for (int i = 1; i <= n; i++)
				A[i].clear(), B[i].clear();
		}
	}
}

int main()
{
//	freopen("4380.in", "r", stdin);
	TYC::work();
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const ll MOD = 1e9 + 7;

void makeNextLink(vector<int> &nxt, const vector<int> &a) {
    map<int, int> memo;
    for (size_t i = nxt.size() - 1; 1 <= i; --i) {
        if (memo.count(a[i]) != 0) nxt[i] = memo[a[i]];
        memo[a[i]] = i;
    }
}

ll Solve() {
    ll n;
    cin >> n;

    vector<ll> pow2(n + 1, 1);
    for (int i = 1; i <= n; ++i) (pow2[i] = 2 * pow2[i - 1]) %= MOD;

    vector<int> a(n + 1), cnt_zero(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        a[i] ^= a[i - 1];
        if (a[i] == 0) ++cnt_zero[i];
        cnt_zero[i] += cnt_zero[i - 1];
    }

    vector<int> nxt(n + 1, -1);
    makeNextLink(nxt, a);

    // for (int i = 0; i < n; ++i)
    //     cout << "nxt[" << i << "] = " << nxt[i] << endl;
    // for (int i = 0; i <= n; ++i)
    //     cout << "cnt_zero[" << i << "] = " << cnt_zero[i] << endl;
    // for (int i = 0; i < n; ++i)
    //     cout << "a[" << i << "] = " << a[i] << endl;
    // cout << "a.back() = " << a.back() << endl;

    ll sum = 1;
    if (a.back() != 0) {
        int idx = 1;
        while (a[idx] != a.back()) ++idx;

        ll sum_a = 1, sum_b = 0;
        while (nxt[idx] != -1) {
            ll num_zero = cnt_zero[nxt[idx]] - cnt_zero[idx - 1];
            (sum_b += num_zero * sum_a) %= MOD;
            (sum_a += sum_b + 1) %= MOD;
            idx = nxt[idx];
        }
        sum += sum_b;
    }
    else {
        set<int> used;
        for (int i = 1; i + 1 <= n; ++i) {
            if (used.count(a[i]) != 0) continue;
            used.insert(a[i]);
            // cout << "start: i = " << i << ", sum = " << sum << endl;

            if (a[i] == 0) {
                // cout << "i = " << i << ": " << sum;
                int num_zero = cnt_zero[n] - cnt_zero[i - 1];
                (sum += pow2[num_zero - 1] - 1 + MOD) %= MOD;
                // cout << " -> " << sum << ", num_zero = " << num_zero << endl;
            }
            else {
                ll sum_a = 1, sum_b = 0, idx = i;
                while (nxt[idx] != -1) {
                    ll num_zero = cnt_zero[nxt[idx]] - cnt_zero[idx - 1];
                    (sum_b += num_zero * sum_a) %= MOD;
                    (sum_a += sum_b + 1) %= MOD;
                    idx = nxt[idx];
                }
                (sum += sum_a) %= MOD;
            }
            // cout << "end: i = " << i << ", sum = " << sum << endl;
        }
    }

    return sum % MOD;
}

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    cout << Solve() << endl;

    return 0;
}


Measured memory_bytes: 23552