akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '9') s[i] = '1';
		else if (s[i] == '1') s[i] = '9';
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n, m;
    scanf("%d%d", &n, &m);

    ll ans = m * 1900 + (n-m) * 100;
    int i;
    for(i=0; i<m; i++) {
        ans *= 2;
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 128
a,b,c=map(int,input().split())
 
sum = b + c
 
#何セットあるか確かめる
set = int(a / sum)
#print(set)
 
#セットの中にある青玉の個数
blue_1 = set * b 
#print(blue_1)
 
#最後のあまりを数える
amari = a % sum
#print(amari)
 
if amari <= b:
  print(blue_1 + amari)
  
else :
  print(blue_1 + b)

Measured memory_bytes: 3060
n=int(input())
a=list(map(int,input().split()))
for i in range(n):a[i]-=i+1
a.sort()
if n%2==1:
    ans,j=0,a[n//2]
    for i in a:ans+=abs(i-j)
else:
    ans,ans2,j,k=0,0,a[n//2],a[n//2+1]
    for i in a:
        ans+=abs(i-j)
        ans2+=abs(i-k)
    ans=min(ans,ans2)
print(ans)

Measured memory_bytes: 26184
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main (void) {
	string s;
	cin >> s;

	set<int> maps[26];
	int lens[26];

	for (int i = 0; i < 26; i++) lens[i] = 0;

	int len = s.length();
	for (int i = 0; i < 26; i++) {
		maps[i].insert(-1);
		maps[i].insert(len);
	}

	for (int i = 0; i < len; i++) {
		maps[s[i] - 'a'].insert(i);
	}
	
	for (int i = 0; i < 26; i++) {
		int j = 0;
		int tem = 0;
		for (auto it = maps[i].begin(); it != maps[i].end(); it++) {
			lens[i] = max (lens[i], (*it) - tem - 1);
			tem = (*it);
		}

		//for (int item : maps[i]) cout << item << ' ';
		//cout << endl;
		//cout << (char)(i + 'a') << " : " << lens[i] << endl;
	}
	int re = len;
	for (int i = 0; i < 26; i++) {
		re = min (re, lens[i]);
	}

	cout << re << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;
int K = 60;

vector<vector<long long>> dp;

long long needs(int x, int y){
    if(dp[x][y]!=-1)return dp[x][y];
    if(x<y)return M;
    if(x==y)return 0;
    long long res = M;
    for(long long s=1;s<=x;s++){
        if(needs(x%s,y)<M)res = min(s,res);
    }
    dp[x][y] = res;
    return res;
}

int main(int argc, char const *argv[]) {
    int n;cin>>n;
    vector<int> a(n),b(n);
    dp = vector<vector<long long>>(K,vector<long long>(K,-1));
    for(int i=0;i<n;++i)cin>>a[i];
    for(int i=0;i<n;++i)cin>>b[i];
    vector<vector<bool>> dp2(n, vector<bool>(K,false));
    long long res = 0;
    for(int i=0;i<n;++i){
        if(needs(a[i],b[i])==M){
            cout<<-1<<endl;
            return 0;
        }
        dp2[i][a[i]] = true;
    }
    while(true){
        long long ma = 0;
        for(int k=0;k<n;++k){
            long long mi = 1ll<<30;
            for(int l=b[k];l<=a[k];++l){
                if(dp2[k][l])mi = min(mi,needs(l,b[k]));
            }
            ma = max(mi,ma);
        }
        if(ma==0)break;
        if(ma>0){
            res += 1ll<<ma;
            for(int k=0;k<n;++k){
                for(int l=0;l<=a[k];++l){
                    if(dp2[k][l])dp2[k][l%ma]=true;
                }
            }
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


vector<vector<int>> graph;
vector<int> c, visited;
int ptr = 0;

void dfs(int v){
    visited[v] = c[ptr];
    ptr++;

    for(int i = 0; i < graph[v].size(); i++){
        if(visited[graph[v][i]] == -1){
            dfs(graph[v][i]);
        }
    }
    return;
}

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

    graph.resize(n);
    for(int i = 0; i < n-1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    c.resize(n);
    for(int i = 0; i < n; i++){
        cin >> c[i];
    }
    sort(all(c));
    int sum = 0;
    for(int i = 0; i < n-1; i++){
        sum += c[i];
    }
    reverse(all(c));

    visited.resize(n);
    fill(all(visited),-1);
    dfs(0);
    cout << sum << endl;
    for(int i = 0; i < n; i++){
        cout << visited[i] << " ";
    }
    cout << endl;
    return 0;

}


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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}

unsigned long lcm(unsigned long x, unsigned long y){
    unsigned long g = gcd(x, y);
    return x*y/g;

}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

int a[105];

int main(void){
    int n;
    int cnt = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    for (int i = n-1; i >= 1; i--){
        for (int j = 1; j <= i; j++){
            if (a[j-1] > a[j]){
                int tmp = a[j-1];
                a[j-1] = a[j];
                a[j] = tmp;
                cnt++;
            }
        }
    }
    for (int i = 0; i < n-1; i++){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[n-1]);
    printf("%d\n", cnt);
    return 0;

}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int Node[251];
int parent(int i ){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}
int main()
{
	int n;
	cin >> n;
	for(int i =0;i<n;i++)
	cin >> Node[i+1];
	

	for(int i = 1;i<=n;i++)
	{
		printf("node %d: key = %d, ",i,Node[i]);
		if(i!=1)printf("parent key = %d, ",Node[parent(i)]);
		if(left(i)<=n)printf("left key = %d, ",Node[left(i)]);
		if(right(i)<=n)printf("right key = %d, ",Node[right(i)]);
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,l,r,s=0;
	cin>>n;
	for(int i=1;i<=n;i++)
    {
    	cin>>l>>r;
    	s+=(r-l+1);
	}
	cout<<s<<endl;
	return 0;
}

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

int main()
{
    while (1)
    {
	double x,h;
	cin >> x >> h;
	if (x==0)break;
	printf("%.6f\n", x*x+2.0*x*sqrt(x*x/4.0+h*h));
    }
    return 0;
}

Measured memory_bytes: 0
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()

    var max = 0
    var maxScore = 0
    repeat(n) {
        val (a, b) = readLine()!!.split(" ").map{it.toInt()}
        if (a > max) {
            max = a
            maxScore = b
        }
    }

    println(max+maxScore)
}

Measured memory_bytes: 55708
#include <iostream>
#include <string.h>
using namespace std;

int main() {
	char c[501];
	int w,h,da[501],db[501],dc[501],mx,s,p,i;
	db[0]=-1;
	while(cin >> h >> w) {
		if (w+h==0) break;
		for (i=0;i<w;i++) da[i]=0;
		mx=0;
		for (h;h>0;h--) {
			cin >> c;
			p=0; 
			for (i=0;i<w;i++) dc[i]=db[i]=0;
			for (i=0;i<=w;i++) {
				if (c[i]=='.') da[i]++; else da[i]=0;
				if (da[i]>db[p]) { p++; db[p]=da[i]; dc[p]=1; continue;}
				s=1;
				while(da[i]<db[p]) {
					s+=dc[p]; 
					if (mx<db[p]*(s-1)) { mx=db[p]*(s-1); } 
					dc[p--]=0;
				}
				if (da[i]>db[p]) { p++; db[p]=da[i]; dc[p]=s; } else dc[p]+=s;
			}
		}
    cout << mx << endl;
	}
return 0;	
}

Measured memory_bytes: 1168
n=int(input())
s=[input() for i in range(n)]
s.sort()
b=list(set(s))
b.sort()
a=s[0]
m=[0]
for i in range(n):
  if s[i]!=a:
    m.append(i)
    a=s[i]
m.append(n)
o=[]
for i in range(len(m)-1):
  o.append(m[i+1]-m[i])
num=max(o)
for i in range(len(o)):
  if o[i]==num:
    print(b[i])

Measured memory_bytes: 30256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  int sum=0;
  for(int i=0;i<k;i++) sum+=a[i];
 cout<<sum<<endl;
}


Measured memory_bytes: 3560
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    string a,b;
    cin >> a >>b;
    int i;
    for(i=0;i<b.size();i++){
      cout << a[i] << b[i];
    }
    if(a.size()>b.size())cout << a[a.size()-1]<<endl;
    return 0;
}


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

using namespace std;
int X,N;
int A[2000010]{};
bool B[2000010]{};
vector <int> C;
int main()
{
  cin>>N;
  if(N%1000==0)cout<<0;
  else cout<<1000-(N%1000);
  
  return 0;
}


Measured memory_bytes: 3596
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 24 21:04:16 2019

@author: Toroi0610
"""

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

M, D = map(int, input().split())
day = [str(d) for d in range(1, D+1)]
cnt = 0
for m in range(1, M+1):
    s = make_divisors(m)
    length = len(s)
    if length == 2:
        continue
    if length%2 == 0:
        for l, r in zip(s[:int(length/2)], s[int(length/2):][::-1]):
            if (l > 10) or (r > 10) or (l==1):
                continue
            else:
                if str(l)+str(r) in day:
                    cnt += 1
                if str(r)+str(l) in day:
                    cnt += 1
    else:
        for l, r in zip(s[:int(length/2)+1], s[int(length/2):][::-1]):
            if (l > 10) or (r > 10) or (l==1):
                continue
            else:
                if str(l)+str(r) in day:
                    cnt += 1
                if l != r:
                    if str(r)+str(l) in day:
                        cnt += 1
print(cnt)


Measured memory_bytes: 3188
#include<stdio.h>
int main()
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if(a==1&&b==0&&c==0||a==0&&b==1&&c==0||a==0&&b==0&&c==0)
{
printf("Close\n");
}
else
{
printf("Open\n");
}
return 0;
}

Measured memory_bytes: 584
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))

typedef struct block{
  int w,s,v;
} node;

int cmp(const void *a,const void *b){
  node *p=(node *)a;
  node *q=(node *)b;
  return (p->s+p->w)-(q->s+q->w);
}

void run(void){
  int n;
  scanf("%d",&n);
  node *p=(node *)calloc(n,sizeof(node));
  int i;
  for(i=0;i<n;i++){
    int w,s,v;
    scanf("%d%d%d",&w,&s,&v);
    p[i]=(node){w,s,v};
  }
  qsort(p,n,sizeof(node),cmp);
  const int m=2*10000;
  int64 *dp=(int64 *)calloc(m+1,sizeof(int64));
  for(i=0;i<n;i++){
    for(int j=p[i].s;j>=0;j--){
      dp[j+p[i].w]=MAX(dp[j+p[i].w],dp[j]+p[i].v);
    }
  }
  int64 ans=0;
  for(i=0;i<=m;i++) ans=MAX(ans,dp[i]);
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
int P[1010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) cin>>P[i];
	sort(P,P+N);
	x=0;
	FOR(i,K) x+=P[i];
	cout<<x<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3648
import java.util.*;

class Main{

    String S;
    int I;
    ArrayList<Character> line;
    boolean end;

    void solve(){
	Scanner sc = new Scanner(System.in);

	while(true){
	    S = sc.next();
	    I = sc.nextInt();
	    if(S.equals("0") && I==0)break;

	    line = new ArrayList<Character>();
	    end = false;
	    splitLine(S);

	    String ans = "";
	    if(I>=line.size())ans = "0";
	    else ans = String.valueOf(line.get(I));

	    System.out.println(ans);
	}
    }

    void splitLine(String s){
	if(end)return;

	for(int i=0; i<s.length(); i++){
	    if(s.charAt(i)-'A'<=25 && s.charAt(i)-'A'>=0){
		int j = i+1;
		for(j=i+1; j<s.length(); j++){
		    if(!(s.charAt(j)-'A'<=25 && s.charAt(j)-'A'>=0))break;
		}
		addLine(s.substring(i,j));
		if(end)return;
		i = j-1;
		
	    }else{
		int from = i;
		for(from=i+1; from<s.length(); from++){
		    //if(!(s.charAt(from)<10 || s.charAt(from)=='0'))break;
		    char c = s.charAt(from);
		    if(!(c=='0' || c=='1' || c=='2' || c=='3' || c=='4' || c=='5' || c=='6' || c=='7' || c=='8' || c=='9'))break;
		}
		int N = Integer.parseInt(s.substring(i,from));

		int pair = 0;
		int to=from;
		for(to=from; to<s.length(); to++){
		    if(s.charAt(to)=='(') pair++;
		    if(s.charAt(to)==')') pair--;
		    if(pair==0)break;
		}
		
		String seq = "";
		if(from==to){
		    seq = s.substring(from,from+1);
		}else{
		    seq = s.substring(from+1,to);
		}
		
		while(N-->0)splitLine(seq);
		i = to;
	    }
	}
    }
    
    void addLine(String s){
	char[] c = s.toCharArray();
	for(int i=0; i<c.length; i++){
	    line.add(c[i]);
	    if(line.size()>I){end = true; return;}
	}
    }

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

Measured memory_bytes: 23000
import java.util.*

fun main(args:Array<String>){
    val (h,w) = readLine()!!.split(" ").map{it.toInt()}
    val n = readLine()!!.toInt()
    var a = readLine()!!.split(" ").map{it.toInt()}.toIntArray()
    var ans = Array(h) {IntArray(w)}
    var itr = 0
    for(i in 0 until h){
        if(i % 2 == 0){
            for(j in 0 until w){
                if(a[itr] == 0) itr++
                ans[i][j] = itr + 1
                a[itr]--
            }
        }
        else{
            for(j in w - 1 downTo 0){
                if(a[itr] == 0) itr++
                ans[i][j] = itr + 1
                a[itr]--
            }
        }
    }
    for(i in 0 until h){
        print(ans[i][0])
        for(j in 1 until w){
            print(" " + ans[i][j].toString())
        }
        println()
    }
}


Measured memory_bytes: 39184
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&a!=c) cout<<"Yes"<<endl;
	else if(a==c&&a!=b) cout<<"Yes"<<endl;
	else if(b==c&&a!=b) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
} 

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

#define mid ((l + r) >> 1)

int n, k;
ll t[800200], lazy[800200], mod = 998244353;
vector<pair<int, int>> v;

void lazy_update(int node, int l, int r){
	if(lazy[node]){
		(t[node] += lazy[node]) %= mod;
		if(l != r) (lazy[node*2] += lazy[node]) %= mod, (lazy[node*2+1] += lazy[node]) %= mod;
		lazy[node] = 0;
	}
}

ll find(int id, int node = 1, int l = 1, int r = n){
	lazy_update(node, l, r);
	if(id < l || r < id) return 0;
	if(l == r) return t[node];
	return find(id, node*2, l, mid) + find(id, node*2+1, mid+1, r);
}

void update(int nl, int nr, ll x, int node = 1, int l = 1, int r = n){
	lazy_update(node, l, r);
	if(nr < l || r < nl) return;
	if(nl <= l && r <= nr){
		lazy[node] += x;
		lazy_update(node, l, r);
		return;
	}
	update(nl, nr, x, node*2, l, mid), update(nl, nr, x, node*2+1, mid+1, r);
	t[node] = (t[node*2] + t[node*2+1]) % mod;
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n >> k;
	for(int i=1;i<=k;i++){
		int a, b; cin >> a >> b;
		v.push_back({a, b});
	}

	update(1, 1, 1);
	for(int i=1;i<n;i++){
		ll k = find(i);
		for(auto [l, r] : v) if(i + l <= n) update(i + l, min(i + r, n), k);
	}

	cout << find(n);
}

Measured memory_bytes: 11840
import math 

n,k = map(int,input().split(" "))
result = 0.0

for i in range(1,n+1):
    if i > k:
        max_pow = 0.0
    else:
        max_pow = math.ceil(math.log(k/i)/math.log(2))
    result += (0.5) ** max_pow /n
print(result)

Measured memory_bytes: 3060
function f(s)
	ret=0
	T=length(s)
	for i=0:2^(T-1)-1
		now=0
		p=0
		for j=1:T
			p=10p+Int(s[j])-48
			if (i>>(j-1))%2==1
				now+=p
				p=0
			end
		end
		ret+=now+p
	end
	ret
end
println(f(chomp(readline())))


Measured memory_bytes: 110088
import sys
input = sys.stdin.readline

N = int(input().strip())

a = []
for i in range(N):
    l = input().strip().split()
    l[1] = 100-int(l[1])
    l.append(i+1)
    a.append(l)
a.sort()

for i in range(N):
    print(a[i][2])

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



int main() {
	float N;
	double ans=0;
	cin >> N;

	int tmp;
	tmp = N-((int)N/2);

	
	ans = (double)tmp/N;
	

	
	cout << fixed<<setprecision(10) << ans<<endl;
	
	
	

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "<<"\n"
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "<<"\n"
#define F           first
#define S           second
#define debug_set(s) for(auto p:s) cout<<p<<" "
#define debug_map(m) for(auto p:m) cout<<p.F<<" "<<p.S<<"\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
//#pragma GCC optimize("Ofast")  // works very well
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll kjk;
    for(kjk=0;kjk<b;kjk++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// to generate random number , use rng() ... eg cout<<rng();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,i;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    ll ans=0;
    ll nn=n-1;
    if(nn)
    {
        ans+=a[n-1];
        nn--;
    }
    ll idx=n-2;
    while(nn)
    {
        if(nn>1)
        {
            nn-=2;
            ans+=2*a[idx];
            idx--;
        }
        else
        {
            nn-=1;
            ans+=a[idx];
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 5212
#include<bits/stdc++.h>
using namespace std;
int main(){
long long int n,a,b,c,d,e,min,t;
  t=5;
  cin>>n>>a>>b>>c>>d>>e;
  min=a;
  if(min>b){min=b;}
  if(min>c){min=c;}
  if(min>d){min=d;}
  if(min>e){min=e;}
if(n%min==0){
t+=((n/min)-1);
}else{
  t+=(n/min);
}
  cout<<t<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <deque>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <sstream>
#include <numeric>
using namespace std;
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define pf push_front
#define fs first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
int main() {
    fastio
    ll n;
    cin>>n;
    ll sum = n*(n+1)/2;
    ll a = n/3;
    sum -= (3*a*(a+1))/2;
    a = n/5;
    sum -= (5*a*(a+1))/2;
    a = n/15;
    sum += (15*a*(a+1))/2;
    cout<<sum<<endl;
}



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

int main() {
  int N;
  cin >> N;
  string t="Three";
  for (int i = 0; i < N; i++){
    string s;
    cin >> s;
    if(s=="Y"){
      t="Four";
    }
  }
  cout << t << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define MAX_A 50
using namespace std;

int main() {
    int n, a;
    cin >> n >> a;
    int x[n];
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    long dp[1 + n][1 + n * MAX_A];
    for (int i = 0; i <= n; i++) {
        fill(dp[i], dp[i] + n * MAX_A + 1, 0);
    }
    dp[0][0] = 1;
    for (int v: x) {
        for (int i = n; i > 0; i--) {
            for (int j = 0; j <= n * MAX_A - v; j++)
            dp[i][j + v] += dp[i - 1][j];
        }
    }
    long ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += dp[i][a * i];
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    ll n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    string s;
    a--;b--;c--;d--;
    cin>>s;
    bool flag=true;

    if(d>c){
        for(int i=a;i < d;i++) {
            if(i+1<n&&s.at(i)=='#' && s.at(i+1)=='#'){
                flag=false;
            }
        }
    }else{
        flag=false;
        for(int i=b-1;i<d;i++)
        {  
            if(i+2<n &&s.at(i)=='.'&&s.at(i+1)=='.' && s.at(i+2)=='.'){
                flag=true;
            }
        }
    }

    if(flag==true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;   
    }
}


Measured memory_bytes: 640
/* AOJ 0029
 *
 *
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define DEBUG 0

#define DEFAULTSIZE 1024


int comp_x(const void*a, const void*b)
{
  char* x = *(char**) a;
  char* y = *(char**) b;

  while (*x && *y && *x==*y){
    x++; y++;
  }
  if(*x && *y){
    return *x - *y;
  }
  if(*x){ /* x is longer */
    return -1;
  }
  if(*y){/* y is longer */
    return 1;
  }
  return 0; /* same! */
}

typedef struct TPair Pair;
struct TPair {
  char* fValue;
  int fCount;
};

int comp_pair(const void*a, const void*b)
{
  return ((Pair*)b)->fCount - ((Pair*)a)->fCount;
}


int main(){
  /* The mode value is the element which occurs most frequently */

  char buf[33];
  int n;
  char* p[1024];
  int used;
  int size;
  int i,j;
  char* last;
  int count;
  Pair *q;
  char * tmp;
  char* longest;
  int len;


  used = 0;
  while(scanf("%s", buf)==1){
    if(DEBUG)
      printf("[%s]\n", buf);
    *(p+used) = (char*)malloc(strlen(buf)+1);
    strcpy(*(p+used), buf);
    used++;
  }
  qsort(p, used, sizeof(char*), comp_x);
  if(DEBUG)
    printf("=======\n");

  if(DEBUG)
    for(i=0; i< used; i++){
      printf("%s\n", *(p+i));
    }

  q = (Pair*)malloc(sizeof(Pair)*used);

  last = *p;
  longest = *p;
  count = 1;
  j = 0;
  for(i = 1; i<used; i++){
    if(strlen(*(p+i)) > strlen(longest)){
      longest = *(p+i);
    }
    if(comp_x((p+i), &last)==0){
      count +=1;
    }else{
      (q+j)->fCount = count;
      (q+j)->fValue = last;
      j++;
      last = *(p+i);
      count = 1;
    }
  }
  (q+j)->fCount = count;
  (q+j)->fValue = last;
  j++;

  qsort(q, j, sizeof(Pair), comp_pair);

  printf("%s", q->fValue);/*mostfreq*/
  printf(" ");
  printf("%s\n", longest);

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int ta,ao;
  
  if((c % b) == 0){
    ta = (c / b);
   }else{
    ta = (c / b) + 1;
   }
  
   if((a % d) == 0){
    ao = (a / d);
   }else{
    ao = (a / d) + 1;
   }
  
  if(ta <= ao) {
     cout << "Yes" << endl;
  }else{
     cout << "No" << endl; 
  }
 
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


#line 1 "lib/segment_tree.hpp"



#include <vector>
#include <algorithm>
#include <functional>

template<typename Monoid>
class SegmentTree {
public:
    using Operator = std::function<Monoid(Monoid, Monoid)>;

    SegmentTree(int n, const Operator &op, const Monoid init)
        : op(op), init(init) {

        num = 1;
        while (num < n) num *= 2;
        dat.resize(2 * num, init);
    }

    SegmentTree(const std::vector<Monoid> &m,
        const Operator &op, const Monoid init)
        : SegmentTree(m.size(), op, init) {

        int n = m.size();
        for (int i = 0; i < n; i++) {
            dat[num - 1 + i] = m[i];
        }
        for (int i = num - 2; i >= 0; i--) {
            dat[i] = op(dat[2 * i + 1], dat[2 * i + 2]);
        }
    }

    // Update the k-th value (0-indexed) to a.
    void update(int k, Monoid a) {
        k += num - 1;
        dat[k] = a;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[k] = op(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }

    // Get the value of the range [a, b).
    // k: The index of the node.
    // [left, right): The range corresponds to the k-th node.
    // Call like getval(a, b).
    Monoid getval(int a, int b, int k = 0, int left = 0, int right = -1) {
        if (right < 0) right = num;
        if (right <= a || b <= left) return init;
        if (a <= left && right <= b) return dat[k];
        Monoid vleft = getval(
            a, b, 2 * k + 1, left, left + (right - left) / 2);
        Monoid vright = getval(
            a, b, 2 * k + 2, left + (right - left) / 2, right);
        return op(vleft, vright);
    }

private:
    int num;
    std::vector<Monoid> dat;
    const Operator op;
    const Monoid init;
};


int main() {
    int n; std::cin >> n;
    using P = std::pair<long long, long long>;
    std::vector<P> lr(n);
    for (int i = 0; i < n; i++) {
        std::cin >> lr[i].first >> lr[i].second;
        lr[i].second++;
    }
    std::sort(lr.begin(), lr.end());
    SegmentTree<P>
        seg(lr,
            [](const P &a, const P &b) -> P {
                return {
                    std::max(a.first, b.first),
                    std::min(a.second, b.second) };
            },
            { 0, 1e9 + 2 });
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        long long v = lr[i].second - lr[i].first;
        auto p = seg.getval(0, i), q = seg.getval(i + 1, n);
        v += std::max(0LL,
            std::min(p.second, q.second) - std::max(p.first, q.first));
        ans = std::max(ans, v);
    }
    for (int i = 0; i < n - 1; i++) {
        auto p = seg.getval(0, i + 1), q = seg.getval(i + 1, n);
        auto u = std::max(0LL, p.second - p.first);
        auto v = std::max(0LL, q.second - q.first);
        ans = std::max(ans, u + v);
    }
    std::cout << ans << std::endl;
    return 0;
}


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

using ll = long long;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W)), B(H, vector<int>(W));
    rep(i, H) {
        rep(j, W) {
            cin >> A[i][j];
        }
    }
    rep(i, H) {
        rep(j, W) {
            cin >> B[i][j];
        }
    }
    vector<vector<vector<bool>>> s(H + 1, vector<vector<bool>>(W + 1, vector<bool> (12800, false)));
    s[0][1][0] = true;
    s[1][0][0] = true;
    rep(i, H) {
        rep(j, W) {
            rep(k, 12800) {
                if (s[i][j + 1][k] || s[i + 1][j][k]) {
                    s[i + 1][j + 1][abs(k + A[i][j] - B[i][j])] = true;
                    s[i + 1][j + 1][abs(k - A[i][j] + B[i][j])] = true;
                }
            }
        }
    }
    rep(i, 12800) {
        if (s[H][W][i]) {
            cout << i << "\n";
            return 0;
        }
    }
    /*
    rep(i, H) {
        cout << "i=" << i << "\n";
        rep(j, W) {
            cout << "j=" << j << " s=";
            for (auto k : s[i + 1][j + 1]) {
                cout << k << " ";
            }
            cout << "\n";
        }
    }
    */
}

Measured memory_bytes: 11008
import java.util.Scanner;

public class Main {

    public static void main( String[] args ){

        Scanner in = new Scanner(System.in);

        String[] params = in.nextLine().split(" ");
        int x = Integer.parseInt(params[0]);
        int a = Integer.parseInt(params[1]);

        System.out.println( x < a ? 0 : 10);

    }
}

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define I_1000000007 (1000000007)
#define I_998244353   (998244353)
#define I_INF             (1<<28)
#define L_INF           (1LL<<60)
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"
template<class T> inline bool chmin(T& a, const T& b) {
  if (a > b) { a = b; return true; } else return false;
}
template<class T> inline bool chmax(T& a, const T& b) {
  if (a < b) { a = b; return true; } else return false;
}

namespace solver {
  using namespace std;
  using ll = long long;

  double A, B, H, M;

  void init() {
    cin >> A >> B >> H >> M;
  }

  void solve() {
    double ax, ay, bx, by;
    double a_deg = 360.0/12.0*H+30.0/60.0*M;
    double b_deg = 360.0/60.0*M;
    ax = A*cos(a_deg*M_PI/180);
    ay = A*sin(a_deg*M_PI/180);
    bx = B*cos(b_deg*M_PI/180);
    by = B*sin(b_deg*M_PI/180);
    double ans = sqrt(pow(abs(ax-bx), 2) + pow(abs(ay-by), 2));
    cout << fixed << setprecision(20) << ans << "\n";
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 4112
package main

import (
	"fmt"
)

func main() {
	var P, Q, R int
	fmt.Scan(&P)
	fmt.Scan(&Q)
	fmt.Scan(&R)

	min := P + Q
	
	if min > Q + R { 
		min = Q + R
	}
	if min > R + P {
		min = R + P
	}
	
	fmt.Println(min)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<int, int>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

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

  ll n;
  cin >> n;
  vector<vector<ll>> g(n);
  REP(i, n-1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<ll> c(n+1);
  c[2] = 1;
  for(ll i=4; i<=n; i+=2) {
    (c[i] = c[i-2] * (i-1)) %= MOD;
  }
  // cout << c << endl;

  // 2乗の木DP
  function<vector<vector<ll>>(ll,ll)> dfs = [&](ll v, ll par) {
    auto ret = make_v<ll>(2,2);
    fill_v(ret, 0);
    ret[1][0] = 1;
    for(auto to: g[v]) {
      if(to == par) continue;
      auto tmp = dfs(to, v);
      vector<vector<ll>> nret(ret.size()+tmp.size()-1, vector<ll>(2, 0));
      // fill_v(nret, 0);
      REP(i, ret.size()) REP(j, tmp.size()) {
        // vからtoまでの辺を切断
        (nret[i][0] += ret[i][0] * tmp[j][1] % MOD * c[j] + ret[i][1] * tmp[j][0] % MOD * c[j]) %= MOD; 
        (nret[i][1] += ret[i][0] * tmp[j][0] % MOD * c[j] + ret[i][1] * tmp[j][1] % MOD * c[j]) %= MOD;
        // vからtoまでの辺をつないだまま
        (nret[i+j][0] += ret[i][0] * tmp[j][0] + ret[i][1] * tmp[j][1]) %= MOD;
        (nret[i+j][1] += ret[i][0] * tmp[j][1] + ret[i][1] * tmp[j][0]) %= MOD;
      }
      ret = nret;
    }
    return ret;
  };

  auto ret = dfs(0, -1);

  ll ans = 0;
  REP(i, ret.size()) {
    (ans += ret[i][0] * c[i] % MOD) %= MOD;
    (ans -= ret[i][1] * c[i] % MOD) %= MOD;
    if(ans < 0) ans += MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2176
#include<iostream>

using namespace std;

int main()
{
  int n;
  cin >> n;
  long long cnt = 0;
  for(int i=0;i<n;i++)
    {
      int a,b; char c;
      cin >> a >> c >> b;
      c == '('?cnt += b:cnt -= b;
      !cnt?cout << "Yes" << endl:cout << "No" << endl;
    }
 
  return 0;
}

Measured memory_bytes: 1156
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, a, b;
  cin >> x >> a >> b;
  a -= x;
  b -= x;
  if(abs(a) < abs(b)) {
    cout << 'A' << '\n';
  } else {
    cout << 'B' << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a ,b,c,d;
cin>>a>>b>>c>>d;
int c1=c/b,c2=a/d;
if(c%b)
    c1++;
if(a%d)
    c2++;

if(c1<=c2)
    cout<<"Yes\n";
else
    cout<<"No\n";



return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define repitr(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	string s;
	cin >> s;
	set<char> st;
	rep(i, 3){
		st.insert(s[i]);
	}
	if(st.size() == 1) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
void print_vv(vector<vector<int>>v) {
	rep(i, 0, v.size()) {
		rep(j, 0, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
}
void print_v(vector<int>v) {
	rep(i, 0, v.size())cout << v[i] << " ";
	cout << endl;
}
int N, K;
vector<vector<int>>table(11, vector<int>(1, 0));
vector<vector<int>>dp(11, vector<int>(2048, -1));
int dfs(int n, int k) {
	if (n == 10)return 0;
	if (dp[n][k] != -1)return dp[n][k];
	int res(0);
	rep(i, 0, table[n].size()) {
		if (k + i > K) break;
		res = max(res, dfs(n + 1, k + i) + table[n][i]);
	}

	return dp[n][k] = res;
}
signed main() {
	cin >> N >> K;
	vector<int>v(N), kind(N), num(11, 0);
	rep(i, 0, N) {
		cin >> v[i] >> kind[i];
		table[--kind[i]].push_back(v[i]);
		num[kind[i]]++;
	}

	rep(i, 0, 11) {
		sort(table[i].begin() + 1, table[i].end(), greater<int>());
		//print_v(table[i]);
		rep(j, 1, table[i].size()) {
			table[i][j] += table[i][j - 1];
		}
		//print_v(table[i]);
		rep(j, 1, table[i].size()) {
			table[i][j] += (j - 1)*j;
		}
		//print_v(table[i]);
	}
	//print_vv(table);
	//vector<vector<int>>dp(table);
	//rep(i, 1, 10) {
	//	rep(j, 1, k + 1) {
	//		if (dp[i][j] == 0)break;
	//		for (int l = 0; l + j < k + 1; l++) {
	//			bool f1(false), f2(false);
	//			if (dp[i + 1][j + l] == 0)f1 = true;
	//			if (dp[i + 1][j + l] < dp[i][j] + dp[i + 1][l])f2 = true;
	//			dp[i + 1][j + l] = max(dp[i + 1][j + l], dp[i][j] + dp[i + 1][l]);
	//			if (f1 || f2)break;
	//		}
	//		//print_vv(dp);
	//	}
	//}
	cout << dfs(0, 0) << endl;
	return 0;
}

Measured memory_bytes: 3256
object Main extends App {
    val in = io.Source.stdin.getLines
    for (x <- in; Array(m, nmin, nmax) = x.split(" ").map(_.toInt) if m != 0) {
        val ps = in.take(m).toList.map(_.toInt).zipWithIndex.slice(nmin-1, nmax+1)
        println(ps.foldLeft((0, 0, -1)){ case ((gap, p0, res), (p1, i)) =>
            if (p0 - p1 >= gap) (p0-p1, p1, i) else (gap, p1, res)
        }._3)
    }
}

Measured memory_bytes: 55484
import itertools
import math

N = int(input())
S_list = []
for i in range(N):
    S_list.append(input())

count_M = 0
count_A = 0
count_R = 0
count_C = 0
count_H = 0

for l in S_list:
    if l.startswith('M'):
        count_M += 1
    elif l.startswith('A'):
        count_A += 1
    elif l.startswith('R'):
        count_R += 1
    elif l.startswith('C'):
        count_C += 1
    elif l.startswith('H'):
        count_H += 1

count = [count_M,count_A,count_R,count_C,count_H]
c = list(itertools.combinations(count,3))
x = 0
for i in c:
    i_list = list(i)
    x += i_list[0]*i_list[1]*i_list[2]
print(x)


Measured memory_bytes: 9792
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<stdbool.h>

int ceil_pow2(int n){
	int res = 0;
	while(1U<<res < (unsigned int)n)res++;
	return res;
}

typedef int64_t Int;
Int segtree_op(Int a, Int b){return a + b;}
const Int segtree_id = 0;

Int* segtree(int n){
	int lg = ceil_pow2(n);
	Int* res = (Int*)malloc(sizeof(Int) * (1<<lg) * 2);
	for(int i=0; i<=(1<<lg)*2; i++)res[i] = segtree_id;
	return res;
}
void update(Int arr[], int k){arr[k] = segtree_op(arr[k*2], arr[2*k+1]);}
void set(Int arr[], int n, int p, Int x){
	int lg = ceil_pow2(n);
	p += 1<<lg;
	arr[p] = x;
	for(int i=1; i<=lg; i++)update(arr, p>>i);
}
void _set(Int arr[], int n, int p, Int x){
	int lg = ceil_pow2(n);
	p += 1<<lg;
	arr[p] = segtree_op(arr[p], x);
	for(int i=1; i<=lg; i++)update(arr, p>>i);
}
Int get(Int arr[], int n, int p){
	return arr[p +(1<<ceil_pow2(n))];
}
Int prod(Int arr[], int n, int l, int r){
	Int sml = segtree_id, smr = segtree_id;
	int lg = ceil_pow2(n);
	l += 1<<lg;
	r += 1<<lg;
	while(l < r){
		if(l & 1) sml = segtree_op(sml, arr[l++]);
		if(r & 1) smr = segtree_op(arr[--r], smr);
		l >>= 1;
		r >>= 1;
	}
	return segtree_op(sml, smr);
}
Int all_prod(Int arr[]){return arr[1];}
int max_right(Int arr[], int n, int l, bool (*f)(Int)){
	if(l == n) return n;
	int lg = ceil_pow2(n);
	int size = 1<<lg;
	l += size;
	Int sm = segtree_id;
	do{
		while(l % 2 == 0) l >>= 1;
		if(!f(segtree_op(sm, arr[l]))){
			while(l < size){
				l = 2*l;
				if(f(segtree_op(sm, arr[l]))){
					sm = segtree_op(sm, arr[l]);
					l++;
				}
			}
			return l - size;
		}
		sm = segtree_op(sm, arr[l]);
		l++;
	}while((l & -l) != l);
	return n;
}
int min_right(Int arr[], int n, int r, bool (*f)(Int)){
	if(r == 0) return 0;
	int lg = ceil_pow2(n);
	int size = 1<<lg;
	r += size;
	Int sm = segtree_id;
	do{
		r--;
		while(r>1 && r&1) r >>= 1;
		if(!f(segtree_op(arr[r], sm))){
			while(r < size){
				r = 2*r + 1;
				if(f(segtree_op(arr[r], sm))){
					sm = segtree_op(arr[r], sm);
					r--;
				}
			}
			return r + 1 - size;
		}
		sm = segtree_op(arr[r], sm);
	}while((r & -r) != r);
	return 0;
}

int main(){
	int N, Q;
	scanf("%d%d", &N, &Q);
	Int *d = segtree(N);
	for(int i=0; i<N; i++){
		int A;
		scanf("%d", &A);
		set(d, N, i, A);
	}
	while(Q--){
		int T, X, Y;
		scanf("%d%d%d", &T, &X, &Y);
		if(T == 1)printf("%ld\n", prod(d, N, X, Y));
		else _set(d, N, X, Y);
	}
	return 0;
}

Measured memory_bytes: 12368
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int N=100010;
int compare_int(const void *a, const void *b)
{
    return *(long long int*)b - *(long long int*)a;
}
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}

int main(){
	int n, max=0, a=0;
	char s[1000000];
	cin>>n>>s;
	rep(i, n){
		if(s[i]=='.'){
			a++;
			if(a>max){
				max=a;
			}
		}
		else{
			a--;
		}
	}
	int anss=(n-max*2+a)/2;
	cout<<anss<<endl;









//	qsort(b, 5, sizeof(long long int), compare_int);
/*	rep(i, 5){
		if((b[i]-1)%10<k){
			k=b[i]%10;
		}
		ans=ans+(b[i]+9)/10;
	}
	anss=ans*10+k-10;
	if(k==0){
		anss=anss+10;
	}
	cout<<anss<<endl;




/*	qsort(b, 5, sizeof(int), compare_int);
	if(b[4]-b[0]>k){
		printf(":(\n");
	}
	else{
		printf("Yay!\n");
	}
		rep(i, n){
		ans=c;
		rep(j, m){
			cin>>imp;
			ans=ans+imp*b[j];
		}
		if(ans>0){
			anss++;
		}
	}
	cout<<anss<<endl;
}*/
}

Measured memory_bytes: 384
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
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; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s;
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}

int main() {
	ll q;
	cin >> n >> k >> q;
	vector<ll> a(q);
	vector<ll> b(n);
	rep(i, q) {
		cin >> a[i];
		b[a[i]-1]++;
	}
	ll sum = 0;
	rep(i, n) {
		ll ans = k - (q - b[i]);
		if (ans > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 2176
A=int(input())
B=int(input())
if A==1 and B==2:
    print(3)
if A==1 and B==3:
    print(2)
if A==2 and B==1:
    print(3)
if A==2 and B==3:
    print(1)
if A==3 and B==1:
    print(2)
if A==3 and B==2:
    print(1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
///...................................*****.................................................///
///        Author :  MD. Rakibul Islam ( mmdrakibul2912@gmail.com )                         ///
///                  Department of Computer Science                                         ///
///                  & Engineering,                                                         ///
///                  Comilla University , Bangladesh.                                       ///
///...................................*****.................................................///
using namespace std;
int main()
{
    string s, s1;
    int i, j, k, l, cnt=0;
    cin>>s;
    cin>>s1;
    for(i=0; i<3; i++)
    {
        if(s[i]==s1[i])
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
using namespace std;
int h,n;
int a[1005];
int b[1005];
int dp[20005];
int ans=0x3f3f3f3f;
inline int min(int a,int b){
	return a<b?a:b;
}
int main(){
	scanf("%d%d",&h,&n);
	for (int i=1;i<=n;i++){
		scanf("%d%d",&a[i],&b[i]);
	}
	memset(dp,0x3f,sizeof(dp));
	dp[0]=0;
	for (int i=1;i<=n;i++){
		for (int j=a[i];j<=(int)1e4;j++){
			dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
		}
	}
//	for (int i=0;i<=h;i++){
//		printf("%d ",dp[i]);
//	}
	for (int i=h;i<=(int)1e4;i++){
		ans=min(ans,dp[i]);
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

namespace {

struct Process {
  char name[10];
  // required time to process this task.
  int time;
  int id;
  // last modified time
  int timestamp;
};

class ProcessComparator {
 public:
  bool operator()(const Process* a, const Process* b) const {
    return (a->timestamp == 0 && a->timestamp == b->timestamp) ?
        a->id > b->id : a->timestamp >= b->timestamp;
  }
};

inline int min(int a, int b) {
  return a < b ? a : b;
}

} // namespace

int main() {
  using Queue = priority_queue<Process*, vector<Process*>,
                               ProcessComparator>;
  Queue queue;
  vector<Process *> backstore;

  int n;
  int q;
  cin >> n >> q;
  for (int i = 0; i < n; ++i) {
    auto p = new Process;
    cin >> p->name >> p->time;
    p->id = i;
    p->timestamp = 0;
    backstore.push_back(p);
    queue.push(p);
  }

  int current_time = 0;
  while (!queue.empty()) {
    auto p = queue.top();
    queue.pop();

    const int used = min(p->time, q);
    p->time -= used;
    current_time += used;
    if (p->time <= 0) {
      cout << p->name << " " << current_time << endl;
      continue;
    }
    p->timestamp = current_time;
    queue.push(p);
  }

  for (auto p : backstore)
    delete p;
  return 0;
}

Measured memory_bytes: 5312