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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1LL<<61)

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

typedef int Cost;
struct Edge {
  int src, dst; Cost cost;
  Edge(int s, int d, Cost c) : src(s), dst(d), cost(c) {}
};
typedef vector<Edge>  Edges;
typedef vector<Edges> Graph;
typedef vector<Cost>  Array;
typedef vector<Array> Matrix;

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

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int X; cin >> X;
  for (int i = 0; i <= 100000; i++) {
    if (i*(i+1)/2 < X)
      continue;
    cout << i << endl;
    break;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    
    int ans = 1;
    for (int i = 0; i < N; i++) {
      ans = Math.min(ans+K, ans*2);
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 22100
#include<iostream>
using namespace std;
int main() {
	int n, b,mark,num;
	char a,c;
	cin >> n;
	int x[4][13];
	for (mark = 0; mark < 4; mark++) {
		for (num = 0; num < 13; num++) {
			x[mark][num] = 0;
		}
	}
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		if (a == 'S') {
			mark = 0;
		}
		else if (a == 'H') {
			mark = 1;
		}
		else if (a == 'C') {
			mark = 2;
		}
		else if (a == 'D') {
			mark = 3;
		}
		num = b - 1;
		x[mark][num] = 1;
	}
	for (mark = 0; mark < 4; mark++) {
		for (num = 0; num < 13; num++) {
			if (mark == 0) {
				c = 'S';
			}
			else if (mark == 1) {
				c = 'H';
			}
			else if (mark == 2) {
				c = 'C';
			}
			else if (mark == 3) {
				c = 'D';
			}
			if (x[mark][num] == 0) {
				cout << c << " " << num + 1 << endl;
			}
		}
	}
}



Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

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

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int X; std::cin >> X;
  std::cout << 8 - (X-400)/200 << std::endl;
  return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
#define pb push_back
#define mp make_pair
#define INF (ll)(1e18)
#define inf 0x7fffffff
#define inff 100000
#define ff first
#define ss second
#define sz(x) ((int) (x).size())
#define fast cin.sync_with_stdio(0);cin.tie(0)
#define rep(i,N) for(int i = 0;i < N;i++)
#define frep(i,a,b) for(int i = a;i <= b;i++)
#define pii pair<int , int>
#define pll pair<ll , ll>
#define vii vector<int>
#define vpii vector< pii >
#define fill(A,v) memset(A,v,sizeof(A))
#define setbits(x) __builtin_popcountll(x)
#define print(A,j,k) for(int ii=j;ii<k;ii++)cout<<A[ii]<<" ";cout<<"\n"
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
#define SQRT 350
#define CASES int t;cin>>t;while(t--)
#define FILE freopen("inp.txt" , "r" , stdin);
#define ld long double
 
const int MOD = 1e9 + 7;
const int N = 1e6 + 5;
 
ll A[N];
 
int main(int argc, char const *argv[])
{
    fast;
 
    int n;
    cin >> n;
 
    rep(i , n) 
        cin >> A[i + 1];
   
    ll ans = 0;
    frep(i , 1 , n) {
    	if(A[i - 1] && A[i]) {
            A[i]--;
            A[i - 1]--;
            ans++;
        }
        ans += A[i] / 2;
        A[i] %= 2;
    }
    cout << ans << '\n';
 
    return 0;
}


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

#define MIN(X,Y) ((X)<(Y)?(X):(Y))
#define MAXLEN 1000
int main(void){
  string s,t;
  int dp[MAXLEN+1][MAXLEN+1];
  
  cin >> s >> t;
  // init
  dp[0][0] = 0;
  for (int i=1; i<=s.size(); i++) dp[i][0] = i;
  for (int j=1; j<=t.size(); j++) dp[0][j] = j;
  // DP
  for (int i=1; i<=s.size(); i++){
    for (int j=1; j<=t.size(); j++){
      int flg = s[i-1]==t[j-1]?0:1;
      dp[i][j] = MIN(dp[i-1][j-1]+flg, MIN(dp[i][j-1]+1, dp[i-1][j]+1));
    }
  }
  /*
  for (int i=0; i<=s.size(); i++){
    cout << dp[i][0];
    for (int j=1; j<=t.size(); j++){
      cout << " " << dp[i][j];
    }cout << endl;
  }*/
  cout << dp[s.size()][t.size()] << endl;
  return 0;
}


Measured memory_bytes: 7156
from collections import defaultdict, deque

def main():
    N = int(input())
    S = input()
    ans = 0
    for i in range(1000):
        password = str(i).zfill(3)
        j = 0
        for s in S:
            if s == password[j]:
                j += 1
            if j == 3:
                ans += 1
                break

    print(ans)


if __name__ == "__main__":
    main()

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

using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define FASTIO cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit); cout.tie(0);

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define DEBUG 1
#define ddcout if (DEBUG) cout
#define ddprintf(fmt, ...) if (DEBUG) printf (fmt, __VA_ARGS__)
const int maxn = 1e5+9;
string game;
int n, k, r, s, p, dp[maxn][5];
//0 -> rock, 1 -> paper, 2->scissors
int solve(int i, int choose){
    if (i >= n) return 0;
    if (dp[i][choose] != -1) return dp[i][choose];
    if (game[i] == 'r' and choose != 1) return dp[i][choose] = p + solve(i+ k, 1);
    if (game[i] == 'p' and choose != 2) return dp[i][choose] = s + solve(i+ k, 2);
    if (game[i] == 's' and choose != 0) return dp[i][choose] = r + solve(i+ k, 0);
    if (game[i] == 'r') return dp[i][choose] = max(solve(i + k, 0), solve(i + k, 2));
    if (game[i] == 'p') return dp[i][choose] = max(solve(i + k, 0), solve(i + k, 1));
    if (game[i] == 's') return dp[i][choose] = max(solve(i + k, 1), solve(i + k, 2));
}

int main() {
    FASTIO;
    cin >> n >> k;
    cin >> r >> s >> p;
    cin >> game;
    memset(dp, -1, sizeof dp);
    ll ans = 0;
    rep(i, 0, k){
        ans += solve(i, 3);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 7120
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>
#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF 1e9;
#define INFL 1e18;
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

class BRollerCoaster {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll N, K;
        in >> N >> K;
        int count = 0;
        REP(i, N) {
            int h;
            in >> h;
            if (h >= K) count++;
        }
        out << count << '\n';
	}
};


int main() {
	BRollerCoaster solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node { int p, l, r; };
struct Node T[MAX];
int n;

void preParse(int u){
    if (u == NIL ) return;
    printf(" %d", u);
    preParse(T[u].l);
    preParse(T[u].r);
}

void inParse(int u){
    if ( u == NIL ) return;
    inParse(T[u].l);
    printf(" %d", u);
    inParse(T[u].r);
}

void postParse(int u){
    if ( u == NIL ) return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d", u);
}

int main() {
    int i, v, l, r, root;

    scanf("%d", &n);
    for ( i = 0; i < n; i++ ) {
        T[i].p = NIL;
    }

    for ( i = 0; i < n; i++){
        scanf("%d %d %d", &v, &l, &r);
        T[v].l = l;
        T[v].r = r;
        if ( l != NIL ) T[l].p = v;
        if ( r != NIL ) T[r].p = v;
    }

    for ( i = 0; i < n; i++ )if ( T[i].p == NIL )root = i;

    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");


  return 0;
}


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

int main(){
    string S;
    cin >> S;
    string T;
    cin >> T;

    int count=0;

    for(int i=0;i<S.size();i++){
        if(T.at(i)==S.at(i)){
            count++;
        }
    }

    if(count==S.size()){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 3632
import itertools
n, m = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(m)]
pm = list(map(int, input().split()))
bit = itertools.product([0, 1], repeat=n)
ans = 0
for b in bit:
    flag = True
    for i in range(m):
        on = 0
        for s in ks[i][1:]:
            if b[s-1] == 1:
                on += 1
        if on % 2 != pm[i]:
            flag = False
            break
    if flag:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; ++i)

int main() {

	int n, m, p;
	string s;
	cin >> n >> m;

	vector<bool> ac(n + 1);
	vector<int> wa(n + 1);
	int a = 0, b = 0;
	REP(i, m) {
		cin >> p >> s;
		if (s == "AC") {
			if (!ac[p]) {
				++a;
				b += wa[p];
			}
			ac[p] = true;
		}
		else {
			if (!ac[p]) wa[p]++;
		}
	}
	cout << a << " " << b;
	return 0;
}


Measured memory_bytes: 3792
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
sys.setrecursionlimit(int(1e+6))
MOD = int(1e+9) + 7
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3

def main():
    S = i2s()
    nn09 = [i for i in range(10)]
    #rot = [(i*10)%13 for i in range(10)]    # [0, 10, 7, 4, 1, 11, 8, 5, 2, 12]
    DP = [0] * 13
    # 初期化
    if S[-1] == '?':
        for i in nn09:
            DP[i] = 1
    else:
        DP[int(S[-1])] = 1
    d = 10
    for i in range(len(S)-2, -1, -1):
        dp2 = [0] * 13
        s = S[i]
        if s == '?':
            nn = nn09
        else:
            nn = [int(s)]
        for n in nn:
            for j in range(13):
                k = (d*n+j) % 13
                dp2[k] = (dp2[k] + DP[j]) % MOD
        DP = dp2
        d = (d*10) % 13

    #print(DP)
    print(DP[5])

main()


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


Measured memory_bytes: 2104
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello{
    public static void Main(){
        var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = input[0];
        var M = input[1];
        var X = input[2];
        var Y = input[3];
        var x = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
        var y = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
    
        
        for(var i = X + 1;i <= Y;i++){
            if(x.Max() < i && i <= y.Min()){
                Console.WriteLine("No War");
                return;
            }
        }
        Console.WriteLine("War");
        
    }
}


Measured memory_bytes: 13396
#include <iostream>
using namespace std;
int K[100][100];

int main() {
    int n, u, k, v;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> u >> k;
        for(int j = 0; j < k; j++) {
            cin >> v;
            K[u-1][v-1] = 1;
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(j != 0) cout << " ";
            cout << K[i][j];
        }
        cout << endl;
    }
    return 0;
}


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

N=int(input())
A=map(int,input().split())
Q=int(input())
numbers=[]
for _ in range(Q):
    B,C=map(int,input().split())
    numbers.append([B,C])
answers=[0 for _ in range(100001)]
for a in A:
    answers[a]+=a
whole=sum(answers)
for number in numbers:
    suuji=answers[number[0]]//number[0]
    answers[number[0]]=0
    answers[number[1]]+=suuji*number[1]
    whole+=(number[1]-number[0])*suuji
    print(whole)
    

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

int main(){
	int n;
	cin>>n;
	vector<double>x;
	for(int i=0;i<n;i++){
		double x1;
		cin>>x1;
		x.push_back(x1);
	}
	while(x.size()>1){
		sort(x.begin(),x.end());
		x.push_back((x[0]+x[1])/2);
		x.erase(x.begin());
		x.erase(x.begin());
	}
	cout<<x[0]<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    int n, a[100000], b[100000];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[a[i]-1] = i+1;
    }
    for (int i = 0; i < n; i++) {
        cout << b[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	int a,b,s=1;
	cin>>a>>b;
	for(int i=0;i<a;i++){
		if(s<b){
			s*=2;
		}else{
			s+=b;
		}
	}
        cout<<s;
	return 0;
}

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

int main()
{
    int n,m,s,v,flag =0;
    map<int,int> vis;
    vis[1] =-1,vis[2] =-1,vis[3] =-1;
    cin>>n>>m;
    while(m--)
    {
        cin>>s>>v;
        if(vis[s]==-1)
        {
            vis[s] =v;
        }
        else if(vis[s]!=v)
        {
            flag =1;
        }
    }
    if(n==1&&(vis[1]==-1||vis[1]==0))
    {
        cout<<0<<endl;
        return 0;
    }
    if(vis[1]==0&&n!=1)
        flag =1;
    if(flag)
        cout<<-1<<endl;
    else {
        for(int i=1;i<=n;i++){
            if(vis[i]!=-1)
                cout<<vis[i];
            else if(i==1)
                cout<<1;
            else
                cout<<0;
        }
        cout<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
#define   Y            imag()
#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
//#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
//#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
//#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(double a,double b){   return fabs(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
ll setBit1(ll num, int idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(int num, int idx) {return num ^ (1<<idx);}
void FS(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
int c[10][10],b[10],a[10];
int main()
{
    for(int i=1;i<=3;i++)
    {
        for(int j=1;j<=3;j++)
            cin>>c[i][j];
    }

    for(int i=0;i<=100;i++)
    {
        for(int j=0;j<=100;j++)
        {
            for(int k=0;k<=100;k++)
            {

                b[1]=(c[1][1]-i);
                b[2]=(c[1][2]-i);
                b[3]=(c[1][3]-i);
                a[1]=i;
                a[2]=j;
                a[3]=k;
                bool ok=1;
                for(int l=1;l<=3;l++)
                {
                    for(int r=1;r<=3;r++)
                    {
                        if(c[l][r]!=a[l]+b[r])
                        {
                            ok=0;
                        }
                    }
                }
                if(ok==1)
                {
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec A(N); cin >> A;
    bool f = true;

    REP(i, N) if(A[i] % 2 == 0 && A[i] % 3 != 0 && A[i] % 5 != 0) f = false;
    Ans(f, "APPROVED", "DENIED");

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
    char G[100], H[100];
    int A=0;
    scanf("%s", G);
    int len=strlen(G);
    for(int i=0;i<len;i++)
    {
        if(G[i]=='B')
        {
            A--;
            if(A<0)
                A=0;
        }
        else
            H[A++]=G[i];
    }
    H[A]='\0';
    printf("%s\n", H);
    return 0;
}


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

#define int long long
#define pb push_back
#define in insert
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
#define all(x)  x.begin(),x.end()
#define w(x) int x;cin>>x; while(x-->0)
#define memset(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
}
/*
think fast
think simple
*/

void mysol()
{
    int n; cin >> n;
    int arr[n];
    int ans = 0;
    for (int &a : arr)
        cin >> a;
    for (int i = 1; i < n; i++)
    {
        if (arr[i] < arr[i - 1])
            ans += arr[i - 1] - arr[i], arr[i] = arr[i - 1];
    }
    cout << ans << endl;
}

int32_t main()
{
    fast();
    // w(t)
    {
        mysol();
    }
    //cerr << sizeof(dp)*(1e-6) << " megabytes\n";
    return 0;
}


Measured memory_bytes: 5232
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+15+7;
ll n,m,l;
string s,t;
ll d[100],dp[100][100];

int main(){
  cin >> s;
  rep(i,0,s.sz){
    d[s[i]-'a']++;
  }
  bool f = false;
  rep(i,0,26){
    if(d[i] > 1)f = true;
  }
  if(f)puts("no");
  else puts("yes");
  return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        StringBuilder sb = new StringBuilder();
        char[] charArr;
        char c;
        int count;
        while ((str = br.readLine()) != null) {
            try {
                sb.append(str.toCharArray());
            } catch (Exception e) {
                break;
            }
            
        }
        charArr = sb.toString().toCharArray();
        for (c = 'a'; c <= 'z'; c++) {
            count = 0;
            for (char x : charArr) {
                if (x == c || x == Character.toUpperCase(c)) {
                    count++;
                }
            }
            System.out.println(c + " : " + count);
        }
    }
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N;
  cin >> N;
  vector<string> s(N);
  REP(i, N)
  cin >> s[i];
  ll ans = 0;
  REP(i, N)
  {
    int pos = 0;
    while (pos < s[i].size())
    {
      if (0 <= pos && pos < s[i].size() - 1 && s[i][pos] == 'A' && s[i][pos + 1] == 'B')
      {
        ans++;
        pos++;
        pos++;
        continue;
      }
      pos++;
    }
  }
  int lastA = 0;
  int firstB = 0;
  int BA = 0;
  REP(i, N)
  {
    if (s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A')
      BA++;
    else if (s[i][0] == 'B')
      firstB++;
    else if (s[i][s[i].size() - 1] == 'A')
      lastA++;
  }
  if (firstB == 0 && lastA == 0 && BA == 0)
    cout << ans << endl;
  else if (firstB == 0 && lastA != 0 && BA != 0)
    cout << ans + BA << endl;
  else if (firstB != 0 && lastA == 0 && BA != 0)
    cout << ans + BA << endl;
  else if (firstB == 0 && lastA == 0 && BA != 0)
    cout << ans + (BA - 1) << endl;
  else if (firstB != 0 && lastA != 0 && BA != 0)
    cout << ans + BA + min(firstB, lastA) << endl;
  else if (firstB != 0 && lastA != 0 && BA == 0)
    cout << ans + min(firstB, lastA) << endl;
  else if (firstB == 0 && lastA != 0 && BA == 0)
    cout << ans << endl;
  else if (firstB != 0 && lastA == 0 && BA == 0)
    cout << ans << endl;
  return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;
char m[1005][1005];
int c[1005][1005];
int main(){
    int h,w; cin >> h >> w;
    rep(i,h) cin >> m[i];
    rep(i,1005) rep(j,1005) c[i][j] = 1000000000;
    queue<pair<int,int>> q;
    rep(i,h) rep(j,w){
        if(m[i][j] == '#'){
            c[i][j] = 0;
            q.push(mp(i,j));
        }
    }
    int ans = 0;
    while(!q.empty()){
        int i = q.front().first, j = q.front().second;
        int p = c[i][j];
        q.pop();
        if(i!=0 && c[i-1][j] > p+1){c[i-1][j] = p+1; q.push(mp(i-1,j));}
        if(i!=h-1 && c[i+1][j] > p+1){c[i+1][j] = p+1; q.push(mp(i+1,j));}
        if(j!=0 && c[i][j-1] > p+1){c[i][j-1] = p+1; q.push(mp(i,j-1));}
        if(i!=0 && c[i][j+1] > p+1){c[i][j+1] = p+1; q.push(mp(i,j+1));}
    }
    //rep(i,h){ rep(j,w) cout << c[i][j] <<" "; cout << endl;}
    rep(i,h) rep(j,w) ans = max(ans, c[i][j]);
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13328
#include <iostream>
#include <string>
using namespace std;
#define print(var) cout << var
int rev(int num) {
  string tmp;
  int size = to_string(num).length();
  for (int i = 0; i < size; i++) {
    tmp[i] = to_string(num)[size - i - 1];
  }
  int n = stoi(tmp);
  return n;
}
int main() {
  int A, B, count = 0;
  cin >> A >> B;
  for (int i = A; i <= B; i++) {
    if (i == rev(i))
      count++;
  }
  print(count);
}

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

using namespace std;

typedef long long ll;

struct para
{
    ll w, v;
};

bool porownanie(para a, para b)
{
    if (a.w < b.w)
        return true;
    return false;
}

int main()
{
    ios_base::sync_with_stdio(0);
    ll n, w;
    cin >> n >> w;
    vector<para> p(n);
    for (int i = 0; i < n; ++i)
        cin >> p[i].w >> p[i].v;
    sort(p.begin(), p.end(), porownanie);
    vector<ll> a, b, c, d;
    for (int i = 0; i < n; ++i)
    {
        if (p[i].w == p[0].w)
            a.push_back(p[i].v);
        if (p[i].w == p[0].w + 1)
            b.push_back(p[i].v);
        if (p[i].w == p[0].w + 2)
            c.push_back(p[i].v);
        if (p[i].w == p[0].w + 3)
            d.push_back(p[i].v);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    sort(d.begin(), d.end());
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    reverse(c.begin(), c.end());
    reverse(d.begin(), d.end());
    for (int i = 1; i < a.size(); ++i)
        a[i] += a[i - 1];
    for (int i = 1; i < b.size(); ++i)
        b[i] += b[i - 1];
    for (int i = 1; i < c.size(); ++i)
        c[i] += c[i - 1];
    for (int i = 1; i < d.size(); ++i)
        d[i] += d[i - 1];
    ll odp = 0;
    for (int i = 0; i <= a.size(); ++i)
    {
        for (int j = 0; j <= b.size(); ++j)
        {
            for (int k = 0; k <= c.size(); ++k)
            {
                ll wag = i * p[0].w + j * (p[0].w + 1) + k * (p[0].w + 2);
                if (wag > w)
                    continue;
                ll l = (w - wag) / (p[0].w + 3);
                if ((int) d.size() < l)
                    l = d.size();
                ll s = 0;
                if (i != 0)
                    s += a[i - 1];
                if (j != 0)
                    s += b[j - 1];
                if (k != 0)
                    s += c[k - 1];
                if (l != 0)
                    s += d[l - 1];
                if (s > odp)
                odp = s;
            }
        }
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll INF = 1LL << 40;
int N, M;
int a[2010], b[2010], c[2010];
ll dis[1010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--; b[i]--;
    c[i] *= -1;
  }
  fill_n((ll*)dis, N, INF);
  dis[0] = 0;
  for (int t = 0; t < N; t++) {
    for (int i = 0; i < M; i++) {
      if (dis[a[i]] == INF) continue;
      if (dis[b[i]] > dis[a[i]] + c[i]) {
        dis[b[i]] = dis[a[i]] + c[i];
        if (t == N - 1 && b[i] == N - 1) {
          cout << "inf" << endl;
          return 0;
        }
      }
    }
  }
  cout << -dis[N - 1] << endl;

  return 0;
}

Measured memory_bytes: 256
/*
[agc024] B - Backfront
*/

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 200000;

int N;
int p[MAX_N];
int pos[MAX_N];

int solve() {
    for (int i = 0; i < N; i++) {
        pos[p[i]] = i;
    }

    int ans = N;
    int cnt = 1;
    for (int i = 1; i < N; i++) {
        if (pos[i] > pos[i - 1]) {
            cnt++;
        } else {
            ans = min(ans, N - cnt);
            cnt = 1;
        }
    }
    ans = min(ans, N - cnt);
    return ans;
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> p[i];
        p[i]--;
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b, c, n;
string s;

int ketanowa(int x)
{
	if (x < 10)
		return x;
	else
		return x % 10 + ketanowa(x / 10);
}

int main()
{
	cin >> n;
	if (n % ketanowa(n) == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        x: usize
    }

    let mut kyu = 0;

    if x >= 400 && x <= 599 {
        kyu = 8;
    } else if x >= 600 && x <= 799 {
        kyu = 7;
    } else if x >= 800 && x <= 999 {
        kyu = 6;
    } else if x >= 1000 && x <= 1199 {
        kyu = 5;
    } else if x >= 1200 && x <= 1399 {
        kyu = 4;
    } else if x >= 1400 && x <= 1599 {
        kyu = 3;
    } else if x >= 1600 && x <= 1799 {
        kyu = 2;
    } else {
        kyu = 1;
    }

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

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


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

int main() {
    string S;
    cin >> S;
    long long blackCnt = 0;
    long long indexCnt = 0;
    for (long long i = 0; i < S.size(); i++) {
        if (S[i] == 'B') {
            indexCnt += i;
            blackCnt++;
        }
    }

    long long finalIndexCnt = 0;
    long long tmpCnt = 0;
    for (long long i = S.size() - 1; i >= 0 && tmpCnt < blackCnt; i--, tmpCnt++) {
        finalIndexCnt += i;
    }

    cout << finalIndexCnt - indexCnt << endl;

    return 0;
}


Measured memory_bytes: 640
import itertools
from math import sqrt
def main():
    def helper():
        pass
    def dist(p1, p2):
        dX, dY = p1[0]-p2[0], p1[1]-p2[1]
        return sqrt(dX*dX+dY*dY)

    N = int(input())
    P = []
    for _ in range(N):
        x, y = map(int, input().split())
        P.append((x, y))
    
    D = []
    ct = 0
    for p_list in itertools.permutations(P, N):
        ct += 1
        d = 0
        for i in range(len(p_list)-1):
            d += dist(p_list[i], p_list[i+1])
        D.append(d)
    print(sum(D)/ct)

main()

Measured memory_bytes: 4400
/**
 *      author  : kyomukyomupurin
 *      created : 2018/08/19
**/

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

int main(){
    int N, K;
    cin >> N >> K;
    
    if (N % K == 0){
        cout << 0;
    }
    else {
        cout << 1;
    }

    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	if N%2 == 1 {
		fmt.Println(0)
		return
	}
	N /= 2
	// N!の中に5が何個あるか数える
	p := 5
	ans := 0
	for N >= p {
		ans += N / p
		p *= 5
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#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>
using namespace std;
#define INF 0x3f3f3f3f
//#define INF 1100000000000000000LL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	char S[10];
	cin>>S;
	for(int i=1;i<strlen(S);i++){
		if(S[i-1]=='A' && S[i]=='C'){
			cout<<"Yes"<<endl;
			return 0;
		}

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

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

#define ENGZ ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);
#define sfi(x) scanf("%d" , &x)
#define sfi2(x, y) scanf("%d%d" , &x,&y)
#define sfl2(x, y) scanf("%I64d%I64d" , &x,&y)
#define sfl(x) scanf("%I64d" , &x)
#define sfl3(x, y, z) scanf("%I64d%I64d%I64d", &x, &y, &z)
#define sfd(x) scanf("%lf", &x)
#define sfd2(x, y) scanf("%lf", &x, &y)
#define sfs(x) scanf("%s", &x)
#define testv(x) cerr << x << ' '
#define wtf(s) freopen((s), "w", stdout)
#define rff(s) freopen((s), "r", stdin)
#define test cerr << "here"
#define fst(x) cout << fixed << setprecision(x)
#define mod 1000000007
#define pi (2 * acos(0))
typedef long double ld;
typedef long long ll;

ll n, m, dp[1003][1003];
char a[1003][1003];

int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> a[i][j];
    dp[1][1] = 1;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
        {
            if (i == 1 && j == 1)
                continue;
            if (a[i][j] == '#')
                dp[i][j] = 0;
            else
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1], dp[i][j] %= mod;
        }
    cout << dp[n][m];
    return 0;
}

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

int main() {
  int n,d;
  cin>>n>>d;
  vector<vector<int>> a(n,vector<int>(d));
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++){
      cin>>a.at(i).at(j);
    }
  }
  int p=0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      int q=0;
      for(int k=0;k<d;k++){
        q+=(a.at(i).at(k)-a.at(j).at(k))*(a.at(i).at(k)-a.at(j).at(k));
      }
      if(sqrt(q)==(int)sqrt(q)){
        p++;
      }
    }
  }
  cout<<p<<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

N, Q = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
P = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    P[p-1] += x
ans = [-1] * N
#print(G)
#print(P)

def dfs(v, p):
    ans[v] = P[v] + p
    for vi in G[v]:
        if ans[vi] != -1:
            continue
        dfs(vi, ans[v])
dfs(0, 0)

print(' '.join(map(str, ans)))


Measured memory_bytes: 237724
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception{
        
        Scanner sc = new Scanner(System.in);
        int tests;
        int n;
        int m;
      int l;
      double sum=0;
         n = sc.nextInt();
      m = sc.nextInt();
        int[] A = new int[n];
       
       
      for(int i=0;i<n;i++){
        A[i]= sc.nextInt();
         sum = sum+A[i];
      }
      int count=0;
      int reqd = (int)Math.ceil(sum/(4*m));
      for(int i=0;i<n;i++){
       if(A[i] >= reqd){
         count++;
       }
        
      }
          if(count>=m){
            System.out.println("Yes");
          }
          else{
             System.out.println("No");
          }
       
       
        
  }
}
        


Measured memory_bytes: 22996
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <iostream>

using namespace std;
const int MAX = 100000;
string s;

int main() {
  ios::sync_with_stdio(false);
  cin >> s;
  string t = "CODEFESTIVAL2016";
  int cnt = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] != t[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.Array.IO
import Data.Array.Unboxed

type Idx = (Int,Int)
type IODp = IOUArray Idx Int

main = do
    [n,a] <- map read.words<$>getLine::IO[Int]
    ys <- map (flip(-)a.read).words<$>getLine::IO[Int]
    let nx = n * maximum (a:ys)
    dp <- newArray ((0,-nx),(n,nx)) 0 :: IO IODp
    mapM_ (f dp nx) [(j,t)|j<-zip [0..] (0:ys), t<-[-nx..nx]]
    print.flip(-)1 =<< readArray dp (n,0)

f dp _ ((0,_),0) = writeArray dp (0,0) 1
f dp nx ((j,yj),t) | j>0, -nx<=t-yj, t-yj<=nx = liftM2 (+) (readArray dp (j-1,t)) (readArray dp (j-1,t-yj)) >>= writeArray dp (j,t)
f dp _ ((j,yj),t) | j>0 = readArray dp (j-1,t) >>= writeArray dp (j,t)
f _ _ _ = return ()

{-
dp(j,t) -> [y1..yj]から合計をtにするような選び方の総数, -nx<=t<=nx

dp(0,0) = 1
dp(j,t) = dp(j-1,t) + dp(j-1,t-yj) , j>=1, -nx <= t-yj <= nx
dp(j,t) = dp(j-1,t)                , j>=1
other = 0
-}

Measured memory_bytes: 2940
import qualified Data.ByteString.Char8 as B
import qualified Data.Set as S
import qualified Data.Vector.Unboxed as VU
import Data.Maybe (fromJust)
import Data.List (sort, group, sortBy)
import Data.Ord (comparing)

getInts :: IO [Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

main = do
  [n,k] <- getInts
  an <- getInts
  let groupBalls = sortBy (comparing snd) $ map (\x -> (head x,length x)) . group $ sort an
  print $ let kind = length groupBalls in if kind > k then sum . map snd $ take (kind-k) groupBalls else 0

Measured memory_bytes: 64892
program bounding

  implicit none
  integer::n,x,ans,d,i
  integer,allocatable::L(:)
  
  read*,n,x
  allocate(L(n))

  read*,L

  d=0
  ans=1
  do i=2,n+1
    d=d+L(i-1)
    if(d<=x) ans=ans+1
    if(d>x) exit
  end do

  print*,ans

end program bounding

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    ll n;
    cin >> n;
    vector<ll> s(n);
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }

    ll ans = 0;
    for(int c = 0; c < n; c++){
        ll score = 0;
        set<ll> st;
        vector<bool> used(n,false);
        for(int k = 0; k < n; k++){
            ll a = n-1 -k*c;
            ll b = a-c;
            if(a<=0 || b<=0){break;}
            if(used[k*c]){break;}
            score += s[k*c];
            used[k*c] = true;
            if(used[n-1-k*c]){break;}
            score += s[n-1-k*c];
            used[n-1-k*c] = true;
            ans = max(ans, score);
        }
    }

    cout << ans << endl;

    return 0;
}


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

using ll = long long;
using namespace std;
const ll md = 1e9 + 7;


int main(){
    int N, K;
    cin >> N >> K;
    vector<int> p_i;
    for(int i=0;i<N;i++){
        int p;
        cin >> p;
        p_i.push_back(p);
    }

    sort(p_i.begin(), p_i.end());

    int ans = 0;
    for(int i=0;i<K;i++){
        ans += p_i[i];
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
L = int(input())
Ss = input()
Ts = input()

if Ss+Ts > Ts+Ss:
    Ss, Ts = Ts, Ss

lenS, lenT = len(Ss), len(Ts)

for numS in reversed(range(L//lenS+1)):
    numT = (L-lenS*numS) / lenT
    if int(numT) == numT:
        ans = Ss*numS + Ts*int(numT)
        print(ans)
        break


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

int main(){
  int n;
  cin >> n;
  vector<int> data(n);
  for(int i=0; i<n; i++){
    cin >> data.at(i);
  }
  
  int answer = 30000000;
  
  for(int i=-100; i<=100; i++){
    int tmp=0;
    for(int j=0; j<n; j++){
      tmp += pow((data.at(j) - i), 2);
    }
    
    if(answer > tmp) answer = tmp;
    if(answer == 0) break;
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int f(int x) {
  int sum = 0;
  while (x > 0) sum += x%10, x/=10;
  return sum;
}
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  int m = INF;
  for (int A=1; A<N; A++) {
    int B = N-A;
    m = min(m, f(A)+f(B));
  }
  cout << m << "\n";
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String a = sc.next();
			String b = sc.next();
			int na = sc.nextInt();
			int nb = sc.nextInt();
			String c = sc.next();
			if (a.equals(c)) {
				System.out.print(na - 1 + " " + nb);
			} else {
				nb = nb - 1;
				System.out.print(na + " " + nb);
			}
		}
	}

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<double,double> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<vl> mat;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const double PI = 4*atan(1);
const ll INF = 1e18;
const int MX = 100001;

int N;
vl A,B;
ll ans = 0;

void test(int x) {
    vl a,b;
    ll M = 1LL<<(x+1);
    F0R(i,N) {
        a.pb(A[i]%M);
        b.pb(B[i]%M);
    }
    sort(all(a)), sort(all(b));
    
    ll ret = 0;
    int lo = N, hi = N;
    for (ll t: a) {
        if (t < M/2) {
            while (lo > 0 && t+b[lo-1] >= M/2) lo --;
            while (hi > 0 && t+b[hi-1] >= M) hi --;
            ret += hi-lo;
        } else break;
    }
    
    for (auto& x: a) x ^= M/2;
    sort(all(a));
    for (auto& x: b) x ^= M/2;
    sort(all(b));
    
    lo = N, hi = N;
    for (ll t: a) {
        if (t < M/2) {
            while (lo > 0 && t+b[lo-1] >= M/2) lo --;
            while (hi > 0 && t+b[hi-1] >= M) hi --;
            ret += hi-lo;
        } else break;
    }
    
    if (ret&1) ans ^= M/2;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N; A.resize(N), B.resize(N);
    F0R(i,N) {
        cin >> A[i];
        // A[i] = rand();
    }
    F0R(i,N) {
        // B[i] = rand();
        cin >> B[i];
    }
    F0R(i,29) test(i);
    cout << ans;
}

// read the question correctly (is y a vowel?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)

Measured memory_bytes: 8432