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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void printVec(vector<int> &vec) {
    for (auto &e : vec) {
        cout << e << " ";
    }
    cout << endl;
}

int main() {
    string s, t, u;
    int a, b;

    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if (s == u) {
        a--;
    } else {
        b--;
    }
    cout << a << " " << b << endl;

    return 0;
}


Measured memory_bytes: 256
/*
AizuOnline A0088
The Code A Doctor Loved
2012/12/31 WA
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
#include <string.h>
//#include <float.h>
//#include <math.h>
//Global data section

char heibun[1000];
char s1[10000];
char s2[2000];

char *step1table[]={
//  SP ' , - . ?
        "101",
	"000000",
	"000011",
	"10010001",
	"010001",
	"000001",
// A-B
	"100101",
	"10011010",
// C-J
	"0101",
	"0001",
	"110",
	"01001",
	"10011011",
	"010000",
	"0111",
	"10011000",
// K-R
	"0110",
	"00100",
	"10011001",
	"10011110",
	"00101",
	"111",
	"10011111",
	"1000",
// S-Z
	"00110",
	"00111",
	"10011100",
	"10011101",
	"000010",
	"10010010",
	"10010011",
	"10010000"};
int conv(char c)
{
  //printf("%c",c);
  char *x;
  char compared[] = " ',-.?";
  if(NULL != (x = strchr(compared,c)))
    return(x - compared);
  return(c - 'A' + 6);    
}
void step1()
{
  char *s,c;

  s=heibun;
  s1[0]='\0';
  while(c=*s++)
    {
      //printf("%c %s\n",c,step1table[conv(c)]);
      strcat(s1,step1table[conv(c)]);
    }
  strcat(s1,"0000");
}
int conv5bin(char *s)
{
  //printf("%5s\n",s);
  int sum;
  sum  = (s[0]=='1')?16:0;
  sum += (s[1]=='1')?8:0;
  sum += (s[2]=='1')?4:0;
  sum += (s[3]=='1')?2:0;
  sum += (s[4]=='1')?1:0;
  return(sum);
}
void step2()
{
  int s2ptr;
  int i;

  s2ptr=0;
  for(i=0;i<(strlen(s1)/5)*5;i+=5)
    s2[s2ptr++]="ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?"[conv5bin(&(s1[i]))];
  s2ptr='\0';
}
main()
{
  int i;

  while(NULL != gets(heibun))
    {
      
      for(i=0;i<2000;i++)
	s2[i]='\0';
      

      step1();
      step2();


      //printf("%s\n",s1);
      printf("%s\n",s2);
    }
return(0);
}

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

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

int N, a[100001];
ll cunt1, cunt2, sum;

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

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

	sum = 0ll;

	for (int i = 0; i < N; i++) {
		if (i % 2 == 0 && sum + a[i] <= 0) {
			cunt1 += (-1) * sum + 1 - a[i];
			sum = 1;
		} else if (i % 2 != 0 && sum + a[i] >= 0) {
			cunt1 += a[i] + sum + 1;
			sum = -1;
		} else sum += a[i];

	}

	sum = 0ll;
	for (int i = 0; i < N; i++) {
		if (i % 2 != 0 && sum + a[i] <= 0) {
			cunt2 += (-1) * sum + 1 - a[i];;
			sum = 1;
		} else if (i % 2 == 0 && sum + a[i] >= 0) {
			cunt2 += a[i] + sum + 1;
			sum = -1;
		} else sum += a[i];

	}

	cout << min(cunt1, cunt2) << "\n";
}


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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

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

int a[200000];

int main() {
    int n, t = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        t ^= a[i];
    }
    for (int i = 0; i < n; ++i) {
        cout << (t ^ a[i]) << " ";
    }

    return 0;
}

Measured memory_bytes: 4340
from collections import deque

K = int(input())

queue = deque([9, 8, 7, 6, 5, 4, 3, 2, 1])

count = 0
while queue:
    number = queue.pop()
    count += 1

    if count == K:
        print(number)
        break

    last_number = int(str(number)[-1])
    add_center = number * 10 + last_number

    if last_number > 0:
        queue.appendleft(add_center - 1)

    queue.appendleft(add_center)

    if last_number < 9:
        queue.appendleft(add_center + 1)


Measured memory_bytes: 18604
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int c;
	int d;
	int ab;
	int bc;
	int ac;
	
	scanf("%d %d %d %d", &a, &b, &c, &d);
	
	if(a > b){
		ab = a - b;
	}
	else{
		ab = b - a;
	}
	
	if(b > c){
		bc =  b - c;
	}
	else{
		bc = c - b;
	}
	
	if(a > c){
		ac = a - c;
	}
	else{
		ac = c - a;
	}
	
	if(a == b && b == c){
		printf("Yes\n");
	}
	
	else if(ab <= d && bc <= d){
		printf("Yes\n");
	}
	else if(ac <= d){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return(0);
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-9;
const int inf=1e8;
int main(){
	vi sosu(300010);
	sosu[0]=sosu[1]=1;
	for(int i=2;i*i<=300010;i++)if(sosu[i]==0&&(i%7==1||i%7==6)){
		for(int j=i*2;j<300010;j+=i)sosu[j]=1;
	}
	int n;
	while(cin>>n,n-1){
		cout<<n<<":";
		rep(i,300010)if(sosu[i]==0&&(i%7==1||i%7==6)&&n%i==0)cout<<" "<<i;
		cout<<endl;
	}
}

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

const int INF=1e9+1;

int main() {
  int n; cin>>n;
  vector<vector<int>> x(n, vector<int>(3, 0));
  rep(i, n) cin>>x[i][0]>>x[i][1]>>x[i][2];
 

  vector<vector<int>> dp(n+1, vector<int>(3, 0));
  for (int i=0; i<n; i++) {
    rep(j, 3) {
      dp[i+1][j]=max(dp[i+1][j], dp[i][(j+1)%3]+x[i][(j+1)%3]);
      dp[i+1][j]=max(dp[i+1][j], dp[i][(j+2)%3]+x[i][(j+2)%3]);
    }
  }
  int res=0;
  rep(i, 3) res=max(res, dp[n][i]);
  cout<<res<<endl;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int main() 
{
	int a,b;
	cin>>a>>b;
	if(a*b>a-b&&a*b>a+b)
	{
		cout<<a*b<<endl;
	}
	else if(a-b>a+b)
	{
		cout<<a-b<<endl;
	}
	else
	{
	    cout<<a+b<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll _R(){
	ll d=0;bool b=1;char t=getchar();
	while(t<'0'||t>'9'){if(t=='-')b=0;t=getchar();}
	for(;t>='0'&&t<='9';t=getchar())d=(d<<3)+(d<<1)+t-'0';
	return b?d:-d;
}
ll v[6]={0,1,2,4,8},w[6],n,Ans,f[10];
int main(){
	for(int i=1;i<=4;i++)w[i]=_R();
	n=_R()*4;
	memset(f,60,sizeof(f));
	f[0]=0;
	for(int i=1;i<=4;i++)
		for(int j=v[i];j<=8;j++)
			f[j]=min(f[j],f[j-v[i]]+w[i]);
	if(n%8!=0)Ans=f[4]+(n-4)/8*f[8];
	else Ans=n/8*f[8];
	printf("%lld",Ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main() {
	string a, b;
	while (cin >> a >> b) {
		int MAX = 0;
		for (int i = 0; i < a.size(); i++) {
			int c = 0;
			for (int j = 0; j < b.size(); j++) {
				if (i+j < a.size()) {
					if (a[i+j] == b[j]) {
						c++;
					} else {
						MAX = max(MAX, c);
						c = 0;
					}
				} else {
					MAX = max(MAX, c);
					break;
				}
			}
		}
		for (int i = 0; i < b.size(); i++) {
			int c = 0;
			for (int j = 0; j < a.size(); j++) {
				if (i+j < b.size()) {
					if (b[i+j] == a[j]) {
						c++;
					} else {
						MAX = max(MAX, c);
						c = 0;
					}
				} else {
					MAX = max(MAX, c);
					break;
				}
			}
		}
		cout <<MAX << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;

int main(void) {
  int A, B;
  cin >> A >> B;
  if (A <= 9 && B <= 9) {
    cout << A * B << endl;
  } else {
    cout << "-1" << endl;
  }
  return 0;
}


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

typedef long long ll;

int main() {
    int dp[200]; 
    int N;
    dp[4] = 1;
    dp[7] = 1;

    cin >> N;
    for (int i = 1; i <= N; i++) {
        if (dp[i] == 1) {
            if (i + 4 <= N) {
                dp[i + 4] = 1;
            }
            if (i + 7 <= N) {
                dp[i + 7] = 1;
            }
        }
    }

    if (dp[N] == 1) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n;
int a[1000100];
map<int,int> t;

int main(){
	cin>>n;
	REP(i,n)
		cin>>a[i],t[a[i]]++;
	int ans=0;
	for(auto itr=t.begin();itr!=t.end();itr++){
		if(itr->second%2==1){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5376
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (N, M, X) = Slice3<long>();
            var Ai = Sarray();
            var preNum = Ai.Count(a => a < X);
            WriteLine(Min(preNum, M - preNum));
        }


        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

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

int main() {
  
  int N;
  string A,B,C;
  cin >> N >> A >> B >> C;

  set<int> S;
  int ans = 0;
  for(int i = 0;i < N;i++) {
    S.insert(A.at(i));
    S.insert(B.at(i));
    S.insert(C.at(i));
    if(S.size() != 1) ans += S.size() - 1;
    while(!S.empty()) S.erase(S.begin());
  }

  cout << ans << endl;


}


Measured memory_bytes: 256
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

C = [list(map(int, input().split())) for i in range(3)]
A = [0]*3
B = [0]*3

flg = 0
for i in range(C[0][0]+1):
    A[0] = i
    B[0] = C[0][0]-i
    for j in range(1,3):
        A[j] = C[j][0]-B[0]
        B[j] = C[0][j]-A[0]
    
    tmp = abs(C[1][1]-A[1]-B[1])+abs(C[1][2]-A[1]-B[2])+abs(C[2][1]-A[2]-B[1])+abs(C[2][2]-A[2]-B[2])
    if tmp==0:
        flg = 1

if flg:
    print("Yes")
else:
    print("No")

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

const double PI=acos(-1.0);

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    int alice = 0, bob = 0;
    rep(i, n) {
        if(i % 2 == 0) alice += a[i];
        else bob += a[i];
    }

    cout << alice - bob << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.File;
import java.io.FileInputStream;
import java.util.Scanner;
import java.util.Map.Entry;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		char[] s = sc.next().toCharArray();
		int[] count = new int[26];
		for(char c : s) count[c-'a']++;
		for(int c : count){
			if(c % 2 != 0){
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21204
#include<stdio.h>

int main()
{
  char s[3][4]={};
  int i;
  for(i=0;i<2;i++)
  {
   scanf("%s",&s[i]);
  }
  
  if(s[0][0]==s[1][2]&&s[0][1]==s[1][1]&&s[0][2]==s[1][0])
  {
   printf("YES\n");
  }
  else
  {
    printf("NO\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	int n;
  	while(cin>>n){
	int sum = 0;
    if(n==0) break;
	for (int i = 0; i < 9; i++) {
		int x;
		cin >> x;
		sum += x;
	}
	cout << n-sum << endl;
    }
}
		




Measured memory_bytes: 3004
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
ll k;
char S[105];
vector<int> POW[10];
int main(){

	scanf("%s%lld",S,&k);
	int len=strlen(S);
	for(int i=0;i<k;i++)
	{
		if(S[i]!='1')
		{
			printf("%c\n",S[i]);
			return 0;
		}
	}
	printf("1\n");
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main(void)
{
    char name[9][20];
    int am, pm;
    int money[9];
    int sum[9];
    
    for (int i = 0; i < 9; i++){
        scanf("%s %d %d", name[i], &am, &pm);
        money[i] = (am * 200) + (pm * 300);
        sum[i] = am + pm;
    }
    
    for (int i = 0; i < 9; i++){
        printf("%s %d %d\n", name[i], sum[i], money[i]);
    }
    
    return (0);
}

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

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

long long read(){
	long long i;
	cin >> i;
	return i;
}

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

	const int n = read();
	const int m = read();
	vector<vector<int> > a(n, vector<int>(m));
	REP(i, n) {
		REP(j, m) {
			a[i][j] = read();
		}
	}

	vector<int> b(m);
	REP(j, m) {
		b[j] = read();
	}

	vector<int> answer(n);
	REP(i, n) {
		REP(j, m) {
			answer[i] += a[i][j] * b[j];
		}
	}
	
	REP(i, n) {
		cout << answer[i] << endl;;
	}

	return 0;
}



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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  string s; cin >> s;
  string year="";
  rep(i,4) year+=s[i];
  int y = stoi(year);
  string month = "";
  rep(i,2) month+=s[i+5];
  int m = stoi(month);
  string day = "";
  rep(i,2) day+=s[s.size()-1-1+i];
  int d = stoi(day);

  bool heisei = true;
  if(y>=2020) heisei = false;
  else if(m>=5) heisei = false;
  else if(m==4 && d>=31) heisei = false;

  if(heisei) cout << "Heisei" << endl;
  else cout << "TBD" << endl;
  
  return 0;
}


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

int main() {
    int n;

    while (cin >> n, n) {
        vector<ll> a(n);
        rep(i, n) cin >> a[i];

        ll ans = -1e18, cur = 0;
        rep(i, n) {
            cur = max(cur + a[i], a[i]);
            ans = max(ans, cur);
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3024
n = gets.to_i
a = gets.split.map &:to_i
b = gets.split.map &:to_i

x = 0
(n-1).times{|i|
  cnt = b[i..-1].inject(:+) + a[0..i].inject(:+)
  x = cnt if x < cnt
}

puts (n!=1)? x : (a[0]+b[0])


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> v(2*n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &v[i]);
        v[n+i] = v[i];
    }
    vector<ll> S(2*n+1);
    for (int i = 0; i < 2*n; ++i) {
        S[i+1] = S[i] + v[i];
    }
    auto f = [&](int i, ll X){
        auto next = lower_bound(S.begin()+i+1, S.begin()+i+1+n, S[i]+X);
        if(next == S.begin()+i+1+n) return false;
        auto nextnext = lower_bound(S.begin()+i+1, S.begin()+i+1+n, *next+X);
        if(nextnext == S.begin()+i+1+n) return false;
        return S[i+n] - *nextnext >= X;
    };
    ll ok = 0, ng = S[n]/3+2;
    while(ng-ok > 1){
        ll mid = (ok+ng)/2;
        int okk = 0;
        for (int i = 0; i < n; ++i) {
            if(f(i, mid)) {
                okk = 1;
                break;
            }
        }
        if(okk) ok = mid;
        else ng = mid;
    }
    cout << ok << "\n";
    return 0;
}


Measured memory_bytes: 5276
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll F[2100010];

ll Mul(ll a, ll b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
ll square(ll x) {
	return (x * x) % mod;
}

ll power(ll x, ll y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

ll Div(ll a, ll b) {
	return Mul(a, power(b, mod - 2));
}
ll p(ll n, ll r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

ll C(ll n, ll r) {
	if (n < r || n < 0 || r < 0) return 0;
	ll ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}
int A[10010];
int cnt[1000010];
int main()
{
	int N;
	cin >> N;
	int MAX = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		MAX = max(MAX, A[i]);
		int tmp = A[i];
		for (int j = 2; j * j <= A[i]; j++) {
			int c = 0;
			while (tmp % j == 0) {
				tmp /= j;
				c++;
			}
			cnt[j] = max(cnt[j], c);
		}
		cnt[tmp] = max(1, cnt[tmp]);
	}
	ll lcm = 1;
	ll ans = 0;
	for (int i = 2; i <= MAX; i++) {
		lcm = Mul(lcm, power(i, cnt[i]));
	}
	//cout << lcm << endl;
	for (int i = 0; i < N; i++) {
		ans = (ans + Div(lcm, A[i])) % mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 6208
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
int A,B;
cin>>A>>B;
vector<int> i;
i.push_back(A+B);
i.push_back(A-B);
i.push_back(A*B);
int ans;
ans=max(i[0],i[1]);
ans=max(ans,i[2]);
cout << ans<<endl;

}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
while ($n--) {
	fscanf(STDIN, "%s", $s);
	if (isset($x[$s])) { $x[$s]++; } else { $x[$s] = 1; }
}
fscanf(STDIN, "%d", $m);
while ($m--) {
	fscanf(STDIN, "%s", $t);
	if (isset($x[$t])) $x[$t]--;
}
sort($x);
echo max(0, end($x));

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

int main(){int N,c=0;cin>>N;vector<int> n(N);
           for(int i=0;i<N;i++)cin>>n[i];
           for(int i=1;i<N;i++){
             if(n[i]==n[i-1]){
               c++;n[i]=0;}}
           cout<<c<<endl;}

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

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc  = new Scanner(System.in);

    public static void main(String[] args){
        int N = nextInt();

        String s = next();

        println(N < 3200 ? "red" : s);
    }

    //各桁の和
    public static int sumDigits(long n) {
        int sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;//合計を返す
    }

    //最大公約数gcd
    static long gcd (long a, long b) {
        long temp;
        while ((temp = a % b) != 0) {
            a = b;
            b = temp;
        }
        return b;
    }
    //最小公倍数lcm
    static long lcm (long a, long b) {
        long temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return (c/b);
    }
    static int nextInt(){
        return Integer.parseInt(next());
    }
    static Long nextLong(){
        return Long.parseLong(next());
    }
    static String next(){
        return sc.next();
    }
    static void println(Object o){
        PrintWriter out = new PrintWriter(System.out);
        out.println(o);
        out.flush();
    }
   static void print(Object o){
       PrintWriter out = new PrintWriter(System.out);
       out.print(o);
       out.flush();
    }
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
/*
    *
    * Prosen Ghosh
    * American International University - Bangladesh (AIUB)
    *
*/

/*int sum(int n){

      int sum=0;
      while(n!=0){
         sum=sum+n%10;
         n/=10;
      }
      int ans=0
      if((sum/10)==0){
         break;
      }
      else{
          ans=sum(sum(sum(n)));
      }
      return ans;
}*/
int main(){
        
       //char str[100000];
    string str;
       int cnt=0,cnt2=0;
       cin>>str;
       //scanf("%s",&str);
       for(int i=0;i<str.length();i++){
            if(str[i]=='A' && str[i+1]=='C'){
                 cout<<"Yes"<<endl;
                 //break;
                 return 0;
            }
            
       }


       cout<<"No"<<endl;
       return 0;
       

    return 0;
}

Measured memory_bytes: 3572
from heapq import*
import sys
r=sys.stdin.readline
def g(n,E,S,G):
 F=[1e7]*-~n;F[S],H=0,[(0,S)]
 while H:
  c,u=heappop(H)
  if u==G:return c
  for f,v in E[u]:
   t=c+f
   if t<F[v]:F[v]=t;heappush(H,(t,v))
 return-1
def s(n,k):
 E=[[]for _ in[0]*-~n]
 for _ in[0]*k:
  f=r();p=map(int,f[2:].split())
  if'0'==f[0]:print(g(n,E,*p))
  else:c,d,e=p;E[c]+=[(e,d)];E[d]+=[(e,c)]
for e in iter(r,'0 0\n'):s(*map(int,e.split()))


Measured memory_bytes: 6312
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String[] ss = s.split("");
    Arrays.sort(ss);
    String strs = String.join("", ss);
    String t = sc.nextLine();
    String[] tt = t.split("");
    Arrays.sort(tt, Comparator.reverseOrder());
    String strt = String.join("", tt);
    if (strs.compareTo(strt) < 0)
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<set<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

// int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const int INF = 100000000;


int main() {

  int N;
  cin >> N;

  double en = 0.0, bit = 0.0;

  REP(i, N){
    double n;
    string s;
    cin >> n >> s;
    if(s == "JPY"){
      en += n;
    }else{
      bit += n;
    }
  }
  double ans = en + bit * 380000.0;

  cout << ans << endl;



}


/*
みんな、くるくるぱーにな〜れ
　∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a >= 13) {
            System.out.println(b);
        } else if (a >= 6) {
            System.out.println(b / 2);
        } else {
            System.out.println(0);

        }

    }
}


Measured memory_bytes: 22100
#!/usr/bin/env python3


import fractions


def naive_divisors(n):
    ds = set()
    for i in range(1, n + 1):
        d, m = divmod(n, i)
        if m == 0:
            ds.add(i)
            ds.add(d)
    return sorted(ds)


def solve(a, b, k):
    g = fractions.gcd(a, b)
    ds = naive_divisors(g)
    return ds[::-1][k - 1]


def main():
    a, b, k = (int(z) for z in input().split())
    print(solve(a, b, k))


if __name__ == "__main__":
    main()

Measured memory_bytes: 5560
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <cmath>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> m(40,0);
	int p = abs(n);
	int k = abs(log10(p) / log10(2))+1;

	for (int i = k; i >= 1; i--) {
		if (p>= exp2(i-1)) {
			m.at(i) = 1;
			p -= exp2(i-1);
		}
		else {
			m.at(i) = 0;
		}
	}

	int kk = 0;
	if (n > 0) {
		for (int i = 1; i <= k+2; i++) {
			if (m.at(i) == 2) {
				m.at(i) = 0;
				m.at(i + 1) += 1;
				if (i >= k) kk++;
			}
			if (i % 2 == 0 && m.at(i) == 1) {
				m.at(i + 1) += 1;
				if (i >= k) kk++;
			}
		}

		for (int i = k+kk; i >= 1; i--) {
			cout << m.at(i);
		}
		cout << endl;
	}
	else if (n < 0) {
		for (int i = 1; i <= k+2; i++) {
			if (m.at(i) == 2) {
				m.at(i) = 0;
				m.at(i + 1) += 1;
				if (i >= k) kk++;
			}
			if (i % 2 == 1 && m.at(i) == 1) {
				m.at(i + 1) += 1;
				if (i >= k) kk++;
			}
		}
		for (int i = k+kk; i >= 1; i--) {
			cout << m.at(i);
		}
		cout << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;


}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;
    cin >> n;
    
    cout << (n - 1) / 2 << endl;
    
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    if(a>0&&b>0){
        puts("Positive");
        return 0;
    }
    if((a==0||b==0)||(a<0&&b>0)){
        puts("Zero");
        return 0;
    }
    int c=abs(a-b);
    if(c%2==0){
        puts("Negative");
        return 0;
    }
    puts("Positive");
    return 0;
} 

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	static long coins = Long.MAX_VALUE;

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

		int k = getInt(sc);
		if(k%2==0) {

			System.out.println((k/2)*(k/2));
		}else {
			System.out.println((k/2)*(k/2+1));
		}


	}

	/**
	 * *汎用メソッド<br>
	 * 入力した配列に対する順列を取得
	 *
	 * @param numArray
	 * @return
	 */
	private static List<Integer[]> getPermutation(int[] numArray) {
		List<Integer[]> permutation = new ArrayList<>();
		Integer[] ans = new Integer[numArray.length];
		boolean[] used = new boolean[numArray.length];

		return buildPermutaion(permutation, numArray, ans, used, 0);
	}

	/**
	 * *汎用メソッド(内部)<br>
	 * 入力した配列に対する順列を作成
	 *
	 * @param list
	 * @param numArray
	 * @param ans
	 * @param used
	 * @param depth
	 * @return
	 */
	private static List<Integer[]> buildPermutaion(List<Integer[]> list, int[] numArray, Integer[] ans, boolean[] used,
			int depth) {

		// 全部使い切った時=>できた順列を返す
		if (depth == numArray.length) {
			list.add(ans.clone());
			return list;
		}
		// 使い切っていない場合

		for (int i = 0; i < numArray.length; i++) {
			if (used[i]) {
				continue;
			}
			ans[depth] = numArray[i];
			used[i] = true;
			list = buildPermutaion(list, numArray, ans, used, depth + 1);

			used[i] = false;
		}

		return list;
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}

class Status {
	long x;
	long tmpCoins;

	public Status(long x, long tmpCoins) {
		this.x = x;
		this.tmpCoins = tmpCoins;
	}
}


Measured memory_bytes: 24916
#include<iostream>
#define ll long long 
using namespace std;
int n=0;
int dif=0;//字母的种类
char s[1010]; 
void dfs(int i){//这传进来的是字母的长度 
	if(i==n+1){
		cout<<s+1<<endl;
		return ;//结束这次的调用 
	}
	for(int j=0;j<=dif/*遍历字母的种类数*/;j++){
		s[i]='a'+j;
		int temp=dif;//这是字符串的种类
		if(j==dif){//到达第 k  位，此时应该向后推一位 
			dif++;
		}
		dfs(i+1);
		dif=temp;
	}
}
int main(){
	cin>>n;//要求字符串的长度 
	dfs(1);
	return 0;
}

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

using namespace std;

int main() {
    int n,quantum;
    cin >> n >> quantum;
    
    queue<pair<string,int> > q;
    string name;
    int time;
    rep(i,n) {
        cin >> name >> time;
        q.push(make_pair(name,time));
    }
    
    pair<string,int> p;
    int total = 0;
    while(!q.empty()) {
        
        p = q.front();
        q.pop();
        
        p.second -= quantum;
        
        if(p.second > 0) {
            q.push(p);
            total += quantum;
        } else {
            total += (quantum - abs(p.second));
            cout << p.first << " " << total << endl;
        }
    }
    
}
    



Measured memory_bytes: 6320
#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] << " "; cout << endl;}
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 n; cin >> n;
    set<ll> st;
    for (ll i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            st.insert(i);
            st.insert(n/i);
        }
    }
    ll ans = 0;
    for (ll x : st) {
        ll m = n/x - 1;
        if (m == 0) continue;
        if (n/m == n%m) ans += m;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
main()
{
    int t,h,j,i,k=0;
    string a,b;
    cin>>a>>b;
    for(i=0;i<3;i++)
    {
        if(a[i]==b[i])
            k++;
    }
    cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int fr[6][2] = {{2,380},{3,550},{5,850},{10,1520},{12,1870},{15,2244}};
  int dp[51] = {0},n;
  for(int i=1; i<51; i++){dp[i] = 10000;}
  for(int i=0; i<51; i++){
    for(int j=0; j<6; j++){
      if(fr[j][0]<=i){
	dp[i] = min(dp[i],dp[i-fr[j][0]]+fr[j][1]);
      }
    }
  }
  while(cin>>n,n){
    cout <<dp[n/100]<<endl;
  }
  return 0;
}

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

struct I{
    I(){
	ios::sync_with_stdio(false);
	cin.tie(0);
    }
};
#define rep(i,n) for(auto i=(n)*0;i<n;i++)
#define range(it,v) for(auto &it:v)

typedef vector<int> V;
typedef vector<V> VV;
//KMP
int kmp_search(string S,string word,V& table){
    int n=S.size();
    int m=word.size();
    int i=0,j=0;
    for(;j<n&&i<m;i++,j++)
	while(i>=0&&word[i]!=S[j])i=table[i];
    if(i==m)return j-m;
    else return -1;
}


V kmp_table_build(string word){
    int n=word.size();
    V table(n,0);
    table[0]=-1;
    for(int i=2,j=0;i<n;){
	if(word[i-1]==word[j])table[i++]=++j;
	else if(j>0)j=table[j];
	else table[i++]=0;
    }
    return table;
}
bool cww(string& S,string &word,V &table,int &i){
    int n=S.size();
    int m=word.size();
    int j=0;
    for(;j<n&&i<m;i++,j++)
	while(i>=0&&word[i]!=S[j])i=table[i];
    return i==m;
}


int main(){
    for(int n;cin>>n,n;){
	vector<string> S(n);
	range(it,S)cin>>it;
	VV tables(n);
	rep(i,n)
	    tables[i]=kmp_table_build(S[i]);
	VV sz(n,V(n,0));
	VV contain(n,V(n,0));
	rep(i,n){
	    V pos(n,0);
	    int used=0;
	    rep(j,n)if(cww(S[i],S[j],tables[j],pos[j]))used|=(1<<j);
	    contain[i][i]=used;
	    sz[i][i]=S[i].size();
	    rep(j,n)
		if(i!=j){
		    if(used&(1<<j)){
			sz[i][j]=114514;
			contain[i][j]=0;
		    }
		    else{
			string add=S[j].substr(pos[j]);
			int m=(1<<n)-1-used;
			auto nxt_pos=pos;
			auto nxt_used=0;
			while(m){
			    int now=__builtin_ctz(m);
			    if(cww(add,S[now],tables[now],nxt_pos[now]))nxt_used|=(1<<now);
			    m-=(1<<now);
			}
			contain[i][j]=nxt_used;
			sz[i][j]=add.size();
		    }
		}
	}
	//rep(i,n){rep(j,n)cout<<" " << contain[i][j];cout<<endl;}
	VV dp(n,V(1<<14,114514));
	rep(i,n)dp[i][contain[i][i]]=sz[i][i];
	V bits(1<<n);
	iota(bits.begin(),bits.end(),0);
	sort(bits.begin(),bits.end(),[&](int l,int r){return __builtin_popcount(l)< __builtin_popcount(r);});
	rep(i,(1<<n)){
	    if(i==0)continue;
	    int& nowbit=bits[i];
	    rep(j,n)rep(k,n){
		int nxtbit=nowbit|contain[j][k];
		dp[k][nxtbit]=min(dp[k][nxtbit],dp[j][nowbit]+sz[j][k]);
	    }
	}
	int res=114514;
	rep(i,n)res=min(res,dp[i][(1<<n)-1]);
	cout<<res<<endl;
    }
    
}

Measured memory_bytes: 3824
#bin/usr/env python3

N = int(input())
a = input()
x = 0
b = []

a = a.split()
for i in a:
	b.append(int(i))
b.sort()
for i in range(N):
	c = b[-(2*(i+1))]
	x += int(c)
print(x)

Measured memory_bytes: 37084
#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;
    scanf("%d", &n);
    vector<int> ary(n);
    vector<int> cnt(n+1);
    rep(i, n){
        scanf("%d", &ary[i]);
        cnt[ary[i]]++;
    }
    ll tmp = 0;
    for(ll c : cnt){
        tmp += c * (c-1) / 2;
    }
    for(int v : ary){
        printf("%lld\n", tmp - cnt[v] + 1);
    }
    return 0;
}

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

using namespace std;


int main() {
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < int(s.length()); i++) {

		if (s[i] != t[i]) {
			cout << "No"<<endl;
			return 0;
		}
	}
	if (s.length() != t.length() - 1) {
		cout << "No"<<endl;
		return 0;
	}
	cout << "Yes"<<endl;
	return 0;
	
}

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

int main()
{
  int A, B, M;
  cin >> A >> B >> M;
  
  int a[A], b[B], minA = 100000, minB = 100000;
  for(int i = 0; i < A; ++i)
  {
    cin >> a[i];
    if(minA > a[i]) minA = a[i];
  }
  for(int i = 0; i < B; ++i)
  {
    cin >> b[i];
    if(minB > b[i]) minB = b[i];
  }
  
  int min = minA + minB;
  for(int i = 0; i < M; ++i)
  {
    int x, y, c;
    cin >> x >> y >> c;
    if(min > a[x-1] + b[y-1] - c) min = a[x-1] + b[y-1] - c;
  }
  
  cout << min << endl;
}

Measured memory_bytes: 4364
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: usize,
        s: String,
    }

    let vc: Vec<char> = s.chars().collect();
    let mut east_dir = (
        vc.iter().filter(|&c| *c == 'W').count() as u32,
        vc.iter().filter(|&c| *c == 'E').count() as u32,
    );
    let mut west_dir: (u32, u32) = (0, 0);
    let mut ans = n as u32 + 1;
    for i in 0..n {
        let mut humans = west_dir.0 + east_dir.1;
        if vc[i] == 'E' && east_dir.1 > 0 {
            humans -= 1;
        }
        if humans < ans {
            ans = humans;
        }

        if vc[i] == 'W' {
            west_dir.0 += 1;
            east_dir.0 -= 1;
        } else {
            west_dir.1 += 1;
            east_dir.1 -= 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 3948
using System;
using System.Linq;
using System.Text;

public class Program
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var canUse = new int[100000].Select(x => x = int.MaxValue).ToArray();
        var arphas = "abcdefghijklmnopqrstuvwxyz";
        for (int i = 0; i < n; i++)
        {
            var str = Console.ReadLine();
            foreach (var arpha in arphas)
            {
                canUse[arpha] = Math.Min(canUse[arpha], str.Where(x => x == arpha).Count());
            }
        }

        var sb = new StringBuilder();
        foreach (var arpha in arphas)
        {
            for (int i = 0; i < canUse[arpha]; i++)
            {
                sb.Append(arpha);
            }
        }

        Console.WriteLine(sb.ToString());
    }
}

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

const int inf = 1e9;
const ll linf = 1e18;

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

    int n; cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int l, r; cin >> l >> r;
        ans += (r - l + 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
bool echeck(ll a) { return a % 2 == 0 ? 1 : 0; }
ll comb(ll n, ll m){
  ll tmp = 1;
  for(int i = n; i >= n - m + 1; i--){
    tmp *= i;
  }
  ll temp = 1;
  for(int i = 1; i <= m; i++){
    temp *= i;
  }
  return tmp / temp;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  int n,q;
  cin >> n >> q;
  vector<priority_queue<ll>>Q(n);
  int tmp,t,x;
  rep(i,q){
    cin >> tmp;
    if(tmp == 0){
      cin >> t >> x;
      Q[t].push(x);
    }
    else if(tmp == 1){
      cin >> t;
      if(Q[t].size() == 0)continue;
      else cout << Q[t].top() << endl;
    }
    else{
      cin >> t;
      if(Q[t].size() == 0)continue;
      else Q[t].pop();
    }
  }
  return 0;
}  


Measured memory_bytes: 5148
#include <bits/stdc++.h>
#define INF (1<<29)
#define all(c) (c).begin(),(c).end()
#define pb(c) push_back(c)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int getv(int x){
  if(x == 4) return 5;
  return (x < 4) ? x : x+2;
}

void convert(int n){
  if(n == 0) return;
  convert( n/8 );
  cout << getv(n%8);
}

int main(){
  ios::sync_with_stdio(false);
  int n;

  while(cin >> n && n){
    convert(n);
    cout << endl;
  }


}

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

const int maxn = 1e5 + 5;

int dp [maxn], a [maxn];

int main () {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    dp[i] = INT_MAX;
  }
  dp[0] = 0;
  for (int i = 1; i < n; i++) {
    for (int j = i - 1; j >= max(i - k, 0); j--) {
      dp[i] = min (dp[i], dp[j] + abs (a[i] - a[j]));
    }
  }
  cout << dp[n - 1] << '\n';
  return 0;
}

Measured memory_bytes: 1024
N,K = map(int,input().split())

if K%2 == 1:
    ans = pow(int(N/K),3)
else:
    if N%K >= int(K/2):
        ans = pow(int(N/K) + 1,3)  + pow(int(N/K),3)
    else:
        ans = pow(int(N/K),3) * 2

print(ans)


Measured memory_bytes: 3060
//People only find me interesting because they can't tell whether I'm serious or not
//#include <boost/multiprecision/cpp_int.hpp> 
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
typedef long long int ll;
typedef double db;
typedef __int128 s128;
typedef __uint128_t u128;
typedef unsigned long long u64;
#define int long long int
#define P 1000000007
#define Q 1000000006
#define sz(a) (ll)a.size()
#define lt(a) (ll)a.length()
#define pll pair<ll,ll>
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define bac(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define teevra_gati ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define N 100005
#define PI 3.14159265359
#define inf LLONG_MAX
//using namespace boost::multiprecision; 
using namespace __gnu_pbds;
using namespace std;
vl adj[N];
ll vis[N],dp[N];
void dfs(ll s){
    for(auto u:adj[s]){
        if(!vis[u]){
            vis[u]=1;
            dfs(u);
        }
        dp[s] = max(dp[s], 1 + dp[u]);
    }
}

void solve(){
    ll n,m,ans=0;
    cin>>n>>m;
    f(i,0,m){
        ll x,y;
        cin>>x>>y;
        adj[x].pb(y);
    }
    f(i,1,n+1){
        if(!vis[i]){
            vis[i]=1;
            dfs(i);
        }
        ans = max(ans, dp[i]);
    }
    cout<<ans;

}
signed main() {
    teevra_gati
    
    solve();

    return 0;
}

Measured memory_bytes: 9344
using System;

class Program
{
    static void Main(string[] args)
    {

        while (true)
        {
            var input = Console.ReadLine();
            var values = input.Split(' ');
            int a = int.Parse(values[0]);
            int b = int.Parse(values[2]);
            string op = values[1];

            switch (op)
            {
                case "+":
                    Console.WriteLine("{0}", a + b);
                    break;
                case "-":
                    Console.WriteLine("{0}", a - b);
                    break;
                case "*":
                    Console.WriteLine("{0}", a * b);
                    break;
                case "/":
                    Console.WriteLine("{0}", a / b);
                    break;
                case "?":
                    return;
                default:
                    break;
            }
        }
    }
}

Measured memory_bytes: 5724