akhauriyash/Code-Regression huggingface dataset:
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.exception, std.typecons, std.container;

  int h, w; rd(h, w);
  auto c=new char[][](h, w);
  foreach(i; 0..h) c[i]=readln.chomp.to!(char[]);

  auto n=h*w;
  alias E=Tuple!(int, "to", int, "cost");
  auto g=new E[][](n);
  auto dir=[[1, 0], [-1, 0], [0, 1], [0, -1]];
  foreach(i; 0..h)foreach(j; 0..w){
    if(c[i][j]=='#') continue;
    foreach(dd; dir){
      auto ai=i+dd[0], aj=j+dd[1];
      if(ai<0 || ai>=h || aj<0 || aj>=w) continue;
      if(c[ai][aj]=='.'){
        g[i*w+j]~=E(ai*w+aj, 1);
        g[ai*w+aj]~=E(i*w+j, 1);
      }
    }
  }
  auto d=new int[](n);
  const int inf=1e9.to!(int);
  fill(d, inf);
  alias P=Tuple!(int, "v", int, "dist");
  auto Q=new RedBlackTree!(P, "a.dist<b.dist", true);
  d[0]=0; Q.insert(P(0, 0));
  while(Q.empty==false){
    auto cur=Q.front; Q.removeFront;
    foreach(e; g[cur.v]){
      if(d[e.to]<=d[cur.v]+e.cost) continue;
      d[e.to]=d[cur.v]+e.cost;
      Q.insert(P(e.to, d[e.to]));
    }
  }
  if(d[n-1]==inf){writeln(-1); return;}

  int bk=0;
  foreach(i; 0..h) bk+=count(c[i], '#');
  auto res=n-bk-(d[n-1]+1);
  enforce(res>=0);
  writeln(res);
}
void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 1020
#include<algorithm>
#include<iostream>

int main(){
  int n;
  std::cin >> n;
  int a[n];
  for(int i = 0; i < n; i++)
    std::cin >> a[i];
  std::sort(a, a + n);
  std::cout << a[n - 1] - a[0] << std::endl;
  return 0;
}


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

using namespace std;

using ui64 = unsigned long long;

ui64 g(ui64 x) {
    return ((x&1)?0:~(~x|1))|(((x+1)>>1)&1);
}

ui64 f(ui64 a, ui64 b) {
    return g(a) ^ a ^ g(b);
}

int main() {
    ui64 a, b;
    cin >> a >> b;
    cout << f(a, b) << endl;
    return 0;
}



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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll N; cin >> N;
    ll res = 1;
    vector<ll> v;
    REP(i, N) {
        ll tmp; cin >> tmp;
        v.push_back(tmp);
    }
    sort(v.begin(),v.end());
    if (v[0] == 0) {
        cout << 0 << endl;
        return 0;
    }
    for (auto x: v) {
        ll cur_res = res;
        res *= x;
        if (cur_res > res || res > 1000000000000000000) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 4264
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// まずは全探索，次にDP
// 偶奇，逆から，ソート，出現回数，出現位置，DP
// 余事象，包除
// データ構造
// 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
int main() {
cin.tie(0);
ios::sync_with_stdio(false);

int64_t N; cin >> N;

//素数だと，真横か真下にN-1 回移動
//たぶん，ルートN に近い因数の組
Rrep(i, (int)sqrt(N), 1){
    if (N%i == 0) {cout << (i-1) + (N/i - 1) <<"\n"; return 0;}
}

}

// 境界，出力文字列 チェック



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <unordered_set>
#include <cmath>
#include <climits>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 201

using namespace std;

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

	int N, A;
	cin >> N >> A;
	cout << N * N - A;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 36

typedef struct{
	char mark;
	int number;
} card_t;

void Bubblesort(card_t a[],int n){
	char c1;
	int i,j,c2;
	for(i=0;i<n;i++){
		for(j=n-1;j>i;j--){
			if(a[j].number<a[j-1].number){
				c1=a[j].mark;
				c2=a[j].number;
				a[j].mark=a[j-1].mark;
				a[j].number=a[j-1].number;
				a[j-1].mark=c1;
				a[j-1].number=c2;
			}
		}
	}
	
	for(i=0;i<n;i++){
		if(i>0){
			printf(" ");
		}
		printf("%c%d",a[i].mark,a[i].number);
		if(i==n-1){
			printf("\n");
		}
	}
}

void Selectionsort(card_t a[],int n){
	char c1;
	int c2,i,j,min;
	for(i=0;i<n;i++){
		min=i;
		for(j=i;j<n;j++){
			if(a[j].number<a[min].number){
				min=j;
			}
		}
		c1=a[i].mark;
		c2=a[i].number;
		a[i].mark=a[min].mark;
		a[i].number=a[min].number;
		a[min].mark=c1;
		a[min].number=c2;
	}
	for(i=0;i<n;i++){
		if(i>0){
			printf(" ");
		}
		printf("%c%d",a[i].mark,a[i].number);
		if(i==n-1){
			printf("\n");
		}
	}
}

int Stable(card_t a[],card_t b[],int n){
	int i;
	
	for(i=0;i<n;i++){
		if(a[i].mark!=b[i].mark){
			return 0;
		}
	}
	return 1;
}

int main(void){
	card_t  a[N],b[N];
	int i,n;
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf(" %c",&a[i].mark);
		scanf(" %d",&a[i].number);
	}
	
	for(i=0;i<n;i++){
		b[i]=a[i];
	}
	
	Bubblesort(a,n);
	
	printf("Stable\n");
	
	Selectionsort(b,n);
	
	if(Stable(a,b,n)==1){
		printf("Stable\n");
	}
	
	else{
		printf("Not stable\n");
	}
	
	return 0;
}


Measured memory_bytes: 2032
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int n,q,a,c=0,i,j;
	vector<int> S;
	scanf("%d",&n);
	S.resize(n);
	for(i=0; i<n; ++i) {
		scanf("%d",&S[i]);
	}
	sort(S.begin(),S.end());
	scanf("%d",&q);
	for(j=0; j<q; ++j) {
		i=0;
		scanf("%d",&a);
		while(i<n) {
			if(S[i]>a) break;
			if(S[i]==a) {
				++c;
				break;
			}
			++i;
		}
	}
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 2788
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    int N; cin >> N; N++;
    int cnt_one = __builtin_popcount(N);

    bool first = true;
    vector<int> ans;
    int rec = 0;
    repr(i,60,0) {
        if(N >> i & 1) {
            if(first) {
                first = false;
                ans.resize(i);
                iota(ans.begin(), ans.end(), 1);
                rec = ans.size();
                rep(k,0,rec) ans.push_back(ans[k]);
            }
            else {
                ans.insert(ans.begin()+i, ++rec);
                ans.push_back(rec);
            }
        }
    }
    cout << ans.size() << endl;
    rep(i,0,ans.size()) {
        if(i != 0) printf(" ");
        printf("%lld", ans[i]);
    }
    cout << endl;
    return 0;
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A=in();
    int B=in();
    int ans;ans=6/(A*B);
    print(ans);
    return 0;
}


Measured memory_bytes: 3584
import java.util.*;
class Main {
	public static int j;
	public static int y;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		j = stdIn.nextInt();
		y = stdIn.nextInt();
		
		solv(0,0,new int[10],0);
	}
	
	public static void solv(int a, int b, int[] c,int d) {
		if(a == j && b == y) {
			for(int i = 0; i < d; i++) {
				System.out.print((c[i] == 1)?"A":"B");
			}
			System.out.println();
			return;
		}
		if(a > j || b > y) {
			return;
		}
		if((a == 5 && b <= 3) || (a <= 3 && b == 5)) return;
		if(a == 5 && b == 5) return;
		int[] ca = new int[10];
		int[] cb = new int[10];
		for(int i = 0; i < d; i++) {
			ca[i] = c[i];
			cb[i] = c[i];
		}
		ca[d] = 1;
		cb[d] = 0;
		solv(a+1,b,ca,d+1);
		solv(a,b+1,cb,d+1);
	}
}

Measured memory_bytes: 17360
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define MAX 1000000
#define mo 1000000007 
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

bool prime[MAX + 1]; 
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
  
    prime[1] = false; 
  
    for (int p = 2; p * p <= MAX; p++) { 
  
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) { 
  
            // Set all multiples of p to non-prime 
            for (int i = p * 2; i <= MAX; i += p) 
                prime[i] = false; 
        } 
    } 
} 
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll modexp(ll x, ll y, ll p)
{
ll res = 1;   
x = x % p;  
    while (y > 0)
    {
        if (y & 1)    
            res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}
class gfg 
{ 
 public : ll gcd(ll a, ll b)  
 {  
    // Everything divides 0  
    if (a == 0 || b == 0)  
        return 0;  
   
    // Base case     
    if (a == b)  
        return a;  
   
    // a is greater  
    if (a > b)  
        return gcd(a-b, b);  
    return gcd(a, b-a);  
 } 
  
   
// Function to return LCM of two numbers  
  ll lcm(ll a, ll b)  
 {  
    return (a*b)/gcd(a, b);  
 }  
} ;
ll mypow(ll b, ll e) {
    ll ans=1; for(;e;b=b*b%mo,e/=2) if(e&1) ans=ans*b%mo; return ans;}
ll power2(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y % 2 == 0) 
        return power2(x, y / 2) * power2(x, y / 2); 
    else
        return x * power2(x, y / 2) * power2(x, y / 2); 
} 
ll mod=100000000;
#define MAXN 100001
ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
}
ll dp[1002][1002];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll h,w;
	cin>>h>>w;
	vector <string> a(h);
	rep(i,h)
	{
		cin>>a[i];
	}
	memset(dp,0,sizeof(dp));
	dp[h][w]=1;
	for(ll i=h;i>=1;i--)
	{
		for(ll j=w;j>=1;j--)
		{
			if(i==h && j==w)
			continue;
			if(a[i-1][j-1]=='#')
			{
				dp[i][j]=0;
				continue;
			}
			if(j==w)
			dp[i][j]=dp[i+1][j];
			else if(i==h)
			dp[i][j]=dp[i][j+1];
			else
			dp[i][j]=(dp[i+1][j]+dp[i][j+1])%mo; 
		}
	}
	cout<<dp[1][1]<<endl;
	return 0;
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define pi pair<int, int>
#define ppi pair<pair<int, int>, int>
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
#define INF (ll)1e18
#define s(v) v.size()
#define e(v) v.empty()

using namespace std;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);}
// bool sortbysec(const pll &a, const pll &b){return (a.second < b.second);} 
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
        ll n, m;
        cin>>n>>m;
        if((n+m)&1) cout<<"IMPOSSIBLE";
        else cout<<(n+m)/2;
    }
}

Measured memory_bytes: 256
N = int(input())
*A, = map(int, input().split())

C = {}
for a in A:
    C[a] = C.get(a, 0) + 1

ok = 1
if N % 3 != 0:
    if C.get(0, 0) != N:
        ok = 0
else:
    p = []
    K = N // 3
    for k, v in C.items():
        if v % K != 0:
            ok = 0
        for i in range(v // K):
            p.append(k)
    if ok:
        a, b, c = p
        if a ^ b != c:
            ok = 0
print("Yes" if ok else "No")

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


int fib(int n , int t , int p1 , int p2){

  if( n==t )return p1+p2;

  return fib(n+1,t,p2,p1+p2);
  
}


int main(){

  int n;

  cin >> n;

  if(n==0 || n==1)cout << 1 << endl;
  else
    cout << fib(2,n,1,1) << endl;

  return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
      int N;
      
      Scanner sc = new Scanner(System.in);
      N = sc.nextInt(); //入力数
      
      int[][] int2Array;   //Int型の2次元配列intArrayを宣言
      int2Array = new int[2][N];  //N個のInt型データを持つ2次元配列intArrayを生成

      //入力数分、読み込んで配列に入れる

      //(1)初期値i=0、iがN以下の間forループ内を実行 配列に数値を入れる
      for(int i = 0; i < N; i++) {
        int2Array[0][i] = i+1;
        int2Array[1][i] = sc.nextInt();
      }

      
      //配列をクイックソートする
      quick_sort(int2Array, 0, N-1);


      for(int i = 0; i < N; i++) {
        System.out.println(int2Array[0][i]);
      }
      
      
    }

    // 配列dのleftからrightまでの間のデータ列をクイックソートする
    static void quick_sort(int[][] d, int left, int right) {
        if (left >= right) {
            return;
        }
        int partition = d[1][(left+right)/2];
        int L = left, R = right;
        int[] temp = new int[2] ; //2つの要素の配列を宣言
        while(L<=R) {
            while(d[1][L] < partition) { L++; }
            while(d[1][R] > partition) { R--; }
            if (L<=R) {
                temp[0] = d[0][L];
                temp[1] = d[1][L];
                
                d[0][L] = d[0][R];
                d[1][L] = d[1][R];
                
                d[0][R] = temp[0];
                d[1][R] = temp[1];
                
                L++; R--;
            }
        }
        quick_sort(d, left, R);  // ピボットより左側をクイックソート
        quick_sort(d, L, right); // ピボットより右側をクイックソート

    }

}

Measured memory_bytes: 64248
#include<bits/stdc++.h>
using namespace std;
int main(void){

  int N, K;  cin >> N >> K;
  int ans = (N - 1) / (K - 1) ;
  if((N - 1) % (K - 1)) ans += 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
int main(int argc, char const* argv[])
{
	long long x, i;
	i = 1;
	std::cin >> x;
	while (x!=0) {
		std::cout << "Case " << i << ": " << x << std::endl;
		i++;
		std::cin >> x;
	}

	return 0;
}

Measured memory_bytes: 1156
#include<iostream>
using namespace std;
void yes()
{
    cout<<"Yes"<<endl;
}
void no()
{
    cout<<"No"<<endl;
}
int main()
{
    int w,h,x,y,r;
    cin>>w>>h>>x>>y>>r;
    if(r>x||r>y||x+r>w||y+r>h)
    {
        no();
    }
    else
    {
        yes();
    }
    
    
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int A[26]={0};
  string ans="None";
  for(int i=0;i<S.size();i++) A[S[i]-'a']++;
  for(int i=0;i<26;i++){
    if(A[i]==0){
      ans=char(i+'a');
      break;
    }
  }
  cout<<ans<<endl;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{   
    gearup;
    int n; cin >> n;
    vl a(n);
    rep(i,n)cin >> a[i];
    ll res = 0;
    for(int i=0;i<n;){
        int j = i;
        ll sum = 0;
        while(a[j] > 0 && j < n)sum+=a[j++];
        res+=sum/2;
        i = j+1;
    }
    out(res);
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

const int large = 1e5+1;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vi placed(large);
    ll total = 0;
    FOR(i,n){
        int a; cin >> a;
        total+= (ll)a;
        placed[a]++;
    }
    int q; cin >> q;
    FOR(i,q){
        int b,c; cin >> b >> c;
        ll dif = c-b;
        total += (ll)(placed[b]) * dif;
        placed[c] += placed[b];
        placed[b] = 0;
        cout << total << endl;
    }
    return 0;
}


Measured memory_bytes: 3708
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>
#include <queue>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
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 (a > b) {a = b; return 1;} return 0; }

typedef long long ll;
using namespace std;

int main() {
    
    int a, b, c;
    cin >> a >> b >> c;
    cout << a * b / 2 << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
unordered_set<string> strs;
vector<string> res;
void dfs(string & s, int max_idx){
    if(s.size() == n){
        if(strs.count(s) == 0){
            res.push_back(s);
            strs.insert(s);
        }
        return;
    } else {
        for(int i = 0; i < s.size(); i ++){
            s.push_back(s[i]);
            dfs(s, max_idx);
            s.pop_back();
        }
        s.push_back('a' + max_idx);
        dfs(s, max_idx + 1);
        s.pop_back();
    }
}
int main(){
    cin >> n;
    string curr;
    dfs(curr, 0);
    for(auto s: res){
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 14232
import java.util.*;
import java.io.*;

public class Main {
    static ArrayList<edge>[]graph;
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));

        StringTokenizer st=new StringTokenizer(f.readLine());

        int n = Integer.parseInt (st.nextToken());
        int m = Integer.parseInt (st.nextToken());
        graph=new ArrayList[n];
        for(int i=0;i<n;i++)
            graph[i]=new ArrayList<>();
        for(int i=0;i<m;i++){
            st = new StringTokenizer (f.readLine());
            int a = Integer.parseInt (st.nextToken())-1;
            int b = Integer.parseInt (st.nextToken())-1;
            graph[a].add(new edge(b));
        }
        dp=new long[n];
        long ans=0;
        for(int i=0;i<n;i++){
            ans=Math.max(ans,solve(i));
        }
        ans--;
        System.out.println(ans);
        f.close();

        //print to System. out.println

    }
    static long []dp;
    public static long solve(int idx){
        long ret=1;
        long add=0;
        if(dp[idx]!=0){
            return dp[idx];
        }

        for(int i=0;i<graph[idx].size();i++){
            add=0;
            add+=solve(graph[idx].get(i).to);
            ret=Math.max(add+1,ret);
        }
        dp[idx]=ret;
        return ret;
    }
}
class edge{
    int to;
    edge(int a){
        to=a;
    }
}

Measured memory_bytes: 58480
A,B = map(int, input().split())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(n**0.5//1)+1):
        if temp%i == 0:
            cnt = 0
            while temp%i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

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

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

list_a = factorization(A)
list_b = factorization(B)

temp_list = []
double_list = []
for i in range(len(list_a)):
    for j in range(len(list_b)):
        if list_a[i][0] == list_b[j][0]:
            temp_list = []
            index = None
            index = min(list_a[i][1], list_b[j][1])
            temp_list = [list_a[i][0], index]
            double_list.append(temp_list)
        else:
            pass

devision_num = 1
if double_list==[]:
    devision_num = 1
else:
    for i in range(len(double_list)):
        devision_num *= double_list[i][0]**double_list[i][1]

num_answer = None
a = 1
b = 1

for i in range(len(list_a)):
    a *= list_a[i][0]**list_a[i][1]

for j in range(len(list_b)):
    b *= list_b[j][0]**list_b[j][1]

num_answer = a*b//devision_num
print(num_answer)

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


def gcd(n, m):
    while(m > 0):
        n,m = m, n%m
    
    return n


def f(a, b, c):
    return b//c - (a-1)//c


def main():
    A,B,C,D = map(int, input().split())
    
    x = B - A + 1 - f(A,B,C) - f(A, B, D) + f(A, B, C*D//gcd(C, D))
    print(x)





if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <sstream>
#include <vector>
#include <map>
#include <cassert>
using namespace std;

int main(){
	int n;
	while(cin >> n && n){
		vector<int> a(n),b(n-1);
		long long sum = 0;
		for(int i = 0 ; i < a.size() ; i++)
			cin >> a[i] , sum += a[i];
		for(int i = 0 ; i < b.size() ; i++)
			cin >> b[i] , sum += b[i];
		long long ans = 0;
		sort(b.begin(),b.end());
		ans = sum;
		for(int i = 0 ; i < b.size() ; i++){
			sum -= b[i];
			ans = max( ans , sum * (i+2) );
		}
		cout << ans << endl;
		
	}
}

Measured memory_bytes: 1532
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var ai = one[0];
  var ao = one[1];
  var at = one[2];
  var aj = one[3];
  var al = one[4];
  var as = one[5];
  var az = one[6];
  var output1 = Math.floor(ai / 2) * 2 + Math.floor(aj / 2) * 2 + Math.floor(al / 2) * 2;
  var output2
  if(ai >= 1 && aj >= 1 && al >= 1){
    output2= Math.floor((ai - 1) / 2) * 2 + Math.floor((aj - 1) / 2) * 2 + Math.floor((al - 1) / 2) * 2 + 3;
  }else{
    output2 = 0;
  }
  myout(Math.max(output1, output2) + ao);
}


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

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

    for(int i : a)
    {
        sum += i;
    }

    if(sum > n)
    {
        cout << -1;
    }
    else
    {
        cout << n - sum;
    }
    

    return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int N;
    cin >> N;
    Graph G(200000);
    for (int i=0; i<N; ++i) {
        int x, y;
        cin >> x >> y;
        G[x-1].push_back(100000+y-1);
        G[100000+y-1].push_back(x-1);
    }

    vector<bool> used(200000, false);
    ll res = 0;
    queue<int> que;
    for (int i=0; i<200000; ++i) {
        if (used[i]) continue;
        used[i] = true;
        ll cntX = 0, cntY = 0, cntE = 0;
        que.push(i);
        while (!que.empty()) {
            int cur = que.front(); que.pop();
            if (cur < 100000) ++cntX;
            else ++cntY;
            cntE += (ll)G[cur].size();
            for (int nx : G[cur]) {
                if (!used[nx]) {
                    used[nx] = true;
                    que.push(nx);
                }
            }
       }
       res += cntX * cntY - cntE / 2;
    }
    cout << res << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 8192
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int i,n;cin>>n;
	vector<int>h(n,mod);
	vector<int>c(n,mod);
	for(i=0;i<n;i++){
		cin>>h[i];
		if(i==0){c[i]=0;}
		else if(i==1){c[i]=abs(h[i]-h[i-1]);}
		else{c[i]=min(abs(h[i]-h[i-1])+c[i-1],abs(h[i]-h[i-2])+c[i-2]);}
	}
	cout<<c.back()<<endl;
	return 0;
}


Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    x = ini()
    if x == 0:
        return 1
    else:
        return 0


print(solve())


Measured memory_bytes: 9172
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from itertools import accumulate
from collections import Counter

n = ni()
a = list(li())

acum = list(accumulate(a))
cnt = Counter(acum)

ans = 0

for k,v in cnt.items():
    if k == 0:
        ans += v + (v-1)*v//2
        
    else:
        ans += (v-1)*v//2
        
print(ans)

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

long lb(unsigned long a){
    long ret = 0;
    for(long s=32; s>0; s>>=1){
        if(a>>s){
            a >>= s;
            ret += s;
        }
    }
    return ret;
}

int main(void){
    long n;
    cin >> n;
    vector<long> v(n);
    for(long i=0; i<n; i++){
        cin >> v[i];
    }
    multiset<long,greater<long>> s(v.begin(), v.end());
    long cnt = 0;
    while(!s.empty()){
        const auto ix = s.begin();
        const auto y = (1l << lb(*ix<<1))-*ix;
        s.erase(ix);
        const auto iy = s.find(y);
        if(iy!=s.end()){
            s.erase(iy);
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 11136
require "prime"
def fnc(n)
  i = 1
  cnt = 0
  while n > 0
    n -= i
    if n >= 0
      cnt += 1
    end
    i += 1
  end
  return cnt
end


N = gets.chomp.to_i
f = N.prime_division
c = 0
f.each do |val|
  c += fnc(val[1])
end
puts c

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

int main(){
  int n;
  cin>>n;
  int last=0;
  int N=n*2;
  
  int a[N];
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  
  for(int i=0;i<2*n-5;i++){

    if(a[i]==a[i+1] and a[i+2]==a[i+3] and a[i+4]==a[i+5]){
      cout<<"Yes"<<endl;
      last=1;
      break;
    }
  }
    if(last==0){
      cout<<"No"<<endl;
    }
   
}

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

int main() {
	int n, k;
	string s;
	cin >> n >> k >> s;
	k--;
	for (int i = 0; i < n; i++) {
		cout << (char) (s[i] + (i - k ? 0 : 32));
	}
	cout << 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,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N;
int A[112345], ans[112345];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", A + i);
	
	
	REP(i, N) ans[A[i] - 1] = i;
	REP(i, N) printf("%d%c", ans[i] + 1, i == N - 1 ? '\n' : ' ');
	
	return 0;
}

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

int main(void)
{
	//変数の宣言
	char numchar[11];
	int num[11];
	int y[12];
	int i,j,k,l;
	int len;
	long temp=0;
	long sum=0;
	long ans=0;
	
	//データの読み込み
	scanf("%s",&numchar);
	
	
//	for(i=0;i<len;i++){
//		scanf("%d %d",&x[i],&y[i]);
//	}
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	
	len=strlen(numchar);
	for(i=0;i<len;i++){
		num[i]=numchar[i]-48;
	}
	
	for(i=0;i<(1<<len-1);i++){
		temp=num[0];
		for(j=0;j<len-1;j++){
			if(i&1<<j){
				temp=temp*10+num[j+1];
			}else{
				sum=sum+temp;
				temp=num[j+1];
			}
		}
		
		sum=sum+temp;
		ans=ans+sum;
//		printf("i=%d,sum=%d\n",i,sum);
		sum=0;
		temp=0;
	}
	
	
	
//	printf("計算部分終了\n");
	
	//出力
	
		printf("%ld",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
}



Measured memory_bytes: 128
import math
import numpy as np

n = int(input())
S=[]

for i in range(n):
    S.append(str(input()))
    

def Count_Alphabet(word):
    global alphabet
    string = str(word)
    alphabet=str("abcdefghijklmnopqrstuvwxyz")
    count = np.zeros(len(alphabet))
    
    for i in range(0,len(alphabet)):
        for j in range(0,len(string)):
            if alphabet[i] == string[j]:
                count[i] += 1    
    return count

cout = []

for i in range(n):
    cout.append(Count_Alphabet(str(S[i])))
    



ans = str()

for i in range(len(alphabet)):
    ith = []
    for j in range(n):
        ith.append(cout[j][i])
        
    min_i = min(ith)
    ans = ans + str(alphabet[i])*int(min_i)
    
print(ans)

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    vll x(5);
    cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];

    cout << distance(x.begin(), find(all(x), 0))+1 << endl;
}


Measured memory_bytes: 3648
import javax.print.DocFlavor;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;

public class Main {

    //グローバル変数を定義

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        System.out.println(a * b / 2);
    }
}


Measured memory_bytes: 23636
import itertools
N,K = map(int,input().split())
A = list(map(int,input().split()))
if K >= 50:
    print(*[N]*N)
    exit()
for i in range(K):
    newA = [0]*N
    for j in range(N):
        newA[max(0,j-A[j])] += 1
        if j+A[j]+1 < N:
            newA[min(N-1,j+A[j]+1)] -= 1
    A = list(itertools.accumulate(newA))
    if A == [N]*N:
        break
print(*A)

Measured memory_bytes: 177584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll A, B;
  cin >> A >> B;
  cout << max({A + B, A - B, A * B}) << endl;
}

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

bool prime(int n){
  int count = 0;
  for(int i=2; i<n; i++){
    if(n%i != 0){
      count++;
    }
  }
  if(count == n-2){
    return true;
  }
  else{
    return false;
  }
}
 
int main() {
  int X;
  cin >> X;
  int result = X-1;
  int c = 0;
  while (c == 0){
    result++;
    if (prime(result) == true){
      c++;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
N=int(input())
C0,C1,C2,C3=0,0,0,0

for i in range(N):
    s=input()
    if(s=="AC"):
        C0+=1
    elif(s=="WA"):
        C1+=1
    elif(s=="TLE"):
        C2+=1
    else:
        C3+=1
print("AC x",C0,"\nWA x",C1,"\nTLE x",C2,"\nRE x",C3)


Measured memory_bytes: 9184
/*
 * 0610.cc: Weather Forecaster
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int h, w;
  cin >> h >> w;

  for (int y = 0; y < h; y++) {
    string s;
    cin >> s;

    int c = -1;
    for (int x = 0; x < w; x++) {
      if (s[x] == 'c') c = 0;
      else if (c >= 0) c++;

      if (x > 0) putchar(' ');
      printf("%d", c);
    }
    putchar('\n');
  }
  return 0;
}

Measured memory_bytes: 1200
n = gets.to_i
P = gets.split.map(&:to_i).join.to_i
Q = gets.split.map(&:to_i).join.to_i
n_arr = [*1..n].permutation.to_a.map(&:join).map(&:to_i).sort

puts (n_arr.index(P) - n_arr.index(Q)).abs

Measured memory_bytes: 18904
import java.util.*;
import java.math.*;
import java.text.*;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int m = in.nextInt();
		for(int i=0; i<m; i++){
			int max = 0;
			int base = in.nextInt();
			int year = in.nextInt();
			int types = in.nextInt();
			for(int j=0; j<types; j++){
				int type = in.nextInt();
				double rate = in.nextDouble();
				int cost = in.nextInt();
				int result = 0;
				if(type == 0) result = tanri(base,year,rate,cost);
				else result = fukuri(base,year,rate,cost);
				if(max < result) max = result;
			}
			System.out.println(max);
		}
	}
	
	public static int tanri(int base, int year, double rate, int cost){
		int stock = base;
		int bnf = 0;
		for(int i=0; i<year; i++){
			bnf = bnf+(int)((double)stock*rate);
			stock = stock-cost;
		}
		return stock+bnf;
	}
	
	public static int fukuri(int base, int year, double rate, int cost){
		int stock = base;
		for(int i=0; i<year; i++){
			stock = (int)((double)stock*(1+rate))-cost;
		}
		return stock;
	}
}

Measured memory_bytes: 13000
#include<stdio.h>
#include<stdlib.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head=0, tail=0, n;

void enqueue(P x){
  Q[tail]=x;
  if(tail+1==n){
    tail=0;
  }
  else{
    tail++;
  }
}

P dequeue(){
  P x;
  x=Q[head];
  if(head+1==n){
    head=0;
  }
  else{
    head++;
  }
  return x;

}

int main(){
  int elaps = 0, c;
  int i, q,m;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
    enqueue(Q[i]);
  }
  m=n;
  while(1){
    u=dequeue();
    if(u.t<=0);
    else if(u.t<=q){
      elaps+=u.t;
      printf("%s %d\n",u.name,elaps);
      m--;
      if(m==0) break;
    }
    else{
      u.t-=q;
      elaps+=q;
      enqueue(u);
    }
  }
  return 0;
}






Measured memory_bytes: 6840
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
const int INF = 100100100;
using namespace std;
typedef long long ll;
int main()
{
  int N;
  priority_queue<pair<int, int> > pq;
  ll time = 0;
  cin >> N;
  
  rep(i,N) {
    int a, b;
    cin >> a >> b;
    pq.push(make_pair(-b, a));
  }
  while(!pq.empty()){
    pair<int, int> task=pq.top();
    time+=task.second;
    if(time+task.first>0){
      cout << "No" << endl;
      return 0;
    }
    pq.pop();
  }
  cout << "Yes" << endl;
  return 0;

}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  string s, t, u;
  ll a, b;
  cin >> s >> t >> a >> b >> u;

  if (s == u) a--;
  if (t == u) b--;
  cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
//#include<ctype.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)
//#define MAX(a,b) a>b?a:b
//#define MIN(a,b) a<b?a:b
typedef unsigned long long llu;

int main() {
	llu n;
	int ans = -1;
	S(llu, n);
	while (n>>=1&&ans++);
	P(d,ans);
	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int N, Q;
	string S;

	cin >> N >> Q;
	cin >> S;

	int *l = new int[Q];
	int *r = new int[Q];

	for( int i = 0;i < Q; i ++ ) {
		cin >> l[i];
		cin >> r[i];
	}

	int *ac = new int[N];
	{
		int num = 0;
		ac[0] = 0;
		for ( int i = 1; i < N; i ++ ) {
			if ( S[i-1] == 'A' && S[i] == 'C' ) num ++;
			ac[i] = num;
		}
	}


	for ( int i = 0; i < Q; i ++ ) {
		cout << (ac[r[i]-1] - ac[ l[i]-1 ]) << endl;
	}
}


Measured memory_bytes: 2176
let sort array n =
  let rec bubble_sort a c =
    let rec bubble c = function
      | 0 -> a,c
      | i ->
        bubble
          (if a.(i) < a.(i-1)
           then (let aj = a.(i-1) in
                 a.(i-1) <- a.(i); a.(i) <- aj; c+1)
           else c)
          (i-1)
    in
    match bubble 0 n with
      v,0 -> v,c
    | v,t -> bubble_sort v (c+t)
  in
  bubble_sort array 0
    
let () =
  let n = read_int () in
  let a = read_line () |> Str.split (Str.regexp " ")
          |> List.map int_of_string |> Array.of_list in
  let sorted,c = sort a (n-1) in
  Array.iteri
    (fun i x -> Printf.printf (if i=n-1 then "%d\n" else "%d ") x) sorted;
  Printf.printf "%d\n" c

Measured memory_bytes: 2296
#include <cstdio>
#include <cmath>
#include <queue>

const int N = 200000;
int n, k, a[N];

bool run(int v) 
{
	int k_ = k;
	for (int i = 0; i < n; ++i) k_ -= (a[i] - 1) / v;
	return k_ >= 0;
}

int main() 
{
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; ++i) scanf("%d", a + i);
	int l = 1, r = 1e9;
	int ans;
	while (l <= r) {
		int m = (l + r) >> 1;
		if (run(m)) {
			r = m - 1;
			ans = m;
		}
		else l = m + 1;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2460