akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#define min(a,b) (a)<(b)?(a):(b)
int n;
long long a[100005], b[100005];
long long ans;

void cut(int i, int j)
{
	int det = min(b[i], a[j]);
	b[i] -= det;
	a[j] -= det;
	ans += det;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n + 1; i++) {
		scanf("%lld", a + i);
	}
	for (int i = 1; i <= n; i++) {
		scanf("%lld", b + i);
	}
	int i = 1, j = n;
	while (i <= j) {
		cut(i, i);
		cut(i, i + 1);
		cut(j, j + 1);
		cut(j, j);
		i++;
		j--;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
using namespace std;


int main ()
{

int age;
cin >>  age;

if(age==1)
{
	cout << "Hello World";
}
else
{
	int a,b;
	cin >> a >> b;
	cout << a+b << endl;
}


 	return 0;
}












Measured memory_bytes: 3584
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1275
#include <iostream>
#include <vector>
using namespace std;

int main(){
  int n,k,m;

  while(cin>>n>>k>>m&&n|k|m){
    vector<int> stones;

    for(int i=0;i<n;++i){
      stones.push_back(i+1);
    }

//    vector<int>::iterator it = stones.begin()+m-1;
    int pos = m-1;   
    while(stones.size()>1){
      stones.erase(stones.begin()+pos);
      --pos;
      pos = (pos+k) % stones.size();
    }

    cout << stones.front() << endl;
  }

  return 0;
}

Measured memory_bytes: 1324
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int n;
  cin >> n;
  vi p(n);
  rep(i, n) cin >> p[i];

  int mn = p[0];
  int cnt = 0;
  rep(i, n){
    if (p[i] <= mn){
      mn = p[i];
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1024
/*
      @author: Charan Sai
*/
#include <bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define ppi pair<int, int>
#define endl "\n"
#define nl cout << "\n"
#define deb(x) cout << #x << " " << x << endl;

const int N = 1e5 + 2;
int height[N];
int n;

// 1. Backtrack Solution = 2^N Time
int minCost1(int i) {
    // Base Cases
    if(i == n) return 0;
    if(i > n) return INT_MAX;

    // Choice
    int cost1 = minCost1(i+1) + abs(height[i+1] - height[i]);
    int cost2 = minCost1(i+2) + abs(height[i+2] - height[i]);

    return min(cost1, cost2);
}

// 2. Top-Down Solution = Remove read-only arguments and redundant arguments
// and cache the results
// Time = (Range of possible values of the variable arguments) * (Time Compl of each function call)
// O(N) time
int dp[N];
int minCost2(int i) {
    // Base Cases
    if(i == n) return 0;
    if(i > n) return INT_MAX;

    if(dp[i] != -1) return dp[i];

    // Choice
    int cost1 = minCost2(i+1) + abs(height[i+1] - height[i]);
    int cost2 = minCost2(i+2) + abs(height[i+2] - height[i]);

    (dp[i] = min(cost1, cost2));
    return dp[i];
}

// 3. Bottom-Up Solution
int minCost3() {
    dp[n] = 0;
    dp[n+1] = INT_MAX;
    for(int i = n - 1; i >= 1; --i) {
        int cost1 = dp[i+1] + abs(height[i+1] - height[i]);
        int cost2 = dp[i+2] + abs(height[i+2] - height[i]);        
        dp[i] = min(cost1, cost2);
    }
    return dp[1];
}


int32_t main() {
      IOS;
      int t = 1;
      // cin >> t;
      while(t--) {
        memset(dp, -1, sizeof(dp));
        cin >> n;
        for(int i = 1; i <= n; ++i) cin >> height[i];
        cout << minCost3() << endl;
      }
}

Measured memory_bytes: 1792
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt();
		if(b==1) {
			System.out.println(0);
		}else {
			System.out.println(a-b);
		}
	}
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

void func(long long N, long long A, long long B, long long C, long long D,
          long long E) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    // 解説PDFより、ボトルネックを探す
    // ＝最小値
    ll minV = min({A, B, C, D, E});
    // 例 10人を3人のボトルネックを通す場合
    // 3+3+3+1で4回これは10/3の切り上げが答え
    // 切り上げのテクニックとして
    // (a+b)/b がある。
    // 例：(10+3)/3=4
    // 後はボトルネック以外の場所を通過する時間は
    // 必ず4となるので+4する。
    cout << (N + minV - 1) / minV + 4 << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long C;
    scanf("%lld", &C);
    long long D;
    scanf("%lld", &D);
    long long E;
    scanf("%lld", &E);

    func(N, A, B, C, D, E);

    return 0;
}


Measured memory_bytes: 256
N = int(input())
XY = [list(map(int,input().split())) for _ in range(N)]

li = {}
for i in range(N):
    for j in range(N):
        if i==j:
            continue

        x1,y1 = XY[i][0],XY[i][1]
        x2,y2 = XY[j][0],XY[j][1]

        mm1 = x2-x1
        mm2 = y2-y1
        # if mm1<0 and mm2<0:
        #     mm1 *= -1
        #     mm2 *= -1
        PQ = (mm1, mm2)

        if PQ in li:
            li[PQ] += 1
        else:
            li[PQ] = 1

mm = 0
for i in li:
    mm = max(mm,li[i])
print(N-mm)

Measured memory_bytes: 3444
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n,m = map(int,input().split())
ab = [0]*m
for i in range(m):
    ab[i] = list(map(int,input().split()))
ans = [0]*(m+1)
ans[0] = n*(n-1)//2
uf = UnionFind(n+1)
ab = ab[::-1]
for i,[a,b] in enumerate(ab):
    if uf.find(a) == uf.find(b):
        ans[i+1] = ans[i]
    else:
        ans[i+1] = ans[i] - uf.size(a)*uf.size(b)
    uf.union(a,b)
for i in range(m):
    print(ans[-i-2])

Measured memory_bytes: 31764
import sys

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

if N == 0:
    print(X)
    sys.exit()

comp = 101
for i in range(102):
    x = abs(X - i)
    if comp > x and i not in p:
        comp = x
        result = i

print(result)


Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector <ll> v(m);
  rep(i, m) cin >> v.at(i);
  sort(v.begin(), v.end());
  ll tmp = 0;
  rep(i, m-1) tmp += v.at(i);
  if (tmp >= v.at(m-1)) {
    cout << 0 << endl;
  } else {
    cout << v.at(m-1)-tmp-1 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if (a <= 5) {
    cout << 0 << endl;
  } else if (a <= 12) {
    cout << b/2 << endl;
  } else {
    cout << b << endl;
  }
  return(0);
}


Measured memory_bytes: 888
S = gets.chomp.to_i

v0 = [0, 0]
# v1 = (XX, y)
# v2 = (x, YY)
# S = XX * YY - x * y

XX = Math.sqrt(S).ceil
YY = XX
rest = (XX * YY) - S
x = rest
y = 1

v1 = [XX, y]
v2 = [x, YY]
print (v0 + v1 + v2).join(" ")

Measured memory_bytes: 1788
import java.util.*;

public class Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int k = sc.nextInt();
	if(k % 2 == 0){
		System.out.println("-1");
		System.exit(0);
	}
	if(k == 7 || k == 1){
		System.out.println("1");
		System.exit(0);
	}
	boolean finish = false;
	int count = 2;
	final int num = 7 % k;
	int amari = num;
	boolean[] al = new boolean[1000000];
	al[7] = true;
	while(finish == false){
		if((amari * 10 + num) % k == 0) {
			finish = true;
		}
		else if(al[(amari * 10 + num) % k]) {
			System.out.println("-1");
			System.exit(0);
		}
		else if(!((amari * 10 + num) % k == 0)){
			amari = (amari * 10 + num) % k;
			al[amari] = true;
			count++;
		}
	}
	System.out.println(count);
	sc.close();
	}
}

Measured memory_bytes: 36588
from collections import deque


def solve(h, w, ch, cw, dh, dw, s_list):

    s_arr = [[False] * (w + 4) for _ in range(h + 4)]
    for i, s in enumerate(s_list):
        for j in range(w):
            if s[j] == ".":
                s_arr[i + 2][j + 2] = True

    done_arr = [[False] * (w + 4) for _ in range(h + 4)]

    # heap
    queue = deque()
    res = -1
    # start
    queue.append((0, ch + 1, cw + 1))
    # main
    while len(queue):
        d, i, j = queue.popleft()
        if done_arr[i][j]:
            continue
        done_arr[i][j] = True
        # print(d, i, j)
        if i == dh + 1 and j == dw + 1:
            res = d
            # print("done")
            break
        for i_ in range(i - 2, i + 3):
            for j_ in range(j - 2, j + 3):
                if not done_arr[i_][j_] and s_arr[i_][j_]:
                    diff = abs(i_ - i) + abs(j_ - j)
                    if diff > 1:
                        queue.append((d + 1, i_, j_))
                    else:
                        queue.appendleft((d, i_, j_))
    # print(res)
    return res


def main():
    h, w = map(int, input().split())
    ch, cw = map(int, input().split())
    dh, dw = map(int, input().split())
    s_list = []
    for i in range(h):
        s = input()
        s_list.append(s)
    res = solve(h, w, ch, cw, dh, dw, s_list)
    print(res)


def test():
    assert solve(4, 4, 1, 1, 4, 4, ["..#.", "..#.", ".#..", ".#.."]) == 1
    assert solve(4, 4, 1, 4, 4, 1, [".##.", "####", "####", ".##."]) == -1
    assert solve(4, 4, 2, 2, 3, 3, ["....", "....", "....", "...."]) == 0
    assert solve(4, 5, 1, 2, 2, 5, ["#.###", "####.", "#..##", "#..##"]) == 2


def test_large():
    assert solve(1000, 1000, 1, 1, 1000, 1000, ["." * 1000 for _ in range(1000)]) == 0


if __name__ == "__main__":
    test()
    # test_large()
    main()


Measured memory_bytes: 217964
//Date of submission: 21-06-2020
 
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 1e5 + 5;
const double E= 1e-9;
 
//------------------------------------------------------------------------------
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*ifstream cin("input.txt");
    ofstream cout("output.txt");*/
    char a;
    cin>>a;
    if(isupper(a))
    cout<<"A";
    else
    cout<<"a";
    return 0;
}
 
//------------------------------------------------------------------------------

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N,K;
    cin >> N >> K;
    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> queg;
    priority_queue<pair<int,int>, vector<pair<int,int>>, less<pair<int,int>>> quel;
    vector<int> vec(N,0);
    int ans=1;
    int cnt=0;
    int tmp=0;
    for(int i=0; i<K; i++){
        int p;
        cin >> p;
        vec[i]=p;
        queg.push(make_pair(p,i));
        quel.push(make_pair(p,i));
        if(i>0 && vec[i-1]<vec[i]){
            tmp++;
            if(tmp==K-1){
                cnt++;
            }
        }else{
            tmp=0;
        }
    }

    for(int i=K; i<N; i++){
        int p;
        cin >> p;
        int L=vec[i-K];
        int R=vec[i]=p;
        quel.push(make_pair(p,i));

        while(queg.top().second<i-K){
            queg.pop();
        }
        while(quel.top().second<=i-K){
            quel.pop();
        }
        if(queg.top().second!=i-K || quel.top().second!=i){
            ans++;
        }
        queg.push(make_pair(p,i));
        if(i>0 && vec[i-1]<vec[i]){
            tmp++;
            if(tmp==K-1){
                cnt++;
            }
        }else{
            tmp=0;
        }
    }
    cout << ans+min(0,-cnt+1) << endl;
}

Measured memory_bytes: 4332
trump = Array.new

for mark_order in 0...4 do
  mark = begin
    case mark_order
    when 0; "S"
    when 1; "H"
    when 2; "C"
    when 3; "D"
    end
  end
  for n in 1..13 do
    trump << "#{mark} #{n}"
  end
end

cards_num = gets.to_i

cards_num.times do
  card = gets.to_s
  trump.delete("#{card.chop}")
end

puts trump

Measured memory_bytes: 6100
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a!=b && a!=c)cout << a << endl;
	else if(b!=a && b!=c)cout << b << endl;
	else if(c!=a && c!=b)cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            //// 文字列の入力
            //string s = Console.ReadLine();

            //// 整数の入力
            //long n = long.Parse(Console.ReadLine());

            //// 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            //// 整数配列の入力
            //var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            var a = inputLongArray[0];
            var b = inputLongArray[1];
            var c = inputLongArray[2];

            string result = "";

			if (a == b && b == c && c == a) {
                result = "1";
			} else if (a == b || b== c || a == c) {
                result = "2";
			} else {
                result = "3";
			}

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28164
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define in(x) scanf("%d",&x)
#define N 2005
int a[N];
int myabs(int x,int y)
{
    return x-y<0?y-x:x-y;
}
int main()
{
    LL n,m;
    while(cin>>n>>m)
    {
        LL ans=(LL)((n-m)*100+1900*m)*(1LL<<m);
        cout<<ans<<endl;
    }
}


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

using namespace std;

int main(void)
{
    long long A, B, N;
    cin >> A >> B >> N;

    // expr = floor(A * x / B) = ((A * x) - (A * x) % B) / B
    // A * floor(x / B) = A * (x - (x % B)) / B
    // floor(A * x / B) - A * floor(x / B) = (A * (x % B) - (A * x) % B) / B
    // (A * x) % B =  A * (x % B) % B
    // expr = A * (x % B - (x % B) % B) / B
    //      = A / B * floor (x % B)

    if(N >= B - 1){
        cout << floor(A * (B - 1) / B) - A * floor((B - 1)/B) << endl;
    } 
    else {
        cout << floor(A * N / B) - A * floor(N / B)<< endl;
    }


    return 0;

}

Measured memory_bytes: 3728
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1, 0));
    for (int si = 1; si <= s.size(); si++) {
        for (int ti = 1; ti <= t.size(); ti++) {
            if (s[si - 1] == t[ti - 1])
                dp[si][ti] = dp[si - 1][ti - 1] + 1;
            else
                dp[si][ti] = max(dp[si][ti - 1], dp[si - 1][ti]);
        }
    }
    string ans;
    for (int si = s.size(), ti = t.size(); ti >= 1 && si >= 1;) {
        if (dp[si][ti] == dp[si][ti - 1]) {
            ti--;
        } else if (dp[si][ti] == dp[si - 1][ti]) {
            si--;
        } else {
            ans = t[ti - 1] + ans;
            si--;
            ti--;
        }
    }

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

Measured memory_bytes: 35584
n, m = map(int, input().split())
good = [0] * n
pena = [0] * n
for i in range(m):
	pi, si = map(str, input().split())
	pi = int(pi)
	if si == "AC":
		good[pi - 1] = 1
	elif si == "WA" and good[pi - 1] == 0:
		pena[pi - 1] += 1

sum_good = 0
sum_pena = 0
for i in range(n):
	if good[i] >= 1:
		sum_good += 1
		sum_pena += pena[i]

print(sum_good, sum_pena)

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

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int ans;

    if (n * a > b)
    {
        ans = b;
    }
    else
    {
        ans = n * a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
#define alrep(i,j,n) for(int i=0;i<(n);++i)for(int j=i+1;j<(n);++j)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int MOD=1e9+7;
const long long INF = 1LL << 60;
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  int N;
  cin >> N;
  int d[N]={};
  rep(i,N) cin >> d[i];
  static int score=0;
  alrep(i,j,N){
    score+=d[i]*d[j];
  }
  cout << score << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())

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

    if 0 in n1:
        print(0)
        return

    sum = 1
    for i in n1:
        sum *= i
        if sum > 1000000000000000000:
            print(-1) 
            return 
    print(sum)

main()

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

int main(){
    int n;
    cin>>n;
    vector<int> a, b;
    rep(i, n){
        int value;
        cin>>value;
        if(i%2==0) a.push_back(value);
        else b.push_back(value);
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    multimap<int, int> aMap, bMap;
    int mode=1;
    rep(i,(n/2)-1){
        if(a[i]==a[i+1]){
            mode++;
        }else {
            aMap.insert(make_pair(mode,a[i]));
            mode = 1;
        }
    }
    aMap.insert(make_pair(mode,a[n/2-1]));

    mode = 1;
    rep(i,(n/2)-1){
        if(b[i]==b[i+1]){
            mode++;
        }else {
            bMap.insert(make_pair(mode,b[i]));
            mode = 1;
        }
    }
    bMap.insert(make_pair(mode,b[n/2-1]));

    multimap<int,int>::iterator ait, bit;
    ait = aMap.end();
    ait--;
    bit = bMap.end();
    bit--;

    int ans;
    if(ait->second == bit->second){
        if(aMap.size()!=1 && bMap.size()!=1){
            ait--;
            bit--;
            if(ait->first >= bit->first) bit++;
            else ait++;
            ans = n-(ait->first)-(bit->first);
        }else{
            if(aMap.size()==1 && bMap.size()==1){
                ans = n/2;
            }else if(aMap.size()==1){
                bit--;
                ans = n-(ait->first)-(bit->first);
            }else{
                ait--;
                ans = n-(ait->first)-(bit->first);
            }
        }
    }else{
        ans = n-(ait->first)-(bit->first);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 5372
from collections import deque
 
# 1から初めて、xがあるとき10x、x+1のいずれかが行えるとしてqueue
 
K = int(input())
q = deque()
q.append((1,1)) # 各桁の和、modulo K
visited = [False]*K
 
ans = 0
 
while ans == 0:
  s,x = q.popleft()
  if visited[x]:
    continue
  visited[x] = True
  if x == 0:
    ans = s
    break
  q.appendleft((s,(10*x)%K))
  q.append((s+1,(x+1)%K))

print(ans)


Measured memory_bytes: 14444
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n;
	cin >> n;
	
	vector<int> a(n + 1, 1);
	for (int i = 2; i <= n; ++i) 
	    for (int j = i; j <= n; j += i) 
	        a[j]++;
	
	int ans = 0;
	for (int i = 1; i < n; ++i) {
		int tmp = n - i;
		ans += a[tmp];
	}   
	
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 7132
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;


int main() {
  int n, m, k;
  cin >> n >> m;
  vi v[m+10];
  rep(i,n){
    cin >> k;
    int a;
    rep(j,k){
      cin >> a;
      a--;
      v[a].pb(i);
    }
  }
  int ans =0;
  rep(i,m){
    if(sz(v[i])==n){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define all(v) v.begin(), v.end()


int main(){
  ll D,G,ans=INF;
  cin >> D >> G;
  vector<ll> p(D),c(D);
  rep(i,D){
    cin >> p.at(i)>>c.at(i);
  }
  
  for (int tmp = 0; tmp < (1 <<(D)); tmp++) {
    bitset<10> s(tmp);
    ll t=0,x=0;
    rep(i,D){
      if(s.test(i)){
        x+=(100*(i+1)*p.at(i)) + c.at(i);
        t+=p.at(i);
      }
    }
    ll i=D-1;
    while(i>=0&&s.test(i)){
      i--;
    }
    if(x<G){
      rep(j,p.at(i)-1){
        x+=100*(i+1);
        t++;
        if(x>=G){
          break;
        }
      }
    }
    if(x<G){
      continue;
    }
    ans=min(t,ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace ABC178
{
    class Program2
    {
        static void Main()
        {
            var s = int.Parse(Console.ReadLine());
            // max 2000/3個の数列
            // 10 2
            //　全部3削って0*数列の個数 + その他でやる？

            var mod = new Modulo(s);

            long ans = 0;
            for (var i = 1; i <= s / 3; i++)
            {
                var tmp = s - i * 3;
                ans = (ans + mod.DuplicateCombination(i, tmp)) % 1000000007;
            }

            Console.WriteLine(ans);
        }
    }

    public class Modulo
    {
        private readonly int M = 1000000007;
        private readonly int[] m_facs;

        public Modulo(int n, int m = -1)
        {
            m_facs = new int[n + 1];
            m_facs[0] = 1;
            for (int i = 1; i <= n; ++i)
            {
                m_facs[i] = Multiply(m_facs[i - 1], i);
            }
            if (m != -1)
                M = m;
        }

        public int Multiply(int a, int b)
        {
            return (int)(Math.BigMul(a, b) % M);
        }

        public int Factorial(int n)
        {
            return m_facs[n];
        }

        public int Pow(int a, int m)
        {
            switch (m)
            {
                case 0:
                    return 1;
                case 1:
                    return a;
                default:
                    int p1 = Pow(a, m / 2);
                    int p2 = Multiply(p1, p1);
                    return ((m % 2) == 0) ? p2 : Multiply(p2, a);
            }
        }

        public int Divide(int a, int b)
        {
            return Multiply(a, Pow(b, M - 2));
        }

        public int Combination(int n, int r)
        {
            if (n < r) { return 0; }
            if (n == r) { return 1; }
            int res = Factorial(n);
            res = Divide(res, Factorial(r));
            res = Divide(res, Factorial(n - r));
            return res;
        }

        public int DuplicateCombination(int n, int r)
        {
            n = n + r - 1;
            if (n < r) { return 0; }
            if (n == r) { return 1; }
            int res = Factorial(n);
            res = Divide(res, Factorial(r));
            res = Divide(res, Factorial(n - r));
            return res;
        }

        public int Permutation(int n, int r)
        {
            if (n < r) { return 0; }
            if (n == r) { return 1; }
            int res = Factorial(n);
            res = Divide(res, Factorial(n - r));
            return res;
        }
    }
}


Measured memory_bytes: 27500
#include <bits/stdc++.h>
using namespace std;
int n, o[100005];
char s[100005];

int main() {
    scanf("%d%s", &n, s);
    for(int i = 0; i < n; i++) {
        o[i] = (s[i] == 'x');
    }
    for(s[0] = 0; s[0] <= 1; s[0]++) {
        for(s[1] = 0; s[1] <= 1; s[1]++) {
            for(int i = 2; i < n; i++) {
                s[i] = o[i-1]^s[i-1]^s[i-2];
            }
            if((s[0]^s[1]^s[n-1]^o[0]) || (s[n-2]^s[n-1]^s[0]^o[n-1])) {
                continue;
            }
            for(int i = 0; i < n; i++) {
                putchar(s[i] ? 'W': 'S');
            }
            puts("");
            return 0;
        }
    }
    puts("-1");
    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n,n){
        int num[2000]={},co=n;
        for(int i=0;i<n;i++)cin>>num[i];
        for(int i=0;;i++){
            bool kawa=1;
            if(i==10000){
                cout<<-1<<endl;
                break;
            }
            for(int j=0;j<co&&kawa;j++)if(num[j]!=j+1)kawa=0;
            if(kawa){
                cout<<i<<endl;
                break;
            }
            num[co]=co+1;
            for(int j=0;j<=co;j++){
                if(num[j]==1)for(int k=j+1;k<=co&&num[j]==1;k++)if(num[k]!=1)swap(num[j],num[k]);
                num[j]--;
                if(num[j]==0)co=j-1;
            }
            co++;
        }
    }
}

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


N,M,X = map(int,input().split())
table = []
ans = float("inf")


for i in range(N):
    s = list(map(int,input().split()))
    table.append(s)

for i in range(2**N):
    scores = [X]*M
    temp = 0
    for j in range(N):
        if (i>>j) & 1:
#            print(j)
            temp += table[j][0]
            for k in range(M):
                scores[k] -= table[j][k+1]
#    print(i,scores)
    if all(i <=0 for i in scores):
        ans = min(ans,temp)
print(ans if ans!=float("inf") else -1)


Measured memory_bytes: 68856
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int W = scanner.nextInt();
        int H = scanner.nextInt();
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        int r = scanner.nextInt(); 
        if(x-r>=0&&x+r<=W){
            if(y-r>=0&&y+r<=H){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }
        else{
             System.out.println("No");
        }
    }
}

Measured memory_bytes: 26208
module ArrayL = ArrayLabels
module ListL = ListLabels

let dbg = Printf.printf "[debug]%s"

let max_num = 100_000_000_000

let id = fun x -> x
let tuple2 x y = (x,y)
let tuple3 x y z = (x,y,z)
let succ x = x + 1
let pred x = x - 1

let (++) n m =
  let rec aux acc i =
    if i = m then m::acc
    else aux (i::acc) (i+1) in
  if n > m then [] else List.rev @@ aux [] n

let (++^) n m = n ++ (m-1)

let scan fmt f = Scanf.sscanf (read_line ()) fmt f

let scan_list ~sep cnv =
  let line = read_line () in
  Str.split (Str.regexp_string sep) line
  |> List.map cnv

let scan_lines n fmt f =
  List.map (fun _ -> scan fmt f) (0++^n)

let scan_matrix n m e conv =
  let arr = Array.make_matrix n m e in
  Array.iteri (fun i line ->
      let s = Scanf.Scanning.from_string @@ read_line () in
      Array.iteri (fun j _ ->
          arr.(i).(j) <- Scanf.bscanf s " %s" conv;
        ) line) arr; arr

let between n x m = n <= x && x < m

let string_to_list s =
  List.map (String.get s) (0 ++^ String.length s)

let rec powerset = function
  | [] -> [[]]
  | hd::tl ->
    let pws =  powerset tl in
    pws @ ListL.map pws ~f:(fun pw -> hd::pw)

(* let powerset l =
 *   let rec append acc l1 l2 =
 *     match l1, l2 with
 *     | [], [] -> acc
 *     | [], h :: t -> append (h :: acc) [] t
 *     | h :: t, l -> append (h :: acc) t l in
 *   let rec aux acc = function
 *     | [] -> acc
 *     | hd::tl ->
 *       aux (append [] acc @@ ListL.map acc ~f:(fun ac -> hd::ac)) tl in
 *   aux [[]] l *)

let permutations l =
  let rec interleave x = function
    | [] -> [[x]]
    | (hd::tl) as l ->
      (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in
  let rec aux = function
    | [] -> [[]]
    | a::rest ->
      aux rest |> ListL.map ~f:(interleave a) |> List.concat in
  aux l

let n = scan "%d" id
let arr = Array.of_list @@ scan_list ~sep:" " int_of_string
let q = scan "%d" id
let ls = scan_list ~sep:" " int_of_string

exception Found

let () =
  let pwss = powerset (0 ++^ n) in
  let ht = Hashtbl.create @@ List.length pwss in
  ListL.iter pwss ~f:(fun pws ->
      ListL.map pws ~f:(fun i -> arr.(i))
      |> ListL.fold_left ~init:0 ~f:(+)
      |> (fun v-> Hashtbl.add ht v true));
  ListL.iter ls ~f:(fun v ->
      if Hashtbl.mem ht v then Printf.printf "yes\n"
      else  Printf.printf "no\n")



Measured memory_bytes: 128596
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    /*
     2311312312
     120221121
     12201011
     1021110
     121001
     11101
     0011
     010
     11
     0
     
     a b
     a^b b^c
     a^c b^d
     a^b^c^d b^c^d^e
     a^e b^f
     a^b^e^f b^c^f^g
     a^c^e^g b^d^f^h
     a^b^c^d^e^f^g^h b^c^d^e^f^g^h^i
     a^i b^j
     a^b^i^j b^c^j^k
     a^c^i^k b^d^j^l
     a^b^c^d^i^j^k^l b^c^d^e^j^k^l^m
     a^e^i^m b^f^j^n
     a^b^e^f^i^j^m^n b^c^f^g^j^k^n^o
     a^c^e^g^i^k^m^o b^d^f^h^j^l^n^p
     
     1
     11
     101
     1111
     10001
     110011
     1010101
     11111111
     100000001
     1100000011
     10100000101
     111100001111
     1000100010001
     11001100110011
     101010101010101
     1111111111111111
     
     \01
     001
     110
     
     \012
     0012
     1101
     2210
     00:000000
     01:120120
     02:210210
     10:111111
     11:201201
     12:021021
     20:222222
     21:012012
     22:102102
     
     a b c d e f g h i
     ab bc cd de ef fg gh hi
     abbc bccd cdde deef effg fggh ghhi
     ad be cf dg eh fi
     abde bcef cdfg degh dfhi
     abbcdeef bccdeffg cddefggh deefghhi
     addg beeh cffi
     abddeegh bceeffhi
     abbcddeffghhi
     
     a b c d
     |a-b| |b-c| |c-d|
     ||a-b|-|b-c|| ||b-c|-|c-d||
     |||a-b|-|b-c||-||b-c|-|c-d|||
     |a-c|or|a+c| |b-d|or|b+d|
     
     2233231
     010112
     11101
     0011
     010
     11
     0
     */
    int n, z = 0;
    string s;
    cin >> n >> s;
    bool y = 0;
    for (int i = 0; i < n; i++) if (s[i] == '1') y = 1;
    //cin >> n;
    //for (int i = 0; i < n; i++) s += (char)(rand() % 3 + '1');
    //cout << s << '\n';
    string t;
    if (n > 10000) {
        if (!y) {
            //cout << 2;
            //return 1;
        }
        for (int i = 0; i < 100; i++) {
            t.clear();
            for (int j = 1; j < s.length(); j++) t += (char)(abs(s[j] - s[j - 1]) + '0');
            s = t;
        }
        n = (int)s.length();
        //for (int j = 1; j < s.length(); j++) t += (char)(abs(s[j] - s[j - 1]) + '0');
        for (int i = 0; i < n; i++) if ((i | (n - 1)) == n - 1) z = abs(z - (t[i] - '0'));
        cout << z << '\n';
    } else {
        while (s.length() > 1) {
            t.clear();
            for (int j = 1; j < s.length(); j++) t += (char)(abs(s[j] - s[j - 1]) + '0');
            s = t;
        }
        cout << s << '\n';
    }
}


Measured memory_bytes: 3280
#include<bits/stdc++.h>
using namespace std;
const long long maxn=2e5+5;
const long long inf=0x3f3f3f3f;
const long long mod=1e9+7;
long long a[maxn],ans=1,w=1; 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	long long n,k;
	cin>>n>>k;
	long long l=1,r=n;
	for(long long i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	long long ans=1;
	if(k&1)
	{
		ans=a[r--];
		k--;
		w=(ans<0?-1:1); 
	} 
	while(k)
	{
		long long x=a[l]*a[l+1];
		long long y=a[r]*a[r-1];
		if(x*w>y*w)
		{
			ans=ans*(x%mod)%mod;
			l+=2;
		}
		else
		{
			ans=ans*(y%mod)%mod;
			r-=2;
		}
		k-=2;
	}
	cout<<(ans%mod+mod)%mod<<endl;
	return 0;
}




Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vc= vector<char>;
#define REP(i,x,n) for(int i=x; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()

int main(){
  double a1,w,h,x,y,a2=0;
  cin>> w>>h>>x>>y;

  a1= w*h/2.0;
  if(w/2.0==x && h/2.0==y){
    a2= 1;
  }
  cout << a1 << " " << a2 << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  for (int n = 1; n <= N; n++) {
    int ans = 0;
    for (int x = 1; x <= n && x * x <= n; x++) {
      for (int y = 1; y <= n && x * x + y * y <= n; y++) {
        const int c = n - x * x - y * y - x * y;
        for (int z = 1; z <= n; z++) {
          const int tmp = z * z + (y + x) * z;
          if (tmp > c) break;
          if (tmp == c) {
            ans++;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int n;
    cin >> n;
    long long int tmp,result=0;
    REP(i, n){
        cin >> tmp;
        while(tmp%2==0){
            tmp /= 2;
            result++;
        }
    }
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 504
def main():
	N, D = map(int, input().split())
	X = [0]*N
	for i in range(N):
		X[i] = list(map(int, input().split()))
	ans = 0
	for i in range(N):
		for j in range(i+1, N):
			this_len = 0
			for k in range(D):
				cur = X[i][k]-X[j][k]
				this_len += cur*cur
			sqrt = int(this_len**0.5)
			if this_len == sqrt*sqrt:
				ans += 1
	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 3188
/*
17D8101013F 森田　匡博
ID:key4 使用言語:C++
*/

#include <iostream>
#include <cmath>

int main()
{
  int n, q;

  std::cin >> n;
  int S[n];

  for(int i = 0; i < n; i++) {
    std::cin >> S[i];
  }

  std::cin >> q;
  int T[n];

  for(int i = 0; i < q; i++) {
    std::cin >> T[i];
  }

  int c = 0;

  for(int i = 0; i < q; i++) {
    for(int j = 0; j < n; j++) {
      if(T[i] == S[j]) {
	c++;
	break;
      }
    }
  }

  std::cout << c << "\n";

  return 0;

}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
long long num[300005][65], a[300005], n;
long long pom[100], nezz[100], ans, mod=1000000007;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n; nezz[0]=1;
for (int i=1; i<60; i++) nezz[i]=2*nezz[i-1]; 
for (int i=1; i<=n; i++) {
	cin >> a[i];
	for (long long k=0; k<60; k++){
		num[i][k]=num[i-1][k]+(int)((nezz[k]&a[i])?1:0);
	} 
} pom[0]=1;
for (int i=1; i<60; i++){
	pom[i]=2*pom[i-1]; pom[i]%=mod;
}

for (int i=1; i<=n; i++){
	for (long long k=0; k<60; k++){
		if (nezz[k]&a[i]){
			ans+=(n-i-num[n][k]+num[i][k])*pom[k];
			ans%=mod;
		}
		else {
			ans+=(num[n][k]-num[i][k])*pom[k];
			ans%=mod;
		}
	}
} cout << ans;
return 0;
}


Measured memory_bytes: 155008
N,K = map(int,input().split())
cnt = []
for p in range(1,min(N,K)+1):
    count = 0
    while p < K:
        p *= 2
        count += 1
    cnt.append(count)
    count = 0
sumans = 0

for i in range(len(cnt)):
    sumans += (1/2)**cnt[i]

print((1/N) * sumans if N < K else (N-K)/N + (1/N)*sumans)

Measured memory_bytes: 3060
#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;
int main()
{
    ll A[3][3],N,b[10];
    REP(i,3){
        REP(j,3){
            cin >> A[i][j];
        }
    }
    cin >> N;
    REP(i,N)
    {
        cin >> b[i];
    }
    int x=0;
    REP(i,3){
        REP(j,3){
                REP(k,10){
                    if(A[j][i]==b[k]){
                        x++;
                        break;
                    }
                }
            if(x==3){
                cout << "Yes" << endl;
                return 0;
            }
        }
    x=0;
    }
    REP(i,3){
        REP(j,3){
                REP(k,10){
                    if(A[i][j]==b[k]){
                        x++;
                        break;
                    }
                }
            if(x==3){
                cout << "Yes" << endl;
                return 0;
            }
        }
    x=0;
    }
    REP(j,3){
       REP(k,10){
            if(A[j][j]==b[k]){
                x++;
                break;
            }
        }
        if(x==3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    x=0;
    REP(j,3){
       REP(k,10){
            if(A[j][2-j]==b[k]){
                x++;
                break;
            }
        }
        if(x==3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;    
}

Measured memory_bytes: 256
A,B,C,D = map(int,input().split())

if C % B != 0:
    ans_A =  ((C // B) + 1)
else:
    ans_A = C // B

if A % D != 0:
    ans_C =  A // D + 1
else:
    ans_C = A // D


if ans_A <= ans_C:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9184
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=100050;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	char S[100],T[100]="CODEFESTIVAL2016";
	cin>>S;
	int ans=0;
	for(int i=0;i<strlen(T);i++){
		if(S[i]!=T[i])
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;

int main() {
    long ans = 0;
    long n, k;
    cin >> n >> k;
    
    if (k == 0) {
        cout << n * n << endl;
        return 0;
    }
    
    for (long b = k + 1; b <= n; b++) {
        long c = b - k;
        long m = (n + 1) / b;
        ans += c * m;
        if (k + b * m <= n) {
            ans += n - (k + b * m) + 1;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long;
using ll = long long;
#define rep(i,n) for(lint (i) = 0;(i) < (lint)(n);(i)++)
#define repInRange(i,start,end) for(lint (i) = (start);(i) < (end);++(i))
using lpair = pair<lint,lint>;
using vl = vector<lint>;
using vll = vector<long long>;
using Llist = list<lint>;
using vs = vector<string>;
#define all(v) (v).begin(),(v).end()
#define out1(x) (cout << (x) << '\n');

ll pow(ll k,ll l) {
	ll ret = 1;
	rep(i,l) {
		ret *= k;
	}
	return ret;
}

template <typename T>
T sum(vector<T> vec) {
	ll ret = 0;
	rep(i,vec.size()) {
		ret += vec.at(i);
	}
	return ret;
}

void Main() {
	ll n;
	cin >> n;
	map<string,ll> m;
	vs s;
	rep(i,n) {
		string x;
		cin >> x;
		if (m.count(x)) {
			m[x]++;
		} else {
			m[x] = 1;
			s.push_back(x);
		}
	}
	ll max = m[s[0]],count = 0;
	rep(i,m.size()) {
		if (max < m[s[i]])
			max = m[s[i]];
	}
	rep(i,m.size()) {
		if (max == m[s[i]])
			count++;
	}
	vs ans;
	rep(i,m.size()) {
		if (max == m[s[i]])
			ans.push_back(s[i]);
	}
	sort(all(ans));
	rep(i,count) {
		out1(ans[i]);
	}
}

signed main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	Main();
	return 0;
}


Measured memory_bytes: 27120
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MP make_pair
#define pb push_back
#define PI 3.1415926535897932384626433832795
typedef long long ll;
#define MOD 1000000007
ll gcd(ll a,ll b){if (b == 0)return a;return gcd(b, a % b);} 
#define cases int t;cin>>t;while(t--) 
int main(){
    int k;
    cin>>k;

    ll sum = 0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int l=1;l<=k;l++){
                sum += __gcd( __gcd(i,j) , l);
            }
        }
    }
    cout<<sum<<endl;

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC159D()
{
	int N;
	cin >> N;
	vi A(N);
	for (auto& x : A)
		cin >> x;
	map<int, int> M;
	for (auto& x : A)
	{
		++M[x];
	}
	map<int, int> P;
	for (auto& x : M)
	{
		++P[x.second];
	}
	ll ct = 0;
	for (auto& x : P)
	{
		ll c = x.first;
		int d = x.second;
		if (c > 1)
		{
			ll a = c* (c - 1) / 2;
			ct += a * d;
		}
	}
	for (int i = 0; i < N; ++i)
	{
		int b = A[i];
		ll c = M.find(b)->second; // ct
		int d1 = P.find(c)->second;
		ll ct1 = ct;
		if (c > 1)
		{
			ct1 -= c * (c-1) / 2;
		}
		if (c > 2)
		{
			ct1 += (c - 1) * (c - 2) / 2;
		}
		cout << ct1 << endl;
	}
}


int main()
{
	ABC159D();
	return 0;
}

Measured memory_bytes: 8320
s = $stdin.readline.to_i

p1 = [0, 0]
p2 = [10 ** 9, 1]
p3 = Array.new(2)
p3[0] = (- s) % p2[0]
p3[1] = (s + p3[0]) / p2[0]

puts [p1, p2, p3].flatten.join(" ")

Measured memory_bytes: 14320
#include <stdio.h>

int main(void)
{
	int a, b;
	int s, t;
	int i;
	
	s = t = 0;
	for (i = 0; i < 4; i++) {
		scanf("%d", &a);
		s += a;
	}
	for (i = 0; i < 4; i++) {
		scanf("%d", &b);
		t += b;
	}
	
	printf("%d\n", (s > t) ? s : t );
	
	return (0);
}

Measured memory_bytes: 592
//If you are trying to hack me I wish you can get it, Good Luck :D.
#include <bits/stdc++.h>
using namespace std;

#define debug(args...) fprintf (stderr,args)
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const ll  MOD = 1000000007;

ll n, k, sum[MAX];
pll op[MAX];



int main() {
   scanf("%lld%lld", &n, &k);
   for (int i = 0; i < n; i++) {
      ll a, b;
      scanf("%lld%lld", &a, &b);
      op[i] = pii(a, b);
   }
   sort(op, op + n);
   for (int i = 0; i < n; i++) {
      sum[i] = op[i].second;
      if (i > 0) sum[i] += sum[i - 1];      
   }

   ll l = 0, r = n - 1;

   while (l < r) {
      ll mid = (l + r) / 2;
      //debug("--> mid = %lld and sum[mid] = %lld\n", mid, sum[mid]);
      if (sum[mid] < k) l = mid + 1;
      else r = mid;
   }

   printf("%lld\n", op[l].first);

   return 0;
}


Measured memory_bytes: 2560