akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int A;
int B;
int N = 100;
char res[100][101];
int main(){
  int KL2GvlyY, Lj4PdHRW;
  int i;
  int j;
  rd(A);A += (-1);
  rd(B);B += (-1);
  for(i=(0);i<(N);i++){
    for(j=(0);j<(N/2);j++){
      res[i][j] = '.';
    }
    for(j=(N/2);j<(N);j++){
      res[i][j] = '#';
    }
  }
  i = 0;
  j = N-1;
  for(Lj4PdHRW=(0);Lj4PdHRW<(A);Lj4PdHRW++){
    res[i][j] = '.';
    i += 2;
    if(i >= N){
      i = 0;
      j -= 2;
    }
  }
  i = j = 0;
  for(KL2GvlyY=(0);KL2GvlyY<(B);KL2GvlyY++){
    res[i][j] = '#';
    i += 2;
    if(i >= N){
      i = 0;
      j += 2;
    }
  }
  wt_L(N);
  wt_L(' ');
  wt_L(N);
  wt_L('\n');
  {
    int Q5VJL1cS;
    for(Q5VJL1cS=(0);Q5VJL1cS<(N);Q5VJL1cS++){
      wt_L(res[Q5VJL1cS]);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20190921-1

// --- original code ---
// int A, B;
// int N = 100;
// char res[100][101];
// {
//   int i, j;
//   rd(A--,B--);
//   rep(i,N){
//     rep(j,N/2) res[i][j] = '.';
//     rep(j,N/2,N) res[i][j] = '#';
//   }
//   i = 0; j = N-1;
//   rep(A){
//     res[i][j] = '.';
//     i += 2;
//     if(i >= N) i = 0, j -= 2;
//   }
//   i = j = 0;
//   rep(B){
//     res[i][j] = '#';
//     i += 2;
//     if(i >= N) i = 0, j += 2;
//   }
//   wt(N, N);
//   wtLn(res(N));
// }


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder200531
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inputs = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int[] indexes = null;
            try
            {
                indexes = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            }
            catch(Exception ex)
            {

            }
            int[] nums = Enumerable.Range(0, 102).ToArray();
            if (indexes != null)
            {
                foreach (int index in indexes)
                {
                    nums[index] = 99999;
                }
                nums = nums.Select(i => Math.Abs(i - inputs[0])).ToArray();

                int min = 99999;
                int minIndex = -1;
                for (int i = 0; i < nums.Length; i++)
                {
                    if (min > nums[i])
                    {
                        min = nums[i];
                        minIndex = i;
                    }
                }
                Console.WriteLine(minIndex);
            }
            else
            {
                Console.WriteLine(inputs[0]);
            }

        }
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  int sum = 0;
  
  for (int i=0;i < N;i++) {
    cin >> vec.at(i);
    sum += vec.at(i);
  }
  
  int count1=0;
  for (int i=0;i<N;i=i+2) {
    sort (vec.begin(),vec.end());
    reverse (vec.begin(),vec.end());
    count1 += vec.at(i);
  }
  
  cout << count1-(sum-count1) << endl;
}

Measured memory_bytes: 3640
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, X = nl()

M = []
for i in range(N):
    M.append(n())
M = sorted(M)

X -= sum(M)
print(N + X // M[0])


Measured memory_bytes: 3060
import java.util.Scanner;

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

	String s1 = scan.next();
	String s2 = scan.next();

	if(s1.charAt(0) == s2.charAt(2) &&
	   s1.charAt(1) == s2.charAt(1) &&
	   s1.charAt(2) == s2.charAt(0)){
	    System.out.println("YES");
	}else{
	    System.out.println("NO");
	}
    }
}


Measured memory_bytes: 21716
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
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)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,b,x = LI()
    if b-x/a**2 < x/a**2:
        print(math.atan(2*(b-x/a**2)/a)*180/math.pi)
    else:
        print(math.atan(a*b**2/2/x)*180/math.pi)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	N := getStdinInt()
	if N%1000 == 0 {
		fmt.Printf("%d\n", 0)
	} else {
		fmt.Printf("%d\n", 1000-N%1000)
	}
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2180
V,E = map(int,input().split())
 
boss = [i for i in range(V)]
height = [0 for i in range(V)]
 
def get_boss(index):
    if index == boss[index]:
        return index
    else:
        boss[index] = get_boss(boss[index])
        return boss[index]
 
 
def is_same_group(a,b):
    return get_boss(a) == get_boss(b)
 
def unite(x,y):
    boss_x = get_boss(x)
    boss_y = get_boss(y)
 
    if boss_x == boss_y:
        return
 
    if height[x] > height[y]:
 
        boss[boss_y] = boss_x
 
    elif height[x] < height[y]:
 
        boss[boss_x] = boss_y
 
    else:
        boss[boss_y] = boss_x
        height[x] += 1
 
 
for loop in range(E):
    A,B = map(int,input().split())
    unite(A,B)
 
num_query = int(input())
 
for loop in range(num_query):
    A,B = map(int,input().split())
    if is_same_group(A,B) == True:
        print("yes")
    else:
        print("no")


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

int main(){
  int A [3][3];
  for(int i=0;i<3;i++){
    for(int r=0;r<3;r++){
      cin >> A[i][r];
    }
  }
  int N;
  cin >> N;
  int B[N];
  for(int i=0;i<N;i++)cin >> B[i];
  for(int i=0;i<3;i++){
    for(int r=0;r<3;r++){
      for(int t=0;t<N;t++){
        if(A[i][r] == B[t])A[i][r]=0;
      }
    }
  }
  int a[3]={0,0,0};
  int b[3]={0,0,0};
  int c,d;
 
  c = A[0][0]+A[1][1]+A[2][2];
  d = A[0][2]+A[1][1]+A[2][0];
  for(int i=0;i<3;i++){
    for(int r=0;r<3;r++){
      a[i] += A[i][r];
      b[i] += A[r][i];
    }
  }
  int s=0;
  for(int i=0;i<3;i++){
    if(a[i]==0)s=1;
    if(b[i]==0)s=1;
  }
  if(c==0 || d==0)s=1;
  if(s==1)cout << "Yes" << endl;
  if(s==0)cout << "No" << endl;
}


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

int main(){
  long long int n,i,j,k,base=1,kotae=0,kari;
  cin>>n;
  long long int c0[61],c1[61];
  for(i=0;i<61;i++){
    c0[i]=0;
    c1[i]=0;
  }
  for(i=0;i<n;i++){
    cin>>k;
    for(j=0;k>0;j++){
      if(k%2==1){
        c1[j]++;
      }else{
        c0[j]++;
      }
      k/=2;
    }
    for(;j<61;j++){
      c0[j]++;
    }
  }
  for(i=0;i<61;i++){
    kari=base%1000000007;
    kari*=c0[i];
    kari%=1000000007;
    kari*=c1[i];
    kari%=1000000007;
    kotae+=kari;
    kotae%=1000000007;
    base*=2;
  }
  cout<<kotae;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;

public class Main {

	public static String decode (String str) {

		char[] c = str.toCharArray();
		for (int i = 0; i < 26; i++) {
			str = new String(c);
			if (str.indexOf("the") != -1 || str.indexOf("this") != -1 || str.indexOf("that") != -1) {
				return str;
			}
			for (int j = 0; j < str.length(); j++) {
				if ('a' <= c[j] && c[j] <= 'z') {
					if (c[j] == 'z') {
						c[j] = 'a';
					} else {
						c[j]++;
					}
				}
			}
		}
		return null;
	}

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

		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {
			String str = sc.nextLine();
			System.out.println(decode(str));
		}

	}

}

Measured memory_bytes: 11000
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();//height
		int w = sc.nextInt();//width
		char[][] path = new char[h][w];
		for (int i = 0; i < h; i++) {
			path[i] = sc.next().toCharArray();/// .  #
		}
		int cntBlack = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (path[i][j] == '#') {
					cntBlack++;
				}
			}
		}
		Set<Integer> seen = new HashSet<>();
		Deque<Integer> check = new ArrayDeque<>();
		Deque<Integer> cnt = new ArrayDeque<Integer>();
		int[] dx = { 1, 0, -1, 0 };
		int[] dy = { 0, 1, 0, -1 };
		check.addLast(0);
		cnt.addLast(0);
		int tmpp = 0, tmpc = 0;
		while (tmpp != h * w - 1 && !check.isEmpty()) {
			tmpp = check.removeFirst();
			tmpc = cnt.removeFirst();
			seen.add(tmpp);
			for (int i = 0; i < 4; i++) {
				int nx = tmpp / w + dx[i];
				int ny = tmpp % w + dy[i];
				if (0 <= nx && nx < h && 0 <= ny && ny < w && path[nx][ny] != '#' && !check.contains(nx * w + ny)
						&& !seen.contains(nx * w + ny)) {
					check.addLast(nx * w + ny);
					cnt.addLast(tmpc + 1);
				}
			}
		}
		if (tmpp != h * w - 1) {
			System.out.println("-1");
		} else {
			System.out.println(h * w - cntBlack - tmpc - 1);
		}
	}

}


Measured memory_bytes: 23508
const fs = require('fs')
const stdin = fs.readFileSync('/dev/stdin', 'utf8')

const S = stdin.split('\n')[0]

const [y,m,d] = S.split('/').map(Number)

let res = ''

if(m > 4){
  res = 'TBD'
} else if(m === 4 && d === 31){
  res = 'TBD'
} else {
  res = 'Heisei'
}

console.log(res)

Measured memory_bytes: 7372
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
        int A = stdIn.nextInt();
	int B = stdIn.nextInt();
	if(A<13&&A>5){
	    B/=2;
	}else if(A<6){
	    B=0;
	}
	System.out.println(B);
    }
}
		


Measured memory_bytes: 22612
#include<iostream>
using namespace std;
int main(){
        int n,i;
        int a[3];
        cin >> n;
        a[0] = n%10;
        a[1] = n/10%10;
        a[2] = n/100;
        for(i=0;i<3;i++){
                if(a[i]==1) a[i]=9;
                else a[i] = 1;
        }
        cout << a[2]*100+a[1]*10+a[0] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[6] = {0,1,0,-1,1,-1};
const int vy[6] = {1,0,-1,0,1,1};



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

    ll n;
    cin >> n;
    string ans = "";
    while(1){
        if(n <= 26) break;
        ll tmp = 0;
        tmp = n%26;
        tmp--;
        if(tmp != -1) ans += (char)('a'+tmp);
        else ans += 'z';
        n -= ++tmp;
        n /= 26;
        if(tmp == 0 && n == 27) break;
        if(tmp == 0) n--;
    }
    ll tmp = n%26;
    tmp--;
    if(n == 27) ans += 'z';
    else if(tmp != -1) ans += (char)('a'+tmp);
    else ans += 'z';
    reverse(all(ans));
    cout << ans << endl;
    cout << endl;
    return 0;
}


Measured memory_bytes: 3600
#pragma comment(linker, "/stack:200000000")
 #pragma GCC optimize("Ofast")
 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 #include<bits/stdc++.h>
 #define int long long
 using namespace std;
vector<vector<int>> adj;

int dp[500005];
int vis[500005];
int ans=0;
int dfs(int ver)
{
    vis[ver]=1;
    int mx=0;
    for(auto i:adj[ver])
    {
        if(vis[i]==0)
            mx=max(mx,dfs(i));
        else
        {
            mx=max(mx,dp[i]);
        }
    }
    dp[ver]=mx+1;
    ans=max(dp[ver],ans);
    return dp[ver];
}


signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif
 
     clock_t clk;
 	clk = clock();
 
// -------------------------------------Code starts here--------------------------------------------------------------------- 

    string s;
    cin>>s;
    int n=s.length();
    adj.resize(n+1);
    for(int i=0;i<n;i++)
    {
        if(s[i]=='>')
            adj[i].push_back(i+1);
        else
        {
            adj[i+1].push_back(i);
        }
    }
    for(int i=0;i<=n;i++)
    {
        if(vis[i]==0)
           dfs(i);
    }
    int ans=0;
    for(int i=0;i<=n;i++)
        ans+=dp[i]-1;
    // cout<<(ans*(ans-1))/2;
    cout<<ans;
// -------------------------------------Code ends here------------------------------------------------------
 
     clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 52380
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#define N 105
#define fi(a, b, c) for(int a = (b); a < (c); a++)
#define FI(a, b, c) for(int a = (b); a <= (c); a++)
using namespace std;

int n;
char s[N];

int main(){
	scanf("%s", s);
	n = strlen(s);
	s[n - 8] = 0;
	puts(s);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define F0R(i, N) for (long i = 0; i < (N); i++)

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

    vector<int> B(N - 1);
    for (int i = 0; i < N - 1; i++) {
        cin >> B[i];
    }

    int ans = 0;
    for (int n = 0; n < N; n++) {
        if (n == 0) {
            ans += B[n];
        } else if (n == N - 1) {
            ans += B[N - 2];
        } else {
            ans += min(B[n - 1], B[n]);
        }
    }

    cout << ans << "\n";

    return 0;
}


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

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

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

    ll c500 = x / 500;
    ll c5 = (x % 500) / 5;

    ll ans = c500 * 1000 + c5 * 5;

    cout << ans << endl;
    return 0;
}

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

int main() {
  int n; cin >> n;
  vector<int> a(n+1); rep(i, n) cin >> a[i+1];
  vector<int> b(n+1);
  for (int i = n; i >= 1; --i) {
    int sum = 0;
    for (int j = i * 2; j <= n; j += i) {
      sum ^= b[j];
    }
    b[i] = sum^a[i];
  }
  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    if (b[i]) ans.push_back(i);
  }
  cout << ans.size() << endl;
  rep (i, ans.size()) {
    printf("%d%c", ans[i], i+1==ans.size()?'\n':' ');
  }
  return 0;
}


Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		
		if((N-1)*(N-2)/2<K) {
			System.out.println(-1);
		} else {
			int connect = (N-1)*(N-2)/2 - K;
			System.out.println(N-1+connect);
			for(int i=0; i<N-1; i++) {
				System.out.println("1 " + (i+2));
			}
			for(int i=2; i<=N; i++) {
				for(int j=i+1; j<=N; j++) {
					if(connect>0) {
						System.out.println(i + " " + j);
						connect--;
					}
				}
			}
		}
		sc.close();
	}
}


Measured memory_bytes: 24660
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]

oneIdx = 0
for i, a in enumerate(A):
    if 1 == a:
        oneIdx = i

count = 0

i = oneIdx
while (i <= N-2):
    i += (K-1)
    count += 1

i = oneIdx
while (i >= 1):
    i -= (K-1)
    count += 1

##############

i = 0
count2 = 0
while (i <= N - 2):
    i += (K - 1)
    count2 += 1


if N == 1:
    print(0)
elif N <= K:
    print(1)
else:
    print(min(count, count2))


Measured memory_bytes: 13880
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int h, w; cin >> h >> w;
    vector<string> v(h);
    rep(i,h){
        cin >> v[i];
    }
    int now=0;
    bool flag = true;
    rep(i,h){
        rep(j,w){
            if(v[i][j]=='#') {
                if(j<now) flag = false;
                else now = j;
            }
        }
    }
    if(flag) cout << "Possible" << endl;
    else cout << "Impossible" << endl;

    return 0;
}

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

int bubbleSort(int R[], int N) {// Nは配列の要素数
    int count = 0;
    for (int i = 0; i < N-1; i++) {
        for (int j = N-1; j > i; j--) {
            if (R[j-1] > R[j]) {
                swap(R[j], R[j-1]);
                count++;
            }
        }
    }
    return count;
}

int main() {
    int N;
    cin >> N;
    int R[110];
    for (int i = 0; i < N; i++) cin >> R[i];

    int count = bubbleSort(R, N);

    for (int i = 0; i < N; i++) {
        if (i == N-1) cout << R[i] << endl;
        else cout << R[i] << " ";
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3100
#include<stdio.h>

int main()
{
    int jmax;
    int i=0, j=0;
    char num[1000]={0};
    int sum[1000]={0};
    
    while(1){
        scanf("%s",&num);
        if(num[0] == '0') break;               
        for(i=0; num[i]!='\0'; i++){      //i!=NULL 
            sum[j] += (num[i] - '0');
//        printf("%d \n",sum[j]);
        }

        jmax = j+1; 
        j++;
    }
    

    for(j=0; j<jmax; j++){
        printf("%d\n",sum[j]);
    }
//    printf("test \n");

    return 0;
}




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

int main() {
    int n = 0;
    string s;
    cin >> n >> s;
    
    if (n==1) { cout << "No"; return 0; }
    
    string former = s.substr(0,n/2);
    string latter = s.substr(n/2, n-1);
    string ans =  (former == latter) ? "Yes" : "No";
    cout << ans << endl;
}

Measured memory_bytes: 256
def m(L,R):
 global c
 T=[];i=j=0
 for _ in L[:-1]+R[:-1]:
  if L[i]<R[j]:T+=[L[i]];i+=1
  else:T+=[R[j]];j+=1
  c+=1
 return T
def d(A):s=len(A)//2;return m(d(A[:s])+[1e9],d(A[s:])+[1e9]) if len(A)>1 else A
c=0
input()
print(*d(list(map(int,input().split()))))
print(c)


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

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

    if(S[5]=='1' || S[6]>'4') {
        cout << "TBD" << endl;
    } else {
        cout << "Heisei" << endl;
    }

    return 0;
}

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

int main(){
  int N; 
  cin >> N;
  vector<double> vec(N);
  vector<double> prod(N);

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

  prod[0] = pow(2, -(N-1));
  for(int i = N-1; i >= 1;i--){
    prod[i] = pow(2, -i);

    cerr << prod[i] << endl;
  }

  sort(prod.begin(),prod.end());
  sort(vec.begin(),vec.end());

  double ans = 0;
  for(int i = 0; i < N; i++){
    ans += prod[i] * vec[i];
  }

  cout << ans << endl;

}


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

using namespace std;

int n;
int happi[100001][3];
int dp[100001][3];

int main()
{
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> happi[i][0] >> happi[i][1] >> happi[i][2];
    }

    dp[0][0] = happi[0][0];
    dp[0][1] = happi[0][1];
    dp[0][2] = happi[0][2];

    for(int i = 1; i < n; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            int mn = 0;
            for(int h = 0; h < 3; h++)
            {
                if(h != j) mn = max(mn, dp[i-1][h] + happi[i][j]);
            }

            dp[i][j] = mn;
        }
    }

    int mn = 0;
    for(int i = 0; i < 3; i++)
    {
        mn = max(mn, dp[n-1][i]);
    }

    cout << mn << endl;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#include <vector>
using namespace std;
typedef long long LL;

LL ans = 0x3f3f3f3f3f3f3f3f;
LL ca[20005],cb[20005],ba[20005];
string a,b,c;

void solve(string x,string y,string z){
	LL lx = x.length(),ly = y.length(),lz = z.length();
	x = ' ' + x; y = ' ' + y; z = ' ' + z;
	for(LL i = 1;i <= 20000;i ++){
		ba[i] = 1;
		cb[i] = 1;
		ca[i] = 1;
	}
	
	for(LL i = 0;i <= 6005;i ++){
		LL flg = 1;
		for(LL j = 1;j <= ly;j ++){
			if(i + j > lx) break;
			if(x[i + j] != y[j] && x[i + j] != '?' && y[j] != '?') flg = 0;
		}
		ba[i + 1] = flg;
//		cout << ba[i + 1] << (i == lx - 1 ? '\n' : ' ');
	}
	for(LL i = 0;i <= 6005;i ++){
		LL flg = 1;
		for(LL j = 1;j <= lz;j ++){
			if(i + j > ly) break;
			if(y[i + j] != z[j] && y[i + j] != '?' && z[j] != '?') flg = 0;
		}
		cb[i + 1] = flg;
//		cout << cb[i + 1] << (i == ly - 1 ? '\n' : ' ');
	}
	for(LL i = 0;i <= 6005;i ++){
		LL flg = 1;
		for(LL j = 1;j <= lz;j ++){
			if(i + j > lx) break;
			if(x[i + j] != z[j] && x[i + j] != '?' && z[j] != '?') flg = 0;
		}
		ca[i + 1] = flg;
//		cout << ca[i + 1] << (i == lx + ly - 1 ? '\n' : ' ');
	}
	
	for(LL i = 1;i <= 6005;i ++){
		for(LL j = 1;j <= 6005;j ++){
			if(ba[i] && cb[j] && ca[i + j - 1]) ans = min(ans,max(lx,max(i + ly - 1LL,i + j + lz - 2LL)));
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin >> a >> b >> c;
	solve(a,b,c);
	solve(a,c,b);
	solve(b,a,c);
	solve(b,c,a);
	solve(c,a,b);
	solve(c,b,a);
	cout << ans << endl;
	return 0;
}
/*
a?c
cod
der
*/

Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;
int main(){
    int i;
    int a=0,b=0,c=0,d=0,n;
    for(i=0;i<4;i++){
        cin>>n;
        if(n==1) a=1;
        else if(n==9) b=1;
        else if(n==7) c=1;
        else if(n==4) d=1;
    }
    if(a*b*c*d) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
# Acceptance of input

import sys

f_i = sys.stdin

n = int(f_i.readline())

edges = [[] for i in range(n)]

for l_i in f_i:
    s, t, w = map(int, l_i.split())
    edges[s].append((t, w))
    edges[t].append((s, w))

# Tree Walk function

import collections

def tree_walk(start, switch = 0):
    path = collections.deque()
    path.append(start)

    weight = collections.deque()
    weight.append(0)
    
    unvisited = [True] * n
    unvisited[start] = False
    
    rest = n - 1
    end_point = start
    diameter = 0
    
    while True:
        u = path[-1]
        for v, w in edges[u]:
            if unvisited[v]:
                path.append(v)
                unvisited[v] = False
                rest -= 1
                weight.append(w)
                break

        if u == path[-1]:
            distance = sum(weight)
            if diameter < distance:
                diameter = distance
                end_point = u
            if rest == 0:
                break
            path.pop()
            weight.pop()

    if switch:
        print(diameter)
    else:
        return end_point

# Output

tree_walk(tree_walk(0), 1)

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

int main(){
    vector<int> a (5) ;
    rep(i, 5) {
        cin >> a[i] ;
    }
    int k ;
    cin >> k ;
    bool ans = true ;
    rep(i, 5){
        rep(j, 5){
            if(abs(a[i] - a[j]) > k){
                ans = false ;
            }
        }
    }
    if(ans){
        cout << "Yay!" << endl ;
    }
    else {
        cout << ":(" << endl ; 
    }
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

#define H_MAX 50
#define W_MAX 50

char c[H_MAX][W_MAX];
ll d[H_MAX][W_MAX];

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

ll H, W;

ll bfs() {
    queue<Pll> que;

    rep (i, H) {
        rep (j, W) {
            d[i][j] = -1;
        }
    }

    que.push(Pll(0, 0));
    d[0][0] = 0;

    while (que.size()) {
        Pll p = que.front();
        que.pop();

        if (p.first == H-1 && p.second == W-1) {
            break;
        }

        rep (i, 4) {
            ll ny = p.first  + dy[i];
            ll nx = p.second + dx[i];

            if (0 <= nx && nx < W && 0 <= ny && ny <= H && c[ny][nx] != '#' && d[ny][nx] == -1) {
                que.push(Pll(ny, nx));
                d[ny][nx] = d[p.first][p.second] + 1;
            }
        }
    }

    return d[H-1][W-1];
}

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

    cin >> H >> W;
    rep (i, H) {
        rep (j, W) {
            cin >> c[i][j];
        }
    }

    ll ans = H*W;
    rep (i, H) {
        rep (j, W) {
            if (c[i][j] == '#') {
                ans--;
            }
        }
    }

    ans -= bfs();
    ans--;

    if (bfs() == -1) {
        ans = -1;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,q=map(int, input().split())
s=input()

a=[0]*(n+1)
tmp=0
for i in range(1,n+1):
  if s[i-1:i+1]=="AC":
    a[i]=tmp+1
    tmp=a[i]
  else:
    a[i]=tmp
#print(a)

for _ in range(q):
  l,r=map(int, input().split())
  print(a[r-1] - a[l-1])

Measured memory_bytes: 11484
#include <iostream>
#include <string>
#include <vector>

using namespace std;

void rotation_N(int* dise){
   int tmp[6];

   tmp[0] = dise[1];
   tmp[1] = dise[5];
   tmp[2] = dise[2];
   tmp[3] = dise[3];
   tmp[4] = dise[0];
   tmp[5] = dise[4];

   for(int i = 0; i < 6; i++){
      dise[i] = tmp[i];
   }
}
void rotation_E(int* dise){
   int tmp[6];

   tmp[0] = dise[3];
   tmp[1] = dise[1];
   tmp[2] = dise[0];
   tmp[3] = dise[5];
   tmp[4] = dise[4];
   tmp[5] = dise[2];

   for(int i = 0; i < 6; i++){
      dise[i] = tmp[i];
   }
}
void rotation_S(int* dise){
   int tmp[6];

   tmp[0] = dise[4];
   tmp[1] = dise[0];
   tmp[2] = dise[2];
   tmp[3] = dise[3];
   tmp[4] = dise[5];
   tmp[5] = dise[1];

   for(int i = 0; i < 6; i++){
      dise[i] = tmp[i];
   }
}
void rotation_W(int* dise){
   int tmp[6];

   tmp[0] = dise[2];
   tmp[1] = dise[1];
   tmp[2] = dise[5];
   tmp[3] = dise[0];
   tmp[4] = dise[4];
   tmp[5] = dise[3];

   for(int i = 0; i < 6; i++){
      dise[i] = tmp[i];
   }
}

void rotation_spin(int* dise){
   int tmp[6];

   tmp[0] = dise[0];
   tmp[1] = dise[2];
   tmp[2] = dise[4];
   tmp[3] = dise[1];
   tmp[4] = dise[3];
   tmp[5] = dise[5];

   for(int i = 0; i < 6; i++){
      dise[i] = tmp[i];
   }
}

int main(){
   int dise[6];
   int n;

   vector<int> ans;

   for(int i = 0; i < 6; i++){
      cin >> dise[i];
   }

   cin >> n;

   for(int i = 0; i < n; i++){
      int top, front;
      cin >> top >> front;

      if(dise[1] == top){
         rotation_N(dise);
      }
      else if(dise[4] == top){
         rotation_S(dise);
      }

      while(dise[0] != top){
         rotation_E(dise);
      }

      while(dise[1] != front){
         rotation_spin(dise);
      }

      ans.push_back(dise[2]);

   }

   for(int i = 0; i < ans.size(); i++){
      cout << ans[i] << endl;
   }

   return 0;
}


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

const int depth = 2, width = 4;
const int siz[depth + 1] = {2, 4, 1};
double matrix[depth][width][width] = {1.815155022, 0.9025716449, -1.09382462, -0.3875933114, -0.6446463742, -2.024756527, 0.3884682393, 0.8694956143, 0, 0, 0, 0, 0, 0, 0, 0, 0.9463118678, 0, 0, 0, -0.7951753672, 0, 0, 0, -1.570363939, 0, 0, 0, 1.851690207, 0, 0, 0};
double node[depth + 1][width];
double calc(double a, double b){
    memset(node, 0x00, sizeof(node));
    node[0][0] = a;
    node[0][1] = b;
    for(int i = 0; i < depth; i++){
        const auto from = node[i], to = node[i + 1];
        const auto h = siz[i], w = siz[i + 1];
        const auto m = matrix[i];
        for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) to[j] += from[i] * m[i][j];
        if(i + 1 != depth) for(int j = 0; j < w; j++) if(to[j] < 0) to[j] = 0;
    }
    return node[depth][0];
}
int main(){
    int a, b;
    while( scanf("%d %d", &a, &b) != EOF ){
        printf("%ld\n", lround(calc(a, b)));
    }
}





Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,b;
  list<int>a;
  cin>>n;
  string s;
  while(n--){
    cin>>s;
    if(s.size()<=6){
      cin>>b;
      if(s[0]=='i') a.push_front(b);
      else{
        list<int>::iterator it=a.begin();
        while(it!=a.end()){
          if(*it==b){a.erase(it);break;}
          it++;
        }
      }
    }
    else{
      if(s[6]=='F')a.pop_front();
      else a.pop_back();
    }
  }
  list<int>::iterator it=a.begin();
  for(int i=0;it!=a.end();it++,i++){
    if(i)cout<<' ';
    cout<<(*it);
  }
  cout<<endl;
}

Measured memory_bytes: 34412
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#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 pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) {
        cin >> A[i];
        A[i]--;
    }
    ll now = 0;
    vector<ll> hist;
    set<ll> se;
    while(1) {
        hist.pb(now);
        se.insert(now);
        if(se.count(A[now]))
            break;
        now = A[now];
    }
    ll save = 0;
    rep(i, hist.size()) {
        if(hist[i] == A[now]) {
            save = i;
            break;
        }
    }
    vector<ll> new_hist;
    for(int i = save; i < hist.size(); i++) {
        new_hist.pb(hist[i]);
    }
    if(K < save) {
        cout << hist[K] + 1 << endl;
        return 0;
    }
    K -= save;
    ll len = new_hist.size();
    cout << new_hist[K % len] + 1 << endl;
    return 0;
}

Measured memory_bytes: 17804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int N = 200000;



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

    int k, n;
    cin >> n >> k;
    int a[n], s = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a, a+n);
    for(int i = 0; i < k; i++){
        s += a[i];
    }
    cout << s;

    return 0;
}


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

template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main(){
    int n;
    cin>>n;
    string s[n];
    map<string,int> ms;
    int max=0;
    rep(i,n){cin>>s[i];ms[s[i]]++;if(max<ms[s[i]])max=ms[s[i]];}
    vector<string> ans;
    rep(i,n)if(ms[s[i]]==max){
        ans.push_back(s[i]);
        ms[s[i]]=0;
    }
    sort(ans.begin(),ans.end());
    rep(i,ans.size())cout<<ans[i]<<endl;
    return 0;
}




Measured memory_bytes: 28404
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;
typedef vector<pii> Vp;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=140000+19;

struct Edge{
	int y,z,nxt;
} E[N*2];

int las[N];
int n,cnt,x;
ll l,r,mid;

void Add_Edge(int x,int y,int z){
	E[cnt]=(Edge){y,z,las[x]};las[x]=cnt++;
}
Vp Merge(Vp A,Vp B){
	Vp res,ans;
	int c=-1;
	For(i,0,A.size()){
		for (;c+1<B.size()&&A[i].se+B[c+1].fi<=mid;c++);
		if (c>=0) res.pb(mp(A[i].fi,B[c].se));
	}
	c=-1;
	For(i,0,B.size()){
		for (;c+1<A.size()&&B[i].se+A[c+1].fi<=mid;c++);
		if (c>=0) res.pb(mp(B[i].fi,A[c].se));
	}
	sort(res.begin(),res.end());
	For(i,0,res.size()){
		//if (res[i].fi>mid||res[i].se>mid) continue;
		if (!ans.empty()&&res[i].se>=ans.back().se) continue;
		ans.pb(res[i]);
	}
	return ans;
}
Vp dfs(int x){
	if (las[x]==-1){
		return {mp(0,0)};
	}
	Vp V[2];
	int len[2],c=0;
	for (int i=las[x],y;~i;i=E[i].nxt){
		y=E[i].y;
		V[c]=dfs(y);
		len[c++]=E[i].z;
	}
	For(i,0,2) For(j,0,V[i].size()){
		V[i][j].fi+=len[i];
		V[i][j].se+=len[i];
	}
	return Merge(V[0],V[1]);
}

int main(){
	memset(las,-1,sizeof(las));
	n=IN();
	For(i,2,n+1){
		x=IN();
		Add_Edge(x,i,IN());
	}
	l=0,r=131072ll*n;
	while (l<=r){
		mid=(l+r)/2;
		if (!dfs(1).empty()) r=mid-1;else l=mid+1;
	}
	cout<<r+1<<endl;
}

Measured memory_bytes: 16640
#include <iostream>
#include <set>
#include <stdio.h>
#define MAX 200001
using namespace std;

int main()
{
    set<int> S;
    int a, b, temp;
    int brr[MAX];
    scanf("%d", &a);
    for (int i = 0; i < a; i++)
    {
        scanf("%d", &temp);
        S.insert(temp);
    }

    scanf("%d", &b);
    for (int i = 0; i < b; i++)
    {
        scanf("%d", &brr[i]);
    }

    for (int i = 0; i < b; i++)
    {
        if (0 == S.count(brr[i]))
        {
            printf("%d\n", 0);
            return 0;
        }
    }
    printf("%d\n", 1);
    return 0;
}



Measured memory_bytes: 13356
//02
#include<iostream>
#include<algorithm>

using namespace std;

int fr[100];
int bc[100];

int mem[100][100];

int dfs(int f,int l){
  if(mem[f][l]!=-1){
    return mem[f][l];
  }else if(f==l){
    return 0;
  }else{
    long long mc=1LL<<31;
    for(int m=f;m!=l;m++){
      mc=min(mc,(long long)dfs(f,m)+dfs(m+1,l)+fr[f]*bc[m]*fr[m+1]*bc[l]);
    }
    mem[f][l]=mc;
    return mc;
  }
}

int main(){
  int n;
  cin>>n;
  fill(mem[0],mem[100],-1);
  for(int i=0;i<n;i++){
    cin>>fr[i]>>bc[i];
  }
  cout<<dfs(0,n-1)<<endl;
  return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll w[200],v[200];
ll dp[200][100003];
int main()
{
  ll n,w1,i,j,mini;
  cin>>n>>w1;
  for(i=0;i<n;i++)
    cin>>w[i]>>v[i];
  //memset(dp,INT_MAX,sizeof(dp));
  for(i=0;i<=n;i++)
  {
  	for(j=0;j<=w1;j++)
  	{
  		if(j==0||i==0)
  		dp[i][j]=0;
  		else
  		{
  			if(w[i-1]<=j)
  			dp[i][j]=max(v[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
  			else
  			dp[i][j]=dp[i-1][j];
		  }
  	 	
	}
  }
  cout<<dp[n][w1]<<endl;
 }
                


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

vector<int> dp;
int main()
{
  int n;
  cin>>n;
  vector<int> v(n);
  for (int i=0;i<n;i++)
    cin>>v[i];
  dp.assign(n+1,-1);
  dp[0]=0;
  dp[1]=abs(v[0]-v[1]);
  for (int i=2;i<=n;i++)
    dp[i]=min(abs(v[i]-v[i-1])+dp[i-1],abs(v[i]-v[i-2])+dp[i-2]);
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>
#include <cstdio>

using namespace std;

int gcd(int a, int b) {
	if (a%b == 0) {
		return b;
	}
	else {
		return gcd(b, a%b);
	}
}

int main() {

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

	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	vector<int> c(n);
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (v[i] - c[i] > 0)ans += v[i] - c[i];
	}

	cout << ans << endl;

	return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  int n;
  cin >> n;
  int cnt = 1;
  int m;
  cin >> m;
  for(int i=1; i<n; i++){
    int tmp;
    cin >> tmp;
    if(m<=tmp){
      cnt++;
      m = tmp;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=1e5+100;
int dp[110];
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    dp[0]=1;
    for(int i=4; i<110; i++)
        dp[i]|=dp[i-4];
    for(int i=7; i<110; i++)
        dp[i]|=dp[i-7];
    int n;
    cin>>n;
    if(dp[n])cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<random>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,a[100][100];
    ll dp[1<<20];
    ll use[1<<20];
    cin>>n;
    rep(i,n){
        rep(j,n){
            cin>>a[i][j];
        }
    }
    rep(bit,(1<<n)){
        rep(i,n){
            rep2(j,i,n){
                if(bit&(1<<i))if(bit&(1<<j))use[bit]+=a[i][j];
            }
        }
    }
    rep(bit,(1<<n)){
        for(ll mask=bit;mask>0;mask=(mask-1)&bit){
            dp[bit]=max(dp[bit],dp[bit-mask]+use[mask]);
        }
    }
    cout<<dp[(1<<n)-1]<<endl;
    return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define rep(j,m) for(int j=0;j<m;++j)
#define REP(i,n) for(int i=1;i<=n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define len(s)   ((int)s.size())
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<ll> ve;
typedef vector< vector < int> > vee;
typedef vector<pair<ll,ll> > vepa;
typedef set<int>se;
typedef map<char,int> mpp;
const ll N=1e3+5;
ll arr[N],A[N],cnt[N];
bool visited[N];
bool f,ff;

 int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
     ll n,sum=0 ;
    cin>>n;
    for(int a=1;a<=n;a++)
    {
        for(int b=1;b<=n;b++)
        {
            for(int c=1;c<=n;c++)
            {
                sum+=__gcd(__gcd(a,b),c);
            }
        }
    }
    cout<<sum;

go;
}


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

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

  for (int i = 0; i < N; i++) {
    int x, y, b, p;
    int p1, p2;
    cin >> x >> y >> b >> p;
    p1 = x*b + y*p;
    p2 = x*max(5, b) + y*max(2, p);
    p2 *= 0.8;
    cout << min(p1, p2) << endl;
  }
  return 0;
}

Measured memory_bytes: 1164
unittest
{
	assert( [ "RUDLUDR" ].parse.expand.solve == "Yes" );
	assert( [ "DULL" ].parse.expand.solve == "No" );
	assert( [ "UUUUUUUUUUUUUUU" ].parse.expand.solve == "Yes" );
	assert( [ "ULURU" ].parse.expand.solve == "No" );
	assert( [ "RDULULDURURLRDULRLR" ].parse.expand.solve == "Yes" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	foreach( i, c; s )
	{
		if( ( i % 2 == 0 && c == 'L' ) || ( i % 2 == 1 && c == 'R' ) ) return "No";
	}
	return "Yes";
}


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

using namespace std;

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

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    ll Min=LongINF;
    int N,M,X;
    cin>>N>>M>>X;
    vi C(N);
    vector<vector<int>> book(N,vector<int>(M,0));
    rep(i,N){
        cin>>C[i];
        rep(j,M)cin>>book[i][j];
    }
    for(int bit=0;bit<(1<<N);bit++){
        ll money=0;
        vector<int> under(M,0);
        rep(i,N){
            if(bit&(1<<i)){
                money+=C[i];
                rep(j,M){
                    under[j]+=book[i][j];
                }
            }
        }
        int cnt=0;
        rep(i,M){
            if(under[i]>=X){
                cnt++;
            }
        }
        if(cnt>=M){
            //cout<<money<<endl;
            Min=min(Min,money);
        }
    }
    if(Min==LongINF)Min=-1;
    cout<<Min<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 3636
import math
import sys

x, n = map(int, input().split())

if n == 0:
    print(x)
    sys.exit()

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

p.sort()
# closest
ans = min(p, key=lambda y:abs(y-x))
idx = p.index(min(p, key=lambda y:abs(y-x)))

# print(p)
# print(ans, idx)

if x != ans:
    print(x)
    sys.exit()


cnt = idx
larger_near = p[cnt]
smaller_near = p[cnt]

while cnt < n:
    tmp = p[cnt]
    cnt += 1
    if cnt == n:
        larger_near = tmp + 1
        break
    elif p[cnt] != tmp + 1:
        larger_near = tmp + 1
        break

cnt = idx
while cnt >= 0:
    tmp = p[cnt]
    cnt -= 1
    if p[cnt] != tmp - 1:
        smaller_near = tmp - 1
        break

if abs(smaller_near - x) <= abs(larger_near - x):
    ans = smaller_near
else:
    ans = larger_near
print(ans)

    

Measured memory_bytes: 9256
/* Volume0 0002 Digit Number */
import java.util.Scanner;

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

		Scanner stdIn = new Scanner(System.in);

		while( stdIn.hasNext()){
			System.out.println( (int)Math.log10(stdIn.nextInt()+stdIn.nextInt())+1 );
		}

	}
}

Measured memory_bytes: 26228
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		long[] sum = new long[n];
		for(int i=0;i<n;i++){
			int tmp = sc.nextInt();
			a[i] = tmp;
			sum[tmp-1]++;
		}
		long total = 0;
		for(int i=0;i<n;i++){
			total += sum[i]*(sum[i]-1)/2;
		}
		for(int i=0;i<n;i++){
			long minus = 0;
			if(sum[a[i]-1] >= 2){
				long moto = sum[a[i]-1]*(sum[a[i]-1]-1)/2;
				long ato = (sum[a[i]-1]-1)*(sum[a[i]-1]-2)/2;
				minus = moto - ato;
			}
			System.out.println(total-minus);
		}
	}
}

Measured memory_bytes: 102152
answers = []

def get_answer(n, p, answers)
  owan = p
  index = 0
  temoto = []
  n.times do
    temoto << 0
  end
  while true
    if owan == 0
      owan += temoto[index]
      temoto[index] = 0
    else
      if owan == 1 && temoto[index] == p -1
        answers << index
        return answers
      end
      owan -= 1
      temoto[index] += 1
    end
    index += 1
    index = 0 if index == n
  end
end


while true
  array = gets.chomp.split(" ").map(&:to_i)
  n = array[0].to_i
  p = array[1].to_i
  break if n == 0 && p == 0
  answers = get_answer(n,p, answers)
end

answers.each do |ans|
  puts ans
end

Measured memory_bytes: 8696
#include <iostream>
#include <assert.h>
#include <string.h>
#include <string>
#include <list>
using namespace std;

int main(){
    int a,b,ans;
    cin>>a>>b;
    ans=max(a+b,max(a-b,a*b));
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256