akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

// 素数判定
// ret: 1 -> prime, 0-> not prime
int isPrime(LL p){
	if(p<=1) return 0;
	if(p==2 || p==3 || p==5 || p==7) return 1;
	if(p==4 || p==6 || p==8 || p==9) return 0;

	LL i;
	int ret = 1;
	for(i=2; i*i<=p; i++){
		if(p%i==0 && i!=p){
			ret = 0;
			break;
		}
	}
	return ret;
}

// 最大公約数を求める(ユークリッド互除法)
LL GCD(LL x, LL y){
        LL r=0;

	if( x<y ) swap(x, y);
        r = x % y;
        while(r!=0){
                x = y;
                y = r;
                r = x % y;
        }
        return y;
}

// N を素因数分解して mp に格納する。long longは素数、intは指数。
void factorize(long long N, map<long long, int> &mp){
	if(N == 1){
		return;
	}
	if(isPrime(N)){
		mp[N] += 1;
		return;
	}

	long long i = 2, n = N;
	for(i = 2; n != 1 && i < (N/2) + 1; i++){
		if((n % i)==0){
			if(isPrime(i)){
				int e = 0;
				long long u = n;
				while((u % i)==0){
					e++;
					u = u / i;
					n = u;
				}
				mp[i] = e;
				if(isPrime(n)){
					mp[n] = 1;
					break;
				}
			}
		}
	}
	return;
}

LL A, B;
int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> A >> B;
	long long D = GCD(A, B);
	map<LL, int> mp;
	factorize(D, mp);
	int P = mp.size();
	printf("%d\n", P + 1);
	return 0;
}

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

#define Debug(x) x
typedef int regular_int;
// #define int ll
typedef long long ll;

vector<int > G[100000];
int c[100000];
int res[100000];
int M;

regular_int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(12) << fixed;

	int N;
	cin >> N;
	for (int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a].push_back(b);
        G[b].push_back(a);
	}
	for (int i = 0; i < N; ++i) {
        cin >> c[i];
	}
	sort(c, c + N);
	M = N - 1;
	vector<int > active(1, 0);
	ll cnt = 0;
	while (!active.empty()){
        int pos = active.back();
        active.pop_back();
        res[pos] = c[M];
        if (pos){
            cnt += c[M];
        }
        --M;
        for (int i: G[pos]){
            if (!res[i]){
                active.push_back(i);
            }
        }
	}
	cout << cnt << endl;
	for (int i = 0; i < N - 1; ++i) {
        cout << res[i] << " ";
	}
	cout << res[N - 1] << endl;
	return 0;
}


Measured memory_bytes: 3200
def readinput():
    n=int(input())
    ab=[]
    for _ in range(n):
        a,b=map(int,input().split())
        ab.append((a,b))
    return n,ab

def main(n,ab):
    ab.sort(key=lambda x:x[1], reverse=True)
    t=ab[0][1]
    for i in range(n):
        if ab[i][1]<t:
            t=ab[i][1]
        t=t-ab[i][0]
    if t>=0:
        return 'Yes'
    else:
        return 'No'

if __name__=='__main__':
    n,ab=readinput()
    ans=main(n,ab)
    print(ans)


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


ll numDigit(ll x){
    ll cnt = 0;
    while(x > 0){
        cnt ++;
        x/=10;
    }
    return cnt;
}

void solve(long long N){
    ll ans = 100;
    ll a=1, b=1;

    for(; a*a <= N; a++){
        if(N%a != 0) continue;
        b = N / a;
        ans = min(ans, max(numDigit(a), numDigit(b)));
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

int main() {
  int n, k, a, count = 0;
  cin >> n >> k;
  vector<int> vec(n+1);
  for (int i = 0; i < n; i++) {
    cin >> a;
    vec.at(a) += 1;
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int fake_ans = 0, ans = 0;
  for (int i = 0; i < k; i++) {
    fake_ans += vec.at(i);
  }
  ans = n - fake_ans;
  cout << ans << endl;
}



Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, combinations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from operator import itemgetter
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'

def main():
    K = ii()
    print('ACL'*K)











main()



Measured memory_bytes: 9880
//最小生成树Prim算法
#include <iostream>

using namespace std;

const int N = 100;
const int INFTY = 1 << 14; //赋值无穷大

int n; //图的规模

short  Graph[N][N];

int *p; //p[i]记录着它们之间最小权值那个路径上，i的父节点
int *d;//d[i]标记着从i的父节点到i所需的最小权值
char *color; //标记节点是否访问状态


void prim() { //普莱姆算法
    for (int i=0;i<n;i++) {
    	d[i] = INFTY;
    	color[i] = 'W';
	}
	//普莱姆算法选取任意点作为开始点，这里我们选取第一个点 
	p[0] = INFTY;
	d[0] = 0;
	
	while (1) {
		
		//每次从剩余点中选取权值最小的点 
		int mincost = INFTY;
		int u;
		for (int i=0;i<n;i++) {
			if (color[i] != 'B' && mincost > d[i]) {
				mincost = d[i];
				u = i;
			}
		}
		
		if (mincost == INFTY) { //说明所有节点已经访问完毕 
			break;
		}
		
		color[u] = 'B'; //标记节点已经访问结束 
		
		for (int v=0;v<n;v++) {
			if (color[v] != 'B' && Graph[u][v] != INFTY) {
				if (d[v] > Graph[u][v]) {
					d[v] = Graph[u][v];
					p[v] = u;
					color[v] = 'G';
				}
			}
		}
	}
	
}

int main() {
	cin >> n;
	p = new int[n];
	d = new int[n];
	color = new char[n];

	for (int i=0; i<n; i++) {
		for (int j = 0; j<n; j++) {
			cin >> Graph[i][j];
			if (Graph[i][j] == -1) {
				Graph[i][j] = INFTY;
			}
		}
	}
	
	prim();
	int sum = 0;
	for (int i=0; i<n; i++) {
		if (p[i] != INFTY) {
			sum += Graph[i][p[i]];
		}
	}
	cout << sum << endl;
	delete[] p;
	delete[] d;
	delete[] color;
	return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    for (int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<int> dp(n,1000000000);
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for (int i=2;i<n;i++){
            for (int j=i-1;j>=i-k;j--){
                    if(j>=0){
                        dp[i]=min(dp[i],(dp[j]+abs(a[i]-a[j])));

                    }

            }
    }
    cout<<dp[n-1]<<endl;
}


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

using namespace std;

vector<long long> sum(int n, vector<long long>a){
	vector<long long> s(n);
	for(int i = 0;i<n;i++){
		if(i == 0){
			s[i] = a[i];
			continue;
		}
		s[i] = s[i-1] + a[i];
	}
	return s;
}

int main(){
	long long m, n, ans = 0,r;
	cin >> n >> m;
	vector<long long> a(n); 
	for(int i = 0; i<n; i++) cin >> a[i];
	map<int, int> map;
	map[0] = 1;
	vector<long long> s = sum(n,a); 
	for(int i = 0; i<n; i++){
		r = s[i]%m;
		ans += map[r];
		map[r]++;
	}
	cout << ans;
}

Measured memory_bytes: 4720
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
  int n; cin >> n;
  int l[2*n];
  for(int i=0; i<2*n; i++) cin >> l[i];

  sort(l, l+2*n);

  int ans = 0;
  for(int i=0; i<n; i++){
    ans += l[2*i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
 
int main() {
  int N, K;
  scanf("%d%d", &N, &K);
  
  int doubled = 1;
  double prob = 1;
  double ans = 0;
  for(int i = N; i > 0; i--) {
    while(i*doubled < K)
      doubled *= 2, prob /= 2;
    ans += prob / N;
  }
  printf("%.15lf", ans);
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

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

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

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

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

	vector<int> input(n);
	rep(i, n){
		cin >> input[i];
	}

	long long int ans = 0;
	int h = input[0];

	REP(i, 1, n){
		if(max(input[i - 1], h) > input[i]) ans += max(input[i - 1], h) - input[i];

		h = max(input[i], h);
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 4024
#include <stdio.h>
int main() {
  int n;
  double len2 = 0;
  double len1, len;
  double len_max = 0;
  int i;
  int j = 0;
  double ans;

  scanf ("%d", &n);

  double a[n];
  for (i = 0; i < n; i++) {
    if(i == n - 1) scanf ("%lf\n", &a[i]);
    else scanf ("%lf", &a[i]);
  }

  for (i = 0; i < n; i++) {
    len_max += a[i];
  }

  while (len2 < len_max / 2) {
    len2 += a[j];
    j++;
  }

  j--;
  len1 = len2 - a[j];
  if ((len_max / 2) - len1 < len2 - (len_max / 2)) {
    len = len_max - len1;
    ans = (len - len1);
  }
  else {
    len = len_max - len2;
    ans = (len2 - len);
  }

  printf ("%.0lf\n", ans);

  return 0;
}


Measured memory_bytes: 1664
def main():
    N = int(input())
    A = list(map(int, input().split()))

    # 全探索するとN!なのでN=2000のときO(N^2000)となるので無理
    # DPで解く
    # dp[i][l] = 係数が大きい順にi個左右の端どちらにつめるか決めて、左をl回(右はn-l回)選んだときの指標最大値

    # 降順にAをソート+元のインデックスも保存しておく
    Awithidx = [[a,i] for i,a in enumerate(A)]
    sortedA = sorted(Awithidx, reverse=True)
    # DP
    dp = [[0]*(N+1) for _ in range(N+1)]
    for i in range(N):
        a = sortedA[i][0]
        idx = sortedA[i][1]
        for l in range(i+1):
            r = i-l
            dp[i+1][l] = max(dp[i+1][l], dp[i][l]+a*abs((N-r-1)-idx))
            dp[i+1][l+1] = max(dp[i+1][l+1], dp[i][l]+a*abs(l-idx))
    print(max(dp[N]))

main()


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

using namespace std;

const int N = 90;

long long fib[N];

int main() {
    int n;
    cin >> n;
    fib[0] = 2;
    fib[1] = 1;
    for (int i = 2; i <= n; ++i)
        fib[i] = fib[i - 1] + fib[i - 2];
    cout << fib[n] << endl;
}

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

int main() {
	unsigned short N;
	char S[7] = { 0 };
	scanf("%6[^\n]%*[^\n]", S);
	if (S[2] == S[3] && S[4] == S[5]) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    ll n,k,c;
    string s;
    cin>>n>>k>>c;
    cin>>s;
    int d[n+2];
    d[n+1]=0;
    for (int i=0;i<c+1;i++){
        if (s[n-1-i]=='o')d[n-i]=1;
        else d[n-i]=max(0,d[n-i+1]);
    }
    for (int i=n-c-1;i>0;i--){
        if (s[i-1]=='o')d[i]=1+d[i+c+1];
        else d[i]=d[i+1];
    }
    //for (int i=1;i<n+1;i++)cout<<d[i]<<endl;
    vector<int> dic;
    rep(i,n){
        if (s[i]=='o')dic.push_back(i+1);
    }
    vector<int> dic2;//答えの候補
    int now=dic[0];
    dic2.push_back(now);
    while (dic2.size()<k){
        int index=dic2.size();
        int num=dic2[index-1];
        int index1=lower_bound(all(dic),num+1+c)-dic.begin();
        dic2.push_back(dic[index1]);
        //cout<<dic2[index]<<endl;
    }
    vi ans;
    rep(i,k){
        int num=dic2[i];
        if (i+d[num+1]>=k)continue;
        else ans.push_back(num);
    }
    for (int x:ans)cout<<x<<endl;


    return 0;
}

Measured memory_bytes: 4984
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int ans = 0;
  
  if(N % 10 != 0){
    for(;N > 0; N /= 10){
      ans += N % 10;
    }
      cout << ans << endl;
    return 0;
  }
  cout << 10 << endl;
}


Measured memory_bytes: 3612
def f(s):
    s=list(map(int,s.split(':')))
    return (s[0]*60+s[1])*60+s[2]
a=86401
while 1:
    t=[0]*a
    n=int(input())
    if n==0:break
    for _ in range(n):
        b,c=input().split()
        t[f(b)]+=1;t[f(c)]-=1
    d=0
    for i in range(1,a):
        t[i]+=t[i-1]
        d=max(d,t[i])
    print(d)

Measured memory_bytes: 11712
#include<iostream>
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include<bits/stdc++.h>

using namespace std;
int main(){
    const double pi = acos(-1);
    double tan;
    double tyou;
    double ji;
    double hun;
    double move1 = 6;
    double move2 = 30;
    double move3 = 0.5;
    double bairitu = 12;
    double Pi = 180;
    cin >> tan >> tyou >> ji >> hun;
    double kakudo = ji*move2 + hun*move3 - hun*move1;
    if(kakudo >180){
        kakudo = 360-kakudo;
    }
    double kakudo2 = pi*kakudo/180;

    double a = tan*tan+tyou*tyou-2*tan*tyou*cos(kakudo2);
    double ans = sqrt(a);

    cout << fixed << setprecision(10)<<ans;
}

Measured memory_bytes: 4232
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int M = scan.nextInt();
		int ans = 0;
		int[] H = new int[N+1];
		int[] x = new int[N+1];
		int a = 0;
		int b = 0;
		for (int i = 1; i < N+1; i++) {
			H[i] = scan.nextInt();
		}

		for (int i = 0; i < M; i++) {
			a = scan.nextInt();
			b = scan.nextInt();

			if (H[a] <= H[b]) {
				x[a]++;
			}
			if (H[a] >= H[b]) {
				x[b]++;
			}
		}

		for (int i = 1; i < N+1; i++) {
			if (x[i] == 0) ans++;
		}

		System.out.println(ans);
	}

}

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

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

    int a, b;
    cin >> a >> b;

    while(1){
        if(a+1 == b){
            a--;
            if(a < 1){
                cout << "Borys" << endl;
                return 0;
            }
        }else{
            a++;
        }
        if(a == b-1){
            b++;
            if(b > n){
                cout << "Alice" << endl;
                return 0;
            }
        }else{
            b--;
        }
    }
}




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

/**
 * Created by Santa.
 */
public class Main {

  static int N;
  static int K;
  static long Q;
  static int A;
  static int B;
  static long C;
  static double min = 9999999;
  static long ans = 0;

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

    int N = scanner.nextInt();


    scanner.nextLine();

    String s = scanner.nextLine();

    boolean flag = false;
    int ans = 0;
    int hen = 0;
    int sha = 0;
    int dot = 0;
    int temp = 0;
    boolean first = true;
    for (int i = 0; i < N; i++) {
//      System.out.println(s.charAt(i));
      if(s.charAt(i) == '#'){
        first = false;
          if(sha <= dot){
//            System.out.println(sha);
            ans += sha;
            sha = 0;
            dot = 0;
            first = true;
//            System.out.println(111111111);
          }else{
//            System.out.println(9292992);
//            temp += dot;
          }

        sha++;
      }else{
//        System.out.println(first);
//        if(first == false) {

          dot++;
//        }
      }
    }

    if(sha <= dot){
      ans += sha;
      dot = 0;
    }else{
//            temp += dot;
    }


//    System.out.println(dot);

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



Measured memory_bytes: 26180
#include <iostream>
#define MAX_N  101
#define MAX_W   100001

using namespace std;
//dp retorna el mejor valor posible para el peso disponible y los articulos faltantes disponiles
int N, W;

long long  dp[MAX_N][MAX_W];
int pesos[MAX_N];
long long valores[MAX_N];
long long Knapsack(int W,int  n){
	if(W==0|| n==0)return 0;
	if(dp[n][W]!=-1) return 	dp[n][W];
	if(W-pesos[n]>=0)
	return dp[n][W]=max(Knapsack(W-pesos[n],n-1)+valores[n],Knapsack(W,n-1));
	return Knapsack(W,n-1);
	}
void fillDp(){
	for(int i =0;i<MAX_N;i++){
		for (int j=0;j<MAX_W;j++)
			dp[i][j]=-1;
	}	
}

int main(int argc, char** argv) 
{
	cin>>N>>W;
	for (int i =1;i<=N;i++){
		cin>>pesos[i]>>valores[i];
	}
	fillDp();
	cout<<Knapsack(W,N)<<endl;

	return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

void solve() {
	int a, b;
	cin >> a >> b;
	int g = __gcd(a, b);
	int ans = 1;
	for(int i=2; i*i<=g; ++i){
		if(g%i == 0){
			ans++;
			while(g%i == 0)
				g/=i;
		}
	}
	if(g!=1) ans++;
	cout << ans;
}

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

	// test
	solve();

	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long
#define P pair<int, int>
#define PP pair<int,pair<int, int>>
#define pb push_back
#define pp pop_back
#define lson root << 1
#define INF (int)2e9 + 7
#define rson root << 1 | 1
#define LINF (unsigned long long int)1e18
#define mem(arry, in) memset(arry, in, sizeof(arry))
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if(a + b == 15) puts("+");
    else if(a * b == 15) puts("*");
    else puts("x");
    return 0;
}







/*
int n;
int a[400], b[400], sum[400];
map<string, int> mp;

int main()
{
    cin >> n;
    int t = 0;
    for(int i = 1; i <= n; i++) {
        string tp;
        cin >> tp;
        if(!mp[tp]) mp[tp] = ++t;
        a[i] = mp[tp];
        b[i] = tp.size();
        sum[i] =
    }



    return 0;
}
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL a[200000],n,p=0,ans=0,l=0;
queue<int>q;
bool check(LL x){
	if((a[x]^p)==a[x]+p){
		q.push(x);
		p=a[x]+p;
		return true;
	}
	return false;
}
inline void popfront(){
	p-=a[q.front()];
	q.pop();
}
int main(){
	LL i;
	bool k;
	cin>>n;
	for(i=0;i<n;i++)cin>>a[i];
	for(i=0;i<n;i++){
		k=check(i);
		while(!k){popfront();k=check(i);}
		if(k)ans+=(q.size()-1);
	}
	cout<<ans+n<<endl;
	return 0;
}

Measured memory_bytes: 2688
import static java.lang.Integer.parseInt;

public class Main {
    public static void main (String[] args ) {
        int i,j ;
        String line = new java.util.Scanner ( System.in ).nextLine();
        String[] number = line.split(" ", 0);

        i = (int) Rectangle (parseInt(number[0]), parseInt(number[1]));
        j = (int) RectangleLength (parseInt(number[0]), parseInt(number[1]));
        System.out.println(i + " " + j);
    }
    public static double Rectangle (int x ,int y) {
        return x * y;
    }
    public static double RectangleLength (int x ,int y) {
        return (x *2) + (y * 2);
    }
}

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

using namespace std;

#define EPS 1e-9
#define M 256
#define INF 1e9

int main(){
  int N;
  while(cin >> N, N > 0){
    int I[N+1],R[N+1],O[N+1];
    for(int i = 0 ; i < N ; i++){
      cin >> I[i];
    }
    int S,A,C;
    double ans = INF;
    for(int s = 0 ; s <= 15 ; s++){
      for(int a = 0 ; a <= 15 ; a++){
        for(int c = 0 ; c <= 15 ; c++){
          int x[M] = {0};
          R[0] = s;
          for(int i = 1 ; i <= N ;i++){
            R[i] = (a*R[i-1]+c) % M;
            O[i] = (I[i-1]+R[i]) % M;
            x[O[i]]++;
          }
          double H = 0;
          for(int i = 0 ; i < M ; i++){
            double p = (double)x[i]/N;
            if(p > 0){
              H -= p*log(p);
            }
          }
          if(H+EPS < ans){
            ans = H;
            S = s; A = a; C = c;
          }
        }
      }
    }
    cout << S << " " << A << " " << C << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
unittest
{
	assert( [ "2 6" ].parse.expand.solve == 4 );
	assert( [ "3 12" ].parse.expand.solve == 18 );
	assert( [ "100000 1000000000" ].parse.expand.solve == 957870001 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	return tuple( nm[ 0 ], nm[ 1 ] );
}

auto solve( long n, long m )
{
	const MOD = 10L ^^ 9 + 7;
	
	// mを素因数分解して同じ素因数ごとに個数を数える
	auto fs = primefactorize( m ).group;
	
	// 同じ素因数をn個の箱に割り振ったときの組み合わせを計算
	auto ans = 1L;
	foreach( f; fs )
	{
		ans = ans.mulMod!MOD( ( f[ 1 ] + n - 1 ).combinationMod!MOD( n - 1 ) );
	}
	return ans;
}

// 掛け算
auto mulMod( long MOD )( long x, long y )
{
	return x * y % MOD;
}

// 割り算
auto divMod( long MOD )( long x, long y )
{
	return x * y.powMod!MOD( MOD - 2 ) % MOD;
}

// べき乗
auto powMod( long MOD )( long x, long y )
{
	auto a = 1L;
	for( ; 0 < y; y >>= 1 )
	{
		if( y & 1 ) a = a * x % MOD;
		x = x ^^ 2 % MOD;
	}
	return a;
}

// 階乗
auto factorialMod( long MOD )( long x )
{
	static memo = [ 1L ];
	if( memo.length <= x )
	{
		auto i = memo.length;
		memo.length = x + 1;
		for( ; i <= x; i++ ) memo[ i ] = memo[ i - 1 ] * i % MOD;
	}
	return memo[ x ];
}

// 組み合わせ数
auto combinationMod( long MOD )( long x, long y )
{
	return x.factorialMod!MOD.divMod!MOD( y.factorialMod!MOD.mulMod!MOD( ( x - y ).factorialMod!MOD ) );
}

// 順列数
auto permutationMod( long MOD )( long x, long y )
{
	return x.factorialMod!MOD.divMod!MOD( ( x - y ).factorialMod!MOD );
}

// 素数列
auto primes( long x )
{
	long[] ps;
	if( x < 2 ) return ps;
	
	auto cs = new bool[]( x + 1 );
	ps = [ 2L ];
	for( auto i = 3L; i * i < cs.length; i += 2 )
	{
		if( cs[ i ] ) continue;
		for( auto j = i; i * j < cs.length; j++ )
		{
			cs[ i * j ] = true;
		}
	}
	for( auto i = 3L; i < cs.length; i += 2 )
	{
		if( !cs[ i ] ) ps ~= i;
	}
	return ps;
}

// 素因数分解
auto primefactorize( long x )
{
	long[] fs;
	if( x < 2 ) return fs;
	
	auto s = ( cast( long ) x ^^ 0.5 ) + 1;
	foreach( p; s.primes )
	{
		while( x % p == 0 )
		{
			x /= p;
			fs ~= p;
		}
		if( x < 2 ) break;
	}
	if( 2 <= x ) fs ~= x;
	return fs;
}


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

int main(void) {

  int id;
  int counta=0,countb=0,countab=0,counto=0;
  char btype[3];
  char buf[50];
  char* p;
  
  while(fgets(buf,sizeof(buf),stdin)!=NULL) {

    buf[strlen(buf)-1]='\0';

    p=strtok(buf,",");
    p=strtok(NULL,"");

    if(strcmp(p,"A")==0) counta++;
    else if(strcmp(p,"B")==0) countb++;
    else if(strcmp(p,"AB")==0) countab++;
    else if(strcmp(p,"O")==0) counto++;

  }

  printf("%d\n%d\n%d\n%d\n",counta,countb,countab,counto);

  return 0;

}

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

int main() {

    int n, m, cnt = 0;
    double a, b;
    cin >> n >> m;
    while(n--){
        cin >> a >> b;
        if(sqrt(a*a + b*b) <= m) cnt++;
    }
    cout << cnt;
}


Measured memory_bytes: 3836
n, k = map(int, input().split(' '))
r, s, p = map(int, input().split(' '))
t = input()

dasita_te = []

score = 0

for i, c in enumerate(t):
    if c == "r":
        if (i >= k and dasita_te[i - k] != "p") or i < k:
            score += p
            dasita_te.append("p")
        else:
            dasita_te.append("-")
    elif c == "s":
        if (i >= k and dasita_te[i - k] != "r") or i < k:
            score += r
            dasita_te.append("r")
        else:
            dasita_te.append("-")
    elif c == "p":
        if (i >= k and dasita_te[i - k] != "s") or i < k:
            score += s
            dasita_te.append("s")
        else:
            dasita_te.append("-")

print(score)


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a == b) 
    cout << c << endl;
  else if(b == c)
    cout << a << endl;
  else 
    cout << b << endl;
}

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

int main() {
  double h, max_h = -1, min_h = 1000001;
  while (cin >> h)
    max_h = max(h, max_h), min_h = min(h, min_h);
  cout << max_h - min_h << endl;
}


Measured memory_bytes: 3228
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_W_MAX			100										// 最大幅

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 列数取得
	int liCCnt;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d", &liCCnt);

	// １行目取得
	int li1Cnt1[D_W_MAX];
	for (i = 0; i < liCCnt; i++) {
#ifdef D_TEST
		fscanf(szpFpT, "%d", &li1Cnt1[i]);
#else
		fscanf(stdin, "%d", &li1Cnt1[i]);
#endif
	}
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif

	// ２行目取得
	int li1Cnt2[D_W_MAX];
	for (i = 0; i < liCCnt; i++) {
#ifdef D_TEST
		fscanf(szpFpT, "%d", &li1Cnt2[i]);
#else
		fscanf(stdin, "%d", &li1Cnt2[i]);
#endif
	}
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif

	// 左下を通る場合
	int liSum = li1Cnt1[0];
	for (i = 0; i < liCCnt; i++) {
		liSum += li1Cnt2[i];
	}

	// 右へ移動してから下に移動する全パターン
	int liMax = liSum;
	for (i = 0; i < liCCnt - 1; i++) {
		liSum += li1Cnt1[i + 1] - li1Cnt2[i];
		if (liMax < liSum) {
			liMax = liSum;
		}
	}

	// 結果セット
	sprintf(lc1Out, "%d\n", liMax);

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 256
using System;
using System.Text;
using CompLib.Util;

public class Program
{
    private int N;
    private int[] A;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        A = sc.IntArray();

        long yen = 1000;
        long kabu = 0;
        bool hold = false;
        for (int i = 0; i < N; i++)
        {
            if (hold)
            {
                if (i + 1 >= N || A[i] > A[i + 1])
                {
                    yen += kabu * A[i];
                    kabu = 0;
                    hold = false;
                }
            }
            else
            {
                if (i + 1 < N && A[i] < A[i + 1])
                {
                    long t = yen / A[i];
                    yen -= t * A[i];
                    kabu += t;
                    hold = true;
                }
            }
        }

        Console.WriteLine(yen);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 28248
#include <iostream>
#include <cstdio>
#include <string>
#include <map>
using namespace std;

int main()
{
	int i;
	string s;
	char k;
	map<string, int> m;
	m["A"] = 0; m["B"] = 0;
	m["AB"] = 0; m["O"] = 0;
	while(cin>>i>>k>>s){
		m[s]++;
	}
	cout<<m["A"]<<endl;
	cout<<m["B"]<<endl;
	cout<<m["AB"]<<endl;
	cout<<m["O"]<<endl;
	
	return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int e[101][101];
	int R, C, r, c;
	int s, total;

	scanf("%d%d", &R, &C);
	for (r = 1; r <= R; r++) {
		for (c= 1; c <= C; c++) scanf("%d", &e[r][c]);
	}
	
	for (r = 1; r <= R; r++) {
		s = 0;
		for (c = 1; c <= C; c++) s += e[r][c];
		e[r][0] = s;
	}
	total = 0;
	for (c = 1; c <= C; c++) {
		s = 0;
		for (r = 1; r <= R; r++) s += e[r][c];
		e[0][c] = s;
		total += s;
	}
	for (r = 1; r <= R; r++) {
		for (c = 1; c <= C; c++) printf("%d ", e[r][c]);
		printf("%d\n", e[r][0]);
	}
	for (c = 1; c <= C; c++) printf("%d ", e[0][c]);
	printf("%d\n", total);
	return 0;
}





Measured memory_bytes: 2144
#include <iostream>
using namespace std;
int main() {
	int w,h,x,y,r;
	cin >> w >> h >> x >> y >> r;
	if (x-r>=0&&x+r<=w&&y-r>=0&&y+r<=h)
		cout << "Yes";
	else cout << "No";
	cout << endl;
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int main(){
    int64_t x,k,d;
    cin>>x>>k>>d;
    x = abs(x);
    /*
    if(k==1){
        cout<<abs(x-d)<<endl;
        return 0;
    }*/
    if(x/d>=k){//0にたどり着けない
        cout<<x-d*k<<endl;
    }
    else{
        int cnt = x/d;//これで
        x -= cnt*d;
        k -= cnt;
        if(k%2==0){//ここか-2*d
            cout<<min(x,abs(x-2*d))<<endl;
        }
        else{
            cout<<min(x+d,abs(x-d))<<endl;
        }
        
    }
}

Measured memory_bytes: 3600
n = int(input())
t,a = map(int,input().split())
L = list(map(int,input().split()))

sa = 10000
ans = 0
for i in range(n):
      tem = t - (L[i] * 0.006)
      if sa > abs(a - tem):
            sa = abs(a - tem)
            ans = i + 1      

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include <cstdlib>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include <iomanip>

// #pragma comment(linker, "/STACK:1024000000,1024000000")
// #define pi acos(-1)
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x7f7f7f7f //2139062143
#define INF1 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.141592653589793//23846264338327950254
#define pb push_back
#define ll long long
#define debug cout << "debug\n";
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
// ios::sync_with_stdio(false);cin.tie(NULL);
#define scai(x) scanf("%d", &x)
#define sca2i(x, y) scanf("%d %d", &x, &y)
#define scaf(x) scanf("%lf", &x)
#define sca2f(x, y) scanf("%lf %lf", &x, &y)
#define For(m,n) for (int i = m;  i < n; i++)

#define local
#ifdef local
#endif

#define MAX 10233
#define LCH(i) ((i) << 1)
#define RCH(i) ((i) << 1 | 1)

int main()
{
    int H,n;
    scai(H);
    scai(n);
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        int t;
        scai(t);
        sum += t;
    }
    if (sum >= H)
        puts("Yes");else puts("No");
}


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

int main()
{
	int n;
	while(cin >> n){
		if(!n){
			break;
		}
		int bit[100];
		int a=0;
		while(n!=0){
			bit[a++] = n%8;
			if(bit[a-1] >= 4)
				bit[a-1]++;
			if(bit[a-1] >=6)
				bit[a-1]++;
			n/=8;
		}
		for(int i=a-1;i>=0;i--)
			cout << bit[i];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<iostream>
using namespace std;
    int bubbleSort(int a[],int n){
       int sw=0;
       bool flag = 1;
       for(int i=0;flag;i++){
        flag = 0;
        for(int j=n-1;j>=i+1;j--){
            if(a[j]<a[j-1]){
            swap(a[j],a[j-1]);
            flag=1;
            sw++;
        }
       }
      }return sw;
    }
int main(){
   int a[110],n,sw;
   scanf("%d",&n);
   for(int i=0;i<n;i++)scanf("%d",&a[i]);
   sw=bubbleSort(a,n);
   for(int i=0;i<n;i++){
    if(i)cout<<" ";
    cout<<a[i];
   }cout<<endl;
   cout<<sw<<endl;
return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
#define vst vector<string>
ll mx=INT_MAX;
ll mi=INT_MIN;
const ll mod=1e9+7;
int main()
{
    vll v,vv(102,0),vvv[250000],so(250000,0);
    ll i,j,k,n,x=0;
    string s;
    cin>>n>>k;
    for(i=0;i<k;i++)
    {
        ll p;cin>>p;
        for(j=0;j<p;j++)
        {
            ll a;
            cin>>a;vv[a]++;
        }
    }
    for(i=1;i<=n;i++)
    {
        if(vv[i]==0) x++;
    }
    cout<<x;
    
}

Measured memory_bytes: 10984
a, b, c, x, y = map(int, input().split())
ans = a * x + b * y
ans = min(ans, 2 * c * max(x, y))
if x > y:
    ans = min(ans, 2 * c * y + a * (x - y))
else:
    ans = min(ans, 2 * c * x + b * (y - x))
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
    int m,n,money,year,type,commission,account,pool,max;
    double rate;
    int i,j,k;

    scanf("%d",&m);

    for(i=0;i<m;i++)
    {
        scanf("%d %d %d",&money,&year,&n);

        max=0;
        for(j=0;j<n;j++)
        {
            scanf("%d %lf %d",&type,&rate,&commission);

            account=money;
            if(type==0)
            {
                pool=0;
                for(k=0;k<year;k++)
                {
                    pool+=(double)account*rate;
                    account-=commission;
                }
                account+=pool;
            }
            else
            {
                for(k=0;k<year;k++)
                {
                    account=(double)account*(1.0+rate)-commission;
                }
            }
            if(account>max)
            {
                max=account;
            }
        }
        printf("%d\n",max);
    }
    return 0;
}

Measured memory_bytes: 632
package main

import "fmt"

func main() {
	d, n := 0, 0
	fmt.Scan(&d, &n)

	count := 0
	for i := 1; ; i++ {
		if div(i) == d {
			count++
			if count == n {
				fmt.Println(i)
				return
			}
		}
	}
}

func div(x int) int {
	if x%100 != 0 {
		return 0
	}
	return div(x/100) + 1
}


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

bool isPrime(int e) {
  for(int i = 2; i <= (int) sqrt(e); i++) {
    if(e % i == 0) return false;
  }
  return true;
}

int main () {
  int n;
  cin >> n;
  int c = 0;
  for(int i = 0; i < n; i++) {
    int e;
    cin >> e;
    c += isPrime(e);
  }
  cout << c << endl;
  return 0;
}



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

using namespace std;
const int MAX = 1e5 + 1;

int v[MAX];
bool dp[MAX];
int main()
{
    int n, k, minV = MAX;

    cin >> n >> k;

    for(int i = 1; i <= n; ++i)
        cin >> v[i];

    sort(v + 1, v + 1 + n);

    dp[v[1]] = 1;

    for(int i = v[1] + 1; i <= k; i++)
        for(int j = 1; v[j] <= i && j <= n; j++)
            if(!dp[i - v[j]])
                dp[i] = 1;

    if(dp[k])
        cout << "First";
    else
        cout << "Second";

    return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
#define print(x) cout << (x) << endl;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, count = 0;
    cin >> A >> B;
    for (int i = A; i <= B; i++) {
        string str = to_string(i);
        string reverstring = str;
        reverse(reverstring.begin(), reverstring.end());
        if (str == reverstring) {
            count++;
        }
    }
    print(count);
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll  INFL = 1e18;


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N, M; cin >> N >> M;
    vi x(M), y(M);
    REP(i, M)
    {
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
    }
    vb red(N, false); red[0] = true;
    vi count(N, 1);
    REP(i, M)
    {
        if(red[x[i]]) red[y[i]] = true;
        count[x[i]]--; count[y[i]]++;
        if(count[x[i]] == 0) red[x[i]] = false;
    }
    int ans = 0;
    REP(i, N) if(red[i]) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 1408
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int a,b;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
		
	cin >>a >> b;
	
	int ans=0;
	ans+=a-1;
	
	if(b>=a) ans++;
	
	cout << ans << '\n';
	
	
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PipedInputStream;
import java.util.*;

public class Main {
    private static final int MOD = (int) Math.pow(10, 9);
    private static final int[][] DIRS = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        Set<Integer> set = new HashSet<>();

        for (int i = 0; i < n; i++) {
            set.add(sc.nextInt());
        }

        if (set.size() == n) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

        System.exit(0);
    }
    static private class Point {
        public int x;
        public int y;
        Point(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    static private int log2(int x) {
        return (int)(Math.log(x) / Math.log(2));
    }

    static private long gcd(long m, long n) {
        if (m < n) { return gcd(n, m); }
        if (m % n == 0) { return n; }
        return gcd(n, m%n);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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


Measured memory_bytes: 57940
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int main() {
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>c>>a>>b;
  for(int i =a;i<=b;i++){
    if(i%c==0)return cout<<"OK\n",0;
  }
  cout<<"NG\n";
  return 0;
}

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

int64_t GCD(int64_t a, int64_t b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int64_t LCM(int64_t x, int64_t y) {
    return x / GCD(x, y) * y;//先に割り算をして掛けられる数を小さくして掛け算を行う
}


int main() {
    int64_t N,M;
    cin >> N >> M;
    vector<int64_t> a(N), a2(N);
    for ( int64_t i = 0; i < N; ++i){
        int64_t x;
        cin >> x;
        a[i] = x/2;
        a2[i] = x;
    }
    
    bool same = true;
    while (a2[0] % 2 == 0) {
        for (int i = 0; i < N; ++i) {
            if (a2[i] % 2 != 0) same = false;
            a2[i] /= 2;
        }
    }
    for (int i = 0; i < N; ++i) if (a2[i] % 2 == 0) same = false;
    
    int64_t ans = a[0];
    for ( int64_t i = 1; i < N; ++i){
        ans = LCM(ans,a[i]);
        if ( ans > M ){
            ans = 0;
            break;
        }
    }
    
    if ( ans == 0 or same == false ){
        cout << 0 << endl;
    } else {
        int64_t m;
        m = M / ans;
        if ( m % 2 == 0 ) ans = m/2;
        else ans = m/2 + 1;
        cout << ans << endl;
    }
    
    return 0;
}


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

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
#define all(v) (v).begin(), (v).end()
#define sz(v) (int) (v).size()

int main(int argc, char* argv[]) {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) 
    cin >> a[i];
  sort(a.rbegin(), a.rend());
  int cnt = n - 2;
  long long res = a[0];
  for (int i = 1; i < n; i++) {
    if (cnt > 0) {
      res += a[i];
      --cnt;
    }
    if (cnt > 0) {
      res += a[i];
      --cnt;
    }
  }   
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 3976
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main() {
  char b;
  cin>>b;
  if(b=='A') {
    cout<<'T'<<endl;
  }
  if(b=='T') {
    cout<<'A'<<endl;
  }
  if(b=='C') {
    cout<<'G'<<endl;
  }
  if(b=='G') {
    cout<<'C'<<endl;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod  1000000007
#define pb push_back
#define mk make_pair
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ld long double
#define fi first
#define se second
#define setbits __builtin_popcount
//Please check edge cases
int main()
{
    fastIO;
    ll a,b,c;
    cin>>a>>b>>c;
    ll sum=a+b+c;
    if(sum>=22)
    {
        cout<<"bust\n";
    }
    else
    {
        cout<<"win\n";
    }
    return 0;
}

Measured memory_bytes: 384
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    s=input()
    if s[0]==s[2]:
        print("Yes")
    else:
        print("No")
main()

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
#define fors(i,a,b) for(int i=(a);i<=(b);++i)
#define ford(i,a,b) for(int i=(a);i>=(b);--i)
#define min(x,y) ((x) < (y) ? (x) : (y))
#define max(x,y) ((x) < (y) ? (y) : (x))
#define swap(x,y) ((x)^=(y),(y)^=(x),(x)^=(y))
const int maxn=1e5;
typedef long long ll;
const int inf=1<<25;

int read(){
    int s=0,f=1;
    char c=getchar();
    while(c<'0' || c>'9') {if(c=='-') f=-1; c=getchar();}
    while(c>='0' && c<='9') {s=s*10+c-48;c=getchar();}
    return s*f;
}
void write(int x){
    if(x<0) {putchar('-');x=-x;}
    if(x>9) write(x/10);
    putchar(x%10+48);
}

int a[maxn+7];
int n;
struct node
{
    int id,w;
}cnt[maxn+7],cnt2[maxn+7];
int cmp(node a,node b){
    return a.w>b.w;
}
int ans,tot,tot2;
int main(int argc, char const *argv[])
{
    n=read();
    fors(i,1,n) a[i]=read();
    for(int i=1;i<=n;i+=2)
        cnt[a[i]].w+=1,cnt[a[i]].id=a[i],tot+=1;

    for(int i=2;i<=n;i+=2)
        cnt2[a[i]].w+=1,cnt2[a[i]].id=a[i],tot2+=1;

    sort(cnt2+1,cnt2+maxn,cmp);
    sort(cnt+1,cnt+maxn,cmp);

    int ans=0;
    if(cnt[1].id == cnt2[1].id){
        ans+=((tot-cnt[2].w) < (tot2-cnt2[2].w) ? (tot-cnt[2].w+tot2-cnt2[1].w) : (tot2-cnt2[2].w+tot-cnt[1].w));
    }
    else ans+=n-cnt[1].w-cnt2[1].w;
    write(ans),putchar(10);
    
    return 0;
}

Measured memory_bytes: 2176