akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <time.h>
#include <complex>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;
using std::complex;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;
typedef complex<double> cd;

inline ll max(ll a, ll b)
{
    if (a > b)
        return a;
    return b;
}

inline ll min(ll a, ll b)
{
    if (a < b)
        return a;
    return b;
}

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

const ll MOD = 1e9 + 7;
ll n;
ll a, b;

int main()
{
    ios_base::sync_with_stdio();
    cin.tie(0);
    cout.tie(0);
    cin >> n >> a >> b;
    cout << min(n * a, b);
}


Measured memory_bytes: 256
h,w,d=map(int,input().split())
a=[list(map(int,input().split())) for i in range(h)]
q=int(input())
lr=[list(map(int,input().split())) for i in range(q)]
data=[[[0,0]]*(h*w//d+1) for i in range(d)]
for i in range(h):
    for j in range(w):
        b=a[i][j]%d
        c=a[i][j]//d
        data[b][c]=[i, j]
lst=[[0]*(h*w//d+1) for i in range(d)]
for i in range(d):
    for j in range(1,h*w//d+1):
        x,y=data[i][j]
        X,Y=data[i][j-1]
        lst[i][j]=lst[i][j-1]+abs(x-X)+abs(y-Y)
for u in lr:
    l,r=u
    b=l%d
    c=l//d
    e=r//d
    ans=lst[b][e]-lst[b][c]
    print(ans)

Measured memory_bytes: 104668
r=range;d=[1]+[0]*12
for s in input():
 p=[0]*13
 for j in r(13):
  for k in ([s],r(10))[s>'9']:t=(j*10+int(k))%13;p[t]+=d[j];p[t]%=10**9+7
 d=p
print(d[5])

Measured memory_bytes: 44032
#include<iostream>
#include<climits>
void merge(int A[],int left,int mid,int right,int& count){
	int n1 = mid - left;
	int n2 = right - mid;
	int L[n1+1], R[n2+1];
	for (int i=0;i<n1;i++){
		L[i] = A[left + i];
	}
	for (int i=0;i<n2;i++){
		R[i] = A[mid + i];
	}
	L[n1]=INT_MAX;
	R[n2]=INT_MAX;
	int i=0,j=0;
	for(int k=left;k<right;k++){
		if(L[i]<=R[j]){
			A[k] = L[i];
			i = i+1;
		}else{
			A[k] = R[j];
			j = j+1;
		}
		count++;
	}
}
void mergeSort(int A[],int left,int right,int& count){
	if(left+1<right){
	    int mid = (left + right)/2;
	    mergeSort(A, left, mid,count);
	    mergeSort(A, mid, right,count);
	    merge(A, left, mid, right,count);
	}
}

int main(){
	
	int n;
	std::cin>>n;
	int A[n];
	for(int i=0;i<n;i++){
		std::cin>>A[i];
	}
	int count=0;
	
	mergeSort(A,0,n,count);
	
	for(int i=0;i<n;i++){
		std::cout<<A[i];
		if(i!=n-1){
			std::cout<<" ";
		}else{
			std::cout<<"\n";
		}
	}
	
	std::cout<<count<<"\n";
	
	return 0;
}




Measured memory_bytes: 6880
N=int(input())
A,B=map(int,input().split())
p = list(map(int,input().split()))
c=[]
d=[]
e=[]
for i in range(N):
    if p[i]<=A:
        c.append(p[i])
    if A+1 <= p[i] <= B:
        d.append(p[i])
    if B+1 <= p[i]:
        e.append(p[i])

        
print(min(len(c),len(d),len(e)))

Measured memory_bytes: 61780
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
typedef ModInt<1000000007> mint;
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];

    mint ans = 0;
    mint tot = 0;
    rep(i, 0, N) tot += A[i];
    ans += tot * tot;
    rep(i, 0, N) ans -= mint(A[i]) * mint(A[i]);
    ans /= 2;
    cout << ans << endl;
}







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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

template<typename T> struct SegmentTree_max{
	int n;
	vector<T> node;
	T MIN;

	SegmentTree_max(const vector<T> &v, const T &MIN_=0){
		init(v, MIN_);
	}

	// nodeの初期化
	void init(const vector<T> &v, const T &MIN_){
		int n_=v.size();
		n=1;
		while(n<n_){
			n<<=1;
		}
		node.resize(n*2-1);
		MIN=MIN_;
		REP(i, n_){
			node[i+n-1]=v[i];
		}
		FORR(i, 0, n-1){
			node[i]=max(node[i*2+1], node[i*2+2]);
		}
	}

	// k番目(0-indexed)をaに変更
	void update(int k, const T &a){
		k+=n-1;
		node[k]=a;
		while(k>0){
			k=(k-1)/2;
			node[k]=max(node[k*2+1], node[k*2+2]);
		}
	}

	// [a, b)の最大値を求める
	// k: 節点の番号、その節点は[l, r)に対応づく
	T query(int a, int b, int k, int l, int r){
		// [a, b)と[l, r)が交差しなければMIN
		if(r<=a || b<=l){
			return MIN;
		}
		// [a, b)と[l, r)が完全に含んでいればこの節点の値
		if(a<=l && r<=b){
			return node[k];
		}
		// そうでなければ2つの子の最大値
		else{
			T v1=query(a, b, k*2+1, l, (l+r)/2), v2=query(a, b, k*2+2, (l+r)/2, r);
			return max(v1, v2);
		}
	}

	T query(int a, int b){
		return query(a, b, 0, 0, n);
	}
};

ll n;

ll f(SegmentTree_max<ll> &st, ll r, ll p){
	ll lb=-1, ub=r;
	while(ub-lb>1){
		ll mid=(lb+ub)/2;
		if(st.query(mid, r+1)<=p){
			ub=mid;
		}
		else{
			lb=mid;
		}
	}
	return ub;
}

ll g(SegmentTree_max<ll> &st, ll l, ll p){
	ll lb=l, ub=n+2;
	while(ub-lb>1){
		ll mid=(lb+ub)/2;
		if(st.query(l, mid)<=p){
			lb=mid;
		}
		else{
			ub=mid;
		}
	}
	return lb;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	cin>>n;
	vl p(n+2);
	FOR(i, 1, n+1){
		cin>>p[i];
	}
	p[0]=p[n+1]=0;
	SegmentTree_max<ll> st(p);
	ll ans=0;
	FOR(i, 1, n+1){
		ll l1=f(st, i, p[i]);
		ll l2=f(st, l1-2, p[i]);
		ll r1=g(st, i, p[i]);
		ll r2=g(st, r1+1, p[i]);
		if(p[l2]>p[i]) l2=l1-1;
		--r1;--r2;
		// cout<<l2<<' '<<l1<<' '<<r1<<' '<<r2<<'\n';
		if(l1<1){
			if(r1<=n){
				ans+=p[i]*i*(min(r2, n)-r1);
			}
		}
		else if(r1>n){
			if(l1>=1){
				ans+=p[i]*(l1-max(l2, 1ll))*(n-i+1);
			}
		}
		else{
			ans+=p[i]*((i-l1+1)*(min(r2, n)-r1)+(l1-max(l2, 1ll))*(r1-i+1));
		}
		// DEBUG(ans);
	}
	cout<<ans<<'\n';
	return 0;
}


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


int main(){

  int n;
  cin>>n;

  bool flg=false;
  for(int i=0;i<=100;i++){
    for(int j=0;j<=100;j++){

      if(i*4+j*7==n){
        flg=true;
        break;
      }
    }
  }

  if(flg)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl; 

  return 0;

}


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

namespace _0124
{
    public class Program

    {
        struct Team
        {
            public string Name { get; set; }
            public int Score { get; set; }
            public int InputOrder { get; set; }
            public Team(string[] items,int i)
            {
                Name = items[0];
                Score = int.Parse(items[1]) * 3 + int.Parse(items[3]);
                InputOrder = i;
            }
        }

        public static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();
            while (true)
            {
                int n = RInt();
                if (n == 0) break;

                Team[] teams = new Team[n];
                for (int i = 0 ; i < n ; i++) teams[i] = new Team(RStAr(), i);

                if (sb.Length > 0) sb.AppendLine("");
                foreach (var item in teams.OrderByDescending(x => x.Score).ThenBy(x => x.InputOrder))
                {
                    sb.AppendLine(item.Name + "," + item.Score);
                }
            }
            Console.Write(sb.ToString());
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



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

#define M 1000000
#define L 14

char H[M][L];

int getChar(char ch)
{
  if( ch == 'A')
  {
  	return 1;
  }
  else if( ch == 'C')
  {
  	return 2;
  }
  else if( ch == 'G')
  {
  	return 3;
  }
  else if( ch == 'T')
  {
  	return 4;
  }
}

long long getKey(char str[])
{
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key)
{ 
	return key%M;
}
	
int h2(int key)
{ 
	return 1+(key%(M-1));
}

int find(char str[])
{
	long long key,i,h;
	key = getKey(str);
	for(i=0;; i++){
		h=(h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str)==0)
		{
			return 1;
		}
		else if(strlen(H[h]) == 0)
		{
			return 0;
		}
	}
	return 0;
}

int insert(char str[])
{	
	long long key,i,h;
	key=getKey(str);
	for(i=0;;i++){
		h=(h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str)==0)
		{
			return 1;
		}
		else if(strlen(H[h])==0)
		{
			strcpy(H[h],str);
			return 0;
		}
	}
}

int main()
{
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



Measured memory_bytes: 15456
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

n = inp()
x = [0]*(n+1)
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            t = i*i + j*j + k*k + i*j + j*k + i*k
            if t <= n:
                x[t] += 1
            else:
                break
for i in range(1,n+1):
    print(x[i])

Measured memory_bytes: 69616
#include <stdio.h>
#include <math.h>
#define N 200000

int main(){
  int n,i,j,minv,maxv,R[N];

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&R[i]);
  minv=R[0];
  maxv=pow(10,9)*(-1);
  for(j=1;j<n;j++){
    if(maxv<R[j]-minv)
      maxv=R[j]-minv;
    if(minv>R[j])
      minv=R[j];
  }
  printf("%d\n",maxv);
  return 0;
}

Measured memory_bytes: 1376
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

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

	int n, x;
	cin >> n >> x;
	int cd = 0;
	int cans = 1;
	while (n--) {
		int f;
		cin >> f;
		cd += f;
		if (cd <= x) cans++;
	} 
	cout << cans << endl;
}


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

int main(){
    ll x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    rep(i, 0, x) cin >> a[i];
    rep(i, 0, y) cin >> b[i];
    rep(i, 0, z) cin >> c[i];
    vector<ll> d(x*y);
    rep(i, 0, x){
        rep(j, 0, y){
            d[i*y + j] = a[i] + b[j];
        }
    }
    sort(d.begin(), d.end(), greater<ll>());
    vector<ll> e(min(x*y,k)*z);
    rep(i, 0, min(x*y,k)){
        rep(j, 0, z){
            e[i*z+j] = d[i] + c[j];
        }
    }
    sort(e.begin(), e.end(), greater<ll>());
    rep(i, 0, k) cout << e[i] << "\n";
    return 0;
}

Measured memory_bytes: 31616
N = int(input())
xyd = [list(input().split()) for _ in range(N)]

def nasu(s, e, f, n, inf):
  L = [0] * 3
  a, b, c = inf, inf, inf
  for i in range(N):
    t = int(xyd[i][n])
    if xyd[i][2] == s:
      a = f(a, t)
    elif xyd[i][2] == e:
      b = f(b, t)
    else:
      c = f(c, t)
  L[0] = a
  if f(a, c) == a:
    L[1] = abs(a - c)
  else:
    L[0], L[1] = c, 0
  if f(L[0], b) != b:
    if f(c, b) == c:
      L[2] = abs(b - c)
      if L[1] > L[2]:
        L[2] = abs(a - b) / 2
        L[1] = L[2]
    else:
      L[2] = abs(a - b) / 2
      L[1] = L[2]
  else:
    L = [b, 0, 0]
  for i in range(3):
    if abs(L[i]) > abs(inf) / 2:
      L[i] = abs(inf)
  return L

inf = 10 ** 10
R = nasu("L", "R", max, 0, -inf)
L = nasu("R", "L", min, 0, inf)
U = nasu("D", "U", max, 1, -inf)
D = nasu("U", "D", min, 1, inf)

def honya(x):
  r = honyaraka(R, x, 1)
  l = honyaraka(L, x, -1)
  u = honyaraka(U, x, 1)
  d = honyaraka(D, x, -1)
  return abs(r - l) * abs(u - d)

def honyaraka(X, x, f):
  a, b, c = X
  if x <= b:
    return a + x * f * -1
  if x < c:
    return a + b * f * -1
  return a + b * f * -1 + (x - c) * f

ans = honya(0)
T = [R, L, U, D]
for i in range(4):
  for j in range(1, 3):
    x = T[i][j]
    if x != inf:
      ans = min(ans, honya(x))

print(ans)


Measured memory_bytes: 29044
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define endl '\n'

using namespace std;

main()
{
  fast;
  int h,a,b;
  cin>>a;
  cin>>b;
  cin>>h;
  cout<<(h/2)*(a+b)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int sdkys(int a,int b){
    if(b==0) return a;
    return sdkys(b,a%b);
}
int sskbs(int a,int b){
    return a*b/sdkys(a,b);
}
int n,m,cnt=0,aa[220000],ans=0,ab[220000];
pair<int,int> pp[220000];
string s,sa[220000];
char ca[220000];
queue<int> que;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>aa[i];
    }
    rep(i,n){
        cin>>ab[i];
    }
    rep(i,n){
        ans=0;
        rep(j,i+1){
            ans+=aa[j];
        }
        rep(j,n-i){
            ans+=ab[j+i];
        }
        cnt=max(cnt,ans);
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 10436
import sys
n=int(input())
a=list(map(int,input().split()))

cnt=0
while(1):
    for i in range(n):
        if a[i]%2==1:
            print(cnt)
            sys.exit(0)
    cnt += 1
    a=list(map(lambda x : int(x/2) , a))

Measured memory_bytes: 3060
/*================================================================
*   Copyright (C) 2019 Sangfor Ltd. All rights reserved.
*
*   创 建 者： badcw
*   创建日期： 2020/1/26
*
================================================================*/
#include <bits/stdc++.h>

#define ll long long
using namespace std;

const int maxn = 2e4+50;
const int mod = 1e9+7;
ll qp(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template <class T>
inline bool scan(T& ret) {
    char c;
    int sgn;
    if (c = getchar(), c == EOF) return 0; // EOF
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
    ret *= sgn;
    return 1;
}

//template <class T>
//inline void out(T x) {
//    if (x > 9) out(x / 10);
//    putchar(x % 10 + '0');
//}

int dp[maxn];
int h, n;
struct node {
    int val, cost;
}p[1005];

int main(int argc, char* argv[]) {
    scanf("%d%d", &h, &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d%d", &p[i].cost, &p[i].val);
    }
    memset(dp, 0x3f, sizeof dp);
    dp[0] = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = p[i].cost; j <= h + 10000; ++j) {
            dp[j] = min(dp[j], dp[j - p[i].cost] + p[i].val);
        }
    }
    int res = dp[h];
    for (int i = h; i <= h + 10000; ++i) {
        res = min(res, dp[i]);
    }
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int Solve(int, int);

int main(){
  int n, m;
  scanf("%d %d", &n, &m);
  if(Solve(n, m) == -1) printf("-1\n");
  return 0;
}

int Solve(int n, int m){
  if(n/2 < m) return -1;

  int i, j, k;
  for(i=1; i<=m; ++i){
    j = i;
    k = i;
    while(1){
      ++j;
      if(j > n) j -= n;
      if(j == k) break;
      printf("%d %d\n", k, j);
      --k;
      if(k < 1) k += n;
      if(j == k) break;
      printf("%d %d\n", j, k);
    }
    if(i == m) return 0;
    printf("\n");
  }
}

Measured memory_bytes: 600
import java.util.Scanner;

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

        while (sc.hasNext()) {
            String s = sc.next();
            char[] t = s.toCharArray();
            int ansA = -1;
            int ansB = -1;

            for (int i = 0; i < t.length; i++) {
                if ( i < t.length - 1 ) {
                    if ( t[i] == t[i + 1] ) {
                        ansA = i + 1;
                        ansB = i + 2;
                    }
                }
                if ( i < t.length - 2 ) {
                    if ( t[i] == t[i + 1] || t[i] == t[i + 2] || t[i + 1] == t[i + 2] ) {
                        ansA = i + 1;
                        ansB = i + 3;
                    }
                }
            }
            System.out.println(ansA + " " + ansB);
        }
    }
}


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


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

  char a;
  cin >> a;

  if(isupper(a)) {
    cout << "A" << endl;
  }

  else if(islower(a)) {
    cout << "a" << endl;
  }
  return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n; cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    rep(i,n-1){
        rng(j,i+1,n){
            ans += a[i]*a[j];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a;
    int count=0;
    std::deque<int> deq;
    while (cin>>n) {
        if (n==0) {
            break;
        } else {
            for (int i=0;i<n;i++) {
                cin>>a;
                deq.emplace_back(a);
            }
            for (int j=0;j<n;j++) {
                for (int k=0;k<n-1;k++) {
                    if (deq[k]>deq[k+1]) {
                        swap(deq[k],deq[k+1]);
                        count++;
                    }
                }
            }
            cout<<count<<endl;
            count=0;
            deq.clear();
        }
    }
}



Measured memory_bytes: 3108
def dot(x, y):
    return (x.conjugate() * y).real
    
def project(p, d):
    return dot(p, d) / abs(d)

def line_sym(p, x1, x2):
    p -= x1
    d = x2 -x1
    return d * p.conjugate() / d.conjugate() + x1

import sys

p = []
for line in sys.stdin:
    x1, y1, x2, y2, xq, yq = map(float, line.split(','))
    p1 = complex(x1, y1)
    p2 = complex(x2, y2)
    q = complex(xq, yq)
    
    r = line_sym(q, p1, p2)
    
    print(r.real, r.imag)

Measured memory_bytes: 7588
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n string
	_, _ = fmt.Scan(&n)

	fmt.Println(answer162A02(n))
}

func answer162A02(n string) string {
	if strings.Contains(n, "7") {
		return "Yes"
	}
	return "No"
}

Measured memory_bytes: 1836
from collections import deque

k = int(input())

count = 1
d= deque([1,2,3,4,5,6,7,8,9])
#ls = []
while count <= k:
    v = d.popleft()
    count += 1
    last = str(v)[-1]
    if last == '0':
        d.append(int(str(v) + '0'))
        d.append(int(str(v)+'1'))
    elif last == '9':
        d.append(int(str(v) + '8'))
        d.append(int(str(v) + '9'))
    else:
        d.append(int(str(v) + str(int(last) - 1)))
        d.append(int(str(v) + str(int(last) )))
        d.append(int(str(v) + str(int(last) + 1)))
    #ls.append(v)

#print(ls)
print(v)

Measured memory_bytes: 16852
#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__


def main():
    n = int(input())
    d = [int(di) for di in input().split()]
    d.sort()

    n >>= 1
    x = d[n] - d[n - 1]
    print(x)


# region fastio

BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 44140
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define pdd pair<double,double>
using namespace std;
string sex,tsex;
string query(int x)
{
    string s;
    cout<<x<<endl;
    fflush(stdout);
    cin>>s;
    return s;
}
int main(){
    int N;
    scanf("%d",&N);
    sex=query(0);
    bool suc=(sex[0]=='V');
    int l=0,r=N-1;
    while(!suc)
    {
        int mid=ceil((l+r)/2.0);
        tsex=query(mid);
        if(tsex[0]=='V')suc=true;
        int las=mid-l;
        //printf("!%d\n",las);
        if(las%2==0)
        {
            //cout<<tsex<<" "<<sex<<endl;
            if(tsex[0]!=sex[0])r=mid-1;
            else
            {
                l=mid;
                sex=tsex;
            }
        }
        else
        {
            if(tsex[0]==sex[0])r=mid-1;
            else
            {
                l=mid;
                sex=tsex;
            }
        }

    }
    return 0;
}
/*
1 1 2 2
2
2 0 1
1 1 1
*/


Measured memory_bytes: 876
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=1e5+10;
int fa[maxn];
inline int getfa(int x){return fa[x]==x?x:fa[x]=getfa(fa[x]);}
int u[maxn],v[maxn],tp[maxn];
inline bool Union(int x,int y)
{
	x=getfa(x),y=getfa(y);
	if(x==y)return 0;
	fa[x]=y;
	return 1;
}
int main()
{
	int n,q;
	ll m;
	bool f=0;
	scanf("%d%lld%d",&n,&m,&q);
	for(int i=0;i<n;i++)
		fa[i]=i;
	for(int i=0;i<q;i++)
	{
		scanf("%d%d%d",&u[i],&v[i],&tp[i]);
		if(!tp[i])Union(u[i],v[i]);
		if(tp[i])f=1;
	}
	if(m==n-1&&f)
	{
		printf("No\n");
		return 0;
	}
	for(int i=0;i<q;i++)
	{
		if(tp[i]&&getfa(u[i])==getfa(v[i]))
		{
			printf("No\n");
			return 0;
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++)
		if(getfa(i)==i)cnt++;//cout<<i<<" "<<getfa(i)<<endl;
	if(f==1&&cnt<=2)
	{
		printf("No\n");
		return 0;
	}
	ll mx=cnt*1ll*(cnt-1)/2ll+(n-cnt);
/*	set<int> st;
	st.clear();
	for(int i=0;i<q;i++)
	{
		if(tp[i])
		{
			st.insert(getfa(u[i]));
			st.insert(getfa(v[i]));
		}
	}*/
	if(mx>=m)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<vector<pair<int,int>>> G(N);
  F0R(i, N - 1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].emplace_back(b, i);
    G[b].emplace_back(a, i);
  }

  i64 K = 1;
  vector<int> cs(N-1);
  auto dfs = [&](auto dfs, int v, int pc, int p = -1)->void {

    int cl = 1;
    for (auto e : G[v]) {
      if (e.first == p) continue;
      if (cl == pc) cl++;

      cs[e.second] = cl;
      chmax(K, cl);
      dfs(dfs, e.first, cl, v);

      cl++;
    }
  };
  dfs(dfs, 0, 0);

  cout << K << newl;
  F0R(i, cs.size()) {
    cout << cs[i] << newl;
  }
}
#endif


Measured memory_bytes: 6912
import heapq

x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

cnt = 0
q = []
arg = (0, 0, 0)
visited = {}
visited[arg] = True
heapq.heappush(q, (-(a[arg[0]] + b[arg[1]] + c[arg[2]]),) + arg)

while cnt < k:
    score, ia, ib, ic = heapq.heappop(q)
    print(-score)
    cnt += 1
    arg_a = (ia + 1, ib, ic)
    arg_b = (ia, ib + 1, ic)
    arg_c = (ia, ib, ic + 1)
    if arg_a[0] <= x - 1 and arg_a not in visited:
        heapq.heappush(
            q, (-(a[arg_a[0]] + b[arg_a[1]] + c[arg_a[2]]),) + arg_a)
        visited[arg_a] = True
    if arg_b[1] <= y - 1 and arg_b not in visited:
        heapq.heappush(
            q, (-(a[arg_b[0]] + b[arg_b[1]] + c[arg_b[2]]),) + arg_b)
        visited[arg_b] = True
    if arg_c[2] <= z - 1 and arg_c not in visited:
        heapq.heappush(
            q, (-(a[arg_c[0]] + b[arg_c[1]] + c[arg_c[2]]),) + arg_c)
        visited[arg_c] = True


Measured memory_bytes: 4768
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

const M: usize = 1_000_000_007usize;

#[fastout]
fn main() {
    input! {
        s: usize
    }

    let mut dp = vec![0usize; s + 1];
    dp[0] = 1;
    for i in 3..=s {
        dp[i] = dp[i-1] + dp[i-3];
        dp[i] %= M;
    }
    let ans = dp[s];
    println!("{}", ans);
}


Measured memory_bytes: 2196
a=input()
n=int(str(a)[len(str(a))-1])
if n==2 or n==4 or n==5 or n==7 or n==9:
    print("hon")
elif n==0 or n==1 or n==6 or n==8:
    print("pon")
else:
    print("bon")

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#include <math.h>
#define ll long long
using namespace std;

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


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm> // sort


#define ll long long

using namespace std;

int main(){
    int N,M;
    ll res;

    cin >> N >> M;
    
    vector <pair<ll,ll>> p(N);
    //金,在庫

    for(int i = 0; i < N; i++)
    {
        cin >> p[i].first >> p[i].second; 
    }

    sort(p.begin(),p.end());

    int zan = M;
    res = 0;
    for(int i = 0; i < N; i++)
    {
        if (zan <= p[i].second){
            res += p[i].first * zan;
            break;        
        }

        res += p[i].first * p[i].second;
        zan -= p[i].second;
    }

    cout << res << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    string s;
    cin >> s;
    vector<int> dp(1 << 26, inf);
    vector<int> C(s.size() + 1);
    C[0] = 0;
    rep(i, s.size()){
        C[i + 1] = C[i] ^ (1 << (s[i] - 'a'));
    }
    dp[0] = 0;
    rep(i, 1, s.size() + 1){
        int tmp = dp[C[i]] + 1;
        rep(j, 26){
            int c = C[i] ^ (1 << j);
            tmp = min(tmp, dp[c] + 1);
        }
        if(i == s.size()) output(tmp);
        dp[C[i]] = min(dp[C[i]], tmp);
    }
    
    return 0;
}


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

#define pi 3.1415926535
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ll long long
#define llu unsigned long long
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define tc int test_case; cin >> test_case; while(test_case--)
#define f(i,a,n) for(int i = a ; i < n ; i++)
#define rf(i,n,a) for(int i = n-1 ; i >= a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define get(a,n) f(i,0,n) cin >> a[i];
#define show(a,n) f(i,0,n) cout << a[i] << " "; cout << endl;
#define fast ios:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trace(x) cout << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cout<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"

typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;

const int inf = 1e9;
const ll inf64 = 1e18;
const int mod = inf + 7;
const int N = 2e5 + 10;

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

    string s;
    map<string,int> m;
    while(n--)
    {
        cin >> s;
        m[s]++;
    }

//    if(m["AC"] == 0)
        cout << "AC" << " x " << m["AC"] << endl;
 //   if(m["WA"] == 0)
        cout << "WA" << " x " << m["WA"] << endl;
   // if(m["TLE"] == 0)
        cout << "TLE" << " x " << m["TLE"] << endl;
   // if(m["RE"] == 0)
        cout << "RE" << " x " << m["RE"] << endl;

}




Measured memory_bytes: 3628
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  int n, k;
  cin >> n >> k;
  cout << (n+1 < k * 2 ? "NO" : "YES") << endl;
  return 0;
}


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

string s1 = "dream";
string s2 = "dreamer";
string s3 = "erase";
string s4 = "eraser";

bool judgment_dream(string &S, int &n) {
  string s1 = "dream";
  bool result = true;
  for (int i = 0; i < s1.size(); i++) {
    if (n - i >= 0) {
      if (S.at(n - i) != s1.at(s1.size() - i - 1)) {
        result = false;
        break;
      }
    }
    else {
      result = false;
    }
  }
  if (result == true) {
    n -= s1.size();
  }
  return result;
}

bool judgment_dreamer(string &S, int &n) {
  string s1 = "dreamer";
  bool result = true;
  for (int i = 0; i < s1.size(); i++) {
    if (n - i >= 0) {
      if (S.at(n - i) != s1.at(s1.size() - i - 1)) {
        result = false;
        break;
      }
    }
    else {
      result = false;
    }
  }
  if (result == true) {
    n -= s1.size();
  }
  return result;
}

bool judgment_erase(string &S, int &n) {
  string s1 = "erase";
  bool result = true;
  for (int i = 0; i < s1.size(); i++) {
    if (n - i >= 0) {
      if (S.at(n - i) != s1.at(s1.size() - i - 1)) {
        result = false;
        break;
      }
    }
    else {
      result = false;
    }
  }
  if (result == true) {
    n -= s1.size();
  }
  return result;
}

bool judgment_eraser(string &S, int &n) {
  string s1 = "eraser";
  bool result = true;
  for (int i = 0; i < s1.size(); i++) {
    if (n - i >= 0) {
      if (S.at(n - i) != s1.at(s1.size() - i - 1)) {
        result = false;
        break;
      }
    }
    else {
      result = false;
    }
  }
  if (result == true) {
    n -= s1.size();
  }
  return result;
}

int main() {
  string S;
  cin >> S;
  int n = S.size();
  n--;
  bool result = true;
  
  while (n > 0 && result == true) {
    if (judgment_dream(S, n)) {
    }
    else if (judgment_dreamer(S, n)) {
    }
    else if (judgment_erase(S, n)) {
    }
    else if (judgment_eraser(S, n)) {
    }
    else {
      result = false;
    }
  }
  if (result) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int R, G;
	cin >> R >> G;

	cout << R + (G - R) * 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n, m;
  cin >> n;
  vector<string> s(n);
  REP(i, n) {
    cin >> s[i];
  }
  cin >> m;
  vector<string> t(m);
  REP(i, m) {
    cin >> t[i];
  }
  int ret = -100000;
  REP(i, n) {
    int cnt = 0;
    REP(j, n) {
      if (s[i] == s[j]) {
	cnt++;
      }
    }
    REP(j, m) {
      if (s[i] == t[j]) {
	cnt--;
      }
    }
    if (ret < cnt) {
      ret = cnt;
    }
  }
  if (ret < 0) {
    dump(0);
  }
  else  {
    dump(ret);
  }
  return 0;
}


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

int main()
{
    int n, r;
    cin >> n >> r;
    if(n>=10)
        cout << r << endl;
    else
        cout << r + 100*(10-n) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.security.KeyStore.TrustedCertificateEntry
import java.util
import java.util.regex.Pattern
import java.util.{ArrayList, Collections, Comparator, List => JList}

import scala.collection.immutable.TreeMap
import scala.math._
import scala.collection.mutable
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.util.{Failure, Success, Try}

object Main{
  val LINE_SEPARATOR = "\n"
  def main(args: Array[String]): Unit = {
    if (sys.env.getOrElse("TEST", "")=="1"){
      println(test());
    }else{
      val input=io.Source.stdin.getLines().mkString(LINE_SEPARATOR);
      println(solve(input).trim());
    }
  }

  def init (nRows: Int, nCols: Int, default: Int) = Array.tabulate(nRows,nCols)( (x,y) =>  default)

  def sortIgnoreCase1(list: JList[String]): JList[String] = {
    val r = new ArrayList[String](list)
    Collections.sort(r, new Comparator[String] {
      override def compare(o1: String, o2: String): Int = o1.compareToIgnoreCase(o2)
    })
    r
  }

  def solve(input: String): String = {
    val x = input.split(" ").map(_.toInt)
    var res = 0
    (1 to 5).foreach{i =>
      if (x(i - 1) != i) res = i
    }
    res.toString
  }

  def medianCalculator(seq: Seq[Long]): Long = {
    //In order if you are not sure that 'seq' is sorted
    val sortedSeq = seq.sortWith(_ < _)

    if (seq.size % 2 == 1) sortedSeq(sortedSeq.size / 2)
    else {
      val (up, down) = sortedSeq.splitAt(seq.size / 2)
      (up.last + down.head) / 2
    }
  }

  def factorize(x: Long): List[Long] = {
    def foo(x: Long, a: Long = 2, list: List[Long] = Nil): List[Long] = a*a > x match {
      case false if x % a == 0 => foo(x / a, a    , a :: list)
      case false               => foo(x    , a + 1, list)
      case true                => x :: list
    }
    foo(x)
  }

  def divisors(n: Long): Vector[Long] = {
    val halfList = (1 to sqrt(n).toInt).toVector.filter(_ % n == 0).map(_.toLong)
    val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)
    halfList ++ reversedList
  }

  def gcd(m: Long, n: Long): Long = n match {
    case 0 => m
    case _ => gcd(n, m % n)
  }
  def lcm(a: Long, b: Long): Long = a * b / gcd(a, b)

  val tests=List(
    """0 2 3 4 5""".stripMargin -> """1
                                     |
                                   |
                                   |""".stripMargin,
    """1 2 0 4 5""".stripMargin -> """3""".stripMargin
  )

  def test():String= {
    return tests.map{case (i,o)=>(i.trim(),o.trim())}
      .zipWithIndex.map{
      case ((input,outputExpect),i)=>{
        val output=solve(input).trim();
        s"test${i+1}:"+(if(output==outputExpect){
          "Passed"
        }else{
          s"Failed\nexpect:\n${outputExpect}\noutput:\n${output}"
        })
      }}
      .mkString("\n");
  }
}


Measured memory_bytes: 55000
# -*- coding: utf-8 -*-
import math
# 整数の入力
n = int(input())
s = 0
for i in range(1, n + 1):
    for j in range(i, n + 1):
        for k in range(j, n + 1):
            gcd = math.gcd(math.gcd(i, j),k)
            if i == j and j == k:
                s += gcd
            elif i == j or j == k or k ==i:
                s += gcd * 3
            else:
                s += gcd * 6
# for i in range(1, n + 1):
#     for j in range(1, n + 1):
#         for k in range(1, n + 1):
#             gcd = math.gcd(math.gcd(i, j),k)
#             s += gcd
print(s)

Measured memory_bytes: 9184
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
bool compare(const pair<int*,int> a,const pair<int*,int> b){
	return *a.first>*b.first;
}
int main(){
	int check[26];
	pair<int*,int> line[26];
	for(int i=0;i<26;++i){
		line[i].first=check+i;
		line[i].second=i;
	}
	int n;
	bool ok;
	string str;
	while(cin>>n&&n!=0){
		ok=true;
		for(int i=0;i<26;++i){
			check[i]=0;
		}
		getline(cin,str);
		getline(cin,str);
		for(int i=0;i<n;++i){
			++check[str[i*2]-'A'];
			sort(line,line+26,compare);
			if(*line[0].first-*line[1].first>=n-i){
				cout<<(char)(line[0].second+'A')<<' '<<i+1<<endl;
				ok=false;
				break;
			}
		}
		if(ok){
			cout<<"TIE"<<endl;
		}
	}
	return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 100

i64 L[MAX_N + 1];


int main() {
  i64 N, X;
  cin >> N >> X;

  REPS(i, N) {
    cin >> L[i];
  }

  i64 x;
  i64 cnt = 0;
  REPS(i, N+1) {
    if (i == 1) {
      x = 0;
    } else {
      x += L[i-1];
    }

    if (x <= X) {
      cnt++;
    } else break;
  }

  cout << cnt << endl;

  return 0;
}

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

int main() {
	int t,i,ans[5];
	cin >> t;
	for (i = 2; i >= 0; i--) {
		ans[i] = t / int(pow(60, i));
		t %= int(pow(60, i));
	}
	cout << ans[2] << ":" << ans[1] << ":" << ans[0] << endl;

	return 0;
}


Measured memory_bytes: 3280