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

// nCr mod p(n<p)をキビキビ計算する
// 構築:O(n), クエリ:O(1)
struct combination_mod {
    using lint = long long int;
    int sz;
    lint mod;
    vector<lint> fac;
    vector<lint> finv;
    combination_mod(int _sz, lint _mod) : sz(_sz), mod(_mod) {
        fac.assign(sz + 1, 1);
        finv.assign(sz + 1, 1);
        vector<lint> inv(sz + 1, 1);
        for (int i = 2; i <= sz; i++) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    lint query(int n, int r) {
        return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
    }
};

lint n, m, k;

int main() {
    cin >> n >> m >> k;
    lint mod = 1e9 + 7;
    combination_mod comb(m * n, mod);
    lint c = comb.query(m * n - 2, k - 2);
    lint ans = 0;
    for (lint i = 0; i < n; i++) {
        for (lint j = 0; j < m; j++) {
            lint M = (j * (j + 1) + (m - j) * (m - j - 1)) / 2;
            M %= mod;
            lint cand = 0;
            cand += M * n % mod;
            cand %= mod;
            cand += i * (i + 1) / 2 % mod * m % mod;
            cand %= mod;
            cand += (n - i) * (n - i - 1) / 2 % mod * m % mod;
            cand %= mod;
            cand *= c;
            cand %= mod;
            ans = (ans + cand) % mod;
        }
    }
    ans = (((lint)1e+9 + 8) / 2 * ans) % mod;
    cout << ans << endl;
}

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

using namespace std;

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void milkshake() {
  long long n;
  cin >> n;
  long long a;
  for(long long i = 1; i*i <= n; i++) {
    if(n % i != 0) continue;
    a = i;
  }
  long long b = n/a, ans = 0;
  while(b) {
    b /= 10;
    ans++;
  }
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt=1;
  //cin >> tt;
  while(tt--) milkshake();

  return 0;
}


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

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

    int n; cin >> n;
    map<ll, ll> mp;
    for (int i = 0; i < n; ++i) {
        ll a; cin >> a;
        mp[a]++;
    }

    ll s1 = 1;
    ll s2 = 1;
    int c1 = 0, c2 = 0;
    for (auto itr = mp.rbegin(); itr != mp.rend(); ++itr) {
        if (itr->second >= 4 && c1 < 1) {
            s1 = itr->first * itr->first;
            c1++;
        }
        if (itr->second >= 2 && c2 < 2) {
            s2 *= itr->first;
            c2++;
        }
    }

    cout << ((s1 == 1 && s2 == 1) ? 0 : max(s1, s2)) << endl;

    return 0;
}

Measured memory_bytes: 6528
n = int(input())
s = list(map(int, list(input())))

ary1 = [0 for i in range(10)]
ary2 = [[0 for i in range(10)] for j in range(10)]
ary3 = [[[0 for i in range(10)] for j in range(10)] for k in range(10)]

for ss in s:
  for i in range(10):
    for j in range(10):
      if ary1[i] == 1 and ary2[i][j] == 1:
        ary3[i][j][ss] = 1
  for i in range(10):
    if ary1[i] == 1:
      ary2[i][ss] = 1
  ary1[ss] = 1

numbers = set()

def exists(i, j, k, s):
  return ary3[i][j][k] == 1

for i in range(0, 10):
  for j in range(0, 10):
    for k in range(0, 10):
      if exists(i, j, k, s):
        numbers.add(str(i) + str(j) + str(k))

# print(numbers)
print(len(numbers))


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

using namespace std;


int cst[1003];
int doors[1003];
int n, m;
int mem[1003][(1<<13)];

int solve(int ind, int msk){
    if(msk == ((1<<n)-1)) return 0;
    if(ind == m) return 1e9;

    int &ret = mem[ind][msk];
    if(~ret) return ret;
    ret = 1e9;
    ret = min(ret, solve(ind + 1, msk));
    ret = min(ret, solve(ind + 1, msk | doors[ind]) + cst[ind]);
    return ret;
}
int main() {
    scanf("%d %d", &n, &m);
    for(int i=0; i<m; i++) {
        int num;
        scanf("%d %d", cst + i, &num);
        for(int j=0; j<num; j++){
            int cur;
            scanf("%d", &cur);
            doors[i] |= (1<<(cur-1));
        }
    }
    memset(mem, -1, sizeof(mem));
    int ans = solve(0, 0);
    if(ans < 1e9) printf("%d\n", ans);
    else puts("-1");
}

Measured memory_bytes: 32384
def examA():
    def calc_L(x1,y1,x2,y2):
        return ((x2-x1)**2 + (y2-y1)**2)**0.5
    N = I()
    X = [LI()for _ in range(N)]
    ans = 0
    for x in itertools.permutations(X):
        cur = 0
        for i in range(1,N):
            cur += calc_L(x[i-1][0],x[i-1][1],x[i][0],x[i][1])
        #print(x,cur)
        ans += cur
    for i in range(1,N+1):
        ans /= i
    print(ans)
    return

def examB():
    def judge(n):
        sn = 0
        for i in n:
            sn += int(i)
        if int(n)%sn==0:
            return "Yes"
        return "No"
    N = SI()
    ans = judge(N)
    print(ans)
    return

def examC():
    N, K = LI()
    P = LI()
    ans = 0
    S = [0]*(N+1)
    for i in range(N):
        S[i+1] = S[i]+(P[i]+1)/2
    for i in range(N-K+1):
        cur = S[i+K] - S[i]
        if cur>ans:
            ans = cur
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examC()

"""

"""

Measured memory_bytes: 26420
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll N,M,A,tmp;
ll ans;
priority_queue<ll> que;

int main(){
    cin>>N>>M;
    rep(i,N){
        cin>>A;
        que.push(A);
    }
    rep(i,M){
        tmp = que.top();
        que.pop();
        que.push(tmp/2);
    }
    while(que.size()>0){
        tmp = que.top();
        que.pop();
        ans+=tmp;
    }
    out(ans);

}


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

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

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

int main() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;

    double rad = (60.0 * H - 11.0 * M) * 3.141592653589793 / 360.0 ;
    //cout << cos(rad) << endl;
    double c = A * A + B * B - 2.0 * A * B * cos(rad);
    c = sqrt(c);
    printf("%.10f\n", c);

    return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>

typedef int32_t i32;

typedef struct node {
  char s[11];
  i32 p;
  i32 index;
} node;

int cmp_node (const void *a, const void *b) {
  node *p = (node *)a;
  node *q = (node *)b;
  int c = strcmp (p->s, q->s);
  if (c != 0) return c;
  return q->p - p->p;
}

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  node *a = (node *) calloc (n, sizeof (node));
  for (i32 i = 0; i < n; ++i) {
    scanf ("%s%" SCNi32, a[i].s, &a[i].p);
    a[i].index = i + 1;
  }
  qsort (a, n, sizeof (node), cmp_node);
  for (i32 i = 0; i < n; ++i) {
    printf ("%" PRIi32 "\n", a[i].index);
  }
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 128
/**
 *   @FileName	e.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.01 00:38:51
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n;cin >> n;
    vector<pair<int,int>> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].first >> v[i].second;
    }
    if (n & 1) {
        sort(v.begin(), v.end());
        ll s = v[n/2].first;
        sort(v.begin(), v.end(), [](pair<int,int> a, pair<int,int> b) {
            if (a.second != b.second) {
                return a.second > b.second;
            }
            else {
                return a.first > b.first;
            }
        });
        ll t = v[n/2].second;
        cout << t - s + 1 << endl;
    }
    else {
        sort(v.begin(), v.end());
        ll s1 = v[n/2].first;
        ll s2 = v[n/2-1].first;
        ll s3 = s1 + s2;
        sort(v.begin(), v.end(), [](pair<int,int> a, pair<int,int> b) {
            if (a.second != b.second) {
                return a.second > b.second;
            }
            else {
                return a.first > b.first;
            }
        });
        ll t1 = v[n/2].second;
        ll t2 = v[n/2-1].second;
        ll t3 = t1 + t2;
        cout << t3 - s3 + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 4844
N = int(input())
s=[0]*N
p=[0]*N
a=[0]*N
for i in range(N):
  s[i], p[i] = input().split()
for i in range(N):
  a[i]=[s[i],int(p[i]),i+1]
a.sort(key=lambda x: x[1],reverse=True)
a.sort(key=lambda x: x[0])
for i in range(N):
  print(a[i][2])

Measured memory_bytes: 3064
from heapq import heappush, heappop

N = [ int(x) for x in input().split() ]
a = [ sorted([ int(x) for x in input().split() ], reverse=True) for _ in range(3) ]
Q = [ (-(a[0][0]+a[1][0]+a[2][0]),[0,0,0]) ]
L = [ [0,0,0] ]

def f(v):
  global a, L, Q
  if not v in L:
    t = 0
    for i in range(3):
      t -= a[i][v[i]]
    heappush( Q, (t, v) )
    L.append(v)

for _ in range(N[3]):
  p,v = heappop(Q)
  print(-p)
  for i in range(3):
    if v[i]+1 < N[i]: f([x if j!=i else x+1 for j,x in enumerate(v)])


Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD=1e9+7;
int n,k,a[102];
LL dp[102][100002];
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		LL s[100002]={0};
		s[0]=dp[i-1][0];
		for(int j=1;j<=k;j++)s[j]=(s[j-1]+dp[i-1][j])%MOD;
		for(int j=0;j<=k;j++){
			int r=j,l=max(0,j-a[i]);
			dp[i][j]=s[r]-(l>=1?s[l-1]:0);
		}
	}
	cout<<(dp[n][k]%MOD+MOD)%MOD<<endl;
}

Measured memory_bytes: 79104
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
//これは、頭が悪く競プロが世界で一番できないHIR180が
//IOI2014日本代表になるまでのN日間の記録である。
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define f first
#define s second
#define rep(i,x) for(int i=0;i<x;i++)
int dp[155][155][11];
int main()
{
	srand((unsigned int)time(NULL));
	while(1)
	{
		int n,lim;
		vector<P>vec[155];
		scanf("%d%d",&n,&lim); if(!n) return 0;
		for(int i=1;i<=n;i++)
		{
			int cnt; scanf("%d",&cnt);
			for(int j=0;j<cnt;j++)
			{
				int x,y; scanf("%d%d",&x,&y);
				vec[i].pb(mp(x,y));
			}
		}
		vec[0].pb(mp(0,0));
		vec[n+1].pb(mp(0,0));
		for(int i=0;i<=n+1;i++)for(int j=0;j<=lim;j++)for(int k=0;k<=10;k++)dp[i][j][k]=INF;
		dp[0][lim][0]=0;
		for(int i=0;i<=n;i++)
		{
			for(int j=0;j<=lim;j++)
			{
				for(int k=0;k<vec[i].size();k++)
				{
					if(dp[i][j][k]==INF) continue;
					//go to next
					if(!i || i==n)
					{
						for(int s=0;s<vec[i+1].size();s++)
						{
							dp[i+1][j][s]=min(dp[i+1][j][s],dp[i][j][k]);
						}
					}
					else
					{
						for(int s=0;s<vec[i+1].size();s++)
						{
							int add=abs(vec[i][k].f-vec[i+1][s].f)*(vec[i][k].s+vec[i+1][s].s);
							dp[i+1][j][s]=min(dp[i+1][j][s],dp[i][j][k]+add);
						}
					}
					//go  to  next 2
					if(i==n || !j) continue;
					if(!i || i==n-1)
					{
						for(int s=0;s<vec[i+2].size();s++)
						{
							dp[i+2][j-1][s]=min(dp[i+2][j-1][s],dp[i][j][k]);
						}
					}
					else
					{
						for(int s=0;s<vec[i+2].size();s++)
						{
							int add=abs(vec[i][k].f-vec[i+2][s].f)*(vec[i][k].s+vec[i+2][s].s);
							dp[i+2][j-1][s]=min(dp[i+2][j-1][s],dp[i][j][k]+add);
						}
					}
				}
				
			}
		}
		int ret=INF;
		for(int i=0;i<=lim;i++) ret=min(ret,dp[n+1][i][0]);
		printf("%d\n",ret);
	}
}

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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if(abs(x-a) < abs(x-b)) cout << "A" << endl;
  else cout << "B" << endl;
  return 0;
}


Measured memory_bytes: 3600
import java.util.*;
 
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        String before = sc.next();
        String[] data = before.split("");

        for (int i = 0; i < data.length; i++) {
            int charValue = data[i].charAt(0);
            if (charValue + num <= 90) {
                System.out.print(String.valueOf((char)(charValue + num)));
            } else {
                System.out.print(String.valueOf((char)(charValue + num - 26)));
            }
        }
        System.out.println();
	}
}


Measured memory_bytes: 24916
#include <stdio.h>
int main(){
int m, f, r; // int m f r;to kaitesimai error to natta. kiwotukemasyou!
  while(1){
    scanf("%d%d%d",&m,&f,&r);
    if (m == -1 && f == -1 && r == -1)break;
    else if ( m == -1 || f == -1)printf("F\n");
    else if ( (m+f) >= 80)printf("A\n");
    else if ( (m+f) >= 65)printf("B\n");
    else if ( (m+f) >= 50)printf("C\n");
    else if ( (m+f) >= 30 && r >= 50)printf("C\n");
    else if ( (m+f) >= 30 )printf("D\n");
    else if ( (m+f) < 30 )printf("F\n");
  }
return 0;
}

Measured memory_bytes: 584
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Petting Cats
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		int D = parseInt(br.readLine());

		for (int i = 0; i < D; i++) {

			int minx, miny, maxx, maxy;
			int count = 0;

			words = br.readLine().split(" ");

			minx = parseInt(words[0]);
			miny = parseInt(words[1]);
			maxx = minx + parseInt(words[2]);
			maxy = miny + parseInt(words[3]);

			int N = parseInt(br.readLine());

			for (int j = 0; j < N; j++) {

				line = br.readLine();

				int x, y;
				x = parseInt(line.substring(0, line.indexOf(' ')));
				y = parseInt(line.substring(line.indexOf(' ') + 1));

				if (minx <= x && x <= maxx
						&& miny <= y && y <= maxy) count++;
			}

			System.out.println(count);

		}
	}
}

Measured memory_bytes: 24964
N,K = map(int,input().split())
R,S,P = map(int,input().split())
D = {"r":P,"s":R,"p":S}
T = input().strip()
C = {i:[] for i in range(K)}
for i in range(N):
    C[i%K].append(T[i])
cnt = 0
for i in range(K):
    num = 1
    for j in range(1,len(C[i])):
        if C[i][j]==C[i][j-1]:
            num += 1
        else:
            cnt += D[C[i][j-1]]*((num+1)//2)
            num = 1
    cnt += D[C[i][-1]]*((num+1)//2)
print(cnt)        

Measured memory_bytes: 59112
N, M, X = map(int, input().split())
C, A = [], []
for _ in range(N):
    tmp = list(map(int, input().split()))
    C.append(tmp[0])
    A.append(tmp[1:])

ans = float('inf')
for i in range(2 ** N):
    s = []
    for j in range(N):
        if (i >> j) & 1:
            s.append(j)

    # print(s)
    cost = 0
    score = [0] * M
    for t in s:
        cost += C[t]
        for k, a in enumerate(A[t]):
            score[k] += a
    # print(score)
    flag = True
    for sc in score:
        if sc < X:
            flag = False
            break
    if flag:
        ans = min(ans, cost)

# print(ans)
if ans == float('inf'):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9236
n=int(input())
a=list(map(int,input().split()))
left=0
ans=0
xor_sum=0
normal_sum=0
for right,b in enumerate(a):
	xor_sum^=b
	normal_sum+=b
	while xor_sum<normal_sum:
		xor_sum^=a[left]
		normal_sum-=a[left]
		left+=1
	ans+=right-left+1
print(ans)


Measured memory_bytes: 24712
import * as fs from 'fs';

namespace AtCoder {
    export interface Paramable {
        readonly args: string[][];
    }

    export interface Task {
        main(this: Task): void;
    }
}

namespace AtCoder.abc001 {
    export class TaskA implements AtCoder.Task, AtCoder.Paramable {
        public constructor(public readonly args: string[][]) {
        }

        public main(this: TaskA): void {
            const k: number = parseInt(this.args[0][0], 10);
            const a: number = +this.args[1][0];
            const b: number = +this.args[1][1];

            for (let i = a; i <= b; i++) {
                if (i%k===0){
                    console.log('OK');
                    return;
                }
            }

            console.log('NG');

        }
    }

    const args: string[][] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(r => r.split(' '));
    const task: AtCoder.Task = new TaskA(args);
    task.main();
}



Measured memory_bytes: 29624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int n = 305;

ll H, W, K;
bool M[n][n];
int R[n][n];
bool HasS[n];
int main(){
	cin >> H >> W >> K;
	for(int i = 0; i < H; ++i){
		for(int j = 0; j < W; ++j){
			char c; cin >> c;
			M[i][j] = c == '#';
			HasS[i] |= M[i][j];
		}
	}
	int cc = 1;
	int fR = -1;
	for(int i = 0; i < H; ++i){
		if(!HasS[i]) continue;
		if(fR == -1) fR = i;
		int j = 0;
		for(; j < W && !M[i][j]; ++j){
			R[i][j] = cc;
		}
		R[i][j++] = cc;
		for(; j < W; ++j){
			if(M[i][j]) cc++;
			R[i][j] = cc;
		}
		cc++;
	}
	int lR = fR;
	for(int i = 0; i < H; ++i){
		for(int j = 0; j < W; ++j){
			if(HasS[i])
				cout << R[i][j] << " ";
			else
				cout << R[lR][j] << " ";
		}
		cout << "\n";
		if(HasS[i])
			lR = i;
	}
}


Measured memory_bytes: 1280
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)






int main() {
    string s;
    cin >> s;
    int cnt[2] = {};
    for(auto c : s){
        cnt[c - '0']++;
    }
    cout << min(cnt[0], cnt[1]) * 2 << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
  return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong N;
	cin >> N;

	llong sum = 0;
	for (llong i = 1; i <= N; ++i) {
		llong cnt = 0;
		llong cp = i;
		while (cp /= 10)
			cnt++;
		sum += cnt%2 == 0;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def z_algo(N, S):
    end = 1
    start = 0
    max_length = 0

    while start < N:
        while end-start > N-end:
            break
        subword = S[start:end]
        if subword in S[end:]:
            max_length = max(max_length, len(subword))
            end += 1
        else:
            start += 1
            if start == end:
                end += 1
    return max_length


def solve(N: int, S: str):
    print(z_algo(N, S))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == '__main__':
    main()


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n, m;
void solve(){
	cin >> n >> m;
	
	i64 cnt = n*100+m*1800;
	cout << cnt*(1<<m) << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    if(str.equals("AAA") || str.equals("BBB") || str.length() != 3){
      System.out.println("No");
    } else {
      System.out.println("Yes");
    }
  }
}


Measured memory_bytes: 21844
#include<iostream>
#include<bits/stdc++.h>
#include<map>
#define ll long long int
using namespace std;
int main(){
	ll n;
	cin>>n;
	ll a[n];
	ll i;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n,greater<ll>());
	ll ans=a[0];
	ll j=1;
	for(i=2;i<n;){
		ans = ans+a[j];
		i++;
		if(i<n){
			ans += a[j];
			i++;
		}
		j++;
	}
	cout<<ans;
}

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

int main() {
    int N; cin >> N;
    vector<ll> B(N-1, 0);
    for(ll i=0; i<N-1; i++){
        cin >> B.at(i);
    }

    vector<ll> A(N, 0);
    A.at(0) = B.at(0);
    
    for(ll i=0; i<N-1; i++){
        A.at(i+1) = B.at(i);
        if(A.at(i) > B.at(i)) A.at(i) = B.at(i);
    }

    ll sum = 0;
    rep(i, N){
        sum += A.at(i);
    }

    cout << sum << endl;
}

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

char siin[]="w_kstnhmyr";
char boin[256];

int main(){
	boin['T']='a';
	boin['L']='i';
	boin['U']='u';
	boin['R']='e';
	boin['D']='o';
	string in;
	cin>>in;
	for(int i=0;i<in.size();i+=2){
		if(in[i]=='0'&&in[i+1]=='U')cout<<"nn";
		else{
			if(in[i]!='1')cout<<siin[in[i]-'0'];
			cout<<boin[in[i+1]];
		}
	}
	cout<<endl;
	return 0;
}

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

int palindrome(string a,int startindex,int endindex){
	for(int i=0;i<=(endindex-startindex+1)/2;++i){
		if(a[startindex+i]!=a[endindex-i])
			return 0;
	}
	return 1;
}

int main(){
	string s;
	cin>>s;
	int n=s.length();
	if(palindrome(s,0,n-1)&&palindrome(s,0,(n-3)/2)&&palindrome(s,(n+1)/2,n-1))
		cout<<"Yes"<<"\n";
	else
		cout<<"No"<<"\n";
	return 0;
}


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

int main() {
  int n;
  cin >>n;
  ll ans = 1;
  vector<ll> a(n);
  rep(i,n) cin >>a[i];
  sort(a.begin(), a.end());
  rep(i,n){
    if(a[i]==0){
      cout << 0 << endl;
      return 0;
    }
    if(a[i]<=1000000000000000000/ans){
      ans *= a[i];
    }
    else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    cout << fixed << setprecision(12);

    int N, K;
    cin >> N >> K;

    double res = 0;
    for (int n = 1; n <= N; n++)
    {
        int s = n;
        double p = 1.0;
        while (s < K)
        {
            s *= 2;
            p *= 0.5;
        }
        res += (1.0 / N) * p;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
		//出力
		Console.WriteLine(Math.Ceiling(((float)a + b) / 2)) ;
	}
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) throws Exception {
	    Scanner sc = new Scanner(System.in);   
	    long X = sc.nextLong();
	    
	    if (X <= 6) {
	    	System.out.println(1);
	    	return;
	    }
	    
	    long count = (X / 11) * 2;
	    X = X % 11;
	    
	    
	    if (X == 0) {
	    	//skip
	    } else if (X <= 6) {
	    	count++;
	    } else {
	    	count += 2;
	    }
	    
	    System.out.println(count);
	}    
}	

Measured memory_bytes: 21972
import std.conv, std.functional, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


int N, K;
int[] A;

void main() {
  try {
    for (; ; ) {
      N = readInt();
      K = readInt();
      A = new int[N];
      foreach (i; 0 .. N) {
        A[i] = readInt();
      }
      
      auto a = A.dup;
      auto app = new bool[N];
      int now;
      int magic;
      int[] ans;
      for (; ; ) {
        int im = -1;
        foreach (i; 0 .. N) {
          if (!app[i] && a[i] > 0) {
            if (im == -1 || a[im] < a[i]) {
              im = i;
            }
          }
        }
        if (im == -1) {
          break;
        }
        --a[im];
        ans ~= im;
        if (++now == N) {
          ++magic;
          app[] = false;
          now = 1;
        }
        app[im] = true;
      }
      debug {
        writeln("magic = ", magic);
      }
      
      if (magic <= K) {
        writeln(-1);
      } else {
        writeln(ans.length);
        foreach (idx, i; ans) {
          if (idx > 0) {
            write(" ");
          }
          write(i + 1);
        }
        writeln();
      }
    }
  } catch (EOFException e) {
  }
}


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

using namespace std;

int main(){
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i) cin >> a[i];
	sort(a.begin(), a.end());
	for(int i = 0; i < n - 1; ++i){
		if(a[i] == a[i+1]){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

//Istiyak Hossain

int main()
{
    int a, b, i;

    scanf("%d %d", &a, &b);

    while(a | b){
        if(a > b){
            printf("%d %d\n", b, a);
        }
        else {
            printf("%d %d\n", a, b);
        }
        scanf("%d %d", &a, &b);
    }

    return 0;
}



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

long long mod=1e9+7;

int main(){
    int n,k;
    cin>>n>>k;
    int a[n+9];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
     long long dp[n+3][k+9];
    long long prefix[n+3][k+9];
     for(int i=0;i<n;i++){
        for(int j=0;j<=k;j++){
            prefix[i][j]=0;
            dp[i][j]=0;
        }
    }
    
   for(int i=0;i<=k;i++){
        if(i<=a[0])
        dp[0][i]=1;
        else
        dp[0][i]=0;
        prefix[0][i]=dp[0][i];
        if(i>0)prefix[0][i]=(prefix[0][i]%mod+prefix[0][i-1]%mod)%mod;
        
    }

   for(int i=1;i<n;i++){
        for(int j=0;j<=k;j++){
            if(j-a[i]-1>=0)
            dp[i][j]=(prefix[i-1][j]%mod-prefix[i-1][j-a[i]-1]%mod+mod)%mod;
            else dp[i][j]=prefix[i-1][j]%mod;
            prefix[i][j]=dp[i][j];
        }
        for(int j=1;j<=k;j++){
            prefix[i][j]=(prefix[i][j]%mod+prefix[i][j-1]%mod)%mod;
        }
    }
    
    cout<<dp[n-1][k];
    
}

Measured memory_bytes: 160640
n,m=map(int,input().split())
X=list(map(int,input().split()))

X=sorted(X)

total=abs(X[-1]-X[0])

# 差が大きいところで分割する
gap=[]
for i in range(m-1):
    gap.append(abs(X[i+1]-X[i]))
gap=sorted(gap,reverse=True)

print(total - sum(gap[:n-1]))

Measured memory_bytes: 13968
/*
dict
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

int main()
{
    int n, ans = 0;
    std::cin >> n;
    std::vector<long> a(n);
    for (long i = 0; i < n; i++)
        std::cin >> a[i];

    std::sort(a.begin(), a.end());

    // for (long i = 0; i < n; i++)
    //     std::cout << a[i] << "\t";

    // std::vector<int> dp(a[n - 1], 0);
    int tmp;
    for (long i = a[1]; i > 0; i--)
    {
        tmp = 0;
        for (int j = 0; j < n; j++)
        {
            if (a[j] % i != 0)
            {
                tmp++;
                if (tmp >= 2)
                    break;
            }
        }
        if (tmp < 2)
        {
            ans = i;
            break;
        }
    }
    std::cout << ans << std::endl;

    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  ll H,W;
  cin >> H >> W;
  if(H==1 || W==1){
    cout << 1 << endl;
  }else{
    cout << (H*W+1)/2 << endl;
  }
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	aa := make([]int, n)
	ee := n - 1 - m
	if ee == 0 {
		fmt.Fprintln(writer, 0)
		return
	}
	ee <<= 1
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	uf := make([]int, n)
	for i := 0; i < n; i++ {
		uf[i] = i
	}
	for i := 0; i < m; i++ {
		x := getNextInt(scanner)
		y := getNextInt(scanner)
		rx := root(x, uf)
		ry := root(y, uf)
		if rx == ry {
			continue
		}
		uf[ry] = rx
	}
	nn := make([]nodes, n)
	for i := 0; i < n; i++ {
		heap.Init(&nn[i])
	}
	for i := 0; i < n; i++ {
		r := root(i, uf)
		heap.Push(&nn[r], node{
			i: r,
			a: aa[i],
		})
	}
	h := &nodes{}
	var ans int64
	for i := 0; i < n; i++ {
		if nn[i].Len() == 0 {
			continue
		}
		p := heap.Pop(&nn[i]).(node)
		ans += int64(p.a)
		ee--
		for nn[i].Len() > 0 {
			heap.Push(h, heap.Pop(&nn[i]).(node))
		}
	}
	for ee > 0 && h.Len() > 0 {
		p := heap.Pop(h).(node)
		ans += int64(p.a)
		ee--
	}

	if ee > 0 {
		fmt.Fprintln(writer, "Impossible")
		return
	}

	fmt.Fprintln(writer, ans)
}

type node struct {
	i, a int
}
type nodes []node

func (h nodes) Len() int           { return len(h) }
func (h nodes) Less(i, j int) bool { return h[i].a < h[j].a }
func (h nodes) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }
func (h *nodes) Push(x interface{}) {
	*h = append(*h, x.(node))
}
func (h *nodes) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func root(i int, uf []int) int {
	if i == uf[i] {
		return i
	}
	uf[i] = root(uf[i], uf)

	return uf[i]
}


Measured memory_bytes: 15744
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  for(int i=s.size();i>=0;i--){
    if(s.size()-i<t.size())continue;
    int f=1;
    for(int j=0;j<t.size();j++){
      if(s[i+j]=='?'||s[i+j]==t[j])continue;
      f=0;
    }
    if(f){
      for(int j=0;j<s.size();j++){
	if(j>=i&&j<i+t.size())cout<<t[j-i];
	else if(s[j]=='?')cout<<'a';
	else cout<<s[j];
      }
      cout<<endl;
      return 0;
    }
  }
  cout<<"UNRESTORABLE"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;
// const int maxn = 102;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;

	cin >> n;

	vector<int> b(n);

	for (int i = 0; i < n; ++i) {
		cin >> b[i];
		if (b[i] > i+1) {
			cout << -1 << endl;
			return 0;
		}
	}

	vector<int> a(1, 1);
	for (int i = 1; i < n; ++i) {
		int offset = i+1 - b[i];
		a.insert(a.end() - offset, b[i]);
	}

	for (int i = 0; i < n; ++i)
	{
		cout << a[i] << endl;
	}

	return 0;
}

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

int main()
{
    int n;
    while(cin >> n,n!=1){
        cout<<n<<":";
        int sat=6;
        vector<int> vsat;
        vsat.push_back(1);
        if(!(n%6)){
            vsat.push_back(6);
            cout << " " << 6;
        }
        while(sat<n){
            sat+=2;
            if(!(n%sat)){
                for(unsigned int i=0;i<vsat.size();i++){
                    if(i!=0&&!(sat%vsat[i])) break;
                    if(i==vsat.size()-1){
                        vsat.push_back(sat);
                        cout << " " << sat;
                    }
                }
            }
            sat+=5;
            if(!(n%sat)){
                for(unsigned int i=0;i<vsat.size();i++){
                    if(i!=0&&!(sat%vsat[i])) break;
                    if(i==vsat.size()-1){
                        vsat.push_back(sat);
                        cout << " " << sat;
                    }
                }
            }
        }
        
        cout << endl;
    }
}

Measured memory_bytes: 3004
#include <cstdio>
#include <iostream>
#include <bitset>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

#define ALL(obj) (obj).begin(), (obj).end() 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if(b<c) swap(b,c);
    if(a<b) swap(a,b);
    if(b<c) swap(b,c);
  
    if(a%2 & b%2 & c%2) cout << b*c << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int num_query;
	scanf("%d",&num_query);

	int command,digit;

	bitset<64> B(0);

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d",&command);

		switch(command){
		case 0:
			scanf("%d",&digit);
			printf("%d\n",B.test(digit));
			break;
		case 1:
			scanf("%d",&digit);
			B.set(digit);
			break;
		case 2:
			scanf("%d",&digit);
			B.reset(digit);
			break;
		case 3:
			scanf("%d",&digit);
			B.flip(digit);
			break;
		case 4:
			if(B.all()){
				printf("1\n");
			}else{
				printf("0\n");
			}
			break;
		case 5:
			if(B.any()){
				printf("1\n");
			}else{
				printf("0\n");
			}
			break;
		case 6:
			if(B.none()){
				printf("1\n");
			}else{
				printf("0\n");
			}
			break;
		case 7:
			printf("%d\n",B.count());
			break;
		case 8:
			printf("%llu\n",B.to_ulong());
			break;
		}
	}

	return 0;
}



Measured memory_bytes: 3240
/*
* Welcome to my code!
*---------------------------------------------*
* author : lynmisakura(twitter : @andoreiji11)
*/
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <chrono>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define repn for(int i = 0;i < n;i++)
#define ain(a) for(auto& i : a)cin >> i;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size()) 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define cont continue

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using pi = pair<int,int>;
using vpi = vector<pi>;
using pl = pair<ll,ll>;
using vpl = vector<pl>;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
template<class T> void print(std::vector<T> a){ int sz = a.size();
for(int i=0;i<a.size();i++)cout << a[i] << (i < sz-1 ? ' ' : '\n'); }
void ioboost(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}
///////////////////////////////////////////////////////////

ll d,g;
ll p[11],b[11];

long long fscore(int id){
  return (id + 1) * p[id] + b[id];
}
long long func(ll mask){
  ll res = 0;
  ll now_p = 0;
  for (size_t i = 0; i < d; i++)
  {
    if(mask >> i & 1){
      now_p += fscore(i);
      res += p[i];
    }
  }

  if(now_p >= g){
    return res;
  }else{
    ll left = g - now_p;
    for (int i = d - 1; i >= 0; i--)
    {
      if(!(mask >> i & 1)){
        if((i+1)*(p[i] - 1) >= left){
          res += (left + i) / (i + 1);
          return res;
        }else{
          left -= fscore(i);
          res += p[i];
          if(left <= 0)return res;
        }
      }
    }
  }
  return res;
}

int main(void){
  cin >> d >> g;
  g /= 100;
  for (size_t i = 0; i < d; i++)
  {
    cin >> p[i] >> b[i];
    b[i] /= 100;
  }

  ll ans = 1LL << 55;
  for (size_t mask = 0; mask < 1 << d; mask++)
  {
    chmin(ans,func(mask));
  }
  cout << ans << '\n'; 
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int x[10002];
  int i=0;
  int N;
  while(1){
    cin >> x[i];
    if(x[i]==0){
      break;
    }
    i=i+1;
  }
  for(int j=0;j<i;j++){
    cout << "Case " << j+1 << ": " << x[j] << endl;
  }
  return(0);
}


Measured memory_bytes: 3124
#coding:utf-8
import math

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

ans = {}
for b in a:
    if not b in ans:
        ans[b] = 1
    else:
        ans[b] += 1

min = 0
for key, value in ans.items():
    if key < value:
        min += value - key
    elif key > value:
        min += value
print(min)

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int N;
  cin >> N;
  vi32 h(N);
  cin >> h;
  vi32 dp(N, 2e9);
  dp[0] = 0;
  reps(i, N - 1) {
    amin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    if (i >= 2) amin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
  }
  cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std ;

int main()
{
    int k , a , b ;
    cin >> k >> a >> b ;
    if ( ( a >= b - 2 ) || ( k - 1 < a ) )
    {
        cout << k + 1 << endl ;
        return 0 ;
    }
    else
    {
        long long j = ( k - a + 1 ) / 2 , s = b - a , f = j * s ;

        cout << f + ( k - ( k - a + 1 ) / 2 * 2 ) + 1 << endl ;
    }
}


Measured memory_bytes: 256
function Main (S) {
  S = S.split("\n")[0];
  var ans;
  switch (S) {
    case "Sunny":
      ans = "Cloudy";
      break;
    case "Cloudy":
      ans = "Rainy"
      break;
    case "Rainy":
      ans = "Sunny";
      break;
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21192
fun main(args: Array<String>) {
    abc120d()
}

private class UnionFind(vectors: Int) {
    private val parent = IntArray(vectors) { it }
    private val size = LongArray(vectors) { 1L }

    fun root(x: Int): Int {
        if (x == parent[x]) return x

        val xr = root(parent[x])
        parent[x] = xr
        return xr
    }

    fun unite(x: Int, y: Int) {
        val xr = root(x)
        val yr = root(y)
        if (xr == yr) return

        if (size[xr] >= size[yr]) {
            size[xr] += size[yr]
            parent[yr] = xr
        } else {
            size[yr] += size[xr]
            parent[xr] = yr
        }
    }

    fun isSame(x: Int, y: Int): Boolean = root(x) == root(y)

    fun size(x: Int): Long = size[root(x)]
}

fun abc120d() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val bridges = (1..m)
        .map { readLine()!!.split(' ').map { it.toInt() - 1 }.let { Pair(it[0], it[1]) } }

    val uf = UnionFind(n)

    val inconv = LongArray(m)
    inconv[m - 1] = n.toLong() * (n - 1) / 2

    for (i in m - 1 downTo 1) {
        val (first, second) = bridges[i]

        if (uf.isSame(first, second)) {
            inconv[i - 1] = inconv[i]
        } else {
            inconv[i - 1] = inconv[i] - uf.size(first) * uf.size(second)
            uf.unite(first, second)
        }
    }

    val answer = inconv.joinToString(System.lineSeparator())

    println(answer)
}


Measured memory_bytes: 69936
#include<bits/stdc++.h>
namespace csx_std {
	using namespace std;
	typedef long long ll;
	#define FOR(i,a,b) for (register int i=(a);i<=(b);i++)
	#define For(i,a,b) for (register int i=(a);i>=(b);i--)
	#define mem(i,j) memset(i,j,sizeof(i))
	#define pii pair<int,int>
	#define pb push_back
	#define MP make_pair
	#define fi first
	#define se second
	#define GO(u) for (register int j=f[u];j!=-1;j=nxt[j])
	const int N=1e3+5;
	const int M=2e5+5;
	const int mod=1e9+7;
	inline int qpow(int x,int y) {int ret=1;for (;y;y>>=1,x=1LL*x*x%mod) if (y&1) ret=1LL*ret*x%mod;return ret;}
	inline int Inv(int x) {return qpow(x,mod-2);}
	inline void upd(int &x,int y) {x=(1LL*x+y)%mod;return;}
	inline int chkmax(int &x,int y) {return (x<y)?(x=y,1):0;}
	inline int chkmin(int &x,int y) {return (x>y)?(x=y,1):0;}
	inline int read()
	{
		int x=0,f=1;
		char c=getchar();
		while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
		while (c>='0'&&c<='9') {x=(x<<1)+(x<<3)+c-'0';c=getchar();}
		return f*x;
	}
	inline void write(int x)
	{
		if (x<0) x=-x,putchar('-');
		if (x>9) write(x/10);
		putchar(x%10+'0');
		return;
	}
}
using namespace csx_std;
int n,m,tmp1,tmp2,num[N][N],con[N][N],con_con[N][N],vis[N],p[N],q[N],uu[M],vv[M],cnt=0,ans[M];
int tot=0,f[N],nxt[M];
vector <int> G[N];
#define v G[u][i]
inline void dfs(int u,int fa)
{
	con[fa][u]=1;
	vis[u]=1;
	FOR(i,0,(int)G[u].size()-1) if (!vis[v]) dfs(v,fa);
	return;
}
inline void dfs1(int u)
{
	vis[u]=1;
	FOR(i,0,(int)G[u].size()-1) if (!vis[v]) p[v]=num[u][v],dfs1(v);
	return;
}
inline void dfs2(int u)
{
	vis[u]=1;
	For(i,(int)G[u].size()-1,0) if (!vis[v]) q[v]=num[u][v],dfs2(v);
	return;
}
#undef v
int main()
{
	mem(f,-1);
	n=read(),m=read();
	FOR(i,1,m) tmp1=read(),tmp2=read(),G[tmp1].pb(tmp2),uu[i]=tmp1,vv[i]=tmp2,num[tmp1][tmp2]=++cnt;
	FOR(i,1,n) {FOR(j,1,n) vis[j]=0;dfs(i,i);}
	FOR(i,1,n)
	{
		FOR(j,1,n) p[j]=q[j]=0;
		FOR(j,1,n) vis[j]=0;
		dfs1(i);
		FOR(j,1,n) vis[j]=0;
		dfs2(i);
		FOR(j,0,(int)G[i].size()-1)
		{
			int v=G[i][j];
			if (p[v]!=num[i][v]||q[v]!=num[i][v]) con_con[i][v]=1;
		}
	}
	FOR(i,1,m) if (con[vv[i]][uu[i]] xor con_con[uu[i]][vv[i]]) ans[i]=1;
	FOR(i,1,m)
		if (ans[i]) puts("diff");
		else puts("same");
	return 0;
}

Measured memory_bytes: 16896
// Ivan Carvalho
// Problem D - Educational Dynamic Programming Contest - AtCoder
// Link : https://atcoder.jp/contests/dp
#include <bits/stdc++.h>
using namespace std;

const int MAXW = 1e5 + 10;

long long knapsack[MAXW];
int N,W;

int main(){

	cin >> N >> W;

	for(int item = 1;item<=N;item++){
		int w,v;
		cin >> w >> v;
		for(int i = W;i>=w;i--) knapsack[i] = max(knapsack[i-w] + v,knapsack[i]);
	}

	long long best = 0;
	for(int i = 0;i<=W;i++) best = max(best,knapsack[i]);
	cout << best << endl;

	return 0;

}

Measured memory_bytes: 1024