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

using lint = int64_t;
#define bit(n) (lint(1) << n)
const int INF = 1e9;
const lint LINF = 1e18;

const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;

class IoSetup {
    public:
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);

        cout << fixed << setprecision(12);
    }
} iosetup;

int main() {
    int p, q, r;
    cin >> p >> q >> r;
    
    cout << p + q + r - max({p, q, r}) << endl;

    return 0;
}

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

int main(){
  int H,N;
  cin >> H >> N;
  for(int i=0;i<N;i++){
    int A;
    cin >> A;
    H-=A;
  }
  if(H<=0){
    cout <<"Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 1000001

char f[N];

int main()
{		
	int n, x, i;
	
	scanf("%d", &n);
	for(i = 0; i < n; i++) f[i] = 0;
	for(i = 1, x = 0; ; i++){
		x = (10 * x + 7) % n;
		if(f[x]){
			puts("-1");
			return 0;
		}
		f[x] = 1;
		if(!x) break;
	}
	printf("%d\n", i);
				
	return 0;
}

Measured memory_bytes: 2676
M = 10**9 + 7


def main():
    n = int(input())
    a = 1
    b = 1
    c = 1
    for i in range(n):
        a *= 10
        a %= M
        b *= 9
        b %= M
        c *= 8
        c %= M
    print((a - b - b + c) % M)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

map<P, int> mp;
int dy[] = {-2, -2, -2, -1, -1, -1, 0, 0, 0};
int dx[] = {-2, -1, 0, -2, -1, 0, -2, -1, 0};
int ans[10];
signed main(){
	int h, w, n, cnt = 0;
	scanf("%lld%lld%lld", &h, &w, &n);
	rep(i,n){
		int x, y;
		scanf("%lld%lld", &y, &x);
		rep(j,9){
			int yy = y+dy[j];
			int xx = x+dx[j];
			if(yy <= 0 or xx <= 0)continue;
			if(yy+2 > h or xx+2 > w)continue;
			mp[P(yy, xx)]++;
		}
	}
	for(auto it = mp.begin();it != mp.end();it++){
		ans[it->second]++;
		cnt++;
	}
	ans[0] = (h-2)*(w-2)-cnt;
	rep(i,10){
		printf("%lld\n", ans[i]);
	}
	return 0;
}




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

int book[26];

int main(){
   char *str;
   str = (char *)malloc(26);
   scanf("%s",str);
   int len = strlen(str);

   int step,flag = 0;
   for(int i=0;i<len;i++){
     step = str[i] - 97;
     book[step]++;
     if(book[step] == 2){
        flag = 1;
        break;
     }
   }

   if(flag==1) printf("no");
   else printf("yes");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std; 
int main(){
	string A, B, C; 
	cin >> A >> B >> C; 
	int LA = A.size(); int LB = B.size(); int LC = C.size(); 
	int UA = -1; int UB = -1; int UC = -1; 
	char WHO = 'a'; 
	while(UA <= LA && UB <= LB && UC <= LC){
		if(WHO == 'a'){
			UA ++; if(UA < LA) WHO = A.at(UA);
		}
		else if(WHO == 'b'){
			UB ++; if(UB < LB) WHO = B.at(UB);
		}
		else if(WHO == 'c'){
			UC ++; if(UC < LC) WHO = C.at(UC);
		}
	}
	if(UA > LA) cout << "A" << endl; 
	else if(UB > LB) cout << "B" << endl; 
	else if(UC > LC) cout << "C" << endl; 
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int n,i;
	scanf("%d",&n);

	int a[n];

	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}

	printf("%d",a[n-1]);

	for(i=n-2;i>=0;i--){
		printf(" %d",a[i]);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 2736
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
int main() {
    int N;
    cin >> N;
    int h[N];
    for(int i= 0;i<N;i++){
        cin >> h[i];
    }
    int sum = 0;
    for(int i = 0;i<N;i++){
        sum = sum + h[i];
    }
    sort(h,h+N);
    int q;
    bool flag = false;
    for (int i = 0;i<N;i++){
        if(h[i] % 10 != 0){
            q = h[i];
            flag = true;
            break;
        }
    }
    if(sum % 10 != 0){
        cout << sum << endl;
    }
    else{
        if(flag == true){
            cout << sum - q << endl;
        }
        else{
            cout << 0 << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int cal[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

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

    cin>>n>>k>>q;

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

    for(int i=1;i<=n;i++){
        if(k>(q-cal[i]))cout<<"Yes\n";
        else cout<<"No\n";
    }

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
const ll mod = 1e9+7;
const ll inf = 0x3f3f3f3f3f3f3f;
#define ms(a,k)  memset(a,k,sizeof(a))
int n,m;
int w[]={0,2,5,5,4,5,6,3,7,6};
int a[maxn];
int dp[maxn];
map<int,int>vis;
int cmp(int a,int b){return a>b;}
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)cin>>a[i];
    ms(dp,-1);

    dp[0]=1;
    for(int i=0;i<m;i++)
    {
        for(int j=w[a[i]];j<=n;j++)
            dp[j]=max(dp[j],dp[j-w[a[i]]]+1);
    }
    sort(a,a+m,cmp);
    //for(int i=0;i<=n;i++)printf("%d ",dp[i]);

    while(n)
    {
       // printf("==\n");
        for(int i=0;i<m;i++)if(n>=w[a[i]] && dp[n-w[a[i]]]+1==dp[n])
        {
            printf("%d",a[i]);
            n-=w[a[i]];
            break;
        }
    }

    return 0;

}


Measured memory_bytes: 640
import java.util.*;

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

    int array_length = scan.nextInt();

    int[] array =new int[array_length];
    for (int i = 0; i < array_length; i++) {
      array[i] = scan.nextInt();
    }

    selectionSort(array_length, array);
  }

  public static void printArray(int array[], int count) {
  	for (int i = 0; i < array.length-1 ; i++) {
  	    System.out.print(array[i] + " ");
  	}
    System.out.println(array[array.length-1]);
  	System.out.println(count);
  }

  public static void selectionSort(int n, int array[]){

    int count = 0;
    for(int i = 0; i < n; i++){
      int minj = i;
      for(int j = i; j < n; j++){
        if(array[j] < array[minj]){
          minj = j;
        }
      }
      if(minj != i){
      int swap = array[i];
      array[i] = array[minj];
      array[minj] = swap;
      count++;
      }
    }
    printArray(array, count);


  }
}



Measured memory_bytes: 26212
fn main() {
    const N: usize = 100;
    let c = read_vec2::<i32>(3);

    for i in 0..(N+1) {
        let mut a: Vec<i32> = vec![-1; 3];
        let mut b: Vec<i32> = vec![-1; 3];

        // a1
        a[0] = i as i32;
        // b1, b2, b3
        b[0] = c[0][0] - a[0];
        b[1] = c[0][1] - a[0];
        b[2] = c[0][2] - a[0];
        // a2, a3
        a[1] = c[1][0] - b[0];
        a[2] = c[2][0] - b[0];

        let mut ok = true;
        for j in 1..3 {
            for k in 1..3 {
                if c[j][k] != a[j] + b[k] {
                    ok = false;
                }
            }
        }
        if ok {
            println!("Yes");
            return;
        }
    }

    println!("No");
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    let mut v2 = Vec::new();
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let v = s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
        v2.push(v);
    }
    v2
}

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


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, buf, ans[100008];
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	vector<P> a;
	
	a.push_back(P(0, 0));
	rep(i, 1, n){
		cin >> buf;
		a.push_back(P(buf, i));
	}
	sort(a.begin(), a.end());
	
	memset(ans, 0, sizeof(ans));
	ll mi = n;
	rrep(i, n, 1){
		mi = min(a[i].second, mi);
		ans[mi] += (a[i].first-a[i-1].first)*(n-i+1);
	}
	
	rep(i, 1, n){
		print(ans[i])
	}
	return 0;
}

Measured memory_bytes: 3568
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let mut n: Vec<char> = read_as_string().chars().collect::<Vec<char>>();
    //n.dedup();
    if (n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3]){
        println!("Yes");
    }else{
        println!("No");
    }
    /*
    if n.len() < 3{
        println!("Yes");
    }else{
        println!("No");
    }
    */
}


Measured memory_bytes: 4352
from collections import deque
N, M = map(int, input().split())
G = [set() for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    G[a - 1].add(b - 1)
    G[b - 1].add(a - 1)
d = [0] * N
Q = deque()
for i in range(N):
    if d[i] != 0:
        continue
    Q.append(i)
    d[i] = 1
    while len(Q) > 0:
        q = Q.pop()
        for g in G[q]:
            if d[g] != 0:
                continue
            d[i] += 1
            d[g] = -1
            Q.append(g)
print(max(d))

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

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

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

    int sum = INT_MAX;
    int temp = 0;
    //Pを0~100まで探索
    for(int i = 0; i <= 100; i++){
        //Pがiのとき、x0~xNの総和を求める
        for(int j = 0; j < N; j++ ){
            temp += (X[j] - i) * (X[j] - i);
        }
        sum = min(sum, temp); 
        temp =0;
    }


    cout << sum << endl;

}

Measured memory_bytes: 256
#include <iostream>

int li, ri, n, m, a, b;

int main() {
    a = 0;
    b = 1000001;
    std::cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        std::cin >> li >> ri;
        if (li > a) a = li;
        if (b > ri) b = ri;
    }
    int ans = a > b ? 0 : b - a + 1;
    std::cout << ans; 
    return 0;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int k;
    cin >> k;
    int odd, even;
    
    if(k%2 == 0){
        odd = k / 2;
        even = k / 2;
    }
    else{
        even = k / 2;
        odd = even + 1;
    }
    cout << odd * even << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define st string
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define each(i, n) for(auto&& i: n)

int main() {
  int N;
  st S, T;
  cin >> N >> S >> T;
  rep(i, N) {
    cout << S.at(i);
    cout << T.at(i);
  }
  cout << endl;
} 

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

int main(){
  long long N, K;
  cin >> N >> K;
  long long x = N%K;
  if(x > K-x)
    x = K - x;
  
  cout << x << endl;
  
  return 0;
}

Measured memory_bytes: 3596
n = int(input())
sl = []
for i in range(n):
  s = int(input())
  sl.append(s)
nmul = []
for i in range(n):
  if sl[i] % 10 != 0:
    nmul.append(sl[i])
ssl = sum(sl)
if ssl % 10 == 0:
  if len(nmul) != 0:
    subm = ssl - min(nmul)
    print(subm)
  else:
    print(0)
else:
  print(sum(sl))

Measured memory_bytes: 3064
#include <iostream>
#include <queue>
#include <climits>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
struct NODE{
	vector<int> to,cost;
};
typedef vector<NODE> G;

int n;

void gentree(G& g,bool done[20],int connect[20][20],int pos){
	rep(i,n){
		if(connect[pos][i] != -1 && done[i] == false){
			g[pos].to.push_back(i);
			g[pos].cost.push_back(connect[pos][i]);
			done[i] = true;	
			gentree(g,done,connect,i);
		}
	}
}


bool find(G &g,int pos,int want){
	if(pos == want)return true;
	
	bool ret = false;
	rep(i,g[pos].to.size())
		ret |= find(g,g[pos].to[i],want);
	return ret;
}

int getCost(G &g,int pos,int prev){
	
	int ret = 0;
	rep(i,g[pos].to.size()){
		if( g[g[pos].to[i]].to.size() )
			ret += getCost(g,g[pos].to[i],g[pos].cost[i]) + g[pos].cost[i]; 
	}
	return ret + prev;
}

int count = 0;

int cost = INT_MAX;

void dfs(G &g,int pos , int end){
	int atode = -1;
	rep(i,g[pos].to.size()){
		if(find(g,g[pos].to[i],end) == true){
			atode = i;
			//cout << pos << "<jokou>" << g[pos].to[i] << endl;
			continue;
		}
		if(g[g[pos].to[i]].to.size()){
			//cout << pos << "<>" << g[pos].to[i] << "  C : " << getCost(g,g[pos].to[i],g[pos].cost[i]) + g[pos].cost[i] << endl;
			count += getCost(g,g[pos].to[i],g[pos].cost[i]) + g[pos].cost[i];
		}
	}
	if(~atode){
		count += g[pos].cost[atode];
		//cout <<"count:"<<count << endl;
		dfs(g,g[pos].to[atode],end);
	}
	return;
}
int main(){
	while(cin >> n,n){
		int connect[20][20];
		rep(i,20)rep(j,20)connect[i][j] = -1;
		rep(i,n-1){
			int a,b,c;cin >> a >> b >> c;
			a--,b--;
			connect[a][b] = connect[b][a] = c;
		}
		cost = INT_MAX;
		rep(i,n){
			bool done[20] = {0};
			G graph(n);
			done[i] = true;
			gentree(graph,done,connect,i);
			
			if(i+1 == -1){
				cout << i+1 << "ga atama" << endl;
				rep(j,n){
					cout << j+1 << ":";
					rep(k,graph[j].to.size())cout << graph[j].to[k]+1 << " ";
					cout << endl;
				}
				//cout <<  ">>>>" << getCost(graph,2,2) << "]" << endl;
			}
			rep(j,1){
				count = 0;
				dfs(graph,i,j);
				cost = min(count,cost);
				//cout << "[" << j << "]" << count << endl;
			}
		}
		cout << cost << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<vector>
#include<utility>
#define INF 0x3f3f3f3f3f3f3f3f
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'

using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
int main() {
	int n;cin >> n;
	while (n) {
		if (n % 10 == 7) {
			printf("Yes\n");
			return 0;
		}
		n /= 10;
	}
	printf("No\n");
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int a[102];
long long memo[102][22];
int n;
long long ans;
long long count;

void saiki(int kai,int sum) {
  count++;
  int flg = 0;
  if(kai == n-1 && sum == a[n-1]) ans++,memo[kai][sum]++;
  else if(kai == n-1 && sum != a[n-1]) memo[kai][sum] = -1;
  
  
  if(kai < n-1) {
    if(sum+a[kai]<=20 && memo[kai+1][sum+a[kai]] == 0) {
      saiki(kai+1,sum+a[kai]);
      if(memo[kai+1][sum+a[kai]]>0) memo[kai][sum]+=memo[kai+1][sum+a[kai]]; 
    else flg++;
    } else if(sum+a[kai]<=20 && memo[kai+1][sum+a[kai]] > 0) {
      ans += memo[kai+1][sum+a[kai]];
      memo[kai][sum] += memo[kai+1][sum+a[kai]];
    }
    
    
    if(0<=sum-a[kai] && memo[kai+1][sum-a[kai]] == 0) {
      saiki(kai+1,sum-a[kai]);
      if(memo[kai+1][sum-a[kai]]>0) memo[kai][sum]+= memo[kai+1][sum-a[kai]]; 
      else flg++;
    }
    else if(0<=sum-a[kai] && memo[kai+1][sum-a[kai]] > 0) {
      ans+= memo[kai+1][sum-a[kai]];
      memo[kai][sum] += memo[kai+1][sum-a[kai]];
    }
    if(flg == 2) memo[kai][sum] = -1; 
  }
} 

int main() {
  cin >> n;
  for(int i=0;i<n;i++) cin >> a[i];
  
  
  for(int i=0;i<=n;i++) 
    for(int j=0;j<=20;j++)
      memo[i][j] = 0;

  saiki(1,a[0]);

  //  cout << "ans" <<endl;
  //  cout << ans<<endl;
  cout << memo[1][a[0]] << endl;
  // cout <<count <<endl;
  return 0;

}

Measured memory_bytes: 1172
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main() {
  string s;
  cin >> s;
  int res = 0;
  for(int i=0;i<s.length();i++){
    if(s[i]=='+') res ++;
    else res --;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import itertools

l, r = map(int, input().split())
if(r - l) > 2019:
    ans = 0
else:
    a = []
    combs = list(itertools.combinations_with_replacement(range(l, r + 1), 2))
    for comb in combs:
        if comb[0] != comb[1]:
            a.append((comb[0]*comb[1]%2019))

    ans = min(a)

print(ans)

Measured memory_bytes: 220964
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int)(n).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

ll MOD=1e9+7, n, m, dp[1010][1010];
string s[1010];

int solve(int i, int j){
  if(i >= n || j >= m || s[i][j] == '#') return 0;
  if(i == n-1 && j == m-1) return 1;
  ll &r = dp[i][j];
  if(r >= 0) return r;
  r = (solve(i+1,j)+solve(i,j+1))%MOD;
  return r;
}

int main(){FIN;
  memset(dp,-1,sizeof(dp));
  cin >> n >> m;
  fore(i,0,n) cin >> s[i];
  cout << solve(0,0) << "\n";
}

Measured memory_bytes: 9344
using System;
using System.Collections;
using System.Linq;
class Program
{
    static int Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        Array.Sort(a);
        if (a[n - 1] % 2 == 0)
        {
            int max = a[n - 1];
            int min = a[0];
            int d = Math.Abs((max / 2) - min);
            for (int i = 0; i < n - 1; i++)
            {
                if (d > Math.Abs((max / 2) - a[i]))
                {
                    d = Math.Abs((max / 2) - a[i]);
                    min = a[i];
                }
            }
            Console.WriteLine("{0} {1}", max, min);
        }
        else
        {
            int max = a[n - 1];
            int min = a[0];
            int d = Math.Min(Math.Abs(((max - 1) / 2) - min), Math.Abs(((max + 1) / 2) - min));
            for (int i = 0; i < n - 1; i++)
            {
                if (d > Math.Min(Math.Abs(((max - 1) / 2) - a[i]), Math.Abs(((max + 1) / 2) - a[i])))
                {
                    d = Math.Min(Math.Abs(((max - 1) / 2) - a[i]), Math.Abs(((max + 1) / 2) - a[i]));
                    min = a[i];
                }
            }
            Console.WriteLine("{0} {1}", max, min);
        }

        return 0;
    }
}

Measured memory_bytes: 21728
#include<stdio.h>

int main(){
  double v,t,y,n;
  int ans;

  while(scanf("%lf",&v)!=EOF){
    t=v/9.8;
    t=t*t;
    y=4.9*t;
    n=y/5+1;
    n++;
    ans=n;
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true) {
			int h = sc.nextInt();
			int w = sc.nextInt();

			if(h == 0 && w == 0) break;
			for(int i=0; i<h; i++) {
				for(int j=0; j<w; j++) {
					System.out.print("#");
				}
				System.out.println("");
			}
			System.out.println("");
		}

		sc.close();

	}

}


Measured memory_bytes: 36884
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    ll N;
    cin >> N;
    N %= 10;
    if (N == 3) cout << "bon" << endl;
    else if (N==0 || N==1 || N==6 || N==8) cout << "pon" << endl;
    else cout << "hon" << endl;
}

Measured memory_bytes: 3636
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
long bignum = 1_000_000_007;
alias Pair = Tuple!(long, "numbers", long, "change");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long n, m;
    scan(n, m);
    auto a = aryread.sort();
    auto bc = new Pair[](m);
    long b_sum;
    foreach (i; 0 .. m)
    {
        long b, c;
        scan(b, c);
        bc[i] = Pair(b, c);
        b_sum += b;
    }
    bc.sort!"a.change > b.change"();
    long j, corrent_b, corrent_sum;
    long cards_sum = a.sum, replace;
    long max_sum = cards_sum;
    foreach (i; 0 .. min(n, b_sum))
    {
        if (bc[j].numbers <= corrent_b)
        {
            j++;
            corrent_b = 0;
        }

        corrent_sum += bc[j].change;
        corrent_b++;
        replace += a[i];
        max_sum = max(max_sum, cards_sum - replace + corrent_sum);
    }
    max_sum.writeln();
}


Measured memory_bytes: 5248
#include<iostream>

using namespace std;
typedef long long ll;

ll Q,H,S,D;
ll N;

int main()
{
        cin >> Q >> H >> S >> D >> N;
        if (H > 2*Q)
                H = 2*Q;
        if (S > 2*H)
                S = 2*H;
        if (D > 2*S)
                D = 2*S;
        if (N%2)
                cout << D*(N/2) + S << "\n";
        else
                cout << D*(N/2) << "\n";
}

Measured memory_bytes: 256
from collections import deque

h, w = map(int, input().split())
S = []
for _ in range(h):
    s = str(input())
    S.append(s)

deque = deque()
deque.append([0,0])
Visited=[[-1 for _ in range(w)] for _ in range(h)]
Visited[0][0] = 0

while deque:
    now = deque.popleft()
    x_now = now[0]
    y_now = now[1]

    Cands = []
    For_cands = [-1,0,1]
    for i in For_cands:
        for j in For_cands:
            if i == j or i == j*-1:
                continue
            if x_now + i < w and x_now +i >=0 and y_now +j < h and y_now + j >=0:
                if S[y_now+j][x_now+i] == '.':
                    Cands.append([x_now+i, y_now+j])
    for cands in Cands:
        if Visited[cands[1]][cands[0]] != -1:
            continue
        deque.append(cands)
        Visited[cands[1]][cands[0]] = Visited[y_now][x_now] + 1

goal_dist = Visited[h-1][w-1]

white = 0
for i in range(h):
    white += S[i].count('.')

ans = white - goal_dist -1
if goal_dist == -1:
    ans = -1
print(ans)

Measured memory_bytes: 41584
H,W,N,*a = map(int, open(0).read().split())
ans = [[0] * W for _ in range(H)]
count = 0
using = 0
for i in range(H*W):
    dm = divmod(i,W)
    h = dm[0]
    if h % 2 == 0:
        w = dm[1]
    else:
        w = (dm[1]+1) * (-1)
    ans[h][w] = using + 1
    count += 1
    if count == a[using]:
        using += 1
        count = 0
for x in ans:
    print(*x)

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

char s[1000000];
int main() {
	int k; scanf("%s%d", s, &k);
	int len = strlen(s);
	rep(i, len) {
		if (s[i] != 'a'&&s[i] + k > 'z') {
			k = k + s[i] - 'z' - 1;
			s[i] = 'a';
		}
	}
	if (k)s[len - 1] = (s[len - 1] + k - 'a') % 26 + 'a';
	printf("%s\n", s);
}

Measured memory_bytes: 384
N = int(input())
S = input()

num_R = len([c for c in S if c == "R"])
num_G = len([c for c in S if c == "G"])
num_B = len([c for c in S if c == "B"])

total = num_R * num_G * num_B

count = 0
for i in range(0, N - 2):
    for j in range(i, N - 1):
        k = (j - i) + j
        if k < N:
            if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                count += 1

print(total - count)

Measured memory_bytes: 9232
#include<iostream>
using namespace std;
int main()
{
  string a,b;
  cin>>a;
  cin>>b;
  int l=a.length();
int c=0;
  for(int i=0;i<l;i++)
  {if(a[i]!=b[i])
    c++;
  }
  cout<<c;
  return 0;
  
}


Measured memory_bytes: 3920
N,M = [int(i) for i in input().split()]
L = []
R = []
for i in range(M):
    L1,R1 = [int(i) for i in input().split()]
    L.append(L1)
    R.append(R1)
result = min(R) - max(L)  +1
if result < 0:
    result = 0
print(result)

Measured memory_bytes: 11016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;

int main() {
  int N;
  cin >> N;
  string s[N];
  int a = 0;
  int b = 0;
  int c = 0;
  int ans = 0;
  for (int i= 0; i < N; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < N; i++) {
    if (s[i][0] == 'B' && s[i][s[i].size()-1] == 'A') {
      c++;
    } else if (s[i][0] == 'B') {
      b++;
    } else if (s[i][s[i].size()-1] == 'A') {
      a++;
    }
    for (int j = 1; j < s[i].size(); j++) {
      if (s[i][j-1] == 'A' && s[i][j] == 'B') {
        ans++;
      }
    }
  }
  int ab = min(a,b);
  if (ab >= 1) {
    ans += ab + c;
  } else if (a == 0 && b != 0) {
    ans += c;
  } else if (a != 0 && b == 0) {
    ans += c;
  } else if (a == 0 && b == 0 && c != 0) {
    ans += c-1;
  } else if (c == 0) {
    ans += 0;
  } 
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int A, B;
    cin >> A >> B;

    int ans = A + B;

    ans = max(ans, A - B);
    ans = max(ans, A * B);

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

int field[11][11];
int depth[11][11];
int sideNum[6][4] = {
  {2,3,5,4},
  {1,4,6,3},
  {1,2,6,5},
  {1,5,6,2},
  {1,3,6,4},
  {3,2,4,5}
};
int bias = 5;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};

// 次に下になる面の添字 or -1
int next_move(int up, int front, int x, int y) {
  int p = 0;
  for (int i = 0; i < 4; i++) {
    if (sideNum[up-1][i] == front) {
      p = i;
      break;
    }
  }
  
  int max_p = -1;
  for (int i = 0; i < 4; i++) {
    int nx = x+dx[i];
    int ny = y+dy[i];

    if (depth[nx][ny] < depth[x][y] &&
        sideNum[up-1][(p+i)%4] >= 4 &&
        (max_p == -1 || sideNum[up-1][(p+i)%4] > sideNum[up-1][max_p%4])) {
      max_p = p+i;
    }
  }
  if (max_p == -1) return -1;
  return max_p%4;
}

// 次にfrontになる番号を返す
int next_front(int pup, int pfront, int ndown) {
  if (pfront == ndown) return pup;
  int p; // pfrontの添字
  for (int i = 0; i < 4; i++) {
    if (sideNum[pup-1][i] == pfront) {
      p = i;
      break;
    }
  }

  if (sideNum[pup-1][(p+1)%4] == ndown ||
      sideNum[pup-1][(p+3)%4] == ndown) {
    return pfront;
  }else {
    return 7-pup;
  }
}

void put(int up, int front, int x, int y) {
  int p;
  while ((p=next_move(up, front, x, y)) != -1) {
    int c;
    for (int i = 0; i < 4; i++) {
      if (sideNum[up-1][i] == front) {
        c = i;
        break;
      }
    }
    
    for (int i = 0; i < 4; i++) {
      int nx = x+dx[i];
      int ny = y+dy[i];

      if ((c+i)%4 == p) {
        x = nx;
        y = ny;
        front = next_front(up, front, sideNum[up-1][p]);
        up = sideNum[up-1][(c+i+2)%4];
        break;
      }
    }
  }

  field[x][y] = up;
  depth[x][y]++;
}

int main(int argc, char *argv[]) {
  int n;
  while (cin>>n) {
    if (n == 0) break;

    memset(field, 0, sizeof(field));
    memset(depth, 0, sizeof(depth));
    for(int i = 0; i < n; i++) {
      int t, f;
      cin >> t >> f;
      put(t, f, bias, bias);

      // for(int j = 0; j < 11; j++) {
      //   for(int k = 0; k < 11; k++) {
      //     cout << field[k][j] << " ";
      //   }
      //   cout << endl;
      // }
      // cout << endl;
    }

    int ans[6];
    memset(ans, 0, sizeof(ans));
    for(int i = 0; i < 11; i++) {
      for(int j = 0; j < 11; j++) {
        if (field[i][j] == 0) continue;
        ans[field[i][j]-1]++;
      }
    }

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


  return 0;
}

Measured memory_bytes: 1160
n = input()
n = n[::-1]
l = len(n)
ans = 0
flg = 0
x = []
for j in range(l):
  i = n[j]
  i = int(i)
  if i+flg>=6:
    i += flg
    ans += (10-i)
    flg = 1
  elif i+flg == 5:
    if j == l-1:
      ans += i+flg
      flg = 0
    elif int(n[j+1]) >= 5:
      i += flg
      ans += (10-i)
      flg = 1
    else:
      ans += i+flg
      flg = 0
  else:
    i += flg
    ans += i
    flg = 0
if flg:
  ans += 1
print(ans)

Measured memory_bytes: 5492
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
  cin>>s;
  int n=s.size();
  int ans=0;
  for(int i=0;i<n;i++)
  {
  	if(s[i]=='R')
    {
      int cnt=1;
		for(int j=i+1;j<n;j++)
        {
        	if(s[j]=='R')
              cnt++;
            else
                break;
        }
      ans = max(ans,cnt);
    }
  }
  cout<<ans<<endl;
}


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

const int MAX_N = 303;

char grid[3 * MAX_N][3 * MAX_N];

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> grid[i][j];
            for (int k = 0; k <= 2 * N; k += N) {
                for (int l = 0; l <= 2 * N; l += N) {
                    grid[i + k][j + l] = grid[i][j];
                }
            }
        }
    }
    int ans = 0;
    for (int c = -N+1; c < N; c++) {
        bool is_ok = true;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (grid[N + i][N + j] != grid[N + j + c][N + i - c]) {
                    is_ok = false;
                }
            }
        }
        if (is_ok) {
            ans += N - abs(c);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
N = int(input())
A = sorted(map(int, input().split()))
print(pow(2, N >> 1, 10 ** 9 + 7) if (N & 1 and sorted(list(range(0, N, 2)) + list(range(2, N, 2))) == A) or (not N & 1 and sorted(list(range(1, N, 2)) + list(range(1, N, 2))) == A) else 0)

Measured memory_bytes: 13880
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    long sum = 0;
    long even = 0;
    long[] water = new long[n];
    long[] mountain = new long[n];
    for(int i = 0; i < n; i++) {
      water[i] = Long.parseLong(sc.next());
      sum += water[i];
      if(i % 2 == 1) even += water[i];
    }
    mountain[0] = sum - 2 * even;
    StringBuilder sb = new StringBuilder();
    sb.append(mountain[0]);
    for(int i = 1; i < n; i++) {
      mountain[i] = 2 * water[i-1] - mountain[i-1];
      sb.append(" " + mountain[i]);
    }
    System.out.println(sb.toString());
  }
}


Measured memory_bytes: 54112
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    
    int a,b,c;
    cin >>a>>b>>c;
    if(a+b<c) {
        cout <<"No";
    }else{
        cout <<"Yes";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  string s;
  cin >> s;
  int answer = 0;
  int n = s.size();
  if (n % 2 == 0) {
    REP(i, n / 2) {
      if (s[i] != s[n - 1 - i]) {
        answer++;
      }
    }
  } else {
    REP(i, n / 2) {
      if (s[i] != s[n - 1 - i]) {
        answer++;
      }
    }
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=100005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x=(x+y)%mod;}
template<class T>inline void read(T &x){
	x=0;char ch=getchar(),rev=0;
	while(ch>'9'||ch<'0') rev=(ch=='-'),ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	x=rev?-x:x;
}
template<class T>inline void print(T x,const char c){
	if(!x){putchar('0');putchar(c);return;}
	if(x<0) putchar('-'),x=-x;
	int m=0,a[10];
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');
	putchar(c);
}
inline int exp(int x,int y){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,vis[N],si[N];
ll res,mn;
vector<pii> g[N];
vi id;
inline int getroot(int x,int f){
	int tmp=0,ans=1,t=0;
	for(pii y:g[x]){
		if(y.FF==f) continue;
		t=getroot(y.FF,x);
		gmax(tmp,t);ans+=t;
	}
	gmax(tmp,n-ans);
	if(tmp<=n/2) id.pb(x);
	return ans;
}
inline void dfs2(int x,int f){
	si[x]=1;
	for(pii y:g[x]){
		if(y.FF==f) continue;
		dfs2(y.FF,x);si[x]+=si[y.FF];
	}
//	printf("%d %d\n",x,si[x]);
}
inline void dfs(int x,int f,ll l,bool isok){
	res+=l;
	if(isok) gmin(mn,l);
	for(auto y:g[x])
		if(y.FF!=f) dfs(y.FF,x,l+y.SS,isok);
}

ll calc(int id){
//	debug(id);
	res=0;mn=1ll<<60;
	dfs2(id,0);
//	debug(si[id]);
	bool isok=1;
	for(pii y:g[id]) if(si[y.FF]==(n+1)/2) isok=0;
	for(pii y:g[id])
		dfs(y.FF,id,y.SS,(si[y.FF]==(n+1)/2)||isok);
//	debug(mn);
//	debug(res*2-mn);
	return res*2-mn;
}

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int x,y,z;scanf("%d%d%d",&x,&y,&z);
		g[x].pb(mp(y,z));g[y].pb(mp(x,z));
	}
	getroot(1,0);
	ll mx=0;
	for(int i:id) gmax(mx,calc(i));
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    
    // うに作りまーす
    int w[100001] = {0}; // 頂点1を中心とするうに
    
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        if (a == 1) w[b]++;
        else if (b == 1) w[a]++;
        else { w[a]++; w[b]++; }
        
    }
    
    rep(i, n + 1) if (w[i] % 2 != 0) { out("NO"); return 0; }
    out("YES");
    
}


Measured memory_bytes: 768
using System;
using System.Linq;

namespace A
{
    class Frog1
    {
        const long INF = long.MaxValue;

        static void Main(string[] args)
        {
            var h = new long[100001];
            var dp = new long[100001];

            int N = int.Parse(Console.ReadLine());
            h = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

            for (var i = 0; i < 100001; i++) dp[i] = INF;

            dp[0] = 0;
            for (var i = 1; i < N; i++)
            {
                dp[i] = Math.Min(dp[i], dp[i - 1] + Math.Abs(h[i] - h[i - 1]));

                if (i >= 2)
                {
                    dp[i] = Math.Min(dp[i], dp[i - 2] + Math.Abs(h[i] - h[i - 2]));
                }
            }

            Console.WriteLine(dp[N - 1]);
        }
    }
}


Measured memory_bytes: 20320
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
map<string,int> mp;
int n;
vector<pair<int,string> > v;
char c[20];
int main()
{
	cin >>n;
	for (int i=0;i<n;i++)
	{
		string s;
		scanf("%s",&c);
		s=c;
		mp[s]--;
	} 
	for (map<string,int>::iterator it=mp.begin();it!=mp.end();it++)
		v.push_back(MP(it->Snd,it->Fst));
	sort(v.begin(),v.end());
	int t=v[0].Fst;
	for (int i=0;i<v.size();i++)
		if (v[i].Fst==t) printf("%s\n",v[i].Snd.c_str());
	return 0;
}

Measured memory_bytes: 27760
//3
//3 1 2
//2 5 4
//3 6
#include <iostream>
using namespace std;
int main()
{
	int n,total=0;
	cin>>n;
	int a[n+1],b[n+1],c[n];
	for (int i=1;i<=n;i++)  cin>>a[i];
	for (int i=1;i<=n;i++)  cin>>b[i];
	for (int i=1;i<=n-1;i++)  cin>>c[i];
	for (int i=1;i<=n;i++) total+=b[i];
	for (int i=1;i<=n-1;i++)
	{
		if (a[i+1]-a[i]==1)
		{
			total+=c[a[i]];
		}
	}
	cout<<total<<endl;
	return 0;
} 

Measured memory_bytes: 256
S = input()

candidate = ["", "A"]
c = ""
flag = False
for i in candidate:
    c = i + "KIH"
    for j in candidate:
        c1 = c + j + "B"
        for k in candidate:
            c2 = c1 + k + "R"
            for l in candidate:
                c3 = c2 + l
                if S == c3:
                    flag = True
if flag:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i=0; i<n; i++) cin >> d[i];
  int ans = 0;
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      ans += d[i]*d[j];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static class Dice {
		enum Direction {
			N(0, 1, 5, 4), E(0, 3, 5, 2), W(0, 2, 5, 3), S(0, 4, 5, 1);

			private int[] nextRotat;

			Direction(int num1, int num2, int num3, int num4) {
				this.setNextRotat(new int[] { num1, num2, num3, num4 });
			}

			public int[] getNextRotat() {
				return nextRotat;
			}

			public void setNextRotat(int[] nextRotat) {
				this.nextRotat = nextRotat;
			}
		}

		int[] label;

		Dice(int[] label) {
			this.label = label;
		}

		public void Rotation(String str) {
			Direction dir = Direction.valueOf(str);
			LabelUpdate(dir.getNextRotat());
		}

		void LabelUpdate(int[] nextRotat) {
			int work = label[nextRotat[0]];
			for (int i = 1; i < nextRotat.length; i++) {
				label[nextRotat[i - 1]] = label[nextRotat[i]];
			}
			label[nextRotat[nextRotat.length - 1]] = work;
		}

	}

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

		Dice dice = new Dice(CreateIntLabel(sc.nextLine().split("[\\s]+")));

		String[] input = sc.nextLine().split("");

		for (String str : input) {
			dice.Rotation(str);
		}

		System.out.println(dice.label[0]);

	}

	public static int[] CreateIntLabel(String[] input) {
		int[] label = new int[input.length];
		for (int i = 0; i < input.length; i++) {
			label[i] = Integer.parseInt(input[i]);
		}
		return label;
	}

}



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

using namespace std;

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b)) {
        cout << 'A' << endl;
    } else {
        cout << 'B' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define LARGE 10000


int V,E;
int color=0;

typedef struct list{
	int id;
	struct list *next;
}list;

typedef struct node{
	int id;
	int in_num;
}node;

list * makelist(int x){
	list *new=malloc(sizeof(list));
	new->id=x;
	new->next=NULL;
	return new;
}

void list_insert(list* L[],int x,list *new){
	list **p=&L[x];
	
	while((*p)!=NULL){
		p=&((*p)->next);
	}
	(*p)=new;
	
	return;
}

void swap(node h[],int x,int y){
	node temp=h[x];
	h[x]=h[y];
	h[y]=temp;
	return;
}


void heapsort(node heap[],int num){

	for(int i=num-1;i>0;i--){
		if(i%2==0){
			if(heap[i].in_num < heap[i/2-1].in_num)swap(heap,i,i/2-1);
		}else {
			if(heap[i].in_num < heap[i/2].in_num)swap(heap,i,i/2);
		}
	}
	
	return;

}

int update_heap(node heap[],int num,list *L[]){
	int u=heap[0].id;
	list *p=L[u];
	
	swap(heap,0,num-1);
	num--;
	
	
	while(p!=NULL){
		for(int i=0;i<num;i++){
			if(heap[i].id==p->id){
				heap[i].in_num--;
			}
		}
		p=p->next;
	}
	
	
	return num;
}

int main(){
	int i,j;
	int s,t;
	int num;
	list *L[LARGE];
	list *new;
	node heap[LARGE];
	
	scanf("%d %d",&V,&E);
	num=V;
	
	for(i=0;i<V;i++){
		L[i]=NULL;
		heap[i].id=i;
		heap[i].in_num=0;
	}
	
	for(i=0;i<E;i++){
		scanf("%d %d",&s,&t);
		new=makelist(t);
		list_insert(L,s,new);
		heap[t].in_num++;
	}
	
	heapsort(heap,num);
	
	while(num!=0){
		printf("%d\n",heap[0].id);
		num=update_heap(heap,num,L);
		heapsort(heap,num);
	}
	
	return 0;
	
}



Measured memory_bytes: 3264
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	res, _ := strconv.Atoi(sc.Text())
	return res
}

type Seq [][2]int

func (s Seq) Len() int {
	return len(s)
}

func (s Seq) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s Seq) Less(i, j int) bool {
	return s[i][1] > s[j][1]
}

func toA(m map[int]int) Seq {
	a := Seq{}
	for k, v := range m {
		a = append(a, [2]int{k, v})
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	oIdx, eIdx := make(map[int]int), make(map[int]int)

	for i := 0; i < n/2; i++ {
		eIdx[nextInt()]++
		oIdx[nextInt()]++
	}
	eIdx[-1] = 0
	oIdx[-1] = 0

	es, os := toA(eIdx), toA(oIdx)
	sort.Sort(es)
	sort.Sort(os)

	ans := 1 << 28
	for i := 0; i < 2; i++ {
		for j := 0; j < 2; j++ {
			if es[i][0] == os[j][0] {
				continue
			}
			val := n - es[i][1] - os[j][1]

			if val < ans {
				ans = val
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 9472
#include <iostream>
using namespace std;
int main(){
  int N;
  int rate;
  int A[9];
  int color = 0;
  cin >> N;
  for(int i=0;i<9;i++){
    A[i] = 0;
  }
  for(int i=0;i<N;i++){
    cin >> rate;
    A[min(8,rate/400)] += 1;
  }
  for(int i=0;i<8;i++){
    color += min(1,A[i]);
  }
  cout << max(color,1) << " " << color+A[8];
  return 0;
}


Measured memory_bytes: 256
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
a=A%10
b=B%10
c=C%10
d=D%10
e=E%10
result=0
if a==0:
    result+=A
else:
    result+=(A+10-a)
if b==0:
    result+=B
else:
    result+=(B+10-b)
if c==0:
    result+=C
else:
    result+=(C+10-c)
if d==0:
    result+=D
else:
    result+=(D+10-d)
if e==0:
    result+=E
else:
    result+=(E+10-e)
if a==b==c==d==e==0:
    print(result)
else:
    l=set([a,b,c,d,e])
    l.discard(0)
    print(result-(10-min(l)))


Measured memory_bytes: 9112
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;
 

int main ()
{
  prep();
  int n;
  cin >> n;
  int arr[n];
  
  for (int i=0; i<n; i++){
      cin >> arr[i];
  }
  int below = 0;
  int cnt = 0;
  int nums[n] = {0};
  for (int i=0; i<n; i++){
      // spaces = arr[i]-1
      int divv = (arr[i]-1)/2+(arr[i]-1)%2;
      nums[i] = cnt;
      if (below == divv && (arr[i]-1)%2 == 1){
          below--;
          cnt++;
      }
      below++;
  }

  long long res = 1;
 
  int numcnt[n+1] = {0};
  for (int i=0; i<n; i++){
      numcnt[nums[i]]++;
      //cout << nums[i] << " ";
  }
  int cursum = 0;
  for (int i=0; i<n; i++){
      cursum += numcnt[i];
      res *= cursum-i;
      res %= mod;
  }
  cout << res;
  return 0; 
}

Measured memory_bytes: 1408
package main

import (
	"fmt"
	"math"
)

func main() {
	var N int
	fmt.Scanf("%d", &N)

	ans := N - 1
	for i := 1; i <= int(math.Sqrt(float64(N))); i++ {
		if N%i == 0 {
			ans = int(math.Min(float64(ans), float64(i+N/i-2)))
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512