akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define ll long long

const int Max = 1e5+3;
int arr[Max];

bool cmp(pair<int, int> x, pair<int, int> y) {
    return x.second < y.second;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    map<int, int> evens, odds;
    for(int i = 1; i <= n; ++i) {
        cin >> arr[i];
        if(i%2 == 0) {
            evens[arr[i]]++;
        } else {
            odds[arr[i]]++;
        }
    }
    vector<pair<int, int> > even, odd;
    for(auto p : evens) even.push_back(p);
    for(auto p : odds) odd.push_back(p);
    sort(even.begin(), even.end(), cmp);
    sort(odd.begin(), odd.end(), cmp);
    if(even.rbegin()->first != odd.rbegin()->first) {
        cout << n - even.rbegin()->second - odd.rbegin()->second << '\n';
        return 0;
    }
    if(even.size() == 1 && odd.size() == 1) {
        cout << n/2 << '\n';
        return 0;
    }
    int res = n+2;
    if(even.size() == 1) {
        auto it = odd.rbegin();
        it++;
        res = min(res, n-even.rbegin()->second - it->second);
    } else if(odd.size() == 1) {
        auto it = even.rbegin();
        it++;
        res = min(res, n-odd.rbegin()->second - it->second);
    } else {
        auto it = odd.rbegin();
        it++;
        res = min(res, n-even.rbegin()->second - it->second);
    
        auto it2 = even.rbegin();
        it2++;
        res = min(res, n-odd.rbegin()->second - it2->second);
        
    }
    
    cout << res << '\n';
    return 0;
}
















Measured memory_bytes: 9592
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
double a[1000000];
int main()
{
	long long n,i,j,k;
	double mx,x;
	mx=0.0;
	cin>>n>>k;
	for (i=0;i<n;i++)
	{
		cin>>arr[i];
		a[i]=((arr[i]*1.0)+1.0)/2.0;
	}
	for (i=0;i<k;i++)
	{
		mx=mx+a[i];
	}
	x=mx;
	for (i=k;i<n;i++)
	{
		x=x+a[i]-a[i-k];
		mx=fmax(x,mx);
	}
	cout<<setprecision(15)<<mx<<endl;
}

Measured memory_bytes: 5888
n=int(input())
lst=list(input())
#i=0
ans_lst=[lst[1:].count("E")]

for i in range(1,n):
    temp_ans=ans_lst[i-1]
    if lst[i]=="E":
        temp_ans-=1
    if lst[i-1]=="W":
        temp_ans+=1
    ans_lst.append(temp_ans)

print(min(ans_lst))

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, string> duo;

#define TT template<typename T>
#define TTF template<typename T, typename F>
#define ET(T) typename T::value_type
TT inline T sq(T x){return x*x;}
TT inline T In(){T x;cin>>x;return x;}
TT inline void Out(T&x){cout<<x;}
TT inline void sort(T&v){sort(begin(v),end(v));}
TT inline void revs(T&v){reverse(begin(v),end(v));}
TT inline void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT inline int ubnd(T&v,ET(T)&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT inline int lbnd(T&v,ET(T)&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF inline void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF inline void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
#undef TT
#undef TTF
#undef ET

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}

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

int main()
{
  int n;
  while (cin >> n, n){
    map<string, int> cnt;
    cin.ignore();
    for (int i = 0; i < n; i++){
      string line;
      getline(cin, line);
      stringstream ss(line);
      for (string tkn; getline(ss, tkn, ' '); cnt[tkn]++);
    }
    string c = In<string>();
    vector<duo> out;
    for (const auto& si : cnt){
      if (si.first[0] == c[0]){
        out.push_back(duo(-si.second, si.first));
      }
    }
    if (!out.size()) puts("NA");
    else {
      sort(out);
      if (out.size() > 5u) out.erase(begin(out) + 5, end(out));
      show(out, [](duo x){ cout << get<1>(x); });
    }
  }
  return (0);
}
// priority_queue queue deque front stringstream max_element min_element insert count make_tuple

Measured memory_bytes: 1240
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 s=a+b;int m=a*b;int d=a-b;
if(s>m && s>d)
System.out.println(s);
else if(m>s && m>d)
System.out.println(m);
else
System.out.println(d);
}

}

Measured memory_bytes: 22868
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int a,b,x;
  cin>>a>>b>>x;
  if(x>=a && x<=a+b)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

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

std::vector<std::vector<int>> g;
std::vector<int> dp;
int n;

int dfs(int v, int p = -1){
	if(~dp[v]) return dp[v];
	
	int ret = 0;
	for(auto e : g[v]){
		if(e == p) continue;
		ret ^= dfs(e, v) + 1;
	}
	
	return dp[v] = ret;
}

int main(){
	cin >> n; g.resize(n); dp.resize(n, -1);
	for(int i = 0; i < n - 1; i++){
		int a, b; cin >> a >> b;
		
		g[a - 1].push_back(b - 1);
		g[b - 1].push_back(a - 1);
	}
	
	if(dfs(0)) cout << "Alice" << endl;
	else cout << "Bob" << endl;
	return 0;
}


Measured memory_bytes: 12416
N,H=map(int,input().split())
a=list()
b=list()
maxs=0
for j in range(N):
    A,B=map(int,input().split())
    a.append(A)
    b.append(B)
maxa=max(a)
a.sort()
b.sort()
ans=0
while len(b)>0:
    if(H<=0):
        break
    
    if(b[-1]>=maxa):
        H-=b[-1]
        b.pop()
        ans+=1
    else:
        break
if(H>0):
    ans+=H//maxa
    if(H%maxa>0):
        ans+=1
print(ans)

Measured memory_bytes: 11352
#include<algorithm>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<numeric>
#include<stack>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
const double PI = acos(-1);  // PI = 3.141593...

template<typename T>
int binary_search(vector<T> v, T key) {
    int left = 0;
    int right = v.size();
    while(left < right) {
        int mid = (left + right) / 2;
        if(v[mid] == key) {
            return mid;
        }
        else if(key < v[mid]) {
            right = mid;
        }
        else {
            left = mid + 1;
        }
    }
    return -1;
}

int main() {
    int n, q;
    cin >> n;
    vector<ll> s(n);
    rep(i,n) cin >> s[i];
    cin >> q;
    ll t;
    int cnt = 0;
    rep(i, q) {
        cin >> t;
        if(binary_search(s.begin(), s.end(), t)) {
            ++cnt;
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3508
package main

import "fmt"

func main() {
	var a string
	fmt.Scan(&a)

	m := make(map[rune]int)
	for _, s := range a {
		m[s]++
	}

	l := len(a)
	ans := (l*(l-1))/2 + 1
	for _, c := range m {
		ans -= (c * (c - 1)) / 2
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1920
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    
    if (N<105){
        cout << 0;
    }else if (N<135){
        cout <<1;
        
    }else if (N<165){
        cout <<2;
    }else if (N<189){
        cout <<3;
    }else if (N<195){
        cout <<4;
    }else {
        cout <<5;
    }
}



Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC91 C

from operator import itemgetter
n = int(input())
red = [list(map(int,input().split())) for _ in range(n)]
blue = [list(map(int,input().split())) for _ in range(n)]
red = sorted(red,key = itemgetter(1),reverse = True)
blue = sorted(blue,key = itemgetter(0))
checkr = [True]*n
checkb = [True]*n

pair = 0
for c,d in blue:
    for j in range(n):
        a,b = red[j]
        if a < c and b < d and checkr[j]:
            pair += 1
            checkr[j] = False
            break
print(pair)


Measured memory_bytes: 39280
#include<stdio.h>
int main (void){
    int a,b,c,hoge;
    scanf("%d %d %d",&a,&b,&c);
    hoge=a;
        if (a>b){
            hoge=b;
            b=a;
            a=hoge;
        }
        if (b>c){
        hoge=b;
        b=c;
        c=hoge;
        }
        if (a>b){
            hoge=b;
            b=a;
            a=hoge;
        }
                printf("%d %d %d\n",a,b,c);

        return 0;
    
    
    
}


Measured memory_bytes: 2064
#include <iostream>
#include <cmath>
  
using namespace std;
  
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        double x[4],y[4];
        for(int j=0;j<4;j++)
            cin>>x[j]>>y[j];
        if(abs((x[3]-x[2])*(y[1]-y[0])-(x[1]-x[0])*(y[3]-y[2]))<1e-10)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
      
    return 0;
}


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

ifstream in ( "test.in"  );
ofstream out( "test.out" );

const int DIM = 1e5 + 5;

int arr[DIM];

int main( void ) {
    
    int n;
    cin >> n;
    
    for( int i = 1; i <= n; i ++ ) {
        cin >> arr[i];
    }
    
    sort( arr + 1, arr + n + 1 );
    
    int cnt = 0, pos = 0;
    for( int i = 2; i <= n; i ++ ) {
        if( arr[i] != arr[i - 1] ) {
            cnt ++;
            pos = i - 1;
        }
    }
    
    if( cnt >= 2 )
        cout << "No";
    else
    if( cnt == 0 ) {
        if( arr[1] == n - 1 || arr[n - 1] <= n / 2 )
            cout << "Yes";
        else
            cout << "No";
    } else
    if( arr[pos + 1] - 1 != arr[pos] || arr[pos + 1] - pos <= 0 )
        cout << "No";
    else {
        arr[pos + 1] -= pos;
        
        if( arr[pos + 1] <= (n - pos) / 2 )
            cout << "Yes";
        else
            cout << "No";
    }
    
    return 0;
}

Measured memory_bytes: 640
N,M = map(int,input().split())
import sys
num = [-1]*(N+1)
for _ in range(M):
    s,c = map(int,input().split())
    if num[s]==-1 or num[s]==c:
        num[s]=c
    else:
        print(-1)
        sys.exit()
if N==1:
    if num[1]==-1:
        num[1]=0
elif N==2:
    if num[1]==0:
        print(-1)
        sys.exit()
    if num[1]==-1:
        num[1]=1
    if num[2]==-1:
        num[2]=0
else:
    if num[1]==0:
        print(-1)
        sys.exit()
    if num[1]==-1:
        num[1]=1
    if num[2]==-1:
        num[2]=0
    if num[3]==-1:
        num[3]=0
print("".join(map(str,num[1:])))

Measured memory_bytes: 61904
# -*- coding: utf-8 -*-

L_n = []
N, X = map(int, input().split())

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

Lsum = 0
cnt = 1
for i in range(N):
    Lsum += L_n[i]
    if Lsum <= X:
        cnt += 1


print(cnt)



Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std ;
int main()
{
int k;
  cin>>k;
  int a,b;
  cin>>a>>b;
  bool flag;
  for(int i=a;i<=b;i++)
  {
    if(i%k==0)
    {
      flag=true;
      break;
    }
    else
    {flag=false;}
  }
  if(flag)
  cout<<"OK"<<endl;
  else
  cout<<"NG"<<endl;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c,d;
	cin >> a >> b >> c;
	d = c % b;
	for(int i = 1;i <= b; i++)
	{
		if((a * i) % b == d)
		{
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int N = 3000;
 
int a,b,c,d,e,f,ans,total;
int dp[N+10][N+10];
 
void dfs(int sugar,int water){
    if (dp[sugar][water]!=-1) return;
    dp[sugar][water] = 1;
    if (sugar*100>e*water) return;
    if (sugar+water>f) return;
    if (total==0 || sugar*total>ans*(sugar+water)){
        if (water>0){
            ans = sugar;
            total = sugar + water;
        }
    }
    dfs(sugar,water+100*a);
    dfs(sugar,water+100*b);
    dfs(sugar+c,water);
    dfs(sugar+d,water);
}
 
int main(){
    //freopen("F:\\rush.txt","r",stdin);
    memset(dp,255,sizeof dp);
    ios::sync_with_stdio(0),cin.tie(0);
    cin >> a >> b >> c >> d >> e >> f;
    dfs(0,0);
    cout << total << ' '<< ans << endl;
    return 0;
}

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

int m;

struct Seg{
	ll dx, dy;
};

bool check(Seg s1, Seg s2){
	return s1.dx * s2.dy - s1.dy * s2.dx == 0;
}

vector<Seg> s;
int calc(){
	int ret = 0;
	for(int i = 0; i < s.size(); i++){
		for(int j = i + 1; j < s.size(); j++){
			if(check(s[i], s[j])) ret++;
		}
	}
	return ret;
}

ll x[16], y[16];

int ans;

void dfs(ll bit){
	if(bit == (1 << m) - 1){
		ans = max(ans, calc());
		return;
	}
	for(int i = 0; i < m; i++){
		if(bit >> i & 1) continue;
		for(int j = 0; j < m; j++){
			if(i == j || (bit >> j & 1)) continue;
			ll nbit = bit | (1 << i) | (1 << j);
			ll dx = x[i] - x[j];
			ll dy = y[i] - y[j];
			s.push_back({ dx, dy });
			dfs(nbit);
			s.pop_back();
		}
		break;
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

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

	dfs(0);
	cout << ans << endl;
}

Measured memory_bytes: 3212
#include <stdio.h>
int main(void){
	int d,n;
	scanf("%d %d",&d,&n);
	int ans = 0;
	int i;
	if( d==0){
		ans = n;
		if( n==100){
			ans += 1;
		}
		printf("%d",ans);
	}else if( d==1){
		ans = 0;
		for(i=0;i<n;i++){
			ans += 100;
		}
		if( n==100){
			ans += 100;
		}
		printf("%d",ans);
	}else if(d==2){
		ans =0;
		for(i=0;i<n;i++){
			ans +=10000;
		}
		if( n==100){
			ans += 10000;
		}
		printf("%d",ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  int x,y;
  cin >> x >> y;
  if(x==2 || y==2)  cout << "No" << endl;
  else if((x==4 || x==6 || x==9)&&(y==6 || y==9 || y==11))  cout << "Yes" << endl;
  else if((x==1 || x==3 || x==5 || x==7 || x==8 || x==10)&&(y==3 || y==5 || y==7 || y==8 || y==10 || y==12)) cout << "Yes" << endl;
  else  cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define RREP(i, n) for(int i=0; i>(int)(n); i--)
#define ALL(v) v.begin(), v.end()
#define INF 2e9
typedef long long ll;
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(a>b){a=b; return 1;}return 0;}

using namespace std;

int w[101], v[101];
ll dp[101][101010];

int main(void){
	int N, W;
	cin >> N >> W;
	REP(i, N){
		cin >> w[i] >> v[i];
	}
	
	REP(i, W+1){
		if(i<w[0]){
			dp[0][i] = 0;
		}else{
			dp[0][i] = v[0];
		}
	}
	REP(i, N-1){
		REP(k, W+1){
			dp[i+1][k] = dp[i][k];
		}
		REP(k, W){
if(k+w[i+1]>W){break;}
			chmax(dp[i+1][k+w[i+1]], dp[i][k]+v[i+1]);
		}
	}
	
	cout << dp[N-1][W] << "\n";
	return 0;
}


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

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

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	FOR(i,0,ty-sy){
		cout << 'U';
	}
	FOR(i,0,tx-sx){
		cout << "R";
	}
	FOR(i,0,ty-sy){
		cout << "D";
	}
	FOR(i,0,tx-sx+1){
		cout << "L";
	}
	FOR(i,0,ty-sy+1){
		cout << "U";
	}
	FOR(i,0,tx-sx+1){
		cout << "R";
	}
	cout << "D";
	cout << "R";
	FOR(i,0,ty-sy+1){
		cout << "D";
	}
	FOR(i,0,tx-sx+1){
		cout << "L";
	}
	cout << "U";
	cout << "\n";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
   char c;
   int k;
   int a[53]={0};
   cin>>a[0];
   for(int i=1;i<=a[0];i++){
      cin>>c>>k;
      if(c=='S')a[k]=1;
      if(c=='H')a[13+k]=1;
      if(c=='C')a[26+k]=1;
      if(c=='D')a[39+k]=1;
   }
   for(int i=1;i<53;i++){
      if(a[i]==0){
         if(i<14)cout<<"S "<<i<<endl;
         if(13<i&&i<27)cout<<"H "<<i-13<<endl;
         if(26<i&&i<40)cout<<"C "<<i-26<<endl;
         if(39<i)cout<<"D "<<i-39<<endl;
      }
   }
   return 0;
}

Measured memory_bytes: 3044
n, m = map(int, input().split())
a = [False]*(n+1)
for i in range(m):
  ii = int(input())
  a[ii] = True
  
dp = [0]*(n+1)
dp[0] = 1

mod = 1000000007
for i in range(1, n+1):
  if a[i]:
    dp[i] = 0
    continue
  dp[i] = (dp[i-1] + dp[i-2]) % mod

print(dp[-1])

Measured memory_bytes: 44888
fun main(args: Array<String>) {
    val n = readLine()
    val plist = readLine()!!.split(" ").map { it.toInt() }

    var min = plist.first()
    var count = 0
    plist.forEach { 
        if (it <= min) {
            min = it
            count += 1
        }
    }
    print(count)
}

Measured memory_bytes: 82700
open Batteries

let solve (a, b) line =
  Scanf.sscanf line "%d %d" @@ fun x y ->
  let ratio = max ((a-1) / x+1) ((b-1) / y+1) in
  (x*ratio, y*ratio)

let () =
  IO.lines_of stdin
  |> Enum.skip 1
  |> Enum.fold solve (1, 1)
  |> fun (x, y) -> Int.print stdout (x + y)


Measured memory_bytes: 2944
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0


for i in range(A + 1):
    for j in range(B + 1):
        for l in range(C + 1):
            if (500*i + 100*j + 50*l) == X:
                count += 1
              
print(count)

Measured memory_bytes: 3060
def to_cumsum(arr):
    """
    1次元配列を累積和の1次元配列に変換する
    """
    cumsum = 0
    new = [0] * len(arr)
    for i, e in enumerate(arr):
        cumsum += e
        new[i] = cumsum
    return new


N, K = map(int, input().split())
tmp = list(map(int, input().split()))
A = [0]
A.extend(tmp)
cumsum = to_cumsum(A)
arr = list()
for i in range(N + 1):
    for j in range(i + 1, N + 1):
        arr.append(cumsum[j] - cumsum[i])

ans_str = ''
for i in reversed(range(1, cumsum[-1].bit_length() + 1)):
    tmp = list(filter(lambda a: (a >> (i - 1)) & 1, arr))
    cnt = len(tmp)
    if cnt >= K:
        ans_str += '1'
        arr = tmp
    else:
        ans_str += '0'
print(int(ans_str, 2))


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

using namespace std;
int main() {
  string s;
  cin >> s;
  int cnt = 0;
  int maxCnt = 0;
  for (int i = 0; i < s.length(); i++) {
    char c = s[i];
    if (c == 'A' || c == 'C' || c == 'G' || c == 'T')
      cnt++;
    else {
      maxCnt = max(maxCnt, cnt);
      cnt = 0;
    }
  }
  maxCnt = max(maxCnt, cnt);
  cout << maxCnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max();
const ll INFLL = numeric_limits<ll>::max();

signed main() {
    vector<ll> a(7);
    cin >> a;
    ll ans = 0;
    vector<int> explore = {0, 3, 4};
    int oddCount = 0;
    bool check = true;
    for (auto idx : explore) {
        if (a[idx] < 1) check = false;
        if (a[idx] % 2 == 1) oddCount++;
    }
    if (oddCount >= 2 && check) {
        ans += 3;
        for (auto idx : explore) a[idx]--;
    }
    for (auto idx : explore) ans += (a[idx] / 2) * 2;
    ans += a[1];
    cout << ans << endl;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll a[110];
    rep(i,0,N) cin >> a[i];
    ll dp[100010] = {};
    rep(k,0,K+1){
        bool check[110] = {};
        rep(i,0,N){
            if(k - a[i] >= 0){
                check[dp[k-a[i]]] = true;
            }
        }
        rep(i,0,N+1){
            if(not check[i]){
                dp[k] = i;
                break;
            }
        }
    }
    if(dp[K] == 0){
        print("Second");
    }else{
        print("First");
    }

    

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int ll
using namespace std;
typedef long long ll;
 
ll n,s,ans=10000000000000ll;
inline bool check(int x)
{
	if(x==1) return 0;
	ll tt=0,ts=n;
	while(ts)
	{
		tt+=ts%x;
		ts/=x;
	}
//	if(x==10) printf("%d\n",tt);
	return tt==s;
}
signed main()
{
	cin >> n >> s;
	if(n==s){printf("%lld\n",n+1); return 0;}
	for(int i=1;i<=sqrt(n);i++)
	{
		if((n-s+i)%i==0&&i*i<n){ if(((n-s+i)/i)) if(n/((n-s+i)/i)==i) ans=min(ans,(n-s+i)/i);}
		if(check(i)) ans=min(ans,(ll)i);	
	}
	if(ans==10000000000000ll) puts("-1");
	else cout << ans << endl;
	return 0;
}

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

int main() {
  int Y, X;
  cin >> Y >> X;	
  vector<string> vec(X,"#");
  cout << "#";
  for(int i; i<X;i++){
    cout << vec.at(i);
  }
  cout << "#" << endl;
  
  for(int i; i<Y; i++){
    string tex;
    cin >> tex;
    cout << "#" << tex << "#" << endl;
  }
  cout << "#";
  for(int i; i<X;i++){
    cout << vec.at(i);
  }
  cout << "#" << endl;

  
}

Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
int main(){
  int N,K;
  int sum;
  cin >> N >> K;
  if(N==1)cout << K << endl;
  else if(K==2) cout << K << endl;
  else{
   sum = K*(K-1);
    for(int i=0;i<N-2;i++){
     sum = sum*(K-1); 
    }
  cout << sum << endl;
  }
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, a, b, c, d) = (v[0], v[1] - 1, v[2] - 1, v[3] - 1, v[4] - 1);
    let s = read::<String>().chars().collect::<Vec<_>>();

    for i in a..c {
        if s[i] == '#' && s[i + 1] == '#' {
            println!("No");
            return;
        }
    }
    for i in b..d {
        if s[i] == '#' && s[i + 1] == '#' {
            println!("No");
            return;
        }
    }
    if a > b && c < d {
        let mut found = false;
        for i in a..c + 1 {
            if s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.' {
                found = true;
                break;
            }
        }
        if !found {
            println!("No");
            return;
        }
    }

    if a < b && c > d {
        let mut found = false;
        for i in b..d + 1 {
            if s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.' {
                found = true;
                break;
            }
        }
        if !found {
            println!("No");
            return;
        }
    }

    println!("Yes");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    s=list(input())
    lowercase = list('abcdefghijklmnopqrstuvwxyz')

    for i in s:
        if i in lowercase:
            lowercase.remove(i)
    print(lowercase[0] if len(lowercase)!=0 else 'None')

resolve()

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

u64 lcm(u64 a, u64 b) { return (a / gcd(a, b)) * b; }

int main() {
  u32 N, Q;
  string S;
  cin >> N >> Q >> S;
  vector<pair<u32, u32>> Term(Q);
  for (u32 i = 0; i < Q; ++i) cin >> Term[i].first >> Term[i].second;
  vector<u32> Cntv(N);
  Cntv[0] = 0;
  u32 cnt = 0, prev = 0;
  auto pos = S.find("AC");
  while (pos != string::npos) {
    for (; prev <= pos; ++prev) {
      Cntv[prev] = cnt;
    }
    ++cnt;
    pos = S.find("AC", pos + 2);
  }
  for (; prev < N; ++prev) {
    Cntv[prev] = cnt;
  }
  for (u32 i = 0; i < Q; ++i) {
    cout << Cntv[Term[i].second - 1] - Cntv[Term[i].first - 1] << endl;
  }
  return 0;
}


Measured memory_bytes: 2176
N = int(input())
a = list(map(int, input().split()))

a.sort()

n = 0
c = 0
ans = 0
for i in range(N):
    if n != a[i]:
        if c >= n:
            ans += c - n
        else:
            ans += c
        n = a[i]
        c = 1
    else:
        c += 1
if c >= n:
    ans += c - n
else:
    ans += c
print(ans)

Measured memory_bytes: 14268
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
  vector<ll> a(3);
  cin>>a[0]>>a[1]>>a[2];
  sort(all(a));
  if(a[0]%2==1&&a[1]%2==1&&a[2]%2==1){
    cout<<a[0]*a[1]<<endl;
  }else{
    cout<<0<<endl;
  }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
  cin >> s;
  if(s[0]=='7' || s[1]=='7' || s[2]=='7') {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
  
    


Measured memory_bytes: 3612
n = int(input())
xyh = []
x0, y0, h0 = None, None, None
for _ in range(n):
    x, y, h = map(int, input().split())
    if h > 0 and x0 is None:
        x0, y0, h0 = x, y, h
    xyh.append([x, y, h])

for cx in range(101):
    for cy in range(101):
        h = h0 + abs(x0 - cx) + abs(y0 - cy)
        done = True
        for xk, yk, hk in xyh:
            h_ = max(h - abs(xk - cx) - abs(yk - cy), 0)
            if h_ != hk:
                done = False
                break
        if done:
            print(f'{cx} {cy} {h}')

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

using namespace std;


int main (void) 
{

  /* Variable_Proclamation */
  int N;    // input
  int X;    // input
  int count;  // output
  int ans;

  int i;    // subscript
  int sum;
  int min_cost;


  /* Input, Array_Proclamation */
  cin >> N;
  cin >> X;
  vector<int> m(N);


  for(i=0; i<N; i++)
  {
    cin >> m.at(i);
  }


  /* Initialize */
  sum   = 0;
  // count = 0;


  /* Calculation */
  sort( m.begin(), m.end() );
  min_cost = m.at(0);

  for(i=0; i<N; i++)
  {
    sum += m.at(i);
  }

  ans = N + (X -sum)/min_cost;

  // while(X - min_cost > 0)
  // {
  //   X -= min_cost;
  //   count++;
  // }
  

  /* Output */
  cout << ans << endl;


  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> Size;
    bool checker[100050];
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1;
        for(int i = 0; i <= 1e5; i++) checker[i] = false;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

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

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }

    ll size(int x){
        return Size[root(x)];
    }
};

ll N;
ll x[100500], y[100050];
map<ll, ll> appearx, appeary;
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> x[i] >> y[i];
    }
    UnionFind X(100050), Y(100050);
    for(int i = 1; i <= N; i++) {
        if(appearx[x[i]] == 0) {
            appearx[x[i]] = i;
        } else {
            Y.merge(y[appearx[x[i]]], y[i]);
        }
        if(appeary[y[i]] == 0) {
            appeary[y[i]] = i;
        } else {
            X.merge(x[appeary[y[i]]], x[i]);
        }
    }
    ll ans = -N;
    for(int i = 1; i <= N; i++) {
        //cerr << x[i] << " " << y[i] << " "<< X.root(x[i]) << " "<< Y.root(y[i]) << endl;
    }
    for(int i = 1; i <= N; i++) {
        if(X.checker[X.root(x[i])]) continue;
        X.checker[X.root(x[i])] = true;
        ans += X.size(x[i]) * Y.size(y[i]);
        //cerr << i << " "<< X.size(mpx[x[i]]) << " "<< Y.size(mpy[y[i]]) << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13440
#include <stdio.h>
#include <math.h>
int main(void){
  int n,h[100001],dp[100001];
  dp[0]=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&h[i]);
  }
  dp[1]=abs(h[1]-h[0]);
  for(int i=2;i<n;i++){
    dp[i]=fmin(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  printf("%d",dp[n-1]);
  return 0;
}

Measured memory_bytes: 896
# ==================== gcd   最大公約数
from fractions import gcd
#from math import gcd

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

l=[0]*(n+1)
r=[0]*(n+1)

for i in range(n):
    l[i+1]=gcd(l[i],a[i])
    r[n-i-1]=gcd(r[n-i],a[n-i-1])

mimax=1
for i in range(n):
    mi=gcd(l[i],r[i+1])
    mimax=max(mi,mimax)
   
print(mimax)

Measured memory_bytes: 16132
#include <iostream>
 
using namespace std;
 
int main() {
  int D;
  cin >> D;
  
  if (D == 22) {
    cout << "Christmas Eve Eve Eve" << endl;
  } else if (D == 23) {
    cout << "Christmas Eve Eve" << endl;
  } else if (D == 24) {
    cout << "Christmas Eve" << endl;
  } else {
    cout << "Christmas" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
typedef long long ll;
using namespace std;

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;
const double PI=3.1415926535897932;

ll N, ans=0, tmp=0;
vector<ll> A;

ll gcd(ll a, ll b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

signed main(){
    cin >> N;
    cout << lcm(N, 360)/N << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
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; }
const ll MOD = 1e9+7;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i,N){
        ll a;
        cin >> a;
        A[i] = a;
    }

    bool fail = false;

    if(A[0] != 0)
        fail = true;

    //if(N == 1){
    //}

    ll last = A[N-1];
    for(int i = N-2; i >= 0; i--){
        ll a = A[i];
        if(last - a > 1)
            fail = true;
        last = a;
    }

    ll ans = 0;
    last = A[N-1];
    ans += last;
    for(int i = N-2; i >= 0; i--){
        ll a = A[i];
        if(last - a == 0){
            ans += a; 
        }
        else if(last - a < 0){
            ans += a;
        }
        last = a;
    }

    if(fail)
        cout << -1 << endl;
    else
        cout << ans << endl;

    return 0;

}


Measured memory_bytes: 1792
s = list(input())
k =  int(input())
s.append((''))
Dict = {}
dict_keys = []
for left in range(len(s)):
    for right in range(left+1,len(s)):
        string = ''.join(s[left:right])
        if len(string)>k:
            break
        if string not in Dict.keys():
            Dict[string] = True
Dict = sorted(Dict.keys())
print(Dict[k-1])

Measured memory_bytes: 4980
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<iomanip>
#include<map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = 1e9 + 7;
int dx[8] = { 1,0,-1,0,1,1,-1,-1 };
int dy[8] = { 0,1,0,-1,1,-1,1,-1 };




int main() { 	
	
	int x;
	cin >> x;

	if (x < 1200) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ARC" << endl;
	}


	return 0;
}

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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node *NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while(cur != nil){
    if(cur->key == key)break;
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = (NodePointer)malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if(cur == nil)break;
    if(isf == 0)printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  if(t == nil)return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFist(){
  NodePointer t = nil->next;
  if(t==nil)return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if(t == nil)return;
  deleteNode(t);
}

void deleteKey(int key){
  NodePointer t = listSearch(key);
  if(t != nil)deleteNode(t);
}

void insert(int key){
  NodePointer x;
  x = (NodePointer)malloc(sizeof(struct node));
  x->key = key;
  x->prev = nil;
  x->next = nil->next;
  x->next->prev = x;
  nil->next = x;
}

void aaaaa(int a){
  int i;
  for(i=0; i<a; i++){}
  for(;i>=0; i--){}
}

int main(){
  int key, n, i, a=3;
  int size  = 0;
  char com[20];
  int np = 0;
  int nd = 0;
  scanf("%d", &n);
  init();
  for(i=0; i<n; i++){
    scanf("%s%d", com, &key);
    if(com[0] == 'i'){
      insert(key);
      np++;
      size++;
    }
    else if(com[0] == 'd'){
      if(strlen(com) >6){
	if(com[6] == 'F')deleteFist();
	else if(com[6] == 'L')deleteLast();
      }
      else{
	deleteKey(key);
	nd++;
      }
      size--;
    }
  }
  printList();

  aaaaa(a);
  return 0;
}



Measured memory_bytes: 32984
from sys import stdin, setrecursionlimit

setrecursionlimit(10 ** 9)


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


N, M = map(int, input().split())
H = list(map(int, input().split()))
ans = [True] * N
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a] < H[b]:
        ans[a] = False
    elif H[a] > H[b]:
        ans[b] = False
    else:
        ans[a] = False
        ans[b] = False

print(sum(ans))


Measured memory_bytes: 20148
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n;
  cin >> n;
  VI a(n);
  REP(i, n) cin >> a[i];

  VI dp1(n);
  dp1[0] = a[0]==0?INF:-1;
  FOR(i, 1, n) {
    if(a[i] == 0) dp1[i] = INF;
    else if(a[i] > 0) dp1[i] = dp1[i-1] - 1;
    else if(a[i] < 0) dp1[i] = min(dp1[i-1]-1, -a[i]-1);
  }

  VI dp2(n);
  dp2[n-1] = a[n-1]==0?INF:-1;
  for(int i=n-2; i>=0; --i) {
    if(a[i] == 0) dp2[i] = INF;
    else if(a[i] > 0) dp2[i] = dp2[i+1] - 1;
    else if(a[i] < 0) dp2[i] = min(dp2[i+1]-1, -a[i]-1);
  }

  // cout << dp2 << endl;

  int ret = 0;
  REP(i, n) {
    if(a[i] > 0) {
      // 0-indexなので+1
      ret += min(a[i]-1, max({-1LL, dp1[i], dp2[i]})) + 1;
    }
  }

  cout << ret << endl;

  return 0;
}



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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
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();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------

int N;
int a[MAX];
LL ans;


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;
    REP(i,N){
        cin >> a[i];
        ans += a[i] - 1;
    }


    cout << ans << endl;




    return 0;
}


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

#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define rep(i, n) FOR(i, 0, n)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;

int main(void){
	int a, b;
	cin >> a >> b;
	if(a < 10 && b < 10){
		co(a*b);
	}else{
		co(-1);
	}

	return 0;
}


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

#define rep(i, u) for (int i = 0; i < u; i++)

using ll = long long;
using ull = unsigned long long;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << fixed << setprecision(8) << a * b * sin(c * M_PI / 180) / 2 << endl;
  cout << fixed << setprecision(8) << a + b + sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(c * M_PI / 180)) << endl;
  cout << fixed << setprecision(8) << b * sin(c * M_PI / 180) << endl;
  return 0;
}



Measured memory_bytes: 3424
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
ll h[100000];
ll dp[100000];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> h[i];
	fill(dp, dp + N, 1LL << 60);
	dp[0] = 0;
	for (int i = 0; i < N; i++) {
		if (i + 1 < N) {
			dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
		}
		if (i + 2 < N) {
			dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
		}
	}
	cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define fori(j,n) for(ll i=j;i<n;i++)
#define forb(n,j) for(ll i=n-1;i>=0;i--)
#define endl "\n"
#define pb push_back
#define ll long long
#define mp make_pair
#define ff first
#define ss second
#define vec vector<int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

ll sgn(ll x){
    if(x>0)
        return 1;
    if(x==0)
        return 0;
    return -1;
}
//const ll N = 2e5 + 5;
int main()
{
    IOS;
    double n;
    cin>>n;
    ll x = ceil(n/1000);
    cout<<(x*1000)-n;
    return 0;
}




Measured memory_bytes: 3756
#include<cstdio>
#include<algorithm>
using namespace std;
typedef pair<int,int> pii;
const int MAXN = 100005;
pii A[MAXN];

int main(){
  	int N;
  	int a, b;
  	long long K;
  	long long sum = 0;
	scanf("%d %lld", &N, &K);
  	for ( int i=0; i < N; ++i ){
    	scanf("%d %d", &A[i].first, &A[i].second);
    }
  	sort( A, A + N );
  	for ( int i=0; i < N; ++i ){
    	if ( A[i].second >= K ){
        	printf("%d\n", A[i].first);
          	break;
        }
      	else {
        	K -= A[i].second;
        }
    }
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    string s, t;
    cin  >> s >> t;
    string ans = "";
    for(int i=0;i< n;i++){
         ans  += s.substr(i,1)+ t.substr(i,1);
    }
    cout  <<  ans << endl;
    return 0;
}

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

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

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define vuni(v) v.erase(unique(v.begin(), v.end()), v.end());
#define mins(m, s) m.insert(make_pair(s, 1));
#define mfin(m, s) m.find(s) != m.end()

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9 + 7;

int main() {
    int n, l, abs_min, ans;
    cin >> n >> l;
    abs_min = INF;
    ans = 0;
    for(int i = 0; i < n; i++) {
        int now = i + l;
        if(abs(now) < abs(abs_min)){
            abs_min = now;
        }
        ans += now;
    }
    cout << ans - abs_min << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

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

	bool check = true;
	rep(i, s.size()) {
		if (i % 2 == 0) {
			if (s[i] == 'L') {
				check = false;
			}
		}
		else {
			if(s[i] == 'R') {
				check = false;
			}
		}
	}

	if (check)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>
#include <complex>

using namespace std;

#define mod 998244353

long long int getpow(long long int x, long long int n)
{
	if(n == 0) return 1;
	if(n == 1) return x;
	long long int tmp = getpow(x, n / 2);
	if(n % 2 == 0) return (tmp * tmp) % mod;
	else return (((tmp * tmp) % mod) * x) % mod;
}

int main()
{
	int n;
	cin >> n;
	int cnt[100001] = {};
	int maxd = 0;
	long long int ans = 1;
	for(int i = 0; i < n; i++){
		int d;
		cin >> d;
		if(i == 0 && d != 0) ans = 0;
		cnt[d]++;
		maxd = max(maxd, d);
	}
	if(cnt[0] != 1){
		cout << 0 << endl;
		return 0;
	}
	for(int i = 1; i <= maxd; i++){
		ans = (ans * getpow(cnt[i - 1], cnt[i])) % mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;

class Program
{
    #region library
    static int n = 0;
    static int r = 0;
    static int c = 0;
    static int x = 0;
    static int y = 0;
    static string s = "";
    static string[] ss;
    static long sum = 0;
    static long cnt = 0;
    static long max = -1;
    static long min = 2147483647;
    static bool flg = false;
    static bool flg2 = false;
    static string alpha = "abcdefghijklmnopqrstuvwxyz";
    static int[] arr;
    static char[,] map;
    static int[,] imap;
    static string rl()
    {
        return Console.ReadLine();
    }
    static string[] rls()
    {
        return Console.ReadLine().Split();
    }
    static void wl(object obj = null)
    {
        Console.WriteLine(obj);
    }
    static void w(object obj)
    {
        Console.Write(obj);
    }
    static int Int(string s)
    {
        return int.Parse(s);
    }
    static void yes()
    {
        wl("YES");
    }
    static void no()
    {
        wl("NO");
    }
    static void Sum()
    {
        wl(sum);
    }
    static void Cnt()
    {
        wl(cnt);
    }
    static void setarray(int num = -1)
    {
        if (n == 0)
        {
            n = Int(rl());
        }
        arr = new int[n];
        if (num == -1) ss = rls();
        for (int i = 0; i < n; i++)
        {
            if (num == -1)
                arr[i] = Int(ss[i]);
            else
                arr[i] = num;
        }
    }
    static void setmap(char def = '@')
    {
        if (r == 0 && c == 0)
        {
            ss = rls();
            r = Int(ss[0]);
            c = Int(ss[1]);
        }
        map = new char[r, c];
        for (int i = 0; i < r; i++)
        {
            if (def == '@') s = rl();
            for (int j = 0; j < c; j++)
            {
                map[i, j] = (def == '@') ? s[j] : def;
            }
        }
    }
    static void setimap(int def = -1)
    {
        if (r == 0 && c == 0)
        {
            ss = rls();
            r = Int(ss[0]);
            c = Int(ss[1]);
        }
        imap = new int[r, c];
        for (int i = 0; i < r; i++)
        {
            if (def == -1) s = rl();
            for (int j = 0; j < c; j++)
            {
                imap[i, j] = (def == -1) ? Int(s[j].ToString()) : def;
            }
        }
    }
    #endregion

    static void Main(string[] args)
    {
        setarray();
        for (int i = 0; i < n; i++)
        {
            sum += arr[i] - 1;
        }
        Sum();
    }
}



Measured memory_bytes: 11476