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


int main(){
  int n;
  cin >> n;
  vector<int> t(n),x(n),y(n);
  for(int i=0;i<n;++i){
    cin >> t[i] >> x[i] >> y[i];
  }
  int ti=0;
  for(int i=0;i<n;++i){
    int sat=0;
    int sa;
    if(i==0){
      sat=t[i]-0;
      sa=abs(x[i]-0)+abs(y[i]-0);
    }else{
      sat=t[i]-t[i-1];
      sa=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
    }
    if(sa>sat){
      cout << "No" << endl;
      return 0;
    }
    if(sa%2==0 && sat%2!=0){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main(){
  int N,L;
  cin >> N >> L;
  vector <string> S(N);
  for(int i=0;i<N;i++){
    cin >> S.at(i);
  }
  sort(S.begin(),S.end());
  string A="";
  for(string x : S){
    A+=x;
  }
  cout << A << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#define REP(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<vector<int> > c(n,vector<int>(n));
	REP(i,n){
		REP(j,n){cin >> c[i][j];
		}
	}
	long long ans = 0;
	REP(i,n){
		REP(j,n){
			if(i == j)continue;
			ans += min(c[i][j],c[j][i]);
		}
	}
	cout << ans / 2 << endl;
  return 0;
}

Measured memory_bytes: 3260
# https://betrue12.hateblo.jp/entry/2018/10/06/224032

n = int(input())
x, y, h = [], [], []
for i in range(n):
	a, b, c = map(int, input().split())
	x.append(a)
	y.append(b)
	h.append(c)


for i in range(101):
	for j in range(101):
		H = -1
		Hmax = 2 * 10 ** 9
		success = True
		for k in range(n):
			d = abs(i - x[k]) + abs(j - y[k])
			if h[k] > 0:
				H2 = h[k] + d
				if H > 0 and H != H2:
					success = False
					break
				else:
					H = H2
			else: # h[k] == 0
				Hmax = min(Hmax, d)
		
		if success and H <= Hmax:
			print(i, j, H)
			exit()

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

using namespace std;

typedef long long ll;

const int N = 2e5+5;

int n;
int a[N];
int b[N];
int c[N];

int main(){
    scanf("%d " , &n);
    for(int i = 1; i <= n; i++){
        scanf(" %d" , &a[i]);
    }
    for(int i = 1; i <= n; i++){
        scanf(" %d" , &b[i]);
    }
    for(int i = 1; i <= n; i++){
        scanf(" %d" , &c[i]);
    }
    sort(a + 1 , a + n + 1);
    sort(c + 1 , c + n + 1);

    long long ans = 0;
    for(int i = 1; i <= n; i++){
        //a < b < c
        auto f = upper_bound(a + 1 , a + n + 1 , b[i] - 1);
        auto s = upper_bound(c + 1 , c + n + 1 , b[i]);
        /*if(b[i] <= a[1])
            continue;
        if(b[i] >= c[n])
            continue;*/
        long long v1 = f - a - 1;
        long long v2 = n - (s - c) + 1;
        //cout << i << " " << v1 << " " << v2 << "\n";
        ans += v1 * v2;
    }
    printf("%lld\n" , ans);
}


Measured memory_bytes: 5004
#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 int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<string> vecstr;
typedef vector<char> vecchar;
typedef vector<bool> vecbool;
typedef vector<vector<bool>> vec2bool;
typedef vector<vector<int>> vec2int;
typedef vector<vector<double>> vec2d;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int n1 = (a + d - 1) / d;
  int n2 = (c + b - 1) / b;
  
  if (n2 <= n1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

signed main(){
    int t = 1; //cin >> t;
    while(t--){
        int n; cin >> n;
        vector<pair<int,int>> p;
        for(int i = 0; i < n; i++)
        {
            int x,y ; cin  >>x >> y;
            p.push_back({x,y});
        }
        int ans = 0;
        for(int i = 0; i <= n-3; i++)
        {
            if(p[i].first == p[i].second and p[i+1].first == p[i+1].second and p[i+2].second == p[i+2].first)
            {
                cout << "Yes";
                return 0;
            }
        }
        cout << "No";
    }    
}

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

int main(){

    int n,m,t;
    cin>> n >> m >> t;
    
    vector<bool> a(t,true);
    rep(i,n){
        int te;
        cin >> te;
        a[te]=false;
        for(int j=te+1;j<te+m&&j<t;j++){
            a[j]=false;
        }
        for(int j=te-1;j>=te-m&&j>=0;j--){
            a[j]=false;
        }
    }
    int ans=0;
    rep(i,t){
        if(a[i])ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"

void solve() {
  int n; cin >> n;
  int bill = 1000;
  if(n % bill == 0){
    cout << 0 << endl;
  }else{
    cout << bill - (n % bill) << endl;
  }
}
int main(){
// #ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
// #endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3580
#import re
import sys
input = sys.stdin.readline
#import heapq
#import bisect
#from collections import deque
#import math

def main():
    n = input()
    for c in n:
        if c == "7": 
            print("Yes")
            break
    else:
        print("No")

if __name__ == '__main__':
    main()


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

int main(){
	string S, T;
	cin >> S >> T;
	for (int i = 0; i < S.size(); ++i){
		if(S[i] != T[i]){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

ll group(ll a){
    switch (a){
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            return 0;
        case 4:
        case 6:
        case 9:
        case 11:
            return 1;
        case 2:
            return 2;
    }
}

int main() {
    ll x, y;
    cin >> x >> y;
    if (group(x) == group(y)){
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
import sys

N=int(input())

D,X=list(map(int,input().split()))

A=[]
for i in range(N):
	A.append(int(input()))

ans=X

for i in range(N):
	j=0
	while(True):
		if(j*A[i]+1>D):
			break
		ans+=1
		j+=1

print(ans)

Measured memory_bytes: 3064
#include <cstdio>

int main(int argc, char const *argv[]) {
  long long N, A, B;
  scanf("%lld%lld%lld", &N, &A, &B);

  if (N == 1) {
    if (A == B) {
      printf("1\n");
    } else {
      printf("0\n");
    }
  } else if (A > B) {
    printf("0\n");
  } else {
    long long max = A + B + (N - 2) * B;
    long long min = A + B + (N - 2) * A;
    printf("%lld\n", max - min + 1);
  }
  return 0;
}


Measured memory_bytes: 128
#define M 100
char m[M][M],s[M][M][M],r[M],*z;
cmp(char *p,char *q){
  int r=0;
  for(;*p=='0';p++);
  for(;*q=='0';q++);
  if(r=strlen(p)-strlen(q))return r;
  return strcmp(p,q);
}
main(w,h,i,j,k,l){
	for(;scanf("%d%d",&w,&h),w;puts(z)){
		memset(m,0xff,sizeof(m));
		memset(s,0,sizeof(s));
		memset(r,0,sizeof(r));
		for(j=1;j<=h;j++)scanf("%s",m[j]+1);
		for(i=1;i<=w;i++)
			for(j=1;j<=h;j++){
				if(!isdigit(m[j][i]))continue;
				if(cmp(s[j][i-1],s[j-1][i])>0)strcpy(s[j][i],s[j][i-1]),s[j][i][strlen(s[j][i])]=m[j][i];
				else strcpy(s[j][i],s[j-1][i]),s[j][i][strlen(s[j][i])]=m[j][i];
				if(cmp(s[j][i],r)>0)strcpy(r,s[j][i]);
			}
		for(z=r;*z=='0';z++);
	}
return 0;}

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

typedef long long LL ; 

using namespace std ;

int a[200010] ; 

int main() { 
	int n ; 
	scanf("%d", &n) ; 
	for (int i = 1; i <= n; i ++) scanf("%d", &a[i]), a[i] -= i ; 
	sort(a + 1, a + n + 1)  ;
	int mid = (n + 1) / 2 ;
	LL ans = 0 ; 
	for (int i = 1; i <= n; i ++) ans += abs(a[i] - a[mid]) ; 
	cout << ans << endl ; 
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
	int to;
	ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}

int main() {
	COME_LET_THE_GAMES_BEGIN();
	cpp m = 1;
	cpp N, a[3000];
	cin >> N;
	rep(i, N) {
		cin >> a[i];
		m *= a[i];
	}
	m--;
	cpp ans = 0;
	rep(i, N) {
		ans += m % a[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

int change_to_i(string s){
    stringstream ss; int k;
    ss << s; ss >> k;
    return k;
}
string change_to_s(int k){
    stringstream ss; string s;
    ss << k; ss >> s;
    return s;
}

signed main(){
    int q;
    cin >> q;
    rep(x, 0, q){
        string s;
        cin >> s;
        for(int ans = 0;; ans++){
            if(s.size() == 1){
                cout << ans << endl;
                break;
            }
            if(ans > 1000000){
                cout << -1 << endl;
                break;
            }
            string t1, t2;
            int MAX = 0, n1, n2;
            rep(i, 1, s.size()){
                t1 = s.substr(0, i);
                t2 = s.substr(i, s.size() - i);
                n1 = change_to_i(t1);
                n2 = change_to_i(t2);
                int tmp = n1*n2;
                //cout << t1 << ' ' << t2 << endl;
                //cout << n1 << ' ' << n2 << ' ' << tmp << endl;
                MAX = max(MAX, tmp);
            }
            s = change_to_s(MAX);
            //cout << ' ' << MAX << ' ' << s << endl;
        }
    }
}

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

void min_self(ll& a, ll b) {
    a = min(a, b);
}

const ll INF = 1e18L + 5;

int main() {
    int n, W;
    scanf("%d%d", &n, &W);
    vector<int> weight(n), value(n);
    for(int i = 0; i < n; ++i) {
        scanf("%d%d", &weight[i], &value[i]);
    }
    int sum_value = 0;
    for(int x : value) {
        sum_value += x;
    }
    vector<ll> dp(sum_value + 1, INF); // 0 ... W
    dp[0] = 0;
    // dp[i] - the minimum total weight of items with total value exactly i
    for(int item = 0; item < n; ++item) {
        for(int value_already = sum_value - value[item]; value_already >= 0; --value_already) {
            //~ for(int weight_already = 0; weight_already <= W - weight; ++weight_already) {
            min_self(dp[value_already+value[item]], dp[value_already] + weight[item]);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= sum_value; ++i) {
        if(dp[i] <= W) {
            answer = max(answer, (ll) i);
        }
        //~ min_self(answer, dp[i]);
    }
    printf("%lld\n", answer);
}

Measured memory_bytes: 3972
// AOJ 2044: Lying about Your Age
// 2017.11.04 bal4u@uu

#include <stdio.h>
#include <string.h>
#define TM 0
#if TM
#include <time.h>
#endif

#define INF 11001001
int tbl[201][17];
char buf[20], *bp;

int getint()
{
	int n = 0;
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	return n;
}

int cmp(int *a, int *b) { return *b - *a; }

int main()
{
	int a, b, c, i, j, t, ans;

#if TM
	clock_t start, end;
	start = clock();
#endif
	for (j = 1; j <= 200; j++) for (i = 2; i <= 16; i++) {
		t = j, a = 0;
		while (t) {
			b = t % i;
			if (b > 9) { a = INF; break; }
			buf[a++] = b;
			t /= i;
		}
		if (a < INF) {
			b = 0; while (--a >= 0) b = 10*b + buf[a];
		} else b = a;
		tbl[j][i] = b;
	}

	while (scanf("%d%d%d", &a, &b, &c) && a >= 0) {
		ans = INF;
		for (i = 2; i <= 16; i++) if (tbl[a][i] == b) ans = b;
		for (j = a+1; j <= c; j++) {
			for (t = INF, i = 2; i <= 16; i++) if (ans <= tbl[j][i]) {
				if (tbl[j][i] < t) t = tbl[j][i];
			}
			ans = t;
		}
		if (ans == INF) puts("-1");
		else printf("%d\n", ans);
	}
#if TM
	end = clock();
	printf("time %lf\n", (double)(end-start)/CLOCKS_PER_SEC);
#endif
	return 0;
}

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

int main()
{
    int s;
    cin >> s;
    int c = 0;
    int a = s;
    int l[1000001] = {};
    l[a]++;
    while (1)
    {
        if (a % 2 == 0)
            a /= 2;
        else
            a = 3 * a + 1;
        c++;
        l[a]++;
        if (l[a] == 2)
            break;
    }
    cout << c + 1;
    return 0;
}

Measured memory_bytes: 4096
#define _USE_MATH_DEFINES
//#include <bits/stdc++.h>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <complex>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

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


void solve(long long X, long long N, std::vector<long long> p){
	set<long long> s;
	REP(i,N) s.insert(p[i]);
	for(long long i=0;i<101LL;i++){
		if(s.find(X-i)==s.end()){
			cout<<X-i<<endl;
			return;
		}
		if(s.find(X+i)==s.end()){
			cout<<X+i<<endl;
			return;
		}
	}
}

int main(){
  long long X;
  scanf("%lld",&X);
  long long N;
  scanf("%lld",&N);
  std::vector<long long> p(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&p[i]);
  }
  solve(X, N, std::move(p));
  return 0;
}


Measured memory_bytes: 3692
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;
using System.Numerics;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long Gcd(long x,long y)
        {
            if (x < y) Gcd(y, x);
            while (y > 0)
            {
                var z = x;
                x = y;
                y = z % y;
            }
            return x;
        }

        public static long Lcm(long x,long y)
        {
            return x * y / Lcm(x, y);
        }


        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = Read();
            var a = new long[n+1] ;

            for (int i = 1; i*i <=n; i++)
            {
                for (int j = i; j*j <=n ; j++)
                {
                    for (int k = j;k*k <=n; k++)
                    {
                        var m = i * i + j * j + k * k + i * j + j * k + k * i;
                        if (m <= n)
                        {
                            if (i == j && j == k)
                                a[m] += 1;
                            else if (i != j && j != k && i != k)
                                a[m] += 6;
                            else
                                a[m] += 3;
                        }
                    }
                }
            }
            for (int i = 1; i <=n; i++)
            {
                WriteLine(a[i]);
            }
             



            Console.Out.Flush();
        }
    }
}



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

using namespace std;


int main(void){

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


    return 0;
}


Measured memory_bytes: 764
# -*- coding: utf-8 -*-
# template: v1.3.1

import io
import sys
import math

### DEBUG ###
_DEB = 0  # 1:ON / 0:OFF

_INPUT = """\
200000
"""+("R"*200000)
_EXPECTED = """\
2

"""
if _DEB:
    sys.stdin = io.StringIO(_INPUT)
    print("!! Debug Mode !!")

def logd(str):
    if _DEB: print(f"[deb] {str}")


### INPUT ####
n = int(input())
c = input()
c=c.replace("R","0")
c=c.replace("W","1")
c=[int(x) for x in c]

### Solve ####
def solve():
    # Process
    ans=0
    id1=0
    for i in reversed(range(n)):
        if id1 > i:
            break
        id0=-1
        if c[i] == 0:
            id0=i
            not_found=True
            for j in range(id1,id0):
                if c[j]==1:
                    id1=j
                    c[i]=1
                    c[j]=0
                    ans+=1
                    not_found=False
                    break
            if not_found:
                break
                
            if[i]==0:
                c[i]=1
                ans+=1
        

    # OUPUT
    ans = str(ans)
    print(ans)
    return ans

### MAIN ###
if __name__ == "__main__":
    ans = solve()

    # Checker
    if _DEB:
        if _EXPECTED.strip() == ans.strip(): print("\n!! Success !!")
        else: print(f"\n!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

Measured memory_bytes: 11328
import java.util.ArrayList;
import java.util.Scanner;

import static java.lang.Math.min;

/**
 * Created by shoya on 2017/04/13.
 */
public class Main {
    public static void main(String... args){
        Scanner sc = new Scanner(System.in);
        int V = sc.nextInt();
        int E = sc.nextInt();
        FordFulkersonClass ff = new FordFulkersonClass(V, E);

        for (int i = 0; i < E; i++){
            int s = sc.nextInt();
            int d = sc.nextInt();
            int c = sc.nextInt();
            ff.addEdge(s, d, c);
        }

        System.out.println(ff.fordFulkerson(0, V - 1));
        return;
    }


    public static class FordFulkersonClass {
        private class edge {
            int to; int cap; int rev;
            edge(int t, int c, int r){
                to = t; cap = c; rev = r;
            }
        }

        private int V, E;
        private boolean[] used;
        private ArrayList<ArrayList<edge>> edgeOfNodes;

        FordFulkersonClass(int v, int e){
            V = v; E = e;
            edgeOfNodes = new ArrayList<ArrayList<edge>>();
            for (int i = 0; i < V; i++)
                edgeOfNodes.add(new ArrayList<edge>());
        }

        public void addEdge(int from, int to, int cap){
            edgeOfNodes.get(from)
                    .add(new edge(to, cap, edgeOfNodes.get(to).size()));
            edgeOfNodes.get(to)
                    .add(new edge(from, 0, edgeOfNodes.get(from).size() - 1));
        }

        private int dfs(int source, int dest, int flow){
            //System.out.printf("%d %d %d\n", source, dest, flow);
            if (source == dest)
                return flow;
            used[source] = true;
            for (edge e : edgeOfNodes.get(source)){
                if (!used[e.to] && e.cap > 0){
                    int d = dfs(e.to, dest, min(flow, e.cap));
                    if (d > 0){
                        e.cap -= d;
                        edgeOfNodes.get(e.to).get(e.rev).cap += d;
                        return d;
                    }
                }
            }
            return 0;
        }

        public int fordFulkerson(int source, int dest){
            final int INF = 1 << 30;
            int flow = 0;
            while (true){
                used = new boolean[V];
                int f = dfs(source, dest, INF);
                if (f == 0)
                    break;
                flow += f;
            }
            return flow;
        }

    }

}

Measured memory_bytes: 53232
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<cmath>
#include<stack>
#include<algorithm>
#define rg register
#define ll long long
#define LDB long double
#define ull unsigned long long
#define view(i,x) for(rg int i=hd[x];i!=-1;i=e[i].nt)
#define go(i,x,a) for(rg int i=a;i<x;i++)
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
using namespace std;

ll a,b,c;

inline int rd(){
	int ret=0,af=1; char gc=getchar();
	while(gc < '0' || gc > '9'){ if(gc=='-') af=-af; gc=getchar(); }
	while(gc >= '0' && gc <= '9') ret=ret*10+gc-'0',gc=getchar();
	return ret*af;
}

int main(){
	a=rd(); b=rd(); c=rd();
	if(a%2 == 0 || b%2 == 0 || c%2 == 0) puts("0");
	else printf("%lld",min(b*c,min(a*b,a*c)));
	return 0;
}//Faze


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

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

int main(){
    int n,x;
    cin >> n >> x;
    int mi=10000,sum=0;
    for(int i=0;i<n;i++){
        int m;
        cin >> m;
        sum+=m;
        mi=min(mi,m);
    }
    cout << n+(x-sum)/mi << endl;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <math.h>
int main(void){
  int n,a,b;
  scanf("%d %d %d",&n,&a,&b);
  int i,sum=0,j,tmp;
  for(i=1;i<=n;i++){
    tmp=0;j=i;
    while(j!=0){
      tmp+=j%10;
      j/=10;
    }
    if(tmp>=a&&tmp<=b) sum+=i;
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
bool ispal(string a)
{
    long long int n=a.length();
    if(n==1)
        return true;
    else{
    int i=0,j;
    j=n-1;
    while(1)
    {
        if(a[i]!=a[j])
        {
            cout<<i<<" "<<j;
           return false;
        }
        i++,j--;
        if(i==j)
         {
        //     cout<<i<<" ";
             break;
        }
    }
    return true;
}}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
string a,b;
cin>>a>>b;
int mx=0;
for(int i=0;i<a.length()-b.length()+1;i++)
{
  //  cout<<i<<"-->";
    int k=b.length();
 string tm=a.substr(i,i+k);
 //if(tm.length()==k)
 {
    int c=0;
//cout<<tm<<endl;
 for(int j=0;j<b.length();j++)
 {
     if(tm[j]==b[j])
     {
         c++;
     }
 }
 mx=max(mx,c);
 }
}
cout<<b.length()-mx;
}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b)
{
	int res = 1;

	while (b)
	{
		if (b & 1) res = (res * a);

		a = (a * a); 
		b >>= 1;
	}
	return res;
}

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

#define N 200010
#define MOD 1000000007

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);

	int n, m;
	cin >> n >> m;

	int di[n + 1] = {}, s, c;
	for (int i = 0; i < m; ++i)
	{	
		cin >> s >> c;

		if (s == 1 && c == 0 && n != 1)
		{
			cout << -1;
			return 0;
		}

		if (di[s] == 0 || di[s] == c)
			di[s] = c;
		else
		{
			cout << -1;
			return 0;
		}
	}	
		
	if (di[1] == 0 && n != 1)
		di[1] = 1;
	for (int i = 1; i <= n; ++i)
		cout << di[i];

	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = []
B = []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
count = 0
for i in range(n - 1, -1, -1):
    count += (-(A[i] + count)) % B[i]
print(count)

Measured memory_bytes: 16896
import java.util.Scanner;
class Main{
     public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	String W;
    	String T;
    	String change_W = "";
    	String change_T = "" ;
    	String end = "END_OF_TEXT";
    	int count = 0;
    	
    	W = scan.nextLine();
    	change_W = W.toLowerCase();
    	
    	for(;;){
        	T = scan.nextLine();
    		if(T.equals(end)) break;  		
    		change_T = T.toLowerCase();
    		String sepa[] = change_T.split(" ");
    		
    		for(int i = 0; i < sepa.length; i++){
    			if(change_W.equals(sepa[i])){
    				count++;
    			}
    		}
    		
    	}
    	
    	 System.out.println(count);
     }
}

Measured memory_bytes: 26092
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	foreach (line; stdin.byLine) {
		auto w = line.chomp.to!int;
		int[] res;
		foreach (i; 0..10) {
			if (w & 2 ^^ i) res ~= 2 ^^ i; 
		}
		res.map!(to!string).join(" ").writeln;
	}
}

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

#define rep(i, k, n) for(int i = (k); i < (n); i++)
#define irep(i, k, n) for(int i = (k); i > (n); i--)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

int main(void){
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> a(n, 0);
  rep(i, 0, q){
    int ai;
    cin >> ai;
    a[--ai]++;
  }
  rep(i, 0, n){
    if(k-q+a[i] > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  REP(i, N) cin >> h[i];
  vector<int> dp(N);
  dp[0] = 0;
  FOR(i, 1, N) {
    int tmp = 1e9;
    FOR(k, 1, K + 1) {
      if(i - k < 0) { break; }
      tmp = min(tmp, dp[i - k] + abs(h[i] - h[i - k]));
    }
    dp[i] = tmp;
  }
  cout << dp[N - 1] << endl;
  return 0;
}

Measured memory_bytes: 1024
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N = getN()
query = [getNM() for i in range(N - 1)]
C = getList()
C.sort()
ans1 = sum(C) - max(C)

dist = [[] for i in range(N)]
for i in range(N - 1):
    a, b = query[i]
    dist[a - 1].append(b - 1)
    dist[b - 1].append(a - 1)

sta = 0

for i in range(N):
    if len(dist[i]) == 1:
        sta = i
        break

point = [-1] * N

def dfs(now):
    u = C.pop()
    point[now] = u
    for i in dist[now]:
        if point[i] >= 0:
            continue
        dfs(i)

dfs(sta)

print(ans1)
print(*point)

Measured memory_bytes: 22604
z[2002],*a=z,*b=z+999,m,i,j,t,u;main(n){for(;m=scanf("%d",&n)-++n;printf("%d\n",m))for(i=n;i--;j=a,a=b,b=j)for(j=n;j--;t>m?m=t:0)t=b[j]=n+~i&&getchar()>45?1+fmin(u=a[j],t<u?t:u):0;}

Measured memory_bytes: 0
#include<stdio.h>

int main(){
  int A[251];
  int H,i,j,x;
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i!=1){
      x=i/2;
      printf("parent key = %d, ",A[x]);
	}
    if(i*2<=H){
      
      printf("left key = %d, ",A[i*2]);

    }
    if(i*2+1<=H){
      printf("right key = %d, ",A[i*2+1]);
    }
    printf("\n");
  }


  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = int(1e5 + 5);

int main() {
    int w, h, a[MAX_N], b[MAX_N], asum = 0, bsum = 0;
    bool ok = true;
    cin >> w >> h;
    for(int i=0;i<w;i++){
        cin >> a[i];
        asum += a[i];
    }
    for(int i=0;i<h;i++){
        cin >> b[i];
        bsum += b[i];
    }
    ok &= asum == bsum;
    if(ok){
        for(int i=0;i<w;i++){
            sort(b,b+h);
            reverse(b,b+h);
            for(int j=0;j<a[i];j++){
                if(b[j]>0){
                    b[j]--;
                }
                else{
                    ok = false;
                    break;
                }
            }
            if(!ok) break;
        }
    }
    cout << (ok?1:0) << endl;
    return 0;
}


Measured memory_bytes: 3156
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    cout << 10 - x / 200 << endl;

    return 0;
}

Measured memory_bytes: 3632
""" AtCoder """

N, M = map(int, input().split())
X = list(map(int, input().split()))

X.sort()

Y = []
ans = 0

for i in range(M-1):
    Y.append(X[i+1] - X[i])

Y.sort()

for i in range(M - N):
    ans += Y[i]

print(ans)


Measured memory_bytes: 13968
#include <stdio.h>

int main(void) {
	long A, B;
	int K, s;
	scanf("%ld%ld%d", &A, &B, &K);
	if(B-A+1<2*K)
	{for(s=A;s<=B;s++)
	printf("%d \n", s);
	}
	else
	{
	for(s =A;s<A+K&&s<=B;s++)
	{printf("%d \n",s);}
	for(s=B-K+1;s<=B;s++)
	{printf("%d \n",s);}
	}
	return 0;
}


Measured memory_bytes: 256
import Foundation

func readInt() -> [Int] {
    return readLine()!.componentsSeparatedByString(" ").map { Int($0)! }
}

func main() {
    let line = readInt()
    let N = line[0]
    let K = line[1]
    let H = readLine()!.componentsSeparatedByString(" ").map { Int64($0)! }

    var dp = (1...N).map {_ in Int64.max }
    dp[0] = 0

    for i in 0..<N {
        for j in 1...K {
            if i + j >= N {
                continue
            }
            dp[i+j] = min(dp[i+j], dp[i]+abs(H[i+j] - H[i]))
        }
    }
    print(dp[N-1])
}

main()

Measured memory_bytes: 7524
#include <cstdio>

int main() {
	char S[99];
	scanf("%s",S);
	if(S[0]=='Y'&&S[1]=='A'&&S[2]=='K'&&S[3]=='I') {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}


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

using namespace std;

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

 	int n,a,b;
 	int rank = 1;
 	int cnt = 0;
 	string s;

 	cin >> n >> a >> b;
    cin >> s;

    for(int i=0;i<n;i++)
    {
    	if(s[i]=='a')
    	{
    		if(cnt < a + b)
    		{
    			cout << "Yes" << '\n';
    			cnt++;
    		}
    		else
    		{
    			cout << "No" << '\n';
     		}
    	}
    	else if(s[i]=='b')
    	{
    		if(cnt < a + b && rank<=b)
    		{
    			cout << "Yes" << '\n';
    			cnt++;
    			rank++;
    		}
    		else
    		{
    			cout << "No" << '\n';
    		}
    	}
    	else
    	{
    		cout << "No" << '\n';
    	}
    }
    return 0;
}

Measured memory_bytes: 848
N,K = map(int,input().split())

sunuke = []
list_sunuke=[]
for i in range(K):
    d = int(input())
    
    sunuke.append(input().split())

for i in sunuke:
    for j in i:
        list_sunuke.append(j)

set_sunuke = set(list_sunuke)
print(N-len(set_sunuke))

Measured memory_bytes: 9348
#include "bits/stdc++.h" // 1
using namespace std; // 2
#define INF 0x3f3f3f3f    //3
#undef INF // 4
long long A, B, C, X, Y; // 5
long long solve(){   //6
    return -1;} // 7
long long a, b, c, x, y; // 1
void solve2(){ // 2
    long long num=0;    //3
    long min_ = std::min(x, y); // 4
    c = min(2 * c, a + b); // 5
    } //6
int main() { // 7
    cin>>a>>b>>C>>X>>y; // 1
    #define INF 1000000007 // 2
    long long sum=0LL;    //3
    A = a; B = b; c = C; x = X; Y = y; // 4
    long ans = min({A * X + B * Y, max(X, Y) * 2 * C, min(X, Y) * 2 * C + abs(X - Y) * (X > Y ? A : B)}); // 5
    long long q = solve();solve2();   //6 
    #undef INF   // 7
    cout<<ans*q*solve(); // 1
    cout << endl; // 2
    int dx[8]={0,0,-1,1,1,1,-1,-1};    //3
    return 0;}
    


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

struct edge{int to,cost;};
	
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	string s;
	cin >> s;

	int num=0;
	for(int i=1;i<s.size();i++){
		if(s[i-1]!=s[i]) num++;
	}
	cout << num << "\n";
	
	return 0;
}

Measured memory_bytes: 512
import sys
h,w = map(int,input().split())
S = [list(input()) for i in range(h)]
ans = 0

dy_dx = [[1,0],[0,1],[-1,0],[0,-1]]

for i in range(h):
    for j in range(w):
        visit = [[0 for i in range(w)] for i in range(h)]
        pos = []
        if S[i][j] == '.':
            visit[i][j] = 1
            pos.append([i, j])
            while len(pos) > 0:
                now = pos.pop(0)
                for k in range(4):
                    y = now[0]+dy_dx[k][0]
                    x = now[1]+dy_dx[k][1]
                    if 0 <= y < h and 0 <= x < w:
                        if S[y][x] != '#' and visit[y][x] == 0:
                            visit[y][x] = visit[now[0]][now[1]] + 1
                            pos.append([y, x])
        for p in range(h):
            for q in range(w):
                ans = max(ans, visit[p][q])
                
print(ans - 1)

Measured memory_bytes: 3188
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

struct Point {
  int y, x;
  Point() = default;
  Point(int y, int x): y(y), x(x) { }
};

struct Search {
  int dist, y, x;
  Search() = default;
  Search(int d, int y, int x): dist(d), y(y), x(x) { }
};

int main() {
  while (true) {
    int t, n;
    cin >> t >> n;
    if (t + n == 0) {
      break;
    }
    vector<Point> object;
    vector<Point> checked;

    for (int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      object.push_back(Point(y, x));
    }
    int sx, sy;
    cin >> sx >> sy;
    int ans = 0;

    queue<Search> que;
    que.push(Search(0, sy, sx));
    while (!que.empty()) {
      Search s = que.front(); que.pop();
      bool isOK = true;
      for (auto e : object) {
        if (s.y == e.y && s.x == e.x) {
          isOK = false;
        }
      }
      for (auto e : checked) {
        if (s.y == e.y && s.x == e.x) {
          isOK = false;
        }
      }
      if (s.dist > t) {
        continue;
      }
      if (!isOK) {
        continue;
      }

      ans++;
      
      checked.push_back(Point(s.y, s.x));

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

      for (int i = 0; i < 6; i++) {
        int y = s.y + dy[i];
        int x = s.x + dx[i];
        que.push(Search(s.dist + 1, y, x));
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3108
#include <iostream>
using namespace std;
#define ll long long

int main () {
  ll n;
  cin >> n;
  ll h[n + 1];
  for (ll i = 1; i <= n; i++) cin >> h[i];
  ll dp[n + 1];
  for (ll i = 1; i <= n; i++) dp[i] = -1;
  dp[1] = 0;
  dp[2] = abs(h[2] - h[1]);
  for (ll i = 3; i <= n; i++) {
    dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
    ll sub = dp[i - 2] + abs(h[i] - h[i - 2]);
    if (sub < dp[i]) dp[i] = sub;
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 1792
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let s: i64 = a.iter().sum();
    let mn = a
        .iter()
        .enumerate()
        .map(|(i, a)| ((a * n as i64 - s).abs(), i))
        .min()
        .unwrap()
        .1;

    println!("{}", mn);
}


Measured memory_bytes: 2156
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    vector<vector<int>> a(3,vector<int>(3,0)),c(3,vector<int>(3,0));
    rep(i,3)rep(j,3) cin>>a[i][j];
    int n; cin>>n;
    rep(i,n){
        int b; cin>>b;
        rep(j,3)rep(k,3){
            if(a[j][k]==b) c[j][k]=1;
        }
    }
    rep(i,3){
        int cnt=0;
        rep(j,3) cnt+=c[i][j];
        if(cnt==3){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    rep(i,3){
        int cnt=0;
        rep(j,3) cnt+=c[j][i];
        if(cnt==3){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    int cnt=0;
    rep(i,3) cnt+=c[i][i];
    if(cnt==3){
        cout<<"Yes"<<endl;
        return 0;
    }
    cnt=0;
    rep(i,3) cnt+=c[i][2-i];
    if(cnt==3){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}


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

int main()
{
    int M;
    cin>>M;
    vector<int> d(M);
    vector<long long> c(M);
    for (int i=0; i<M; i++)
        cin>>d[i]>>c[i];

    long long ans = 0;
    vector<int> T;
    for (int i=0; i<M; i++)
    {
        int td = d[i];
        long long tc = c[i];
        while (tc>1)
        {
            if (tc%2!=0)
                T.push_back(td);
            td = td+td;
            tc /= 2;
            ans += tc;
            if (td>=10)
            {
                td = td%10+td/10;
                ans += tc;
            }
        }
        T.push_back(td);
    }

    int x = T[0];
    for (int i=1; i<(int)T.size(); i++)
    {
        x += T[i];
        ans++;
        if (x>=10)
        {
            x = x%10+x/10;
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 20968
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define N 500005
#define inf 666666666
int in[N],pos[N],p[N],ans[N],tot,n,k;
priority_queue <int> q;
int head[N],to[N<<1],nxt[N<<1],cnt;
void add(int u,int v)
{
	cnt++;
	to[cnt]=v;
	nxt[cnt]=head[u];
	head[u]=cnt;
}
#define ls id<<1
#define rs id<<1|1
int t[N<<2];
void change(int id,int l,int r,int p,int d)
{
	if(l==r) {
		t[id]=d;
		return;
	}
	int mid=(l+r)>>1;
	if(p<=mid) change(ls,l,mid,p,d);
	else change(rs,mid+1,r,p,d);
	t[id]=min(t[ls],t[rs]);
}
int query(int id,int L,int R,int l,int r)
{
	if(t[id]>=N) return inf;
	if(l==L&&r==R) return t[id];
	int Mid=(L+R)>>1;
	if(r<=Mid) return query(ls,L,Mid,l,r);
	else if(l>Mid) return query(rs,Mid+1,R,l,r);
	else return min(query(ls,L,Mid,l,Mid),query(rs,Mid+1,R,Mid+1,r));
}
int main()
{
	int tmp;
	scanf("%d%d",&n,&k);
	rep(i,1,n) 
		scanf("%d",&tmp),p[tmp]=i;
	memset(t,0x3f,sizeof(t));
	dep(i,n,1) {
		int pos=query(1,1,n,p[i],min(n,p[i]+k-1));
		if(pos!=inf) {
			add(p[i],p[pos]);
			in[p[pos]]++;
		}
		pos=query(1,1,n,max(1,p[i]-k+1),p[i]);
		if(pos!=inf) {
			add(p[i],p[pos]);
			in[p[pos]]++;
		}
		change(1,1,n,p[i],i);
	}
	rep(i,1,n) if(!in[i]) q.push(-i);
	while(!q.empty()) {
		int now=-q.top();
		ans[now]=++tot;
		q.pop();
		for(int i=head[now]; i; i=nxt[i]) {
			int v=to[i];
			--in[v];
			if(!in[v]) q.push(-v);
		}
	}
	rep(i,1,n) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 29684
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		int i = 0;
		int Alice = 0;
		int Bob = 0;
		for(i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		Arrays.sort(a);
		for(i = 1; i <= n; i++) {
			if(i % 2 == 1) {
				Alice = Alice + a[n - i];
			} else {
				Bob = Bob + a[n - i];
			}
		}
		System.out.println(Alice - Bob);
	}
}

Measured memory_bytes: 21844
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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




// ***************************************


int main(){

    int N;
    cin >> N;
    vector<int> vec(N+1, 0);

    int tmp;
    REP(i, N - 1){
        cin >> tmp;
        vec[tmp]++;
    }

    REP(i, N){
        cout << vec[i+1] << endl;
    }

    return 0;
}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define fo(i,a) for(i = 0;i < a;i++)
using namespace std;
int main(void)
{
	int n=0,p,m,c;
	
	cin >> p >> m >> c ;
	n += p + m + c ;
	cout << n << endl ;
	
	return 0 ;
}



Measured memory_bytes: 3104
import java.util.*;

class Main {
	public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
      		Set<Integer> set = new HashSet<Integer>();
      		for (int i = 0; i < 3; i++){
            	set.add(sc.nextInt());	 
            }
			if(set.size() == 2){
             	System.out.println("Yes"); 
            }else{
             	System.out.println("No"); 
            }
	}
}


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

int main() {
    string S;
    cin >> S;
    long int numberOfB = 0;
    long int answer = 0;
    for (int i = 0; i < S.length(); ++i) {
        if (S[i] == 'W') {
            answer += i;
            ++numberOfB;
        }
    }
    for (int i = 0; i < numberOfB; ++i) {
        answer -= i;
    }
    cout << answer << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5+5;
int n, m, k, a[N], b[N];
main() {
    cin >> n >> m >> k;
    for(int i=1; i<=n; i++) {
        int x; cin >> x;
        a[i] = a[i-1] + x;
    }
    for(int i=1; i<=m; i++) {
        int x; cin >> x;
        b[i] = b[i-1] + x;
    }
    int ans = 0;
    for(int i=0; i<=n && a[i]<=k; i++) {
        int r = k - a[i],
            c = upper_bound(b+1, b+m+1, r) - b - 1;
        ans = max(ans, i + c);
    }
    cout << ans;
    
} 

Measured memory_bytes: 6768
#! /usr/bin/python

import math

def main():

	turtle = Turtle(0, 0, 0, 1)
	while True:
		input = raw_input()
		if input == '0,0':
			break

		args = input.strip().split(',')
		dist = int(args[0])
		degree = int(args[1])

		rad = 2 * math.pi * degree / 360.0

		turtle.move(dist)
		turtle.rotate(rad)

	print("%d" % (turtle.x))
	print("%d" % (turtle.y))

class Turtle:

	def __init__(self, x, y, vx, vy):
		self.x  = x
		self.y  = y
		self.vx = vx
		self.vy = vy
		self.normalize_velocity()

	def move(self, dist):
		self.x += self.vx * dist
		self.y += self.vy * dist

	def normalize_velocity(self):
		vx = self.vx
		vy = self.vy
		v = math.sqrt(vx * vx + vy * vy)
		self.vx = vx / v
		self.vy = vy / v

	def rotate(self, theta):
		vx = self.vx
		vy = self.vy

		self.vx = vx * math.cos(theta) + vy * math.sin(theta)
		self.vy = -vx * math.sin(theta) + vy * math.cos(theta)


main()

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

int gcd(int m, int n)
{   
    if( n==0 ) return m;  
    return gcd(n, m%n);
}

int main()
{
    int a,b,k,GCD;
    scanf("%d %d %d", &a, &b, &k);
    GCD = gcd(a,b);
    for (int i = GCD; i >= 1; i--){
        if ( GCD%i == 0) {
            if ( k <= 1 ){
                cout << i << endl;
                return 0;
            } 
            k--;
        }
    }
    return 0;
}

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

typedef signed long long ll;

int H,N;
int a[10100],b[10100];
ll dp[20100];

void solve(){
	int i,j,k,l,r,x,y;
	cin>>H>>N;
	
	for(i=0;i<20001;i++)
		dp[i]=1LL<<60;
		
	dp[0]=0;
	
	for(i=0;i<N;i++)
	{
		cin>>x>>y;
		for(j=0;j<H;j++)
			dp[j+x]=min(dp[j+x],dp[j]+y);
	}
	
	ll mi=1LL<<60;
	
	for(i=H;i<=20000;i++)
		mi=min(mi,dp[i]);
		
	cout<<mi<<endl;
}

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

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

int main(void) {

  long x,k,d,ans;
  scanf("%ld %ld %ld", &x, &k, &d);
  long dis = labs(x);
  long a = dis/d;
  if (k <= a) {
    ans = dis-k*d;
    printf("%ld\n", ans);
  } else {
    ans = dis-a*d;
    k -= a;
    if (k%2 == 1) {
      ans = d-ans;
    }
    printf("%ld\n", ans);
  }

  return 0;
}

Measured memory_bytes: 1736