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


using namespace std;

long long int D = 1000000007;

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++) cin >> a[i];
  
  bool coh = true;
  long long int ans = 1LL;
  
  for(int i = 0; i < N; i++){
    if(a[i] < 0 || a[i] > N-1){
      coh = false;
      break;
    }
  }
  map<int, int> m;
  for(int i = 0; i < N; i++) m[a[i]]++;
  if(N % 2 == 0){
    for(auto iter = m.begin(); iter != m.end(); iter++){
      if(iter->second != 2) coh = false;
      ans = (ans * 2) % D;
    }
  }else{
    for(auto iter = m.begin(); iter != m.end(); iter++){
      if(iter->second != 2){
        if(iter->first == 0 && iter->second == 1){
          ans = (ans * 1LL) % D;
        }else{
          coh = false;
        }
      }else{
        ans = (ans * 2) % D;
      }
    }
  }
  if(coh) cout << ans;
  else cout << 0;
}


Measured memory_bytes: 3584
#include <stdio.h>
#include <string.h>
 
int main(){
 
    char s[222222];
 
    scanf("%s",s);
 
    int a=strlen(s),start=0,finish=0;
    for(int i=0;i<a;i++){
      if(s[i]=='A'){
        start=i;
        break;
      }
    }
 
    for(int i=start;i<a;i++){
      if(s[i]=='Z'){
        finish=i;
      }
    }
 
    printf("%d\n",finish-start+1);
 
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
int main() {
    long n, k;
    cin >> n >> k;
    long sum = 0;
    vector<long> a(n);
    long l = 0, r = 0;
    for (long i = 0 ;i < n; i++) {
        cin >> a[i];
        if (a[i] > r) {
            r = a[i];
        }
    }
    while (l < r - 1) {
        long m = (l + r) >> 1;
        long x = k;
        for (auto b: a) {
            x -= (b + m - 1) / m - 1;
        }
        if (x < 0) {
            l = m;
        } else {
            r = m;
        }
    }
    cout << r << endl;
}



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

int N;
const int MAX_N = 1.0e5 + 100;
ll A[MAX_N], B[MAX_N], AB[MAX_N];

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

    sort(AB, AB+N, greater<>());
    
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans -= B[i];
        if (i % 2 == 0) ans += AB[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
ll len[18];
int main() {
	for (ll i = 1, k = 1; i < 18; i++, k *= 10) {
		len[i] = len[i - 1] + k * 9 * i - k * 9 / 3 * (i - 4)-k*9/5*(i-4)+k*9/15*i;
		if (i == 1)len[i] += 4;
	}
	ll s;
	cin >> s;
	int n = lower_bound(len, len + 18, s) - len - 1;
	ll a = (s - len[n]-1) / ((n + 1) * 8 + 4 * 8);
	int o = (s - len[n]-1) % ((n + 1) * 8 + 4 * 8);
	ll k = 1;
	for (int i = 1; i <= n;i++)k*=10;
	if (n != 0)k++;
	string buf;
	for (ll i = k+a*15; i < k+a*15+30; i++) {
		if (i % 3 == 0) {
			buf += "Fizz";
			if (i % 5 == 0) {
				buf += "Buzz";
			}
		}
		else if (i % 5 == 0) {
			buf += "Buzz";
		}
		else {
			buf += to_string(i);
		}
	}
	string res(buf.begin() + o, buf.begin() + o + 20);
	cout << res << endl;
	return 0;
}

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

using namespace std;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int r, g, b;
	int ans;
	cin >> r >> g >> b;

	ans = r * 100 + g * 10 + b;
	if (ans % 4 == 0) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>
#define MOD 1000000007
using namespace std;

int main() {
    int N,i,j,cnt=0;
    long long X[1000], Y[1000];
    cin>>N;
    for(i=0;i<N;i++){
        cin>>X[i]>>Y[i];
        if(abs(X[0]+Y[0])%2!=abs(X[i]+Y[i])%2){
            cout<<-1;
            return 0;
        }
    }
    long long d[40];
    for(i=32;i>=0;--i){
        d[cnt++]=(1ll<<i);
    }
    if((X[0]+Y[0])%2==0)d[cnt++]=1;

    cout<<cnt<<endl;
    for(i=0;i<cnt;i++){
        cout<<d[i]<<" ";
    }
    cout<<endl;

    for(i=0;i<N;i++){
        string s;
        for(j=0;j<cnt;j++){
            if(abs(X[i])>=abs(Y[i])){
                if(X[i]<=0){
                    X[i]+=d[j];
                    s+='L';
                }else{
                    X[i]-=d[j];
                    s+='R';
                }
            }else{
                if(Y[i]<=0){
                    Y[i]+=d[j];
                    s+='D';
                }else{
                    Y[i]-=d[j];
                    s+='U';
                }
            }
        }
        cout<<s<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
  int n;
  string s;
  cin >> n >> s;
  
  int c = 1;
  for(int i = 1; i < n; i++){
    if(s[i-1] != s[i]){
      c++;
    }
  }
 cout << c;


  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int N, M, Q;
vec<int> a, b, c, d;
int ans = 0;

void dfs(vec<int> A) {
    if (A.size() == N) {
        int tmpans = 0;
        rep(i, Q) {
            if (A[b[i]] - A[a[i]] == c[i]) tmpans += d[i];
        }
        ans = max(ans, tmpans);
        return ;
    }
    for(int i=A.back();i<=M;++i){
        A.push_back(i);
        dfs(A);
        A.pop_back();
    }

}

int main() {
    cin >> N >> M >> Q;
    a.resize(Q);
    b.resize(Q);
    c.resize(Q);
    d.resize(Q);
    rep(i, Q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i],--b[i];
    }
    dfs(vec<int>(1, 1));
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <iostream>

int main(void) {
	using namespace std;
	int x[3];
	cin >> x[0] >> x[1] >> x[2];
	int a = 0;
	
	
	for (int i = 0; i < 2; i++) {
		for (int j = 1; j < 3; j++) {
			if (x[i] > x[j]) {
				a = x[i];
				x[i] = x[j];
				x[j] = a;
			}
		}
	}
	cout << x[0] << ' ' << x[1] << ' ' << x[2] << endl;
	return 0;
}

Measured memory_bytes: 3092
#include<stdio.h>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=200100,P=1e9+7;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar( ));
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
int n,a[N],ans;
int inv(int x){
	int y=P-2,z=1;
	for(;y;y>>=1,x=1ll*x*x%P)
	if(y&1)z=1ll*z*x%P;return z;
}
int main(){
	int i,l,r,k;
	n=read();k=0;
	for(i=1;i<=n;i++)a[i]=read(),(k+=inv(i))%=P;
	l=2;r=n;
	for(i=1;i<=n;i++){
		(ans+=1ll*k*a[i]%P)%=P;
		(k+=P-inv(r))%=P;r--;
		(k+=inv(l))%=P;l++;
	}
	for(i=1;i<=n;i++)ans=1ll*i*ans%P;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<stdio.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1e9

int main()
{
	string n;
	cin >> n;
	int count = 0;
	rep(i, n.length()) {
		if (n[i] == '2') {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
da1=list(map(int, input().split()))
da2=list(map(int, input().split()))
su1=[0 for i in range(n)]
su2=[0 for i in range(n)]
for i in range(n):
  if i==0:
    su1[i]=da1[i]
    su2[n-1]=da2[n-1]
  else:
    su1[i]=da1[i]+su1[i-1]
    x=n-i-1
    su2[x]=da2[x]+su2[x+1]
ans=0
for i in range(n):
  ans=max(ans,su1[i]+su2[i])
print(ans)

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

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const int MAXN=10010;

int d[MAXN],n,c[MAXN],val[MAXN],vis[MAXN];
vector<int> T[MAXN];
ll Ans;

struct cmp{
	bool operator () (int a,int b){return d[a]<d[b];}
};

priority_queue<int,vector<int>,cmp> pq;

int main()
{
	scanf("%d",&n);
	for(int i=1,u,v;i<n;i++)
		scanf("%d%d",&u,&v),
		d[u]++,d[v]++,T[u].push_back(v),T[v].push_back(u);
	for(int i=1;i<=n;i++)
		scanf("%d",&c[i]);
	sort(c+1,c+1+n,greater<int>());
	int tot=0,rt=0;
	for(int i=1;i<=n;i++)
		if(d[rt]<d[i])
			rt=i;
	pq.push(rt);vis[rt]=1;val[rt]=c[++tot];
	while(!pq.empty())
	{
		int x=pq.top();pq.pop();
		for(int v:T[x])
			if(!vis[v])
			{
				vis[v]=1;
				val[v]=c[++tot];
				Ans+=val[v];
				pq.push(v);
			}
	}
	printf("%lld\n",Ans);
	for(int i=1;i<=n;i++)
		printf("%d%c",val[i],"\n "[i!=n]);
}


Measured memory_bytes: 1152
def main():
    n = int(input())
    n_b = 4
    n_f = 3
    n_r = 10

    from collections import defaultdict
    state = defaultdict(int)

    for _ in range(n):
        # b?£?f??????r???????????¨?±?
        # v??????????????§??\?±????????????¨???????????????
        # v?????????????????´??????v????????????????????¨??????????????????
        b, f, r, v = map(int, input().split())
        state[(b, f, r)] += v

    for b in range(1, n_b + 1):
        for f in range(1, n_f + 1):
            room_state = []
            for r in range(1, n_r + 1):
                room_state.append(state[(b, f, r)])
            print(" " + " ".join(map(str, room_state)))
        if b != n_b:
            print("#" * 20)


if __name__ == "__main__":
    main()

Measured memory_bytes: 6000
program answer
  implicit none

  integer :: A, B, C, i, d
  read(*,*) A, B, C

  do i = 1, 100
     d=A*i
     if(mod(d,B)==C) then
        write(*,*) 'YES'
        stop
     end if
  end do

  write(*,*) 'NO'
  stop
 end program answer

Measured memory_bytes: 2848
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int si=s.size();
  si=si-2;
  for(int i=si;i>0;i-=2){
    string cp;
    rep(j,i/2){
      cp+=s[j];
    }
    bool flg=true;
    int count=0;
    rep(j,i){
      if(count==i/2){
        count=0;
      }
      if(s[j]!=cp[count]){
        flg=false;
      }
      count++;
    }
    if(flg){
      cout<<i<<'\n';
      break;
    }
  }
  return(0);
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>

#define pii pair <int, int>
#define pb push_back
#define ll long long
#define ss second
#define ff first
#define N 100010

using namespace std;

ll n, m;

int main()
{
	cin >> n >> m;
	
	if(n == 1 && m != 1) {
		cout << m-2;
		return 0;
	}
	if(n != 1 && m == 1) {
		cout << n-2;
		return 0;
	}
	if(n == 1 && m == 1) {
		cout << 1;
		return 0;
	}
	
	cout << n*1LL*m-m*2LL-2LL*n+4;
}

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

int N;
vector<int> x;
vector<int> y;
int order[8 * 7 * 6 * 5 * 4 * 3 * 2 * 1];

double CalcLength(void)
{
	double sum_length = 0.0;
	for (int i = 0; i < N - 1; ++i){
		double dx = x[order[i]] - x[order[i + 1]];
		double dy = y[order[i]] - y[order[i + 1]];
		double length = sqrt(dx * dx + dy * dy);
		sum_length += length;
	}
	return sum_length;
}

int main()
{
	cin >> N;
	for (int i = 0; i < N; ++i){
		int tmp_x, tmp_y;
		cin >> tmp_x >> tmp_y;
		x.push_back(tmp_x);
		y.push_back(tmp_y);
	}

	vector<int> vc(N);
	for (int i = 0; i < N; ++i) vc[i] = i;
	double sum_length = 0;
	int num = 0;
	do {
		int i = 0;
		for (auto pt:vc){order[i] = pt; ++i;}
		++num;
		sum_length += CalcLength();
	} while (next_permutation(vc.begin(), vc.end()));

	printf("%.7f\n", sum_length / (double)num);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
ll N;
int main(){
    cin>>N;
    VL X(N+1);
    rep(i,1,N+1){
        cin>>X[i];
    }
    ll sum=1000000000000;//最小値の時はINT_MAXとかで大きい値設定しとく
    ll now=0;
    rep(i,1,101){
        now=0;
        rep(j,1,N+1){
            now += pow(fabs(X[j]-i),2);
        }
        sum=min(now,sum);
    }
    cout<<sum;
    return 0;
}

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

using namespace std;

#define int_ int64_t
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

ll a,b,c,x,y;

int main()
{
    scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&x,&y);
    ll ans=1e18;
    ll mx=max(x,y);
    for (ll i=0;i<=2*mx;i++) {
        ll A=max(0ll,x-i/2);
        ll B=max(0ll,y-i/2);
        ll tmp=i*c+A*a+B*b;
        ans=min(ans,tmp);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        String s = sc.next();

        if (s.equals("AAA") || s.equals("BBB")){
            System.out.print("No");
        }else {
            System.out.print("Yes");
        }

    }
}



Measured memory_bytes: 25044
n = int(input())
A = tuple(map(int,input().split()))
q = int(input())
Q = tuple(map(int, input().split()))
dp = [0]*(2**n)

for i in range(n):
    for j in range(1<<i):
        dp[j+(1<<i)] = dp[j] + A[i]

s = set(dp)
for n in Q:
    print("yes" if set([n]) & s else "no")

Measured memory_bytes: 45024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int>x;
  for(int i=0;i<n;i++)
  {
    int temp;
    cin>>temp;
    x.push_back(temp);
  }
  int res=999999;
  for(int i=2;i<n;i++)
  {
    int a=0,b=0;
    for(int j=0;j<x.size();j++)
    {
      if(j+1<=i)a+=x[j];
      else b+=x[j];
    }
    res=min(res,abs(a-b));
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int n = sc.nextInt();
   int[] p = new int[n];
   for(int i = 0; i<n ; i++){
   p[i] = sc.nextInt();
   }
   int ans = 0;
   for(int k = 0;k<n-2 ; k++){
     if(p[k]>p[k+1] && p[k+2]>p[k+1]) continue;
     else if(p[k]<p[k+1] && p[k+2]<p[k+1]) continue;
     else ans++;
   }
  System.out.println(ans);
 
 }
}

Measured memory_bytes: 21844
n, k = map(int, input().split())

import math
def combinations_count(n, r):
    if n >= r:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    else:
        return 0

for i in range(1, k+1):
    if i == 1:
        print(n - k + 1)
    else:
        print((combinations_count(k-1, i-1) * (combinations_count(n - k - 1, i - 2) + combinations_count(n - k - 1, i - 1) * 2 + combinations_count(n - k - 1, i))) % (10 ** 9 + 7))


Measured memory_bytes: 3316
#include <stdio.h>

int main(void) {
	char c[3][4];
	int i;
	
	for (i = 0; i < 3; i++)
		scanf("%s", &c[i][0]);
	
	for (i = 0; i < 3; i++)
		printf("%c", c[i][i]);
	
	return 0;
}

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

int gcd(int x,int y){
	if(y==0)return x;
	return gcd(y,x%y);
}

int s(int p,int q,int r,int b){
	int x=p*r,y=q*b;
	int g=gcd(x,y);
	return x/g*y/p+x/g*y/q;
}

int main(){
while(1){
	int n,p[102],q[102],r[102],b[102],ret[102];
	bool top[102],flag[102];
	scanf("%d",&n);
	if(n==0)break;
	for(int i=0;i<102;i++){top[i]=true; flag[i]=true;}
	ret[0]=1;
	for(int i=1;i<=n;i++){
		scanf("%d%d%d%d",&p[i],&q[i],&r[i],&b[i]);
		top[r[i]]=false;
		top[b[i]]=false;
		ret[i]=-1;
	}
	bool updata=true;
	while(updata){
		updata=false;
		for(int i=1;i<=n;i++){
			if(flag[i]&&ret[r[i]]!=-1&&ret[b[i]]!=-1){
				ret[i]=s(p[i],q[i],ret[r[i]],ret[b[i]]);
				updata=true;
				flag[i]=false;
			}
		}
	}
	for(int i=1;i<=n;i++){
		if(top[i])printf("%d\n",ret[i]);
	}
}
}

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

namespace ABC104A
{
	class Program
	{
		static void Main(string[] args)
		{
			int input;
			string calssify;
			input = int.Parse(Console.ReadLine());
			calssify = (1200 > input && input >= 0) ? "ABC" : (2800 > input && input >= 1200) ? "ARC" :  "AGC";
			Console.WriteLine(calssify);
		}
	}
}

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


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#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 MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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




int cnt[100003];

int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("input.txt","w",stdout);

    int i,n,k,q,x;
    cin >> n >> k >> q;
    for(i=0; i<q; i++)
    {
        cin >> x;
        cnt[x]++;
    }
    int ans=0;
    for(i=1; i<=n; i++)
    {
        cnt[i]=cnt[i]+k-q;
        if(cnt[i] > 0)
        {
            ans++;
        }
    }
    for(i=1; i<=n; i++)
    {
        if(cnt[i] > 0)
        {
            cout << "Yes\n";
        }
        else
        {
            cout << "No\n";
        }
    }
    return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n;

signed main() {
    cin >> n;
    cout << (n-1)/2 << endl;
}


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

long long curA, curT, A, T;
int n;

int main() {
    scanf("%d", &n);
    scanf("%lld%lld", &curT, &curA);
    for(int i = 1; i < n; i++) {
        scanf("%lld%lld", &T, &A);
        if(T < curT || A < curA) {

            long long r = max((curT - 1) / T, (curA - 1) / A) + 1;
            curT = T * r;
            curA = A * r;

        } else {
            curT = T; curA = A;
        }
        //printf("--->%lld %lld\n", curT, curA);
    }
    printf("%lld\n", curT + curA);
    return 0;
}


Measured memory_bytes: 256
#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 <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
const long double eps = 1e-12;
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*2
#define REP(a,b) for(long long a = 0;a < b;++a)
long long cnt[300000] = {};
long long dp[300000];
long long memo[300000];
int main(){
	iostream::sync_with_stdio(false);
	cin.tie(0);
#define int long long
	int n, m;
	cin >> n >> m;
	REP(i, n) {
		int a;
		cin >> a;
		memo[i] = a;
		cnt[a]++;
	}
	for (int i = 1; i <= 200000; ++i) {
		dp[i]--;
		dp[max(0LL, i - cnt[i])]++;
	}
	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		if (i != 0) {
			dp[i] += dp[i - 1];
		}
		if (dp[i] == 0) {
			ans++;
		}
	}
	for (int i = 0; i < m; ++i) {
		int x, y;
		cin >> x >> y;
		x--;
		int geko = memo[x] - cnt[memo[x]];
		if (geko >= 0) {
			dp[geko]--;
			if (dp[geko] == 0) ans++;
		}
		cnt[memo[x]]--;
		memo[x] = y;
		int next = memo[x] - cnt[memo[x]] - 1;
		if (next >= 0) {
			dp[next]++;
			if (dp[next] == 1) ans--;
		}
		cnt[y]++;
		cout << ans << endl;
	}
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define N 200003
#define LL long long
#define mod 998244353

int K,X;


inline int read(){
	int X=0,w=0;
	char ch=0;
	while (ch<'0' || ch>'9')
	  w|=ch=='-',ch=getchar();
	while (ch>='0' && ch<='9')
	  X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
	return w ? -X : X;
}

int main(){
	K=read();X=read();
	for (int i=max(-1000000,X-K+1);i<=min(1000000,X+K-1);i++)
	  printf("%d ",i);
	return 0;
}

Measured memory_bytes: 256
using System;
class Prpgram
{
    static void Main(string[] args)
    {
        string input = Console.ReadLine();
        string[] inputlist = input.Split(' ');

        string X = inputlist[0];
        string Y = inputlist[1];
        string Z = inputlist[2];

        Console.Write(Z + " " + X + " " + Y);
    }
}

Measured memory_bytes: 25776
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin>>n>>s;
  s+=s.at(0);
  vector<string> m={"SS","SW","WS","WW"};
  for(int x=0;x<4;x++)
    for(int i=2;i<=n+1;i++)
      m.at(x)+=((m.at(x).at(i-2)=='S')^(m.at(x).at(i-1)=='S')^(s.at(i-1)=='o')?'S':'W');
  for(int x=0;x<4;x++){
    if(m.at(x).at(0)==m.at(x).at(n)&&m.at(x).at(1)==m.at(x).at(n+1)){
      cout<<m.at(x).substr(0,n)<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
 
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{
	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);

	ll h,n;
	cin>>h>>n;
	ll a[n];
	ll sum=0;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		sum+=a[i];
	}
	if(h-sum>0){
		cout<<"No";
	}
	else{
		cout<<"Yes";
	}

	return 0;
}

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

int main(){
    uint_fast32_t N, K;
    scanf("%u%u", &N, &K);

    vector<uint_fast64_t> ans(N, numeric_limits<uint_fast64_t>::max());
    ans[0] = 0;

    {
        vector<int_fast32_t> h(K + 1);
        scanf("%d", &h[K - 1]);

        for(auto i = 1; i < N; ++i){
            scanf("%d", &*h.rbegin());

            for(auto j = min<uint_fast32_t>(i, K); j > 0; --j){
                ans[i] = min(ans[i], abs(*(h.rbegin() + j) - *h.rbegin()) + ans[i - j]);
            }

            rotate(h.begin(), h.begin() + 1, h.end());
        }
    }

    printf("%llu\n", *ans.rbegin());

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f3f3f3f3f
#define mod 1000000007
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'

using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
int a[maxn];
int main()
{
	ll x, k;cin >> x >> k;
	printf("%lld", min(x % k, abs(x % k - k)));
}



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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI acos(-1.0)
#define sq(n) (n)*(n)

using namespace std;
typedef long long ll;

int main() {
    FAST;

   ll n,x,y,c=0,d=0;
   cin>>n;
   for(ll i=0;i<n;i++)
   {
       cin>>x>>y;
       if(x==y)
       {
           c++;
           if(c==3)
           {
               d=1;
           }
       }
       else
       {
           c=0;
       }


   }
   //cout<<c<<" "<<d<<endl;
   if(d==1)
   {
       cout<<"Yes"<<endl;
   }
   else
   {
       cout<<"No"<<endl;
   }

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,q;
int a[125252];
int x[125252];
ll sum[125252];
ll esum[125252];

int main(){
  scanf("%d%d",&n,&q);
  REP(i,n)scanf("%d",a+i);
  REP(i,q)scanf("%d",x+i);
  REP(i,n)sum[i+1] = sum[i] + a[i];
  REP(i,n)esum[i+1] = esum[i] + (i%2==0 ? a[i] : 0);
  REP(_,q){
    int X = x[_];
    int low = -1, high = 1000000025;
    int ml=n, mr=n;
    while(low+1<high){
      int d = (low+high)/2;
      int l = lower_bound(a,a+n,X-d)-a;
      int r = upper_bound(a,a+n,X+d)-a;
      // printf("X:%d, d:%d, l:%d, r:%d\n",X,d,l,r);
      int sz = r-l;
      if(sz>=2 && X-a[l] == a[r-1]-X){
        // same
        r--; sz--;
        if(n-sz < r){
          high = d;
        }else{
          if(n-sz-1 < r+1){
            // puts("1");
            low = d;
            ml = l;
            mr = r;
          }else{
            // puts("2");
            low = d;
            ml = l;
            mr = r+1;
          }
        }
      }else{
        if(n-sz < r){
          high = d;
        }else{
            // puts("3");
          low = d;
          ml = l; mr = r;
        }
      }
    }
    int sz = mr-ml;
    int zl = n-sz, zr = n;
    // DEBUG(X);
    // DEBUG(ml); DEBUG(mr); DEBUG(zl); DEBUG(zr);
    ll ans = sum[mr] - sum[ml];
    if(zl == mr){
      ans += (ml%2==0 ? esum[ml] : (sum[ml]-esum[ml]));
    }else{
      ans += (ml%2==1 ? esum[ml] : (sum[ml]-esum[ml]));
    }
    printf("%lld\n",sum[n] - ans);
  }
  return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
int m[4][3][10];
int main() {
    int n;
    cin >> n;
    while (n--) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--; c--;
        m[a][b][c] += d;
    }
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) {
                cout << " " << m[i][j][k];
            }
            cout << endl;
        }
        if (i < 3) cout << "####################" << endl;
    }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

int main()
{
  ll k;
  cin >> k;
  string s;
  cin >> s;
  int n = s.size();
  if (n <= k) {
    cout << s << endl;
  } else {
    cout << s.substr(0, k) << "..." << endl;
  }

  return 0;
}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  ll n, m, d;
  cin >> n >> m >> d;
  double ans = 0;
  if (d == 0) {
    ans = (1.0 / n) * (m - 1);
  } else {
    ans = ((2.0 * (n - d)) / (n * n)) * (m - 1);
  }
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1e9+7;

void solve()
{
	ll k,s,ans=0;
	cin>>k>>s;
	for(ll i=0;i<=k;i++)
		for(ll j=0;j<=k;j++)
    		if(0<=s-i-j and s-i-j<=k)
    			ans++;
     
	cout<<ans;
	return;
}
int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}

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

	int main() {
      int N, A;
      cin >> N >> A;
      
      if (N % 500 - A <= 0){
        cout << "Yes" << endl;
      }
      else {
        cout << "No" << endl;
      }
    }
      
      
      


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

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n;
    cin >> n;
    unordered_set<string> us;
    for(int i = 0; i < n;i++){
        string s;
        cin >> s;
        us.insert(s);
    }
    cout << us.size();
}









Measured memory_bytes: 17664
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<list>
#include<queue>
#include<string.h>
#include<functional>
#include<stack>
#include<deque>
#include<string>
#include<limits.h>
#include<map>
#include<set>
#include<unordered_map>
#include<cmath>
#include<unordered_set>
using namespace std;

signed main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	cout << max(0, min(d, b) - max(a, c)) << endl;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=998244353 ;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//17:00~

int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	
	int i,n;cin>>n;
	vector<int>a(n);
	for(i=0;i<n;i++){cin>>a[i];}
	set<llint>s;
	for(int bi=1;bi<(1<<n);bi++){
		llint g=1;
		for(i=0;i<n;i++){
			if(bi&(1<<i)){g=lcm(g,a[i]);}
		}
		s.ins(g);
	}
	cout<<s.size()<<endl;
	return 0;
}



Measured memory_bytes: 4196
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

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

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

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	edge(int _t) : t(_t) {}
};
bool use[100010];


vector<edge> te[100010];
vector<edge> fe[100010];
int t[64];
int d[100100];
int n;
ll rec(int num) {
	if (num == 0) return 0;
	return rec(num - 1) + num;
}
int a[5];

void Solve() {

	for (size_t i = 0; i < 3; i++)
	{
		int f, t;
		cin >> f >> t;

		a[f]++;
		a[t]++;
		if (a[f] > 2 || a[t] > 2) {
			cout << "NO" << endl;
			return;
		}
	}

	cout << "YES" << endl;

}


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



Measured memory_bytes: 6016
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

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

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> prefix(n + 2, 0);
	while(q--)
	{
		int a;
		cin >> a;
		--prefix[0];
		++prefix[a];
		--prefix[a + 1];
	}
	for(int i = 1; i <= n; ++i)
	{
		prefix[i] += prefix[i - 1];
		cout << (prefix[i] > -k ? "Yes" : "No") << '\n';
	}
}

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

using namespace std;

using ll = long long;
#define long long long

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

    ll s = 0, m = 1e9;
    for(ll i=0; i<n; i++) {
        ll x = l + i;
        if(abs(m) > abs(x)) m = x;
        s += x;
    }
    cout << s - m << endl;
}


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

// [0, MaxNumPlusOne - 1 ] の範囲の整数が素数であるかどうかを表す配列を返す関数
// 配列の要素が 1であれば素数
// 配列の要素が-1であれば素数でない
vector<int> Eratosthenes(int MaxNumPlusOne) {
	vector<int> isPrimeArray(MaxNumPlusOne, 1);
	int MaxNum = MaxNumPlusOne - 1;
	isPrimeArray[0] = -1;
	isPrimeArray[1] = -1;
	for (int i = 2; i <= sqrt(MaxNum); i++) {
		if (isPrimeArray[i] == 1) {
			for (int j = 2; j <= MaxNum; j++) {
				if (i * j > MaxNum) break;
				isPrimeArray[i * j] = -1;
			}
		}
	}
	return isPrimeArray;
}

int main() {

	int q; cin >> q;
	const int p = 1000001;
	vector<int> isPrimeNumber = Eratosthenes(p); // [0, p - 1] の範囲を調べる場合
	while (true) {
		if (isPrimeNumber[q] == 1) {
			break;
		}
		q++;
	}
	cout << q << endl;
    return 0;
}

Measured memory_bytes: 7180
s = list(input())
head = int(s[0] + s[1])
tail = int(s[2] + s[3])
 
if (0 < head < 13) and (0 < tail < 13):
    print('AMBIGUOUS')
elif 0 < tail < 13:
    print('YYMM')
elif 0 < head < 13:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int N, H;
vector<int> a, b;

int main () {
  cin >> N >> H;
  a.resize(N), b.resize(N);
  rep(i,N)cin >> a[i] >> b[i];

  sort(all(a));
  sort(all(b));

  int ans = 0;
  int i = N - 1;
  while(H > 0 && b[i] > a[N-1] && i >= 0) {
    H -= b[i];
    ans++;
    i--;
  }

  while(H > 0) {
    H -= a[N-1];
    ans++;
  }

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

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

    vector<ll> A(M);
    rep(i, 0, M){
        cin >> A[i];
    }

    ll ans1 = 0, ans2 = 0;
    rep(i, 0, M){
        if(A[i] < X) ans1 += 1;
        else ans2++;
    }
    cout << min(ans1, ans2) << endl;
    return 0;
}

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

int main()
{
  int h, w;
  cin >> h >> w;
  string a[h];

  for (int i = 0; i < h; i++) cin >> a[i];

  for (int i = 0; i < w + 2; i++) cout << '#';
  cout << endl;

  for (int i = 0; i < h; i++) {
    cout << '#';
    for (int j = 0; j < w; j++) cout << a[i][j];
    cout << '#' << endl;
  }

  for (int i = 0; i < w + 2; i++) cout << '#';
  cout << endl;
}



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

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

    vector<string>s(n);
    for (int i=0;i<n;i++) {
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
    }

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

    long long cnt=1,answer=0;

    for (int i=0;i<n-1;i++) {
        if(s[i]==s[i+1]){
            cnt++;
        }
        else if(cnt>=2){
            answer+=(cnt*(cnt-1))/2;
            cnt=1;
        }
    }
    answer+=(cnt*(cnt-1))/2;

    cout<<answer<<endl;
}


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

int main(){
	int H, W, Q;
	cin >> H >> W;
	Q = H * W;
	vector<char> Ass(Q);
	
	for(int i = 0;i<Q;i++){
		cin >> Ass.at(i);
	}
	
	for(int j = 0;j<W+2;j++){
		cout << "#";
	}
	cout << endl;
	
	for(int k = 0;k<H;k++){
		cout << "#";
		for(int l = 0;l<W;l++){
			int co = k*W + l;
			cout << Ass.at(co);
		}
		cout << "#" << endl;
	}
	
	for(int m =0;m<W+2;m++){
		cout << "#";
	}
	cout << endl;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

import           Control.Monad.State.Strict
import qualified Data.ByteString.Char8      as B
import qualified Data.ByteString.Unsafe     as B
import           Data.Char
import           Data.Tuple
import qualified Data.Vector                as V
import qualified Data.Vector.Unboxed        as U

main :: IO ()
main = do
    [n, k] <- map read.words <$> getLine :: IO [Int]
    edges <- U.map(\(x,y)->(x-1,y-1)).U.unfoldrN n parseInt2 <$> B.getContents
    print $ solve n k edges

type Vertex = Int
type Edge = (Vertex, Vertex)
type Graph = V.Vector (U.Vector Vertex)

toUndirectedEdges :: U.Vector Edge -> U.Vector Edge
toUndirectedEdges edges = edges U.++ U.map swap edges

fromEdges :: Int -> U.Vector Edge -> Graph
fromEdges numV edges = V.map U.fromList
    . V.unsafeAccumulate (flip (:)) (V.replicate numV [])
    $ U.convert edges

nothing :: Int
nothing = -1

solve :: Int -> Int -> U.Vector (Int, Int) -> Int
solve n k edges
    | even k = n - U.maximum (U.generate n (dfs (div k 2) nothing))
    | otherwise = n - U.maximum (U.map (\(v, u)->dfs (div (k-1) 2) v u + dfs (div (k-1) 2) u v) edges)
  where
    !gr = fromEdges n $ toUndirectedEdges edges
    dfs d prev v
        | d < 0 = 0
        | otherwise = U.foldr' ((+).dfs (d-1) v) 1
            . U.filter (/=prev)
            $ V.unsafeIndex gr v

-------------------------------------------------------------------------------

type Parser a = B.ByteString -> Maybe (a, B.ByteString)

parseInt :: Parser Int
parseInt = B.readInt . B.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = runStateT $
    (,) <$> StateT (B.readInt . B.dropWhile isSpace)
        <*> StateT (B.readInt . B.unsafeTail)

Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define ll long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define rep(i, init, n) for (int i = init; i < n; i++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define gcd __gcd
# define M_PI 3.14159265358979323846
using namespace std;
const ll mod = 1e9 + 7;
const int N = 1e5 + 4;
const ll MOD = 998244353;
bool ans[2 * N];

ll POW(ll base, ll exponent){
    ll result = 1;
    while (exponent > 0)
    {
        if (exponent % 2 == 1)
            result = (result * base) % MOD;
        exponent = exponent >> 1;
        base = (base * base) % MOD;
    }
    return result;
}

ll Inv(ll x){
    return POW(x, MOD - 2);
}

void BFS(int s, vector<int> &d, vector<int> edge[]) {
    d[s] = 0;
    queue<int> q;
    q.push(s);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (auto to : edge[v]) {
            if (d[to] == (int)1e9){
                d[to] = d[v] + 1;
                q.push(to);
            }
        }
    }
}

int main(){
    IOS
    ll a, b, c, k;
    cin>>a>>b>>c>>k;
    if(a >= k) cout<<k;
    else if(k - a <= b) cout<<a;
    else cout<<2 * a + b - k;
    return 0;   
}

Measured memory_bytes: 3656
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
    --y;
  }

  return sum;
}

/*考えを書くスペース
  累乗和で解く

  ・総和を求める
  ・取り消すところの一つ先を見る
*/
//main.cpp----------------------------
#define max_n 100

void solve();

ll N, x;
ll a[max_n+1];

int main() {
  cin >> N >> x;
  rep(i, N) cin >> a[i];

  solve();

  return 0;
}

void solve() {

  sort(a, a+N);

  int i = 0, cnt = 0;
  while(i<N-1&&x>=a[i]) {
    x -= a[i];
    ++cnt;
    ++i;
  }

  if(x==a[N-1]) ++cnt;

  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i)
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define dis distance
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define pub push_back
#define sec second
#define fir first

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9+7;
const int INF = (1 << 30);
const double PI = acos(-1);

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	string s,t;
	cin >> s >> t;
	int ans = 2*n;
	FOR(i,1,n+1){
		int now = 2*n-i;
		DUMP(i);
		REP(j,i){
			DUMP(s[n-i+j]);
			DUMP(t[j]);
			if(s[n-i+j]!=t[j]){
				now = INT_MAX;
				break;
			}
		}
		DUMP(now);
		ans = min(ans,now);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256