akhauriyash/Code-Regression huggingface dataset:
// コメント, ロジック見直して, 再提出.
// 解き直し.
// https://img.atcoder.jp/agc015/editorial.pdf
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const int MAX = 61;

int main(){
    
    // 1. 入力情報.
    LL A, B;
    scanf("%lld %lld", &A, &B);
    if(A > B) swap(A, B);
    
    // 2. A = B の 場合.
    if(A == B){
        puts("1");
        return 0;
    }
    
    // 3. 2 の 冪乗(61乗未満).
    vector<LL> vPow2(MAX);
    vPow2[0] = 1LL;
    repx(i, 1, MAX) vPow2[i] = vPow2[i - 1] << 1;
    // rep(i, MAX) printf("%lld\n", vPow2[i]);
    
    // 4. 二進数変換(61桁).
    string binA, binB;
    rep(i, MAX){
        if(1 & (A >> i)) binA = "1" + binA;
        else             binA = "0" + binA;
        if(1 & (B >> i)) binB = "1" + binB;
        else             binB = "0" + binB;
    }
    // printf("A=%s\n", binA.c_str());
    // printf("B=%s\n", binB.c_str());
    
    // 5. 操作 BITWISE OR を取って出来る整数をカウント.
    // 5-1. 二進数 A, B が, 最初に異なる桁.
    int r = -1;
    rep(i, MAX){
        if(binA[i] != binB[i]){
            r = MAX - i;
            break;
        }
    }
    assert(r != -1);
    // printf("r=%d\n", r);
    
    // 5-2. r桁より大きい部分(A, B の 共通部分)を計算し, A を 更新.
    LL extra = 0;
    rep(i, MAX - r) if(binA[i] == '1') extra += vPow2[MAX - 1 - i];
    A -= extra;
    
    // 6. 各パターンを集計.
    // 6-1. A ～ 2 の (r - 1)乗未満 の 整数 を カウント(パターン①).
    LL ans = vPow2[r - 1] - A;
    
    // 6-2. 最上位が 1 の 整数のみ使う場合(パターン②).
    // 15.txt, 16.txt, 18.txt, 53.txt で WA版となった(maxP2 = -1 から maxP2 = 0 へ 変更).
    // -> B が 1000 の ような形で, k = -1 となったパターンについて考慮が必要とのこと.
    // -> 但し, 修正後に, 12.txt, 24.txt で, WA版 だったため, そもそも, k = -1 から k = 0 に ロジック変更.
    int k = 0;
    repx(i, MAX - r + 1, MAX){
        if(binB[i] == '1'){
            k = MAX - i;
            break;
        }
    }
    // printf("k=%d\n", k);
    LL minP2 = vPow2[r - 1], maxP2 = vPow2[r - 1] + vPow2[k];
    
    // 6-3. 最上位が 0, 1 の 整数を使う場合(パターン③).
    LL minP3 = vPow2[r - 1] + A;
    LL maxP3 = vPow2[r];
    
    // 6-4. パターン②, ③ を 統合.
    if(maxP2 >= minP3) ans += maxP3 - minP2;
    else               ans += maxP2 - minP2, ans += maxP3 - minP3;
    
    // 7. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 3764
#include <cstdio>
#include <algorithm>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)

const int N_MAX = 200000;

int N;
int P[N_MAX];
pair<int, int> os[N_MAX];

void solve() {
  REP(i, N) {
    os[i] = make_pair(P[i], i);
  }
  sort(os, os + N);
  int lx = 0;
  int l = 1;
  REP(i, N - 1) {
    if (os[i].second < os[i + 1].second) {
      l++;
    } else {
      lx = max(lx, l);
      l = 1;
    }
  }
  lx = max(lx, l);
  int ans = N - lx;
  printf("%d\n", ans);
}

void input() {
  scanf("%d", &N);
  REP(i, N) scanf("%d", P + i);
}

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


Measured memory_bytes: 2560
N = int(input())
lis = []
for i in range(N):
    lis.append(list(map(int,input().split())))
lis = sorted(lis, key = lambda x:x[1])
a = 0
for j in range(N):
    a += lis[j][0]
    if a > lis[j][1]:
        print('No')
        exit()
print('Yes')

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

int main()
{

    int a,b,c,p,q,r,A,B;

    cin>>a;

    p=a/100;
    q=a%100;



    if ((q>0&&q<13)&&(p>0&&p<13))
        cout<<"AMBIGUOUS"<<endl;


    /* else if(p>=13&&q>=13)
         cout<<"AMBIGUOUS"<<endl;*/

    else if (p>0&&p<13)
        cout<<"MMYY"<<endl;


    else if(q>0&&q<13)
        cout<<"YYMM"<<endl;


    else
        cout<<"NA"<<endl;

    return 0;
}

Measured memory_bytes: 256
//BadWaper gg
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define M 2200
#define N 100010
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
ll a[N];
map<ll,ll>sum,Vis;
ll p[N],q[N];
ll n;
ll prime[N],vis[N],tot;
inline void prepare(ll Maxn)
{
	for(register ll i=2;i<=Maxn;i++)
	{
		if(!vis[i]){prime[++tot]=i;}
		for(register ll j=1;j<=tot&&prime[j]*i<=Maxn;j++)
		{
			vis[i*prime[j]]=1;
			if(i%prime[j]==0)break;
		}
	}
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	prepare(M);
	n=read();
	for(register ll i=1;i<=n;i++)a[i]=read();
	for(register ll i=1;i<=n;i++)
	{
		ll v=a[i];p[i]=q[i]=1;
		for(register ll j=1;j<=tot;j++)
		{
			ll tmp=prime[j]*prime[j]*prime[j];
			while(v%tmp==0)v/=tmp;
			tmp=prime[j]*prime[j];
			if(v%tmp==0)
			{
				v/=tmp;
				p[i]*=tmp;
				q[i]*=prime[j];
			}
			tmp=prime[j];
			if(v%tmp==0)
			{
				v/=tmp;
				p[i]*=tmp;
				q[i]*=prime[j]*prime[j];
			}
		}
		if(v>1)
		{
			ll tmp=sqrt(v);
			if(tmp*tmp==v)
			{
				p[i]*=v;
				q[i]*=tmp;
			}
			else
			{
				p[i]*=v;
				q[i]*=v*v;
			}
		}
		sum[p[i]]++;
	}
	ll ans=0;
	for(register ll i=1;i<=n;i++)
	{
//		cout<<"WTF:"<<i<<" "<<a[i]<<" "<<p[i]<<" "<<q[i]<<" "<<sum[p[i]]<<" "<<sum[q[i]]<<endl;
		if(Vis[p[i]])continue;
		if(p[i]==q[i]){Vis[p[i]]=1;ans++;continue;}
		ans+=max(sum[p[i]],sum[q[i]]);
		Vis[p[i]]=1,Vis[q[i]]=1;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 31056
# -*- coding: utf-8 -*-

N = int(input())

pf = [0] * (N + 1)  # Prime factors

for i in range(2, N + 1):
    cur = i
    for j in range(2, i + 1):
        while cur % j == 0:
            pf[j] += 1
            cur = int(cur // j)


def count(n):
    f = filter(lambda x: x >= n - 1, pf)
    return len(list(f))


ans = count(75)
ans += count(25) * (count(3) - 1)
ans += count(15) * (count(5) - 1)
ans += (count(5) * (count(5) - 1) * (count(3) - 2)) // 2

print(ans)


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest._400Problems_remain_
{
    class CF2016C_C
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] tArray = ReadInts();
            int[] aArray= ReadInts();
            bool[] tFixed = new bool[n];
            bool[] aFixed = new bool[n];
            tFixed[0] = true;
            aFixed[n - 1] = true;
            for(int i = 1; i < n; i++)
            {
                if (tArray[i] > tArray[i - 1]) tFixed[i] = true;
                if (aArray[n - 1 - i] > aArray[n - i]) aFixed[n-1-i] = true;
            }
            long res = 1;
            long mask = 1000000000 + 7;
            for(int i = 0; i < n; i++)
            {
                if (tFixed[i] && aFixed[i]){
                    if (tArray[i] == aArray[i]) continue;
                    else
                    {
                        Console.WriteLine(0);
                        return;
                    }
                }
                else if (tFixed[i])
                {
                    if (tArray[i] <= aArray[i]) continue;
                    else
                    {
                        Console.WriteLine(0);
                        return;
                    }
                }
                else if (aFixed[i])
                {
                    if (aArray[i] <= tArray[i]) continue;
                    else
                    {
                        Console.WriteLine(0);
                        return;
                    }
                }
                else
                {
                    res *= Math.Min(tArray[i], aArray[i]);
                    res %= mask;
                }
            }
            Console.WriteLine(res);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 34012
N = int(input())
hist = {}
for _ in range(N):
    s = input()
    hist[s] = hist.get(s,0) + 1

mx = max(list(hist.values()))
ans = []
for x in hist.keys():
    if hist[x] == mx:
        ans.append(x)
ans = sorted(ans)
for x in ans:
    print(x)


Measured memory_bytes: 33112
#include <bits/stdc++.h>
#define int long long
#define double long double
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define td(v) v.begin(),v.end()
#define tdr(v) v.rbegin(),v.rend()
#define endl "\n"
#define Matrix vector<vector<int> >
using namespace std;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int INF = 2e18;

int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}

inline long long mod(long long n, long long m){
    long long ret = n%m;
    if(ret < 0) ret += m;
    return ret;
}

int exp(int a, int b, int m){
    int result = 1;
    while (b > 0){
        if (b & 1)
            result = mod(result*a,m);
 
        b >>= 1;
        a = mod(a*a,m);
    }
    return result;
}
void solve(){
    int a,b,c; cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<' '<<b<<' '<<c<<endl;
}
main(){
    fastio;
    // int q; cin>>q;
    // while(q--)
        solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long x,y;
struct xs{
	long long ai,bi;
}xx[55];
struct jc{
	long long ci,di,bh;
}jj[55];
int main( ){
	cin>>x>>y;
	for(long long i=1;i<=x;i++)
		cin>>xx[i].ai>>xx[i].bi;
	for(long long i=1;i<=y;i++){
		cin>>jj[i].ci>>jj[i].di;
		jj[i].bh=i;
	}
	for(long long i=1;i<=x;i++){
		long long d=1;
		for(long long j=2;j<=y;j++)
			if(abs(xx[i].ai-jj[j].ci)+abs(xx[i].bi-jj[j].di)<abs(xx[i].ai-jj[d].ci)+abs(xx[i].bi-jj[d].di))
				d=j;
		cout<<d<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int h, a;
	cin >> h >> a;
	cout << (h + a - 1) / a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;cin>>N;
    vector<string> S(N);
    for (int i = 0; i < N; i++)
    {
        cin>>S[i];
    }
    sort(S.begin(),S.end());
    long long cnt=1;
    for (int i = 0; i < N-1; i++)
    {
        if(S[i]!=S[i+1])cnt++;
    }
    cout<<cnt<<endl;
}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

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

signed main() {
	ll n, w, result = 0, a, b;
  map<ll, ll> dp;
  dp[0] = 0;
  cin >> n >> w;
  rep(i, n) {
    cin >> a >> b;
    auto dp2 = dp;
    for(auto x: dp2) {
      if(x.first + a <= w) {
        dp[x.first + a] = max(dp[x.first + a], x.second + b);
        result = max(result, dp[x.first + a]);
      }
    }
  }
  cout << result << endl;
	return 0;
}

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

class Class1
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ').Select(long.Parse).ToList();
        long A = input[0];
        long B = input[1];
        long C = input[2];
        long D = input[3];

        long result = 0;

        long numb = B - (B / C + B / D) + (B / (lcm(C, D)));
        long numa = (A - 1) - ((A - 1) / C + (A - 1) / D) + ((A - 1) / lcm(C, D));

        Console.WriteLine(numb - numa);
    }

    // 最大公約数
    static long gcd(long a, long b)
    {
        if (a % b != 0)
        {
            return gcd(b, a % b);
        }
        else
        {
            return b;
        }
    }

    static long lcm(long a, long b)
    {
        return a * b / gcd(a, b);
    }
}

Measured memory_bytes: 28240
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] s = new int[n + 1];		// ????????¨???????°?????????¨?????¨???????????????
		for (int i = 0; i < n; i++) {
			s[i] = sc.nextInt();
		}

		int q = sc.nextInt();
		int[] t = new int[q];
		for (int i = 0; i < q; i++) {
			t[i] = sc.nextInt();
		}
		sc.close();

		int count = 0;
		for(int sagasu : t) {
			if(binarySearch(s, sagasu) != -1) count++;
		}

		System.out.println(count);
	}

	private static int binarySearch(int[] ary, int target) {
		int low = 0;
		int high = ary.length-1;
		int mid = (low + high) / 2;

		while(low < high) {

			if(ary[mid] == target) return mid;

			if(ary[mid] < target) {
				low = mid + 1;
			} else {
				high = mid;
			}
			mid = (low + high) / 2;

		}
		return -1;
	}
}

Measured memory_bytes: 80968
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int x[100];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  REP(i, n) cin >> x[i];

  int ans = INF;
  FOR(i, 1, 101) {
    int sum = 0;
    REP(j, n) {
      sum += (i - x[j]) * (i - x[j]);
    }

    ans = min(ans, sum);
  }

  cout << ans << endl;
}


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

inline ll rd() {
  ll x = 0;
  bool f = 0;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = 1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + (c ^ 48);
    c = getchar();
  }
  return f ? -x : x;
}

int main() {
  ll x = abs(rd());
  ll k = rd();
  ll d = rd();
  ll cnt = (x + d - 1) / d;
  if (cnt > k) printf("%lld\n", x - k * d);
  else printf("%lld\n", abs(x - cnt * d + ((k - cnt) & 1) * d));
  return 0;
}


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

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

	int a[50];
	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
	}

	sort(a, a + N);

	int sum = 0;
	for (int i = 0; i < K; i++)
	{
		sum += a[N - (i + 1)];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
typedef long long ll;
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

#define for(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) for(i,0,n)
 
int main() {
	// 入力
    int A, B, C, D;
    cin >> A >> B >> C >> D;
 
	int ans = 0;
	if (A<B) ans += A;
	else ans += B;
	if (C<D) ans += C;
	else ans += D;
	
    cout << ans << endl;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int h, w;

int main()
{
    while (cin>>h>>w, h != 0) {
        REP(i,h) {
            REP(j,w) {
                cout<<((i + j) % 2 == 0 ? '#' : '.');
            }
            putchar('\n');
        }
        putchar('\n');

    }

    return 0;
}



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

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

    long long a, b, c, d, x;
    cin>>a>>b>>x>>c>>d>>x>>x;

    long long ans = a+b+c+d-a%2-c%2-d%2;

    if (a && c && d) {
        a--; c--; d--;
        long long ans2 = 3+a+b+c+d-a%2-c%2-d%2;
        ans = max(ans,ans2);
    }

    cout<<ans<<endl;
}


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

int main() {
    string a;
    cin >> a;
    
    for(int i=0; i<3; i++){
        
        if(a[i] == '9'){
            cout << "1";
        }else{
            cout << '9';
        }
    }
    
   
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
using namespace std;
int main()
{
	int i,n,a,b,c,d;
	char s[1000];
	scanf("%s",&s);
		a=b=c=d=0;
		n=strlen(s);
		for(i=0;i<n;i++)
		{
			if(s[i]=='N') a++;
			if(s[i]=='S') b++;
			if(s[i]=='W') c++;
			if(s[i]=='E') d++;
		}	
			if(a!=0 && b!=0 && c!=0 && d!=0)
			{
			 printf("Yes\n");
			 return 0;	
			}
			else if(c!=0 && d!=0 && a==0 && b==0)
			printf("Yes\n");
			else if(a!=0 && b!=0 && c==0 && d==0)	
			printf("Yes\n");
			else printf("No\n");
		return 0;						
}

Measured memory_bytes: 256
<?php
$n=trim(fgets(STDIN));

for($i=1;$i<=$n;$i++){
  $x=$i;
  if($x%3){
    do{
      if($x%10==3){
        echo ' ',$i;
        break;
      }
      $x=floor($x/10);
    }while($x);
  }
  else echo ' ',$i;
}
?>

Measured memory_bytes: 15300
#include <stdio.h>
int main (void)
{
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	if(a > b){
		printf("a > b\n");
	}
	else{
		if(a < b){
			printf("a < b\n");
		}
		else{
			printf("a == b\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include <iostream>

using namespace std;

int n, m;
bool removed[300];
int a[300][300];
int c[300];
int visible[300];
int res = 1e9;

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) {
        cin >> a[i][j];
        a[i][j]--;
    }
    for (int i = 0; i < n; ++i) visible[a[i][0]]++;

    for (int i = 0; i < m; ++i) {
        int maxVisible = 0;
        for (int j = 0; j < m; ++j) if (visible[j] > visible[maxVisible]) maxVisible = j;
        res = min(res, visible[maxVisible]);
        if (i == m - 1) break;

        visible[maxVisible] = -1e9;
        removed[maxVisible] = true;
        for (int j = 0; j < n; ++j) {
            while (c[j] < m && removed[a[j][c[j]]]) {
                c[j]++;
                visible[a[j][c[j]]]++;
            }
        }
    }

    cout << res << "\n";
}


Measured memory_bytes: 640
#include <stdio.h>

long n;
long a[200000];
long b[200000];
long long count = 0;

void partinversion(long begin, long last) {
	long mid = (begin + last) / 2;
	if (mid - begin > 0) {
		partinversion(begin, mid);
	}
	if (last - mid > 1) {
		partinversion(mid, last);
	}
	long p = begin, q = mid;
	long k = begin;
	while (p < mid && q < last) {
		if (a[p] <= a[q]) {
			b[k] = a[p];
			p++;
			k++;
		}
		else {
			b[k] = a[q];
			q++;
			k++;
			count += mid-p;
		}
	}
	while (p < mid) {
		b[k] = a[p];
		p++;
		k++;
	}
	while (q < last) {
		b[k] = a[q];
		q++;
		k++;
	}
	for (long j = begin; j < last; ++j) {
		a[j] = b[j];
	}
}

int main() {
	scanf("%ld", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%ld", &a[i]);
	}
	partinversion(0, n);
	printf("%ld\n", count);
	return 0;
}


Measured memory_bytes: 4980
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String needle = sc.nextLine().toLowerCase();
        int c = 0;
        while (sc.hasNextLine()) {
            String line = sc.nextLine();
            if ("END_OF_TEXT".equals(line)) {
                break;
            }
            String[] hashstack = line.split(" ");
            for (int i = 0, l = hashstack.length; i < l; i++) {
                String s = hashstack[i];
                if (s.toLowerCase().equals(needle)) {
                    c++;
                }
            }
        }
        System.out.println(c);
    }
}

Measured memory_bytes: 17336
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
#define int ll
signed main(){
    int a,b,n; cin>>a>>b>>n;
    int ans=INF*INF;
    for(int i=1; i<=100;i++){
        for(int j=1; j<=100; j++){
            if(i>n||j>n)continue;
            if(b*j%i)continue;
            cmin(ans,abs(abs(a-b*j/i)));
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  printf("%.10f\n", (double)((int)(n + 1) / 2) / n);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
const int MAX = 2e5 + 111;

int n;

int a[MAX];

int main() {
#ifdef LOCAL
    freopen("xxx.in", "r", stdin);
    freopen("xxx.out", "w", stdout);    
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    ll s = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        s += a[i];
    }
    ll cur = 0;
    ll ans = 1e18;
    for (int i = 0; i < n - 1; ++i) {
        cur += a[i];
        ans = min(ans, abs(cur - (s - cur)));
    } 
    cout << ans;
    return 0;
}

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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
ll n,k;

int main() {
    ll m, i, j;
    cin >> n >> k;
    vector<ll> A(n);
    for(i=0;i<n;i++){
        cin >> A[i];
        A[i]--;
    }
    ll dp[n]={};
    ll sum[n+1] = {};
    sum[1] = A[0];
    map<ll,ll> mp;
    for(i=0;i<n;i++){
        sum[i+1] = (sum[i]+A[i])%k;
    }
    ll ret = 0;
    for(i=0;i<=n;i++){
        if(mp.count(sum[i]))ret+=mp[sum[i]];
        mp[sum[i]]++;
        if(i>=k-1){
            mp[sum[i-k+1]]--;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 17408
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 314159
#define  vi vector<int>
#define  v  vector

signed main() 
{
        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
        int r,g,b,n;
        cin>>r>>g>>b>>n;
        
        int ans = 0;
        
        forn(i,0,3000)forn(j,0,3000)if(n-i*r-j*g>=0 and (n-i*r-j*g)%b==0)ans++;
        cout<<ans;


        return 0;

}

//       g++ -g c.cpp ; ./a.exe

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

//#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int N;

string Name[40];
vector<string>to[40];
vint G[40];
int val[40];

pint bef[1<<20],aft[1<<20];
bool used[40];
void solve(){

    fill_n(bef,1<<20,pint(-1,-1));
    fill_n(aft,1<<20,pint(-1,-1));

    rep(i,N){
        cin>>Name[i];
        cin>>val[i];
        int m;cin>>m;
        to[i].resize(m);
        rep(j,m)cin>>to[i][j];
    }

    rep(i,N){
        G[i].resize(to[i].size());
        rep(j,to[i].size()){
            int hoge=find(Name,Name+N,to[i][j])-Name;
            G[i][j]=hoge;
        }
    }

    int a=N/2;
    int b=N-a;

    bef[0]=mp(0,0);
    rep(i,1<<a){
        if(bef[i].first==-1)continue;
        rep(j,a){
            if(bef[i].second>>j&1)continue;
            int b=bef[i].second|(1<<j);
            rep(k,G[j].size())if(G[j][k]<a)b|=(1<<G[j][k]);
            bef[i|(1<<j)].first=bef[i].first+val[j];
            bef[i|(1<<j)].second=b;
        }
    }
    aft[0]=mp(0,0);
    rep(i,1<<b){
        if(aft[i].first==-1)continue;
        rep(j,b){
            if(aft[i].second>>j&1)continue;
            int b=aft[i].second|(1<<j);
            rep(k,G[j+a].size())if(G[j+a][k]>=a)b|=(1<<(G[j+a][k]-a));
            aft[i|(1<<j)].first=aft[i].first+val[j+a];
            aft[i|(1<<j)].second=b;
        }
    }



    rep(i,1<<b){
        rep(j,b){
            if((i>>j&1)==0)continue;
            chmax(aft[i].first,aft[i^(1<<j)].first);
        }
    }


    int ans=0;
    rep(i,1<<a){
        if(bef[i].first==-1)continue;
        if((i&1)==0)continue;
        memset(used,0,sizeof(used));
        rep(j,a){
            if(i>>j&1)rep(k,G[j].size())used[G[j][k]]=true;
        }

        int bit=(1<<b)-1;
        for(int j=a;j<N;j++){
            if(used[j])bit^=1<<(j-a);
        }
        chmax(ans,bef[i].first+aft[bit].first);
    }
    cout<<ans<<endl;
}

int main(){
    while(scanf("%d",&N),N)solve();
}

Measured memory_bytes: 17792
//  Created by conan1024hao in 2020.
//  Copyright © 2020 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e17
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------
bool color[1001][1001];ll m[30];
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????统一类型        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    string s;cin>>s;
    int l=0,r=0;
    int cnt=0;
    for(int i=0;i<n;i++){
        if(s[i]=='(')l++;
        else{
            if(l){
                l--;
            }
            else{
                cnt++;
            }
        }
    }
    while(cnt--){
        s='('+s;
    }
    cnt=0;
    n=s.length();
    for(int i=n-1;i>=0;i--){
        if(s[i]==')'){
            r++;
        }
        else{
            if(r){
                r--;
            }
            else{
                cnt++;
            }
        }
    }
    while(cnt--){
        s=s+')';
    }
    cout<<s<<Endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------








Measured memory_bytes: 256
import bisect
N, M, *AB = [int(_) for _ in open(0).read().split()]
AB = sorted(zip(AB[::2], AB[1::2]))
l, r = AB[0]
ans = 1
for a, b in AB[1:]:
    if r <= a:
        l, r = a, b
        ans += 1
    else:
        r = min(r, b)
print(ans)


Measured memory_bytes: 31692
let n, d = Scanf.scanf " %d %d" @@ fun a b -> a, b
let xss = Array.init n @@ fun _ -> Array.init d @@ fun _ -> Scanf.scanf " %d" (+) 0
let g x = x * x
let f ys zs = Array.mapi (fun i y -> g @@ y - zs.(i)) ys |> Array.fold_left (+) 0
let h n = let rec f i = if i * i >= n then i * i = n else f (i + 1) in f 0
let ans = ref 0
let _ = Array.iteri (fun i xs -> for j = i + 1 to n - 1 do if h @@ f xs xss.(j) then incr ans done) xss; Printf.printf "%d\n" !ans

Measured memory_bytes: 384
N = int(input())
a_list = list(map(int, input().split()))

a_sorted_list = sorted(a_list, reverse=True)

score_Alice = 0
score_Bob = 0

for i in range(N):
  if i % 2 == 0:
    score_Alice += a_sorted_list[i]
  else:
    score_Bob += a_sorted_list[i]

print(score_Alice - score_Bob)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
ll a[1000],b[1000],ind[1000];
bool comp(ll i,ll j){
	return a[i]<a[j];
}
void solve(){
	ll n,res=0;
	cin>>n;
	for(ll i=1;i<=2*n;i++){
		cin>>a[i]>>b[i];
		ind[i]=i;
	}
	sort(ind+1,ind+2*n+1,comp);
	set<ll> s;
	for(ll qc=1;qc<=2*n;qc++){
		ll i=ind[qc];
		if(i<=n)
			s.insert(b[i]);
		else{
			auto it=s.lower_bound(b[i]);
			if(!s.empty()&&it!=s.begin()){
				--it;
				s.erase(it);
				res++;
			}
		}
	}
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++){
        solve();
    }
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}

Measured memory_bytes: 3756
#include<stdio.h>
#include<string.h>

int main()
{
    char a[50],b[50],c[50];
    int i=0,len;
    scanf("%s",a);
    len=strlen(a);
    scanf("%s",b);
    scanf("%s",c);
    if(a[len-1]==b[0]){
        len=strlen(b);
        if(b[len-1]==c[0]) printf("YES\n");
        else printf("NO\n");
    }
    else    printf("NO\n");

    return 0;
}


Measured memory_bytes: 128
import java.lang.reflect.Array;
import java.util.*;

import static java.lang.Math.abs;

class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String c = sc.next();
        String[] b =  new String[c.length()];
        String[] d = new String[c.length()];
        b = c.split("");
        d = c.split("");
        int count =0;
        for(int i =0; i < c.length()-1 ; i++){
            if(b[i].equals(b[i+1])){
               b[i+1] = Integer.toString(abs(Integer.parseInt(b[i+1]) - 1));
            count ++;
            }
        }
        int count1 =1;
        d[0] = Integer.toString(abs(Integer.parseInt(d[0]) - 1));
        for(int k=0; k < c.length() - 1; k++){
            if(d[k].equals(d[k+1])){
                d[k+1] = Integer.toString(abs(Integer.parseInt(d[k+1]) - 1));
                count1 ++;
            }
        }
        if(count <= count1){
            System.out.println(count);
        }else if(count > count1){
            System.out.println(count1);
        }
    }
}


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

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

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

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

	int n, x;
	
	cin >> n >> x;

	if ((x == 1) || (x == 2 * n -1))
	{
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	if (n == 2)
	{
		cout << 1 << endl << 2 << endl << 3 << endl;
		return 0;
	}

	if (x == 2)
	{
		int t = 5;
		rep(i, n*2-1)
		{
			if (i == n-2)
			{
				cout << 3 <<  endl;
			}
			else if ( i == n - 1)
			{
				cout << 2 << endl;
			}
			else if (i == n)
			{
				cout << 1 << endl;
			}
			else if (i == n + 1)
			{
				cout << 4 << endl;
			}
			else
			{
				cout << t++ << endl; 
			}
		}
	}
	else
	{
		int t = 1;
		rep(i, n * 2 - 1)
		{
			if (i == n-2)
			{
				cout << x-1 <<  endl;
			}
			else if ( i == n - 1)
			{
				cout << x << endl;
			}
			else if (i == n)
			{
				cout << x+1 << endl;
			}
			else if (i == n + 1)
			{
				cout << x - 2 << endl;
			}
			else
			{
				if (t == x-2)
				{
					t = x + 2;
				}
				cout << t++ << endl; 
			}
		}
	}
	

	return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	char c=getchar();int t=0,f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n,m,k;
int main()
{
	n=read(),m=read();
	m+=n*3;
	printf("%d\n",m/2);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
const int INF = 1e9;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    rep(i, 0, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
    }
    int S, T;
    cin >> S >> T;
    S--, T--;
    using P = pair<int, int>;
    priority_queue<P, vector<P>, greater<P>> PQ;
    vector<vector<int>> dist(N, vector<int>(3, INF));
    PQ.push({0, S});
    dist[S][0] = 0;
    while(!PQ.empty()) {
        P t = PQ.top(); PQ.pop();
        int cur = t.second;
        int cost = t.first;
        int ncost = cost + 1;
        for(auto to : G[cur]) {
            if(dist[to][ncost % 3] > dist[cur][cost % 3] + 1) {
                dist[to][ncost % 3] = dist[cur][cost % 3] + 1;
                PQ.push({dist[to][ncost % 3], to});
            }
        }
    }
    if(dist[T][0] == INF) cout << -1 << endl;
    else cout << dist[T][0] / 3 << endl;
    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 

using namespace __gnu_pbds;
using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll i = 0; i < n; i++)
#define FORN(i, a, b) for (ll i = a; i < b; i++)
#define FORE(i, l) for (auto i : l)

#define pb push_back
#define pob pop_back
#define emp emplace
#define fi first
#define se second

#define all(n) n.begin(), n.end()
#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);	
    //cout << setprecision(15);
    ll n; string s;
    cin >> s;
    n = s.size();
    ll x = 0;
    ll ans = 0;
    FOR(i, n)
    {
        if (s[i] == 'B') x++;
        else ans += x;
    }
    cout << ans << '\n';
}



Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
using namespace std;
int main() {
	long long n, k;
	long long ans = 0;
	cin >> n >> k;
	long long k1 = 1;
	long long k2 = 1;
	if (n == 1) {
		cout << "1" << endl;
		return 0;
	}
	for (;;) {
		n = n / k;
		ans++;
		if (n < k) {
			cout << ans+1 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
import bisect
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)


n = int(input())
A = list(map(int, input().split()))
edges = [[]for _ in range(n)]
for _ in range(n-1):
    u, v = list(map(lambda x: int(x)-1, input().split()))
    edges[u].append(v)
    edges[v].append(u)
INF = 10**18
ans = [INF]*n

def dfs(v, parent):
    x = bisect.bisect_left(lis, A[v])
    prev = lis[x]
    lis[x] = A[v]
    ans[v] = bisect.bisect_left(lis, INF)
    for v2 in edges[v]:
        if v2 == parent:
            continue
        dfs(v2, v)
    lis[x] = prev


lis = [INF]*n
dfs(0, -1)
for x in ans:
    print(x)


Measured memory_bytes: 224700
#include <iostream>
#include <set>
#define llint long long

using namespace std;

llint n;
llint a[10005], b[10005];
set<llint> S;

int main(void)
{
	cin >> n;
	for(llint i = n; i >= 0; i--) cin >> b[i];
	
	llint k = 0;
	for(llint i = 0; i <= n; i++){
		if(b[i]){
			k = i;
			break;
		}
	}
	for(llint i = 0; i <= n-k; i++) a[i] = b[i+k];
	n -= k;
	
	llint m = abs(a[0]);
	for(llint i = 1; i*i <= m; i++){
		if(m%i) continue;
		S.insert(i), S.insert(m/i);
	}
	for(int i = 1; i <= n+k; i++) S.insert(i);
	
	for(auto p : S){
		bool flag = true;
		if(p == 1) flag = false;
		for(llint i = 2; i*i <= p; i++){
			if(p % i == 0){
				flag = false;
				break;
			}
		}
		if(!flag) continue;
		
		for(llint i = 0; i <= n; i++){
			b[i] = a[i];
			if(b[i] < 0) b[i] = p - (-b[i]) % p;
			b[i] %= p;
		}
		for(llint i = n; i >= p-1; i--){
			if(b[i] == 0) continue;
			if(k == 0 && i == p-1) continue;
			b[i-(p-1)] += b[i], b[i-(p-1)] %= p;
			b[i] = 0;
		}
		
		flag = true;
		for(llint i = 0; i <= n; i++){
			if(b[i]) flag = false;
		}
		if(flag) cout << p << endl;
	}
	return 0;
}

Measured memory_bytes: 896
using System;
using System.Collections.Generic;
using System.Linq;

class A
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var es = new int[n - 1].Select(_ => Read()).ToArray();

		Console.WriteLine(Diameter(n - 1, 0, es));
	}

	static long Diameter(int n, int sv, int[][] es)
	{
		var map = Array.ConvertAll(new int[n + 1], _ => new List<int[]>());
		foreach (var e in es)
		{
			map[e[0]].Add(new[] { e[1], e[2] });
			map[e[1]].Add(new[] { e[0], e[2] });
		}

		var d = Distances(n, sv, map);
		var ev = Enumerable.Range(0, n + 1).OrderBy(v => -d[v]).First();
		return Distances(n, ev, map).Max();
	}

	static long[] Distances(int n, int sv, List<int[]>[] map)
	{
		var from = new int[n + 1];
		var d = new long[n + 1];
		var q = new Queue<int>();
		from[sv] = -1;
		q.Enqueue(sv);

		while (q.Count > 0)
		{
			var v = q.Dequeue();
			foreach (var e in map[v])
			{
				if (e[0] == from[v]) continue;
				from[e[0]] = v;
				d[e[0]] = d[v] + e[1];
				q.Enqueue(e[0]);
			}
		}
		return d;
	}
}



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

#define ri register int
#define ssd 10000010
#define sid 205

int n, N = 1e7;
int pr[ssd / 10], tot;
int nj, no, js[sid], os[sid];
bool nop[ssd], e[ssd];

int tim, vis[sid], mat[sid];
bool ex[sid][sid];

inline void Init() {
    for(ri i = 2; i <= N + 1; i ++) {
        if(!nop[i]) pr[++ tot] = i;
        for(ri j = 1; j <= tot; j ++) {
            int nx = i * pr[j]; if(nx > N + 1) break;
            nop[nx] = 1; if(i % pr[j] == 0) break;
        }
    }
    nop[1] = nop[2] = 1;
}

inline int dfs(int o) {
    for(int i = 1; i <= no; i ++)
    if(ex[o][i] && vis[i] != tim) {
        vis[i] = tim;
        if(!mat[i] || dfs(mat[i])) 
        return mat[i] = o, 1;
    }
    return 0;
}

int main() {
    Init();
    cin >> n;
    for(ri i = 1; i <= n; i ++) { int x; cin >> x; e[x] = 1; }
    
    for(ri i = 1; i <= N + 1; i ++)
    if(e[i] != e[i - 1]) {
        if(i & 1) js[++ nj] = i;
        else os[++ no] = i;
    }

    for(ri i = 1; i <= nj; i ++)
    for(ri j = 1; j <= no; j ++)
    if(!nop[abs(js[i] - os[j])]) ex[i][j] = 1;

    int num = 0, ans = 0;

    for(ri i = 1; i <= nj; i ++)
    ++ tim, num += dfs(i);

    nj -= num; no -= num;
    ans = num + nj / 2 * 2 + no / 2 * 2 + (nj & 1) * 3;
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;
mt19937_64 rng(58);

const int MxN = 2 * 100000 + 1;
long long a[MxN];
long long c[MxN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        c[a[i]]++;
    }
    long long ans = 0;
    for (int i = 1; i < MxN; i++) {
        ans += c[i] * (c[i] - 1) / 2;
    }
    for (int i = 0; i < n; i++) {
        cout << ans - c[a[i]] + 1ll << "\n";
    }
}

Measured memory_bytes: 4736
import string
characters = "0123456789"
def base_cvt(value, n=2):
    result = ''
    tmp = value
    while tmp >= n:
        idx = tmp % n
        result = characters[idx] + result
        tmp = int(tmp / n)
    idx = tmp % n
    result = characters[idx] + result
    return result
def resolve():
    n,k = map(int,input().split())
    print(len(base_cvt(n,k)))
resolve()

Measured memory_bytes: 3768
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    int c=0;
    for(int i=0;i<(n)/2;i++){
        if(s[i]!=s[n-1-i]){
            c+=1;
        }
    }
    cout<<c;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n = 1e6;
int t[5][5];
ll h,a,b,c,d,e;
int ans = 1;
bool memo[15][15] = {0};
int main(){
  ll m,n;
  cin >> n ;
  deque<ll> que;
  for(int i=0 ; i<n ; i++){
    ll x; cin >> x;
    if((n-i)%2 == 0)  que.push_back(x);
    else que.push_front(x);
  }
  for(int i=0 ; i<n ; i++){
    cout << que.front() << " ";
    que.pop_front();
  }
  return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
int n;
int main() {
    int x;
    scanf("%d",&n);
    long long cur = 1, ans = 1;
    for(int i=1;i<=n;i++) {
        ans *= 3;
        scanf("%d",&x);
        if(x%2==0) cur*=2;
    }
    printf("%lld",ans-cur);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  
  int ans=0;
  int x=0;
  
  for(int i=0;i<N;i++){
    ans++;
    
if(a[x]==2){
  cout<<ans<<endl;
  break;
}
    
    if(i==N-1&&a[x]!=2){
cout<<"-1"<<endl;
      break;
    }
     x=(a[x]-1);
  }
}

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

int main(){
 int n,m,A[100][100],b[100],c[100];
    
  cin >> n >> m;
  for ( int i = 0; i < n; i++ )
   for ( int j = 0; j < m; j++ ) cin >> A[i][j];
  for ( int i = 0; i < m; i++ ) cin >> b[i];
      
     for ( int i = 0; i < n; i++ ){
       c[i] = 0;
      for ( int j = 0; j < m; j++ ){
        c[i] += A[i][j]*b[j];
      }
     }
    
  for ( int i = 0; i < n; i++ ) cout << c[i] << endl;
    
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll comb(int now){
    ll res;
    return (ll)now*(now-1)/2;
}

int main(){
    int n;
    cin >> n;
    vector<string> a;
    rep(i,n){
        string t;
        cin >> t;
        sort(t.begin(),t.end());
        a.push_back(t);
    }
    sort(a.begin(),a.end());
    int now=1;
    ll ans=0;
    rep(i,n-1){
        if(a[i]==a[i+1]){
            now++;
        }
        else{
            ans+=comb(now);
            now=1;
        }
    }
    ans+=comb(now);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5748