akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define get2(c,x) (upper_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
void solve(){
	vector<VI> dic(26);
	string s,t;
	cin>>s>>t;
	rep(i,0,sz(s)){
		dic[s[i]-'a'].pb(i);
	}
	int page = 0;
	int loc = -1;
	rep(i,0,sz(t)){
		if(sz(dic[t[i]-'a'])==0)//不存在 
		{
			cout<<-1;
			return ;
		} 
		int pos = get2(dic[t[i]-'a'],loc);
		if(pos<sz(dic[t[i]-'a'])){
			loc = dic[t[i]-'a'][pos];
		}else{
			page++;
			loc = dic[t[i]-'a'][0];
		}
	}
	cout<<(1LL*page*sz(s)+loc+1);
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//	caset{
		solve();
//	}
  	return 0;
}

Measured memory_bytes: 1228
import numpy as np

input_str = input()
N, M = list(map(lambda x: int(x), input_str.split(' ')))

input_str = input()
input_list = np.array(list(map(lambda x: int(x), input_str.split(' '))))

A_sum = np.sum(input_list)

count = np.count_nonzero(input_list >= A_sum / (4*M))

print('Yes' if count >= M else 'No')


Measured memory_bytes: 12504
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const x: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    for (let i = 1; i <= 5; i++) {
      if (x[i - 1] == 0) {
        return `${i}`;
      }
    }
    return `No`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 29624
#define _GLIBCXX_DEBUG //提出時に消す
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

int main() {
  ll n, d;
  cin >> n >> d;
  ll cnt = 0;
  for (int i = 0; i < n; i++) {
    ll x, y;
    cin >> x >> y;
    if (x * x + y * y <= d * d) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3612
#include<stdio.h>
int main(void)
{
	int n,i;
	int p,d1,d2;
	int max,p1;
	scanf("%d",&n);
	max=0;
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d %d %d",&p,&d1,&d2);
			if(max<d1+d2){
				p1=p;
				max=d1+d2;
			}
		}
		printf("%d %d\n",p1,max);
		scanf("%d",&n);
		max=0;
	}
	return 0;
}

Measured memory_bytes: 1028
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	double N = sc.nextDouble();
    	sc.close();
    	for(double i = N; i >= 0; i--){
    		if(Math.sqrt(i) % 1 == 0){
    			System.out.println((int)i);
    			break;
    		}
    	}
    }
}

Measured memory_bytes: 24532
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    lint X;
    cin >> X;
    int bits = 0;
    while ((1LL << bits) <= X)
        bits++;
    cout << ((1LL << (bits)) - 1) << endl;
    return 0;
};

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 24;

int main(void){
    for(int n, m; cin >> n >> m, n;){
        int r; cin >> r;

        vector<vector<pii>> table(m);
        vi cnt(m);
        rep(aaa, r){
            int t, nn, mm, s; cin >> t >> nn >> mm >> s;
            nn--; mm--;

#define F first
#define S second

            if(table[mm].size() == 0 || table[mm][table[mm].size() - 1].S != inf){
                cnt[mm]++;
                table[mm].pb(mp(t, inf));
            }
            else {
                if(s == 1){
                    cnt[mm]++;
                }
                else {
                    cnt[mm]--;
                    if(cnt[mm] == 0){
                        table[mm][table[mm].size() - 1].S = t;
                    }
                }
            }
        }

        int q; cin >> q;
        rep(aaa, q){
            int ts, te, mm; cin >> ts >> te >> mm;
            mm--;

            int res = 0;

            for(auto && tt : table[mm]){
                int s, e;
                s = max(ts, tt.F);
                e = min(te, tt.S);

                if(e - s > 0) res += (e - s);
            }

            cout << res << endl;
        }
    }

	return 0;
}

Measured memory_bytes: 1468
import sys
input = sys.stdin.readline
from collections import *

def bfs(s):
    color[s] = 1
    q = deque([s])
    b, w = 1, 0
    
    while q:
        v = q.popleft()
        
        for nv in G[v]:
            if color[nv]==0:
                color[nv] = -color[v]
                q.append(nv)
                
                if color[nv]==1:
                    b += 1
                else:
                    w += 1
    
    return b*w
                    
N = int(input())
xy, xs, ys = [], [], []

for _ in range(N):
    x, y = map(int, input().split())
    xy.append((x, y))
    xs.append(x)
    ys.append(y)

xs = list(set(xs))
ys = list(set(ys))
xs.sort()
ys.sort()
idx1 = defaultdict(int)

for i in range(len(xs)):
    idx1[xs[i]] = i

idx2 = defaultdict(int)

for i in range(len(ys)):
    idx2[ys[i]] = i+len(xs)

M = len(xs)+len(ys)
G = [[] for _ in range(M)]

for x, y in xy:
    G[idx1[x]].append(idx2[y])
    G[idx2[y]].append(idx1[x])

color = [0]*M
S = 0

for i in range(M):
    if color[i]==0:
        S += bfs(i)

print(S-N)

Measured memory_bytes: 83540
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from itertools import permutations, combinations,combinations_with_replacement,product
from fractions import Fraction as frac
import bisect
import heapq

import logging
logging.basicConfig(level=logging.DEBUG)

import sys
#input = sys.stdin.readline().rstrip

setrecursionlimit(1000000)

MOD = 10**9+7
INF = float('inf')

def main():
	A=[int(x) for x in input().split()]
	

	if (sum(A) >= 22):
		print("bust")
	else:
		print("win")

main()

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

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

int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<char>> v(H+1, vector<char>(W+1));

  for(int i = 0; i < H; ++i){
    for(int j = 0; j < W; ++j){
      cin >> v.at(i).at(j);
    }
  }

  for(int i = 0; i < W+2; ++i){
    cout << '#';
  }
  cout << endl;
  for(int i = 0; i < H; ++i){
    cout << '#';
    for(int j = 0; j < W; ++j){
      cout << v.at(i).at(j);
    }
    cout << '#' << endl;
  }
  for(int i = 0; i < W+2; ++i){
    cout << '#';
  }

  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 a = sc.nextInt();
        int b = sc.nextInt();
        
        int ans = ((a + b + 1) / 2);
        
        System.out.println(ans);
        
        sc.close();
        
    }
}


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

namespace A_Painting
{
    class Program
    {
        static void Main(string[] args)
        {
            int gyou = int.Parse(Console.ReadLine());
            int retu = int.Parse(Console.ReadLine());
            int umeruyatu = int.Parse(Console.ReadLine());

            int goukei = 0;
            
            
            //行　列　どっちが大きいか
            if (gyou < retu)
            {
                goukei = umeruyatu / retu;
                if(0<umeruyatu % retu)
                {
                    goukei = goukei + 1;
                }
                Console.WriteLine(goukei);
            }
            else if (retu<gyou)
            {
                goukei = umeruyatu / gyou;
                if (0 < umeruyatu % gyou)
                {
                    goukei = goukei + 1;
                }
                Console.WriteLine(goukei);
            }
            else if (retu == gyou)
            {
                goukei = umeruyatu / retu;
                if (0 < umeruyatu % retu)
                {
                    goukei = goukei + 1;
                }
                Console.WriteLine(goukei);
            }
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <string.h>

#define INF 1000000000

int n, a[5010], dp[5010];

int max(int a, int b){
    return a > b ? a : b;
}

int main(void){
    int x;
    while(scanf("%d", &n) && n){
        for(x = 0; x < n; x++){
            scanf("%d", a+x);
        }
        memset(dp, -INF, sizeof(dp));  
        dp[0] = a[0];
        int ans = a[0];
        for(x = 1; x < n; x++){
            dp[x] = max(a[x], dp[x-1] + a[x]);
            ans = max(ans, dp[x]);
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n)cin >> a[i];
	rep(i,n-1)a[i+1] += a[i];
	// trace(a);
	//a[i]:iまでの和
	int ret = 1e18;
	{
		//+-+-+-
		int tmp = 0,tot = 0;
		rep(i,n){
			int x = a[i] + tot;
			if(i%2){
				//+
				if(x> 0)continue;
				tmp += abs(x-1);
				tot += 1-x;
			}
			else{
				//-
				if(x<0)continue;
				tmp += abs(x+1);
				tot -= x+1;
			}
		}
		// trace(tmp);
		ret = min(ret,tmp);
	}
	{
		//+-+-+-
		int tmp = 0,tot = 0;
		rep(i,n){
			int x = a[i] + tot;
			if(i%2){
				//+
				if(x< 0)continue;
				tmp += abs(x+1);
				tot -= x+1;
			}
			else{
				//-
				if(x>0)continue;
				tmp += abs(x-1);
				tot += 1-x;
			}
		}
		// trace(tmp);
		ret = min(ret,tmp);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  int n,m;
  cin >> n >> m;
  int l = (n-m)*100 + m*1900;
  rep(i,m) {
    l *= 2;
  }
  cout << l << endl;
  return 0;
}

Measured memory_bytes: 3616
n, m = gets.split.map(&:to_i)
params = []
n.times do
  params << gets.split.map(&:to_i)
end

params.sort_by! { |param| param[0] }

ans = 0
until m == 0
  param = params.shift
  count = [m, param[1]].min
  ans += param[0] * count
  m -= count
end

puts ans


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

int main(){
	int n, t;
	cin >> n >> t;
	vector<int> a(n);
	int mi0 = 1000000001;
	int d = 0;
	rep(i, n){
		cin >> a.at(i);
		if(mi0 > a.at(i)){
			mi0 = a.at(i);
		}
		if(d < a.at(i) - mi0){
			d = a.at(i) - mi0;
		}
	}
	int ans = 0;
	int mi = 1000000001;
	int ma = 0;
	int mas = 0;
	int mis = 0;
	a.push_back(0);
	rep(i, n+1){
		if(a.at(i) < mi){
			if(ma-mi == d){
				for(int j=i-1; j>=0; j--){
					if(a.at(j) == mi+d) break;
					if(a.at(j) == mi) mis--;
				}
				ans += min(mis, mas);
			}
			mi = a.at(i);
			ma = 0;
			mas = 0;
			mis = 0;
		}
		if(d == a.at(i) - mi){
			mas++;
		}
		if(mi == a.at(i)){
			mis++;
		}
		if(ma < a.at(i)){
			ma = a.at(i);
		}
	}
	cout << ans << endl;
	return 0;
}

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

#include <stdio.h>
#include <string.h>


/********
*	?????????????´¢
*********/	

/*********??¢?????´?????????
*	(1)????????????????????¢??°????????¨
*	(2)????????°?????????????????????????????????0????????????
*********/

int main(void)
{
	char word [10] ={0};
	char sentence[1000] ={0};
	const char *end = "END_OF_TEXT";
	int i, j;		//
	int length_w ;
	int length_T ;
	int count = 0;
	int sa 	  = 0;

	scanf("%s", word);
	length_w = strlen(word);
	
	while(1){
		scanf("%s", sentence);
		if (strcmp(end,sentence) == 0) {
			break;
		}
		else {
			length_T = strlen(sentence);
		
		
			if (length_w == length_T){
				//??????W???????????¨??????T????????????????????????????????¨???
				j=0;
				for(i= 0 ; i<	length_w; i++ ){
					sa = word[i] - sentence[i];//???????????????????????????
					
					if(32 <= sa && sa <= 59){//??§???????????¨????????????
						 sa = sa-32; 
					}
					if(sa == 0){
						j ++; 	
						if(j==length_w ){
							count++;
						}
					} else {
					//?????????????????????
					}
				}
			}else {
			//?????????????????????
			}
		}
	}
	cout << count << endl;
	
	return 0;
}
	

Measured memory_bytes: 1156
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

const int MAXN = 210000;

char s[MAXN];

const int MOD = 1000000007;

void add(int &a, int b) {
  if ((a += b) >= MOD) a -= MOD;
}

void sub(int &a, int b) {
  if ((a -= b) < 0) a += MOD;
}

int mul(int a, int b) {
  return (int) ((a * 1LL * b) % MOD);
}

int mpow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

int minv(int x) {
  return mpow(x, MOD - 2);
}

int main() {
#ifdef LOCAL
  freopen("e.in", "r", stdin);
  freopen("e.out", "w", stdout);
#endif

  int n, m;
  while (scanf("%d%d", &n, &m) == 2) {
    scanf("%s", s);
    if (s[0] != 'B') {
      for (int i = 0; i < m; i++) {
        s[i] = s[i] ^ 'B' ^ 'R';
      }
    }
    int first = find(s, s + m, 'R') - s;

    if (first == m) {
      vector<int> dp(n + 1);
      dp[0] = 1;
      dp[1] = 2;
      for (int i = 2; i <= n; i++) {
        dp[i] = dp[i - 1];
        add(dp[i], dp[i - 2]);
      }
      int ans = dp[n];
      if (n == 3) {
        sub(ans, dp[n - 3]);
      } else if (n > 3) {
        sub(ans, dp[n - 4]);
      }
      printf("%d\n", ans);
      continue;
    }

    int lim = n;
    int prev_r = 0;
    for (int i = 0; i < m; i++) {
      if (s[i] == 'R') {
        if ((i - prev_r) % 2 == 1) {
          lim = min(lim, i - prev_r);
        }
        prev_r = i + 1;
      }
    }
    lim = min(lim, first + 1);
    eprintf("lim = %d\n", lim);

    if (n % 2 != 0) {
      printf("0\n");
    } else {
      vector<int> dp(n / 2 + 1);
      vector<int> dp2(n / 2 + 2);
      dp[0] = 1;
      dp2[1] = 1;
      for (int i = 1; i <= n / 2; i++) {
        dp[i] = dp2[i];
        int pos = i - (lim + 1) / 2;
        if (pos >= 0)
          sub(dp[i], dp2[pos]);
        dp2[i + 1] = dp2[i];
        add(dp2[i + 1], dp[i]);
      }

      int ans = 0;
      for (int i = 1; i <= (lim + 1) / 2; i++) {
        add(ans, mul(2 * i, dp[n / 2 - i]));
      }
      printf("%d\n", ans);
    }

  }

  return 0;
}


Measured memory_bytes: 1280
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4.2")
#include <x86intrin.h>
#include <bits/stdc++.h>


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

const int NMX = 2048;
int N, res=0;
__attribute__((aligned(16))) int16_t d[NMX][NMX];

void f1(int16_t d[][NMX]){
	for (int k = 0; k < N; k++) for (int i = 0; i < N; i++){
		int j = 0;
		const __m128i dik = _mm_set1_epi16(d[i][k]);
		for (;j+7<N;j+=8){
			__m128i dij = _mm_load_si128((__m128i*)(d[i] + j));
			__m128i dkj = _mm_load_si128((__m128i*)(d[k] + j));
			dkj = _mm_add_epi16(dkj, dik);
			dij = _mm_min_epi16(dij, dkj);
			_mm_store_si128((__m128i*)(d[i] + j), dij);
		}
 
		for (;j<N;j++){
		  d[i][j] = min<int>(d[i][j], d[i][k] + d[k][j]);
		}
	}
}
int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n, x, y;
	cin >>n >>x >>y;
	//vector<VI> a(n, VI(n, INF));
	//rep(i, n) a[i][i] = 0;
	//rep(i, n-1) a[i][i+1] = a[i+1][i] =1;
	//a[x-1][y-1] = a[y-1][x-1] =1;
	//rep(k,n) rep(i,n) rep(j,n) a[i][j] =min(a[i][j], a[i][k] + a[k][j]);
	
	rep(i, n+2) rep(j, n+2) d[i][j] = n;
	rep(i, n) d[i][i] = 0;
	rep(i, n-1) d[i][i+1]=d[i+1][i] =1;
	d[x-1][y-1] = d[y-1][x-1] =1;
	N = n;
	f1(d);
	//dbg("dd");
	VI ds(n+2);
	rep(i, n) rep2(j, i+1, n) ds[d[i][j]]++;
	
	//for(auto x :ds) cerr<<x<<" "; dbg();
	rep2(i, 1, n) cout << ds[i]<<"\n";
	return 0;

	return 0;
}


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

int main(){
    int64_t X;
    cin >> X;
    int64_t A = 100;
    int64_t ans = 0;
    while(A < X){
        int64_t a = A / 100;
        A += a;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
n , t = map(int,input().split())
p = list(map(int,input().split()))
ans = t
for i in range(1,n):
    if p[i-1] + t > p[i]:
        ans += p[i] - p[i-1] 
    elif p[i-1] + t <= p[i]:
        ans += t
print(ans)

Measured memory_bytes: 25196
#include <iostream>

using namespace std;
int a[1000];

int bin_search(int m, int n, int k,int count) {
  int l = (m + n) / 2;
  if ( n < m) {
    return count;
  }
  count ++;
  if ( a[l] < k ) {
    return bin_search(l + 1, n, k, count);
  } else if ( a[l] > k ){
    return bin_search(m,  l - 1, k, count);
  }
  return count;
}

int main() {
  while (1) {
    int n;
    int k;
    cin >> n;
    if (n == 0) {
      return 0;
    }
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    cin >> k;

    int r = bin_search(0, n - 1, k,0);
    cout << r << endl;
  }
}

Measured memory_bytes: 3044
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
y=0
if n!=1:
    for i in range(m):
        x=0
        for j in range(n):
            if i+1 in a[j][1:a[j][0]+1]:
                x+=1
            else:
                x+=0
        if x==n:
            y+=1
    print(y)
else:
    for i in range(2,a[0][0]+1):
        if a[0][1]!=a[0][i]:
            y+=1
    print(y+1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
ll n,t,x,y,m,q;

int main(){
      ios_base::sync_with_stdio(false); cin.tie(NULL);
      cin>>n>>x;
      cout<<6-(n+x);
      
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <iomanip>
#include <utility>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

long long gcd(int x, int y){
    if ( x == 0 ) return y;

    return gcd(y%x, x);
}

long long lcm(int x, int y){
    if ( y == 0 ){
        return x;
    }

    return x*y/gcd(x, y);
}

int min(int a, int b){
    return a > b ? b : a;
}

int max(int a, int b){
    return a > b ? a : b;
}

int n;
vector <int> tree(400005, 0);

int query(int a){
    int res = 0;
    for (;a>0;a-=a&-a){
        res+=tree[a];
    }

    return res;
}

void update(int a){
    for (;a<=200000;a+=a&-a){
        tree[a]++;
    }
}

int main()
{
    cin.sync_with_stdio( false );
    cin>>n;

    int res = 0;
    for (int i=0;i<n;i++){
        int a;
        cin>>a;

        if ( i == 0 ){
            update(a);
            res++;
        }else{
            update(a);
            if ( query(a) - 1 == 0 ){
                res++;
            }
        }
    }

    cout<<res<<endl;
}


Measured memory_bytes: 4688
#include <iostream>
#include <vector>
using namespace std;
#define MAXVALUE (1<<21)
vector<int> dp(5000+1,MAXVALUE);

void init(){
	int item[6] = {200,300,500,1000,1200,1500};
	int price[6]= {380,550,850,1520,1870,2244};
	
	dp[0]=0;

	for(int k=0;k<6;k++){
		for(int i=0;i+item[k]<=5000;i++){
			dp[i+item[k]] = min( dp[i+item[k]] , dp[i]+price[k] );
		}
	}
}

int main(){
	init();
	int n,mi;
	while(cin >> n && n){
		mi = dp[n];
		/*for(int i=n;i<=5000;i++){
			mi = min(dp[i],mi);
		}*/
		cout << mi << endl;
	}
}

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

using namespace std;
typedef long long ll;
int main()
{
    ll H,W;
    scanf("%lld%lld",&H,&W);
    ll ans=1e18;
    for(int i=1;i<H;i++)
    {
        ll s[3];
        s[0]=(ll)i*W;
        s[1]=(W/2)*(H-(ll)i);
        s[2]=(W-W/2)*(H-(ll)i);
        ll MAX=0;
        ll MIN=1e18;
        for(int i=0;i<3;i++)
        {
            MAX=max(MAX,s[i]);
            MIN=min(MIN,s[i]);
        }
        ans=min(ans,MAX-MIN);
        s[1]=(H-(ll)i)/2*W;
        s[2]=((H-(ll)i)-(H-(ll)i)/2)*W;
        MAX=0;
        MIN=1e18;
        for(int i=0;i<3;i++)
        {
            MAX=max(MAX,s[i]);
            MIN=min(MIN,s[i]);
        }
        ans=min(ans,MAX-MIN);
    }
    for(int i=1;i<W;i++)
    {
        ll s[3];
        s[0]=(ll)i*H;
        s[1]=(H/2)*(W-(ll)i);
        s[2]=(H-H/2)*(W-(ll)i);
        ll MAX=0;
        ll MIN=1e18;
        for(int i=0;i<3;i++)
        {
            MAX=max(MAX,s[i]);
            MIN=min(MIN,s[i]);
        }
        ans=min(ans,MAX-MIN);
        s[1]=(W-(ll)i)/2*H;
        s[2]=((W-(ll)i)-(W-(ll)i)/2)*H;
        MAX=0;
        MIN=1e18;
        for(int i=0;i<3;i++)
        {
            MAX=max(MAX,s[i]);
            MIN=min(MIN,s[i]);
        }
        ans=min(ans,MAX-MIN);
    }
    printf("%lld",ans);

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

int N;
vector<ll>x;
ll fact[101010];
ll MOD = 1e9 + 7;

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

	cin >> N;
	x.resize(N);
	for (int i = 0; i < N; i++)cin >> x[i];
	fact[0] = 1;
	for (ll i = 1; i < 101010; i++) {
		fact[i] = fact[i - 1] * i;
		fact[i] %= MOD;
	}

	int idx = 0;
	ll ans = 1;
	ll cnt = 0;
	ll pre = -1;
	while (idx < N) {
		if (pre != x[idx] - 2) {
			x[idx] = pre + 2;
			pre = x[idx];
			cnt++;
			idx++;
		}
		else {
			if (idx == N - 1) { cnt++; break; }
			if (x[idx + 1] - x[idx] != 1) {
				pre = x[idx];
				idx++;
				cnt++;
			}
			else {
				ans *= cnt + 2;
				ans %= MOD;
				pre = x[idx];
				idx = idx + 2;
				cnt++;
			}
		}
	}
	ans *= fact[cnt];
	ans %= MOD;
	puts(ans);

	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
int main() {
    double r, a, b;
    scanf("%lf", &r);
    a = r * r * M_PI;
    b = 2 * r * M_PI;
    printf("%f %f", a, b);
    printf("\n");
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<string> w(n);
  rep(i,n) cin >> w[i];
  
  bool ok = true;
  rep(i,n) {
    for (int j=i+1; j<n; j++) {
      if (w[i]==w[j])
        ok = false;
    }
  }
  rep(i,n-1) {
    if (w[i].back() != w[i+1].front())
      ok = false;
  }
  
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())

if (b-a) % 2 == 0:
    ans = (b-a)//2
else:
    if (a-1) < (n-b):
        ans = a+((b-a-1)//2)
    elif (a-1) == (n-b):
        ans = n/2
    else:
        ans = n-b+1+((b-a-1)//2)

print(int(ans))


Measured memory_bytes: 3060
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

int main(void){
        int w,n,a,b;
        int tmp;
        cin>>w;
        int amida[30];
        for(int i=0; i<30; i++) {
                amida[i]=i+1;
        }
        cin>>n;
        for(int i=0; i<n; i++) {
                scanf("%d,%d",&a,&b,stdin);
                tmp=amida[a-1];
                amida[a-1]=amida[b-1];
                amida[b-1]=tmp;
        }
        for(int i=0; i<w; i++) {
                cout<<amida[i]<<endl;
        }

}



Measured memory_bytes: 3236
float q;
A,B,C,D,E,F,R;
M(a,b,c,d,e,f){
	e=c-a;
	f=d-b;
	q=fabs(-f*a+e*b)/hypot(e,f);
	return a*e+b*f<0&c*e+d*f>0&q<=R?q<R?2:1:0;
}
I(){
	q=E*B-F*A;
	return(C*F-D*E)*q>0&q*(A*D-B*C)>0;
}
main(v,w,o,c){
	for(;scanf("%d%d%d%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F,&v,&w,&R),A;){
		A-=v,B-=w;
		C-=v,D-=w;
		E-=v,F-=w;
		o=(A*A+B*B>R*R)+(C*C+D*D>R*R)+(E*E+F*F>R*R);
		c=M(C,D,E,F)|M(E,F,A,B)|M(A,B,C,D);
		puts(o?o-3|c&2?"c":I()?"a":c&1?"c":"d":"b");
	}
	exit(0);
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int l = sc.nextInt();

        int sum = 0;
        int min_abs = Integer.MAX_VALUE;
        int min = Integer.MAX_VALUE;

        for (int i = 0; i < n; i++) {
            int tmp = l + i;
            sum += tmp;
            if (min_abs > Math.abs(tmp)) {
                min = tmp;
                min_abs = Math.abs(tmp);
            }
        }

        System.out.println(sum - min);
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N; cin >> N;
	int A[N], c[N];
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		c[i] = A[i];
	}
	sort(c, c + N);

	for (int i = 0; i < N; i++)
	{
		if(A[i] == c[N-1]) cout << c[N-2] << endl;
		else cout << c[N-1] << endl;
	}

	return 0;
}


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

// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

struct UnionFind {
  vector< int > par;
  UnionFind(int n = 1) {
    init(n);
  }

  void init(int n = 1) {
    par.resize(n);
    for(int i = 0; i < n; i++)
      par[i] = -1;
  }
  
  int root(int n) {
    if (par[n] < 0) return n;
    return par[n] = root(par[n]);
  }

  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;

    return true;
  }

  bool issame(int x, int y) {
    return root(x) == root(y);
  }
};

vector< int > e[MAX_N];
signed main() {
  INIT;
	map<int,int> mp;
	REP(i, 3){
		VAR(int, a,b);
		--a;--b;
		mp[a]++;
		mp[b]++;
	}

	bool ok = (mp[0]==1 && mp[1]==2 && mp[2] == 2 && mp[3]==1);
	cout << (ok?"YES":"NO") << endl;
	
	
  return 0;
}


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

using namespace std;

int main(){
	int n, x;
	while(1){
		int ans=0;
		cin >> n >> x;
		if(n==0) break;
		for(int i=1; i<=n; i++){
			for(int j=i+1; j<=n; j++){
				for(int k=j+1; k<=n; k++){
					if(i+j+k==x) ans++;
				}
			}
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3116
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll N, K;
    cin >> N >> K;

    ll count = 0;
    while(N > 0){
        N /= K;
        count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3544
X,N = list(map(int, input().split()))
P = list(map(int, input().split()))

ans,ansdiff = -1,1000000

for i in range(-1,102):
  if i in P:
    continue
    
  wdiff = abs(X-i)
  if wdiff < ansdiff:
    ansdiff = wdiff
    ans = i
  elif wdiff == ansdiff:
    if ans > i:
      ans = i
      
print(ans)

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int a[500005],b[500005],x[500005];
int data[5005][5005];

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

	int n,m; cin >> n >> m;

	for (int i = 0;i < m;i++){
		cin >> a[i] >> b[i] >> x[i];
		a[i]--; b[i]--;x[i]++;
	}

	for (int i = 0;i < n;i++){
		for (int j = 0;j <= i;j++){
			data[i][j] = 0;
		}
	}

	for (int i = 0;i < m;i++){
		data[a[i]][b[i]] = x[i];
	}

	int cnt = 0;

	for (int i = 0;i < n;i++){
		for (int j = 0;j <= i;j++){
			if(i == 0 && data[i][j] == 0){ cnt++; continue;}
			if(i == 0) continue;
			if(j == 0) data[i][j] = max(data[i][j], data[i-1][j]-1);
			else if(j == i) data[i][j] = max(data[i][j], data[i-1][j-1]-1);
			else data[i][j] = max(data[i][j], max(data[i-1][j], data[i-1][j-1])-1);
			
			if(data[i][j] == 0) cnt++;
		}
	}

	int sum = 0;

	for (int i = 1;i <= n;i++){
		sum += i;
	}

	cout << sum - cnt << endl;

	return 0;

}




Measured memory_bytes: 75848
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void){
    int N, K, Hbuf;
    vector<int> H;
    cin >> N >> K;
    for(int i=0; i<N; i++){
        cin >> Hbuf;
        H.push_back(Hbuf);
    }
    if(N < K){
        cout << 0 << endl;
        return 0;
    }
    sort(H.begin(), H.end());
    cout << accumulate(H.begin(), H.end()-K, 0LL) << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int f[MAX_N]={};
int b[MAX_N]={};

int main() {
	int n;
	cin>>n;
	int w[n];
	rep(i,n)cin>>w[i];
	int a[n]={};
	a[0]=w[0];
	rep(i,n-1)a[i+1]=a[i]+w[i+1];
	int res = a[n-1];
	rep(i,n-1)res=min(res,abs(a[n-1]-2*a[i]));
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

int IsOk(int*);

int main() {
    int data[3];
    int temp;

    temp = scanf("%d %d %d", &data[0], &data[1], &data[2]);

    if (IsOk(data)==1) {
        printf("YES");
    }
    else {
        printf("NO");
    }
}

int IsOk(int* data) {
    int cnt5 = 2;
    int cnt7 = 1;
    int sz = sizeof(data);
    int i;
    for (i = 0;i < sz-1;i++)
    {
        if (data[i] == 5)
        {
            cnt5--;
            if (cnt5 < 0) {
                return 0;
            }
        }
        else if (data[i] == 7)
        {
            cnt7--;
            if (cnt7 < 0) {
                return 0;
            }
        }
    }
    if (cnt5 == 0 && cnt7 == 0) {
        return 1;
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

ll gcd(ll a,ll b){while(a^=b^=a^=b%=a);return b;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

void solve() {
  VAR(int, N);
  VEC(int, a, N);
  ll ans = 0;
  each(x, a) {
    ans += x - 1;
  }
  print(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	ll ch[200000];
	for(ll i=0;i<n;i++){
		cin>>ch[i];
	}
	ll ans=ch[0];
	for(ll i=1;i<n;i++){
		ans^=ch[i];
	}
//	cout <<ans;
	for(ll i=0;i<n;i++){
		ll now=ans^ch[i];
		cout << now<<" ";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 5144
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

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

int l[100005];
bool bad[100005];
const int MOD = 1000000007;
void solve() {
  int n, m;
  cin >> n >> m;
  while(m--) {
    int t;
    cin >> t;
    bad[t] = true;
  }
  l[0] = 1;
  if(!bad[1]) l[1] = 1;
  for(int i = 2; i <= n; i++) {
    if(bad[i]) continue;
    l[i] = l[i-1] + l[i-2];
    l[i] %= MOD;
  }
  cout << l[n] << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


Measured memory_bytes: 768
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void solve() {
    int H, W;
    for (;;) {
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        }
        rep(h, H) {
            rep(w, W) {
                if ((h + w) & 1) {
                    cout << ".";
                } else {
                    cout << "#";
                }
            }
            cout << "\n";
        }
        cout << "\n";
    }
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3160
import java.util.*;
import static java.lang.Math.*;
public class Main {
	final Scanner sc=new Scanner(System.in);
	public static void main(String[] args) {
		new Main().init();
	}
	void init(){
		final long STACK_SIZE=8*1024*1024;
		new Thread(null, new AOJ1306(), "RUN!", STACK_SIZE).start();
		//new Live5015();
	}
	
	class AOJ1306 implements Runnable{
		int N;
		final int INF=1<<29;
		AOJ1306(){}
		@Override public void run(){
			while(sc.hasNext()){
				N=sc.nextInt();
				if(N==0)	break;
				solve();
			}
		}
		void solve(){
			int[] p=new int[N+1],t=new int[N+1];
			for(int i=1; i<=N; i++){
				p[i]=sc.nextInt();
				t[i]=sc.nextInt();
			}
			
			int[][] dp=new int[N+1][4];
			for(int i=0; i<=N; i++)for(int j=0; j<=3; j++)dp[i][j]=INF;
			dp[1][1]=p[1];
			dp[1][0]=p[1]*3;
			if(t[1]<p[1]){
				System.out.println("NG 1");
				return;
			}
			
			int ans=INF;
			for(int now=2; now<=N; now++){
				boolean f=false;
				for(int b=1; b<=3; b++){
					int d0=p[now-1]+p[now],
						t0=p[now-1]*(b+1)+p[now],
						d1=(b==3?d0:abs(p[now-1]-p[now])),
						t1=(b==3?t0:d1*(b+1)),
						tlim=t[now]-t[now-1];
					if(dp[now-1][b]<INF){
						if(t0<=tlim){
							f=true;
							dp[now][1]=min(dp[now][1], dp[now-1][b]+d0);
						}
						if(t1<=tlim){
							f=true;
							dp[now][(b%3)+1]=min(dp[now][(b%3)+1], dp[now-1][b]+d1);
						}
					}
				}
				if(!f){
					ans=now;
					break;
				}
			}
			
			if(ans<INF)	System.out.println("NG "+ans);
			else{
				for(int i=0; i<=3; i++)	ans=min(ans,dp[N][i]);
				System.out.println("OK "+(ans+p[N]));
			}
			
			// degug
//			for(int y=0; y<=3; y++){
//				for(int x=1; x<=N; x++)System.out.printf("%4d ",dp[x][y]>=INF?-1:dp[x][y]);
//				System.out.println();
//			}
//			System.out.println("---------------------------------------");
		}
	}
}

Measured memory_bytes: 13000
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define pi 3.1415926535897
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define mod1 998244353
#define inf 1000000000000000000
#define inf1 1000000000
#define endl '\n'
ll arr[200005];
ll dp[200005];
pair<ll,ll> tree[4000005];
ll cal(pair<ll,ll> a,ll x)
{
	return a.ff*x+a.ss;
}
void insert(ll t,ll tl,ll tr,pair<ll,ll> ins)
{
	if(tl==tr)
	{
		if(cal(tree[t],tl)>cal(ins,tl))
			tree[t]=ins;
		return;
	}
	ll mid=(tl+tr)/2;
	bool lcheck=cal(tree[t],tl)>cal(ins,tl)?1:0;
	bool mcheck=cal(tree[t],mid)>=cal(ins,mid)?1:0;
	if(mcheck)
		swap(tree[t],ins);
	if(lcheck!=mcheck)
		insert(2*t,tl,mid,ins);
	else
		insert(2*t+1,mid+1,tr,ins);
	return;
}
ll get(ll t,ll tl,ll tr,ll pos)
{
	if(tl==tr)
		return cal(tree[t],tl);
	ll mid=(tl+tr)/2;
	ll a;
	if(pos<=mid)
		a=get(2*t,tl,mid,pos);
	else
		a=get(2*t+1,mid+1,tr,pos);
	return min(a,cal(tree[t],pos));
}
int main()
{
	fastio;
	#ifdef APNA_IO
		freopen("input.txt" , "rt" ,stdin);
		freopen("output.txt" , "wt" ,stdout);
	#endif
	ll n,c;
	cin>>n>>c;
	for(ll i=0;i<n;i++)
		cin>>arr[i];
	for(ll i=0;i<4000005;i++)
		tree[i]=mp(0,inf);
	ll a=-2*arr[0];
	ll b=arr[0]*arr[0];
	insert(1,1,1000000,mp(a,b));
	for(ll i=1;i<n;i++)
	{
		ll mi=get(1,1,1000000,arr[i]);
		ll d=arr[i]*arr[i];
		mi+=c+d;
		dp[i]=mi;
		a=-2*arr[i];
		insert(1,1,1000000,mp(a,dp[i]+d));	
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 65920
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	int d,a,dir=0;
	double x=0,y=0;
	double rad;
	while(scanf("%d,%d",&d,&a)){
		if(d==0&&a==0)
		break;
		rad = dir*(M_PI/180);
		x+=d*sin(rad);
		y+=d*cos(rad);
		dir+=a;
	}
	printf("%d\n%d\n",(int)x,(int)y);
}

Measured memory_bytes: 3448
N = int(input())
L = list(map(int,input().split()))

ans = 0
if N >= 3:
    for p in range(N):
        P = L[p]
        for q in range(p+1,N):
            Q = L[q]
            for r in range(q+1,N):
                R = L[r]
                if P!=Q and Q != R and R != P :
                    if P+Q>R and Q+R>P and R+P>Q:
                        ans += 1
print(ans)
                


Measured memory_bytes: 9204
#include <iostream>

using namespace std;

int main()
{
    char c;
    cin >> c;
    string s = "consonant";
    if( c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' ) s = "vowel";
    cout << s << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int h,w,i,j;
    char c[101][101];

    scanf("%d %d",&h,&w);
    for (i = 0; i < h; i++)
    {
        scanf("%s",c[i]);
    }

    for (i = 0; i < h; i++)
    {
        printf("%s\n%s\n",c[i],c[i]);
    }
        
}

Measured memory_bytes: 128
//hail to jwalaji
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
lli h,w,a,b,f,t,e;
set<pair<lli,lli>> st;
multiset<lli> ms;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>h>>w;
    for(lli i=0;i<w;i++){
        st.insert({i,i});
        ms.insert(0);
    }
    for(lli i=0;i<h;i++){
        cin>>a>>b;
        auto tl=st.lower_bound({a-1,0}),el=st.lower_bound({b,0});
       e=tl!=el;
       for(;tl!=el;tl=st.erase(tl)){
        tie(t,f)=*tl;
        ms.erase(ms.find(t-f));
       }
       if(e&&b!=w){
        st.insert({b,f});
        ms.insert(b-f);
       }
       if(ms.empty()){cout<<-1<<endl;}
       else{
        cout<<*ms.begin()+i+1<<endl;
       }
    }
}


Measured memory_bytes: 25480