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

int main() {
  int N , M;
  cin >> N >> M;
  vector<int> v(N);
 /* for (int i = 0; i < N; i++){
    v.at(i) = 0;
  }*/
  int A , B;
  for (int i = 0; i < M; i++){
    cin >> A >> B;
    v.at(A - 1) += 1;
    v.at(B - 1) += 1;
  }
  for (int i = 0; i < N; i++){
    cout << v.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int y;
    int m;
    int d;
    scanf("%d/%d/%d", &y, &m, &d);
    if (y < 2019)
    {
        printf("Heisei\n");
        return 0;
    }
    if (y == 2019)
    {
        if (m < 5)
        {
            printf("Heisei\n");
            return 0;
        }
    }
    printf("TBD\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=3006;//最多要开3000，因为n那里输入两个，m那里输入1个，共3个
const int inf=1e9+7; 
typedef long long ll;
int dir[][2]={1,0,-1,0,0,1,0,-1};
int a[maxn],b[maxn],c[maxn],D[maxn],e[maxn],f[maxn];//用于查询
int u[maxn][maxn],d[maxn][maxn],l[maxn][maxn],r[maxn][maxn],vis[maxn][maxn];//记录线段（方格边界）
vector<int>xx({-inf,inf}),yy({-inf,inf});//先塞入粉色区域
void bfs(int x,int y){
	vis[x][y]=1;
	queue<pair<int,int> > q;
	q.push({x,y});
	while(!q.empty()){
		x=q.front().first,y=q.front().second;
		q.pop();
		for(int i=0;i<4;i++){
			if(i==0&&r[x][y]) continue;
			if(i==1&&l[x][y]) continue;
			if(i==2&&u[x][y]) continue;
			if(i==3&&d[x][y]) continue;
			int nx=x+dir[i][0];
			int ny=y+dir[i][1];
			if(nx<0||ny<0) continue;//越界
			if(nx>=xx.size()-1||ny>=yy.size()-1) continue;//越界
			if(vis[nx][ny]) continue;
			vis[nx][ny]=1;
			q.push({nx,ny});
		}
	}
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		scanf("%d",&b[i]);
		scanf("%d",&c[i]);
		xx.push_back(a[i]);
		xx.push_back(b[i]);
		yy.push_back(c[i]);
	}
	for(int i=0;i<m;i++){
		scanf("%d",&D[i]);
		scanf("%d",&e[i]);
		scanf("%d",&f[i]);
		xx.push_back(D[i]);
		yy.push_back(e[i]);
		yy.push_back(f[i]);
	}
	sort(xx.begin(),xx.end());//先按照从小到大sort
	sort(yy.begin(),yy.end());
	xx.resize(unique(xx.begin(),xx.end())-xx.begin());//然后把重复项去掉！（压缩）
	yy.resize(unique(yy.begin(),yy.end())-yy.begin());
	for(int i=0;i<n;i++){
		//接下来对于每条线段，先把线段查找出来，再用新的压缩坐标标记。
		//新的压缩坐标是vector中的下标。
		int aa=lower_bound(xx.begin(),xx.end(),a[i])-xx.begin();
		int bb=lower_bound(xx.begin(),xx.end(),b[i])-xx.begin();
		int cc=lower_bound(yy.begin(),yy.end(),c[i])-yy.begin();
		for(int x=aa;x<bb;x++){
			u[x][cc-1]=1;
			d[x][cc]=1;
		}
	}
	for(int i=0;i<m;i++){
		int dd=lower_bound(xx.begin(),xx.end(),D[i])-xx.begin();
		int ee=lower_bound(yy.begin(),yy.end(),e[i])-yy.begin();
		int ff=lower_bound(yy.begin(),yy.end(),f[i])-yy.begin();
		for(int y=ee;y<ff;y++){
			l[dd][y]=1;
			r[dd-1][y]=1;
		}
	}
	//找到牛位置
	int x=lower_bound(xx.begin(),xx.end(),0)-xx.begin();
	int y=lower_bound(yy.begin(),yy.end(),0)-yy.begin();
	//用左下角方格做起点
	bfs(x-1,y-1);
	if(vis[0][0]){
		printf("INF\n");return 0;
	}
	ll ans=0;
	for(int i=0;i<xx.size()-1;i++){
		for(int j=0;j<yy.size()-1;j++){
			if(vis[i][j]) ans+=(ll)(xx[i+1]-xx[i])*(yy[j+1]-yy[j]);
		}
	}
	printf("%lld\n",ans);
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  string a = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
  for(int i = 0; i < s.size(); i++){
     for(int j = 0; j < 26; j++){
    if(s.at(i) == a.at(j)){
      s.at(i) = a.at(j+n);
      break;
    }
     continue;
  }
  }
  cout << s << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	Scanner sc;
	String S;
	
	private void calc() {
		sc = new Scanner(System.in);
		S = sc.next();
		int N = S.length();
		if (isRev(S) && isRev(S.substring(0, (N-1)/2)) && isRev(S.substring( (N-1)/2+1)))
			System.out.println("Yes");
		else System.out.println("No");
	}
	
	private boolean isRev(String s) {
		int n = s.length();
		for (int i = 0; i < n / 2; i++) {
			if (s.charAt(i) != s.charAt(n-1-i)) return false;
		}
		return true;
	}

	public static void main(String[] args) {
		new Main().calc();
	}
}


Measured memory_bytes: 35680
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint

INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))

N = int(input())
A = [int(input()) for _ in range(N)]

B = sorted(A)
B.reverse()
m1 = B[0]
m2 = B[1]

for a in A:
    if m1 == a:
        print(m2)
    else:
        print(m1)





Measured memory_bytes: 70232
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    if(x==2||y==2)
        cout<<"No";
    else if(y==11||y==9||y==6||y==4)
    {
        
        if(x==9||x==6||x==4)
        cout<<"Yes";
        else
            cout<<"No";
    }
    else
        {
            if(x!=9&&x!=6&&x!=4&&x!=11)
                cout<<"Yes";
            else
                cout<<"No";
        }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
	int n;
    cin>>n;
    double ans=0;
    REP(i,n){
        int a;
        cin>>a;
        ans+=(double)1/a;
    }
    ans=(double)1/ans;
    printf("%.8lf\n",ans);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

p1 = 0
p2 = sum(A)
diff = 9999999999999999
for i in range(N-1):
    p1 += A[i]
    p2 -= A[i]
    diff = min(diff, abs(p1-p2))

print(diff)

Measured memory_bytes: 23796
#include<bits/stdc++.h>
#define MAX_N 200005
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(V) (V).begin(),(V).end()
#define reset(V) (V).clear();(V).resize(0);
#define sq(x) ((x)*(x))
#define abs(x) ((x)>0?(x):(-(x)))
#define fi first
#define se second
#define inf 0x3fffffff
#define full_inf 0x7fffffff
#define half_inf 0x3fffffff
//#define inf 0x3fffffff
#define MOD 1000000007LL
#define cpx_mod(x) (((LD)(((LL)x.real())%MOD)),((LD)(((LL)x.imag())%MOD)))
#define prev(x) (((x)+n-1)%n)
#define next(x) (((x)+1)%n)
#define mod(x) (((x)%h + h)%h)
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pil;
typedef pair<LL,string> pls;
typedef complex<LD> Complex;
int n;
int lst[15];
void f(int l,int m){
	if(l == n){
		for(int i=0;i<n;i++){
			printf("%c",'a' + lst[i]);
		}
		printf("\n");
		return;
	}
	for(int i=0;i<m;i++){
		lst[l] = i;
		f(l + 1, max(i + 2, m));
	}
}
int main(){
	scanf("%d",&n);
	f(0,1);
	return 0;
}	

Measured memory_bytes: 1536
k, s = gets.split.map(&:to_i)
cnt = 0
f = [s - k * 2, 0].max
f.upto(k) do |x|
  f.upto(k) do |y|
    z = s - x - y
    next if k < z || z < 0
    cnt += 1
  end
end
p cnt

Measured memory_bytes: 1916
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

lint euc(lint a, lint b) {
	//aとbの最大公約数を返す
	if (a < b) return euc(b, a);
	lint r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

int main() {
	lint N;
	cin >> N;
	vector<lint>X(N + 1);
	rep(i, N + 1) {
		cin >> X[i];
	}
	sort(X);
	vector<lint>dif(N);
	rep(i, N) {
		dif[i] = X[i + 1] - X[i];
	}
	int ans = dif[0];
	rep(i, N) {
		ans = euc(ans, dif[i]);
	}
	cout << ans << endl;
}



Measured memory_bytes: 1792
import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
T = np.array(lr()).astype('int64')
A = np.array(lr()).astype('int64')
MOD = 10 ** 9 + 7

T_low = T.copy()
T_low[1:][T[1:] <= T[:-1]] = 1
A_low = A.copy()
A_low[:-1][A[:-1] <= A[1:]] = 1

lower = np.maximum(T_low, A_low)
upper = np.minimum(T, A)
domain = np.maximum(0, upper - lower + 1) #変域が0の時は記録が間違い
L = len(domain); LSQ = int(L**.5 + 1) # least squares method 最小二乗推定?
domain = np.resize(domain, LSQ**2) #行列の形に無理やりする下準備（1次元）
domain[L:] = 1 #後半は全部1
domain = domain.reshape((LSQ, LSQ))
for n in range(1, LSQ):
    domain[:, n] *= domain[:, n-1]; domain[:, n] %= MOD
for n in range(1, LSQ):
    domain[n] *= domain[n-1, -1]; domain[n] %= MOD
answer = domain[-1, -1]
print(answer)


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

using namespace std;

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

  string line;
  getline(cin, line);

  for (char& ch: line) {
    if (ch == '1') cout << '9';
    else cout << '1';
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

import math

Asum = sum(A)
candidates = []
for i in range(1, int(math.sqrt(Asum)) + 1):
    if Asum % i == 0:
        candidates.append(i)
        candidates.append(Asum // i)
candidates.sort()

# print("#", Asum)
# print("#", candidates)

ans = 1
for targ in candidates:
    if targ == 1: continue
    A_tmp = [(Ai % targ) for Ai in A]
    # A_tmp.sort(key=lambda x: min((x % targ), ((targ - x) % x)))
    A_tmp.sort()
    idx_l = 0
    idx_r = N - 1
    cnt = 0
    while sum(A_tmp) > 0 and idx_l < idx_r:
        cap_l = A_tmp[idx_l]
        cap_r = targ - A_tmp[idx_r]
        A_tmp[idx_l] = (A_tmp[idx_l] - min(cap_l, cap_r)) % targ
        A_tmp[idx_r] = (A_tmp[idx_r] + min(cap_l, cap_r)) % targ
        cnt += min(cap_l, cap_r)
        if A_tmp[idx_l] == 0:
            idx_l += 1
        if A_tmp[idx_r] == 0:
            idx_r -= 1
    #
    if cnt <= K and sum(A_tmp) == 0: ans = targ

print(ans)

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

int n, A[1000000];

int binary(int key){
    int left = 0;
    int right = n;
    int mid;
    while(left < right) {
        mid = (left + right) / 2;
        if (A[mid] == key) {return 1;}
        else if (key < A[mid]) {right = mid;}
        else {left = mid + 1;}
    }
    return 0;
}

int main() {
    int T;
    int q;
    int count = 0;
    
    scanf("%d", &n);
    
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%d", &T);
        if(binary( T )) count++;
    }
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 3508
#include <iostream>

using namespace std;

int main(void) {
  string s;
  cin >> s;
  int m = 0;

  for (int i = 0; i < 3; i++) {
    int cnt = 0;
    if (s[i] == 'R') {
      int cnt = 1;
      for (int j = i + 1; j < 3; j++) {
        if (s[j] == 'R')
          cnt++;
        else
          break;
      }
      m = max(m, cnt);
    }
  }
  cout << m << endl;
}

Measured memory_bytes: 3600
using System;
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            if (a < 6)
            {
                b = 0;
            }else if (a < 13)
            {
                b /= 2;
            }
            Console.WriteLine(b);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define maxn 50018
#define N 558
#define inf 200000000
#define PII pair<int,int>
using namespace std;
int n,m;
int cnt = 0;
int sum1,sum2;
int ans;
int father[N];
struct nod{
    int from,to,cost;
   
}edg[maxn];
bool cmp(nod i,nod j)
{
    return i.cost<j.cost;
}
int v[N],num[N];
void init()
{
    for(int i = 0;i <= n;i ++)
    {
        father[i]=i;num[i]=1;
    }
}
int find(int x){
    if(x!=father[x]) return father[x]=find(father[x]);
    return father[x];
}

bool Union(int x,int y)
{
        int fx = find(x),fy = find(y);
    if(fx!=fy)
    {
        father[fy] = fx;  num[fx]+=num[fy]; return true;
    }
    else
    {
        return false;
    }
         
}
void krus2()
{
    sum1=0,sum2=0;
    for(int i=0;i<cnt;i++){
       // cout << cnt << endl;
        int tmp=0;init();
        for(int j=0;j<m;j++){
            if(j!=v[i]){
                if(Union(edg[j].from,edg[j].to))
                {
                    tmp+=edg[j].cost;
                }
            
            }
        }
        if(tmp!=ans) sum1++,sum2+=edg[v[i]].cost;
    }
    printf("%d %d\n",sum1,sum2);
}
int main(){
     //freopen("in.txt","r",stdin);
    while(~scanf("%d%d",&n,&m)){
        cnt = 0;
        init();
        for(int i=0;i<m;i++){
            scanf("%d%d%d",&edg[i].from,&edg[i].to,&edg[i].cost);
        }
        sort(edg,edg+m,cmp);
        ans=0;
        memset(v,0,sizeof(v));
        for(int i=0;i<m;i++){
            if(Union(edg[i].from,edg[i].to)){
                ans+=edg[i].cost;
                v[cnt++]=i;
            }
        }
        krus2();
    }
    return 0;
}

Measured memory_bytes: 1800
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;

int main() {
    int N;
    cin >> N;
    if (N % 10 == 3){
        cout << "bon" << endl;
    }
    else if(N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8){
        cout << "pon" << endl;
    }
    else {
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3624
def qsort_by_point(d3_lst):
    if len(d3_lst) < 2:
        return d3_lst
    
    pivot = d3_lst[0][1]
    more = [i for i in d3_lst if i[1] > pivot]
    less = [i for i in d3_lst if i[1] < pivot]
    same = [i for i in d3_lst if i[1] == pivot]

    return qsort_by_point(more) + same + qsort_by_point(less)

def qsort_by_city(d3_lst):
    if len(d3_lst) < 2:
        return d3_lst
    pivot = d3_lst[0][0]
    more = [i for i in d3_lst if i[0] > pivot]
    less = [i for i in d3_lst if i[0] < pivot]
    same = [i for i in d3_lst if i[0] == pivot]

    return qsort_by_city(less) + same + qsort_by_city(more)

N = int(input())

restrant_and_point_lst = []

for number in range(1, N+1):
    Si, Pi = input().split()
    Pi = int(Pi)

    restrant_and_point_lst.append((Si, Pi, number))


restrant_and_point_lst = qsort_by_point(restrant_and_point_lst)
restrant_and_point_lst = qsort_by_city(restrant_and_point_lst)

for i in range(N):
    print(restrant_and_point_lst[i][2])

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

int main() {
  int N, K;
  cin >> N >> K;
  int d[K];
  int A[K][N];
  int B[N] = {};
  rep(i, K) {
    cin >> d[i];
    rep(j, d[i]) {
      cin >> A[i][j];
      B[A[i][j]-1]++;
    }
  }
  int ans = 0;
  rep(i, N){
    if(B[i] == 0)ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int long long i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int graph[51][51];
int a[51],b[51];
int color[51];
int nt[51];
int n,m;

int next(int v){
    for(int i=nt[v];i<n;i++){
        nt[v]=i+1;
        if(graph[v][i]==1&&color[i]==0){
            return i;
        }
    }
    return -1;
}


int main(){
    
    cin>>n>>m;
    int ans=0;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>a[i]>>b[i];
        graph[a[i]-1][b[i]-1]=1;
         graph[b[i]-1][a[i]-1]=1;
        
    }
    
    for(int i=0;i<m;i++){
        graph[a[i]-1][b[i]-1]=0;
         graph[b[i]-1][a[i]-1]=0;
        rep(j,51){
            color[j]=0;nt[j]=0;
        }
        
        color[0]=1;
        stack<int> q;
        q.push(0);
        
        while(!q.empty()){
            int u=q.top();
            int v=next(u);
            
            if(v!=-1){
                color[v]=1;
                q.push(v);
               // cout<<u<<v<<endl;
            }else{
                q.pop();
            }
        }
        
        rep(j,n){
            if(color[j]==0){
                ans++;
                break;
            }
        }
        
        
        graph[a[i]-1][b[i]-1]=1;
          graph[b[i]-1][a[i]-1]=1;
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define x first
#define y second
#define ii pair<int,ll>
using namespace std;

int n;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n;cin>>n;
    cout<<(n*(n-1))/2;
}

Measured memory_bytes: 256
s = str(input())
n = len(s)
for i in range(1,n):
    if s[i]==s[i-1]:
        print(i,i+1)
        break
    elif i >=2 and s[i]==s[i-2]:
        print(i-1, i+1)
        break
else:
    print(-1, -1)


Measured memory_bytes: 3188
# https://atcoder.jp/contests/abc065/tasks/abc065_b

import itertools
from collections import Counter
from collections import defaultdict
import bisect
import math
import heapq

def main():
    N = int(input())
    a = [int(input()) for _ in range(N)]

    ans = 0
    i = 0
    for _ in range(N):
        if a[i] - 1 == 1:
            print(ans + 1)
            exit()
        i = a[i] - 1
        ans += 1

    print(-1)

if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

int main(void){
	int result=0;
	string S,com={"CODEFESTIVAL2016"};
	cin>>S;

	REP(i,16) if(S[i]!=com[i]) result++;
	
	cout<<result<<endl;
	return 0;
}



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

const int INF = 1e9;

const int MAXN = 2333;
int N;
string S;
vector<int> adj[MAXN];
int subcnt[MAXN], dpmi[MAXN], dpma[MAXN];

void dfs(int cur, int prv = -1) {
	int maxmi = -1;
	int maxma = -1;
	subcnt[cur] = (S[cur] == '1');
	dpmi[cur] = dpma[cur] = 0;
	for (int nxt : adj[cur]) {
		if (nxt == prv) continue;
		dfs(nxt, cur);

		subcnt[cur] += subcnt[nxt];
		dpma[cur] += dpma[nxt] + subcnt[nxt];
		if (dpmi[nxt] + subcnt[nxt] > maxmi) {
			maxmi = dpmi[nxt] + subcnt[nxt];
			maxma = dpma[nxt] + subcnt[nxt];
		}
	}

	dpmi[cur] = max(maxmi - (dpma[cur] - maxma), dpma[cur] % 2);
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	cin >> S;
	for (int i = 0; i < N-1; i++) {
		int a, b; cin >> a >> b; a--, b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	int ans = INF;
	for (int root = 0; root < N; root++) {
		dfs(root);
		if (dpmi[root] == 0) {
			ans = min(ans, dpma[root] / 2);
		}
	}
	if (ans == INF) {
		ans = -1;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
Uses math;
var
	n,i,cx,cy,hg,flag,s:Longint;
	x,y,h:array[1..100]of Longint;
begin
	read(n);
	for i:=1 to n do begin
		read(x[i],y[i],h[i]);
		if h[i]>0 then s:=i;
	end;
	for cx:=0 to 100 do begin
		for cy:=0 to 100 do begin
			hg:=h[s]+abs(x[s]-cx)+abs(y[s]-cy);
			flag:=1;
			for i:=1 to n do begin
				if h[i]<>Max(hg-abs(x[i]-cx)-abs(y[i]-cy),0) then begin
					flag:=0;
					break;
				end;
			end;
			if flag>0 then writeln(cx,' ',cy,' ',hg);
		end;
	end;
end.


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

int main()
{
  int A, B;
  cin >> A >> B;
  
  if(A > B)
    cout << A + (A - 1) << endl;
  else if(A < B)
    cout << B + (B - 1) << endl;
  else if(A == B)
    cout << A + B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n, k;
    cin >> n >> k;
    int p[n];
    rep(i, n) {
        cin >> p[i];
    }
    sort(p, p + n);
    int ans = 0;
    rep(i, k) {
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);
        
        // 1st row
        int length = scanner.nextInt();

        // initial
        int max = -1000000;
        int min = 1000000;
        long total = 0;
        
        // 2st row split
        for (int i=0; i<length; i++) {
            int num = scanner.nextInt();
            
            // update max, min, total
            if (max < num) {
                max = num;
            }
            if (min > num) {
                min = num;
            }
            total += num;
        }

        System.out.println(min + " " + max + " " + total);
    }
}


Measured memory_bytes: 41252
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();

    LL n;
    cin >> n;
    LL ans = n*(n-1)/2;
    cout << ans << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = AtRead::from(i);
    let (n, x) = i.read2::<usize, usize>();
    let a = i.read_vec::<usize>(n);

    writeln!(o, "{}", solve(&a, x)).unwrap();
}
fn solve(a: &[usize], x: usize) -> usize {
    let mut b = Vec::new();
    b.push(0);
    b.push(a[0]);
    for i in 0..a.len() - 1 {
        b.push(a[i] + a[i + 1]);
    }
    b.push(a[a.len() - 1]);
    b.push(0);
    for bi in &mut b {
        if *bi > x {
            *bi = *bi - x;
        } else {
            *bi = 0;
        }
    }

    fn eat(b: &mut usize, value: usize) {
        if *b > value {
            *b -= value;
        } else {
            *b = 0;
        }
    }

    let mut result = 0;
    let mut changed = true;
    while changed {
        changed = false;
        for i in 1..b.len() - 1 {
            let bi = b[i];
            if bi == 0 {
                continue;
            }
            if b[i - 1] == 0 {
                eat(&mut b[i], bi);
                eat(&mut b[i + 1], bi);
                result += bi;
            } else if b[i + 1] == 0 {
                eat(&mut b[i - 1], bi);
                eat(&mut b[i], bi);
                result += bi;
            }
            changed = true;
        }
    }
    result
}

mod utils {
    use super::*;

    pub struct AtRead<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        {$f:ident($($v:ident: $t:ident),*)} => {
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                $(
                    let $v = next(i);
                )*
                ($($v),*)
            }
        };
    }

    impl<R: BufRead> AtRead<R> {
        pub fn from(r: R) -> Self {
            AtRead {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(v1: T1, v2: T2) }

        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            self.read_line()
                .split(' ')
                .take(n)
                .map(|x| x.parse().ok().unwrap())
                .collect()
        }
    }

    fn next<'a, T: FromStr, I: std::iter::Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 10492
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")



void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
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;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    // char ;
    ll n,ans=1;
    scanf("%lld",&n);
    ll d[n],dis[n];
    rep(i,0,n){
        scanf("%lld",&d[i]);
        dis[i]=0;
        if(i!=0&&d[i]==0){
            printf("0\n");
            return 0;
        }
    }
    if(d[0]!=0){
        printf("0\n");
        return 0;
    }
    sortup(d,n);
    dis[0]=1;
    rep(i,1,n){
        if(dis[d[i]-1]==0){
            printf("0\n");
            return 0;
        }else{
            ans*=dis[d[i]-1];
            ans%=MOD2;
            dis[d[i]]++;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2556
N, W = map(int, input().split())
w, v = [0] * (N + 1), [0] * (N + 1)
for i in range(1, N + 1):
    w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for i in range(N + 1)]

for i in range(1, N + 1):
    for j in range(1, W + 1):
        dp[i][j] = dp[i - 1][j]
        if j - w[i] >= 0: dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i])
        #print(dp)
print(dp[N][W])


Measured memory_bytes: 120172
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string.h>
#include<algorithm>

int main() {

	int N;
	int h[200];
	int cnt = 0;

	scanf("%d", &N);

	for (int i = 0; i < N; i++) {
		scanf("%d", &h[i]);
	}
	for (int i = 0; i < 10000; i++) {
		A:

		for (int j = 0; j < N; j++) {
			if (h[j] > 0) {
				for (int k = j + 1; k < N+1; k++) {
					if (k==N||h[k] == 0) {
						
						for (int u = j; u < k; u++) {
							h[u] -= 1;
						}
						cnt++;
						goto A;
					}
				}
			}
			if (j == N - 1)goto B;
		}
	}
	B:
	printf("%d", cnt);


	return(0);
}

Measured memory_bytes: 128
package main

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

func main() {
	n := readI()
	p := make([]float64, n+1)
	for i := 1; i <= n; i++ {
		p[i] = readF()
	}

	// dp[i][j] = i枚目までのコインを投げて表がj枚になる確率
	dp := make([][]float64, n+1)
	for i := 0; i <= n; i++ {
		dp[i] = make([]float64, i+2)
	}
	dp[0][0] = 1.0
	for i := 1; i <= n; i++ {
		dp[i][0] = dp[i-1][0] * (1 - p[i])
		for j := 1; j <= i; j++ {
			dp[i][j] = dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i])
		}
	}
	fmt.Println(sum(dp[n][n/2+1:]))

}

func sum(a []float64) float64 {
	s := 0.0
	for _, v := range a {
		s += v
	}
	return s
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


Measured memory_bytes: 40752
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

  		int nums[] = new int[2]; 
      	
      	for(int i = 0;i < 2; i++){
        	nums[i] = sc.nextInt();
        }
      
      	int counts[] = new int[nums[0]];
        for(int i = 0; i < nums[0]; i++) counts[i] = 0;
      
      	for(int i = 0; i < nums[1]*2; i++){
          counts[sc.nextInt()-1]++;
        }
 		
      	for(int count:counts) System.out.println(count);
        
	}
}


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

public class Main {

    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {

        solve();
    }

    private static void solve() {

        int n = scanner.nextInt();
        long k = scanner.nextLong();

        int[] next = new int[n + 1];
        boolean[] visited = new boolean[n + 1];

        for (int i = 1; i <= n; i++) {
            next[i] = scanner.nextInt();
        }


        int result = 1;

        int count = 0;

        while (count < k && !visited[result]) {
            count++;
            visited[result] = true;
            result = next[result];
        }

        Arrays.fill(visited, false);
        int count2 = 0;
        while (count + count2 < k && !visited[result]) {
            count2++;
            visited[result] = true;
            result = next[result];
        }

        if (count + count2 < k) {
            int diff = count - count2;
            long r = (k - diff) % count2;


            for (int i = 0; i < r; i++) {
                result = next[result];
            }
        }

        System.out.println(result);

    }
}

Measured memory_bytes: 60344
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999
MOD = 10**9+7

n = int(input())

# factors = [1] * (n+1)

ans = 0
for i in range(1, n+1):
    for j in range(i, n+1, i):
        ans += j

print(ans)


Measured memory_bytes: 74372
S = input()
N = len(S)

hand = {'g': 0, 'p': 0}
ans = 0
for i in range(N):
    if S[i] == 'g':
        if hand['g'] > hand['p']:
            hand['p'] += 1
            ans += 1
        else:
            hand['g'] += 1
    else:
        if hand['g'] > hand['p']:
            hand['p'] += 1
        else:
            hand['g'] += 1
            ans -= 1

print(ans)

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

int main()
{
	ll a, b, c, d;

	cin >> a >> b >> c >> d;

	ll s1 = max(a * c, a * d);
	ll s2 = max(b * c, b * d);

	cout <<max(s1,s2);
}


Measured memory_bytes: 3608
N = int(input())
A = sorted(list(map(int,input().split())))

ave = sum(A) // N
ave2 = sum(A) // N + 1

total = [0,0]

for i in range(N):
  total[0] += abs(A[i] - ave) ** 2
  total[1] += abs(A[i] - ave2) ** 2
  
print(min(total))

Measured memory_bytes: 3064
class lheapq:
    def __init__(self, p):
        self.l = []
        if p:
            for sp in p:
                self.heappush(sp)

    def heappush(self, a):
        n = len(self.l)
        self.l.append(a)
        t = n
        while t != 0:
            if self.l[t][1] < self.l[(t - 1) // 2][1]:
                self.l[t], self.l[(t - 1) // 2] = self.l[(t - 1) // 2], self.l[t]
                t = (t - 1) // 2
            else:
                break

    def heappop(self):
        n = len(self.l)
        if n == 0:
            return [-1, 0]
        if n == 1:
            return self.l.pop()
        ret = self.l[0]
        self.l[0] = self.l.pop()
        n -= 1
        t = 0
        while t < n:
            child1 = t * 2 + 1
            child2 = t * 2 + 2
            if child1 >= n:
                break
            elif child2 >= n:
                if self.l[t][1] > self.l[child1][1]:
                    self.l[t], self.l[child1] = self.l[child1], self.l[t]
                    t = child1
                else:
                    break
            else:
                if self.l[child2][1] < self.l[child1][1]:
                    child1, child2 = child2, child1
                if self.l[t][1] > self.l[child1][1]:
                    self.l[t], self.l[child1] = self.l[child1], self.l[t]
                    t = child1
                elif self.l[t][1] > self.l[child2][1]:
                    self.l[t], self.l[child2] = self.l[child2], self.l[t]
                    t = child2
                else:
                    break
        return ret

    def isnotblank(self):
        if self.l:
            return True
        else:
            return False


def dijkstra(s, g, n):
    # グラフgの点0から点n-1までの最短距離を求める。
    # グラフは隣接行列で[[[目的地、辺の重み],[目的地、辺の重み]],[],...]
    f = [-1 for _ in range(n)]
    f[s] = 0
    q = lheapq(g[s])
    while True:
        kakutei = q.heappop()
        if kakutei[0] == -1:
            return f
        while f[kakutei[0]] != -1:
            kakutei = q.heappop()
            if kakutei[0] == -1:
                return f
        s = kakutei[0]
        f[s] = kakutei[1]
        for sg, sl in g[s]:
            if f[sg] == -1:
                q.heappush([sg, sl + f[s]])


def main():
    N, X, Y = map(int, input().split())
    g = [[] for _ in range(N)]
    for i in range(N - 1):
        g[i].append([i + 1, 1])
        g[i + 1].append([i, 1])
    g[X - 1].append([Y - 1, 1])
    g[Y - 1].append([X - 1, 1])
    res = [0 for _ in range(N)]
    for i in range(N):
        tres = dijkstra(i, g, N)
        for stres in tres:
            res[stres] += 1

    for i in range(1, N):
        print(res[i] // 2)


main()


Measured memory_bytes: 58204
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <iomanip>

using namespace std;

void B_149()
{
  long long A, B, K;
  cin >> A >> B >> K;

  A -= K;
  if (A < 0)
  {
    B += A;
    A = 0;
  }
  if (B < 0) B = 0;

  cout << A << " " << B << endl;
}

int main()
{
  //C_140();
  //C_141();
  //C_142();
  //C_143();
  //C_144();
  //C_145();
  //C_146();
  //C_147();
  //C_148();
  //C_149();
  //A_149();
  B_149();
  return 0;
}


Measured memory_bytes: 256
/// 5:28 PM 17/05/20
/// Author: t_bone_289 (An Immature Programmer.... I'm still developing !!)
#include<bits/stdc++.h>

using namespace std;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define VARIABLE_ERROR(x) cout << #x << " = " << x << endl;
#define CONTAINER_ERROR(v) cout << "{";for (auto &x:v) { cout << x << ','; }cout << "}" << endl;
#define PI 3.14159265358979323846
#define M 1000000007
#define INF 1e15
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n;
    cin >> n;
    n = n%10;
    if(n==2||n==4||n==5||n==7||n==9) {
        cout << "hon";
    } else if(n==0||n==1||n==6||n==8) {
        cout << "pon";
    } else {
        cout << "bon";
    }
    return 0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


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


int main(){
    ll n;
    string s;
    cin >> n >> s;

    ll mod = 1e9 + 7;

    map<char, ll> ma;
    set<char> keys;
    for(auto c : s){
        ma[c]++;
        keys.insert(c);
    }

    ll res = 1;
    for(auto c : keys){
        res *= 1+ma[c], res %= mod;
    }
    res--;
    for(auto c : keys){
        if(2 <= ma[c]){
            ma[c]*pow(2, n-ma[c]);
        }
    }

    cout << res << endl;
    

    return 0;
}



Measured memory_bytes: 720
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fi first
#define se second
#define fr front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}


signed main() {
	int a, b, c, d, e, f, g, h;
	cin >> a >> b >> c >> d;
	a--;
	e = b - a;
	f = a / c + a / d - a / lcm(c, d);
	g = b / c + b / d - b / lcm(c, d);
	h = g - f;
	cout << e - h << endl;
}



Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (k : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    list = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
  print $ list !! k

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
fn print_vec(arr: &Vec<u32>) {
    for i in 0..arr.len() {
        print!("{}", arr[i]);
        if i < arr.len() - 1 {
            print!(" ");
        }
    }
}
fn selection_sort(arr: &Vec<u32>, _n: u32) -> Vec<u32> {
    let mut sorted = arr.to_vec();
    let mut n_swap = 0;
    for i in 0..sorted.len() {
        let mut min_index = i;
        let mut min_value = sorted[i];

        for j in (i + 1)..sorted.len() {
            if sorted[j] < min_value {
                min_index = j;
                min_value = sorted[j];
            }
        }

        if sorted[min_index] != sorted[i] {
            n_swap += 1;
            sorted[min_index] = sorted[i];
            sorted[i] = min_value;
        }
    }
    print_vec(&sorted);
    println!("\n{}", n_swap);

    sorted
}

fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    let n: u32 = line.trim().parse().ok().unwrap();

    line.clear();
    std::io::stdin().read_line(&mut line).ok();
    let arr = line.split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect();

    selection_sort(&arr, n);
}



Measured memory_bytes: 5028
import sys

#+++++
		
def main():
	n = int(input())
	l=[i for i in range(n) if len(str(i+1)) % 2 == 1]
	print(len(l))
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 6676
#include<stdio.h>
//operation a == doubled
//operation b == increase by b
int main(){
    int a, b;
    scanf("%d %d", &a, &b);
    int result = 1;
    for(int i = 0; i < a; i++){
        if(result < b)//it works if result + b is smaller than doubled
        {
            result = result * 2;
        }
        else//it works if result * 2 is smaller than doubled
        {
            result = result + b;
        }
    }
    printf("%d\n", result);
    return 0;
}

Measured memory_bytes: 1736
#include "bits/stdc++.h"
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(ll i=0;i<n;++i)
#define END(x) (*(x.end()-1))
#define INF (INT_MAX / 2)

using namespace std;
typedef long long ll;


template<typename T>
T gcd(T a, T b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}

template<typename T>
T lcm(T a,T b){
    return a/gcd(a,b)*b;
}

int main(void){
    int a,b,c,n;
    cin>>a>>b>>c>>n;
    rep(i,n){
        if(a>=b){
            b*=2;
        }
        else{
            c*=2;
        }
    }
    if(a<b&&b<c){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}
/*

*/

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int, int>>> vvpp;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<pair<int, int>> vpp;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define all(n) (n).begin(), (n).end()
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void out(Arg1&& arg1) {
    cout << arg1 << '\n';
}

template <typename Arg1, typename ...Args>
void out(Arg1&& arg1, Args&& ...args) {
    cout << arg1 << ' ';
    out(args...);
}


template <typename T>
void outarr(vector<T> arr) {
    for (int i = 0; i < arr.size() -1; ++i) cout << arr[i] << ' ';
    cout << arr.back() << '\n';
}

template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    map<ll, ll> count;
    for (ll i = 0; i < n -1 ; ++i) {
        ll boss; cin >> boss;
        count[boss] += 1;
    }

    for (ll i = 1; i <= n; ++i) {
        cout << count[i] << '\n';
    }

    return 0;
}



Measured memory_bytes: 16168
#include <iostream>
#include <vector>
#include <complex>
#include <algorithm>

using namespace std;

typedef complex<double> Point;

//Verified PKU 2812
double cross(const Point &v1, const Point &v2) {
    return (v1.real()*v2.imag()) - (v1.imag()*v2.real());
}

//Verified AOJ 0012
//Verified PKU 3348
double ccw(const Point &p1, const Point &p2, const Point &p3) {
    return cross(p2-p1, p3-p1);
}

//Verified PKU 3348
bool cmp(const Point &p1, const Point &p2) {
    return p1.real() < p2.real();
}

//Verified PKU 3348
vector<Point> convex_hull(const vector<Point> &points) {
    int N = points.size();
    vector<Point> v = points;
    sort(v.begin(), v.end(), cmp);
    vector<Point> hull(2*N);
    int pos = 0;
    for(int i = 0; i < N; ++i) {
        while(pos >= 2 && ccw(hull[pos-2], hull[pos-1], v[i]) <= 0) --pos;
        hull[pos++] = v[i];
    }
    int lim = pos;
    for(int i = N-2; i >= 0; --i) {
        while(pos >= lim+1 && ccw(hull[pos-2], hull[pos-1], v[i]) <= 0) --pos;
        hull[pos++] = v[i];
    }
    hull.erase(hull.begin()+pos-1, hull.end());
    return hull;
}

int main() {
    while(true) {
        int N;
        cin >> N;
        if(!N) break;
        vector<Point> ps(N);
        char comma;
        for(int i = 0; i < N; ++i) cin >> ps[i].real() >> comma >> ps[i].imag();

        vector<Point> hull = convex_hull(ps);
        cout << N-hull.size() << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi acos(-1)
using ll = long long;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using namespace std;
using namespace __gnu_pbds;
using vl = vector<ll>;
using pll =  pair<ll,ll>;



void solve(){
    string s;
    int a,b,m;
    cin>>a>>b>>m;
    ll r[a+1],mi[b+1],mr=mod,mmi=mod;
    for(int i=1;i<=a;i++){
        cin>>r[i];
        mr = min(mr,r[i]);
    }
 
    for(int i=1;i<=b;i++){
        cin>>mi[i];
        mmi = min(mmi,mi[i]);
    }
 
    ll ans = mmi+mr;
    for(int i=0;i<m;i++){
        int x,y,dis;
        cin>>x>>y>>dis;
        ans = min(ans,r[x]+mi[y] - dis);
    }
    cout<<ans;
}    

 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //int n;cin>>n;for(int i=0;i<n;i++) 
    solve();
    return 0;
}

Measured memory_bytes: 1792