akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int factorial(int k) {
  int sum = 1;
  for (int i = 1; i <= k; ++i) {
    sum *= i;
  }
  return sum;
}
int main() {
  int n, m[10][10] = { };
  long long sum = 0;
  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    if (i % 10) {
      m[(int) (i / pow(10, (int) log10(i)))][i % 10]++;
    }
  }
  for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      if (m[i][j] > 0 && m[j][i] > 0) {
        sum += m[i][j] * m[j][i];
      }
    }
  }
  cout << sum;
  return 0;
}

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

using namespace std;

int n, ind[30] = {0}, x, mn[30] = {0};

int main(){
	string s, out;
	
	
	cin>>n;
	
	cin>>s;
	for(int j=0; j<s.length(); j++){
		x = s[j] - 'a';
		ind[x]++;
		mn[x] = ind[x];
	}
	
	for(int i=1; i<n; i++){
		cin>>s;
		memset(ind, 0, sizeof(ind));

		for(int j=0; j<s.length(); j++){
			x = s[j] - 'a';
			ind[x]++;
		}
		
		for(int j=0; j<27; j++){
			if(mn[j]>ind[j]) mn[j] = ind[j];
		}
	}
	
	for(int i=0; i<27; i++){
		for(int j=0; j<mn[i]; j++){
			out = 'a' +i;
			cout<<out;
		}
	}
		
	
	
		
		
	return 0;
}

Measured memory_bytes: 384
import sys
input=sys.stdin.readline

n,a,b=map(int,input().split())
x=a-b
h=[int(input()) for _ in range(n)]
ok=10**9+1
ng=0
while ok-ng>1:
    m=(ok+ng)//2
    k=0
    for i in range(n):
        k+=(max(0,h[i]-m*b)+x-1)//x
    if k<=m:
        ok=m
    else:
        ng=m
print(ok)


Measured memory_bytes: 44380
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		s = s.replaceAll("0", "");
		System.out.println(s.length());

	}

}

Measured memory_bytes: 21588
type UF
	n::Int
	pr::Array{Int}
	sz::Array{Int}
	UF(n)=new(n,1:n,ones(Int,n))
end
find(uf::UF,a::Int)=uf.pr[a]==a ? a : uf.pr[a]=find(uf,uf.pr[a])
same(uf::UF,a::Int,b::Int)=find(uf,a)==find(uf,b)
function unite(uf::UF,a::Int,b::Int)
	a=find(uf,a)
	b=find(uf,b)
	if a==b
		false
	else
		if uf.sz[a]<uf.sz[b]
			uf.pr[a]=b
			uf.sz[b]+=uf.sz[a]
		else
			uf.pr[b]=a
			uf.sz[a]+=uf.sz[b]
		end
		true
	end
end
size(uf::UF,a::Int)=uf.sz[find(uf,a)]
function main()
	N,M=map(x->parse(Int,x),split(readline()))
	pr=-ones(Int,M)
	uf=UF(N)
	for i=1:N
		L=map(x->parse(Int,x),split(readline()))
		shift!(L)
		for l=L
			if pr[l]<0
				pr[l]=i
			else
				unite(uf,pr[l],i)
			end
		end
	end
	for i=1:N
		if !same(uf,1,i)
			println("NO")
			exit()
		end
	end
	println("YES")
end
main()


Measured memory_bytes: 155108
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect
import heapq


MOD = 1000000007


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


def main():
    # N, K = get_inputs(int)
    # H = get_inputs(int)

    # if K >= N:
    #     print(0)
    # else:
    #     # K < N
    #     print(sum(sorted(H)[:N-K]))

    H = get_input(int)
    def f(h):
        if h == 1:
            return 1
        else:
            return 2 * f(h//2) + 1
    print(f(H))

if __name__ == '__main__':
    main()


Measured memory_bytes: 21052
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<limits.h>
#include<string>
#include<iomanip>
#include<numeric>
#include<queue>
using namespace std;

long long  mod = 1000000007;

long max(long x, long y) {
	return x > y ? x : y;
}

long min(long x, long y) {
	return x < y ? x : y;
}

long factorial(long n) {
	if (n == 1) {
		return 1;
	}
	else {
		return n * factorial(n - 1);
	}
}

long long  fel(long long  n,long long  f) {

		if (f == 1) {
			return n % mod;
		}
		else if (f % 2 == 0) {
			return (fel(n,f / 2) * fel(n,f / 2)) % mod;
		}
		else {
			return ((n  * fel(n,f / 2) %mod) * fel(n,f / 2))% mod;
		}
	

}


int main()
{
	int a, b, c, d;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;

	if (d == 1) {
		cout << 1;
	}
	else {
		cout << 0;
	}
 

}



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

const int N = 110;

char s[N];

int main(){
	int x;
	scanf("%d", &x);
	scanf("%s", s);
	int len = strlen(s), max = 0, now = 0;
	for (int i = 0; i < len; ++ i){
		if (s[i] == 'I'){
			++ now;
		}
		else{
			-- now;
		}
		max = std::max(max, now);
	}
	return printf("%d\n", max), 0;
}

Measured memory_bytes: 256
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    string s;
    cin >> n >> s;
    string s1="",s2="";
    rep(i,0,n/2){
        s1+=s[i];
    }
    rep(i,n/2,n){
        s2+=s[i];
    }
    if(s1==s2) cout << "Yes" ENDL;
    else cout << "No" ENDL;
    
    return 0;
}

Measured memory_bytes: 3592
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

A,B = LI()
print(A*B)

Measured memory_bytes: 27184
#include<bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include<string>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
int main(void){
  int N;
  cin >> N;
  int a[N+1];
  rep(i,N){
    cin >> a[i+1];
  }
  int tmp;
  int b[N+1];//入れ方
  rep(i,N){
    b[i+1]=0;
  }
  for(int i=N;i>=1;i--){
    if(i>N/2){//前半
      b[i]=a[i];
      //cout <<"b" << b[i] << " " << i << endl;
    }else if(i<=N/2){//後半
      tmp=0;
      for(int j=2;j*i<=N;j++){//倍数を全部見る
      //cout << b[i*j] << "ff" << endl;
        tmp+=b[i*j];
      }
      //cout << i << " " << tmp << endl;
      if(a[i]==tmp%2){
        b[i]=0;
      }else{
        b[i]=1;
      }
    }else{
      cout <<"ERROR";
    }
  }
  //cout << "dd";
  /*rep(i,N){
    cout << b[i+1]<<endl;
  }*/
  int sum=0;
  for(int i=0;i<N;i++){
    sum+=b[i+1];
    //cout << b[i+1] << endl;
  }
  //cout << "gg";
  cout << sum << endl;
  for(int i=0;i<N;i++){
    if(b[i+1]==1){
      cout << i+1  << " ";
    }
  }
	return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    double L;
    cin >> L;
    L /= 3.0;
    L = L * L * L;
    printf("%.8f\n", L);


    return 0;
}


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

int main(){
    int w, h, n;
    cin >> w >> h >> n;
    vector<int> x(n), y(n), a(n);
    for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> a[i];

    vector<vector<bool>> memo(h, vector<bool>(w, false));

    for(int i = 0; i < n; i++){
        if(a[i] == 1){
            for(int j = 0; j < h; j++){
                for(int k = 0; k < x[i]; k++){
                    memo[j][k] = true;
                }
            }
        }else if(a[i] == 2){
            for(int j = 0; j < h; j++){
                for(int k = x[i]; k < w; k++){
                    memo[j][k] = true;
                }
            }
        }else if(a[i] == 3){
            for(int j = 0; j < y[i]; j++){
                for(int k = 0; k < w; k++){
                    memo[j][k] = true;
                }
            }
        }else{
            for(int j = y[i]; j < h; j++){
                for(int k = 0; k < w; k++){
                    memo[j][k] = true;
                }
            }
        }
    }

    int ans = 0;
    for(int i = h-1; i >= 0; i--){
        for(int j = 0; j < w; j++){
            if(!memo[i][j]) ans++;
        }
    }

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

Measured memory_bytes: 3648
package main

import "fmt"

func main() {
	var a, b, c int
	ans := "No"
	fmt.Scanf("%d %d", &a, &b)
	for i := 0; i <= a; i++ {
		c = a - i
		if i*2+c*4 == b {
			ans = "Yes"
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1832
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int INF = 10e8;
const int maxN = 1010;
const int maxM = 100010;
const int N = 5000; 
const int MOD = 1000000007;


int n;

int sum(int x)
{
	int tmp = 0;
	while(x)
	{
		int y = x%10;
		tmp += y;
		x = x/10;
	}
	return tmp;
}

int main()
{
	scanf("%d",&n);
	int minv = INF;
	for(int i=1;i<=n/2;i++)
	{
		int j = n-i;
		int tsum = sum(i) + sum(j);
		if(tsum < minv)
			minv = tsum;
	}
	printf("%d\n",minv);
	return 0;
}  

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

    for (int i = 0; i < 3; i++) {
      data[i] = sc.nextInt();
    }

    int k = sc.nextInt();

    for (int i = 0; i < k; i++) {
      Arrays.sort(data);
      data[2] *= 2;
    }

    System.out.println(data[0]+data[1]+data[2]);
  }
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110

ll N;
ll part[MAX_N];

signed main()
{
    cin >> N;

    if( N % 2 == 0) {
        for(int i = 1; i <= N / 2; ++i) {
            int one = i;
            int two = N - (i - 1);
            part[one] = two;
            part[two] = one;
        }
    }
    else {
        part[N] = -1;
        for(int i = 1; i <= (N-1) / 2; ++i) {
            int one = i;
            int two = N - i;
            part[one] = two;
            part[two] = one;
        }
    }

    vector< pair<ll, ll> > ans;
    for(int i = 1; i <= N; ++i) {
        for(int j = 1; j <= N; ++j) {
            if(i == j) { continue; }
            if(part[i] == j) { continue; }
            ans.push_back({min(i, j), max(i, j)});
        }
    }
    SORT(ans);
    ans.erase(unique(ans.begin(), ans.end()), ans.end());

    printf("%zu\n", ans.size());
    for(auto& p : ans) {
        printf("%lld %lld\n", p.first, p.second);
    }


    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
const int ddy[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int ddx[] = {0, 1, 0, -1, 1, -1, -1, 1};
const int dddy[] = {1, 0, -1, 0, 1, 1, -1, -1, 2, 0, -2, 0};
const int dddx[] = {0, 1, 0, -1, 1, -1, -1, 1, 0, 2, 0, -2};
bool range_check(int y, int x)
{
    if(y < 0 || x < 0 || y >= 10 || x >= 10) return false;
    else return true;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, y, com;
    int table[10][10] = {};
    char bother;
    while(cin >> x >> bother >> y >> bother >> com)
    {
        table[y][x]++;
        if(com == 1)
        {
            for(int i = 0; i < 4; i++)
            {
                int ny = y + dy[i];
                int nx = x + dx[i];
                if(!range_check(ny, nx)) continue;
                table[ny][nx]++;
            }
        }
        if(com == 2)
        {
            for(int i = 0; i < 8; i++)
            {
                int ny = y + ddy[i];
                int nx = x + ddx[i];
                if(!range_check(ny, nx)) continue;
                table[ny][nx]++;
            }
        }
        if(com == 3)
        {
            for(int i = 0; i < 12; i++)
            {
                int ny = y + dddy[i];
                int nx = x + dddx[i];
                if(!range_check(ny, nx)) continue;
                table[ny][nx]++;
            }
        }
    }
    int cnt = 0, max_num = -INF;
    for(int i = 0; i < 10; i++)
    {
        for(int j = 0; j < 10; j++)
        {
            if(table[i][j] == 0) cnt++;
            max_num = max(table[i][j], max_num);
        }
    }
    cout << cnt << "\n" << max_num << endl;
    return 0;
}




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

const int MAX_N=100005;
int n, A[MAX_N], ans[MAX_N];
int main() {
    cin >> n;
    rep(i,n) cin >> A[i];

    ll s=0;
    rep(i,n-1) {
        if(i%2) s-=A[i];
        else s+=A[i];
    }
    ans[0]=(s+A[n-1])/2;
    ans[n-1]=A[n-1]-ans[0];
    rep(i,n-2) {
        ans[i+1]=A[i]-ans[i];
    }
    rep(i,n) printf("%d%c", 2*ans[i], (i==n-1?'\n':' '));
    return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>
int main()
{
    int a,b,c,n;
    scanf("%d%d%d",&a,&b,&c);
    if(a>=b){
        if(a>=c){n=b+c;}
        if(a<c){n=a+b;}}
    else {
        if(b>=c){n=a+c;}
    if(b<c){n=a+b;}}
    printf("%d",n);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int w;
int calc()
{
	int ret=1150;
	if(w<=10)return ret;
	ret+=min(10,w-10)*125;
	if(w<=20)return ret;
	ret+=min(10,w-20)*140;
	if(w<=30)return ret;
	ret+=(w-30)*160;
	return ret;
}
int main()
{
	while(scanf("%d",&w),w>=0)printf("%d\n",4280-calc());
	return 0;
}

Measured memory_bytes: 0
class Main {
    public static void main(String[] args) throws java.io.IOException {
        for(int a = 1;a<=9;a++){
        	for(int b = 1;b<=9;b++){
        		System.out.println(a + "x" + b  + "=" + a*b);
        	}
        }
	}
}

Measured memory_bytes: 15012
import java.io.*;

public class Main {
    public static void main(String[] args) {
        String S;

        try (InputScanner is = new InputScanner(System.in)) {
            S = is.next();
        }
        char[] arr = S.toCharArray();
        System.out.println((char) (arr[0] +1));

    }

    //-------------------------------------------------------------------
    public static class InputScanner implements Closeable {
        private final BufferedReader br;
        private String[] element;
        private int elementIndex;

        public InputScanner(InputStream is) {
            this.br = new BufferedReader(new InputStreamReader(is));
        }

        public String next() {
            return this.nextElement();
        }

        //next int
        public int ni() {
            return Integer.parseInt(this.nextElement());
        }

        //next long
        public long li() {
            return Long.parseLong(this.nextElement());
        }

        //next int array
        public int[] nia(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = this.ni();
            }
            return arr;
        }

        private void readLine() {
            try {
                this.element = this.br.readLine().split("\\s");
            } catch (IOException e) {
                e.printStackTrace();
            }
            this.elementIndex = 0;
        }

        private String nextElement() {
            if (!hasElement()) {
                this.readLine();
            }
            return this.element[this.elementIndex++];
        }

        private boolean hasElement() {
            return this.element != null && this.element.length > this.elementIndex;
        }

        @Override
        public void close() {
            if (this.br != null) {
                try {
                    this.br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
//-------------------------------------------------------------------
}


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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 60;

int a[3];

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	REP(i, 0, 3) scanf("%d", a + i);
	int tmp = __gcd(__gcd(a[0], a[1]), a[2]);
	a[0] /= tmp;
	a[1] /= tmp;
	a[2] /= tmp;
	int n = a[0] + a[1] + a[2];
	static char ans[maxn + 5];
	static int nxt[maxn + 5][3], pre[maxn + 5];
	memset(nxt, 0, sizeof nxt);
	pre[0] = 0;
	REP(i, 0, n)
	{
		static bool f[maxn + 5][maxn + 5][maxn + 5][maxn + 5];
		for (int j = 2; j >= 0; --j) if (a[j] > 0)
		{
			ans[i] = 'a' + j;
			--a[j];
			memset(f, 0, sizeof f);
			f[a[0]][a[1]][a[2]][0] = 1;
			for (int x = a[0]; x >= 0; --x) for (int y = a[1]; y >= 0; --y) for (int z = a[2]; z >= 0; --z)
				REP(l, 0, i + 1)
				{
					if (f[x][y][z][l])
					{
						REP(k, 0, 3)
						{
							int b[3] = {x, y, z};
							if (b[k])
							{
								--b[k];
								if (ans[l] <= 'a' + k)
								{
									int nxtl = (l + 1) % (i + 1);
									if (ans[l] != 'a' + k)
									{
										if (!i) nxtl = 0;
										else 
										{
											nxtl = nxt[pre[l]][k];
										}
									}
									f[b[0]][b[1]][b[2]][nxtl] = 1;
								}
							}
						}
					}
				}
			if (f[0][0][0][0]) break;
			else ++a[j];
		}
		int u = i;
		while (u && ans[u] != ans[i]) u = pre[u];
		pre[i + 1] = pre[u] + (ans[u] == ans[i]);
		REP(j, 0, 3)
		{
			if (ans[i] == 'a' + j) nxt[i][j] = i + 1;
			else
			{
				if (!i) nxt[i][j] = 0;
				else nxt[i][j] = nxt[pre[i]][j];
			}
		}
	}
	REP(i, 0, tmp) printf("%s", ans);
	return 0;
}


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





int main()
{
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k ;
  if ( e-a>k)
  {
    cout << ":(" << endl;
  }
  else 
  { cout <<"Yay!" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>

#define N 1024

//sort and  upper k
int main(){
int n,k;
int p[N]={0};
int tmp=0;
  
  scanf("%d %d",&n,&k);
  for(int i=0;i<n;i++)scanf("%d",&p[i]);
  //for(int i=n-1;i>=0;i--) printf("%d\n",p[i]);puts("");
  
  for(int i=0; i<n; i++){          //n- i  is ng make it simple 
      for(int j=i+1; j<n; j++){ //for(int j=; j<n-i; j++){//for(int j=i+1; j<n-i; j++){ //for(int j=n-1;n>=0;j--){
        if( p[i] > p[j] ){
          tmp=p[i];
          p[i]=p[j];
          p[j]=tmp;
        }  
                
      }
  }
  //for(int i=n-1;i>=0;i--) printf("%d\n",p[i]);
  //all conditon ? not || it is or
    
    for(int i=0;i<k;i++) p[1008]+=p[i];   
    printf("%d\n",p[1008]);
    
    
return 0;
}

/*
5 3
50 100 80 120 80

*/

Measured memory_bytes: 2144
import java.util.*;
public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
   
    int x = N * A;
    int y = B;
    
    if (x < y){                       
    	System.out.println(x);
    }else if (x > y){
    	System.out.println(y); 
    }else if (x == y){
    	System.out.println(y); 
    }
  }
}

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

int main() {
	long long n,m;
	cin >> n >> m;
	int l[100000],r[100000];
	for(int i=0;i<m;i++) {
		cin >> l[i] >> r[i];
	}
	sort(l,l+m);
	sort(r,r+m);
	if(l[m-1]<=r[0]) {
		cout << (r[0]-l[m-1]) + 1 << endl;
	}
	else cout << 0 << endl;
	return 0;
}

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

 
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int s = 0;
  rep(i,n) s += a[i];
  int cnt = 0;
  rep(i,n) {
    if (a[i]*(4*m) >= s) cnt++;
  }
  if (cnt >= m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3612
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)

	var min float64 = 9999999999
	var max float64 = -9999999999
	var total float64 = 0
	for i := 0; i < n; i++ {
		var a float64
		fmt.Scan(&a)
		max = math.Max(max, a)
		min = math.Min(min, a)
		total += a
	}

	fmt.Println(int(min), int(max), int(total))

}



Measured memory_bytes: 1784
#include <algorithm>
#include <iostream>
#include <string>

#include <vector>
#include <cmath>
#include <limits>
#include <functional>
using namespace std;

int main()
{
    int a, b, c, x, y;
    int ans = 0;

    cin >> a >> b >> c >> x >> y;

    if (x > y)
    {
        if (a + b > 2 * c)
        {
            ans = ans + c * 2 * y;
        }
        else
        {
            ans = ans + a * y + b * y;
        }

        if ((x - y) * a < (x - y) * 2 * c)
        {
            ans += (x - y) * a;
        }
        else
        {
            ans += (x - y) * 2 * c;
        }
    }
    else if (x <= y)
    {
        if (a + b > 2 * c)
        {
            ans = ans + c * 2 * x;
        }
        else
        {
            ans = ans + a * x + b * x;
        }

        if ((y-x) * b < (y-x) * 2 * c)
        {
            ans += (y-x) * b;
        }
        else
        {
            ans += (y-x) * 2 * c;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3144
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define FOR(i,k,n) for((i)=(k);(i)<(n);(i)++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define pb push_back
#define all(a) (a).begin(),(a).end()  //greater<int>()
using namespace std;

int main(){
	int W,a,b;
	cin>>W>>a>>b;

	if (abs(a-b)>W){
		cout<<abs(a-b)-W<<endl;}

	else cout<<0<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 110000;

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

int n,k;
int a[maxn];

int main()
{
	scanf("%d%d",&n,&k);
	int d=0,mx=0;
	for(int i=1;i<=n;i++) 
	{
		scanf("%d",&a[i]);
		d=gcd(d,a[i]); if(a[i]>mx) mx=a[i];
		if(a[i]==k) { puts("POSSIBLE");return 0; }
	}
	if(mx>k&&k%d==0) puts("POSSIBLE");
	else puts("IMPOSSIBLE");	
	
	return 0;
}


Measured memory_bytes: 640
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
const int INF=0x3f3f3f3f;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int arr[1005];
int main()
{
    int n;
    while(cin>>n)
    {
        int maxval=-INF;
        int minval=INF;
        for(int i=1;i<=n;i++)
        {
            cin>>arr[i];
        }
        int ans=INF;
        for(int i=1;i<=100;i++)
        {
            int res=0;
            for(int j=1;j<=n;j++)
            {
                res+=(arr[j]-i)*(arr[j]-i);
            }
            ans=min(ans,res);
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
lis = list(map(int, input().split()))

lis =sorted(lis)

if n > m:
    print(0)
    exit()
    
tmp = []
for i in range(m-1):
    tmp.append(lis[i+1] - lis[i])
    
tmp = sorted(tmp)

if n == 1:
    print(sum(tmp))
else:
    print(sum(tmp[:-(n-1)]))

Measured memory_bytes: 13968
import sys
sys.setrecursionlimit(1000000)
 
n = int(input())

a = list(map(int,input().split()))

m1 = a[0]

for i in range(1,n-1):
    if i % 2 == 0:
        m1 += a[i]
    else:
        m1 -= a[i]
mnt =[]

m1 = m1+a[n-1]
print(m1,end=" ")

for i in range(n-1):
    m1 = 2 * a[i] - int(m1)
    print(m1,end=" ")
    


Measured memory_bytes: 14096
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		int[] A = nextIntArray(N);

		Arrays.sort(A);

		int cnt = 0;
		if(N % 2 == 1) {
			out.println(0);
			return;
		}

		int L = A[N/2-1];
		int R = A[N/2];

		cnt = R - L;

		//out.println(Arrays.toString(A));
		out.println(cnt);
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}

Measured memory_bytes: 48044
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
//----
const int N=101010;
char s[N];
int main(){
	scanf("%s", s);
	int n=strlen(s);
	int ans=0;
	rep(i, 0, n)if(s[i]=='g')ans++;
	else ans--;
	printf("%d\n", ans/2);
	return 0;
}

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

int r,s,p;

//dpでやったけどうまくいかなかったので解説見て貪欲法で




int main(){
	cin>>n>>k>>r>>s>>p;
	int a=0,b=0;
	int t[k][(n+k-1)/k+1]={};
	int g=(n+k-1)/k+1;
	char h;
	for(int i=0;i<n;i++){
		cin>>h;
		if(h=='r'){
			t[a][b]=3;
		}else if(h=='s'){
			t[a][b]=1;
		}else{
			t[a][b]=2;
		}
		//cout<<a<<" "<<b<<endl;
		if(a>=k-1){
			b++;
			a=0;
		}else{
			a++;
		}
		
	}
	//cout<<"A"<<endl;
	int ans=0;
	for(int i=0;i<k;i++){
		int c=0,e=0;
		while(t[i][c]!=0){
			//cout<<e<<endl;
			if(e!=t[i][c]){
				if(t[i][c]==1){
					ans+=r;
				}else if(t[i][c]==2){
					ans+=s;
				}
				if(t[i][c]==3){
					ans+=p;
				}
				e=t[i][c];
			}else{
				e=0;
			}
			c++;
		}


	}
	cout<<ans<<endl;
}

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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i, m, n) for(int i = (int)m; i < (int)n; i++)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    string n;
    int a,b,c,d; cin >> n;
    a = n[0] - '0';
    b = n[1] - '0';
    c = n[2] - '0';
    d = n[3] - '0';

    if(a+b+c+d == 7){cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7";}
    else if(a+b+c-d == 7){cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7";}
    else if(a+b-c+d == 7){cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7";}
    else if(a-b+c+d == 7){cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7";}
    else if(a-b-c+d == 7){cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7";}
    else if(a-b+c-d == 7){cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7";}
    else if(a+b-c-d == 7){cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7";}
    else if(a-b-c-d == 7){cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7";}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 2000000000
#define limit 10000000
int arr[100005];
vector<pair<pair<int, string>, pair<int, int>>> v;
struct op {
    bool operator()(pair<pair<int, string>, pair<int, int>> a,pair<pair<int, string>, pair<int, int>> b) {
        return a.second.second<b.second.second;
    }
};

struct op2 {
    bool operator()(pair<pair<int, string>, pair<int, int>> a,pair<pair<int, string>, pair<int, int>> b) {
        return a.first.first<b.first.first;
    }
};
int main(){
    int n,m;cin>>n>>m;
    for (int i=0;i<m;i++) {
        int p,y;cin>>p>>y;
        v.push_back({{i,""},{p,y}});
    }
    sort(v.begin(), v.end(), op());
    for (int i=0;i<m;i++) {
        string f,s; 
        s = to_string(++arr[v[i].second.first]);
        f = to_string(v[i].second.first);
        while ((int) s.length()<6) s = '0'+s;
        while ((int) f.length()<6) f = '0'+f; 
        f+=s; v[i].first.second = f;
    }
    sort(v.begin(), v.end(), op2());
    for (int i=0;i<m;i++) {
        cout<<v[i].first.second<<"\n";
    }
    return 0;
    
}

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

long long int gcm(long long a,long long b){
	long long r,tmp;
	if(a<b){
		tmp=a;
		a=b;
		b=tmp;
	}
	
	r=a%b;
	while(r!=0){
		a=b;
		b=r;
		r=a%b;
	}
	return b;
}

int main(){
	long long N,X,ans;
	cin >> N >> X;
	
	if(X>N/2)X=N-X;
	long long g=gcm(N,X);
	N/=g;X/=g;
	
	ans=(N-1)*3;
	
	ans*=g;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;                                                                                  

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] l = line.split(" ");
        int a = Integer.parseInt(l[0]);
        int b = Integer.parseInt(l[1]);

        int x = a * b;
        int y = a * 2 + b * 2;
        System.out.println(x + " " + y); 
    }   
}

Measured memory_bytes: 26036
#include <bits/stdc++.h>
using namespace std;
int a, b, n;
int main()
{
	scanf("%d%d%d", &n, &a, &b);
	if (abs(a-b)%2 == 0)
	{
		printf("Alice\n");
	}
	else printf("Borys\n");
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string s,t;
  cin>>s>>t;
  sort(s.begin(), s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(), t.end());
  
  if(s<t) cout<<"Yes"<< endl;
  else cout<<"No"<< endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		long N = Long.parseLong(n);
		String a = sc.next();
		long A = Long.parseLong(a);
		String b = sc.next();
		long B = Long.parseLong(b);
		long ans;
		long mult = N / (A + B);
		long ex = N - (A + B) * mult;
		if(A == 0){
			ans = 0;
		}else{
			ans = mult * A;
			if(ex <= A){
				ans += ex;
			}else{
				ans += A;
			}
		}
		System.out.println(ans);
	}
}

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

int main() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	int score = 0;
	rep(i, n-1) {
		if(s[i] == s[i+1]) score++;
	}
	int ans = min(score + 2 * k, n-1);
	cout << ans << endl;
	return 0;
}

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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll N,A,B;
    cin>>N>>A>>B;
    if((A-B)%2==0){
        cout<<abs(A-B)/2<<endl;
    }else{
        if(A>B) swap(A,B);

        ll tmp1=abs(A-1)+abs(B-A+1)/2;
        ll tmp2=abs(N-B)+abs(B-A+1)/2;
        cout<<min(tmp1,tmp2)<<endl;
        
    }
}

Measured memory_bytes: 3604
import sys
from operator import itemgetter
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N, M = map(int, readline().split())
    ab = map(int, read().split())
    ab = sorted(zip(ab, ab), key=itemgetter(1))

    east_island = ab[0][1]
    answer = 1

    for i, j in ab:
        if i >= east_island:
            answer += 1
            east_island = j

    print(answer)


if __name__ == '__main__':
    main()

Measured memory_bytes: 29720
//abc107b.cpp
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    char a[h][w];
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cin>>a[i][j];
        }
    }
    //yoko
    int flag,ryaku[h];
    for(int k=0;k<h;k++)
    {
        ryaku[k]=0;
    }
    for(int c=0;c<h;c++)
    {
        flag=0;
        for(int b=0;b<w;b++)
        {
            if(a[c][b]=='.')
            {
                flag++;
            }
        }
        if(flag==w)
        {
            ryaku[c]=1;            
        }
    }
    int hata,habuki[w];
    for(int g=0;g<w;g++)
    {
        habuki[g]=0;
    }
    for(int d=0;d<w;d++)
    {
        hata=0;
        for(int e=0;e<h;e++)
        {
            if(a[e][d]=='.')
            {
                hata++;
            }
            if(hata==h)
            {
                habuki[d]=1;
            }
        }
    }
    //write
    for(int p=0;p<h;p++)
    {
        for(int q=0;q<w;q++)
        {
            if((ryaku[p]==0)&&(habuki[q]==0))
            {
                cout<<a[p][q];
            }
        }
        if(ryaku[p]==0)
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int A, B, c = 0;
    string x="", y="";
    cin >> A >> B;
    for(int i = A; i <= B; i++) {
        x = i / 10000;
        x += i / 1000 % 10;
        y = i % 10;
        y += i / 10 % 10;
        if(x == y) {
            c++;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int N;
	char S[N];
	scanf("%d", &N);
	scanf("%s", S);
	
	int yes = 0, no = 0;
	
	if(N % 2 == 0){
		for(int i = 0; i < (N / 2); i++){
			if(S[i] == S[i + (N / 2)]){
				yes++;
			}else{
				no++;
			}
		}
		
		if(yes == N / 2){
			printf("Yes");
		}else{
			printf("No");
		}
	}else{
		printf("No");
	}
	
	return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,i,x,key=0;
    scanf("%d",&n);
    int a[200000];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    for(i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            printf("NO");
            break;
        }
    }
    if(i==n-1){
        printf("YES");
    }
    return 0;
}


Measured memory_bytes: 1024
import math


def main():
    a, b, x = map(int, input().split())
    y = x / a
    s = a * b
    if y == s:
        print('0.0')
    elif y >= s / 2:
        y = (a * b) - (x / a)
        b_temp = 2 * y / a
        angle = math.atan(a / b_temp)
        print(90 - math.degrees(angle))
    else:
        a_temp = 2 * y / b
        angle = math.atan(b / a_temp)
        print(math.degrees(angle))



if __name__ == '__main__':
    main()


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

using namespace std;

const int NMAX = 200000 + 5;

typedef long long int lint;

map <lint, int> S;

int main() {
    ios_base :: sync_with_stdio(false);
    int N;
    cin >> N;

    lint s = 0;
    S[s] = 1;

    lint ans = 0;
    for (int i = 1; i <= N; ++ i) {
        int val;
        cin >> val;
        s += val;
        ans += S[s];
        ++ S[s];
    }

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


Measured memory_bytes: 12800
#include<stdio.h>
int main()
{
    int a,b,n;
    scanf("%d%d",&a,&b);
    n=a+b;
    if(n%3==0||a%3==0||b%3==0){
        printf("Possible\n");
    }
    else{
        printf("Impossible\n");
    }
    return 0;
}


Measured memory_bytes: 1620
c=[]
for i in range(3):
  c.append( list(map(int,input().split())) )
flag=0
for i in range(3):
  if c[i][0]-c[(i+1)%3][0] == c[i][1]-c[(i+1)%3][1] == c[i][2]-c[(i+1)%3][2]:
    flag+=1
for i in range(3):
  if c[0][i]-c[0][(i+1)%3] == c[1][i]-c[1][(i+1)%3] == c[2][i]-c[2][(i+1)%3]:
    flag+=1
if flag==6:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
x=int(input())
ans=0
if x>=10**4:
  ans=1
elif x<100:
  ans=0
else:
  y=x%100
  for i in range(1,21):
    if (y//(5*i)==0 or y==5*i) and x>=100*i:
      ans=1
print(ans)
    
    

Measured memory_bytes: 2940
import java.io.*;
//import java.math.BigDecimal;
//import java.lang.reflect.Array;
//import java.util.Arrays;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String line = br.readLine();
//			do {
//				String[] in = line.split(" ", 0);
//				//???????????????????¨????
//				
//				//???????????§??????
//				line = br.readLine();
//			} while (line != null);
			int num = line.length();
			String x = "";
			for(int i = 0; i < num; i++){
				x += line.charAt(num - i - 1);
			}
			System.out.println(x.toString());
		} catch (Exception e) {
			// TODO: handle exception
			System.exit(0);
		}

	}

}

Measured memory_bytes: 24328
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n; cin >> n;
    vector<int> a(n);
    repf(i,1,n) {
        int b; cin >> b;
        b--;
        a[b]++;
    }
    rep(i,n) {
        cout << a[i] << endl;
    }
    return 0;
}

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

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

string s;
ll dp[10000000 + 100][2];

int main() {
    cin >> s;
    // 桁から数える
    reverse(s.begin(), s.end());
    s += '0';

    int n = s.size();

    // i: 何桁め
    rep(i, n + 1)rep(j, 2) dp[i][j] = INF;
    dp[0][0] = 0;

    rep(i, n)rep(j, 2) {
        int x = s[i] - '0';
        // x += j;

        rep(a, 10) {
            int ni = i + 1, nj = 0;
            int b = (a - j) - x;
            if (b < 0) {
                nj = 1;
                b += 10;
            }

            dp[ni][nj] = min(dp[ni][nj], dp[i][j] + a + b);
        }
    }

    int ans = dp[n][0];
    cout << ans << endl;
}

Measured memory_bytes: 17668
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($N,$M) =  explode(" ",trim(fgets(STDIN)));
$A = explode(" ",trim(fgets(STDIN)));

$r = array_reduce($A,'gcd');
printf("%d\n",$r);

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


Measured memory_bytes: 12792
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

vll a;
vvl G = VV(200001, 0, 0, ll);
vvl T = VV(200001, 0, 0, ll); //森
vll par(200001, -1);
map<pair<ll, ll>, ll> edge;

void err(){
  std::cout << -1 << '\n';
  exit(0);
}
vll color(200001, -1);

void dfs(ll now, ll omit, ll d){
  if(color[now]!=-1) return;
  color[now] = d;
  for(auto to:T[now]){
    if(to==omit) continue;
    ll x = min(now, to);
    ll y = max(now, to);
    edge.emplace(make_pair(x, y), a[to]);
    dfs(to, -1, d^1);
  }
}
int main(int argc, char const *argv[]) {
  ll n, m;std::cin >> n >> m;
  re(i, n){
    ll b;scanf("%lld", &b);
    a.push_back(b);
  }
  vvl dat = VV(m, 2, 0, ll);
  re(i, m){
    ll x, y;scanf("%lld %lld", &x, &y);
    x--, y--;
    G[x].push_back(y);
    G[y].push_back(x);
    dat[i][0] = x, dat[i][1] = y;
  }

  for(int i=0;i<n;i++){
    ll min_num = 10000000000, idx = -1;
    for(auto to:G[i]){
      if(a[to]<=a[i]&&a[to]<min_num) {
        if(a[to]<min_num||to<idx) min_num = a[to], idx = to;
      }
    }
    if(idx==-1) err();
    T[idx].push_back(i);
    par[i] = idx;
  }

  // 各木の根は双方向の辺を持つ2頂点
  for(ll i=0;i<n;i++){
    if(par[par[i]]==i){
      ll x = min(i, par[i]);
      ll y = max(i, par[i]);
      edge.emplace(make_pair(x, y), a[i]);
      dfs(i, par[i], 0);
      dfs(par[i], i, 1);
    }
  }
  for(int i=0;i<n;i++) std::cout << (color[i]?'W':'B') << (i==n-1?"\n":"");
  for(int i=0;i<m;i++){
    ll x = min(dat[i][0], dat[i][1]);
    ll y = max(dat[i][0], dat[i][1]);
    auto itr = edge.find(make_pair(x, y));
    if(itr==edge.end()) std::cout << 1000000000 << '\n';
    else std::cout << (*itr).second << '\n';
  }

  return 0;
}


Measured memory_bytes: 40308
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
long long x,y;
int main() {
    cin >> x >> y;
    if(y >= 2*x && (y-2*x)%2 == 0 && y <= 4*x) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n;
  cin >>n;
  ll a[n+1][4];
  for(ll i=1;i<=n;i++){
    for(ll j=0;j<3;j++){
        cin >> a[i][j];
    }
  }
  ll dp[n+1][3];
  for(ll i=0;i<n+1;i++){
    for(ll j=0;j<3;j++){
      dp[i][j]=-1;
    }
  }
  dp[1][0]=a[1][0];
  dp[1][1]=a[1][1];
  dp[1][2]=a[1][2];
  for(ll i=2;i<n+1;i++){
    for(ll j=0;j<3;j++){
      for(ll k=0;k<3;k++){
        if(k==j) continue;
      dp[i][j]=max(a[i][j]+dp[i-1][k],dp[i][j]);
    }
    }
    }
  cout << max({dp[n][0],dp[n][1],dp[n][2]})<<endl;
  return 0;
}


Measured memory_bytes: 5760
import sys
input = sys.stdin.readline
def main():
    N, M = map(int, input().split())
    maxL, minR = 0, N+1
    for i in range(M):
        L, R = map(int, input().split())
        maxL = max(L, maxL)
        minR = min(R, minR)
    ans = minR -maxL + 1
    print(ans if ans>0 else 0)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9220
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
#include <string.h>
typedef long long ll;
const int MYINF = 1e9+7;
typedef int bool;
const bool true = 1;
const bool false = 0;

typedef struct node_st {
	int par;
	int left, right;
	int sib;
	int deg;
	int dep;
	int hei;
} node_t;

#define MAX_N 30

int n;
node_t nd[MAX_N];

const char *node_type_str(int id) {
	if (nd[id].par == -1) return "root";
	if (nd[id].left == -1 && nd[id].right == -1) return "leaf";
	else return "internal node";
}

void dfs(int id, int d) {
	int l, r;

	if (id == -1) return;
	l = nd[id].left;
	r = nd[id].right;

	nd[id].dep = d;
	dfs(l, d+1);
	dfs(r, d+1);

	nd[id].hei = 0;
	if (l != -1) {
		nd[id].hei = nd[l].hei + 1;
	}
	if (r != -1) {
		if (nd[id].hei <= nd[r].hei) {
			nd[id].hei = nd[r].hei + 1;
		}
	}
}

void pnode(int id) {
	printf("node %d: parent = %d, sibling = %d, degree = %d, "
	       "depth = %d, height = %d, %s\n",
	       id, nd[id].par, nd[id].sib, nd[id].deg, nd[id].dep,
	       nd[id].hei, node_type_str(id));
}

int main(int argc, char **argv)
{
	int i, id, l, r;

	memset(nd, -1, sizeof(node_t) * MAX_N);
	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d %d %d", &id, &l, &r);
		nd[id].left = l;
		nd[id].right = r;
		nd[id].deg = 0;
		if (l != -1 && r != -1) {
			nd[l].sib = r;
			nd[r].sib = l;
		}
		if (l != -1) {
			nd[l].par = id;
			nd[id].deg++;
		}
		if (r != -1) {
			nd[r].par = id;
			nd[id].deg++;
		}
	}

	for (i = 0; i < n; i++) {
		if (nd[i].par == -1) {
			dfs(i, 0);
			break;
		}
	}

	for (i = 0; i < n; i++) {
		pnode(i);
	}

	return 0;
}

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

int main() {
	int n,k,x;
	cin>>n>>k;
	int a[n],dp[k+1];
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	memset(dp,0,sizeof dp);
	for(int i=0;i<=k;i++)
	{
		if(i<a[0])dp[i]=0;
		else{
			for(int j=0;j<n;j++)
			{
				x=i-a[j];
				if(x<0){dp[i]=0;break;}
				if(dp[x]==0){dp[i]=1;break;}
			}
		}
	}
	if(dp[k]==1)cout<<"First";
	else cout<<"Second";
	return 0;
}

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

bool solve();

int main()
{
	if (solve())
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

bool solve()
{
	int n[4];
	for (int i{}; i < 4; i++)
		scanf("%d", n + i);
	std::sort(n, n + 4);
	int s[4]{1, 4, 7, 9};
	for (int i{}; i < 4; i++)
		if (n[i] != s[i])
			return false;

	return true;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main()
{
    int s, w;
    cin >> s >> w;

    if (s <= w)
    {
        cout << "unsafe" << endl;
    }
    else
    {
        cout << "safe" << endl;
    }
}

int main()
{
    std::cout << std::fixed << std::setprecision(15);
    Main();
}

Measured memory_bytes: 3624