akhauriyash/Code-Regression huggingface dataset:
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;


int main(){
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N), B(M), C(N + 1, 0), D(M + 1, 0);
    rep(i, 0, N) cin >> A.at(i);
    rep(i, 0, M) cin >> B.at(i);
    
    C.at(1) = A.at(0);
    rep(i, 1, N){
        C.at(i + 1) = C.at(i) + A.at(i);
    }
    
    D.at(1) = B.at(0);
    rep(i, 1, M){
        D.at(i + 1) = D.at(i) + B.at(i);
    }
    
    ll j = 0, ans = 0;
    for(ll i = N; i >= 0; i--){
        if(C.at(i) > K) continue;
        
        ll time = K - C.at(i);
        while((j < M) &&D.at(j + 1) <= time){
            j++;
        }
        //cout << i << " " << j << endl;
        ans = max(ans, i + j);
    }
    cout << ans << endl;
}

Measured memory_bytes: 9568
#include <bits/stdc++.h>
#define ll int
#define MAX 5000005
using namespace std;

ll gcd(ll a, ll b){
    if(!b) return a;
    return gcd(b, a%b);
}

int n;
ll ans = 0;

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= n; k++){
                ans += gcd(gcd(i,j),k);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    from collections import defaultdict

    NIL = -1

    n = int(input())

    # pythonは構造体を用意するのに手間取るので、辞書型を使う
    # 本の40行目はpythonならdefaultdictで実装可能
    T = defaultdict(lambda: {'p':NIL, 'l':NIL, 'r':NIL})
    D = {}

    # 入力の受け取りは本と若干異なります
    for _ in range(n):
        id, k, *cc = map(int, input().split())
        if k != 0:
            T[id]['l'] = cc[0]
        else:
            T[id]['l'] = NIL
        r = NIL
        for c in cc[::-1]:
            T[c]['p'] = id
            T[c]['r'] = r
            r = c

    # 再帰的に深さを求める
    # 本と同様のコードのすると
    # 再帰回数のエラー(maximum recursion depth exceeded in comparison)
    # が生じるため、自分の子供全てに対して自分の深さ+1することにして解決
    def rec(u, p):
        D[u] = p
        l = T[u]['l']
        while l != NIL:
            rec(l, p+1) # 自分の子に自分の深さ+1を設定
            l = T[l]['r']

    for i, value in T.items():
        if value['p'] == NIL:
            r = i
            break  # breakがなくても問題ないが、余計な計算をしないようにするためつけた

    rec(r, 0)

    def print_children(u):
        c = T[u]['l']
        i = 0
        while c != NIL:
            if i == 0:
                i = 1
            else:
                print(', ', end='')
            print(str(c), end='')
            c = T[c]['r']

    for u in range(n):
        value = T[u]
        print('node ' + str(u) + ': ', end='')
        print('parent = ' + str(value['p']) + ', ', end='')
        print('depth = ' + str(D[u]) + ', ',end='')
        if value['p'] == NIL:
            type = 'root'
        elif value['l'] == NIL:
            type = 'leaf'
        else:
            type = 'internal node'
        print(type + ', ', end = '')
        print('[',end = '')
        print_children(u)
        print(']')


Measured memory_bytes: 48456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = null;

		// エラトステネスの篩
		int MAX = 1000000;
		int num = (MAX - 3) / 2;
		boolean[] prime = new boolean[MAX + 1];
		Arrays.fill(prime, true);
		int count = 1;
		int[] total = new int[10000 + 1];
		total[1] = 2;

		for (int i = 0; i < num; i++) {
			if (prime[i] == true) {
				int primeNum = i + i + 3;
				count++;
				total[count] = total[count - 1] + primeNum;
				for (int j = i + primeNum; j <= MAX; j += primeNum)
					prime[j] = false;
				if(count == 10000) break;
			}
		}
		
		try {
			while ((line = br.readLine()) != null) {
				line = line.trim();
				if (line.equals("0"))
					break;
				int N = Integer.parseInt(line);
				
				System.out.println(total[N]);
			}
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}

Measured memory_bytes: 22612
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>

#define INF 1010001000

using namespace std;

int main()
{
    int n, a, b;
    cin >> n;

    vector<vector<int> > tree(n);

    for (int i = 0; i < n-1; i++) {
        cin >> a >> b;
        tree[--a].push_back(--b);
        tree[b].push_back(a);
    }

    vector<int> data(n, INF);
    priority_queue<pair<int, int>, vector<pair<int, int> >,
        greater<pair<int, int> > > priQue;

    int k;
    cin >> k;
    for (int i = 0; i < k; i++) {
        cin >> a >> b;
        data[--a] = b;
        priQue.push(pair<int, int>(b, a));
    }

    while (!priQue.empty()) {
        pair<int, int> p = priQue.top();
        priQue.pop();
        for (int i = 0; i < tree[p.second].size(); i++) {
            if (data[tree[p.second][i]] == INF) {
                data[tree[p.second][i]] = data[p.second] + 1;
                priQue.push(pair<int, int>(data[tree[p.second][i]], 
                            tree[p.second][i]));
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < tree[i].size(); j++) {
            if (abs(data[i] - data[tree[i][j]]) != 1) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    for (int i = 0; i < n; i++) {
        cout << data[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 7924
#include<stdio.h>
#include<string.h>
int s[8][8],a[8],book[8],b[16],c[16];
void cn(int x)
{
    int i,j;
    if(x==8)
    {
        for(i=0; i<8; i++)
        {
            for(j=0; j<8; j++)
            {
                if(s[i][j])
                {
                    if(a[i]!=j)
                        return;
                }
            }
        }
        for(i=0; i<8; i++)
        {
            for(j=0; j<8; j++)
            {
                if(a[i]==j)
                    printf("Q");
                else
                    printf(".");
            }
            printf("\n");
        }
        return;
    }
    for(i=0; i<8; i++)
    {
        if(book[i]||b[x+i]||c[x-i+7])
            continue;
        a[x]=i;
        book[i]=b[x+i]=c[x-i+7]=1;
        cn(x+1);
        book[i]=b[x+i]=c[x-i+7]=0;
    }
}
int main()
{
    int r,l,n,i;
    memset(s,0,sizeof(s));
    memset(a,0,sizeof(a));
    memset(book,0,sizeof(book));
    memset(b,0,sizeof(b));
    memset(c,0,sizeof(c));
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {
        scanf("%d%d",&r,&l);
        s[r][l]=1;
    }
    cn(0);
    return 0;
}



Measured memory_bytes: 2684
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
ll n,arr[400005];
ll ans;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=1;i<=3*n;i++){
        cin>>arr[i];
    }
    sort(arr+1,arr+3*n+1);
    for(int i=1;i<=n;i++){
        int idx=i*2;
        ans+=arr[3*n-idx+1];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
fn solve(sum: i64, xor: i64, sup: i64) -> Option<i64> {
    if xor > sum || (sum - xor) % 2 != 0 {
        return None;
    }
    let and = (sum - xor) / 2;
    let mut v = and;
    for i in (0..41).rev() {
        if xor >> i & 1 == 1 && and >> i & 1 == 0 && v + (1 << i) <= sup {
            v += 1 << i;
        }
    }
    if 0 < v && v <= sup && v ^ (sum - v) == xor {
        Some(sup - v)
    } else {
        None
    }
}

fn run() {
    proconio::input! {
        n: usize,
        a: [i64; n],
    }
    let xor = a.iter().skip(2).fold(0, |s, a| s ^ *a);
    let sum = a[0] + a[1];
    if let Some(ans) = solve(sum, xor, a[0]) {
        println!("{}", ans);
    } else {
        println!("-1");
    }
}

fn main() {
    run();
}


Measured memory_bytes: 2140
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())
ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += gcd(a, b, c)
print(ans)

Measured memory_bytes: 69688
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main{
  public static void main(String[] args){
    BufferedReader in = null;
    
    String line = "";
    
    String result = "";
    
    try{
      in = new BufferedReader(new InputStreamReader(System.in));
      line = in.readLine();
      
      String x = line.split(" ")[0];
      String y = line.split(" ")[1];
      
      HashMap<String, String> group = new HashMap<String, String>();
      group.put("1", "A");
      group.put("3", "A");
      group.put("5", "A");
      group.put("7", "A");
      group.put("8", "A");
      group.put("10", "A");
      group.put("12", "A");
      group.put("4", "B");
      group.put("6", "B");
      group.put("9", "B");
      group.put("11", "B");
      group.put("2", "C");
      
      String xGroup = group.get(x);
      String yGroup = group.get(y);
      
      if(xGroup.equals(yGroup)){
        result = "Yes";
      }else{
        result = "No";
      }
    
    }catch(Exception e){
      e.printStackTrace();
      result = "Error!";
    }finally{
      try{
        in.close();
      }catch(Exception e){
        result = "Error!";
      }
      System.out.println(result);
    }
  }
}


Measured memory_bytes: 23124
#include <iostream>
using namespace std;
#define MAX 100000

int partition(int a[], int p, int r) {
    int x = a[r];
    int i = p - 1;
    for (int j = p; j < r; j++) {
        if (a[j] <= x) {
            i++;
            swap(a[i], a[j]);
        }
    }
    swap(a[i+1], a[r]);
    return i + 1;
}

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

    int q = partition(a, 0, n - 1);

    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        if (i == q) cout << "[";
        cout << a[i];
        if (i == q) cout << "]";
    }
    cout << endl;
}



Measured memory_bytes: 3484
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
 if(x1 == 0){
   cout << 1 <<endl;
 }
  else if(x2 == 0){
    cout << 2 <<endl;
  }
  else if(x3 == 0){
    cout << 3 <<endl;
  }
  else if(x4 == 0){
    cout << 4 <<endl;
  }
  else{
    cout << 5 <<endl;
  }
}

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

int main(){
 int x;
 int h;
 int m;
 int s;
cin >> x;
h=x/3600;
m=(x-3600*h)/60;
s=x-3600*h-60*m;
cout << h <<":"<<m<<":"<<s<<endl;
    return 0;
}

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

const ll MX =1e18;

int main(){
  int n;
  cin>>n;
  ll ans=1;
  bool ng =false;
  rep(i,n) {
    ll a;
    cin>>a;
    if(a==0){
      cout<<0<<endl;
      return 0;
    }
    if(ng || MX/ans < a){
     ng = true;
    }
    ans*=a;
  }
  if(ng) cout<< -1<<endl;
  else cout<<ans<<endl;
  return 0;
}
    
      
    
  
  
  
  



Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n'; cout << fixed << setprecision(10);

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	bool f = 0;
	int n;
	cin >> n;
	rep(i, 3) {
		if (n % 10 == 7) { f = 1; break; }
		n /= 10;
	}
	if (f)cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 3644
count, x = gets.chomp.split(" ").map(&:to_i)
yen10000 = -1
yen5000 = -1
yen1000 = -1

(0..count).each do |a|
    (0..count-a).each do |b|
        if a*10000 + b*5000 + (count - a - b)*1000 == x
            yen10000,yen5000,yen1000 = a ,b,(count-a-b)
        end
    end
end
puts "#{yen10000} #{yen5000} #{yen1000}"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i].size() << " ";
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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


int main(int argc, char const *argv[]) {
    int n; cin>>n;
    if (n==1) {
        printf("Yes\n%d\n%d %d\n%d %d\n",2,1,1,1,1);
        return 0;
    }
    int ok = -1;

    for (int i = 1; i <= n; ++i) {
        if (i*(i-1)/2 == n) {
            ok = i;
            break;
        }
    }

    if (ok == -1) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    cout << ok << endl;
    vector<vector<int>> a(ok-1);
    vector<vector<int>> ans(ok);
    int col = 1;
    int cnt = 1;

    rep(i,ok-1) {
        rep(j,col) {
            a[i].push_back(cnt);
            ++cnt;
        }
        ++col;
    }

    rep(i,ok-1) {
        int yoko = i;
        rep(j,yoko) {
            ans[i].push_back(a[i][j]);
        }
        for (int j = i; j < ok-1; ++j) {
            ans[i].push_back(a[j][yoko]);
        }
    }

    rep(i,ok-1) {
        ans[ok-1].push_back(a[i].back());
    }

    print(ans);

    return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>
#include <map>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int n, m;
    cin >> n >> m;

    vector<int> p(m), y(m);
    vector<vector<int> > v(n);
    v.resize(n);

    for (int i=0; i< m; i++) {
        int pt, yt;

        cin >> pt >> yt;
        p[i] = pt;
        y[i] = yt;
        v[pt-1].push_back(yt);
    }


    map<int, int> mp[100001];
    for (int i=0; i<n; i++){
        sort(v[i].begin(), v[i].end());
        for(int j=0; j<v[i].size(); j++) {
            mp[i+1][v[i][j]] = j+1;
        }
    }


    for (int i=0; i<m; i++){
        printf("%06d%06d\n", p[i], mp[p[i]][y[i]] );
    }

    return 0;
}

Measured memory_bytes: 17152
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int mod=1e9+7;
int dp[200005][2];
int mm[200005];


signed main()
{

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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n;
    cin>>n;
    n*=2;
    string s;
    cin>>s;
    s="#"+s;
    dp[0][0]=1;
    if(s[1]=='W')
    {
        cout<<0;
        return 0;
    }
    vector<int>pos;
    dp[1][1]=1;
    for(int i=2;i<=n;i++)
    {
        if(s[i]=='W')
        {
            dp[i][1]=dp[i-1][0];
            dp[i][0]=dp[i-1][1];
            if(dp[i][1])
                mm[i]=1;
        }
        else
        {
            dp[i][0]=dp[i-1][1];
            dp[i][1]=dp[i-1][0];
            if(dp[i][0])
                mm[i]=1;
        }        
    }
    int ans=1;
    int tot=0;
    for(int i=1;i<=n;i++)
    {
        if(mm[i])
        {
            ans*=tot;
            tot--;
        }
        else
        {
            tot++;
        }        
        if(tot<0)
        {
            cout<<0;
            return 0;
        }
        ans%=mod;
    }
    if(tot!=0)
    {
        cout<<0;
        return 0;
    }
    int lol=1;
    for(int i=1;i<=n/2;i++)
    {
        lol*=i;
        lol%=mod;
    }
    ans*=lol;
    ans%=mod;
    cout<<ans;

} 



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

int main(){
	int n; cin >> n;
	vector<int> a(n), b(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> b[i];
	reverse(b.begin(), b.end());
	int l = 0, r = -1, c;
	for(int i = 0; i < n; i++)
		if(a[i]==b[i]){
			l = i; c = a[i]; 
			break;
		}
	for(int i = n-1; 0 <= i; i--)
		if(a[i]==b[i] && a[i]==c){
			r = i; break;
		}
	for(int i = 0; i < n && l <= r; i++)
		if(a[i]!=c && b[i]!=c) swap(b[i], b[l++]);
	if(l<=r) cout << "No\n";
	else {
		cout << "Yes\n";
		for(int i = 0; i < n; i++) cout << b[i] << ' ';
		cout << '\n';
	}
	return 0;
}


Measured memory_bytes: 4828
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
  int N, K, X, Y,a=0,b;
  
  cin>> N >> K >> X >> Y ;
  
  
  if(N<=K){
      
      a=N*X;
  }
  

  
  if(N>K){
      
      b=N-K;
      
      a=K*X+a+Y*b;
      
  }
  
  
  
  cout<<a<<endl;
  
  
}


Measured memory_bytes: 256
(let ((s (make-array 4))
    (ans "Good"))
    (loop for i below 4 do
        (setf (aref s i) (read-char))
    )
    (if (char= (aref s 0) (aref s 1))
        (setq ans "Bad")
    )
    (if (char= (aref s 1) (aref s 2))
        (setq ans "Bad")
    )
    (if (char= (aref s 2) (aref s 3))
        (setq ans "Bad")
    )
    (princ ans)
)

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

int N, A[100000], B[100000];
long long C[100000];

int main(){
	long long total = 0;
	scanf("%d", &N);
	for(int i = 0; i < N; i++) scanf("%d", &A[i]);
	sort(A, A + N);
	for(int i = 0; i < N; i++)
		scanf("%d", &B[i]);
	sort(B, B + N);
	for(int i = 0; i < N; i++){
		int low = lower_bound(A, A + N, B[i]) - A;
		if(i < 1) C[i] = low;
		else C[i] = (long long)low + C[i - 1];
	}
	for(int i = 0; i < N; i++){
		int val;
		scanf("%d", &val);
		int low = lower_bound(B, B + N, val) - B;
		if(low > 0) total += C[low - 1];
	}
	printf("%lld\n", total);
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string S;
	set<char> c;

	cin >> S;
	rep(i, (int)S.length()) c.insert(S[i]);

	if (c.size() == S.length()) cout << "yes" << endl;
	else cout << "no" << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    Tenka1PCB2017B solver = new Tenka1PCB2017B();
    solver.solve(1, in, out);
    out.close();
  }

  static class Tenka1PCB2017B {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int n = in.nextInt();
      Pair[] p = new Pair[n];
      for (int i = 0; i < n; i++) {
        int a = in.nextInt();
        int b = in.nextInt();
        p[i] = new Pair(a, b);
      }

      Arrays.sort(p);

      System.out.println(p[n - 1].x + p[n - 1].y);

    }

  }

  static class Pair implements Comparable<Pair> {

    int x;
    int y;

    Pair(int x, int y) {
      this.x = x;
      this.y = y;
    }

    public int compareTo(Pair p) {
      return Integer.compare(this.x, p.x) * 2 + Integer.compare(this.y, p.y);
    }

  }
}



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

int main() {
	int n;
	cin >> n;
	int a[1000];
	int b[1000];
	int c[1000];
	
	for (int i = 0; i < n; ++i) cin >> a[i];
	for (int i = 0; i < n; ++i) cin >> b[i];
	for (int i = 0; i < n; ++i) cin >> c[i];

  	
	int sum = 0;

	for (int i = 0; i < n; ++i) {
		sum += b[a[i] - 1];
		if (a[i]+1 == a[i + 1]) sum += c[a[i]-1];
	}
	cout << sum << endl;
}

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

int judge(int, int);
void insert(int, int);
void print(int);

char S[51], T[51];

int main(){
    int i, j, Slen, Tlen, cnt=0, n=-1;

    scanf("%s", S);
    scanf("%s", T);

    Slen = strlen(S);
    Tlen = strlen(T);

    if(Slen < Tlen){
        printf("UNRESTORABLE\n");
        return 0;
    }

    for(i=0; i<Slen; i++){
        if(S[i] == '?')
            cnt++;
    }
    if(cnt == Slen){
        insert(Slen-Tlen, Tlen);
        print(Slen);
        
        return 0;
    }

    for(i=0; i<Slen-Tlen+1; i++){
        if(judge(i, Tlen) == 1){
            n = i;
        }
    }
    if(n != -1){
        insert(n, Tlen);
        print(Slen);

        return 0;
    }

    printf("UNRESTORABLE\n");

    return 0;

}

int judge(int n, int len){
    int i, cnt=0;
    for(i=0; i<len; i++){
        if(S[i+n] == T[i] || S[i+n] == '?')
            cnt++;
    }

    if(len == cnt)
        return 1;
    else
        return 0;
}

void insert(int n, int len){
    int i;
    for(i=0; i<len; i++){
        S[i+n] = T[i];
    }
}

void print(int len){
    int i;
    for(i=0; i<len; i++){
        if(S[i] != '?')
            printf("%c", S[i]);
        else
            printf("a");
    }
    printf("\n");
}

Measured memory_bytes: 128
class Graph
  attr_accessor :n, :node
  def initialize(n)
    @n = n
    @node = Array.new(n){ [] }
  end

  def add(i,j)
    node[i] << j
    node[j] << i
  end

  def is_connected?
    seen = Array.new(n, false)
    seen[0] = true
    que = [0]
    while que.size > 0
      v = que.shift
      node[v].each do |nv|
        next if seen[nv]
        seen[nv] = true
        que << nv
      end
    end
    seen.all?(&:itself)
  end
end

class Problem
  attr_accessor :a, :b, :n, :m, :h, :w

  def initialize
    @n,@m = gets.to_s.split.map{ |v| v.to_i }
    @a = Array.new(m){ gets.to_s.split.map{ |v| v.to_i - 1 } }
  end

  def solve
    ans = 0
    m.times do |i|
      g = Graph.new(n)
      m.times do |j|
        next if i == j
        g.add(*a[j])
      end
      ans += 1 unless g.is_connected?
    end
    ans
  end

  def show(ans)
    puts ans
  end
end

Problem.new.instance_eval do
  show(solve)
end


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

int main() {
  	int n,m;
  	string ans;
  
  	cin >> n;
  	m = n % 10;
  	if (m==3)
      ans="bon";
  	else if (m==0 || m==1 || m==6 || m==8)
      ans="pon";
  	else
      ans="hon";
  
  	cout << ans << endl;
}


Measured memory_bytes: 3628
"use strict"

const main = arg => {
  arg = arg.trim().split("\n");
  const A = parseInt(arg[0].split(" ")[0]);
  const B = parseInt(arg[0].split(" ")[1]);
  const C = parseInt(arg[0].split(" ")[2]);
  const X = parseInt(arg[0].split(" ")[3]);
  const Y = parseInt(arg[0].split(" ")[4]);
  
  const AB = 2 * C;
  
  // ABセットはA,Bをバラで1枚づつ買うのに比べお得か？
  if(A + B > AB) {
      let priceAB = AB * Math.min(X, Y);
      let soloPrice = 0;
      
      if(X > Y) {
        soloPrice = A * (X - Y);
      } else if(Y > X) {
        soloPrice = B * (Y - X);  
      }
      
      let partialAB = priceAB + soloPrice;
      let allAB = AB * Math.max(X, Y);
      
      // 余りが出ても全てABセットで買う方法と
      // 一部ABセットで買って、残りをバラで買う方法を比較して安い方
      console.log(Math.min(allAB, partialAB));
  } else {
    　// 得でないなら全部バラで買う
      console.log((A * X) + (B * Y));
  }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
import Data.List
import Data.IntMap ((!))
import qualified Data.IntMap.Strict as M
import Control.Monad

main = do
 [n,m] <- map read . words <$> getLine
 abcs <- map (map read . words) . lines <$> getContents
 putStrLn $ maybe "inf" show (scoreAttack n abcs)

scoreAttack n abcs = do 
 let ad = foldl' (move abcs) (M.singleton 1 0) [1..1000]
 let mn = foldl' (move abcs) ad [1..100]
 guard (ad!n == mn!n)
 return (ad!n)

move abcs im i = foldl' (\im [a,b,c] -> if M.member a im then M.insertWith max b ((im!a) + c) im else im) im abcs

Measured memory_bytes: 3452
# coding: utf-8
from math import ceil
N = int(input())
A = list(map(int, input().split()))
total = sum(A)
half = ceil(sum(A) / 2)
tmp = 0
diff = sum(A)
for i in range(N):
    tmp += A[i]
    total -= A[i]
    if total == tmp:
        print(0)
        exit()
    diff = min(diff, abs(total - tmp))
print(diff)

Measured memory_bytes: 27300
#include <bits/stdc++.h>
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;
}
#define DEBUG
#ifdef DEBUG
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
#else
template <class T, class... Args>
void debug(const T &x, const Args &... args) {}
template <class T> void debugVector(const vector<T> &v) {}
#endif

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<string> A(N), B(M);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for(int i = 0; i < M; i++) {
        cin >> B[i];
    }
    for(int i = 0; i < N - M + 1; i++) {
        for(int j = 0; j < N - M + 1; j++) {
            bool ok = true;
            for(int r = 0; r < M; r++) {
                for(int c = 0; c < M; c++) {
                    if(A[i + r][j + c] != B[r][c]) {
                        ok = false;
                    }
                }
            }
            if(ok) {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll x, a, b;
    cin >> x >> a >> b;
    MSG(x - (a + ((x - a) / b) * b))
}


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

int triple_max(int x, int y, int z){
    int ans = x;
    if (y > x && y > z) ans = y;
    else if (z > x && z > y) ans = z;

    return ans;
}

int main(){
    int a, b;
    cin >> a >> b;
    cout << 2*b - a << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  h.push_back(0);
  int ans=0;
  for(int i=1;i<=n;i++){
    if(h[i]<h[i-1]) ans+=h[i-1]-h[i];
  }
  cout<<ans;
}

Measured memory_bytes: 256
A, B = list(map(int, input().split()))
a = A % 2
b = B % 2

if not a and not b:
    num = [(B-A)//2%2, B]
elif a and b:
    num = [(B-A)//2%2, A]
elif not a and b:
    num = [(B-A+1)//2%2]
else:
    num = [(B-1-A)//2%2, A, B]

for n in num[1:]:
    num[0] ^= n
print(num[0])


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    int alimit = F / (100 * A);

    double sratiomax = 0.0;
    int watermax = 100 * A;
    int sugarmax = 0;
    for (int a = 0; a <= alimit; a++) {
        int blimit = (F - 100 * A * a) / (100 * B);
        for (int b = 0; b <= blimit; b++) {
            int water = 100 * A * a + 100 * B * b;
            int sugarlimit = (A * a + B * b) * E;
            int climit = (F - water < sugarlimit ? F - water : sugarlimit) / C;

            for (int c = 0; c <= climit; c++) {
                int dlimit = (F - water - C * c) / D;
                for (int d = 0; d <= dlimit; d++) {
                    int sugar = C * c + D * d;
                    if (sugar > sugarlimit) break;

                    double sratio = 1.0 * sugar / (water + sugar);
                    if (sratio > sratiomax) {
                        sratiomax = sratio;
                        watermax = water;
                        sugarmax = sugar;
                    }
                }
            }
        }
    }
    cout << watermax + sugarmax << " " << sugarmax << endl;
}


Measured memory_bytes: 504
#include<iostream>
#include<vector>
using namespace std;
int num=10e8+7;
int H,W;
bool inside(int x,int y)
{
    if(x>=0&&x<=H-1&&y>=0&&y<=W-1)
    return true;
    else
    {
        return false;
    }
}
int main()
{
    cin>>H>>W;
    vector<vector<int>> dp(H+1,vector<int> (W+1,0));
    vector<string> grid;
    for(int i=0;i<H;i++)
    {
        string s;
        cin>>s;
        grid.push_back(s);
    }
    if(grid[0][0]=='.')
    dp[0][0]=1;
    for(int i=0;i<H;i++)
    {
        for(int j=0;j<W;j++)
        {
            if(inside(i,j-1)&&grid[i][j]=='.')
            {
                dp[i][j]+=dp[i][j-1];
            }
            if(inside(i-1,j)&&grid[i][j]=='.')
            {
                dp[i][j]+=dp[i-1][j];
            }
            dp[i][j]%=num;
        }
    }
    cout<<dp[H-1][W-1];
}

Measured memory_bytes: 8096
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int N;
  while(cin >>N && N){
    int ans = 0;
    FOR(i, 1, N){
      FOR(j, 2, N - i + 1){
        int sum = 0;
        REP(k, j) sum += i + k;
        if(N == sum) ++ans;
      }
    }
    cout <<ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main()
{
    int e,ans;
    int x,y,z;
    while(1)
    {
        cin >> e;
        ans=e;
        if(e==0||e>1000000)
            break;
        else    for(y=0;y*y<=e;y++)
                    for(z=0;z*z*z<=e-y*y;z++)
                    {
                        x=e-y*y-z*z*z;
                        ans=min(ans,x+y+z);
                    }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 2988
#include<bits/stdc++.h>
using namespace std;
int main(){
  long A,B,K;cin>>A>>B>>K;
  cout<<(0>A-K?0:A-K)<<" "<<((K>A?B-(K-A):B)>0?(K>A?B-(K-A):B):0)<<endl;

}

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

int main(){
  int n,m;
  string u,t;
  set<string> id;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> u;
    id.insert(u);
  }

  cin >> m;
  bool isOpen = false;
  for(int i=0;i<m;i++){
    cin >> t;
    if(id.count(t)){
      if(isOpen)cout << "Closed by " << t << endl;
      else cout << "Opened by " << t << endl;
      isOpen = !isOpen;
    }else cout << "Unknown " << t << endl;
  }
}

Measured memory_bytes: 1232
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<sstream>
#include<complex>
#include<map>
#include<algorithm>
#include<cassert>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define fr(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
typedef complex<double> P;
const double PI=acos(-1.0),EPS=1e-9;
int n;
P c[100]; double r[100];

pair<double,double> crossptCC(P a,double r,P b,double s){
	double d=abs(a-b),e=(d*d+r*r-s*s)/2/d,h=sqrt(r*r-e*e);
	P dir=(b-a)*(1/d),x=dir*e+dir*P(0,1)*h,y=dir*e-dir*P(0,1)*h;
	
	return mp(arg(x),arg(y));
}
int main(){
	while(scanf("%d",&n),n){
		rep(i,n)scanf("%lf%lf%lf",&c[i].real(),&c[i].imag(),r+i);
		double ans=0;
		rep(i,n){
			map<double,int> M;
			int cnt=0; double p,s=0;
			M[-PI]=0; M[PI]=0;
			
			rep(j,n)if(i!=j){
				double d=abs(c[i]-c[j]);
				if(d>r[i]+r[j]-EPS)continue;
				if(d<abs(r[i]-r[j])+EPS){
					if(r[i]>r[j])continue;
					goto END;
				}
				pair<double,double> crs=crossptCC(c[i],r[i],c[j],r[j]);
				double a=crs.first,b=crs.second;
				if(a>b)swap(a,b);
				if(abs(c[i]+r[i]*P(cos(a+1e-5),sin(a+1e-5))-c[j])<r[j]+EPS)M[a]++,M[b]--;
				else{
					M[-PI]++; M[a]--; M[b]++; M[PI]--;
				}
			}
			fr(j,M){
				if(cnt>0)s+=j->first-p;
				cnt+=j->second;
				p=j->first;
			}
			ans+=(2*PI-s)*r[i];
			END:;
		}
		printf("%.9f\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <string>

using  namespace std;

int main() {
  string str;
  cin >> str;
  if (str == "SUN") puts("7");
  else if (str == "MON") puts("6");
  else if (str == "TUE") puts("5");
  else if (str == "WED") puts("4");
  else if (str == "THU") puts("3");
  else if (str == "FRI") puts("2");
  else puts("1");
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
  public static void main(String[] args) {
	  FastReader sc = new FastReader();
	  long n = sc.nextLong();
	  long minTrans = Long.MAX_VALUE;
	  for (int i = 0; i < 5; i++) {
		  long m = sc.nextLong();
		  minTrans = Math.min(minTrans, m);
	  }
	  
	  long res = (long)Math.ceil((n/(minTrans * 1.0))) + 4;
	  System.out.println(res);
  }
  
  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }
  
    String next() { 
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException  e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() { 
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
        try{
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
      }
  }
}


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

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;
const int INFi = 2e9 + 1;
const lli INFl = (lli)(9e18) + 1;
// const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto (i) = (vec).begin(); (i) != (vec).end(); (i)++)
#define vrREP(i, vec) for(auto (i) = (vec).end()-1;(i) != (vec).begin()-1;(i)--)

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


int main(void){
  int n, t1, a1; cin >> n;
  lli t = 1, a = 1;
  REP(_, n){
    cin >> t1 >> a1;
    // t_next = k * t1　≥ t, a_next = k * a1 ≥ aとなる最小の整数 k
    // => k ≥ t / t1, and k ≥ a / a1
    lli k, k1, k2;
    k1 = (t % t1 == 0) ? t / t1 : t / t1 + 1;
    k2 = (a % a1 == 0) ? a / a1 : a / a1 + 1;
    k = max(k1, k2);
    t = k * t1;
    a = k * a1;
  }
  cout << t + a << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <bits/stdc++.h> 
using namespace std;
int main(){
  long long N,val,sum=0;
  cin >> N;
  vector<long long> cnt(1e5+10,0);
  
  for(int i = 0; i < N ; i++){
    cin >> val;
    cnt[val]++;
    sum += val;
  }
  
  long long Q,b,c;
  cin >> Q;
  
  for(int i = 0; i < Q ; i++){
    cin >> b;
    cin >> c;
    if(cnt[b] > 0){
      sum += cnt[b]*(c-b);
      cnt[c] += cnt[b];
      cnt[b] = 0;
    }
    //vector<long long>::iterator it;
    //it = find (ival.begin(), ival.end(), b);
    
    //while(it != ival.end()){
      //*it = c;
      //it = find (ival.begin(), ival.end(), b);
    //}
    //cout<<accumulate(ival.begin(),ival.end(),0)<<'\n';
    cout<<sum<<'\n';
  }
  
}


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


int find_ab(string s){
    int abnum = 0;
    for(int i = 0;i<s.size();i++){
        if (s[i] == 'A'){
            if (s[i+1] == 'B') abnum ++;
        }
    }
    return abnum;
}

int main(){
    int N,last;
    string str;
    cin >> N;
    vector<string> vec(N);
    for(int i = 0;i<N;i++) cin >> vec[i];

    int ab = 0;
    int a = 0;
    int b = 0;
    int AB = 0;
    for(int i = 0;i<N;i++){
        str = vec[i];
        AB += find_ab(str);

        last = str.size()-1;
        if (str[0] == 'B' && str[last] == 'A') ab++;
        else if (str[0] == 'B') b++;
        else if (str[last] == 'A') a++;
    }

    if (ab == 0) cout << min(a,b) + AB << endl;
    else if (a == 0 && b == 0) cout << ab - 1 + AB << endl;
    else if (a == 0 || b == 0) cout << ab + AB << endl;
    else cout << min(a,b) + ab + AB<< endl;
}


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

int main () {
  int x,n;
  cin >>x>>n;
 
  vector<int> p(400);
  for (int i = 0; i <400 ; i++) {
    p.at(i)=i-150;
  }
  for (int i = 0; i < n; i++) {
    int del;
    cin >> del;
    p.at(del+150) = 1000;
  }
  vector<int> q(400);
  int mi =1000;
  for (int i = 0; i < 400; i++) {
    q.at(i) = abs(p.at(i)-x);
    mi = min(mi,abs(p.at(i)-x));
  }
  
  int answer = 1000;
  for (int i = 0; i < 400; i++) {
    if (q.at(i)==mi){
    answer = min(answer,p.at(i));
    }
  }
  cout << answer << endl;
}


Measured memory_bytes: 3604
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;
  vector<int> d(n);
  rep(i, n) {
    cin>>d[i];
  }
  sort(all(d));
  dump(d);

  cout << d[n/2]-d[n/2-1] << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

int main() {
    char s[11], r[4] = {};
    for (int i = 0; i < 3; i++) {
        cin >> s;
        r[i] = s[0] - 'a' + 'A';
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};

int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    string x,y;
    cin>>x;
    y=x;
    reverse(all(y));
    int cnt=0;
    for(int i=0;i<x.length();i++)
        if(x[i]!=y[i])
        cnt++;

    cout<<cnt/2<<endl;
    return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;

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

		String S = sc.next();
		String T = sc.next();
		sc.close();

		if (T.substring(0, S.length()).equals(S)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 35692
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int H = sc.nextInt();
        int W = sc.nextInt();
        int K = sc.nextInt();
        int[][] board = new int[H][W];
        for (int i = 0; i < H; i++) {
            char[] seq = sc.next().toCharArray();
            for (int k = 0; k < W; k++)
                board[i][k] = seq[k] == '#' ? 1 : 0;
        }

        for (int bin = 0; bin < (1 << (H + W)); bin++) {
            int sum = 0;
            for (int h = 0; h < H; h++) {
                if ((bin & (1 << h)) != 0)
                    continue;
                for (int w = 0; w < W; w++) {
                    if ((bin & (1 << (H + w))) != 0)
                        continue;
                    sum += board[h][w];
                }
            }
            // System.err.println(Integer.toBinaryString(bin));
            // System.err.println(sum);
            if (sum == K)
                ans++;
        }

        System.out.println(ans);
    }

    public static void main(String[] args) {
        new Main();
    }
}


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

int main() {
   int n;
   cin >> n;
   int four = 0, two = 0, one = 0;
   for (int i = 0; i < n; i++) {
      int a; cin >> a;
      if (a % 4 == 0) {
         four++;
      } else if (a % 2 == 0) {
         two++;
      } else {
         one++;
      }
   }

   if (two) {
      if (one <= four) {
         puts("Yes");
      } else {
         puts("No");
      }
   } else {
      if (one <= four+1) {
         puts("Yes");
      } else{
         puts("No");
      }
   }

   return 0;
}

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

using namespace std;

using int64 = long long;

int main() {
  int N, C;
  cin >> N >> C;
  int sum = 0;
  for(int i = 0; i < C; i++) {
    int x;
    cin >> x;
    sum += x;
  }
  cout << (sum + N) / (N + 1) << endl;
}



Measured memory_bytes: 3104