akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(N, K);
  cout << (N % K == 0 ? 0 : 1) << endl;

  return 0;
}



Measured memory_bytes: 256
n,x = map(int,input().split())
a = [int(i) for i in input().split()]
ans = 0
for i in range(n-1):
    if a[i] + a[i+1] <= x: continue
    ans += a[i] + a[i+1] - x
    a[i+1] = max(0,x - a[i])
print(ans)

Measured memory_bytes: 14540
k, n = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
l = []

for i in range(n-1):
  l.append(a[i+1] - a[i])
  
l.append(k-a[n-1] + a[0])

print(sum(l) - max(l))

Measured memory_bytes: 26444
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int main(){
   
    int n;
    cin>>n;
    int cd[n];
    rep(i,n){
        cin>>cd[i];
    }
    sort(cd,cd+n);
    reverse(cd,cd+n);
    int a=0,b=0;
    rep(i,n){
        if(i%2==0){
            a+=cd[i];
        }else{b+=cd[i];}
    }
    cout<<a-b<<endl;
   
return 0;
}


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

#define CIN2(a,b) long long a,b;cin >> a >> b;
#define CIN3(a,b,c) long long a,b,c;cin >> a >> b >> c;
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)

int main(){
    int n;cin >> n;
    vector<int> v(n);
    int sum = 0;
    rep(i,n){
        cin >> v[i];
        sum += v[i];
    }
    int tmp = *max_element(v.begin(),v.end());
    string s = (sum-tmp>tmp)?"Yes":"No";
    cout << s << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef  long long ll;

int sum =0;
ll N;

void func(string s){
  if(s.length() >=3 && stoll(s) <= N){
    int flag3, flag5, flag7;
    flag3 = flag5 = flag7 = 0;
    for(int i=0; i<s.length(); ++i){
      if(s[i] == '3')
        flag3 = 1;
      else if(s[i] == '5')
        flag5 = 1;
      else if(s[i] == '7')
        flag7 = 1;
      
    }
    //cout << s << endl;
    if(flag3 && flag5 && flag7){
      ++sum;
    }
  }
  if(stoll(s) <= N){
    s += '3';
    func(s);
    s.pop_back();
    s +='5';
    func(s);
    s.pop_back();
    s+='7';
    func(s);
  }
}

int main(){
  cin >> N;
  string s;
  s += '3';
  func(s);
  s.pop_back();
  s +='5';
  func(s);
  s.pop_back();
  s+='7';
  func(s);
  cout << sum << endl;
  return 0;
}




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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define in(x) cin>>x
#define ina(x, n) rep(x_i,n) cin>>x[x_i]
#define outa(x, n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll,vl,greater<ll> > pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int n, m; cin >> n >> m;
  vll ab(m);
  rep(i,m) {
    int a, b; cin >> a >> b;
    a--; b--;
    ab[i] = mp(a, b);
  }
  sort(all(ab));
  if (n==2 && m==1) {
    cout << 1 << endl;
    return 0;
  }

  pq ends;
  int i_ab = 0, ans = 0;
  rep(pos,n) {
    while (ab[i_ab].ff == pos) {
      ends.push(ab[i_ab++].ss);
    }
    if (!ends.empty() && ends.top()==pos+1) {
      ans++;
      pq emp;
      swap(ends, emp);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
const int N = 1000;
int g[N][N], flips[N+1][N+1];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h, w, n;
    while(cin >> h >> w >> n and h and w and n) {
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                cin >> g[i][j];
                flips[i][j] = 0;
            }
        }
        flips[0][0] = n - 1;
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                if(g[i][j]) {
                    flips[i][j+1] += (flips[i][j] + 1) / 2;
                    flips[i+1][j] += flips[i][j] / 2;
                } else {
                    flips[i+1][j] += (flips[i][j] + 1) / 2;
                    flips[i][j+1] += flips[i][j] / 2;
                }
            }
        }
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                g[i][j] ^= flips[i][j] & 1;
            }
        }
        int x = 0, y = 0;
        while(x < h and y < w) {
            (g[x][y] ? y : x)++;
        }
        cout << x + 1 << " " << y + 1 << endl;
    }
    return 0;
}



Measured memory_bytes: 10960
def solve():
    n = int(input())
    a = list(map(int,input().split()))
    sum1 = sum2 = cost1 = cost2 = 0
    for i in range(n):
        cur = a[i]
        sum1 += cur
        if (sum1<=0, sum1>=0)[i%2]:
            cost1 += 1+sum1*[-1,1][i%2]
            sum1 = [1,-1][i%2]
        sum2 += cur
        if (sum2>=0, sum2<=0)[i%2]:
            cost2 += 1+sum2*[1,-1][i%2]
            sum2 = [-1,1][i%2]
    print(min(cost1, cost2))
if __name__ == '__main__':
    solve()

Measured memory_bytes: 14468
#include<iostream>

using namespace std;

int main() {
    int N;

    cin >> N;

    int A[N];

    double bunbo = 1;

    for(int i = 0; i < N; i++) {
        cin >> A[i];
        bunbo *= A[i];
    }

    double bunshi = 0;

    for(int i = 0; i < N; i++) {
        bunshi += bunbo / A[i];
    }

    double ans = bunbo / bunshi;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


class UnionFind:
    def __init__(self, n):
        # 負  : 根であることを示す。絶対値はランクを示す
        # 非負: 根でないことを示す。値は親を示す
        self.table = [-1] * n
        self.size = [1] * n
        self.group_num = n

    def root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.root(self.table[x])
            return self.table[x]

    def is_same(self, x, y):
        return self.root(x) == self.root(y)

    def get_size(self, x):
        r = self.root(x)
        return self.size[r]

    def union(self, x, y):
        r1 = self.root(x)
        r2 = self.root(y)
        if r1 == r2:
            return
        # ランクの取得
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.size[r1] += self.size[r2]
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2
            self.size[r2] += self.size[r1]
        self.group_num -= 1



n = I()
U = UnionFind(10 ** 5 * 2)
for i in range(n):
    x, y = LI()
    U.union(x - 1, y + 10 ** 5 - 1)



X = [0] * 10 ** 5 * 2
Y = [0] * 10 ** 5 * 2
for x in range(10 ** 5):
    X[U.root(x)] += 1
for y in range(10 ** 5, 10 ** 5 * 2):
    Y[U.root(y)] += 1


ret = 0
for j in range(10 ** 5 * 2):
    ret += X[j] * Y[j]


print(ret - n)

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

typedef long long int ll;

int main(){
    int n;
    cin >> n;
    
    ll aa=1,b=1;
    ll t,a,s;

for(int i=0;i<n;i++) {
    cin >> t >> a;
    aa = aa/t+(aa%t==0?0:1);
    b = b/a+(b%a==0?0:1);
    s = max(aa,b);
    aa=s*t; b=s*a;
    }
cout << aa+b<<endl;
}


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

using namespace std;

int recurse(int i , int flag , vector<vector<int>> &arr , vector<vector<int>> &dp)
{
    if(i <= 0) return 0;
    else
    {
        if(flag == -1)
        {
            int max1 = INT_MIN;
            int t0 = recurse(i-1,0,arr,dp) + arr[i-1][0];
            int t1 = recurse(i-1,1,arr,dp) + arr[i-1][1];
            int t2 = recurse(i-1,2,arr,dp) + arr[i-1][2];
            max1 = max(t0,t1);
            max1 = max(max1,t2);
            return max1;
        }
        else if(flag == 0)
        {
            if(dp[i][0] != -1) return dp[i][0];
            else return dp[i][0] = max(recurse(i-1,1,arr,dp)+arr[i-1][1],recurse(i-1,2,arr,dp)+arr[i-1][2]);   
        }
        else if(flag == 1)
        {
            if(dp[i][1] != -1) return dp[i][1];
            else return dp[i][1] = max(recurse(i-1,0,arr,dp)+arr[i-1][0],recurse(i-1,2,arr,dp)+arr[i-1][2]);
        }
        else
        {
            if(dp[i][2] != -1) return dp[i][2];
            else return dp[i][2] = max(recurse(i-1,1,arr,dp)+arr[i-1][1],recurse(i-1,0,arr,dp)+arr[i-1][0]);
        }
        
    }
     
}

int main(int argc, char const *argv[])
{
    int n,temp;
    cin >> n;
    vector<vector<int>> arr(n,vector<int>(3,0));
    vector<vector<int>> dp(n+1,vector<int>(3,-1));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> temp;
            arr[i][j] = temp;
        }
    }
    cout << recurse(n,-1,arr,dp) << endl;
    return 0;
}


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

int main(){
  for(int i=0;i<100;i++){
    int N;
    cin >> N;
    if(N==0){
      break;
    }
 	int K[10000];
    int kekka[10000];
    for(int j=0;j<N;j++){
      int k;
      cin >> K[j];
      kekka[j] = 0;
    }
    int ans=1;
    int yaba=0;
    for(int j=0;j<N;j++){
      if(K[j] == 0||K[j] == 1){
        yaba++;
      }    
      if(K[j] >= 1){
        ans++;
      }
    }
    if(yaba == N){
      cout << "NA" << endl;
    }
    else{
      cout << ans << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3128
import itertools,math,numpy as np
def I(): return int(input())
def LI(): return list(map(int,input().split()))
N = I()
xy = np.array([LI() for _ in range(N)])
sum_norm = 0
dict_norm = {}
for a in itertools.permutations(range(N)):
    for i in range(len(a)-1):
        vector = tuple(xy[a[i+1]]-xy[a[i]])
        if not vector in dict_norm:
            dict_norm[vector] = np.linalg.norm(vector)
            vector_Inverse = tuple(xy[a[i]]-xy[a[i+1]])
            dict_norm[vector_Inverse] = dict_norm[vector]
        sum_norm += dict_norm[vector]
print(sum_norm/math.factorial(N))


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

int main(void) {
  int D;
  cin >> D;

  if (D == 25) {
    cout << "Christmas";
  } else if (D == 24) {
    cout << "Christmas Eve";
  } else if (D == 23) {
    cout << "Christmas Eve Eve";
  } else if (D == 22) {
    cout << "Christmas Eve Eve Eve";
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static void log(String s) {
		System.out.println(s);
	}

	static void log(int i) {
		System.out.println(i);
	}

	static void log(long i) {
		System.out.println(i);
	}

	static void log(double d) {
		System.out.printf("%.12f\n",d);
	}
	

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

		long total=0;
		int gcd1;
		
		for(int i=1; i<=k; i++) {

			for(int j=1; j<=k; j++) {
				gcd1 = gcd2(i,j);
				for(int l=1 ;l<=k; l++) {
					total += gcd2(gcd1,l);
				}
			}
		}
		
		sc.close();
		
		log( total );
		
	}

    public static int gcd2(int m, int n) {
        int r;
        while (n > 0) {
            r = m % n;
            m = n;
            n = r;
        }
        return m;
    }
	
}


Measured memory_bytes: 27176
#include <stdio.h>
 
 
int main(void) {
	unsigned long long int h,w;
	scanf("%lld%lld",&h,&w);
	if(h==1||w==1){printf("1");return 0;}
	
	unsigned long long int ans;
	ans=h*w/2+h*w%2;
    
	printf("%lld",ans);
	// your code goes here
	return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;

int main()
{
    long long n, k;
    cin >> n >> k;
    long long a[n + 1];
    for (long long i = 1; i <= n; i++)
        cin >> a[i];
    vector<long long> path;
    set<long long> pr;

    long long curr = 1;
    path.push_back(curr);
    pr.insert(1);
    long long st = 0;
    while (true)
    {
        curr = a[curr];
        if (pr.find(curr) != pr.end())
        {
            // st = cycle start number
            st = curr;
            break;
        }
        else
        {
            path.push_back(curr);
            pr.insert(curr);
        }
    }
    vector<long long>::iterator it = find(path.begin(), path.end(), st);
    long long b = it - path.begin();
    long long l = path.size();
    long long int i;
    // for(i=0;i<l;i++)
    // {
    //     cout << path[i] << " ";
    // }
    // cout << '\n';
    // cout << b  << " " << l << '\n';
    
    if (k < l)
    {
        cout << path[k] << endl;
        return 0;
    }
    // cout << "YEs\n";
    k -= b;
    l -= b;
    long long rem = (k % l);
    
    // cout << b << " " << rem << '\n';
    if((b + rem) == 0)
    {
        cout << path[b] << endl;
        return 0;
    }    
    cout << a[path[b + rem-1]] << endl;  

    return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//template end



int main(){
    string s; cin>>s;
    int ans=inf;
    rep(rot,0,26){
        int cnt=0,sub=0;
        rep(i,0,s.size()){
            int cur=s[i]-'a';
            if(cur==rot)sub=0;
            else{sub++; chmax(cnt,sub);}
        }
        chmax(cnt,sub); chmin(ans,cnt);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
import sys
def f(A):
  return sorted(A, key=lambda x:x[1])

A = [map(float,s.split()) for s in sys.stdin]
A1 = f(A[0:8])
A2 = f(A[8:16])
A3 = f(A[16:24])
A4 = f(A1[2:]+A2[2:]+A3[2:])

B1 = A1[0:2]+A2[0:2]+A3[0:2]+A4[0:2]

for e in B1:
  print '%d %.2f' %(e[0], e[1])

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

int main(){
  int H,W;
  cin>>H>>W;
  
  /*if(H%3==0||W%3==0){
    cout<<0<<endl;
    return 0;
  }
  */
  int mindif,dif,x,y,z;
  mindif=100000000000000;

  //縦切りその１
  x=(W/3)*H;
  y=(W-(W/3))*(H/2);
  z=W*H-x-y;
  dif=max(max(x,y),z)-min(min(x,y),z);
  mindif=min(mindif,dif);
  //cout<<x<<" "<<y<<" "<<z<<endl;
  //縦切りその２
  x=((W+2)/3)*H;
  y=(W-(W+2)/3)*(H/2);
  z=W*H-x-y;
  dif=max(max(x,y),z)-min(min(x,y),z);
  mindif=min(mindif,dif);  
  //cout<<x<<" "<<y<<" "<<z<<endl;
  //縦切りその４
  x=(W/3)*H;
  y=(W/3)*H;
  z=W*H-x-y;
  dif=max(max(x,y),z)-min(min(x,y),z);
  mindif=min(mindif,dif);  
  //縦切りその４
  x=(W/3)*H;
  y=((W/3)+1)*H;
  z=W*H-x-y;
  dif=max(max(x,y),z)-min(min(x,y),z);
  mindif=min(mindif,dif);
  
  //横切りその１
  x=(H/3)*W;
  y=(H-(H/3))*(W/2);
  z=W*H-x-y;
  dif=max(max(x,y),z)-min(min(x,y),z);
  mindif=min(mindif,dif);  
  //cout<<x<<" "<<y<<" "<<z<<endl;
  //横切りその２
  x=((H+2)/3)*W;
  y=(H-(H+2)/3)*(W/2);
  z=W*H-x-y;
  dif=max(max(x,y),z)-min(min(x,y),z);
  mindif=min(mindif,dif);  
  //cout<<x<<" "<<y<<" "<<z<<endl;
  //横切りその３
  x=(H/3)*W;
  y=(H/3)*W;
  z=W*H-x-y;
  dif=max(max(x,y),z)-min(min(x,y),z);
  mindif=min(mindif,dif);  
   //横切りその４
  x=(H/3)*W;
  y=((H/3)+1)*W;
  z=W*H-x-y;
  dif=max(max(x,y),z)-min(min(x,y),z);
  mindif=min(mindif,dif);  
  
  
  cout<<mindif<<endl;
  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int a[100005],n,k,q;

int main()
{
	cin>>n>>k>>q;
	for(int i=1;i<=n;i++)
		a[i]=(q*-1)+k;
	for(int i=1;i<=q;i++){
		int b;
		cin>>b;
		a[b]++;	
	}
	for(int i=1;i<=n;i++)
		if(a[i]>0) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;
ll fact[101010],invfact[101010],inv[101010];
ll comb(int n,int k){
    if(n<0||k<0||k>n)return 0;
    ll ret=invfact[k]*invfact[n-k]%mod;
    return ret*fact[n]%mod;
}
int main(){
    inv[1]=1;
    REP(i,2,100001)inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    fact[0]=invfact[0]=1;
    rep(i,100000){
        fact[i+1]=fact[i]*(i+1)%mod;
        invfact[i+1]=invfact[i]*inv[i+1]%mod;
    }
    int n,m;
    cin>>n>>m;
    int a[m];
    rep(i,m)cin>>a[m-1-i];
    int all=1<<n;
    ll dp[all];
    int sum[all];
    rep(i,all)sum[i]=i;
    rep(i,all)dp[i]=0;
    dp[0]=all;
    rep(i,m)for(int bit=all-1;bit>=0;bit--)rep(j,n){
        if(bit&(1<<j))continue;
        int cnt=(1<<j);
        cnt--;
        ll res=comb(all-sum[bit]-a[i],cnt)*fact[cnt+1]%mod;
        dp[bit|(1<<j)]+=res*dp[bit];
        dp[bit|(1<<j)]%=mod;
    }
    rep(i,all)dp[i]=dp[i]*fact[all-sum[i]-1]%mod;
    ll ans=0;
    rep(i,all){
        int cnt=__builtin_popcount(i);
        if(cnt%2)ans+=mod-dp[i];
        else ans+=dp[i];
        ans%=mod;
    }
    cout<<ans<<endl;
   return 0;
}

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

using namespace std;

int main()
{
   
   long long n,Y,t,f,o = -1;
   
   cin>>n>>Y;
   
   Y = Y / 1000;
   
   for(t = 0 ; t <= n ; t++){
       for(f = 0 ; f <= n-t ; f++){
           if(9*t+4*f+n-Y==0){
               o = n - f - t;
               break;
           }
       }
       if(o!=-1) break;
   }
   
   if(o==-1){
       cout<<"-1 -1 -1";
   } else
    cout<<t<<' '<<f<<' '<<o;
   
   return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
struct node
{
	ll x,y;
};
node w[3030];
ll n,m,t,f[3030][2],ny[200020],jc[200020];
bool cmp(node a1,node b1)
{
	if(a1.x==b1.x)
		return a1.y<b1.y;
	return a1.x<b1.x;
}
ll ksm(ll d,ll z)
{
	ll base=d,res=1;
	while(z)
	{
		if(z&1)
			res=(res*base)%mod;
		base=(base*base)%mod;
		z>>=1;
	}
	return res;
}
ll c(ll n1,ll m1)
{
	return (jc[n1]*ny[n1-m1]%mod*ny[m1]%mod)%mod;
}
int main()
{
	jc[0]=ny[0]=1;
	for(int i=1;i<=200010;i++)
		jc[i]=(jc[i-1]*i)%mod;
	for(int i=1;i<=200010;i++)
		ny[i]=ksm(jc[i],mod-2);
	cin>>n>>m>>t;
	for(int i=0;i<t;i++)
		cin>>w[i].x>>w[i].y;
	w[t].x=w[t].y=1;
	w[t+1].x=n,w[t+1].y=m;
	sort(w,w+t+2,cmp);
	f[0][0]=1;
	for(int i=0;i<=t+1;i++)
	{
		for(int j=0;j<i;j++)
		{
			if(w[i].y>=w[j].y)
			{
				ll dx=w[i].x-w[j].x,dy=w[i].y-w[j].y;
				f[i][0]=(f[i][0]+(f[j][1]*c(dx+dy,dy))%mod)%mod;
				f[i][1]=(f[i][1]+(f[j][0]*c(dx+dy,dy))%mod)%mod;
			}
			
		}
	}
	cout<<(f[t+1][1]+mod-f[t+1][0])%mod<<endl;
	return 0;
}


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

int main(){
    ll N;
    cin >> N;
    vector<ll> apple(N,0);
    for(int i = 0; i < N; i++){
        cin >> apple[i];
    }

    sort(apple.begin(),apple.end());
    auto result = unique(apple.begin(), apple.end());
    apple.erase(result,apple.end());

    if(apple.size() % 2 == 0){
        cout << apple.size() - 1 << endl;
    }else{
        cout << apple.size() << endl;
    }

}   


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

int main(void) {
	int N, D, X;
	scanf("%d %d %d", &N, &D, &X);
	int A[100];
	int ans = X;
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		ans += (D - 1) / A[i] + 1;
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
 
int main () {
  int N, M;
  cin >> N >> M;
  
  vector<int> H(N, 0);
  vector<int> A(M, 0);
  vector<int> B(M, 0);
  
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  
  for (int i = 0; i < M; i++) {
    cin >> A.at(i) >> B.at(i);
  }
  
  vector<int> good(N, 1);
  
  for (int i = 0; i < M; i++) {
    if (H.at(A.at(i)-1) > H.at(B.at(i)-1)) {
      good.at(B.at(i)-1) = 0;
    } else if (H.at(A.at(i)-1) == H.at(B.at(i)-1)) {
      good.at(A.at(i)-1) = 0;
      good.at(B.at(i)-1) = 0;
    } else {
      good.at(A.at(i)-1) = 0;
    }
  }
  
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (good.at(i)) {
      count++;
    }
  }
  cout << count;
}

Measured memory_bytes: 4844
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>

#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF ll(1e9)
#define INFL ll(1e18)
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int ctoi(char c) {return c - '0';}

class CSqrtInequality {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll a, b, c;
        in >> a >> b >> c;
        ll d = c - a - b;
        string ans = "No";
        if (d > 0 && 4 * a * b < d * d) ans = "Yes";
        out << ans << '\n';
	}
};


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

	CSqrtInequality solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
//----------------------------------------------------------------------
// ITP1_1_C:   Rectangle
//----------------------------------------------------------------------

//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include <iostream>

//----------------------------------------------------------------------
// Definitions
//----------------------------------------------------------------------
class Rectangle
{
public:
    Rectangle( size_t height, size_t width )
        : m_height( height )
        , m_width( width )
    {}

    size_t getArea()
    {
        return m_height * m_width;
    }

    size_t getCircumference()
    {
        return m_height * 2 + m_width * 2;
    }

private:
    size_t m_height;
    size_t m_width;
};

//----------------------------------------------------------------------
// Entry point
//----------------------------------------------------------------------
int main()
{
    size_t a = 0, b = 0;

    std::cin >> a >> b;

    Rectangle rect( a, b );

    std::cout << rect.getArea() << ' ' << rect.getCircumference() << std::endl;

    return 0;
}

Measured memory_bytes: 2996
mod = 10**9+7
rng = 2000100
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
  if n<0 or k<0:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod

x1,y1,x2,y2 = map(int,input().split())
print((cmb(x2+y2+2,x2+1)-cmb(x2+y1+1,y1)-cmb(x1+y2+1,x1)+cmb(x1+y1,x1))%mod)

Measured memory_bytes: 127232
N, K = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)

tele = Hash.new
# 訪れたかどうか
visited =  Hash.new(false)
# 何回目に訪れたか
num = Hash.new(0)


N.times do |i|
  tele[i+1] = a[i]
end


start = 10**10
per = 10**10


cur = 1

point = 0

visited[1] = true
num[1] = 0

1.upto(N) do |i|
  cur = tele[cur]

  if i == K
    puts cur
    exit
  end


  unless visited[cur]
    visited[cur] = true
    num[cur] = i
  else
    per = i - num[cur]
    start = num[cur]
    point = cur
    break
  end

end

m = K-start
step = m % per

(step).times do |i|
  point = tele[point]
end

p point







Measured memory_bytes: 53780
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;
const int maxn = 1e5 + 5;

vector<int>vc[maxn];
queue<int> que;

int in[maxn], sum[maxn];
int n, m, ans;


int main(){
	scanf("%d %d", &n, &m);
	int u, v;
	for(int i = 1; i <= m; i++){
		scanf("%d %d", &u, &v); //u -> v
		vc[u].push_back(v);
		in[v]++;
	}
	int p = 0;
	for(int i = 1; i <= n; i++){
		if(!in[i]) 
			que.push(i);
	}
	int x;
	while(!que.empty()){
		x = que.front();
		que.pop();
		int len = vc[x].size();
		for(int i = 0; i < len; i++){
			int y = vc[x][i];
			in[y]--;
			if(!in[y]) {
				que.push(y);
				sum[y] = sum[x] + 1;
			}
		}
	}
	for(int i = 1; i <= n; i++){
		ans = max(ans, sum[i]);
	}
	printf("%d\n" ,ans);
}

Measured memory_bytes: 6528
S = input()
result = True
for i in range(len(S)):
    if (i + 1) % 2 == 1:
        if S[i] not in ['R','U','D']:
            result = False
            break
    else:
        if S[i] not in ['L','U','D']:
            result = False
            break
print('Yes' if result else 'No')


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cctype>

using namespace std;
using ll = long long;

int main(){
    int n,y;
    cin >> n >> y;
    y /= 1000;
    int a,b,c;
    for(int b = 0; b < n+1; b++){
        a = -1;
        c = -1;
        if(y-n-4*b < 0){
            continue;
        }
        if((y-n-4*b) % 9 == 0){
            a = (y-n-4*b)/9;
            c = n-a-b;
            if(a >= 0 && c >= 0 && a+b+c == n){
                cout << a << " " << b << " " << c << endl;
                return 0;
            }
        }
    }

    if(a == -1 || c == -1){
        cout << -1 << " " << -1 << " " << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n,q = map(int,input().split())
L = []
for i in range(q):
    L.append(list(map(int,input().split())))
par = []
for i in range(n):
    par.append(i)
rank = [0]*n
def find(x,par):
    if x == par[x]:
        return x
    else:
        return find(par[x],par)
def unite(x,y,par,rank):
    x = find(x,par)
    y = find(y,par)
    if x != y:
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1
for i in range(q):
    if L[i][0] == 0:
        unite(L[i][1],L[i][2],par,rank)
    else:
        if find(L[i][1],par) == find(L[i][2],par):
            print(1)
        else:
            print(0)


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

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

struct Edge {
    ll to, cost;
};
typedef vector<vector<Edge> > AdjList;  // 隣接リストの型
AdjList graph;

const ll INF = 1e15;

vector<ll> dist;
vector<ll> pre;


bool bellman_ford(ll n, ll s){
    dist = vector<ll>(n,INF);
    pre = vector<ll>(n,-1);
    dist[s] = 0;
    for(ll i=0;i<n;i++){
        for(ll v=0;v<n;v++){
            for(ll k=0;k<graph[v].size();k++){
                Edge e = graph[v][k];
                if(dist[v] != INF && dist[e.to] > dist[v] + e.cost){
                    dist[e.to] = dist[v] + e.cost;
                    pre[e.to] = v;
                    if(i == n-1)
                    {
                        //cout<< "from:"<<v<<"\tto:"<<e.to<<endl;
                        return true;
                    }
                }
            }
        }
    }
    return false;
}

bool checkPath(ll to)
{
    unordered_set<ll> se;
    for (; to != -1; to=pre[to])
    {
        if(se.find(to)!=se.end()) return false;
        se.insert(to);
    }
    return true;
}

vector<ll> getPath(ll to)
{
    vector<ll> path;
    for (; to != -1; to=pre[to])
    {
        path.push_back(to);
    }
    reverse(all(path));
    return path;
}

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

    graph = AdjList(n);

    for(ll i=0;i<m;i++){
        ll from, to, cost;
        cin >> from >> to >> cost;
        from--;
        to--;
        cost-=p;
        graph[from].push_back((Edge){to,-cost});
    }

    bool hasNega = bellman_ford(n,0);
    //cout<<hasNega<<endl;

    if(checkPath(n-1)==true)
    {
        cout<<max(0LL, -dist[n-1])<<endl;
        /*
        for (ll i = 1; i < n; i++){
        if(dist[i] != INF){
            //cout << i << " " << dist[i] << endl;
        }
        }

        for (int i = 0; i < pre.size(); i++)
        {
            //cout<<"pre:"<<i<<":"<<pre[i]<<endl;
        }
        

        auto path = getPath(n-1);
        cout<<"path: ";
        for (int i = 0; i < path.size(); i++)
        {
            cout<<path[i]<<" ";
        }
        cout<<endl;
        */
    }
    else
    {
        cout<<-1<<endl;
    }
    

    
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
#define ll long long
#define ld long double
#define ms(a,v) memset(a,v,sizeof a)
#define pii pair<int, int>
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor
 *
 * */
int mod = 1000000007;
int main(){
	vector<vector<ll>> pasc(2001, vector<ll>(2001));
	for (ll i=0; i<=2000; ++i){
		pasc[i][0] = pasc[i][i] = 1;
		for (ll k=1;  k<i; ++k) {
			pasc[i][k] = pasc[i-1][k] + pasc[i-1][k-1];
			pasc[i][k]%=mod;
	}	}
	ll n, k; scanf("%Ld %Ld", &n, &k);
	for (ll i=1ll; i<=k; ++i) printf("%Ld\n", (pasc[n-k+1][i]*pasc[k-1][i-1])%mod);
	return 0;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
vector<vector<long long>> edges;
int main() {
    long long N, M;
    cin >> N >> M;
    edges.resize(N);
    vector<long long> a(M), b(M);
    REP(i, M) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        edges[a[i]].push_back(b[i]);
        edges[b[i]].push_back(a[i]);
    }
    for(int i = 0; i < edges[0].size(); i++) {
        int next = edges[0][i];
        for(int j = 0; j < edges[next].size(); j++) {
            if(edges[next][j] == N - 1) {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 15848
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 1e5+5;
const ll mod = 1e9 + 7;

vector <ll> adj[L];
ll dp[L][2];

// col = 1 implies black else white

void dfs(ll src, ll par, ll col)
{
    if(dp[src][col] != -1)
    {
        return;
    }

    dp[src][col] = 1;

    for(auto i: adj[src])
    {
        if(i != par)
        {
            if(col)
            {
                dfs(i, src, col^1);

                dp[src][col] *= dp[i][col^1];
                dp[src][col] %= mod;
            }

            else
            {
                dfs(i, src, col);
                dfs(i, src, col^1);
                dp[src][col] *= ((dp[i][col] + dp[i][col^1])%mod);
                dp[src][col] %= mod;
            }
        }
    }
}

void solve()
{
    ll n = nxt();

    for(ll i=0; i<=n; i++)
    {
        dp[i][0] = -1;
        dp[i][1] = -1;
    }

    for(ll i=0; i<n-1; i++)
    {
        ll u = nxt() - 1, v = nxt() - 1;

        adj[u].pb(v);
        adj[v].pb(u);
    }   

    dfs(0, -1, 0);
    dfs(0, -1, 1);

    cout << (dp[0][0] + dp[0][1])%mod << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

    while(T--)
    {
        solve();
    }

    return 0;
}

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

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    static int dx[]={-1,0,1,0};
    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        
        int n=sc.nextInt();
        int s=0;
        for (int i = 0; i < n; i++) {
			s+=sc.nextInt()%2;
		}
        
        out.println(s>0? "first":"second");
        out.flush();
    }


    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }


    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}


//class P implements Comparable<P>{
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//    public int compareTo(P p){
//        return d-p.d; //des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 34116
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    int n; cin >>n;
    vector<int> a(n); REP(i,n) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());

    double res = 0;
    double num = 1;
    for (int i = 0; i < n-1; i++) {
        num *= 2;
        res += ((double)a[i])/((double)num);
    }
    res += ((double)a[n-1])/((double)num);

    cout << setprecision(12) << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
using namespace std;
int main(void)
{
  set<int> st;
  int n, x;
  int ans=0;
  cin>>n;
  for(int i=0; i<n; i++)
    {
      cin>>x;
      if(st.find(x)== st.end())
	{
	  st.insert(x);
	  ans++;
	}
      else
	{
	  st.erase(x);
	  ans--;
	}
    }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4864
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
//#define ll __int64
#define ll long long
#define P pair<ll,ll>

//int n,k;
//int a[200000];

int main(){
//cin>>n>>k;
//rep(i,n)cin>>a[i];
 ll n,m,ans=0;
	cin>>n>>m;

	if(n>=m/2)ans=m/2;
	else{
		ans=n;
		m-=n*2;
		ans+=m/4;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scn := newScanner()
	N := scn.nextInt()
	A := make([]int, N)
	B := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = scn.nextInt()
		B[i] = scn.nextInt()
	}
	cnt := 0
	for i := N - 1; i >= 0; i-- {
		A[i] += cnt
		if A[i] != 0 && A[i] <= B[i] {
			cnt += B[i] - A[i]
		} else if A[i]%B[i] != 0 {
			cnt += B[i] - A[i]%B[i]
		}
	}
	fmt.Println(cnt)
}

type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) nextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) nextInt() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) nextInt64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (i32 idx = 0; idx < N; idx++)

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

  unordered_map<i32, i32> a;
  vector<i32> v;
  i32 ai;

  rep(i, n) {
    cin >> ai;
    a[ai] += 1;
    v.push_back(ai);
  }

  unordered_map<i32, u64> c;

  u64 sum = 0;
  for (auto ai : a) {
    c[ai.first] = (u64)(ai.second - 1) * ai.second / 2;
    sum += c[ai.first];
  }

  rep(k, n) {
    u64 ans = 0;

    u64 ai = v[k];
    u64 num = a[ai];
    ans = sum - c[ai] + ((num - 1) * (num - 2)) / 2;

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


Measured memory_bytes: 17020
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t,c,m;
    cin>>a>>b>>c;
    for(i=0;i<10;i++)
    {
        c=(a*c)-b;
        cout<<c<<endl;
    }
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
#include<iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

ll p(ll x,ll n) {
	ll res=1;
	while(n) {
		if(n&1) res=(res*x)%MOD;
		x=(x*x)%MOD;
		n/=2;
	}
	return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
   	ll n,i,j;
   	cin >> n;
   	ll a[n],sum=0,setBit, unsetBit;
   	for(i=0;i<n;i++) cin >> a[i];
   	for(i=0;i<60;i++) {
   		setBit=0;
   		for(j=0;j<n;j++) {
   			if((a[j]>>i)&1) setBit++;
   		}
   		unsetBit = n-setBit;
   		sum=(sum+(((setBit*unsetBit)%MOD)*p(2,i))%MOD)%MOD;
   	}
   	cout << sum << "\n";
    return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

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

    string a_s;
    string b_s;
    while (cin >> a_s >> b_s)
    {
        string c_s = a_s + b_s;
        double c = stoi(c_s);
        double c_root = sqrt(c);
        if (pow(floor(c_root), 2) == c)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }

        return 0;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int L= keyboard.nextInt();
		long D = keyboard.nextInt();
		long d = keyboard.nextInt();
		
		long ans = 0;
		
		for(int i = L; i<D+1; i++) {
			if(i%d == 0) {
				ans++;
			}
		}
		
		System.out.print(ans);
		keyboard.close();	
		
	}
}

Measured memory_bytes: 35608
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

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

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

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

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, M, K;
	cin >> N >> M >> K;
	vector<vector<int>> fr(N);
	vector<set<int>> bl(N);
	UnionFind uf(N);
	REP(i, M){
		int a, b;
		cin >> a >> b;
		a--; b--;
		fr[a].push_back(b);
		fr[b].push_back(a);
	}
	REP(i, K){
		int c, d;
		cin >> c >> d;
		c--; d--;
		bl[c].insert(d);
		bl[d].insert(c);
	}
	vector<bool> done(N, false);
	REP(i, N){
		if(done[i]) continue;
		queue<int> que;
		que.push(i);
		done[i] = 1;
		while(que.size()){
			int cur = que.front();
			que.pop();
			EACH(next, fr[cur]){
				if(done[next]) continue;
				uf.unionSet(cur, next);
				que.push(next);
				done[next] = 1;
			}
		}
	}

	REP(i, N){
		int ret = uf.size(i) - fr[i].size() - 1;
		EACH(b, bl[i]){
			if(uf.findSet(i, b)) ret--;
		}
		cout << ret << " ";
	}
	cout << endl;

	return 0;
}


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

using namespace std;

const int MAX_N = 100000, INDEX = 1;

int n, a[MAX_N + INDEX];

vector<int> defeated[MAX_N + INDEX];

int ans[MAX_N + INDEX];

bool compAns(int a, int b) {
    if (ans[a] > ans[b]) {
        return true;
    }

    if (ans[a] < ans[b]) {
        return false;
    }

    return a > b;
}

void DFS(int v) {
    ans[v] = 0;

    for (auto i: defeated[v]) {
        DFS(i);
    }

    sort(defeated[v].begin(), defeated[v].end(), compAns);

    for (int i = 1; i <= defeated[v].size(); i++) {
        ans[v] = max(ans[v], ans[defeated[v][i - 1]] + i);
    }
}

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

    cin >> n;

    for (int i = 2; i <= n; i++) {
        cin >> a[i];
    }

    for (int i = 2; i <= n; i++) {
        defeated[a[i]].push_back(i);
    }

    DFS(1);

//    for (int i = 1; i <= n; i++) {
//        cout << ans[i];
//
//        if (i < n) {
//            cout << ' ';
//        } else {
//            cout << '\n';
//        }
//    }

    cout << ans[1] << endl;

    return 0;
}


Measured memory_bytes: 11136
//ALDS1_4_A Search - Linear Search
#include <iostream>
#include <vector>
using namespace std;

int linierceach(vector<int> &V, int key)
{
    V[V.size() - 1] = key;
    int i = 0;
    while (V[i] != key)
    {
        if (i == V.size() - 2)
            return 0;
        i++;
    }
    return 1;
}

int main()
{
    vector<int> S, T;
    int n, q, t;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> t;
        S.push_back(t);
    }
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        cin >> t;
        T.push_back(t);
    }
    S.push_back(0);
    int sum = 0;
    for (auto a : T)
    {
        sum += linierceach(S, a);
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3164
#include <cstdio>
#include <iostream>

using namespace std;

int main(){
  string str;
  cin >> str;
  int count=0;
  for(int i = 0; i < (int)str.size(); ++i){
    char ch = str[i];
    if(int(ch)=='1') count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
X = list(map(int,input().split()))
def search():
  if N>=M:
    return 0
  X.sort()
  cost=[X[i+1]-X[i] for i in range(M-1)]
  ans_tmp=0
  cost.sort()
  for i in range(M-N):
    ans_tmp+=cost[i]
  return ans_tmp

print(search())

Measured memory_bytes: 13968
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<string > vecstr;
int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  REP(i, 10000){
    if(a*i % b == c){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
} 


Measured memory_bytes: 256