akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES //M_PI, M_E
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b;
	cin>>a>>b;
	cout<<(a+b+1)/2;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    while(true) {
        int W, H;
        cin >> W >> H;
        if(W == 0 && H == 0) break;
        vector< vector<vector<P> > > map(H, vector< vector<P> >(W, vector<P>()));
        REP(i, H ) {
            if(i > 0) {
                REP(j, W) {
                    int w;
                    cin >> w;
                    if(w == 0){
                        map[i][j].push_back(make_pair(i-1, j));
                        map[i-1][j].push_back(make_pair(i, j));
                    }
                }
            }

            REP(j, W-1) {
                int w;
                cin >> w;
                if(w == 0) {
                    map[i][j].push_back(make_pair(i, j+1));
                    map[i][j+1].push_back(make_pair(i, j));
                }
            }
        }

        queue<P> que;
        que.push(make_pair(0, 0));
        vector< vector<int> > dist(H, vector<int>(W, 0));
        dist[0][0] = 1;

        while(!que.empty()) {
            P cur = que.front();
            que.pop();

            for(P next: map[cur.first][cur.second]) {
                if(dist[next.first][next.second] == 0) {
                    dist[next.first][next.second] = dist[cur.first][cur.second] + 1;
                    que.push(next);
                }
            }
        }

        cout << dist[H-1][W-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3144
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <cassert>
#include <cstring>
#include <queue>
#include <cstdio>
#include <cmath>
#include <sstream>
 
using namespace std;
 
typedef long long Long;

struct DisjointSet
{
	vector<int> P; // if < 0 then negative size, else parentId
	DisjointSet(int N) : P(N, -1) {}
	int find(int x) {
		return P[x] < 0 ? x : (P[x] = find(P[x]));
	}
	bool join(int x,int y) {
		if((x = find(x)) == (y = find(y))) return false;
		if(P[y] < P[x]) swap(x,y);
		P[x] += P[y];
		P[y] = x;
		return true;
	}
};

int main(int argc, char *argv[]) {
	
	int N, M;
	cin >> N >> M;
	vector<int> V(N);
	for (int &x : V) {
		cin >> x;
		x--;
	}
	DisjointSet DS(N);
	for (int i = 0; i < M; ++i) {
		int u,v;
		cin >> u >> v;
		u--;v--;
		DS.join(u, v);
	}
	int c = 0;
	for (int i = 0; i < N; ++i) {
		if (DS.find(V[i]) == DS.find(i)) {
			c++;
		}
	}
	cout << c << endl;
	
	
}
 
/*
 
gautambishal
5
3 0
2 0 5
3 1
4 0 0
4 3 0

 */
 


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

using namespace std;

int n;

int main()
{
  cin >> n;

  bool ok = false;
  int a, b;
  for (a = 1; a*a < 2*n; a++) {
    if (((2*n) % a) == 0 && (2*n)/a == a+1) {
      b = (2*n) / a;
      ok = true;
      break;
    }
  }

  if (ok) {
    vector<int> v[b];
    int next[b];
    for (int i = 0; i < b; i++) next[i] = (i+1)%b;
    int i = 0;
    for (int num = 1; num <= n; num++) {
      v[i].push_back(num);
      v[next[i]].push_back(num);
      next[i] = (next[i] + 1) % b;
      i = (i + 1) % b;
    }

    cout << "Yes" << endl;
    cout << b << endl;
    for (auto x : v) {
      cout << x.size() << " ";
      for (int i = 0; i < x.size(); i++) {
        cout << x[i] << (i+1==x.size()?'\n':' ');
      }
    }
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 2304
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner; 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		ArrayList<HashSet<Integer>> adj = new ArrayList<HashSet<Integer>> ();
		for(int i=0; i<n; i++)adj.add(new HashSet<Integer>());
		
		for(int i=0; i<m; i++) {
			int x = sc.nextInt() - 1 , y = sc.nextInt() - 1;
			adj.get(x).add(y);
		}
		
		for(int x : adj.get(0)) {
			if(adj.get(x).contains(n-1)) {
				System.out.println("POSSIBLE\n");
				return;
			}
		}
		System.out.println("IMPOSSIBLE");
	}
}


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

int main(){
	

char a[2];
for(int i=0;i<3;++i)cin>>a[i];

if(a[1]=='A'&&a[0]=='A'&&a[2]=='A'){cout<<"No"<<endl;}
else if(a[1]=='B'&&a[0]=='B'&&a[2]=='B'){cout<<"No"<<endl;}
else{cout<<"Yes"<<endl;}

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<map>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#include<cctype>
#define pa pair<int,int>
#define INF 0x3f3f3f3f
#define inf 0x3f
#define fi first
#define se second
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pb push_back

using namespace std;

inline ll read()
{
	long long f=1,sum=0;
	char c=getchar();
	while (!isdigit(c)) {if (c=='-') f=-1;c=getchar();}
	while (isdigit(c)) {sum=sum*10+c-'0';c=getchar();}
	return sum*f;
}
const int MAXN=2010;
#define Mod 924844033
int f[2*MAXN][2*MAXN][2],cnt;
bool lk[MAXN*2];
int fac[MAXN];
int main()
{
	int n,K;
	scanf("%d%d",&n,&K);
	fac[0]=1;
	for (int i=1;i<=n;i++)
		fac[i]=1ll*fac[i-1]*i%Mod;
	for (int i=1;i<=K;i++)
	{
		for (int j=i;j<=n;j+=K)
			lk[++cnt]=(j!=i);
		for (int j=i;j<=n;j+=K)
			lk[++cnt]=(j!=i);
	}
	f[0][0][0]=1;
	for (int i=0;i<2*n;i++)
	{
		for (int j=0;j<=n;j++)
		{
			f[i+1][j][0]=(f[i][j][0]+f[i][j][1])%Mod;
			if (lk[i+1]) f[i+1][j+1][1]=f[i][j][0];
		}
	}
	ll ans=0;
	for (int i=0;i<=n;i++)
	{
		int tmp=1ll*(f[2*n][i][0]+f[2*n][i][1])*fac[n-i]%Mod;
		if (i&1) ans-=tmp,ans+=Mod;
		else ans+=tmp;
		ans%=Mod; 
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 124800
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b && b!=c && a!=c) || (b==c && a!=b && a!=c) || (a==c && b!=a && b!=c)) {
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>u,v,w;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    string a;
   cin>>n;
   for(i=0,k=0;i<n;i++)
   {
       cin>>p>>q;
       k+=(q-p)+1;

   }
   cout<<k<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long MAXN=2550,MAXE=5050;
using namespace std;
long long nt[MAXE],val[MAXE],to[MAXE],opnt[MAXE],opto[MAXE];
long long f[MAXN],d[MAXN],vis[MAXN],book[MAXN],opf[MAXN],used[MAXN];
queue<long long>q;
long long num,n,m,p;
void add(long long u,long long v,long long w){
	num++;nt[num]=f[u];f[u]=num;to[num]=v;val[num]=w;
	opnt[num]=opf[v];opf[v]=num;opto[num]=u;
}

void dfs(int x){
	if(used[x]) return ;
	used[x]=1;
	for(int i=opf[x];i;i=opnt[i])
		dfs(opto[i]);
}

void SPFA(){
	memset(d,-0x3f,sizeof d);
	q.push(1);vis[1]=1;d[1]=0;
	while(!q.empty()){
		long long u=q.front();q.pop();vis[u]=0;
		book[u]++;if(book[u]==n)cout<<"-1\n",exit(0);
		for(long long i=f[u];i;i=nt[i])
			if(used[to[i]]&&d[u]+val[i]>d[to[i]]){
				d[to[i]]=d[u]+val[i];
				if(!vis[to[i]])
					q.push(to[i]),vis[to[i]]=1;
			}
	}
	cout<<(d[n]<0?0:d[n])<<endl;
}

int main(){
	cin>>n>>m>>p;long long u,v,w;
	for(long long i=1;i<=m;i++)
		cin>>u>>v>>w,add(u,v,w-p);
	dfs(n);
	SPFA();
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
/**
vector<int>ar(3);
for(auto&e:ar){
    scanf("%d",&e);
        }
sort(ar.begin(),ar.end())
int sum=accumulate(ar.begin(),ar.end(),0);
**/
//memo d17202 1274246
const int NIL = -1;
const int INF = 1000000000;
 
typedef tuple<int, int, int, bool> Uncertain;
 
int BellmanFord(const vector<vector<int>>& g, int start) {
  vector<int> distance(g.size(), INF);
  distance[start] = 0;
  for(int step = 1; step <= g.size(); ++step) {
    for(int i = 0; i < g.size(); ++i) {
      for(int j = 0; j < g.size(); ++j) {
        if(g[i][j] == INF) continue;
        if(distance[j] <= distance[i] + g[i][j]) continue;
        if(step == g.size()) return NIL;
        distance[j] = distance[i] + g[i][j];
      }
    }
  }
  return *max_element(begin(distance), end(distance));
}
 
int solve(const vector<vector<int>>& g, const vector<Uncertain>& uncertain, bitset<8> bit = 0, int depth = 0) {
  if(depth == uncertain.size()) {
    auto h(g);
    for(int i = 0; i < uncertain.size(); ++i) {
      int u, v, d;
      bool positive;
      tie(u, v, d, positive) = uncertain[i];
      if(bit[i]) swap(u, v);
      h[v][u] = 0;
      if(positive) h[v][u] = -d;
      else         h[u][v] = d;
    }
    return BellmanFord(h, 0);
  }
  return max(solve(g, uncertain, bit.set(depth), depth + 1), solve(g, uncertain, bit.reset(depth), depth + 1));
}
int main(){
    double pai=3.141592653589;
  int N, C;
  cin >> N >> C;
  vector<vector<int>> g(N, vector<int>(N, INF));
  for(int i = 1; i < N; ++i) g[i][0] = 0;
  vector<Uncertain> uncertain;
  for(int i = 0; i < C; ++i) {
    string s;
    cin >> s;
    // parse
    enum {LESS = '<', EQUAL = '*', MORE = '>'};
    int u = 0, v = 0, d = 0;
    char order;
    bool positive;
    int index = 0;
    while(isdigit(s[index])) u = 10 * u + (s[index++] - '0');
    if((order = s[index++]) != EQUAL) ++index;
    while(isdigit(s[index])) v = 10 * v + (s[index++] - '0');
    positive = (s[index++] == '+');
    while(isdigit(s[index])) d = 10 * d + (s[index++] - '0');
    // edge
    --u;
    --v;
    if(order == EQUAL) {
      uncertain.emplace_back(u, v, d, positive);
    } else {
      if(order == MORE) swap(u, v);
      g[v][u] = 0;
      if(positive) g[v][u] = -d;
      else         g[u][v] = d;
    }
  }
  // output
  int answer = solve(g, uncertain);
  if(answer == INF) cout << "inf";
  else              cout << answer;
  cout << endl;
}

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

int main(){
    int a[100],n;
    cin >> n;
    for (int i = 0; i < n; i++)cin >> a[i];
    for (int i = n-1; i >= 0 ; i--)
    {
        if (i != n-1)cout << " ";
        cout << a[i];
    }
    cout << endl;
return 0;
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N, K;
	string S;
	queue<int> left;
	queue<int> right;
	cin >> N >> K;
	cin >> S;

	left.push(0);
	right.push(N - 1);

	int ans = 0;
	for (int i = 0; i + 1 < N; i++)
	{
		if (S[i] == '0' && S[i + 1] == '1')
		{
			left.push(i + 1);
		}
		else if (S[i] == '1' && S[i + 1] == '0')
		{
			if (K < left.size())
			{
				ans = max(ans, i - left.front() + 1);
				left.pop();
			}
		}
	}

	for (int i = N - 1; 0 < i; i--)
	{
		if (S[i] == '0' && S[i - 1] == '1')
		{
			right.push(i - 1);
		}
		else if (S[i] == '1' && S[i - 1] == '0')
		{
			if (K < right.size())
			{
				ans = max(ans, right.front() - i + 1);
				right.pop();
			}
		}
	}

	if (ans == 0)
		cout << N << endl;
	else
		cout << ans << endl;

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 640
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args)
    {
        Reader r=new Reader();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int N=r.nextInt();
        int[] values=new int[N];
        int[] costs=new int[N];
        int[] diff=new int[N];
        for(int i=0; i<N; i++)
        {
            values[i]=r.nextInt();
        }
        for(int i=0; i<N; i++)
        {
            costs[i]=r.nextInt();
        }
        for(int i=0; i<N; i++)
        {
            diff[i]=values[i]-costs[i];
        }
        Arrays.sort(diff);
        solve(out, diff);
        out.close();


    }
    static void solve(PrintWriter out, int[] diff)
    {
        int max=0;
        for(int i=0; i<diff.length; i++) {
            if (diff[i] > 0) {
                max += diff[i];
            }
        }
        out.println(max);
    }

    //Fast I/O class
    static class Reader
    {
        BufferedReader br;
        StringTokenizer st;

        public Reader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }


}


Measured memory_bytes: 21332
#include <iostream>
#include <stack>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <vector>
#include <cmath>
#include <unordered_map>
#define ll long long
using namespace std;
int a[1001];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int mx=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++)
            mx=max(mx,abs(a[i]-a[j]));
    }
    cout<<mx;
}


Measured memory_bytes: 256
n,m,q=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(q)]
ans=0
for i1 in range(1,m+1): #愚直に10重ループを行っても、そのループ回数は高々92378回
 for i2 in range(i1,m+1):
   for i3 in range(i2,m+1):
     for i4 in range(i3,m+1):
       for i5 in range(i4,m+1):
         for i6 in range(i5,m+1):
           for i7 in range(i6,m+1):
             for i8 in range(i7,m+1):
               for i9 in range(i8,m+1):
                 for i10 in range(i9,m+1):
                   tmp=0
                   arrs=[0,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10]
                   for a,b,c,d in arr: #条件を満たす数列について、最大値を求める
                     if arrs[b]-arrs[a]==c:
                       tmp+=d
                   ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 9152
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll A, B, C;
    cin >> A >> B >> C;
    ll ret = (A % 2) * B * C;
    ret = min(ret, (B % 2) * A * C);
    ret = min(ret, (C % 2) * A * B);
    
    output(ret, 0);
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long int gcd(long long int x,long long int y)
{
	if(x%y==0)
	  return y;
	else
       return  gcd(y,x%y);		
	
}
int main()
{
	long long int ans,a,b,t;
    while(cin>>a>>b)
	{
		
		ans=gcd(a,b);
		
		t=a*b/ans;
		cout<<ans<<' '<<t<<endl;
		
	}
	
	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Long h = sc.nextLong();
        int n = sc.nextInt();
        long[] arrA = new long[n];
        for(int i = 0; i < n; i++){
            arrA[i] = sc.nextLong();
        }
        long sum = Arrays.stream(arrA).sum();
        if(sum>=h){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
        
        
    }
}

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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007

signed main()
{
	init();
	solve();
}

int cost[100][100];
int minc[100][100];
#define INF 10000000
int N, M;

void init()
{
	rep(i, 100) rep(j, 100) cost[i][j] = INF;
	rep(i, 100) cost[i][i] = 0;
	rep(i, 100) rep(j, 100) minc[i][j] = INF;
	rep(i, 100) minc[i][i] = 0;
	cin >> N >> M;
	rep(i, M) {
		CIN(int, a);
		CIN(int, b);
		CIN(int, c);
		a--;b--;
		cost[a][b] = cost[b][a] = c;
		minc[a][b] = minc[b][a] = c;
	}
}



void solve()
{
	int res = 0;
	rep(k, N) rep(i, N) rep(j, N) {
		minc[i][j] = min(minc[i][j], minc[i][k] + minc[k][j]);
	}
	rep(i, N) {
		reps(j, i, N) {
			if (cost[i][j] != INF && cost[i][j] != minc[i][j]) res++;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include<algorithm>
#include <string>
#include <set>
#include <limits.h>
#include <map>
#include <queue>
#include <stack>

using namespace std;

#define rip(i,n,s) for (int i=(s);i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<long long, int> P;

void dijk(vector<vector<P> > &da, int s, vector<ll> &ans) {
	priority_queue<P,vector<P>,greater<P> > q;
	int x = da[s].size();
	rip(i, x, 0) {
		q.push(da[s][i]);
	}
	ans[s] = 0;
	while (!q.empty()) {
		P no = q.top();
		q.pop();
		//printf("%lld %d\n", no.first, no.second);
		if (ans[no.second] < 0) {
			x = no.second;
			ans[x] = no.first;
			int size = da[x].size();
			rip(i, size, 0) {
				P PA = make_pair(da[x][i].first + no.first, da[x][i].second);
				q.push(PA);
			}
		}
	}
}

int main() {
    int n;
    cin >> n;
    vector<vector<P> >  da(n,vector<P>(0));
    rip(i,n,0){
        int x;
        cin >> x;
        cin >> x;
        int v,c;
        rip(j,x,0){
            cin >> v >> c;
            da[i].push_back(make_pair(c,v));
        }
    }
    vector<ll> ans(n,-1);
    dijk(da,0,ans);
    rip(i,n,0){
        printf("%d %lld\n",i,ans[i]);
    }
}


Measured memory_bytes: 19944
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
    cin>>a>>b;
    if(a>0)cout<<"Positive";
    else if(a==0||(a<0&&b>0))cout<<"Zero";
    else if((abs(b)-abs(a))%2!=0)cout<<"Positive";
    else cout<<"Negative";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
static const int MAX_N = 100000;

int N, K, Q;
int A[MAX_N + 1];

int main() {
  scanf("%d%d%d", &N, &K, &Q);
  int x;
  for (int i = 0; i < Q; i++) {
    scanf("%d", &x);
    A[x - 1]++;
  }

  int score;
  for (int i = 0; i < N; i++) {
    score = K - (Q - A[i]);
    if (score > 0) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }
  
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <vector>

using namespace std;

int main()
{
    int n;  cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) cin >> s[i];
    int m;  cin >> m;
    vector<string> t(m);
    for (int i = 0; i < m; i++) cin >> t[i];

    int x = 0;
    for (int i = 0; i < n; i++){
        int cnt = 0;
        string u = s[i];
        for (auto v : s){
            if(u == v) cnt++;
        }
        for (auto v : t){
            if (u == v){
                cnt--;
            }
        }
        if (x < cnt) x = cnt;
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main() {
	vector<int> i;
	int a, b, c;
	string s = "No";
	cin >> a >> b >> c;
	if (c >= a && c <= b) {
		s = "Yes";
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

int main(){
  double a,b,c,d,e,f,x,y;

  while(cin>>a>>b>>c>>d>>e>>f){
    y=(a*f-c*d)/(a*e-b*d);
    x=(c-b*y)/a;
    cout<<fixed<<setprecision(3)<<x<<" "<<y<<endl;
  }

  return 0;
}



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

using namespace std;

bool f() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  int x = a - b;
  for (long i = 0; i < n; i++) {
    long ma = i * d - (n - i - 1) * c;
    long mi = i * c - (n - i - 1) * d;
    if (mi <= x && x <= ma) return true;
  }
  return false;
}

int main() {
  if (f()) cout << "YES" << endl;
  else cout << "NO" << endl;
}
    

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using llint = long long;
using vint = vector<int>;

int main () {
    int h, w, x, y; cin >> h >> w >> x >> y;
    cout << h * w - (x*w + y*h - x*y) << endl;
}

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

int main() {
	int n;
	cin >> n;
	int a[101][101] = {};
	for(int y = 1; y <= n; y++) {
		for(int x = 1; x <= n; x++) cin >> a[y][x];
	}
	for(int y = 1; y <= n; y++) {
		for(int x = 1; x <= n; x++) a[y][x] += a[y][x-1];
	}
	for(int x = 1; x <= n; x++) {
		for(int y = 1; y <= n; y++) a[y][x] += a[y-1][x];
	}
	int ans = -10000*10000 - 1;
	for(int y1 = 1; y1 <= n; y1++) {
		for(int x1 = 1; x1 <= n; x1++) {
			for(int y2 = y1; y2 <= n; y2++) {
				for(int x2 = x1; x2 <= n; x2++) {
					int sum = a[y2][x2] - a[y2][x1-1] - a[y1-1][x2] + a[y1-1][x1-1];
					ans = max(sum, ans);
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#define ll long long 
#define mp make_pair 
#define pb push_back 
#define F first 
#define S second 
#define f(i,n) for(int i=0;i<n;i++) 
#define fr(i,a,b) for(int i=a;i<b;i++) 

using namespace std;

int find(int arr[],int i){
	if(arr[i]!=i)
		arr[i]=find(arr,arr[i]);
	return arr[i];
}

void unionn(int a,int b,int arr[]){
	int pa=find(arr,a);
	int pb=find(arr,b);
	arr[pa]=pb;
	return ;
}

void test(){
	int n;
	cin>>n;
	int m ;
	cin>>m;
	int arr[n];
	for(int i=0;i<n;i++)arr[i]=i;
	f(i,m){
		int u,v;
		cin>>u>>v;
		u--,v--;
		unionn(u,v,arr);
	}
	
	set<int> st;
	
	int freq[n]={0};
	
	for(int i=0;i<n;i++)
		freq[find(arr,i)]++;
	
	int ans = 0;
	
	f(i,n)ans = max(ans,freq[i]);
	cout<<ans<<"\n";
	
}

int main(){
	int t=1;
//	cin>>t;
	while(t--){
		test();
	}
}

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

A = [0] * (n+1)

for i in range(1, 105):
    for j in range(1,105):
        for k in range(1,105):
            l = i**2+j**2+k**2+i*j+j*k+k*i
            if l <= n:
                A[l] += 1
for i in range(1, n+1):
    print(A[i])

Measured memory_bytes: 69544
#!/usr/bin/env python
# coding: utf-8

# In[2]:


import math


# In[13]:


N = int(input())


# In[15]:


ans = len(str(N))
x = int(math.sqrt(N)//1)
a = 1
while a < x+1:
    if N%a == 0:
        b = N//a
        ans = min(ans,max(len(str(a)),len(str(b))))
    a += 1
print(ans)


# In[ ]:






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

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

    int N = S.size();
    int ans = 0;
    int l = 0, r = N - 1;

    while(l < r){
        if(S[l] == S[r]){
            l++; r--;
        }else if(S[l] == 'x'){
            ans++;
            l++;
        }else if(S[r] == 'x'){
            ans++;
            r--;
        }else{
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void) {

	int n, i;
	int a[100];

	scanf("%d", &n);

	for (i = 0; i < n; i++) {

		scanf("%d", &a[i]);

		}	
	
	for (i = n-1; i >= 0;i--) {
	
		if (i > 0) {
			printf("%d ", a[i]);
		}
		else
			printf("%d", a[i]);
	}
	printf("\n");

	return(0);

}


Measured memory_bytes: 2036
using System;
using System.Linq;

namespace Sample
{
	class Program
	{
		static void Main(string[] args)
		{
			while (true)
			{
				var array = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
				var a = array[0];
				var b = array[1];
				if(a == 0 && b == 0)
				{
					break;
				}
				else
				{
					var x = Math.Min(a, b);
					var y = Math.Max(a, b);
					Console.WriteLine($"{x} {y}");
				}
			}
		}
	}
}



Measured memory_bytes: 14220
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main(){
        ios::sync_with_stdio(false);    
        cin.tie(0);
        int n, m;
        cin>>n>>m;
        int ans=0;
        int temp;
        int array[m];
        while(m--){
        	cin>>temp;
        	ans += temp;
		}
		if(ans>n){
			cout<<-1;
		}else{
			cout<<n-ans;
		}

        return 0;

}

Measured memory_bytes: 3652
/*input
BWWWWWWWWWW
*/

#include <bits/stdc++.h>

using namespace std;

const int N = 200004;

typedef long long LL;

char s[N];

int main() {
  ios_base::sync_with_stdio(false);

  cin >> s;

  int n = strlen(s), offset = -1;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'B') {
      continue;
    }
    ans += i - offset - 1;
    offset++;
  }
  cout << ans;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
#define endl "\n"
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}while(0)

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

vec eratosthenes(ll N){
  ll i;
  vec ch(N+1,1),p;
  ch[0]=ch[1]=0;
  rep(i,N+1){
    if(ch[i]){
      p.push_back(i);
      for(ll j=2;i*j<=N;j++){
        ch[i*j]=0;
      }
    }
  }
  return ch;
}



int main(){
  ll i,N,M,a,b,inf=1LL<<60;
  cin>>N>>M;
  vec d(N*3,inf);
  mat v(N*3);
  rep(i,M){
    cin>>a>>b;
    a--;b--;
    v[a].push_back(b+N);
    v[a+N].push_back(b+N*2);
    v[a+N*2].push_back(b);
  }
  cin>>a>>b;
  a--;b--;
  d[a]=0;
  priority_queue<datas,pvec,greater<datas>> que;
  for(auto i:v[a])que.push(datas(1,i));
  while(d[b]==inf&&!que.empty()){
    auto x=que.top();que.pop();
    if(d[x.second]!=inf)continue;
    d[x.second]=x.first;
    for(auto i:v[x.second]){
      if(d[i]!=inf)continue;
      que.push(datas(x.first+1,i));
    }
  }
  if(d[b]==inf){
    cout<<-1<<endl;
  }else{
    d[b]/=3;
    cout<<d[b]<<endl;
  }
  return 0;
}

Measured memory_bytes: 18944
#include<iostream>
#include<algorithm>
#include<vector>

int main(){

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

    std::string s;
    std::cin >> s;

    int k;
    std::cin >> k;

    std::vector<std::string> v;

    for(int i = 0 ;  i < s.size() ; ++i){
        for(int len = 1 ; len <= s.size() - i ; ++len){
            std::string news = s.substr(i , len);
            if(news.size() <= k) v.push_back(news);
        }
    }

    std::sort(v.begin() , v.end());
    v.erase(unique(v.begin() , v.end()) , v.end());

    std::cout << v[k - 1];

    return 0;

}

Measured memory_bytes: 1660
import sys
import socket

hostnames = ['N551J', 'F551C', 'X553M']
input_file = 'c1.in'
# if socket.gethostname() in hostnames:
#     sys.stdin = open(input_file)


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():

    cache = {}
    def f(x):
        if x in cache:
            return cache[x]

    n = read_int()
    a = read_int_list()
    s = [[] for i in range(n)]
    for i in range(n - 1):
        s[a[i] - 1].append(i + 1)
    res = [len(x) for x in s]
    res = '\n'.join(map(str, res))
    return res


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61664
//
//  main.cpp
//  agc001E BBQ Hard
//
//  Created by 黄道煜 on 2018/10/3.
//  Copyright © 2018年 黄道煜. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>
#define LL long long
#define p 1000000007
using namespace std;

int n, x, y, mp[5004][5005], tag[5005][5005];
LL ans, inv[8005], fac[8005];

void init()
{
    fac[1]=fac[0]=inv[1]=inv[0]=1;
    for(int i=2; i<=8000; i++)
    {
        fac[i]=(fac[i-1]*i)%p;
        inv[i]=(inv[p%i]*(p-p/i))%p;
    }
    for(int i=2; i<=8000; i++) inv[i]=(inv[i]*inv[i-1])%p;
}

LL comb(int n, int m)
{
    return fac[n]*inv[n-m]%p*inv[m]%p;
}

int main()
{
    init();
    scanf("%d", &n);
    for(int i=1; i<=n; i++)
    {
        scanf("%d%d", &x, &y);
        mp[x+2000][y+2000]++;
        tag[2000-x][2000-y]++;
        ans=(ans+p-comb(x+y+x+y, x+x))%p;
    }
    for(int i=4000; i>=0; i--)
        for(int j=4000; j>=0; j--)
        {
            mp[i][j]=(mp[i][j]+mp[i+1][j]+mp[i][j+1])%p;
            ans=(ans+1LL*tag[i][j]*mp[i][j])%p;
        }
    printf("%lld\n", ans*inv[2]%p);
}


Measured memory_bytes: 122368
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;

	vector<int> H(N);
	vector<int> ma(N);
	for (int i = 0; i < N; i++) {
		cin >> H.at(i);
		ma.at(i) = 0;
	}

	for (int i = 0; i < M; i++) {
		int A, B;
		cin >> A >> B;
		ma.at(A - 1) = max(ma.at(A - 1), H.at(B - 1));
		ma.at(B - 1) = max(ma.at(B - 1), H.at(A - 1));
	}

	int count = 0;
	for (int i = 0; i < N; i++) {
		if (H.at(i) > ma.at(i)) {
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>

using namespace std;

int main() {
	int n;
	cin >> n;
	int x[n];
	int xc[n];
	for(int i = 0; i < n; i++) {
		cin >> x[i];
		xc[i] = x[i];
	}

	sort(xc,xc+n);
	int p1 = xc[n / 2 - 1];
	int p2 = xc[n / 2];
	for(int i = 0; i < n; i++) {
		if(x[i] == p1) cout << p2 << endl;
		else if(x[i] == p2) cout << p1 << endl;
		else if(x[i] < p1) cout << p2 << endl;
		else cout << p1 << endl;
	}

	

	
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  ll h,w;
  char k;
  cin >>h>>w;
  vector <char> e[h];
  for(ll i=0;i<h;i++){
    for(ll j=0;j<w;j++){
      cin >>k;
      e[i].push_back(k);
    }
  }
  ll l[h][w],r[h][w],u[h][w],d[h][w],sum;
  for(ll i=0;i<h;i++){
    sum=0;
    for(ll j=0;j<w;j++){
      if(e[i][j]=='#') sum=0;
      else sum++;
      l[i][j]=sum;
    }
  }
  for(ll i=0;i<h;i++){
    sum=0;
    for(ll j=w-1;j>=0;j--){
      if(e[i][j]=='#') sum=0;
      else sum++;
      r[i][j]=sum;
    }
  }
  for(ll i=0;i<w;i++){
    sum=0;
    for(ll j=0;j<h;j++){
      if(e[j][i]=='#') sum=0;
      else sum++;
      u[j][i]=sum;
    }
  }
  for(ll i=0;i<w;i++){
    sum=0;
    for(ll j=h-1;j>=0;j--){
      if(e[j][i]=='#') sum=0;
      else sum++;
      d[j][i]=sum;
    }
  }
  ll ans=0;
  for(ll i=0;i<h;i++){
    for(ll j=0;j<w;j++){
      ans=max(ans,d[i][j]+u[i][j]+r[i][j]+l[i][j]-3);
    }
  }
  cout <<ans<<endl;
}


Measured memory_bytes: 129280
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONGINF 1000000000000000000
int main() {
	string s;
	cin >> s;
	long long a = 0;
	REP(i, s.length()) {
		if (s[i] == 'p') a--;
		else a++;
	}
	cout << a / 2 << endl;
	return 0;
}

Measured memory_bytes: 512
DBG = !true
P = 1000000007
n,m = gets.split.map{|x| x.to_i}
a = gets.split.map{|x| x.to_i}
b = gets.split.map{|x| x.to_i}
a.sort_by!{|x| -x}
b.sort_by!{|x| -x}
aon = Array.new(n*m, false)
bon = Array.new(n*m, false)
for x in a
  aon[x] = true
end
for x in b
  bon[x] = true
end

r = n
c = m
rs = 0
cs = 0
rcs = 0
x = 1

(n*m).downto(1) { |i|
  ron = aon[i] #a.include?(i)
  con = bon[i] #b.include?(i)
  if ron && con
    rcs += (n-r)+(m-c)   # r,c uses the old value
    r -= 1
    c -= 1
    rs += c-(n-r-1)  # NOTE c,r uses the new (updated) value
    cs += r-(m-c-1)    # no change for x
  elsif ron
    r -= 1
    rs += c
    x = (x * (m-c)) % P
    cs -= m-c  # c, rcs, stay
    rcs += m-c-1
  elsif con
    c -= 1
    cs += r
    x = (x * (n-r)) % P
    rs -= n-r  # c, rcs, stay
    rcs += n-r-1
  else
    x = (x * rcs) % P
    rcs -= 1
  end
  if DBG
    puts "i #{i} ron #{ron} con #{con} r #{r} c #{c} rs #{rs} cs #{cs} " +
         "rcs #{rcs} x #{x}"
  end
}
print x


Measured memory_bytes: 19448
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
 
int main() {
  int n,d;
  cin >> n >> d;
  int ans;
  
  if(n%(2*d+1)==0)
    ans = n/(2*d+1);
  else
    ans = n/(2*d+1) + 1;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int h[100005];
int ans[100005];
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	int pos=0;
	for(int i=0;i<n-1;i++){
		if(h[i]>=h[i+1]){
			ans[pos]++;
		}else{
			pos=i+1;
		}
	}
	int anss=0;
	for(int i=0;i<n;i++){
		anss=max(ans[i],anss);
	}
	cout<<anss;
	return 0;
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    if(s == "ABC"){
        cout << "ARC";
    }
    else
        cout << "ABC";
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define test(t) int t; cin>>t; while(t--)
#define p1(x) { cout << " [" << #x << ": " << x << "]\n"; }
#define p2(x) { cout << " [" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]\n"; }
#define pb push_back
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
 
 
void solve()
{
	int n, ans=0;
	string s;
	cin>>s;
	if(s=="RRR")	ans=3;
	else if(s=="SRR" or s=="RRS") ans=2;
	else if(s=="SSS") ans=0;
	else ans=1;
	cout<<ans<<endl;
}
 
int main() {
	// your code goes here
	// test(t)
		solve();
	return 0;
}
 

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

using namespace std;

bool isPrime(int n){

	for(int i=2;i<n;i++){
		if(n%i==0) return false;
	}

	return true;
}

int main(){


	int n;

	cin >> n;

	while(true){
		if(isPrime(n)){
			cout << n << endl;
			break;
		}
		n++;
	}




	return 0;
}

Measured memory_bytes: 256
n,c = map(int,input().split())

data = []

for i in range(n):
    s,t,h = map(int,input().split())
    data.append((s,t,h))

data.sort()

record = []

for s,t,h in data:
    flag = False
    for track in record:
        if track[0]<=s and track[1]==h:
            track[0]=t
            track[1]=h
            flag = True
            break
        elif track[0]<s and track[1]!=h:
            track[0]=t
            track[1]=h
            flag = True
            break
    if not flag:
        record.append([t,h])

print(len(record))
        


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

#define ll long long
#define pb push_back
#define fori(a,b) for(int i=a;i<b;i++)
#define ford(b,a) for(int i=b;i>=a;i--)
typedef pair<int, int> pi;
#define PI 3.14159265359
//long long mod=1000000007;
//int count=INT_MAX;

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};
int isPal(string a,string b){
    int n=a.size();
    fori(0,n){
        if(a[i]!=b[i]) return 0;
        
    }
    return 1;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    //cin>>t;
    //cout<<t;
    //scanf("%d",&t);
    while(t--){
        int n,k;
        cin>>n>>k;
        int p[n];
        fori(0,n){
            cin>>p[i];
        }
        sort(p,p+n);
        int sum=0;
        fori(0,k){
            sum+=p[i];
        }
        cout<<sum<<endl;

    }
    
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)


typedef long long int ll;
typedef double D;      // ??§?¨?????????????double???long double?????????

const int INF = (1<<30) - 1;
const D EPS = 1e-9;
const int MOD = 1000000007;

#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

int H, W;
ll L;

//h, w, dir
typedef tuple<int, int, int> State;

string directions = "NESW";
//NESW
int dh[] = {-1, 0, 1, 0};
int dw[] = {0, 1, 0, -1};

inline bool infield(int h, int w){
    return 0<=h&&h<H && 0<=w&&w<W;
}

void solve(){
    vector<string> field(H);
    for(int i=0; i<H; i++)
        cin >> field[i];
    
    int dir = -1;
    int h = -1, w = -1;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            int tdir = directions.find(field[i][j]);
            if(tdir != string::npos){
                dir = tdir;
                h = i; w = j;
                field[h][w] = '.';
            }
        }
    }
    
    map<State, ll> memo;
    
    while(L--){
        while(!(infield(h+dh[dir], w+dw[dir]) && field[h+dh[dir]][w+dw[dir]]=='.'))
            dir = (dir+1) % 4;
        
        if(memo.find(State(h, w, dir)) != memo.end()){
            ll d = memo[State(h, w, dir)];
            L %= (L - d);
        }
        memo[State(h, w, dir)] = L;
        
        h += dh[dir];
        w += dw[dir];
    }
    
    cout << h+1 << " " << w+1 << " " << directions[dir] << endl;
}

//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(16);
    //cout.setf(ios::fixed);
    
    while(cin>>H>>W>>L, H|W|L){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 1568
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;

const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long


double c;
int main() {
  //auto start_clock = clock();
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif
  cin >> c;
  printf("%.8f", c * c * c / 27);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main () {
  string s;
  cin >> s;
  int n = s.length();
  bool yes = true;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'L' && (i+1)%2 != 0) { //odd
      yes = false;
      break;
    }
    if (s[i] == 'R' && (i+1)%2 == 0) { //even
      yes = false;
      break;
    }
  }
  if (yes) {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

void raushan_kumar(){
	int n;cin>>n;
	int t[n];
	int sum=0;
	fo0(i,n){
		cin>>t[i];
		sum+=t[i];
	}
	int again=sum;
	int q;cin>>q;
	while(q--){
		int x,y;cin>>x>>y;
		sum=sum-t[x-1]+y;
		cout<<sum<<endl;
		sum=again;
	}
}

int32_t main()
{
	fast;int t=1;
	//cin>>t;
	while(t--){
		raushan_kumar();
	}

}

Measured memory_bytes: 256
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1)(r(2).readFileSync("/dev/stdin","UTF-8"))},function(e,t){e.exports=function(e){for(var t=e.split("\n"),r=Number(t[0]),n=t[1].split(" ").map(function(e){return Number(e)}),o=0,u=0,i=0;i<r;i++)n[i]-1==i?1==u?u=0:(o+=1,u=1):u=0;console.log(o)}},function(e,t){e.exports=require("fs")}]);

Measured memory_bytes: 16716
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;

void main(){
    while(true){
	auto s = readln();
	if(stdin.eof()) break;
	auto s1 = split(s);
	real[] inp;
	for(int i=0;i<s1.length;i++){
	    inp ~= to!real(s1[i]);
	}
	if(inp[0]<=inp[6]&&inp[1]<=inp[7]&&inp[4]<=inp[2]&&inp[5]<=inp[3]) writeln("YES");
	else writeln("NO");
    }
}

Measured memory_bytes: 2468