akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define NTL -1
#define M 25
typedef struct tree{
  int p;
  int l;
  int r;
}tree;
int depth(int,tree *);
int hei(int,tree *);
int sib(int,tree *);
int deg(int, tree *);
int type(int,tree *);
int h[M];
int main(){
  int n,i,j,now,chi,bchi,num;
  /*scan n*/
  scanf("%d",&n);
  tree t[n];
  /*NTL*/
  for(i=0;i<n;i++){
    t[i].p=NTL;
  }
  /*scan tree*/
  for(i=0;i<n;i++){
    scanf("%d",&now);
    scanf("%d %d",&t[now].l,&t[now].r);
    if(t[now].l!=NTL) t[t[now].l].p=now;
    if(t[now].r!=NTL) t[t[now].r].p=now;
  }
  /* print*/
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, ",i,t[i].p,sib(i,t));
    printf("degree = %d, depth = %d, height = %d, ",deg(i,t),depth(i,t),hei(i,t) );
    if(type(i,t) == 1){
      printf("root\n");
    }
    else if(type(i,t) == 2){
      printf("internal node\n");
    }
    else if(type(i,t) == 3)printf("leaf\n");
  }
  return 0;
}
int depth(int num,tree *t){
  int d=0;
  while(t[num].p != NTL){
    d++;
    num = t[num].p;
  }
  return d;
}
int hei(int now,tree *t){
  int hl=0;
  int hr=0;
  if(t[now].l!=-1) hl=hei(t[now].l,t)+1;
  if(t[now].r!=-1) hr=hei(t[now].r,t)+1;
  if(hl>hr) h[now]=hl;
  else h[now]=hr;
  return h[now];
}

int sib(int now,tree *t){
  if(t[now].p==-1) return -1;
  if(t[t[now].p].l!=now && t[t[now].p].l!=-1){
    return t[t[now].p].l;
  }
  else if(t[t[now].p].r!=now && t[t[now].p].r!=-1){
    return t[t[now].p].r;
  }
  else return -1;
}

int deg(int now,tree *t){
  int deg=0;
  if(t[now].l!=-1){
    deg++;
  }
  if(t[now].r!=-1){
    deg++;
  }
  return deg;
}
int type(int num,tree *t){
  if(t[num].p == NTL) return 1;/*root*/
  else if(t[num].l != NTL || t[num].r != NTL) return 2;/*internal*/
  else if(t[num].l == NTL && t[num].r == NTL) return 3;/*leaf*/
  return 3;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n;
  cin >> n;
  vi x(n);
  rep(i,n) cin >> x[i];
  vi y = x;
  sort(y.begin(), y.end());
  rep(i,n) printf("%d\n", x[i]<y[n/2]?y[n/2]:y[n/2-1]);
  return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int m, k;
    cin >> m >> k;

    if(k == 0){
        rep(i, 1 << m){
            cout << i << " " << i << " ";
        }
        cout << endl;
        return 0;
    }

    int maxi = 0;
    rep(i, 31){
        if(k >> i & 1){
            maxi = max(maxi, i);
        }
    }

    if(maxi >= m){
        cout << -1 << endl;
        return 0;
    }

    vector< P > v;
    rep(i, 1 << m){
        if((i == k) || (i ^ k) == k){
            continue;
        }
        if(i < (i ^ k)){
            v.emplace_back(i, i ^ k);
        }
    }

    if(v.empty()){
        cout << -1 << endl;
        return 0;
    }

    vector<int> ans(1 << (m + 1));
    ans[1 << m] = v[0].first;
    ans[(1 << m) - 1] = v[0].second;
    ans[(1 << m) + 1] = 0;
    ans[(1 << m) - 2] = 0;
    ans[(1 << m) + 2] = k;
    ans[(1 << m) - 3] = k;
    ans[(1 << m) + 3] = v[0].first;
    ans[(1 << m) - 4] = v[0].second;

    int j = 1;
    for(int i = (1 << m) + 4 ; i < (1 << (m + 1)) ; i += 4){
        if(j + 1 >= (int)v.size()){
            cout << -1 << endl;
            return 0;
        }
        ans[i] = v[j].first;
        ans[i + 1] = v[j + 1].first;
        ans[i + 2] = v[j + 1].second;
        ans[i + 3] = v[j].first;
        int l = (1 << (m + 1)) + ~i;
        ans[l] = v[j].second;
        ans[l - 1] = v[j + 1].first;
        ans[l - 2] = v[j + 1].second;
        ans[l - 3] = v[j].second;
        j += 2;
    }

    rep(i, 1 << (m + 1)){
        cout << ans[i] << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3448
#!/usr/bin/env python3
import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)
 
 
H, W, h, w = map(int, input().split())
yes, no = "Yes", "No"
 
if (H%h == 0) and (W%w == 0):
    print(no)
    exit()
 
print(yes)
 
unit = 1000
if (W%w != 0):
    for i in range(H):
        # l_ = [str(unit)] * (w-1)
        # l_ += [str(-unit*(w-1)-1)]
        # l = l_ * (W//w)
        # l += [str(unit)] * (W%w)
        l = []
        for j in range(W):
            if j % w == w-1:
                l.append(str(-unit*(w-1)-1))
            else:
                l.append(str(unit))
        print(" ".join(l))
    exit()
if (H%h != 0):
    for i in range(H):
        if i%h == h-1:
            l = [str(-unit*(h-1)-1)] * W
        else:
            l = [str(unit)] * W
        print(" ".join(l))
    exit()
raise Exception("hogeeee")

Measured memory_bytes: 43612
import math

N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

tr = [A,B,C,D,E]
ls = []

for i in range(0,5):
    ls.append([tr[i],i])

m = min(ls)[0]
i = min(ls)[1]

print(math.ceil(N/m)+4)


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  string S;
  cin >> S;
  bool e, w, s, n;
  e = false;
  w = false;
  s = false;
  n = false;
  int l = S.length();
  REP(i, l) {
    if (S.at(i) == 'E') {
      e = true;
    } else if (S.at(i) == 'W') {
      w = true;
    } else if (S.at(i) == 'S') {
      s = true;
    } else {
      n = true;
    }
  }

  if (((e && w) || (!e && !w)) && ((n && s) || (!n && !s))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v),end()
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;

template<typename A,typename B> inline void chmin(A &a,B b){if(a>b) a=b;}
template<typename A,typename B> inline void chmax(A &a,B b){if(a<b) a=b;}
//-----------------------------------------------------------------------

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

    while(true)
    {
        int x,y,s;
        cin>>x>>y>>s;
        if(x+y+s==0) break;

        int ans=0;
        for(int i=1;i<=s/2;i++)
        {   
            int a=(100*i+99)/(100+x);
            int b=(100*(s-i)+99)/(100+x);
            if(a*(100+x)/100+b*(100+x)/100!=s) continue;
            chmax(ans,a*(100+y)/100+b*(100+y)/100);
        }
        cout<<ans<<endl;
    }   
}

Measured memory_bytes: 3144
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    Map<String, Integer> map = new HashMap<>();
    int max = 0;
    for (int i = 0; i < n; i++) {
      String t = in.next();
      map.put(t, map.get(t) == null ? 1 : map.get(t) + 1);
      max = Math.max(max, map.get(t));
    }
    List<String> list = new ArrayList<>();
    for (Map.Entry<String, Integer> entry : map.entrySet()) {
      if (entry.getValue() == max) {
        list.add(entry.getKey());
      }
    }
    Collections.sort(list);
    for (String e : list) {
      System.out.println(e);
    }
  }
}


Measured memory_bytes: 82484
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int k = parseInt(sc.next());
		char[] s = sc.next().toCharArray();
		sc.close();
		int m = n;
		int cnt=0;
		for (i = 0; i < s.length-1; i++) {
			if(s[i] == 'R' && s[i+1] == 'L') {
				cnt++;
				i++;
			}
		}
		if(s[n-1] == 'R') {
			cnt++;
			m++;
		}
		if(s[0] == 'L') {
			cnt++;
			m++;
		}
		out.println(Math.min(n-1,m-2*(cnt-k)));
	}
}


Measured memory_bytes: 28900
#include <bits/stdc++.h>
using namespace std;
int main (){
	int n, s, sum =0;
	vector <int> punt;
	cin >>n;
	
	for (int i=0;i<n;i++){
		cin >>s;
		punt.push_back(s);
		sum += s;
	}
	
	if (sum % 10 != 0) {
		cout << sum;
		return 0;
	}
	else {
		int min = 101;
		bool gaa = false;
		for (int i=0;i<n;i++){
			if (punt[i] % 10 != 0 && punt[i] < min) {
				min = punt[i];
				gaa = true;
			}
		} 
		if (gaa == false) cout << "0";
		else cout << sum - min;
	}
	
	return 0;
}

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

int main() {
  int A, B, c=0, a;
  cin >> A >> B;
  a=A;
  
  for (int i = 0; i < (B-A+1); i++) {
    for (int j = 0; j < 3; j++) {
      if(j==2){
        c += 1;
        break;
      }else if(j==1){
        if(((a / 1000) % 10) != ((a / 10) % 10))
          break;
      }else{
        if((a / 10000) != (a % 10))
          break;
      }
    }
    a++;
  }
  
  cout << c << endl;

}


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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll d;
    cin >> d;
    cout << "Christmas";
    frep(i, d, 24) {
        cout << " Eve";
    } 
    cout << endl;

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
typedef long long ll;
ll mod_pow(ll, ll, ll);
ll mod_fact(ll, ll);
ll mod_inv(ll, ll);
//
int main(){
    int n, y;
    cin >> n >> y;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n - i; j++){
            if(i * 10000 + j * 5000 + (n - i - j) * 1000 == y){
                cout << i << " " << j << " " << n - i - j;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1";
}

Measured memory_bytes: 256
using System;

namespace Application
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split();
            var a = int.Parse(ab[0]);
            var b = int.Parse(ab[1]);

            if (a < 10 && b < 10) Console.WriteLine(a * b);
            else Console.WriteLine(-1);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <memory>

//#define int long long

using namespace std;

void Main()
{
	int x, a;
	cin >> x >> a;

	if (x < a) {
		cout << 0 << endl;
		return;
	}
	cout << 10 << endl;
}

int32_t main()
{
	Main();
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		boolean ans = false;
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String s1 = String.valueOf(a);
		String s2 = String.valueOf(b);
		double n = Integer.parseInt(s1 + s2);
		int h = (int)Math.sqrt(n);
		if(Math.sqrt(n) == h) {
			System.out.println("Yes");
		}
		else System.out.println("No");
		sc.close();
	}

}


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

int main()
{
	int a,b,c,d,l,r;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	l = a + b;
	r = c + d;
	if(l > r) printf("Left\n");
	if(l < r) printf("Right\n");
	if(l == r) printf("Balanced\n");
}

Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n;
ll a[MAXN], s[MAXN];
ll MOD = MODBASE;

ll binPowMod(ll a, ll b) {
    a %= MOD;
    ll res = 1;
    while (b > 0) {
        if (b & 1LL) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1LL;
    }
    return res;
}

ll add(ll a, ll b) {
    return (a + b) % MOD;
}

ll sub(ll a, ll b) {
    return (a - b + MOD) % MOD;
}

ll mul(ll a, ll b) {
    return a * b % MOD;
}

ll get(int l, int r) {
    return sub(s[r], s[l-1]);
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    FOR(i,1,n) s[i] = add(s[i-1], a[i]);
    ll res = 0;
    FOR(i,1,n-1) res = add(res, mul(a[i], get(i+1, n)));
    cout << res;
    return 0;
}


Measured memory_bytes: 6764
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n;
        String ans = "No";

        n = sc.nextInt();
        
        if((n % 10 == 7) || ((n % 100 >= 70) && (n % 100 <= 79)) || ((n % 1000 >= 700) && (n % 1000 <= 799))){
            ans = "Yes";
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 35708
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int digitsum(ll A){
    int n = 0;
    while(A > 0){
        n += A % 10;
        A /= 10;
    }

    return n;
}

int main(){
    ll N;
    int A,B,digisum,goukei = 0;
    cin >> N >> A >> B;

    for(ll i = 1;i <= N;i++){
        digisum = digitsum(i);
        if(digisum >= A and digisum <= B)
            goukei += i;
    }

    cout << goukei << endl;

}

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

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

#define pb push_back

const int INF = 100100100;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

int dp[44];

ll f( int n){

  if( dp[n] ) return dp[n];
  else dp[n] = f(n-1)+f(n-2);
  
  return dp[n];
}

int main(){

  int x;
  REP( i, 44){
    dp[i] = 0;
  }

  dp[0] = 1;
  dp[1] = 1;

  cin >> x;
  cout << f(x) << endl;

}

Measured memory_bytes: 3116
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define mdn 1000000007
#define N 100010
using namespace std;
int pre[N],suf[N],fac[N],inv[N],n,a[N];
int ksm(int bs,int mi)
{
	int ans=1;
	while(mi)
	{
		if(mi&1)	ans=1ll*ans*bs%mdn;
		bs=1ll*bs*bs%mdn; mi>>=1;
	}
	return ans;
}
int C(int n,int m)
{
	if(n<m)	return 0;
	return 1ll*fac[n]*inv[m]%mdn*inv[n-m]%mdn;
}
int main()
{
	scanf("%d",&n); fac[0]=inv[0]=1;
	for(int i=1;i<=n;i++)	scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)	fac[i]=1ll*fac[i-1]*i%mdn;
	inv[n]=ksm(fac[n],mdn-2);
	for(int i=n-1;i;i--)	inv[i]=1ll*inv[i+1]*(i+1)%mdn;
	for(int i=0;i<n;i++)
	{
		pre[i]=1ll*fac[n-i-1]*C(n,i+1)%mdn*fac[i]%mdn;
		if(i)	pre[i]=((ll)pre[i]+pre[i-1])%mdn;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int tmp=((ll)pre[i-1]+pre[n-i]-pre[0]+mdn)%mdn;
		ans=((ll)ans+1ll*tmp*a[i]%mdn)%mdn;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
// ------------------------------------
// Date:2018/ 3/17
// Problem:C- Big Array b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
static const int MOD = 1000000007;
static const int MAX_N = 1;

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

  LCIN(N, K);
  vector< pair< ll, ll > > a(N);
  REP(i, N) {
    CIN(p, q);
    a[i] = make_pair(p, q);
  }

  sort(ALL(a), [](pair< ll, ll > x, pair< ll, ll > y) { return x.first < y.first; } );

  ll cnt = 0;
  ll ans = a[cnt].first;
  REP(i, N) {
    ans = a[i].first;
    cnt += a[i].second;
    if (cnt > K -1) break;
  }

  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<cstring>
#include<vector>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<utility>
#include<climits>
#include<set>
using namespace std;
#define ll long long

	    ll mod=1000000007;
ll func(ll a,ll b)
{
	if(b==0)
		return 1LL;

	ll ans=1;
	while(b>0)
	{
		if(b&1)
		{
			ans=(ans*a)%mod;
		}
		a=(a*a)%mod;
		b=b>>1;
	}
	return ans;
}
int main(){ 
	ios_base::sync_with_stdio(false);
	    cin.tie(0);
	    cout.tie(0);
	    
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);
	    freopen("output.txt","w",stdout);
	#endif


		ll n;cin>>n;
	    if(n==1)
	    {
	    	cout<<0;
	    	return 0;
	    }


	    
	    ll a=10;
	    ll b=9;
        ll c=8;
        ll d=n;
        
        ll ans1=func(10,n);
        ll ans2=func(9,n);
        ll ans3=func(8,n);


        
        cout<<(ans1%mod - (2*ans2)%mod + ans3%mod +mod)%mod;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int 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; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n , k;
cin>>n>>k;
if(n >= 10){
 cout<<k<<endl;
 return 0;
}
cout<< k+ 100*(10 - n)<<endl;
}



Measured memory_bytes: 256
//Traveling

#include<bits/stdc++.h>
using namespace std;

int main (){
    int N;
    cin >> N;
    vector<int> T(N+1),X(N+1),Y(N+1);
    T[0] = X[0] = Y[0] =0;
    for(int i=1;i<=N;i++)cin >> T[i] >> X[i] >> Y[i];
    bool flag =true;
    for(int i=0;i<N;i++){
        int dt = T[i+1]-T[i];
        int dist = abs(X[i+1]-X[i]) + abs(Y[i+1]-Y[i]);
        if(dt<dist)flag = false;
        if(dist%2 != dt%2)flag = false;
    }
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1408
/* 
 * File:   main.c
 * Author: s1252007
 *
 * Created on June 19, 2018, 11:37 AM
 */

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

/*
 * 
 */

int main(int argc, char** argv) {
    int size, counter= 0;
    int *A;
    
    scanf("%d", &size);
    A = (int *)malloc(sizeof(int) * size);
    for (int ix = 0; ix < size; ++ix) scanf("%d", &A[ix]);
    for ( int c = 0 ; c < ( size - 1 ) ; c++ )
    {
        int position, swap, d;
        position = c;

        for ( d = c + 1 ; d < size ; d++ )
        {
           if ( A[position] > A[d] )
              position = d;
        }
        if ( position != c )
        {
           swap = A[c];
           A[c] = A[position];
           A[position] = swap;
           counter++;
        }
    }
    for (int ix = 0; ix < size; ++ix)
    {
        if (ix > 0) printf(" ");
        printf("%d", A[ix]);
    }
    printf("\n");
    printf("%d\n", counter);
    return (EXIT_SUCCESS);
}





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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
	int n,w;
	while(cin >> n >> w){
		int hmax=0;
		int rmax=0;
		int h[15]={0};
		if(n==0)
			break;
		rep(i,n){
			int in;
			cin >> in;
			rmax=max(rmax,in/w);
			h[in/w]++;
		}
		rep(i,15) hmax=max(hmax,h[i]);
		double ans=0.01;
		rep(i,rmax){
			double coef=1.0*(rmax-i)/rmax;
			double num=1.0*h[i]/hmax;
			ans+=coef*num;
		}
		cout.precision(9);
		cout << fixed << ans << endl;
	}
	return 0;
}

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

const double EPS = 1e-6;
const double INF = 1e12;
const double PI = acos(-1);

using Point = complex<double>;
using Polygon = vector<Point>;

inline int sgn(const double &a) { return (a < -EPS ? -1 : (a > EPS ? 1 : 0)); }

inline bool eq(const Point &a, const Point &b) { return abs(a - b) < EPS; }

namespace std {
inline bool operator<(const Point &a, const Point &b) {
    if (sgn(a.real() - b.real()))
        return sgn(a.real() - b.real()) < 0;
    return sgn(a.imag() - b.imag()) < 0;
}
} // namespace std

double dot(const Point &a, const Point &b) { return real(conj(a) * b); }

double det(const Point &a, const Point &b) { return imag(conj(a) * b); }

struct Line {
    Point p1, p2;

    Line(Point p1 = Point(), Point p2 = Point()) : p1(p1), p2(p2) {}

    bool operator<(const Line &rhs) const {
        if (eq(p2, rhs.p2))
            return p1 < rhs.p1;
        return p2 < rhs.p2;
    }
    bool operator==(const Line &rhs) const {
        return (eq(p1, rhs.p1) && eq(p2, rhs.p2)) ||
               (eq(p1, rhs.p2) && eq(p2, rhs.p1));
    }
};

inline Point curr(const Polygon &p, const int &i) { return p[i % p.size()]; }

inline Point next(const Polygon &p, const int &i) {
    return p[(i + 1) % p.size()];
}

inline Point prev(const Polygon &p, const int &i) {
    return p[(i + p.size() - 1) % p.size()];
}

struct Circle {
    Point p;
    double r;
    Circle(Point p = Point(), double r = 0) : p(p), r(r) {}
};

double distanceLP(Line line, Point p) {
    return abs(det(line.p2 - line.p1, p - line.p1)) / abs(line.p2 - line.p1);
}

Point projection(Line line, Point p) {
    Point a = line.p2 - line.p1, b = p - line.p1;
    double r = dot(a, b) / norm(a);
    return line.p1 + r * a;
}

vector<Point> intersection(Circle c, Line line) {
    double d = distanceLP(line, c.p);
    vector<Point> res;
    if(sgn(d-c.r) > 0) return res;
    Point p = projection(line, c.p);
    if(eq(d, c.r)) {
        res.push_back(p);
        return res;
    }
    double len = sqrt(c.r*c.r - d*d);
    Point e = (line.p1 - line.p2) / abs(line.p1 - line.p2);
    res.push_back(p + len*e);
    res.push_back(p + len*e*Point(-1, 0));
    if(res[1] < res[0]) swap(res[0], res[1]);
    return res;
}

int main(){
    double cx, cy, r;
    cin >> cx >> cy >> r;
    Circle c(Point(cx, cy), r);
    int q;
    cin >> q;
    for(int i=0;i<q;++i){
        double x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        Line line(Point(x1, y1), Point(x2, y2));
        auto v = intersection(c, line);
        printf("%.10f %.10f ", v[0].real(), v[0].imag());
        int idx = 1 % v.size();
        printf("%.10f %.10f\n", v[idx].real(), v[idx].imag());
    }

    return 0;
}



Measured memory_bytes: 3276
n, m, k = map(int, input().split())
mod = 998244353

ans = 0
t = 1
b = 1
for i in range(k+1):
  ans += t * pow(m-1, n-1-i, mod) * pow(b, mod-2, mod)
  ans %= mod
  #n-1Ci * (m-1)**i
  t *= (n-1-i)
  t %= mod
  b *= (i+1)
  b %= mod
print(ans*m%mod)

Measured memory_bytes: 9204
N = int(input())
a = []

for _ in range(N):
    a.append(int(input()) - 1)

i, count = 0, 0
success = False
for _ in range(N):
    i = a[i]
    count += 1

    if i == 1:
        success = True
        break

if not success:
    count = -1

print(count)

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

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

    int ans = 9;
    for (int i = 400; i <= x; i += 200) ans--;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
#include<stdio.h>

int main(){
	int N,ans=0;
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		int a;
		scanf("%d",&a);
		while(a%2==0){
			ans++;
			a/=2;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
N, T = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(N)]
x.sort(key=lambda y:y[0], reverse=True)
ans = 0
for (c, t) in x:
    if t <= T:
        ans = c
if ans == 0:
    print('TLE')
else:
    print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define ump unordered_map
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define len length()
double doINF = 1.0/0.0 ;
ostream_iterator <int> outp(cout," ");
inline ll modadd(ll n,ll m,ll mod){
    ll sum = ((n+m)%mod+mod)%mod;
    return sum;
} 
inline ll modsub(ll n,ll m, ll mod){
    ll diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}
inline ll modpro(ll n,ll m,ll mod){
    ll pro = ((n*m)%mod+mod)%mod;
    return pro;
}
inline ll pow(int x,int y){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}
inline ll powmod(ll x,ll y,ll mod){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = modpro(res , x,mod);
        y = y >> 1;
        x = modpro(x , x,mod);
    }
    return res;
}
//ll min(ll a, ll b){
//    if(a>b){
//        return b;
//    }
//    return a;
//}
// 
//ll max(ll a, ll b){
//    if(a>b){
//        return a;
//    }
//    return b;
//}
bool pairdec(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 		if(a.fi!=b.fi)
       	return (a.fi> b.fi);
		else return a.se>b.se;  
} 

ll power(ll x, ll y, ll mod) 
{ 
    ll res = 1; 
    x = x%mod; 
    while (y > 0) { 
        if (y & 1) 
            res = (res * x) % mod; 
  
        y = y >> 1;
        x = (x * x) % mod; 
    } 
    return res; 
} 
ll modInverse(ll a, ll mod) 
{ 
    return  powmod(a, mod - 2, mod); 
} 
ll modFact(ll n, ll mod) 
{ 
    if (n >=mod) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) %mod; 
  
    return result; 
} 
//cout<<setprecision(9)<<fixed<<sum<<endl; --- precision for double numbers
//copy(v.beg,v.en,outp);
ll findTrailingZeros(ll n) 
{ 
    // Initialize result 
    ll count = 0; 
  
    // Keep dividing n by powers of  
    // 5 and update count 
    for (ll i = 5; n / i >= 1; i *= 5) 
        count += n / i; 
  
    return count; 
} 
int main()
{
	
	ll n;
	cin>>n;
	if(n%2!=0)
	{
		cout<<0<<endl;
		return 0;
	}
	else{
		cout<<findTrailingZeros(n/2)<<endl;
	}
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);

    int N;
    cin >> N;

    int m = 0;
    vi chain(N);

    for (int i = 0; i < N; i++) {
        int v;
        cin >> v;
        v--;

        chain[v] = chain[v-1]+1;
        m = max(m, chain[v]);
    }

    cout << N - m << endl;
    return 0;
}



Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int k,s,cnt=0;
int main()
{
    cin>>k>>s;
    for(int x=0;x<=k;x++)
    {
        for(int y=0;y<=k;y++)
        {
            if(s-x-y>=0&&s-x-y<=k) cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 384
nums = input().split()
W = int( nums[0])
H = int( nums[1])
x = int( nums[2])
y = int( nums[3])
r = int( nums[4])
  
if (x - r) >= 0 and (x + r) <= W:
    if (y - r) >= 0 and (y + r) <= H:
        print( "Yes")
    else:
        print( "No")
else:
    print( "No")

Measured memory_bytes: 6724
def parse(s):
  ret = 0
  dic = {"m":1000, "c":100, "x":10, "i":1}
  while s:
    if s[0] in dic:
      ret += dic[s[0]]
      s = s[1:]
    else:
      ret += int(s[0]) * dic[s[1]]
      s = s[2:]
  return ret

def conv(n):
  ret = ""
  def func(ret, c, i):
    if i == 0:
      pass
    elif i == 1:
      ret += c
    else:
      ret += str(i) + c
    return ret
  a = n // 1000
  ret = func(ret, "m", a)
  n %= 1000
  b = n // 100
  ret = func(ret, "c", b)
  n %= 100
  c = n // 10
  ret = func(ret, "x", c)
  n %= 10
  ret = func(ret, "i", n)
  return ret

n = int(input())
for _ in range(n):
  s1, s2 = input().split()
  print(conv(parse(s1) + parse(s2)))


Measured memory_bytes: 5620
#include <stdio.h>

int main(void) {

	int a;
	int b;
	int d;
	int r;
	double f;

	scanf("%d%d",&a,&b);
	d = a / b;
	r = a % b;
	f = 1.0 * a / b;
	printf("%d %d %.8lf\n",d,r,f);
	return 0;
}


Measured memory_bytes: 2716
import itertools

n = input()
ans = 0
l = ["3", "5", "7"]

for i in range(3, len(n) + 1):
    for j in itertools.product(l, repeat = i):
        j = "".join(j)
        if int(j) <= int(n):
            if "3" in str(j):
                if "5" in str(j):
                    if "7" in str(j):
                        ans += 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int l;
    char s[1004];
    cin>>s;
    l=strlen(s);
    if(s[l-1]=='s')
    {
        cout<<s<<"es"<<endl;
    }
    else
    {
        cout<<s<<"s"<<endl;
    }
    return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  bool can = false;
  for(int i = 1; i <= b; i++){
    if(a * i % b == c) can = true;
  }
  
  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/perl
my ($n) = map { $_ - 0 } split(/\s+/,<STDIN>);
my $s = <STDIN>;
my $mb = 10**9 + 7;
my %cc = ();
for(my $i=0;$i<$n;$i++){
  my $c = substr($s,$i,1);
  $cc{$c} ++ ;
}
my $ct = 0;
my $p = 0;
foreach my $c (keys %cc){
  $p = ( $p + $cc{$c} + ( $p * $cc{$c} ) ) % $mb;
}
print "$p\n";



Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
int main(){
	string S;
	cin>>S;
	int x=0, y=0;
	for(int i=0; i<S.size(); i++){
		if(S[i] == '0'){
			x++;
		}
		if(S[i] == '1'){
			y++;
		}
	}
	cout<<2*(x>y?y:x)<<endl;
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(1000000)
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque, Counter as cnt

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]
def nlist(n, v):
    if not n: return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]

# エントリーポイント
def main():
    A = input(int)
    S = input(str)
    if 3200 <= A:
        print(S)
    else:
        print("red")
    return

if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


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

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

    int p;
    int t1 = 0;
    int t2 = 0;
    int t3 = 0;
    for (int i = 0; i < n; i++) {
        cin >> p;
        if (p <= a) {
            t1++;
        } else if (a < p && p <= b) {
            t2++;
        } else {
            t3++;
        }
    }

    cout << min({t1, t2, t3}) << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import Counter
n=int(input())
a=sorted(list(map(int,input().split())),reverse=1)
b=Counter(a)
cnt=0
for i in range(n):
    if b[a[i]]<=0:
        continue
    k=a[i].bit_length()
    x=(1<<k)-a[i]
    if x==a[i]:
        if b[x]>1:
            cnt+=1
            b[x]-=2
    elif x in b and b[x]>0:
        cnt+=1
        b[a[i]]-=1
        b[x]-=1
print(cnt)

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

int main(){

    int a, b, c; cin >> a >> b >> c;

    for(int i = 1; i < 10000; i++){
        if((a * i) % b == c){
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll tree[200005];
ll lowbit(ll x){
    return x&(-x);
}
void add(ll x,ll k){
    while(x<=200005){
        tree[x]+=k;
        x+=lowbit(x);
    }
}
ll query(ll x){
    ll res=0;
    while(x>0){
        res+=tree[x];
        x-=lowbit(x);
    }
    return res;
}
int main(){
	ll n,m,num=0,l,r;
	cin>>n>>m;
	for(ll i=1;i<=m;i++){
		cin>>l>>r;
		add(l,1);
		add(r+1,-1);
	}
	for(ll i=1;i<=n;i++){
		ll x=query(i);
		if(x==m) num++;
	}
	cout<<num<<endl;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int q;
  cin >> q;
  vector<int> b(q), c(q);
  for (int i = 0; i < q; i++) {
    cin >> b[i] >> c[i];
  }
  map<int, int> cnt;
  for (int i = 0; i < n; i++) {
    cnt[a[i]]++;
  }
  vector<long long> ans(q, 0);
  ans[0] = accumulate(a.begin(), a.end(), 0LL);
  for (int i = 0; i < q; i++) {
    if (cnt.count(b[i])) {
      long long temp = b[i];
      long long temp2 = cnt[b[i]];
      cnt[c[i]] += cnt[b[i]];
      cnt.erase(b[i]);
      ans[i] += temp2 * c[i] - temp2 * temp;
    }
    if (i < q - 1) {
      ans[i + 1] = ans[i];
    }
  }
  for (int i = 0; i < q; i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}

Measured memory_bytes: 8172
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);

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

    int largest = A + B;

    if(A - B > largest) largest = A - B;
    if(A * B > largest) largest = A * B;

    cout << largest << endl;

    return 0;
}


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

#define MAX 4000

int main(int, char**)
{
    int n;
    string s;

    cin >> n;
    cin >> s;

    int r_tail[MAX];
    int g_tail[MAX];
    int b_tail[MAX];

    int r_count, g_count, b_count;
    r_count = g_count = b_count = 0; 
    for (int i = n-1; i >= 0; i--) {
        if (s[i] == 'R') r_count++;
        if (s[i] == 'G') g_count++;
        if (s[i] == 'B') b_count++;
        r_tail[i] = r_count;
        g_tail[i] = g_count;
        b_tail[i] = b_count;
    }

    long long result = 0;
    char remain;
    for (int i = 0; i < n; i++)
        for (int j = i+1; j < n; j++) {
            if (s[i] == s[j]) continue;
            if (s[i] == 'R' && s[j] == 'G') remain = 'B';
            if (s[i] == 'R' && s[j] == 'B') remain = 'G';
            if (s[i] == 'G' && s[j] == 'R') remain = 'B';
            if (s[i] == 'G' && s[j] == 'B') remain = 'R';
            if (s[i] == 'B' && s[j] == 'R') remain = 'G';
            if (s[i] == 'B' && s[j] == 'G') remain = 'R';
            if (remain == 'R') result += r_tail[j];
            if (remain == 'G') result += g_tail[j];
            if (remain == 'B') result += b_tail[j];
            if (s[j + (j-i)] == remain) result--;
        }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 3660
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>
#include<ctype.h>
#include<limits.h>

//qsort
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

//比較
int max(int a, int b){
	if (a>b) return a;
	else return b;
}

int min(int a,int b) {
	if(a>b) return b;
	else return a;
}


//main関数
int main() {
	unsigned long long int X;
	scanf("%lld",&X);
	unsigned long long int number = 100;
	for(unsigned long long int i=1; i<100000000000; i++) {
		number = number * 1.01;
		if(number >= X ){
			printf("%lld",i );
			return 0;
		}
	}
}



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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30
#define MOD 1000000007 // 1e9+7

int main()
{
	int sx, sy, tx, ty;

	cin >> sx >> sy >> tx >> ty;

  // 1st forward path
  for( int i=0; i<ty-sy; i++ )
    cout << "U";
  for( int i=0; i<tx-sx; i++ )
    cout << "R";
  // 1st backward path
  for( int i=0; i<ty-sy; i++ )
    cout << "D";
  for( int i=0; i<tx-sx; i++ )
    cout << "L";

  // 2nd forward path
  cout << "L";
  for( int i=0; i<ty-sy+1; i++ )
    cout << "U";
  for( int i=0; i<tx-sx+1; i++ )
    cout << "R";
  cout << "D";
  // 2st backward path
  cout << "R";
  for( int i=0; i<ty-sy+1; i++ )
    cout << "D";
  for( int i=0; i<tx-sx+1; i++ )
    cout << "L";
  cout << "U";

  cout << endl;

	return 0;
}



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

int main(){
	int n;
	cin>>n;
	int a[n];
	for (int i=0;i<n;i++)
		cin>>a[i];
	long long int dp[n][n], temp;
	for (int i=0;i<n-1;i++){
		dp[i][i+1] = a[i] + a[i+1];
		dp[i][i] = 0;
	}
	dp[n-1][n-1] = 0;
	long long int sm[n][n];
	for (int i=0;i<n;i++){
		sm[i][i] = a[i];
		for (int j=i+1;j<n;j++){
			sm[i][j] = sm[i][j-1] + a[j];
		}
	}
	for (int i=2;i<n;i++){
		for (int j=0;j+i<n;j++){
			temp = LONG_MAX;
			for (int k=0;k<i;k++){
				temp = min(temp, dp[j][j+k] + dp[j+k+1][j+i]);
			}
			dp[j][j+i] = temp + sm[j][j+i];
		}
	}
	// for (int i=0;i<n;i++){
	// 	for(int j=0;j<n;j++){
	// 		cout<<sm[i][j]<<" ";
	// 	}
	// 	cout<<"\n";
	// }
	// cout<<"\n\n";
	// for (int i=0;i<n;i++){
	// 	for(int j=i;j<n;j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<"\n";
	// }
	cout<<dp[0][n-1];
}

Measured memory_bytes: 2688
X,Y=map(int, input().split())
ans=0

if X==1:
    ans+=300000
elif X==2:
    ans+=200000
elif X==3:
    ans+=100000
    
if Y==1:
    ans+=300000
elif Y==2:
    ans+=200000
elif Y==3:
    ans+=100000

if X==1 and Y==1:
    ans+=400000

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int juge(char *a,int c){
  int cnt1=0;
  int cnt2=0;
  for(int i=0;a[i]!='\0';i++){
    if(a[0]==a[i])
      cnt1++;
    if(a[c]==a[i])
      cnt2++;
  }
  if(cnt1 == 2 && cnt2 == 2)
    return 1;
  else 
    return 0;
}

int main(){
  char a[5];
  int c=0;
  scanf("%s",a);

  for(;a[c]!='\0' && a[0]==a[c];c++);
  
  if(c==5)
    printf("No");
  else 
    if(juge(a,c))
      printf("Yes");
    else 
      printf("No");
   
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	int n;
	cin >> n;
	vector<string> S(n);
	REP(i, n) cin >> S[i];
	vector<vector<int>> memo(n, vector<int>(26, 0));
	REP(i, n) {
		REP(j, S[i].size()) {
			memo[i][S[i][j] - 'a']++;
		}
	}
	REP(i, 26) {
		int mn = INT_MAX;
		REP(j, n) {
			mn = min(mn, memo[j][i]);
		}
		REP(j, mn) cout << (char)(i + 'a');
	}
	cout << "\n";

	return 0;
}

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

public class Main {
    void run() {
        while (true) {
            int N = readInt();
            if (N == 0) break;
            int[][] M = new int[N][N];
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    M[i][j] = readInt();
                }
            }
            boolean[][] target = new boolean[N][N];
            for (int i = 0; i < N; i++) {
                int minVal = Integer.MAX_VALUE;
                for (int j = 0; j < N; j++) {
                    minVal = Math.min(minVal, M[i][j]);
                }
                for (int j = 0; j < N; j++) {
                    if (M[i][j] == minVal) target[i][j] = true;
                }
            }
            ArrayList<Integer> ans = new ArrayList<Integer>();
            for (int i = 0; i < N; i++) {
                int maxVal = Integer.MIN_VALUE;
                for (int j = 0; j < N; j++) {
                    maxVal = Math.max(maxVal, M[j][i]);
                }
                for (int j = 0; j < N; j++) {
                    if (M[j][i] == maxVal && target[j][i]) {
                        ans.add(M[j][i]);
                    }
                }
            }
            if (ans.isEmpty()) sysout.println(0);
            else {
                sysout.println(Collections.min(ans));
            }
        }
    }

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

    // flush automatically iff you call `println` or `printf` or `format`.
    PrintWriter sysout = new PrintWriter(System.out, true);

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer buffer = null;

    String read() {
        if (buffer == null || !buffer.hasMoreTokens()) {
            try {
                buffer = new StringTokenizer(in.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return buffer.nextToken();
    }

    int readInt() {
        return Integer.parseInt(read());
    }

    long readLong() {
        return Long.parseLong(read());
    }

    double readDouble() {
        return Double.parseDouble(read());
    }

    String readLine() {
        buffer = null;
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

Measured memory_bytes: 16908
#include <iostream>
using namespace std;
int main(){
  int S;
  cin >> S;
  int h, m, s;
  h = S/3600;
  m = (S - h * 3600) / 60;
  s = S - h * 3600 - m * 60;
  cout << h << ":" << m << ":" << s <<endl;
}


Measured memory_bytes: 3100