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

using namespace std;

int N;
pair<int, int> StonesInfo[100000];

int main() {
	int num, curPos, sum;
	
	while (cin >> N, N) {
		cin >> num;
		StonesInfo[0] = { num,1 };
		curPos = 0;
		for (int i = 2; i <= N; ++i) {
			cin >> num;
			if ((i & 1) == 1) {
				if (StonesInfo[curPos].first == num) {
					++StonesInfo[curPos].second;
				}
				else {
					++curPos;
					StonesInfo[curPos] = { num,1 };
				}
				continue;
			}

			if (StonesInfo[curPos].first == num) {
				++StonesInfo[curPos].second;
				continue;
			}
			if (curPos == 0) {
				StonesInfo[curPos].first = num;
				++StonesInfo[curPos].second;
			}
			else {
				StonesInfo[curPos - 1].second += StonesInfo[curPos].second + 1;
				--curPos;
			}
		}
		sum = 0;
		for (int i = 0; i <= curPos; ++i) {
			if (StonesInfo[i].first == 0) {
				sum += StonesInfo[i].second;
			}
		}
		cout << sum << endl;
	}

	return 0;
}


Measured memory_bytes: 3784
import java.util.Scanner;


public class Main{
	
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int a, b;
		while(sc.hasNextInt()) {
			a = sc.nextInt();
			b = sc.nextInt();
			System.out.println(numOfDigit(a+b));
		}
		sc.close();
	}
	
	static int numOfDigit(int n) {
		return (int) Math.log10(n) + 1;
	}
}

Measured memory_bytes: 20404
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, k; cin >> n >> k;
    ll total = 0;
    reprr(i, k, n + 2) {
        ll min_num = (i - 1) * i / 2;
        ll max_num = (n * (n + 1) - (n - i) * (n - i + 1)) / 2;
        //cout << i << ": " << min_num << " " << max_num << endl;
        total = (total + ((max_num - min_num) + 1)) % (ll)(1e9 + 7);
    }

    cout << total << endl;
    return 0;
}

Measured memory_bytes: 3632
s = input()
a = int(s[:2])
b = int(s[2:])

if 0<a<13:
    if 0<b<13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 0<b<13:
        print("YYMM")
    else:
        print("NA")


Measured memory_bytes: 8972
from collections import deque
n, m = map(int, input().split())
rinsetsu_lis = [[] for _ in range(n+1)]
for _ in range(m):
    a,b = map(int, input().split())
    rinsetsu_lis[a].append(b)
    rinsetsu_lis[b].append(a)
l= deque([1])
unvisit= [True]*(n+1)
unvisit[1] = False
anslis = [0]*(n+1)
while len(l) != 0:
    now = l.popleft()
    for r in rinsetsu_lis[now]:
        if unvisit[r]:
            unvisit[r] = False
            l.append(r)
            anslis[r] = now
print("Yes")
for i in range(2,len(anslis)):
    print(anslis[i])

Measured memory_bytes: 94900
// Why do we fall ? So we can learn to pick ourselves up.
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] dd = new int[n];
        for(int i=0; i<n; i++){
            dd[i] = sc.nextInt();
        }
        int ss = 0;
        for(int i=0; i<n; i++){
            for(int j=i+1; j<n ;j++){
                ss += dd[i]*dd[j];
            }
        }
        System.out.println(ss);
    }
}

Measured memory_bytes: 21716
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	w := make([]int, n)
	for i := range w {
		fmt.Scan(&w[i])
	}

	fmt.Println(search(1, 1000000000, n, k, w))
}

func canLoadAll(maxWeight, k, n int, w []int) bool {
	trackCount := 0
	i := 0
	for i < n {
		weight := 0
		for i < n && weight+w[i] <= maxWeight {
			weight += w[i]
			i++
		}
		trackCount++
		if trackCount > k {
			return false
		}
	}

	return true
}

func search(lower, upper, n, k int, w []int) int {
	l := lower
	u := upper
	for u-l != 1 {
		middle := (u-l)/2 + l
		if canLoadAll(middle, k, n, w) {
			u = middle
		} else {
			l = middle
		}
	}

	if canLoadAll(l, k, n, w) {
		return l
	} else {
		return u
	}
}

Measured memory_bytes: 5932
n = int(input())
a_list = list(map(int,input().split()))
b_list = [0]*(n)

for i in range(n):
    k = int(n-i-1)
    if a_list[k] != sum(b_list[k::k+1])%2:
        b_list[k] = 1

b_list = [i+1 for i,x in enumerate(b_list) if x ==1]
x = len(b_list)
print(x)
if x != 0:
    print(*b_list)

Measured memory_bytes: 12728
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
from bisect import bisect_left
from itertools import product
import math
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def LF(): return list(map(float, input().split()))
def LC(): return [c for c in input().split()]
def LLI(n): return [LI() for _ in range(n)]
def NSTR(n): return [input() for _ in range(n)]

def array2d(N, M, initial=0):
    return [[initial]*M for _ in range(N)]

def copy2d(orig, N, M):
    ret = array2d(N, M)
    for i in range(N):
        for j in range(M):
            ret[i][j] = orig[i][j]
    return ret


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


def main():
    N, K = MAP()
    A = LI()

    if K == 0:
        print(max(A))
        return

    # 決め打ち二分探索
    left = 0
    right = 10**9+7
    # for i in range(100):
    while right - left > 1:
        mid = (right + left) // 2
        count = 0
        for a in A:
            count += int(math.ceil(a / mid))-1
        if count <= K:
            right = mid
        else:
            left = mid
    # print(int(math.ceil(left)))
    print(right)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 104352
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N = 0,x = 0;
  cin >> N;
  rep(i,10){
    x = pow(2,i);
    if(N < x){
      cout << x/2;
      return 0;
    }
  }
}

Measured memory_bytes: 256
k = input()
a, b = input().split()

for cnt in range(int(b)):
    if cnt+1 >= int(a):
       # print(cnt+1,int(k),int(cnt+1) % int(k))

        if int(cnt+1)% int(k) == 0 or int(k) == 1:
            print("OK")
            exit()
print("NG")

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
using ll=int64_t;
using vll=vector<ll>;
using vi=vector<int>;
int main(){
  int n,i,ans=0;
  cin>>n;
  vi v(n),c(n);
  for(i=0;i<n;i++) cin>>v.at(i);
  for(i=0;i<n;i++){
    cin>>c.at(i);
    if(c.at(i)<v.at(i)) ans+=v.at(i)-c.at(i);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        while(true){
            String line = sc.next();
            if(line.equals("-")){
                break;
            }else{
                int shuffleCount = sc.nextInt();
                for(int i = 0; i < shuffleCount; i++){
                    int cp = sc.nextInt();
                    line = shuffle(cp,line);
                }
                System.out.println(line);
            }
        }
        
    }
    public static String shuffle(int cuttingPoint, String line){
        return line.substring(cuttingPoint) + line.substring(0, cuttingPoint);
    }
}


Measured memory_bytes: 26276
# import sys
# sys.setrecursionlimit(10 ** 6)
import bisect
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N, Ps, Qs):
    def dfs(s, perm):
        if len(s) == N + 1:
            perm.append(int(s))
            return perm
        for i in range(1, N + 1):
            if not str(i) in s:
                perm = dfs(s + str(i), perm)
        return perm

    perm = dfs('0', [])

    p = int(''.join(Ps))
    q = int(''.join(Qs))

    print(abs(bisect.bisect_right(perm, p) - bisect.bisect_right(perm, q)))


if __name__ == '__main__':
    N = int(input())
    Ps = input().split()
    Qs = input().split()
    solve(N, Ps, Qs)


Measured memory_bytes: 4676
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a[n+1],t,c[n],s = 0;
	for(int i = 1 ; i <= n ; i++)
		cin >> a[i];
	for(int i = 1 ; i <= n ; i++){
		cin >> t;s+=t;
	}
	for(int i = 1 ; i <= n-1 ; i++)
		cin >> c[i];
	for(int i = 1 ; i <= n-1 ; i++){
		if(a[i] + 1 == a[i+1]){
			s += c[a[i]];
		//	cout << c[i] << endl;
		}
	}
	cout << s ;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



l, r = LI()
ret = INF
if r - l >= 2019:
    print(0)
else:
    for i in range(l, r+1):
        for j in range(l, r+1):
            if i == j:
                continue
            ret = min(ret, i % 2019 * j % 2019)
    print(ret)

Measured memory_bytes: 41196
#include <stdio.h>  
  
#define N 20  
  
char stack[N];  
int ps;  
  
void push(char c)  
{  
    stack[ps++] = c;  
}  
  
char pop()  
{  
    return stack[--ps];  
}  
  
int main(void)  
{  
    char c;  
  
    ps = 0;  
  
    for(;;) {  
        c = getchar();  
        if(c == '\n' || c == EOF) {  
            while(ps)  
                putchar(pop());  
            if(c != EOF)  
                putchar(c);  
        } else  
            push(c);  
  
        if(c == EOF)  
            break;  
    }  
  
    return 0;  
}  


Measured memory_bytes: 2024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if (a >= k) cout << k << endl;
    else if (a+b >= k) cout << a << endl;
    else {
        cout << a - (k-(a+b)) << endl;
    }
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void){

	int mid,final,re,tot;
	
	while(1){
		scanf("%d",&mid);
		scanf("%d",&final);
		scanf("%d",&re);
		tot=mid+final;
		
		if(mid==-1&&final==-1&&re==-1){
			break;
		}else if(mid==-1||final==-1||tot<30){
			printf("F\n");
		}else if(tot<50){
			if(re>=50){
				printf("C\n");	
			}else{
				printf("D\n");
			}
		}else if(tot<65){
			printf("C\n");
		}else if(tot<80){
			printf("B\n");
		}else{
			printf("A\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 2672
import java.lang.Math.*;
import java.util.Scanner;
import java.util.Arrays;

class Main{
    public static void main(String[] args){
	final Scanner sc = new Scanner(System.in);
	int n=sc.nextInt();
	int[] a=new int[3]; 
	for(int i=0;i<n;i++){
	    a[0]=sc.nextInt();
	    a[1]=sc.nextInt();
	    a[2]=sc.nextInt();
	    Arrays.sort(a);	    
	    if(Math.pow(a[2],2)==Math.pow(a[0],2)+Math.pow(a[1],2)) System.out.println("YES");
	    else System.out.println("NO");
	}
    }
}

Measured memory_bytes: 23412
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt(); //出来上がる焼き鳥の本数
		int Kushi = 2*N;	//串の本数
		ArrayList<Integer> L = new ArrayList<Integer>(); //串の長さ一覧
		int KK = 0;

		for(int i=0; i < Kushi; i++){
			L.add(sc.nextInt());
		}
		Collections.sort(L); 

		for(int i=0; i<Kushi; i+= 2){
			KK += L.get(i);
		}
		
		System.out.println(KK);
	}
}

Measured memory_bytes: 9940
import Data.List
import Control.Monad
import Control.Applicative

data Card = S Int | H Int | C Int | D Int deriving (Show, Eq, Ord)

readCards :: IO [Card]
readCards =
    map rd . lines <$> getContents 
    where
    rd :: String -> Card
    rd l =
        case (words l) of
            ["S", n] -> S (read n)
            ["H", n] -> H (read n)
            ["C", n] -> C (read n)
            ["D", n] -> D (read n)
            _ -> undefined

main = do
    _ <- getLine
    cards <- readCards
    let suit = concat [map f [1..13] | f<-[S,H,C,D]]
    mapM_ print (suit \\ cards)

Measured memory_bytes: 4012
#include<bits/stdc++.h>
#define ll                      long long int
#define pb                      push_back
#define mp                      make_pair
#define in                      insert
#define all(x)                  (x).begin(),(x).end() 
#define rep(i,a,n)              for(int i=0;i<n;++i)
#define per(i,a,n)              for(int i=n-1;i>=0;--i)
#define mod                     1000000007
using namespace std;

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

	int n;
	cin>>n;
	int a[n];
	rep(i,0,n) cin>>a[i];
	int mx=-1;
	rep(i,0,n) if(a[i]>mx) mx=a[i];
	ll freq[mx+1]={0};
	rep(i,0,n) freq[a[i]]++;
	ll sum=0;
	for(ll i=0;i<=mx;++i){
		sum+=(freq[i])*(freq[i]-1)/2;
	}

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

		cout<<sum-(freq[a[i]]-1)<<'\n';
	}


    
    return 0;
}


Measured memory_bytes: 4864
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

int n;
int p[200005];
int fr[200005];//数字iより前は前に寄せる操作で揃える時、何回の操作が必要か
int bk[200005];

//[i]番目を前に持って行く時、
int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &p[i]);
	}
	std::set<int> left;
	for(int i = 0; i < n; i++){
		auto it = left.upper_bound(p[i]);
		if(it == left.end()){
			bk[p[i]] = 0;
		}else{
			bk[p[i]] = n - *it + 1;
		}
		left.insert(p[i]);
	}
	std::set<int> right;
	for(int i = n-1; i >= 0; i--){
		right.insert(p[i]);
		auto it = right.lower_bound(p[i]);
		if(it == right.begin()){
			fr[p[i]] = 0;
		}else{
			it--;
			fr[p[i]] = *it;
		}
	}
	for(int i = 1; i <= n; i++){
		fr[i] = std::max(fr[i], fr[i-1]);
	}
	for(int i = n; i > 0; i--){
		bk[i] = std::max(bk[i], bk[i+1]);
	}
	/*
	for(int i = 1; i <= n; i++){
		printf("%3d ", fr[i]);
	}
	printf("\n");
	for(int i = 1; i <= n; i++){
		printf("%3d ", bk[i]);
	}
	printf("\n");
	//*/
	int ans = INF;
	for(int i = 1; i <= n; i++){
		ans = std::min(ans, fr[i] + bk[i]);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 21376
#include <stdio.h>
int main (void){
  int max[3]={0};
  int cont,i;
  for(i=0;i<10;i++){
    scanf("%d",&cont);
    if(max[0]<cont){
      max[2]=max[1];
      max[1]=max[0];
      max[0]=cont;
    }
    else if(max[1]<cont){
      max[2]=max[1];
      max[1]=cont;
    }
    else if(max[2]<cont)
      max[2]=cont;
  }
  for(i=0;i<3;i++)
    printf("%d\n",max[i]);
  return (0);
}

Measured memory_bytes: 600
#include <iostream>
#include <cmath>
#include <stdint.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
using namespace std;
 
#define int long long
#define INF (1e18)+1
 
int nChoosek( int n, int k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    int result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i; 
    }
    return result;
}

int choose2(int n){
	
	return n*(n-1)/2;
}
 
 
int log(int num){
	
	if(num == 1){ 
		return 1;
	}
	
	int div = floor(num/2);
	
	return (log(div) + log(div) + 1);
	
}

int arr[2000001];

void loop(int num){
	
 	for(int i=1;i<=num; i++){
 		
 		
	 	
 		
	}
	
}
 
int32_t main() {
 
    int H;
    
    cin >> H;
   
   cout << log(H) << endl;
}

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

int main(){
        int n;
        int a[100010];
        int MaxNum=0,MinNum=100010,ans=0;
        int count[100010]={0};

        cin>>n;
        for(int i=0; i<n; i++) {
                cin>>a[i];
                ++count[a[i]];
                MaxNum=max(MaxNum,a[i]);
                MinNum=min(MinNum,a[i]);
        }

        for(int i=max(1,MinNum-1); i<max(2,MaxNum); i++) ans=max(ans,count[i-1]+count[i]+count[i+1]);

        cout<<ans<<endl;

	return 0;
}


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

int main(void){
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  for(int i = a; i >= 0; i--){
    if(i * 500 > x) continue;
    for(int j = b; j >= 0; j--){
      if(i * 500 + j * 100 > x) continue;
      for(int k = c; k >= 0; k--){
	if(i * 500 + j * 100 + k * 50 == x) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long n){
    char N = to_string(n).back();
    if (N == '2' || N == '4' || N == '5' || N == '7' || N == '9') {
        cout << "hon" << endl;
    } else if (N == '0' || N == '1' || N == '6' || N == '8') {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int n,d;
  cin>>n>>d;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i],a[i]--;
  Int ans=0;
  for(Int i=0;i<n;i++) ans^=a[i]%(d+1);
  cout<<(ans?"First":"Second")<<endl;
  return 0;
}



Measured memory_bytes: 4808
#include<bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint(){
    int x=0,p=1;char c=getchar();
    while (c<=32)c=getchar();
    if(c==45)p=-p,c=getchar();
    while (c>32)x=x*10+c-48,c=getchar();
    return x*p;
}
using namespace std;
//ruogu
//
int main(){
	int n=getint(),m=getint();
	for(int i=m-n+1;i<=m+n-1;i++)cout<<i<<" ";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e9)
using namespace std;
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,A,B;
    cin >> N;
    if(N == 1){
        print("Hello World");
    }else{
        cin >> A >> B;
        print(A+B);
    }

}


Measured memory_bytes: 896
#include <iostream>
using namespace std;
typedef unsigned long long ull;

#define MAX_N 100000
#define MOD 1000000007
int N;
ull T[MAX_N+2], A[MAX_N+2];
bool flagT[MAX_N] = {false}, flagA[MAX_N] = {false};

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

    cin >> N;
    T[0] = 0;
    A[N+1] = 0;
    for(int i=1; i<=N; i++) cin >> T[i];
    for(int i=1; i<=N; i++) cin >> A[i];

    for(int i=0; i<N; i++){
        if(T[i+1] > T[i]) flagT[i+1] = true;
    }
    for(int i=2; i<N+2; i++){
        if(A[i-1] > A[i]) flagA[i-1] = true;
    }

    ull ans = 1;
    for(int i=1; i<=N; i++){
        if(!flagT[i] && !flagA[i]) {
            ans = (ans * min(A[i], T[i])) % MOD;
        }else if((!flagT[i] && flagA[i] && A[i] > T[i]) || 
                (flagT[i] && !flagA[i] && A[i] < T[i]) ||
                (flagT[i] && flagA[i] && A[i] != T[i])){
           cout << 0 << endl;
           return 0;
        }
    }
    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
#define MANX 100000

int main(){
    int N;
    int A[MANX];
    cin >> N;
    rep(i,N) cin >> A[i];
    int a[3];
    rep(i,3)a[i] = 0;
    int count = 0;
    ll ans = 1;
    for(int i=0;i<N;i++){
        int c = 0;
        rep(j,3){
            if(c==0&&A[i]==a[j]){
                a[j]++;
                count++;
                c = 1;
            }else if(A[i]==a[j]){
                count++;
            }
        }
        ans *= count;
        ans %= MOD;
        count=0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define vd vector<double>
#define vs vector<string>
#define mii map<int, int>

void show(auto a){
  int i = 0;
  while(i < a.size()){
    cout<<a[i]<<" ";
    i++;
  }
  cout<<endl;
}


int main(){
  ios_base::sync_with_stdio(false);

  int n;
  cin>>n;
  vd a(n, 0);
  for(int i = 0; i < n; i++) cin>>a[i];

  double dp[n+1][n+1];
   for(int i = 0; i <= n; i++){
  	for(int j = 0; j <= n; j++){
  		dp[i][j] = 0;
  	}
  	
  }
	
  dp[1][0] = 1-a[0];
  dp[1][1] = a[0];
	// dp[i][j] means the total probability
	// of getting j heads in i items
  for(int i = 2; i <= n; i++){
  	for(int j = 0; j <= i; j++){
  		if(i == j) dp[i][j] = dp[i-1][j-1]*a[i-1];
  		else if(j == 0) dp[i][j] = dp[i-1][j]*(1-a[i-1]);
  		else dp[i][j] = (dp[i-1][j]*(1-a[i-1]) + dp[i-1][j-1]*(a[i-1]));
  	}
  }


  double ans = 0;
  
  for(int j = n/2+1; j <= n; j++){
  	ans += dp[n][j];
  }
  cout<<setprecision(10);
  cout<<fixed;

  cout<<ans<<endl;

  



}

Measured memory_bytes: 70656
var s:ansistring;
    v:array[char(0)..char(255)]of boolean;
    c:char;
    i:longint;
begin
  readln(s);
  for i:=1 to length(s) do
  v[s[i]]:=true;
  for c:='a' to 'z' do
  if not v[c] then
  begin
    writeln(c);
    exit;
  end;
  writeln('None');
end.

Measured memory_bytes: 256
#coding:UTF-8
a = input()
b = a.split(" ")
num = int(b[0])
gram = int(b[1])
s = list()
for i in range(num):
  s.append(input())
s_i = [int(ss) for ss in s]
s_i.sort()
for i in range(len(s_i)):
  gram = gram-s_i[i]
work = gram//s_i[0]
print(num+work)

Measured memory_bytes: 3064
import sys
import numpy as np

n, m = map(float, input().split())
lines = sys.stdin.readlines()
lines = [list(map(float, line.strip().split())) for line in lines]
lines.sort()
price = 0
for line in lines:
    if m - line[1] > 0:
        price += line[0] * line[1]
        m -= line[1]
    else:
        price += line[0] * m
        break
print(int(price))

Measured memory_bytes: 42584
#include<bits/stdc++.h>
using namespace std;
int main()
{
    
    int a,b;
    cin>>a>>b;
    
    for(int i=1;i<=1500;i++)
    {
       if ((i * 8) / 100 == a && (i * 10) / 100 == b) {
            cout << i << endl; return 0;}
        
    }
    
    
    cout<<-1<<endl;

        
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N ;
 
  cin >> N ;
 
  vector<int> a(N);
 
  for(int i=0;i<N;i++) cin >> a.at(i);//入力終了
 
  int ans=0,j=0;
 
  while(1){
    int x=a.at(j);
    j=x-1;
    ans++;
    if(ans>=N){ans=-1; break;}
    if(j==1) break;
  }
 
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 640
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "main.cpp"

// generated by online-judge-template-generator v4.4.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
  bool x;
  std::cin >> x;
  std::cout << !x << std::endl;
  return 0;
}


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

int main(){
  while(1){
    int H, W;
    cin>>H>>W;
    if(H == 0 && W == 0) break;

    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        cout<<"#";
      }
      cout<<endl;
    }
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 3056
try:
    while True:
        for i in range(10000):
            a = input()
            taiga = 0
            if a == 0:
                break
            b = len(a)
            for c in range(b):
                taiga += int(a[c])
            if taiga == 0:
                continue
            else:
                print(taiga)
except EOFError:
    pass
        
        


Measured memory_bytes: 5604
#include <stdio.h>
#define N 100
int main(){
  int num=0,n,k;
  int A[N];
  int j,min,i;
  scanf("%d",&n);  
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  } 
  for(i=0;i<n-1;i++){
    min=i;
    for(j=i;j<n;j++){
      if(A[j]<A[min]) min=j;
    }
     if(i!=min) num++; 
    k=A[min];
    A[min]=A[i];
    A[i]=k;
     }
  for(k=0;k<n-1;k++){
    printf("%d ",A[k]);
  }
  printf("%d",A[n-1]);
  printf("\n");
  printf("%d\n",num);
  return 0;
}



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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    int ans = 0;
    while(true) {
        bool is_divisible = true;
        for(int i = 0; i < N; i++) {
            if(A.at(i) % 2 == 0) {
                A.at(i) /= 2;
            } else {
                is_divisible = false;
            }
        }
        if(is_divisible) {
            ans += 1;
        } else {
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))

//頂点数、スタート、隣接行列を引いて最短距離と経路を返す
//O(V^2)
double cost[1010][1010];
double daikusutorap[1010];
void daikusutora(ll n,ll s){
	ll*f=(ll*)malloc(n*sizeof(ll));
	rep(i,0,n){
		daikusutorap[i]=i==s?0:INF;
		f[i]=0;
	}
	rep(nnnnnn,1,n){
		ll m=INF,mv=-1;
		rep(i,0,n){
			if(!f[i]&&m>daikusutorap[i]){
				m=daikusutorap[i];
				mv=i;
			}
		}
		if(mv==-1)break;
		f[mv]=1;
		rep(i,0,n)if(daikusutorap[i]>daikusutorap[mv]+cost[mv][i]){
			daikusutorap[i]=daikusutorap[mv]+cost[mv][i];
		}
	}
	free(f);
}


double x[1010],y[1010],r[1010];
int main(){
	double sx,sy,gx,gy;
	scanf("%lf%lf%lf%lf",&sx,&sy,&gx,&gy);
	int n;
	scanf("%d",&n);
	n+=2;

	x[  0]=sx;y[  0]=sy;r[  0]=0;
	x[n-1]=gx;y[n-1]=gy;r[n-1]=0;
	
	rep(i,1,n-1)scanf("%lf%lf%lf",x+i,y+i,r+i);
	
	rep(i,0,n)rep(j,0,n){
		double d=hypot(x[i]-x[j],y[i]-y[j]);
		cost[i][j]=max(d-r[i]-r[j],0);
	}
	daikusutora(n,0);
	printf("%.15f\n",daikusutorap[n-1]);
	return 0;
}

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

int main() {
	int n;
	double ax,ay,bx,by,cx,cy,dx,dy;
	vector<int> r;
	cin >> n;
	for (int i=0; i<n; i++)
	{
		cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy;
		if (ax == bx)
		{
			cx == dx ? r.push_back(1) : r.push_back(0);
		} else if (cx == dx) {
			r.push_back(0);
		} else {
			(ay-by)/(ax-bx) == (cy-dy)/(cx-dx) ? r.push_back(1) : r.push_back(0);
		}
	}
	for (int i=0; i<n; i++)
	{
		r[i] == 1 ? cout << "YES" << endl : cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <set>
#define REP(i, a, n) for(int i = a; i <= n; i++)
using namespace std;
 
 
const int SIZE = 200001;
int N, a[SIZE], pos[SIZE];
long ans;
set<int> s;
 
int main(void) {
  cin >> N;
  REP(i, 1, N) {
    cin >> a[i];
    pos[a[i]] = i;
  }
 
  s.insert(0);
  s.insert(N + 1);
  ans = 0;
 
  REP(i, 1, N) {
    set<int>::iterator itr = s.lower_bound(pos[i]);
    int r = *itr - pos[i];
    int l = pos[i] - *(--itr);
    ans += (long) i * r * l;
    s.insert(pos[i]);
  }
 
  cout << ans << endl;
 
  return 0;
}

Measured memory_bytes: 11136
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define int long long
#define ld long double
#define all(x) x.begin(),x.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vstr vector<string>
#define vbool vector<bool>
#define vvi vector<vector<int> >
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define vpair vector<pii > 
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<<a[i]<<' ';}cout<<'\n'
#define mem(a,v) memset(a,v,sizeof(a))
#define loop(i,a,b) for (int i = a; i < b; i++)
#define loope(i,a,b) for (int i = a; i <= b; i++)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(9)
#define PI 3.14159265
#define S second
#define F first
#define CHECK cout<<"CHEDEDWB"<<endl
int mod = 1e9+7;
int inf = 1e18;
//int m_inf = INT_MIN;

int mnum(int n,int m)
{
	int sum = 0;
	while(m)
	{
		sum = sum*10 + n;
		m--;
	}
	return sum;
}

void solve()
{
	int a,b;
	cin>>a>>b;
	if(a>b)
		cout<<mnum(b,a)<<endl;
	else
		cout<<mnum(a,b)<<endl;
}

int32_t main()
{
	FastIO; PRECISION;
	int t = 1;
	//cin>>t;
	while(t--)
		solve();
	return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    int n,m,q;
    vector<vector<int>> g;
    vector<vector<pair<int,int>>> col,now;
    Problem(LL n, LL m):n(n),m(m),g(n),col (n,vector<pair<int,int>>(11,{-1,0})),now (n,vector<pair<int,int>>(11,{-1,0})){};

    void solve(){
        for(int i=0; i<m; ++i){
            int a,b;
            cin >> a >> b;
            --a;--b;
            g[a].push_back(b);
            g[b].push_back(a);
        }
        cin >> q;
        for(int i=0; i<q; ++i){
            int v,c,d;
            cin >> v >> d >> c;
            --v;
            col[v][d]={i,c};
        }
        for(int i=0; i<10; ++i){
            for(int j=0; j<n; ++j){
                for(int l=10-i; l>=1; --l){
                    if(col[j][l].first > col[j][l-1].first){
                        col[j][l-1]=col[j][l];
                    }
                }
                for(auto && v:g[j]){
                    for(int l=10-i; l>=1; --l){
                        if(col[j][l].first > col[v][l-1].first){
                            col[v][l-1]=col[j][l];
                        }
                    }
                }
            }
        }
        for(int i=0; i<n; ++i){
            cout << col[i][0].second<<endl;
        }

    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0,m;
    cin >> n >> m;

    Problem p(n,m);
    p.solve();
    return 0;
}



Measured memory_bytes: 29944
N = int(input())
S = [0]*N

for i in range(N):
    S[i] = input()

S = sorted(S)
S.append(-1)

#print(S)

counta = []

times = 1
for i in range(1, N+1):
    if S[i-1] == S[i]:
        times += 1
    else:
        counta.append((times, i-1))
        times = 1

#print(counta)

M = max(counta, key=lambda x: x[0])[0]

#print(M)

for i in range(len(counta)):
    if counta[i][0] == M:
        print(S[counta[i][1]])

Measured memory_bytes: 39296
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


h,w = list(map(int, input().split()))
data= []
rs = []
cs = []
for i in range(h):
    c = input()
    if "S" in c:
        start = (i, c.index("S"))
    if "T" in c:
        goal = (i, c.index("T"))
    for j in range(w):
        if c[j] in ("o"):#, "S", "T"):
            data.append(1)
            rs.append(i)
            cs.append(h+j)
            data.append(1)
            rs.append(h+j)
            cs.append(i)
s = h+w
t = h+w+1
V = 10**9
data.append(V)
rs.append(s)
cs.append(start[0])
data.append(V)
rs.append(start[0])
cs.append(s)

data.append(V)
rs.append(s)
cs.append(start[1]+h)
data.append(V)
rs.append(start[1]+h)
cs.append(s)

data.append(V)
rs.append(goal[0])
cs.append(t)
data.append(V)
rs.append(t)
cs.append(goal[0])

data.append(V)
rs.append(t)
cs.append(goal[1]+h)
data.append(V)
rs.append(goal[1]+h)
cs.append(t)

import scipy.sparse
m = scipy.sparse.csr_matrix((data, (rs, cs)), shape=(h+w+2,h+w+2))
val = scipy.sparse.csgraph.maximum_flow(m, s, t).flow_value
if val>=10**9:
    val = -1
print(val)

Measured memory_bytes: 39492
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>

using namespace std;

int main() {
	int N;
	scanf("%d", &N);

	// 現在の場所
	int now_t = 0, now_x = 0, now_y = 0;
	// 次に行く場所
	int t, x, y;

	for (int i = 0; i < N; i++) {
		scanf("%d %d %d", &t, &x, &y);

		// まず最低限必要な時間
		int rest_t = t - now_t - (abs(x - now_x) + abs(y - now_y));
		if (rest_t < 0 || rest_t % 2 == 1) {
			printf("No\n");
			return 0;
		}

		// 更新
		now_t = t;
		now_x = x;
		now_y = y;
	}

	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
#左右に'.'を余分に付けて標準入力からリストを作成
grid = [list('.'+input()+'.') for i in range(H)]
#上下にも付けてやる
grid.insert(0, list('.' * (W + 2)))
grid.append(list('.' * (W + 2)))
#答えを入れるリスト
ans = []
 
#付け足した行列はカウントしない
for i in range(1, H + 1):
  for j in range(1, W + 1):
    if grid[i][j] == '#':
      ans.append('#')
    else:
      #8方向にある'#'の数をカウント
      #付け足したのは'.'なので条件分岐は不要
      #str型で出力しなければjoinできない
      ans.append(str((grid[i-1][j-1:j+2]+grid[i][j-1:j+2]+grid[i+1][j-1:j+2]).count('#')))
  #一行終わったので改行を入れる
  ans.append('\n')
print(''.join(ans)) #リストをつないで出力

Measured memory_bytes: 3188
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
  int N, a;
  bool cond{1};
  cin >> N;
  map<int, int> m;
  vector<int> v;
  if (N % 3) {
    while (cin >> a) {
      if (a) {
        cond = 0;
        break;
      }
    }
  } else {
    while (cin >> a) {
      ++m[a];
      if (m[a] == N / 3) {
        v.push_back(a);
        m[a] = 0;
      }
    }
    cond = v.size() == 3 && !(v[0] ^ v[1] ^ v[2]);
  }

  cout << (cond ? "Yes" : "No") << endl;
}


Measured memory_bytes: 7132
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
    int h,w;
    int c[10][10] = {0};
    int a[200][200] = {0};

    cin >> h >> w;
    for(int i = 0; i < 10; i++)
    {
        for(int j = 0; j < 10; j++)
        {
            cin >> c[i][j];
        }
    }
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            cin >> a[i][j];
        }
    }

    int dist[10][10] = {0};
    for(int i = 0; i < 10; i++)
    {
        for(int j = 0; j < 10; j++)
        {
            dist[i][j] = c[i][j];
        }
    }

    for(int k = 0; k < 10; k++)
    {
        for(int i = 0; i < 10; i++)
        {
            for(int j = 0; j < 10; j++)
            {
                if (dist[i][j] > dist[i][k] + dist[k][j])
                {
                    dist[i][j] = dist[i][k] + dist[k][j];
                }
            }
        }
    }


    // for(int i = 0; i < 10; i++)
    // {
    //     for(int j = 0; j < 10; j++)
    //     {
    //         cout << dist[i][j] << " ";
    //     }
    //     printf("\n");
    // }

    int sol = 0;

    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            if (a[i][j] == 0 || (1 < a[i][j] && a[i][j] < 10))
            {
                sol += dist[a[i][j]][1];
            }
        }
    }

    cout << sol << endl;


    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>     
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
#define int ll
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
 
using namespace std;
 
const int maxn = (int)3e3 + 100;
const int N = (int)1e5 + 100;
const int mod = (int)1e9 + 7;
 
#define inf mod
 
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
 
int n, a[maxn],s[2]={1,-1};
int dp[maxn][maxn][2];
int calc(int l,int r,int step){
	if(l==r)
		return a[l]*s[step];
	int &res=dp[l][r][step];
	if(res!=-1)
		return res;
	if(!step){
		res=-inf*inf;
		res=max(res,calc(l+1,r,step^1)+a[l]);
		res=max(res,calc(l,r-1,step^1)+a[r]);
	}else{
		res=inf*inf;
		res=min(res,calc(l+1,r,step^1)-a[l]);
		res=min(res,calc(l,r-1,step^1)-a[r]);
	}
	return res;
}
main () {
	cin>>n;
	forn(i,1,n)
		cin>>a[i];
	memset(dp,-1,sizeof(dp));
	cout<<calc(1,n,0);
}

Measured memory_bytes: 150528
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
int main(){

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

    int n;
    cin >> n;
   	bool isPrime[N+1];
	for(int i = 0; i <= N;++i) {
	    isPrime[i] = true;
	}
	isPrime[0] = false;
	isPrime[1] = false;
	for(int i = 2; i * i <= N; ++i) {
	     if(isPrime[i] == true) {                    //Mark all the multiples of i as composite numbers
	         for(int j = i * i; j <= N ;j += i)
	             isPrime[j] = false;
	    }
	}

	int start = n;
	int ans;
	// while(start<=end){
	// 	mid = start + (end - start)/2 ;
	// 	if(isPrime[mid]){
	// 		ans = mid;
	// 		end = mid -1;
	// 	}

	// }

	for(int i=n;i<=N;++i){
		if(isPrime[i]){
			ans = i;
			break;
		}
	}

	cout << ans << endl;



    

	return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const int INF = 1e9+7;


int dp[1<<26];
int main(){
	//ios_base::sync_with_stdio(false);
	int ans=INF;
	string s;

	cin >> s;

	Fill(dp, INF);
	dp[0] = 0;
	int bitsum = 0;
	for(auto c: s){
		int bit = (1 << (c - 'a'));
		bitsum ^= bit;
		rep(k,26) chmin(dp[bitsum], dp[bitsum^(1<<k)] + 1);
	}
	ans = max(1, dp[bitsum]);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 262788
#include<bits/stdc++.h>
using namespace std;
// 12 10
// --------------------------------------------------------------------------------
#define fast_IO	ios_base::sync_with_stio(false),cin.tie(NULL),cout.tie(NULL);
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b,k) for(int i=a;i<=b;i+=k)
#define frepj(a,b,k) for(int j=a;j<=b;j+=k)
// --------------------------------------------------------------------------------


void solve()
{
	int k;cin>>k;
	string s;cin>>s;
	for(int i=0;i<k && i<s.size();++i)
	{
		cout<<s[i];
	}
	if(s.size()>k)
		cout<<"...";
}

int main()
{
	// #ifndef ONLINE_JUDGE
 //    	freopen("/home/suryakant/input.txt","r",stdin);
 //        freopen("/home/suryakant/output.txt","w",stdout);
 //    #endif
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    
}

Measured memory_bytes: 3548
def main():
    k = int(input())

    if k % 2 == 0:
        print(-1)
        return

    n = 0
    i = 1
    while True:
        n %= k
        n = 10*n + 7
        if n % k == 0:
            print(i)
            return
        if k < i:
            print(-1)
            return
        i += 1

main()


Measured memory_bytes: 9152
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
long long A[200000];
long long dp[200000][5];
int main(){
  int L;
  cin >> L;
  for(int i = 0; i < L; i++){
    cin >> A[i];
  }

  if(A[0] == 0){
    dp[0][0] = A[0];
    dp[0][1] = 2;
    dp[0][2] = 1;
    dp[0][3] = 2;
    dp[0][4] = 0;
  } else {
    dp[0][0] = A[0];
    dp[0][1] = A[0] % 2;
    dp[0][2] = (A[0] % 2 + 1) % 2;
    dp[0][3] = A[0] % 2;
    dp[0][4] = A[0];
  }

  for(int i = 1; i < L; i++){
    dp[i][0] = A[i] + dp[i - 1][0];
    if(A[i] == 0){
      dp[i][1] = 2 + min(dp[i - 1][0], dp[i - 1][1]);
      dp[i][2] = 1 + min(dp[i - 1][0], min(dp[i - 1][1], dp[i - 1][2]));
      dp[i][3] = 2 + min(dp[i - 1][0], min(dp[i - 1][1], min(dp[i - 1][2], dp[i - 1][3])));
    } else {
      dp[i][1] = A[i] % 2 + min(dp[i - 1][0], dp[i - 1][1]);
      dp[i][2] = (A[i] % 2 + 1) % 2 + min(dp[i - 1][0], min(dp[i - 1][1], dp[i - 1][2]));
      dp[i][3] = A[i] % 2 + min(dp[i - 1][0], min(dp[i - 1][1], min(dp[i - 1][2], dp[i - 1][3])));
    }
    dp[i][4] = A[i] + min(dp[i - 1][0], min(dp[i - 1][1], min(dp[i - 1][2], min(dp[i - 1][3], dp[i - 1][4]))));
  }
  cout << min(dp[L - 1][0], min(dp[L - 1][1], min(dp[L - 1][2], min(dp[L - 1][3], dp[L - 1][4])))) << endl;
  return 0;
}


Measured memory_bytes: 9600
// Sakhiya07 - Yagnik Sakhiya

#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll pair<ll,ll>
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 200005;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
    ll n,k;
    cin >> n >> k;
    ll ans = 0;
    ll a[n];
    for(ll i=0;i<n;i++)   cin >> a[i];
    sort(a,a+n);
    for(ll i=0;i<k;i++)  ans += a[i];
    cout<<ans;   
}

int main()
{
    FAST;
    ll t = 1;
   // cin >> t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
 
int main() {

    int ans = 0;
    vector<int> dish(5);
    int last = 10;
    int lastt;

    for(int i = 0; i < 5; ++i){
        cin >> dish.at(i);
        if(last > dish.at(i)%10 && dish.at(i)%10 != 0){
            last = dish.at(i)%10;
            lastt = i;
        }
    }

    for(int i = 0; i < 5; ++i){
        if(i == lastt || dish.at(i)%10 == 0){
            ans += dish.at(i);
        }else{
            ans += dish.at(i) + (10-dish.at(i)%10);
        }
    }

    cout << ans << endl;

}

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

typedef long long ll;
//loop
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//STL
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

void Main() {
    int x,t;
    cin>>x>>t;
    int ans = (x - t) < 0 ? 0 : x - t;
    cout << ans <<endl;
}

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


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int n, m; 
	while (cin >> n >> m, n + m) {
		int needed = m / n;
		int a, ans = 0;
		for (int i = 0; i < n; ++i) {
			cin >> a;
			if (a >= needed) ans += needed;
			else ans += a;
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3108