akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
using namespace std;
inline int read()
{
	int f = 1, x = 0;
	char ch;

	do{
		ch = getchar();
		if (ch == '-')
			f = -1;
	}while(ch < '0' || ch > '9');
	do{
		x = x * 10 + ch - '0';
		ch = getchar();
	}while(ch >= '0' && ch <= '9');
	return f * x;
}
const int N = 1e5;

int n;
int a[N + 2], ans;

inline bool compare(int x, int y)
{
	return x > y;
}
int main()
{
	n = read();
	for (int i = 1; i <= n; i++)
		a[i] = read();
	sort(a + 1, a + n + 1, compare);

	for (int i = 0; i <= n; i++) {
		if (i + 1 > a[i + 1]) {
			for (int j = i + 1; a[j] == i; j++)
				ans ^= 1;
			ans |= (a[i] - i) & 1;
			if (ans)
				printf("First\n");
			else
				printf("Second\n");
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 4008
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
using namespace std;

int main() {
	int a, b, c,ta,tb,tc,cnt=0;
	cin >> a >> b >> c;
	while (1) {
		if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) break;
		else if (a == b &&b== c) {
			cnt = -1;
			break;
		}
		ta = a / 2;
		tb = b / 2;
		tc = c / 2;
		a = tb + tc;
		b = ta + tc;
		c = ta + tb;
		cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
from itertools import accumulate
n=int(input())
a=list(map(int, input().split()))
acc=list(accumulate(a))
left=0; center=1; right=2
ans=float('inf')
score=[acc[left], acc[center]-acc[left], acc[right]-acc[center], acc[n-1]-acc[right]]
nextS=[acc[left+1], acc[center]-acc[left+1], acc[right+1]-acc[center], acc[n-1]-acc[right+1]]
for center in range(1,n-1):
    while abs(score[1]-score[0]) > abs(nextS[1]-nextS[0]):
        left+=1
        score[0]+=a[left]
        score[1]-=a[left]
        nextS[0]+=a[left+1]
        nextS[1]-=a[left+1]
    while abs(score[3]-score[2]) > abs(nextS[3]-nextS[2]):
        right+=1
        score[2]+=a[right]
        score[3]-=a[right]
        nextS[2]+=a[right+1]
        nextS[3]-=a[right+1]
    ans=min(ans, max(score)-min(score))
    score[1]+=a[center+1]
    score[2]-=a[center+1]
    nextS[1]+=a[center+1]
    nextS[2]-=a[center+1]
print(ans)


Measured memory_bytes: 25548
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<vector>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int N=2e5+5;
template<class T>inline void read(T &res)
{
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
struct node{
	ll x,h;
};
node f[N];
ll n,d,a,pre[N];
bool cmp(node a,node b){
	return a.x<b.x;
}
int main(){
	read(n),read(d),read(a);
	for(int i=1;i<=n;i++){
		read(f[i].x);
		ll tmp;read(tmp);
		ll z=(tmp-1)/a+1;
		f[i].h=z;
	}
	sort(f+1,f+1+n,cmp);
	int r=1;
	ll sum=0,ans=0;
	for(int i=1;i<=n;i++){
		while(r<=n&&f[r].x<=f[i].x+2*d)r++;
		sum-=pre[i];
		f[i].h-=sum;
		if(f[i].h<=0)continue;
		sum+=f[i].h;
		pre[r]+=f[i].h;
		ans+=f[i].h;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4992
n = input()
hh = map(int, raw_input().split())

a = 0
b = abs(hh[0] - hh[1])
for i in range(2, n):
    a, b = b, min(a + abs(hh[i] - hh[i - 2]), b + abs(hh[i] - hh[i-1]))
print(b)


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

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

int main(void){
    int count = 0, n;
    cin >> n; 
    for(int i = 0; i < n; i++) {
        int p;
        cin >> p;
        if(IsPrime(p)) {
           count++;
        }
    }
    cout << count << endl;
    return 0;
 }



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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int a, b;
int main() {
    cin >> a >> b;
    int c = a + b;
    if (a % 3 && b % 3 && c % 3)
        cout << "Impossible" << endl;
    else
        cout << "Possible" << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<31)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, A, a[51];
ll dp[55][55][3000];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> A;
    erep(i, 1, n) cin >> a[i];
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    rep(i, 0, n) {
        erep(j, 0, n) {
            rep(k, 0, 3000) {
                if (dp[i][j][k]) {
                    dp[i+1][j][k] += dp[i][j][k];
                    if (k + a[i + 1] < 3000) 
                        dp[i+1][j+1][k+a[i+1]] += dp[i][j][k];
                }
            }
        }
    }

    ll ans = 0;
    erep(i, 1, n) {
        ans += dp[n][i][A*i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 71168
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
typedef vector<int> Vec;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    string k;
    int d;
    cin >> k >> d;
    vector<vector<int>> dp(d, vector<int>(2));
    dp[0][true] = 1;

    rep(i, k.size()) {
        int here = k[i] - '0';
        vector<vector<int>> after(d, vector<int>(2));
        for(int prevmod = 0; prevmod < d; prevmod++) {
            for(int now = 0; now < 10; now++) {
                int nowmod = (prevmod + now) % d;
                if(now < here) {
                    after[nowmod][false] += dp[prevmod][true];
                    after[nowmod][true] %= MOD;
                } else if(now == here) {
                    after[nowmod][true] += dp[prevmod][true];
                    after[nowmod][true] %= MOD;
                }
                after[nowmod][false] += dp[prevmod][false];
                after[nowmod][false] %= MOD;
            }
        }
        dp = after;
    }
    cout << (dp[0][true] + dp[0][false] - 1 + MOD) % MOD << endl;
    return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
s = input()

def isint(str):
    try: int(str)
    except: return False
    return True

if isint(s[:a]) == True and s[a:a+1] == "-" and isint(s[a+1:]) == True: print("Yes")
else:  print("No")

Measured memory_bytes: 9120
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())
#define PI 2 * acos(0)

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll n) { if (n <= 1)  return false; if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } 




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




Measured memory_bytes: 3516
import heapq
maxB = 10 ** 1

N, M = map(int, input().split())
AB = []
for _ in range(N):
    A, B = map(int, input().split())
    AB.append((maxB - B, A))

AB.sort(key=lambda x: x[1])

ans, heap, idx, lAB = 0, [], 0, len(AB)
for i in range(M):
    while idx < lAB and AB[idx][1] <= i + 1:
        heapq.heappush(heap, AB[idx])
        idx += 1
    if len(heap) > 0:
        ans += maxB - heapq.heappop(heap)[0]

print(ans)


Measured memory_bytes: 18232
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a < b){
      for(int i = 0;i < b;i++){
        System.out.print(a);
      }
    }
    else if(b < a){
      for(int i = 0;i < a;i++){
        System.out.print(b);
      }
    }
    else{
      for(int i = 0;i < a;i++){
        System.out.print(a);
      }
    }
    System.out.println();
  }
}

Measured memory_bytes: 35644
import java.text.DecimalFormat;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        final int X = sc.nextInt(), A = sc.nextInt(), B = sc.nextInt();
        String ans = "dangerous";

        if (B - A <= 0) {
            ans = "delicious";
        } else if (B - A <= X) {
            ans = "safe";
        }

        out.println(ans);

        out.flush();
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

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

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

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


Measured memory_bytes: 21332
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(){
    int n,ans = 0;
    string s;
    map<string,int>m;
    cin >> n;

    for(int i = 0;i < n;i++){
        cin >> s;
        m[s]++;
    }

    for(auto &i:m){
        if(i.second >= 1)ans++;
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
	int i, ans = 0;
	char *S = (char *)malloc(sizeof(char) * 102);
	S[0] = 'A';
	scanf("%s", &S[1]);
	for(i = 1; S[i] != '\0'; i++){
		if(S[i] <= S[i - 1]){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1832
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

typedef long long LL;

#define INF 0x7fffffff
#define MAX 1048576
#define MAXN 65535
#define MAXLg 16
#define MAXQ 20000

int A[MAX],Log[MAXN + 1],tableMin[MAXN][MAXLg];

void makeRMinQ(int *a,int s,int t){
	int n = t - s;
	for (int i = s; i < t; ++i) tableMin[i - s][0] = a[i];
	for (int j = 1; (1 << j) <= n; ++j)
		for (int i = s; i + (1 << j) <= t; ++i)
			tableMin[i - s][j] = min(tableMin[i - s][j - 1], tableMin[i - s + (1 << (j - 1))][j - 1]);
}

int QueryMin(int x,int y){
	int p = Log[y - x + 1];
	return min(tableMin[x][p],tableMin[y - (1 << p) + 1][p]);
}

struct query{
    int x1, y1;
    int x2, y2;
}fQ[MAXQ];

int Res[MAXQ];

int main() {
	for (int i = 0, x = 0, cd = 2; i <= MAXN; ++x, cd <<= 1)
		while (i <= MAXN && i < cd)
		    Log[++i] = x;
	int R, C, Q;
	while(scanf("%d%d%d",&R,&C,&Q), R){
        if (R <= C){
            for (int i = 0; i < R; ++i)
                for (int j = 0; j < C; ++j)
                    scanf("%d", &A[i * C + j]);
            for (int q = 0; q < Q; ++q)
                scanf("%d%d%d%d", &fQ[q].x1, &fQ[q].y1, &fQ[q].x2, &fQ[q].y2);
        }else{
            for (int i = 0; i < R; ++i)
                for (int j = 0; j < C; ++j)
                    scanf("%d", &A[j * R + i]);
            swap(R, C);
            for (int q = 0; q < Q; ++q){
                scanf("%d%d%d%d", &fQ[q].x1, &fQ[q].y1, &fQ[q].x2, &fQ[q].y2);
                swap(fQ[q].x1, fQ[q].y1);
                swap(fQ[q].x2, fQ[q].y2);
            }
        }
        for (int q = 0;q < Q; ++q)
            Res[q] = INF;
        int fC = (C-1) / MAXN+1;
        for (int i = 0; i < R; ++i){
            for (int j = 0, k = 0; j < fC; ++j){
                int nk = min(C, k + MAXN);
                makeRMinQ(A, i * C + k, i * C + nk);
                for (int q = 0; q < Q; ++q){
                    if (i < fQ[q].x1 || fQ[q].x2 < i)
                        continue;
                    int cs = max(fQ[q].y1,k);
                    int ct = min(fQ[q].y2,nk - 1);
                    if (cs > ct) continue;
                    Res[q] = min(Res[q],QueryMin(cs - k,ct - k));
                }
                k = nk;
            }
        }
        for (int q = 0; q < Q; ++q)
            printf("%d\n", Res[q]);
    }
    return 0;
}

Measured memory_bytes: 9488
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 105;
const int mod = 1000000007;

int f[maxn][2][4];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  string s;
  int n;
  cin>>s>>n;
  f[0][1][0] = 1;
  for(int i=0;i<s.size();i++)
    for(int j=0;j<2;j++)
      for(int k=0;k<=n;k++){
        if(!f[i][j][k])continue;
        for(int r=0;r<10;r++){
          if(k==n&&r)continue;
          if(j&&r>s[i]-'0')continue;
          f[i+1][j&&r==s[i]-'0'][k+(r>0)]+=f[i][j][k];
        }
      }
  cout<<f[s.size()][0][n]+f[s.size()][1][n]<<endl;
  return 0;
}

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

int n;
long long m;
vector<int> a;
vector<long long> sum;

int g(int x){
    if(a[0] < x) return 0;
    if(a[n-1] >= x) return n;
    int ok = 0, ng = n;
    while(ok + 1 < ng){
        int mid = (ok + ng) / 2;
        if(a[mid] >= x) ok = mid;
        else ng = mid;
    }
    return ng;
}

long long f(int x){
    long long cnt = 0;
    for(int i=0;i<n;i++){
        cnt += g(x-a[i]);
    }
    return cnt;
}

long long h(int x){
    long long res = 0;
    for(int i=0;i<n;i++){
        int cnt = g(x-a[i]);
        res += sum[cnt] + (long long) a[i]*cnt;
    }
    return res;
}

int main() {
    cin >> n >> m;
    a.assign(n, 0);
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    sum.assign(n+1, 0);
    for(int i=0;i<n;i++) sum[i+1] = sum[i] + a[i];

    int ok = 0, ng = 1e6;
    while(ok + 1 < ng){
        int mid = (ok+ng)/2;
        if(f(mid) >= m) ok = mid;
        else ng = mid;
    }
    long long ans = h(ng);
    ans += (m - f(ng)) * ok;
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
import java.util.*;
public class Main {

	public static void main(String[] args) {
		int[] dx = { 0, 1,1,1,0,-1,-1,-1};
		int[] dy = {-1,-1,0,1,1, 1, 0,-1};
		Scanner sc = new Scanner(System.in);

		while (true) {
			int w = sc.nextInt();
			int h = sc.nextInt();
			if ((w | h) == 0) break;
			int[][] map = new int[h][w];
			boolean[][] check = new boolean[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					map[i][j] = sc.nextInt();
				}
			}
			int ans = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {

					if (map[i][j] == 0 || check[i][j]) continue;

					check[i][j] = true;
					ans++;
					Queue<Integer> queueX = new LinkedList<Integer>();
					Queue<Integer> queueY = new LinkedList<Integer>();

					queueX.add(j);
					queueY.add(i);

					while (!queueX.isEmpty()) {

						int x = queueX.poll();
						int y = queueY.poll();

						for (int k = 0; k < dx.length; k++) {
							int nextX = x + dx[k];
							int nextY = y + dy[k];

							if (0 <= nextY && nextY < h &&
								0 <= nextX && nextX < w &&
								!check[nextY][nextX] &&
								map[nextY][nextX] == 1) {

								check[nextY][nextX] = true;
								queueX.add(nextX);
								queueY.add(nextY);

							}

						}

					}

				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define sz(x) ((int)x.size())

int a[100005], b[100005], c[100005], dp[100005][3];
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i] >> b[i] >> c[i];
    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    for(int i = 1; i <= n; i++)
    {
        dp[i][0] = max({dp[i-1][1], dp[i-1][2]}) + a[i];
        dp[i][1] = max({dp[i-1][0], dp[i-1][2]}) + b[i];
        dp[i][2] = max({dp[i-1][0], dp[i-1][1]}) + c[i];
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
}

Measured memory_bytes: 8312
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int maxn=1e5;
int a,b,c,d,x,y;
int main(){
	cin>>a>>b>>c>>x>>y;
	if((a+b)>c*2){
	if(x>=y)d=2*c*y+a*(x-y);
	else d=2*c*x+b*(y-x);
	d=min(d,max(x,y)*c*2);
	}
	else d=a*x+b*y;
	printf("%d\n",d);
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int a, b, h, c, d;
	cin >> a >> b >> h >> c >> d;
	int ans;
	if (c >= d) ans = d * h * 2 + (c - d)*a;
	else ans = c * h * 2 + (d - c)*b;

	int aans;
	if (c >= d) aans = c * 2 * h;
	else aans = d * 2 * h;
	int bans = min(aans, ans);
	cout << min(a*c + b * d, bans) << endl;
}

Measured memory_bytes: 256
import math
h, w = map(int, input().split())

a = 0
b = 0
c = 0
ans = 1e+9

if h == 2 and w == 2:
    print(1)
    exit()

for ha in range(1, h-1):  # bとcを横に分割するパターン
    a = ha * w
    b = (h-ha) * (w//2)
    c = (h-ha) * math.ceil(w/2)
    smax = max(a, max(b, c))
    smin = min(a, min(b, c))
    ans = min(ans, smax-smin)

for ha in range(1, h-1):  # bとcを縦に分割するパターン
    a = ha * w
    b = (h-ha)//2 * w
    c = math.ceil((h-ha)/2) * w
    smax = max(a, max(b, c))
    smin = min(a, min(b, c))
    ans = min(ans, smax-smin)

h, w = w, h

for ha in range(1, h-1):  # bとcを横に分割するパターン
    a = ha * w
    b = (h-ha) * (w//2)
    c = (h-ha) * math.ceil(w/2)
    smax = max(a, max(b, c))
    smin = min(a, min(b, c))
    ans = min(ans, smax-smin)

for ha in range(1, h-1):  # bとcを横に分割するパターン
    a = ha * w
    b = (h-ha)//2 * w
    c = math.ceil((h-ha)/2) * w
    smax = max(a, max(b, c))
    smin = min(a, min(b, c))
    ans = min(ans, smax-smin)

print(int(ans))


Measured memory_bytes: 3188
#!/usr/bin/env python3
from collections import*

n = int(input())
a = list(map(int, input().split()))

l = []
r = []
for i, j in enumerate(a):
    l += [i + j]
    r += [i - j]

c = 0
l = Counter(l)
for r in r:
    c += l.get(r, 0)
print(c)

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

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

    int L[200];
    for(int i = 0; i < N*2; i++)
        cin >> L[i];

    sort(L, L+N*2);

    int ans = 0;
    for(int i = 0; i < N*2; i += 2)
        ans += L[i];

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


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

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

struct edge { int to,cost; };

int main() {
  ll N,A,B;cin>>N>>A>>B;
  vector<int> XS(N);
  REP(i,N) cin>>XS[i];
  // 原則左から順番に移動していくでも問題はない
  // どことどこの間を歩くかして、それ以外は全てテレポートなのだから問題はないから
  // o...o..o.oo...o..oo...
  // 歩く距離はA*x<Bとなるところ
  vector<ll> dists(N-1);
  REP(i,N-1) dists[i] = (XS[i+1]-XS[i])*A;
  sort(ALL(dists));

  int idx = lower_bound(ALL(dists),B)-dists.begin();
  ll ans = 0;
  REP(i,idx) ans += dists[i];
  ans += B*(N-idx-1);
  OUT(ans);

  return 0;
}

Measured memory_bytes: 1408
#include<cstdio>
#include<queue>
#include<map>
#include<algorithm>
#include<vector>

#define pb push_back
#define fs first
#define sc second
#define INF 500000000
using namespace std;

typedef pair<int,int> P;
typedef pair<int,P > P2;

int n,m,l;
int num[110][110];
vector<int> to[110],d[110],e[110];

int main(){
  while(scanf("%d %d %d",&n,&m,&l) && (n||m||l)){

    for(int i=1;i<=n;i++){
      to[i].clear();
      d[i].clear();
      e[i].clear();
    }

    for(int i=0;i<m;i++){
      int a,b,dis,en;
      scanf("%d %d %d %d",&a,&b,&dis,&en);
      to[a].pb(b);
      d[a].pb(dis);
      e[a].pb(en);
      to[b].pb(a);
      d[b].pb(dis);
      e[b].pb(en);
    }

    for(int i=1;i<=n;i++){
      for(int j=0;j<=l;j++){
	num[i][j] = INF;
      }
    }

    num[1][l] = 0;
    priority_queue<P2 ,vector<P2> ,greater<P2> > q;
    q.push(P2(0,P(1,l)));

    while(q.size()){
      P2 p = q.top();q.pop();
      int en = p.fs, pos = p.sc.fs, mon = p.sc.sc;

      for(int i=0;i<(int)to[pos].size();i++){
	int next = to[pos][i];
	if(d[pos][i] <= mon){
	  int rem = mon - d[pos][i];
	  if(num[next][rem] > en){
	    num[next][rem] = en;
	    q.push(P2(num[next][rem],P(next,rem)));
	  }
	}
	int enemy = en + e[pos][i];
	if(num[next][mon] > enemy){
	  num[next][mon] = enemy;
	  q.push(P2(enemy,P(next,mon)));
	}
      }
    }
  
    int ans = INF;
    for(int i=0;i<=l;i++)ans = min(ans,num[n][i]);
    printf("%d\n",ans);
  }
}

Measured memory_bytes: 0
const main = (input) => {
    // 標準入力の末尾などに不要な空白などが入っているときが稀にあ流からtrim
    const args = input.trim().split("\n");
	const N = args[0]
    const As = args[1].trim().split(" ")
    // フラグを初期値空
	let flag = ''
    // Asのどっちかに0が含まれていたらzero
    if (As.includes('0')) { flag = 'zero' }
	let answer = As[0]
 
    // リミットを設定
    const limit = 10 ** 18
	if (flag !== 'zero') {
		let i = 1;
        // ここはnでもいいような気はする
        while (i < As.length) {
			if (answer <= limit) {
                // 数値に変換してi番目を既存のanswerに掛け算して更新
				answer = BigInt(answer) * BigInt(As[i])
                // iを更新　 bitwise or 0.5とかは切り捨てられる
                i = (i + 1) | 0　
                // answerがリミットをオーバーフローしたら中し
                if (answer > limit) {
					flag = 'over'
					break
				}
			}
		}
	}
    // 条件分岐
    switch (flag) {
		case 'zero' :
			console.log(0)
			break
		case 'over':
			console.log(-1)
			break
		default:
            // 文字型に変換して出力
			console.log(answer.toString())
	}
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

const int MAX_N=51,MAX_S=51;

int n,ok; string port,code;
vector<string> codes(MAX_N),check(MAX_N);
vector<char> vowels={'a','i','u','e','o'};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(cin >> n,n){
		for (int i=0;i<n;++i){
			cin >> port; code=""; code+=port[0];
			for (int j=0;j+1<port.size();++j){
				for (int k=0;k<5;++k){
					if (port[j]==vowels[k]) code+=port[j+1];
				}
			}
			for(int j=0;j<MAX_S;++j){
				if (j>=code.size()) code+='#';
			}
			codes[i]=code;
		}
		for (int k=1;k<=MAX_S;++k){
			ok=1;
			for (int i=0;i<n;++i) check[i]=codes[i].substr(0,k);
			for (int i=0;i<n;++i){
				for (int j=i+1;j<n;++j){
					if (check[i]==check[j]) ok=0;
				}
			}
			if (ok){
				cout << k << '\n';
				break;
			}
			if (k==MAX_S) cout << -1 << '\n';
		}
	}
}


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

using namespace std;

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

int main(int argc, char const *argv[]) {
	int n;
	std::cin >> n;
	std::vector<int> v(n);
	int max_1st, max_2nd;
	max_1st = max_2nd = 0;
	for (size_t i = 0; i < n; i++) {
		std::cin >> v[i];
		if (v[i] >= max_1st) {
			max_2nd = max_1st;
			max_1st = v[i];
		}
		else if (v[i] > max_2nd) {
			max_2nd = v[i];
		}
	}

	for (size_t i = 0; i < n; i++) {
		if (v[i] == max_1st) {
			std::cout << max_2nd << '\n';
		}
		else {
			std::cout << max_1st << '\n';
		}
	}

	return 0;
}


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

using namespace std;

#ifdef LOCAL
#define DBG_MACRO_NO_WARNING
#include <dbg.h>
#else
#define dbg(...) 0
#endif

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

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

#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  ll n, k;
  cin >> n >> k;

  vector<ll> h(n);

  for (auto &i : h) {
    cin >> i;
  }

  sort(h.rbegin(), h.rend());

  h.erase(h.begin(), h.begin() + min(k, n));

  dbg(h);

  ll ans = accumulate(h.begin(), h.end(), 0ll);

  cout << ans << "\n";
}

Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<ctime>
#include<fstream>
#include<sstream>
#include<vector>
#include<set>
#include<deque>
#include<cstring>
#include<queue>
#include<stdio.h>
#include<set>
#include<stack>
#include<numeric>
#include<map>
#include<cstdio>
#include<bitset>
#include<array>
#include<list>
using namespace std;
#define ll long long 
const ll mod = 1e9 + 7;

ifstream f1;
ofstream f2;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	f1.open("INP.txt");
	f2.open("OUT.txt");
	//system("pause");
	ll n;
	cin >> n;
	vector<ll> hold(n + 1);
	for (ll i = 1; i <= n; i++) {
		cin >> hold[i];
	}
	ll cnt = 0;
	for (ll i = 1; i <= n; i++) {
		if (hold[i] != i) {
			cnt++;
		}
	}
	if (cnt > 2) {
		cout << "NO" << '\n';
	}
	else {
		cout << "YES" << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main(){
    var num int
    fmt.Scanf("%d", &num)
    //fmt.Printf("num->%d", num) 
    if (num == 7) || (num == 5) || (num == 3){
        fmt.Println("YES")
    }else{
        fmt.Println("NO")
    }
}


Measured memory_bytes: 512
x, y = gets.chomp.split.map(&:to_i)

ans = 0
if x == 1
  ans+=300000
elsif x == 2
  ans+=200000
elsif x == 3
  ans+=100000
end

if y == 1
  ans+=300000
elsif y == 2
  ans+=200000
elsif y == 3
  ans+=100000
end

if x == 1 && y == 1
  ans += 400000
end
puts ans

Measured memory_bytes: 1788
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b,c,d=LI()
  while True:
    c-=b
    if c<=0:
      return 'Yes'
    a-=d
    if a<=0:
      return 'No'

# main()
print(main())


Measured memory_bytes: 10752
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a;
		int min=0, max=0;
		long sum=0;
		for(int i=0; i<n; i++){
			a = sc.nextInt();
			if(i==0){
				min = max = a;
			}
			if(min>a) min = a;
			if(max<a) max = a;
			sum += a;
		}
		System.out.println(min + " " + max + " " + sum);
	}
}

Measured memory_bytes: 31952
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n;
  cin>>n;
  vll p(n);
  rep(i,n) cin>>p[i];
  ll ans=1;
  ll cu=p[0];
  for(int i=1;i<n;i++){
    if(p[i]<=cu){
      ans++;
      cu=p[i];
    }
  }
  COUT(ans);
}
    


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a; i < n; i++)
#define per(i,n,a) for (int i = n - 1; i >= a; i--)
using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    cout << (s < t ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define min(p,q)((p)<(q)?(p):(q))

int f(int n){
	int s=0;
	while(n){
		s+=n%10;
		n/=10;
	}
	return s;
}

int main(){
	int n;
	scanf("%d",&n);
	int ans=50;
	for(int i=1;i<n;i++){
		ans=min(ans,f(i)+f(n-i));
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.stream.IntStream;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] P = new int[M+1];
    int[] Y = new int[M+1];
    for (int i = 1; i <M+1; i++) {           
      P[i] = sc.nextInt();       
      Y[i] = sc.nextInt();
    }
    
    String[] result = new String[P.length+1]; //Pの桁数
    int[] count = new int[N + 1]; 
    int[] list = 
      IntStream.range(0, P.length)
      .boxed()
      .sorted((i1, i2) -> Integer.compare(Y[i1], Y[i2]))
      .mapToInt(x -> x).toArray();
    for (int index : list) {
      count[P[index]]++;
      result[index] = String.format("%06d%06d", P[index], count[P[index]]);
    }
    for (int i =1; i<=M; i++) {
      System.out.println(result[i]);
    }
  }
}

Measured memory_bytes: 77720
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> T;
typedef pair<long double , ll> Ps;
typedef pair<ll, bool> Pb;

const ll INF = 1e18;
const ll fact_table = 3200008;
long double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll, vector<ll>, greater<ll> > pqls;
priority_queue <P, vector<P>, greater<P> > pqps;
//small priority queue
//top pop

ll dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
ll dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
char dir[] = "DRUL";
//↓,→,↑,←

#define endl "\n"
#ifdef ENJAPMA
#undef endl
#endif
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)();
#define pc(x) cout << x << ",";
#define rep(i, n) for (ll i = 0; i < (n); i ++)

// const ll mod = 998244353ll;
const ll mod = 1000000007ll;

ll mypow(ll a, ll b, ll mod) {ll x = 1; while (b) {while (!(b & 1)) {(a *= a) %= mod; b >>= 1;}(x *= a) %= mod; b--;} return x;}
void YES(bool cond) { if (cond) { p("YES");} else { p("NO");} return;}
void Yes(bool cond) { if (cond) { p("Yes");} else { p("No");} return;}

ll line_count = 0;

void line(){

    line_count ++;
    string s = (line_count % 2) ? "v-v-v-v-v-v-v-v-v-v" : "^-^-^-^-^-^-^-^-^-^";
    cout << endl << s << endl << endl;
}

/*
ll fact[fact_table + 5],rfact[fact_table + 5];

void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/

bool multicase = false;

ll n, m, k, num, a, b, c, d, e, h, q, ans, sum;
string s;

void solve() {
    cin >> a >> b;
    if(2 * a <= b && b <= 4 * a && b % 2 == 0){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

int main() {
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if (multicase) {
        cin >> q;
    } else {
        q = 1;
    }
    while (q--) {
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    // solve();
    return 0;
}
















Measured memory_bytes: 3656
#include <stdio.h>
#define N 500000
#define SENTINEL 1000000000

int count = 0;
void mergeSort(int*,int,int);
void merge(int*,int,int,int);

int main(){
  int S[N], n, i;
  scanf("%d",&n);
  for(i = 0; i < n; i++) scanf("%d",&S[i]);
  mergeSort(S, 0, n);
  for(i = 0; i < n; i++){
    printf("%d",S[i]);
    if(i < n - 1) printf(" ");
  }
  printf("\n%d\n",count);
  
  return 0;
}

void mergeSort(int* S, int left, int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right) / 2;
    mergeSort(S, left, mid);
    mergeSort(S, mid, right);
    merge(S, left, mid, right);
  }
}

void merge(int* S, int left, int mid, int right){
  int i, j, k, n1, n2, L[N], R[N];
  n1 = mid - left;
  n2 = right - mid;
  for(i = 0; i < n1; i++) L[i] = S[left+i];
  for(i = 0; i < n2; i++) R[i] = S[mid+i];
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  i = 0;
  j = 0;
  for(k = left; k < right; k++){
    count++;
    if(L[i] <= R[j]){
      S[k] = L[i];
      i += 1;
    }
    else{
      S[k] = R[j];
      j += 1;
    }
  }
}

Measured memory_bytes: 5512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long LL;

int main()
{
    int A, B, C;
    cin>>A>>B>>C;
    int t = 0;
    while(t < 1e7){
        if((A&1)||(B&1)||(C&1)) break;
        int tA = (B+C)/2, tB = (A+C)/2, tC = (A+B)/2;
        A = tA; B = tB; C = tC;
        t++;
    }
    if(t < 1e7) cout<<t<<endl;
    else cout<<"-1"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h;
    cin>>h;
    int res=0;
    int cnt=1;
    while(h){
        res+=cnt;
        h/=2;
        cnt*=2;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 10200;
int n,a[N],b[N];set<int>Set;
int gcd(int a, int b){return !b?a:gcd(b,a%b);}
bool isprime(int x){
	for(int i=2;i*i<=x;i++)if(x%i==0)return 0;
	return 1;
}
inline bool ck(int p){
	rep(i,0,n)b[i]=a[i]%p;
	per(i,n,p)if(b[i]){
		b[i-p+1]=(b[i-p+1]+b[i])%p;b[i]=0;
	}
	rep(i,0,p-1)if(b[i])return 0;
	return 1;
}
int main() {
	read(n);per(i,n,0)read(a[i]);
	int g=0;rep(i,0,n)g=gcd(g,a[i]);g=g>0?g:-g;
	for(int i=2;i*i<=g;i++)if(g%i==0){
		Set.insert(i);while(g%i==0)g/=i;
	}
	if(g>1)Set.insert(g);
	rep(i,2,n)if(isprime(i)&&ck(i))Set.insert(i);
	while(!Set.empty())
		printf("%d\n",*Set.begin()),Set.erase(Set.begin());
	return 0;
}


Measured memory_bytes: 384
///
// File:  c.cpp
// Author: ymiyamoto
//
// Created on Sun Dec 17 10:11:58 2017
//

#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int32_t main()
{
  uint32_t N;
  cin >> N;
  vector<uint64_t> arr(N);

  for (uint32_t i = 0; i < N; i++) {
    cin >> arr[i];
  }

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

  uint64_t old = arr[0];
  uint32_t same_num = 1;
  uint32_t remove = 0;
  for (uint32_t i = 1; i < N; i++) {
    if (old != arr[i]) {
      if (same_num != old) {
        if (same_num > old) {
          remove += same_num - old;
        } else {
          remove += same_num;
        }
      }
      old = arr[i];
      same_num = 1;
    } else {
      same_num++;
    }
  }

  if (same_num != old) {
    if (same_num > old) {
      remove += same_num - old;
    } else {
      remove += same_num;
    }
  }
  cout << remove << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(int i=a;i<b;i++)
#define rFor(i,a,b) for(int i=a;i>b;i--)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//vector<vector<int>> data(a,vector<b>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  string a,b;
  ci(a);
  if(a=="Sunny")
    b="Cloudy";
  else if(a=="Cloudy")
    b="Rainy";
  else
    b="Sunny";
  co(b);
}

Measured memory_bytes: 256
N,X,M = map(int,input().split())
i = X%M
L = [i]
S = set([i])
i = i**2 % M
while not i in S:
    L.append(i)
    S.add(i)
    i = i**2 % M
index = L.index(i)
k = (N-index)//len(L[index:])
l = (N-index)%len(L[index:])

# これでうまくいくのたまたまだよ。本当はN<indexの場合分けがひつよう。なんで場合分けするよ
if N<index:
    ans = sum(L[:N])
else:
    ans = sum(L[:index]) + (k*sum(L[index:])) + sum(L[index:index+l])
print(ans)

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int N, M, X, Y; std::cin >> N >> M >> X >> Y;
  std::vector<int> x(N), y(M);
  for(int i=0; i<N; i++) std::cin >> x[i];
  for(int i=0; i<M; i++) std::cin >> y[i];

  int xmax = *std::max_element(x.begin(), x.end());
  int ymin = *std::min_element(y.begin(), y.end());


  bool flag = false;
  for(int k=xmax+1; k<=ymin; k++) {
    if ( X < k && k <= Y && xmax < k && k <= ymin ) flag = true;
  }

  if (flag) std::cout << "No War" << std::endl;
  else std::cout << "War" << std::endl;

  return 0;
}


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

using namespace std;

long long arr[1005];

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

    long long n,i,g,l=0,sum=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>arr[i];
    }
    l = arr[0];
    for(i=1;i<n;i++){
        g = __gcd(l,arr[i]);
        l = (l*arr[i])/g;
    }
    for(i=0;i<n;i++){
        sum+=(l/arr[i]);
    }
    cout<<fixed<<setprecision(8)<<(double)l/(double)sum<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <algorithm>

using namespace std;

int inStackPriority[]={2,4,0,5},outStackPriority[]={1,3,5,0};//| & ( )

int opToIndex[256];

void init(){
    opToIndex['|']=0;
    opToIndex['&']=1;
    opToIndex['(']=2;
    opToIndex[')']=3;
    opToIndex['\n']=3;
}

int main(){
    stack<int> valueStack[2];//true false
    stack<int> ops;

    init();
    ops.push(2);
    while(!ops.empty()){
        char c=getchar();
        if (c=='?'){
           for(int i=0;i<=1;i++) valueStack[i].push(1);
        //    puts("push ?");
        }else{
            int cIndex=opToIndex[c];
            while(inStackPriority[ops.top()]>=outStackPriority[cIndex]){
                // puts("pop");
                int op=ops.top();
                ops.pop();
                if (op==2) break;
                int tempOperand[2][2];//true false snd fst
                for(int i=0;i<2;i++) 
                    for(int j=0;j<2;j++) 
                        tempOperand[i][j]=valueStack[i].top(),valueStack[i].pop();

                if (op==0){
                    valueStack[1].push(tempOperand[1][0]+tempOperand[1][1]);
                    valueStack[0].push(min(tempOperand[0][1],tempOperand[1][1]+tempOperand[0][0]));
                }else if (op==1){
                    valueStack[0].push(tempOperand[0][0]+tempOperand[0][1]);
                    valueStack[1].push(min(tempOperand[1][1],tempOperand[0][1]+tempOperand[1][0]));
                }else{
                    return -1;
                }
            }

            if (cIndex!=3) ops.push(cIndex);
            // puts("push op");
        }


    };

    printf("%d %d\n",valueStack[1].top(),valueStack[0].top());

    return 0;
}


Measured memory_bytes: 2716
function Main(input) {
  	input = input.split("\n");
  	var N = Number(input[0]);
	var tmp = input[1].split(" ");
	var count = 0;
	function loop(tmp){
  		for(var i=0;i<N;i++){
    		if(tmp[i]%2==0){
    			tmp[i]=tmp[i]/2;
    		}else{
      			return count;
    		}
    		if(i==N-1){
      			count++;
      			return loop(tmp);
    		}
  		}
	}
	loop(tmp);
	console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define int long long

vector<int> g[100005];
int c[100005];
int c2[100005];
pair<int,int> c3[100005];

int memo[100005];

vector<int> black;
vector<int> white;

auto main() -> signed {
    int n;
    cin >> n;
    for(int i=0; i<n-1; ++i) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    c[1] = 1;
    c[n] = 2;
    c2[1] = 1;
    c2[n] = 2;
    black.push_back(1);
    white.push_back(n);

    int b = 0;
    queue<pair<int,int>> q;
    q.push(make_pair(1, 0));
    while(!q.empty()) {
        auto p = q.front();
        q.pop();
        int t = p.first;
        b++;
        c[t] = 1;
        for(int i=0; i<g[t].size(); ++i) {
            if(c[g[t][i]]!=0) continue;
            c3[g[t][i]].first = p.second+1;
            q.push(make_pair(g[t][i], p.second+1));
        }
    }

    int w = 0;
    queue<pair<int, int>> q2;
    q2.push(make_pair(n,0));
    while(!q2.empty()) {
        auto p = q2.front();
        q2.pop();
        int t = p.first;
        w++;
        c2[t] = 2;
        for(int i=0; i<g[t].size(); ++i) {
            if(c2[g[t][i]]!=0) continue;
            c3[g[t][i]].second = p.second+1;
            q2.push(make_pair(g[t][i], p.second+1));
        }
    }

    int mb = 0;
    int mw = 0;
    int tmp = 0;
    for(int i=1; i<=n; ++i) {
        auto p = c3[i];
        if(p.first==0||p.second==0) continue;
        if(p.first <= p.second) mb++;
        else mw++;
    }

    b -= mw;
    w -= mb;

    if(b>w) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
    return 0;
}



Measured memory_bytes: 9856
#include<iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	int a[100];
	for (int i = 0; i < n; i++) {
		cin >> a[i];

	}
	cout << a[0];
	for (int i = 1; i < n; i++)cout << " " << a[i]; cout << endl;
	
	for (int i = 1; i < n; i++) {
		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
			a[j + 1] = v;
		}
		cout << a[0];
		for (int i = 1; i < n; i++)cout << " " << a[i]; cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1160