akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
  public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
  public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};


int main(){
  ll n,m,v,p; cin >> n >> m >> v >> p;
  vl a(n); rep(i,n) cin >> a[i];

  sort(all(a));
  reverse(all(a));

  if(v <= p){
    ll num = a[p-1];
    rrep(i,n) {
      if(num - a[i] <= m){
        cout << i+1 << endl;
        return 0;
      }
    }
  }
  
  //rep(i,n) cout << a[i] << " ";
  //cout << endl;
  ll num = a[p-1];
  ll ans = p;
  v = v-p+1;
  //cout << "v:" << v << endl;
  vl b;
  for(int i = p-1; i < n; i++) {
    b.pb(a[i]);
  }
  ll N = b.size();
  //rep(i,N) cout << b[i] << " ";
  //cout << endl;
  vl s(N+1); rep(i,N) s[i+1] = s[i] + b[i];

  rrep(i,N) {
    if(b[0] - b[i] > m) continue;
    ll tmp = v - (N-i);
    if(tmp <= 0){
      //while(i+1 < N && b[i] == b[i+1]) i++;
      cout << ans + i << endl;
      return 0;
    }
    else{
      if(s[i]+m*tmp <= (b[i]+m)*i){
        //while(i+1 < N && b[i] == b[i+1]) i++;
        cout << ans + i << endl;
        return 0;
      }
    }
  }

  cout << ans + 1 << endl;
  
}

Measured memory_bytes: 2676
from bisect import bisect_right, bisect_left
inpl = lambda: list(map(int,input().split()))
N = int(input())
A = inpl()
x = [-1]
y = [0]
for i in range(N):
    if A[i] > y[-1]:
        x.append(i)
        y.append(A[i])
ans = [0] * N
L = len(x)
k = [0] * (L+1)
i = N-1
base = y[-1]
for n in range(L-1,0,-1):
    roof = base
    base = y[n-1]
    height = roof - base
    k[n] += k[n+1]
    ans[x[n]] += k[n] * height
    while i >= x[n]:
        p = bisect_left(y, A[i])
        ans[x[p]] += A[i] - y[p-1]
        k[p-1] += 1
        i -= 1
for i in range(N):
    print(ans[i])


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

int main() {
	int n;cin>>n;
	int a[n];
	vector<int> c(9,0);
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]<3200){
			int j=a[i]/400;
		c[j]++;
		}else{
			c[8]++;
		}
	}
	int min=0;
	for(int i=0;i<8;i++){
		if(c[i])min++;
	}
	int max=min+c[8];
//	if(max>8){
//		max=8;
//	}
	if(min==0)min=1;
	cout<<min<<' '<<max<<endl;

	return 0;
}


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

int n,m,ans;
signed main(){
    cin>>n>>m;
    if(n==1||m==1) return puts("1"),0;

    ans=m*(n/2);
    if(n%2){
        if(m%2) ans+=m/2+1;
        else ans+=m/2;
    }

    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n,K;cin>>n>>K;
  vector<P>v(n);
  rep(i,n)cin>>v[i].first>>v[i].second;
  sort(v.begin(),v.end());
  ll ans=INF*5;
  rep(i,n){
    for(ll j=i+K-1;j<n;j++){
      vl part;
      for(ll k=i;k<=j;k++){
        part.push_back(v[k].second);
      }
      sort(part.begin(),part.end());
      ll t=part.size();
      rep(k,t){
        if(k+(K-1)>=t)continue;
        ans=min(ans,(part[k+(K-1)]-part[k])*(v[j].first-v[i].first));
      }
    }
  }
  cout<<ans<<endl;
}
      
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x = c/b;
  if(c>(x*b))
  {
    x++;
  }
  int y = a/d;
  if(a>(y*d))
  {
    y++;
  }
  if(x>y)
  {
    cout<<"No";
  }
  else
  {
    cout<<"Yes";
  }
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int maxn = 1e5 + 10;
int n;
int d[maxn];
int cnt[maxn];
int pw(int a, int n) {
	int res = 1;
	while(n) {
		if(n & 1) res = 1LL * res * a % mod;
		n >>= 1, a = 1LL * a * a % mod;
	}
	return res;
}
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &d[i]);
	if(d[1] != 0) 
		return puts("0"), 0;
	for(int i = 2; i <= n; i++) 
		if(d[i] == 0) return puts("0"), 0;
	for(int i = 1; i <= n; i++) 
		cnt[d[i]]++;
	int ans = 1;
	int tot = 0;
	for(int dis = 0;; dis++) {
		if(cnt[dis] == 0) {
			if(tot != n) return puts("0"), 0;
		}
		if(tot + cnt[dis] == n) break;
		ans = 1LL * ans * pw(cnt[dis], cnt[dis + 1]) % mod;
		tot += cnt[dis];
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 1024
flag=False
while True:
    a,b=map(int,raw_input().split())
    if (a,b)==(0,0):
        break
    if not flag:
        flag=True
    else:
        print
    ans=[y for y in xrange(a,b+1) if (y%4==0 and not y%100==0) or y%400==0]
    if not ans:
        print "NA"
    else:
        print "\n".join(map(str,ans))

Measured memory_bytes: 4260
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N,x = MI()
if x == 1 or x == 2*N-1:
    print('No')
    exit()

print('Yes')
A = [i for i in range(1,2*N)]
A = A + A + A
print(*A[x+N-1:x+3*N-2],sep='\n')


Measured memory_bytes: 108564
#include <iostream>
#include <string>
#include <vector>
#include <bitset>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector <long> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  
  sort(A.begin(), A.end(), [](long l, long r) { return l > r; });
  
  long long ans = 0;
  ans += A[0];
  int j = 1;
  int i = 0;
  int p = 0;
  for (i = 0; i < N - 2; ++i) {
    ans += A[j];
    p = (p + 1) % 2;
    if (p == 0) {
      j++;
    }
  }
  
  cout << ans << endl;
    
  return 0;
}

Measured memory_bytes: 4476
import itertools
  
n = int(input())
l = list(map(int, input().split()))
index_list = [i for i in range(n)]

def is_triangle(a, b, c):
    if a + b <= c:
        return False
    if b + c <= a:
        return False
    if c + a <= b:
        return False
    if abs(a - b) >= c:
        return False
    if abs(b - c) >= a:
        return False
    if abs(c - a) >= b:
        return False
    return True

ans = 0
for i1, i2, i3 in itertools.permutations(index_list, 3):
#   print(f"{a} {b} {c}")
    if l[i1] != l[i2] and l[i2] != l[i3] and l[i1] != l[i3]:
    # if len(set(l[i1], l[i2], l[i3])) == 3:
        if i1 < i2 < i3:
            if is_triangle(l[i1], l[i2], l[i3]):
                # print(f"{i1 + 1} {i2 + 1} {i3 + 1}")
                ans += 1
print(ans)

Measured memory_bytes: 9136
// #includes {{{
#include <bits/stdc++.h>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

Int x;

int main(){
	cin>>x;//1,6,5,6,5,
	x--;
	Int r = x%11, q = x/11;
	if(r<=5)cout<<q*2+1<<endl;
	else cout<<q*2+2<<endl;
	return 0;
}

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

import static java.lang.Integer.parseInt;

/**
 * Problem B: Matsuzaki Number
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		boolean[] primes = primes(100_0000);

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int N, P;
			N = parseInt(line.substring(0, line.indexOf(' ')));
			P = parseInt(line.substring(line.indexOf(' ') + 1));
			if (N == -1 || P == -1) break;

			List<Integer> _primes = new ArrayList<>();
			for (int i = N + 1; ; i++) {
				if (primes[i]) {
					_primes.add(i);
					if (_primes.size() == P) {
						break;
					}
				}
			}

			List<Integer> ans = new ArrayList<>();
			for (int i = 0; i < _primes.size(); i++) {
				for (int j = 0; j < _primes.size(); j++) {
					if (i <= j) {
						ans.add(_primes.get(i) + _primes.get(j));
					}
				}
			}
			Collections.sort(ans);
			System.out.println(ans.get(P - 1));
		} //end while
	} //end main

	static boolean[] primes(int limit) {

		boolean[] ps = new boolean[limit + 1];
		int _limit = (int) Math.ceil(Math.sqrt(ps.length));

		Arrays.fill(ps, 2, ps.length, true);

		for (int i = 2; i <= _limit; i++) {
			if (ps[i]) {
				for (int j = i * 2; j < ps.length; j += i) {
					if (ps[j]) ps[j] = false;
				}
			}
		}
		return ps;
	}
}

Measured memory_bytes: 66384
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int R; cin >> R;

	if(R < 1200) cout << "ABC" << endl;
	else if(R < 2800) cout << "ARC" << endl;
	else  cout << "AGC" << endl;


	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstring>
#include<cmath>
using namespace std;
int num[100001];
int n;
int t;
int ans;
int cnt;
int sum;
int maxn=-99;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>t;
		maxn=max(t,maxn);
		num[t]++;
	}
	for(int i=1;i<=maxn;i++)
	{
		if(num[i]) ans++;
	}
	for(int i=1;i<=maxn;i++)
	{
		if(num[i]>1) sum+=num[i]-1;
	}
	if(sum%2==1) cout<<ans-1<<endl;
	else cout<<ans<<endl;
	return 0;
}

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

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
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();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

signed main() {
  int N;
  cin >> N;
  vector<int> a(N), b(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  for (int i = 0; i < N; i++) cin >> b[i];

  int ans = 0, x = 1;
  for (int j = 0; j < 30; j++) {
    vector<int> aa(N), bb(N);
    for (int i = 0; i < N; i++) {
      aa[i] = a[i] % (x * 2);
      bb[i] = b[i] % (x * 2);
    }

    sort(ALL(aa));

    int s = 0;
    for (int i = 0; i < N; i++) {
      if (bb[i] < x) {
        s += lower_bound(ALL(aa), x * 2 - bb[i]) - lower_bound(ALL(aa), x - bb[i]);
      } else {
        s += lower_bound(ALL(aa), x * 2 - bb[i]) - aa.begin();
        s += aa.end() - lower_bound(ALL(aa), x * 3 - bb[i]);
      }
    }
    ans += (1 << j) * (s % 2);
    x *= 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6572
#include<bits/stdc++.h>
using namespace std;
//define
#define int long long
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define pb() push_back()
#define mod 100000007
#define elif else if
#define str string

signed main(){
  int N,M,O,P,X,count=0,count2=0;
  double D=0,d;
  int c='A'-'a';
  //char C;
  str S,T;
  cin>>N;
  rep(N/2,N+1){
    d=i*1.08;
    M=d;
    if(M==N)count=i;
  }
  if(count!=0)cout<<count<<endl;
  else cout<<":("<<endl;
}


Measured memory_bytes: 256
n,x=map(int,input().split())
a=list(map(int,input().split()))

res=0
i=0
a.sort()

while 0<x and i < n:
    if a[i] <= x:
        res+=1
    x-=a[i]
    i+=1
if 0 < x:
    print(res-1)
else:
    print(res)

Measured memory_bytes: 9180
import java.io.*;
public class Main{
  public static void main(String[] args){
    int D=1;
    int N=1;
    String buf1,buf2,buf3;
    try{
      BufferedReader br
          = new BufferedReader(new InputStreamReader(System.in));

      buf1 = br.readLine();
      buf2 = buf1.substring(0,buf1.indexOf(" "));
      buf3 = buf1.substring(buf1.indexOf(" ")+1);
      D= Integer.parseInt(buf2);
      N = Integer.parseInt(buf3);

  } catch(Exception e) {
      System.out.print("Error:" + e);
  }
    if(N<=100){
    if(D==0){
     if(N==100){System.out.println(N+1);}
     else{System.out.println(N);}}
     if(D==1){
       if(N==100){System.out.println(N*101);}
     else{System.out.println(N*100);}}
    if(D==2){
       if(N==100){System.out.println(N*10100);}
     else{System.out.println(N*10000);}}
    }


  }
}

Measured memory_bytes: 24404
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);
const long double PI=3.14159265358979;

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    vector<ll> A,B;
    FORI(i,0,N)
    {
        READV(l);
        READV(r);
        A.pb(l);
        B.pb(r);
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if(N%2==1)
    {
        cout<<max(0LL,B[N/2]-A[N/2]+1)<<endl;
    }
    else
    {
        cout<<max(0LL,B[N/2]+B[(N/2)-1]-A[N/2]-A[(N/2)-1]+1)<<endl;
    }
    

//-----------------------------------------------------------------------------------------------------------//


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

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


#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int x,y;
    cin >> x >> y;
    if(x%y==0){
        put(-1);
    }else{
        put(x);
    }
    return 0;
}


Measured memory_bytes: 764
N, M, X, Y = list(map(int, input().split()))
cx = list(map(int, input().split()))
cy = list(map(int, input().split()))
if min(cy) - max(cx) < 1:
    print("War")
    exit()
z_max = min(cy)
z_min = max(cx) + 1
if z_min > Y or X+1 > z_max:
    print("War")
else:
    print("No War")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int n, k;
    cin >> n >> k;
    if (k % 2 == 1) {
        ll ans = n / k;
        cout << ans * ans * ans << "\n";
    } else {
        ll ans = n / k;
        ll temp = n * 2 / k - ans;
        cout << ans * ans * ans + temp * temp * temp << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
#define repprev(i,a,b) for(ll i=b-1;i>=a;i--)
#define reprev(i,n) repprev(i,0,n)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> int former(const vector<T> &v, T x){
   return upper_bound(v.begin(),v.end(),x) - v.begin() - 1;
}
template<class T> int latter(const vector<T> &v, T x){
    return lower_bound(v.begin(),v.end(),x) - v.begin();
}
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
#define BIT_FLAG_1 (1<<1) // 0000 0000 0000 0010
#define BIT_FLAG_2 (1<<2) // 0000 0000 0000 0100
#define BIT_FLAG_3 (1<<3) // 0000 0000 0000 1000
#define BIT_FLAG_4 (1<<4) // 0000 0000 0001 0000
#define BIT_FLAG_5 (1<<5) // 0000 0000 0010 0000
#define BIT_FLAG_6 (1<<6) // 0000 0000 0100 0000
#define BIT_FLAG_7 (1<<7) // 0000 0000 1000 0000
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INF = 1<<29;

const int MAX = 510000;
const int MOD = 1000000007;



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


int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	string s;
	cin >> s;
	int ans = INF;
	rep(i,s.size()-2){
		string tmp = "";
		REP(j,i,i+3){
			tmp += s[j];
		}
		int n = stoi(tmp);
		chmin(ans, abs(753 - n));
	}                           
	cout << ans << endl;                                          
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

ll A[10];
ll B[10];
ll T[10];

ll mygcd(ll a,ll b){
    return a?mygcd(b%a,a):b;
}

int main()
{
    ll n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int idx = -1;
    int tc;
    ll totA,totB;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>T[1]>>T[2];
    cin>>A[1]>>A[2];
    cin>>B[1]>>B[2];

    totA = A[1]*T[1]+A[2]*T[2];
    totB = B[1]*T[1]+B[2]*T[2];

    if(totA==totB){
        cout<<"infinity\n";
        return 0;
    }

    if(totA>totB){
        swap(A[1],B[1]);
        swap(A[2],B[2]);
        swap(totA,totB);
    }

    //cout<<totA<<"\n"<<totB<<"\n";
    //cout<<totB-totA<<"\n";

    ll res = 0;

    if(B[1]<A[1]){
        res+=((T[1]*(A[1]-B[1]))/(totB-totA));
    }

    ll cur;

    x = (A[2]-B[2])*T[2]+(A[1]-B[1])*T[1];
    y = (A[1]-B[1])*T[1];

    if(!(y%(totB-totA))&&y>=0)res--;

    if(x<y)swap(x,y);

    if(x>=0){

        y = max(0LL,y);
        res+=(x/(totB-totA)-y/(totB-totA));
        if(!(y%(totB-totA)))res++;
    }

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int i,j,n,count=2,a[1000000];
    while(scanf("%d",&n)!=EOF){
		if (n<=1) {
			count=0;
		}else if (n==2) {
			count=1;
		}else{
			a[0]=2;
			a[1]=3;
			for(i=5;i<=n;i+=2) {
				j=0;
				while(a[j]*a[j]<=i){
					if(i%a[j]==0){ 
						break;
					}
					j++;
				}
				if (a[j]*a[j]>i) {
					a[count]=i;
					count++;
				}
			}
		}
		printf("%d\n",count);
		count=2;
	}
	return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <random>
#include <set>
#include <algorithm>

using namespace std;

int main() {
    
    int n, k;
    cin >> n >> k;
    
    int p = 0;
    for (int i = 0; i < n; ++i)
    {
        int num;
        cin >> num;
        if (num == 1)
        {
            p = i;
        }
    }
    
    int ret = 1000000;
    int c = 1;
    for (int i = 0; i < k; ++i)
    {
        c = 1;
        if (p - i > 0)
        {
            c += (((p - i) / (k - 1)) + (((p - i) % (k - 1) == 0) ? 0 : 1));
        }
        if (p + k - 1 - i < n - 1)
        {
            c += (((n - p - k + i) / (k - 1)) + (((n - p - k + i) % (k - 1) == 0) ? 0 : 1));
        }
        ret = min(ret, c);
    }
    
    cout << ret << endl;
    
    return 0;
}


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

int main()
{
	int n;
	while (scanf("%d", &n), n){
		vector<int> board(1, (1 << 5) - 1);
		int res = 0;
		for (int i = 0; i < n; i++){
			int d, p, q;
			scanf("%d %d %d", &d, &p, &q);
			--q;
			
			int block = 0, num;
			if (d == 1){
				for (int j = 0; j < p; j++){
					block |= 1 << (q + j);
				}
				num = 1;
			}
			else {
				block = 1 << q;
				num = p;
			}
			
			for (int j = 0; j < num; j++){
				for (int h = board.size(); h > 0; h--){
					if (!(board[h - 1] & block)) continue;
					if (h == board.size()) board.push_back(0);
					board[h] |= block;
					break;
				}
			}
			
			res += p;
			for (int h = board.size() - 1; h > 0; h--){
				if (board[h] == (1 << 5) - 1){
					board.erase(board.begin() + h);
					res -= 5;
				}
			}
		}
		printf("%d\n", res);
	}
	return 0;
}

Measured memory_bytes: 1264
# -*- coding: utf-8 -*-
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
write = sys.stdout.write
# template


def resolve():
    ofs = 1000
    h, w = map(int, readline().split())
    A = [list(map(int, readline().split())) for i in range(h)]
    B = [list(map(int, readline().split())) for i in range(h)]
    dp = [[0]*w for _ in range(h)]
    x = abs(A[0][0]-B[0][0])
    dp[0][0] |= ((1 << (ofs+x)) | (1 << (ofs-x)))

    for i in range(h):
        for j in range(w):
            x = abs(A[i][j]-B[i][j])
            t = 0
            if(i-1 >= 0):
                t |= dp[i-1][j]
            if(j-1 >= 0):
                t |= dp[i][j-1]
            dp[i][j] |= ((t << x) | (t >> x))

    for i, s in enumerate(bin(dp[-1][-1])[-ofs-1:]):
        if(s == '1'):
            print(i)
            return


if __name__ == "__main__":
    INF = float("inf")
    MOD = 10**9+7
    resolve()


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

	

int main(){
	int n;
	cin >> n;
	vector<int> l(n);
	//priority_queue<int> l;
	rep(i,n){
		//int length;
		cin >> l[i];
	}
	sort(l.rbegin(), l.rend());
	
	int count=0;
	rep(i,n){
		for(int j=i+1; j<n; j++){
			if(l[i]/2 > l[j]-1) break;
			for( int k=j+1; k<n; k++){
				if(l[i] < l[j]+l[k]){
					count++;
				}
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
#define MAX 1000100

int prime[MAX-4];

void is_prime(){
    for(int i = 0 ; i < MAX ; i++) prime[i] = 0;
    prime[0] = prime[1] = 1;
    for(int i = 4 ; i < MAX ; i += 2) prime[i] = 1;
    
    for(int i = 3 ; i*i < MAX ; i++){
        if(prime[i]) continue;
        for(int j = i*2 ; j < MAX ; j+= i)
            prime[j] = 1;
    }
}

    int main(){
        int n;
        
        is_prime();
        
        while(true){
            cin >> n;
            if(!n) break;
            
            int cnt = 0;
            for(int i = 2 ; i <= n/2 ; i++){
                if(!prime[i]&&!prime[n-i]) cnt++;
            }
            cout << cnt << endl;
        }
        
        return 0;
    }

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

int main() {
  string S;
  cin >> S;
  if (S == "SUN") {
    cout << 7 << endl;
  } else if (S == "MON") {
    cout << 6 << endl;
  } else if (S == "TUE") {
    cout << 5 << endl;
  } else if (S == "WED") {
    cout << 4 << endl;
  } else if (S == "THU") {
    cout << 3 << endl;
  } else if (S == "FRI") {
    cout << 2 << endl;
  } else if (S == "SAT") {
    cout << 1 << endl;
  }
}


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


int main() {
	int N,M;
	cin >> N >> M;
	vector<int> val(N, 0);
	vector<int> cnt(N, 1);
	val[0] = 1;
	
	for(int i=0; i<M; i++) {
		int x, y;
		cin >> x >> y;
		x--;y--;
		cnt[x]--;
		cnt[y]++;
		if(val[x] == 1) {
			val[y] = 1;
			if(cnt[x] == 0) val[x] = 0;
		}
	}
	int ans = 0;
	for(int i=0; i<val.size(); i++)
		ans += val[i];
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
using namespace std;

char ss[12][12];

void dfs(int x, int y) {
  if (x < 0 || y < 0 || x >= 12 || y >= 12 || ss[y][x] == '0')
    return;
  ss[y][x] = '0';
  dfs(x + 1, y);
  dfs(x - 1, y);
  dfs(x, y + 1);
  dfs(x, y - 1);
}
int main() {
  int n, ans = 0;
  while (cin >> ss[0][0]) {
    ans = 0;
    rep(i, 12) rep(j, 12) {
      if (i == 0 && j == 0)
        ;
      else
        cin >> ss[i][j];
    }
    rep(i, 12) rep(j, 12) {
      if (ss[i][j] == '1') {
        ans++;
        dfs(j, i);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3008
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AFiveVariables solver = new AFiveVariables();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFiveVariables {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            ArrayList<Integer> list = new ArrayList<>();
            while (in.hasNext()) list.add(in.nextInt());

            out.println(list.indexOf(0) + 1);
        }

    }

    static class Scanner {
        private final InputStream in;
        private final byte[] buffer;
        private int ptr;
        private int buflen;

        public Scanner(InputStream in) {
            this.in = in;
            this.buffer = new byte[1024];
            this.ptr = 0;
            this.buflen = 0;
        }

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

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

        private boolean isPrintableChar(byte c) {
            return '!' <= c && c <= '~';
        }

        private void skipUnprintable() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
                ptr++;
            }
        }

        public boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

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

    }
}



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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }


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

    string S;
    cin >> S;
    S[3] = '8';

    cout << S << endl;


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n = 0;
void dfs(string cur, char mx) {
  if(cur.size() == n) {
    cout << cur << endl;
    return;
  }
  for(char c = 'a'; c <= mx + 1; c++) {
    string t = string(cur + c);
    dfs(t, max(c, mx));
  }
}
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //everytime when i do virtual contest someone disturbs, wtf

  cin >> n;

  dfs("a", 'a');

  return 0;
}
/*

*/


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int a[200000];
int main(){
	int h,n;cin>>h>>n;
	ll sum=0;
	rep(i,n){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	if(sum>=h)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 640
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] abc = Console.ReadLine().Split(' ');
            int a = int.Parse(abc[0]);
            int b = int.Parse(abc[1]);
            int c = int.Parse(abc[2]);

            int d = a - b;
            int e = c - d;
            if(e < 0) { e = 0; }

            Console.WriteLine(e);


        }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), X = sc.nextInt();
		int[] L = new int[N];
		for(int i = 0; i < N; i++) L[i] = sc.nextInt();
		int D = 0;
		int ans = 1;
		for(int i = 0; i < N; i++) {
			D = D + L[i];
			if(D <= X) ans++;
		}
		System.out.println(ans);
	}
}

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

using namespace std;

typedef long long ll; 
typedef long double ld;

int main() {
	
	// make input and output more efficient
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	
	
	// to read whole line
	//string s;
	//getline(cin, s);
	
	char a;
	
	cin >> a;
	
	if(a<='z' && a>='a')
		cout << "a\n";
	else 
		cout << "A\n";
	
	return 0;
}


Measured memory_bytes: 3568
s = list(input())
t = list(input())
count = 0
if s == t:
    print("Yes")
    exit()
for i in range(len(s)):
    s.append(s.pop(0))
    if s == t:
        print("Yes")
        count += 1
        break
if count == 0:
    print("No")

Measured memory_bytes: 3060
//Atcoder-AGC003-B-Simplified mahjong 
#include <bits/stdc++.h>
using namespace std;
long long a[100005];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin >> a[i];
	long long ans=0;
	for(int i=0;i<n;i++){
		ans+=a[i]/2;
		a[i]%=2;
		if(a[i]&&a[i+1]){
			ans++;
			a[i]--;
			a[i+1]--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
int main(void){
    int S,h,m,s;
    scanf("%d",&S);
    h = S/3600;
    m = (S/60)%60;
    s = (S%3600)%60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

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

int main() {
  int n, m, k;
  map<int, int> d;
  cin >> n;
  rep (i, n) {
    cin >> k;
    d[k]++;
  }

  // cout << "-----------" << endl;
  // for (pair<int, int> p : d) {
  //   cout << p.first << ": " << p.second << endl;
  //   cout << d[p.first] << endl;
  // }
  // cout << "-----------" << endl;

  cin >> m;
  rep (i, m) {
    cin >> k;
    if (d[k] > 0) {
      d[k]--;
    }
    else {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
char s[200005];
int mp[67110000];
int hsh[200005];
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	for (int i=1;i<=n;i++)
		hsh[i]=hsh[i-1]^(1<<(s[i]-'a'));
	memset(mp,120,sizeof(mp));
	mp[0]=0;
	for (int i=1;i<=n;i++){
		int tmp=1e9;
		for (int j=0;j<26;j++)
			tmp=min(tmp,mp[hsh[i]^(1<<j)]+1);
		if (i==n) printf("%d",min(tmp,mp[hsh[i]]+1));
		else mp[hsh[i]]=min(mp[hsh[i]],tmp);
	}
}

Measured memory_bytes: 263424
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.first+a.second > b.first+b.second; }

int main() {
	SS(ll,n);
	SV(ll,a,n-1);
	vl ans(n);
	rep(i,n-1){
		ans[a[i]-1]++;
	}
	rep(i,n){
		p(ans[i]);
	}
}

Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const double pi=3.14159265358979323846;
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b){
    if (a % b == 0){
        return(b);
    }else{
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
bool isprime(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}
void sayYes(bool f) {
    if (f) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
void sayYES(bool f) {
    if (f) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

int main() {
  int n;
  cin >> n;
  vector<int> x=input(n);
  double ave=0;
  rep(i,n){
    ave+=x[i];
  }
  ave/=(double)n;
  if(ave-floor(ave)>ceil(ave)-ave){
    ave=ceil(ave);
  }else{
    ave=floor(ave);
  }
  ll ans=0;
  rep(i,n){
    ans+=(x[i]-ave)*(x[i]-ave);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

a,b = inp
puts (a==b)? "Yes" : "No"

Measured memory_bytes: 2044
a,b,c,d = (int(i) for i in input().split())
def gcd(x,y):
	if x%y==0: return y
	else: return gcd(y,x%y)
if a==c or b==d: ans = 0
else:
	n = gcd(abs(a-c),abs(b-d))
	e,f = abs(a-c)//n,abs(b-d)//n
	ans = (e+f-1)*n
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
 
int main() {
	int F[100][10], P[100][11], p[100] = { 0 }, N;
	long long int sum = 0, max = 0;
 
	cin >> N;
	for (int i = 0; i<N; i++)for (int j = 0; j<10; j++) cin >> F[i][j];
	for (int i = 0; i<N; i++)for (int j = 0; j<11; j++) cin >> P[i][j];
 
	for (int i = 1; i<1024; i++) {
		for (int j = 0; j<N; j++)p[j] = 0;
		for (int j = 0; j<11; j++)
			if ((i>>j)%2)
				for (int k = 0; k<N; k++)p[k] += F[k][j];
		sum = 0;
		for (int j = 0; j < N; j++) sum += P[j][p[j]];
		if (i == 1 || sum > max)max = sum;
	}
	cout << max << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

#define rep(i,n) for(int i=0; i<(n); i++)

using namespace std;
typedef pair<int,int> pii;

template<typename A, size_t N, typename T>
void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const int INF = 0x3fffffff;

int V, E;
int C[1005];
int F[1005];
vector<pii> e[105];

int solve(int n, int c, bool bf[105]){
	if( n == V-1 ) return c;
	bf[n] = true;
	for(auto to: e[n]){
		int i = to.second;
		int cc = ( i>0 ? C[i]-F[i] : F[-i] );
		if( bf[to.first] || cc == 0 ) continue;
		int flow = solve(to.first, min(c, cc), bf); 
		if( flow > 0 ){
			F[ abs(i) ] += flow * (i/abs(i));
			return flow;
		}
	}
	return 0;
}

int main(){
	cin >> V >> E;
	for(int i=1; i<=E; i++){
		int u, v, c;
		cin >> u >> v >> c;
		e[u].emplace_back(v,  i);
		e[v].emplace_back(u, -i);
		C[i] = c;
	}

	int ans = 0;
	bool bf[105] = {};
	for(int add; add = solve(0, INF, bf); Fill(bf, false) ) ans += add;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define ll long long int
#define mod 1e9+7
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int t;
   t=1;
   while(t--)
   {
     double d,t,s;
     cin>>d>>t>>s;
     if(d<=(s*t))
        cout<<"Yes\n";
            else
            cout<<"No\n";
   }
}


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

int n,k;
long long T[100000];

int P(long long p)
{
	int i=0,j;
	long long s;
	for(j=0;j<=k-1;j++)
	{
		s=0;
		while(s+T[i]<=p)
		{
			s+=T[i];
			i++;
			if(i==n) return n;
		}
	}
	return i;
}


int main()
{
	int i;
	long long left=0;
	long long right;
	long long mid;
	int v;
	
	scanf("%d%d",&n,&k);
	right=10000*n;
	for(i=0;i<=n-1;i++) scanf("%d",&T[i]);
	while(right-left>1)
	{
		mid=(right+left)/2;
		v=P(mid);
		if(v>=n) right=mid;
		else left=mid;
	}
	printf("%d\n",right);
	return 0;
}

Measured memory_bytes: 3980
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define saken string
#define erba continue
#define vl vector<ll>
#define vi vector<int>
#define vli vector <pair <ll, int> >
#define vll vector <pair <ll, ll> >
using namespace std;

ll n, s, a[111];

int main(){

cin >> n >> s;

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

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

ll ans = 0;

bool check = 0;

for(int i = 1; i <= n; ++i) {

    if(s >= a[i]) {ans++; s -= a[i];}
    else {check = 1; break;}

}

if(s) {

    if(!check) {ans--;}

}

cout << max(ans, 0ll);

return 0;
}



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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

// Supports two operations.
// - Adds a value to a single element.
// - Returns a sum of a range.
// Verified: CF573Div1D
class BinaryIndexedTree {
 private:
  int n;
  vector<int> xs;
 public:
  BinaryIndexedTree(int n) : n(n), xs(n) {}

  // Adds x to the i-th element.
  void Add(int i, int x) {
    int cur = i;
    while (cur < n) {
      xs[cur] += x;
      cur = cur | (cur + 1);
    }
  }

  // Returns a sum of a range [l r).
  int SumOfRange(int l, int r) {
    if (l >= r) return 0;
    if (l > 0) {
      return SumOfRange(0, r) - SumOfRange(0, l);
    }
    int s = 0;
    int i = r - 1;
    while (i >= 0) {
      s += xs[i];
      i = (i & (i + 1)) - 1;
    }
    return s;
  }
};

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  vector<BinaryIndexedTree> bits(26, BinaryIndexedTree(n));
  for (int i = 0; i < n; i++) {
    bits[s[i] - 'a'].Add(i, 1);
  }

  int q_count;
  cin >> q_count;
  for (int q = 0; q < q_count; q++) {
    int q_type;
    cin >> q_type;
    if (q_type == 1) {
      int index;
      char c;
      cin >> index >> c;
      index--;
      if (s[index] != c) {
        bits[s[index] - 'a'].Add(index, -1);
        bits[c - 'a'].Add(index, 1);
        s[index] = c;
      }
    } else if (q_type == 2) {
      int l, r;
      cin >> l >> r;
      l--;
      // [l, r)
      int count = 0;
      for (int i = 0; i < 26; i++) {
        if (bits[i].SumOfRange(l, r) > 0) {
          count++;
        }
      }
      cout << count << endl;
    }
  }
}

Measured memory_bytes: 53660