akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{
speed_up;
string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  int l1, l2, l3;
  l1 = s1.size();
  l2 = s2.size();
  l3 = s3.size();
  int cnt1, cnt2, cnt3;
  cnt1 = cnt2 = cnt3 = 0;
  char t = 'A';
  while(true) {
    if(t == 'A' && cnt1 == l1 || t == 'B' && cnt2 == l2 || t == 'C' && cnt3 == l3) break;
    if(t == 'A') {
      if(s1[cnt1] == 'b') t = 'B';
      else if(s1[cnt1] == 'c') t = 'C';
      ++cnt1;
    } else if(t == 'B') {
      if(s2[cnt2] == 'a') t = 'A';
      else if(s2[cnt2] == 'c') t = 'C';
      ++cnt2;
    } else {
      if(s3[cnt3] == 'a') t = 'A';
      else if(s3[cnt3] == 'b') t = 'B';
      ++cnt3;
    }
  }
 
  cout << t << endl;
 
  return 0;
}

Measured memory_bytes: 3604
//non use binary search
#include <iostream>
#define int long long
using namespace std;

int n, k;

signed main() {
	cin >> n >> k;
	
	//now_id = a * k + b (0 ??? b < k)
	int a = 0;
	int b = 0;
	for (int i = 0; i < n - 1; i++) {
		int x = a * k + b;
		if ((x + 1) % (k - 1) == 0) {
			a = (x + 1) / (k - 1) - 1;
			b = k - 1;
		}
		else {
			a = (x + 1) / (k - 1);
			b = x + 1 - a * (k - 1);
		}
	}
	cout << a * k + b << endl;
	return 0;
}

Measured memory_bytes: 3096
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		if(0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17308
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   
   int A, B, C, K;
   cin >> A >> B >> C >> K;
   int ans = 0;
   ans += A;
   ans += B;
   ans += C;
   int max = A;
   if (max < B) max = B;
   if (max < C) max = C;
   
   ans += max * pow(2, K);
   ans -= max;

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


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc138/tasks/abc138_d

#include <cstdio>
#include <vector>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')

//------------------------------------------------------------------------------
const int V_MAX = 200000;

int V;
vector<int> G[V_MAX];

void add_edge(int a, int b) {
  G[a].push_back(b);
  G[b].push_back(a);
}


//------------------------------------------------------------------------------
int cnt[V_MAX];
int acc[V_MAX];

void dfs(int v, int p) {
  if (p >= 0) acc[v] = acc[p];
  acc[v] += cnt[v];
  REP(i, G[v].size()) {
    int u = G[v][i];
    if (u == p) continue;
    dfs(u, v);
  }
}

//------------------------------------------------------------------------------
const int N_MAX = 200000;
const int Q_MAX = 200000;
const int X_J_MAX = 10000;

int N, Q;
int a[N_MAX];
int b[N_MAX];
int p[Q_MAX];
int x[Q_MAX];


void solve() {
  V = N;
  REP(i, N - 1) add_edge(a[i] - 1, b[i] - 1);
  REP(i, Q) cnt[p[i] - 1] += x[i];
  dfs(0, -1);
  // DUMP(cnt, N);
  // DUMP(acc, N);
  REP(i, N) printf("%d%c", acc[i], i + 1 == N ? '\n' : ' ');
}

void input() {
  scanf("%d%d", &N, &Q);
  REP(i, N - 1) scanf("%d%d", a + i, b + i);
  REP(i, Q) scanf("%d%d", p + i, x + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 30464
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
using namespace std;
typedef long long LL;
typedef complex<double> C;
double dot(C a, C b)
{
    return real(a)*real(b)+imag(a)*imag(b);
}
const double eps=1e-9;
int N;
C ps[500];
double rs[500][2];
int ret=1;
void exec4(C v, double c)
{
    int cnt=0;
    for(int i=0;i<N;i++){
        double w=abs(dot(ps[i],v)-c);
        //cout << w << ": " << rs[i][0] - eps << ": " << rs[i][1] + eps<< endl;
        if (rs[i][0]-eps<=w&&w<=rs[i][1]+eps)
        {
            //cout << "ok" << endl;
            cnt++;
        }
        else
        {
        //cout << "ng" << endl;
        }
    }
     
    /*
    if (cnt < 2){
        cout << cnt << ", " << v << ", " << c << endl;
    }*/
    ret=max(cnt,ret);
}
 
void solve(double a, double b, double c, C ans[2])
{
    bool sw=false;
    if (b==0){
        swap(a,b);
        sw=true;
    }
 
    double s=-a/b;
    double t=c/b;
    double p=1+s*s;
    double q=2*s*t;
    double r=t*t-1;
    /*
    if (q*q-4*p*r<0){
        cout << "aaa " << endl;
    }*/
    double x0=(-q-sqrt(q*q-4*p*r))/(2*p);
    double y0=s*x0+t;
    double x1=(-q+sqrt(q*q-4*p*r))/(2*p);
    double y1=s*x1+t;
    if(!sw){
        ans[0]=C(x0,y0);
        ans[1]=C(x1,y1);
    }
    else
    {
        ans[0]=C(y0,x0);
        ans[1]=C(y1,x1);
    }
}
void exec3(C q, C p, double r)
{
    if (abs(q-p)<r-eps){
        return;
    }
 
    C v[2];
    int cnt;
    if (abs(q-p)<=r+eps){
        v[0]=(q-p)/abs(q-p);
        cnt=1;
    }
    else
    {
        solve(real(p-q),imag(p-q),r,v);
        cnt=2;
    }
    for(int i=0;i<cnt;i++){
        double c=dot(v[i],q);
        exec4(v[i],c);
    }
}
void exec2(C p1, double r1, C p2, double r2)
{
    if (r1>r2){
        swap(p1,p2);
        swap(r1,r2);
    }
 
    C q=(r2*p1+r1*p2)/(r1+r2);
    //cout << "aaa " << endl;
    exec3(q,p1,r1);
 
    if(r1!=r2){
        q=(r2*p1-r1*p2)/(r2-r1);
        //cout << "bbb " << endl;
        exec3(q,p1,r1);
    }
    else
    {
        C v=(p2-p1)/abs(p2-p1)*C(0,1)*r1;
        exec3(p1+v,p1,r1);
        exec3(p1-v,p1,r1);
    }
}
void exec()
{
    cin >> N;
    if(N==0){
        exit(0);
    }
 
    for(int i=0;i<N;i++){
        int x,y;
        cin >> x >> y >> rs[i][0] >> rs[i][1];
        rs[i][1]+=rs[i][0];
        ps[i]=C(x,y);
    }
 
    ret=1;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            for(int s=0;s<2;s++){
                for(int t=0;t<2;t++){
                    exec2(ps[i],rs[i][s],ps[j],rs[j][t]);
                }
            }
        }
    }
    cout << ret << endl;
}
 
int main() {
    while(1)
        exec();
}
 


 

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int ggcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  string s;
  cin>>s;
  int k=0;
  bool f1=false;
  bool f2=false;
  while(!f1 && k<s.size()){
     if(s[k]=='C') f1=true;
     k++;
  }
  while(!f2 && k<s.size()){
    if(s[k]=='F') f2=true;
    k++;
  }
  if(f1 && f2){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
///////////////////////////

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

#pragma warning(disable : 4996)

int n, s, dp[10][331][1024];

int rec(int depth, int ans, int bit)
{
	if (depth == n) return s == ans ? 1 : 0;

	if (dp[depth][ans][bit] != -1)
	{
		return dp[depth][ans][bit];
	}

	int res = 0;

	for (int i = 0; i < 10; i++)
	{
		if (!(bit & (1 << i)))
		{
			res += rec(depth + 1, ans + (depth + 1) * i, bit + (1 << i));
		}
	}

	dp[depth][ans][bit] = res;

	return res;
}

int main()
{
	while (~scanf("%d %d", &n, &s))
	{
		memset(dp, -1, sizeof(dp));

		printf("%d\n", rec(0, 0, 0));
	}

	return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N, K;
int A[100500];
ll B[100500];

int main() {
    //cout.precision(10);
    cin >> N >> K;
    for(int i = 1; i <= N; i++) cin >> A[i] >> B[i];
    ll ans = 0;
    for(int i = 1; i <= N; i++) {
        if((K & A[i]) == A[i]) ans += B[i];
    }
    int val = 1;
    int index = 0;
    while(index <= 30) {
        if(((K >> index) & 1)) {
            int now = K - val;
            now |= (val - 1);
            ll now_ans = 0;
            for(int i = 1; i <= N; i++) {
                if((now & A[i]) == A[i]) now_ans += B[i];
            }
            ans = max(ans, now_ans);
        }
        val *= 2;
        index++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
import java.math.BigInteger;
import java.util.*;


public class Main {
	
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int diff = b - a - 1;
			long ans =  (long)diff * (diff + 1) / 2 - a;
			System.out.println(ans);
		}
	}
	
	private long calc(long n, long m, long l){
		long sum = 1;
		for(long i = n; i > m; i--){
			sum *= i;
		}
		for(long i = 2; i <= l; i++){
			sum /= i;
		}
		return sum;
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


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

const int N = 4000;
int n;
int cr[N+1], cg[N+1], cb[N+1];

int cnt(int cnt[], int i) {
	return cnt[n] - cnt[i];
}

int main() {
	cin >> n;
	string s; cin >> s;
	rep(i,n) {
		cr[i+1] = cr[i];
		cg[i+1] = cg[i];
		cb[i+1] = cb[i];
		if (s[i] == 'R') ++cr[i+1];
		else if (s[i] == 'G') ++cg[i+1];
		else ++cb[i+1];
	}

	ll sum = 0;
	rep(i,n-1)REP(j,i+1,n) {
		if (s[i] == s[j]) continue;
		char ch;
		int *p;
		if (s[i] != 'R' && s[j] != 'R') ch = 'R', p = cr;
		else if (s[i] != 'G' && s[j] != 'G') ch = 'G', p = cg;
		else ch = 'B', p = cb;
		sum += cnt(p, j);
		if (s[2*j-i] == ch) --sum;
	}

	printf("%lld\n", sum);
}

Measured memory_bytes: 3768
#include <stdio.h>
 
int main(void){
    int l,x,y,min,max;
    long long sum;
    sum = 0;
    scanf("%d", &x);
    for (l = 0;l<x;l++){
        scanf("%d", &y);
        if(l == 0){
            min = y;
            max = y;
        }
        if (min > y){
            min = y;
        }
        if (max < y){
            max = y;
        }
        sum += y;
    }
    printf("%d %d %lld\n",min,max,sum);
    return(0);
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int MAX = 100010;
ll dp[MAX];

int main() {
    int n; cin >> n;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];

    rep(i, MAX) dp[i] = LLINF;
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= 2; j++) {
            if (i + j >= n) continue;
            chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        }
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1792
#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 req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}





int main() {
  int n;
  cin >> n;
  ll x,a[n+1];
  cin >> x;
  rep (i,n){
    cin >> a[i];
  }
  int res = 0;
  sort (a,a+n);
  rep (i,n){
    if (x >= a[i]) {
      res ++;
      x -= a[i];
    }
    else break;
  }
  if (res == n && x) --res;
  cout << res << endl;
}

Measured memory_bytes: 3680
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;
ll N;

int main(){
    //ll P , Q , R;
    //cin >> P >> Q  >> R;
    ll N;
    cin >> N;
    vector<pair <pair <string, ll >, ll> > dic(N);

    for(ll i = 0; i < N; i++){
        string name;
        ll point;
        cin >> name >> point;
        dic[i] = make_pair(make_pair(name, point * -1), i);
    }

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

    for(ll i = 0; i < N; i++){
        //string s = to_string(dic[i].second);
        cout << dic[i].second+1 << endl;
    }


} 

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
 
using namespace std;
 
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
 
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).end()) i=(c).end(); i!=(c).begin(); --i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
 
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
 
#define PB(a) push_back(a)
#define PF(a) pop_front(a)
 
#define MP(a,b) make_pair(a,b)
 
#define FS first
#define SE second
 
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
 
//------show vector---------
template <typename T>
void showV(vector < T > a){
  EACH(i,a){
    cerr << *i << ',';
  }  
  cerr << endl;
}
 
//------show matrix---------
template <typename T>
void showVV(vector < vector < T > > a){
  EACH(i,a){
    showV(*i);
  }  
}
//grobal var
//------------------------------------------
LL dp[2000][2000];
vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  return (ret);
}

int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------
  int N;
  cin >> N;
    LL ans = 0;
    VL a(N+1),b(N);

    REP(i,N+1){
      cin >> a[i];
    }

    REP(i,N){
      cin >> b[i];
    }

    REP(i,N){
      LL ca = a[i];
      LL cb = b[i];
      if(ca >= cb){
        ans += cb;
      }
      else{
        ans += ca;
        LL cc = min((cb-ca), a[i+1]);
        a[i+1] -= cc;
        ans += cc;
      }
    }
    cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int N, ans;
int main(){
    cin>>N;
    if(N==1)cout<<1;
    else{
        for(int i=2;i*i<=N;i++){
            int tmp=i*i;
            while(tmp*i<=N)tmp*=i;
            ans=max(ans,tmp);
        }
        cout<<ans<<'\n';
    }
    return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    N = int(sys.stdin.readline())
    SN = N
    def calc(N):
        import math
        L = []
        for i in range(2, int(math.sqrt(N))+2):
            while N % i==0:
                L += [i]
                N = N//i
        if N !=1:
            L += [N]
        print(str(SN) + ': ' + ' '.join(map(str,L)))
    
    calc(N)
   

if __name__=='__main__':
    main()


Measured memory_bytes: 5664
$Q = scalar(<STDIN>);
@P=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317);
$s=0;
for($i=3;$i<=100000;$i++){
	$f=1;
	$ii=($i+1)/2;
	for($j=0;$P[$j]*$P[$j]<=$ii;$j++){
		if($ii%$P[$j]==0) { $f=0; last; }
	}
	if ($f) {
		for($j=0;$P[$j]*$P[$j]<=$i;$j++){
			if($i%$P[$j]==0) { $f=0; last;}
		}
		$s=$s+1 if ($f);
	}
	$S[$i]=$s;
}

$\="\n";
for($i=$Q;$i>0;$i--){
	($l,$r)=split " ",<STDIN>;
	print $S[$r]-$S[$l-1];
}


Measured memory_bytes: 4096
# Problem: https://atcoder.jp/contests/abc080/tasks/abc080_b
# Python 3rd Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def LLI(rows_number): return [LI() for _ in range(rows_number)]


yes = "Yes"
no = "No"


def solver(inputNum):
    result = no
    # algorithm
    inputNumStr = str(inputNum)
    fx = 0
    for j in range(0, len(inputNumStr)):
        fx = fx + int(inputNumStr[j])
    if inputNum % fx == 0:
        result = yes
    return result


if __name__ == "__main__":
    print("{}".format(solver(II())))


Measured memory_bytes: 3064
N, A, B = [int(x) for x in input().split()]

def sum_each_digit(n):
    ans = 0
    div = 10000
    while div > 0:
        t = n // div
        ans += t
        n -= div * t
        div //= 10
    return ans

ans = 0
for i in range(1, N + 1):
    t = sum_each_digit(i)
    if A <= t and t <= B:
        ans += i

print(ans)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] a = new int[N];
        int ans = 0;
        
        for(int i=0; i<N; i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        for(int i=0; i<K; i++){
            ans += a[i];
        }
        
        System.out.println(ans);
    }
}


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

const int DIM = 105;

int arr[DIM];

int main(void) {
	int n; cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> arr[i]; }
	int ans = 0;
	for (int i = 1, j = 1; i <= n; ++i) {
		while (j + 1 <= n and arr[j + 1] == arr[i]) {
			++j; }
		ans += (j - i + 1) / 2; i = j; }
	cout << ans; 
	return 0; }
		


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 1000000000000000
#define mod 1000000007
#define ld long double
#define pll pair<ll,ll>
using namespace std;

int main()
{ 

fast;
string s;
cin>>s;

cout<<s[0]<<s[1]<<s[2];

}


Measured memory_bytes: 3640
inf = float('inf')

N, K = map(int, input().split())
x = tuple(map(int, input().split()))

m, p = [], []
for xx in x:
    if xx > 0:
        p.append(xx)
    elif xx < 0:
        m.append(-xx)
    else:
        K -= 1
        if K == 0:
            print(0)
            exit()
m.sort()
lp = len(p)
lm = len(m)

ans = inf
for from_minus in range(min(lm, K) + 1):
    from_plus = K - from_minus
    if from_plus > lp:
        continue
    if from_minus == 0:
        ans = min(ans, p[K - 1])
    elif from_minus == K:
        ans = min(ans, m[K - 1])
    else:
        ans = min(ans, p[from_plus - 1] * 2 + m[from_minus - 1])
        ans = min(ans, m[from_minus - 1] * 2 + p[from_plus - 1])
print(ans)


Measured memory_bytes: 15024
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::cerr;
using std::endl;

namespace chrono = std::chrono;
using namespace std::literals;

[[gnu::constructor]]
void fast_iostream() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
}

int main() {
    int n; cin >> n;
    int pt = 0;
    int px = 0, py = 0;
    bool flag = true;
    while (n--) {
        int t, x, y;
        cin >> t >> x >> y;
        int u = std::abs(x - px) + std::abs(y - py);
        int v = std::abs(t - pt);
        if (u > v || u % 2 != v % 2) {
            flag = false;
        }
    }
    cout << (flag ? "Yes"s : "No"s) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;


typedef pair<ll, int> pli;

int main() {
    int n;
    cin>>n;
    vector<int>a(n);
    vector<int>rgb(3,0);
    ll ans=1;
    rep(i,n){
        cin>>a[i];
        int cnt=0;
        rep(j,3){
            if(rgb[j]==a[i]){
                cnt++;
            }
        }
        ans*=cnt;
        ans%=M;
        rep(j,3){
            if(rgb[j]==a[i]){
                rgb[j]++;
                j=5;
            }
        }
    }
    cout<<ans<<endl;

  
}

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

//　考えられる組み合わせは2^d
int		main(void)
{
	vector<int> p(10);
	vector<int> c(10); // ボーナス
	int d, g;
	
	cin >> d >> g;
	for (int i = 0; i < d; i++)
		cin >> p[i] >> c[i];
	int ans = 1e9;

	for (int tmp = 0; tmp < (1 << d); tmp++)
	{
		bitset<10> s(tmp);
		int sum = 0; // gを超えるための合計
		int num = 0; // 解いた問題の数
		int rest_max = -1; // ボーナスを解いていないpのうち、最大のもののi

		for (int i = 0; i < d; i++)
		{
			if (s.test(i))
			{
				sum += 100 * (i + 1) * p[i] + c[i];
				num += p[i];
			}
			else
				rest_max = i;
		}
		if (sum < g)
		{
			// sum >= g になるかp[rest_max]が足りなくなるまでsum += REST_MAX
			for (int i = 0; (sum <  g) && (i < p[rest_max]); i++)
			{
				sum += 100 * (rest_max + 1);
				num++;
			}
		}
		if (sum >= g)
			ans = min(ans, num);
	}
	cout << ans << endl;
}


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

# D - Derangement
def swap(index, swap_with_right):
  global p

  if swap_with_right:
    l = index
    r = index + 1
  else:
    l = index - 1
    r = index

  pl = p[l]
  pr = p[r]
  p[l] = pr
  p[r] = pl


N = int(input())
p = list(map(int, input().split()))

p.insert(0, 0)
ans = 0

if p[1] == 1:
  swap(1, True)
  ans += 1

for i in range(2, N+1):
	if i < N:
		if i == p[i] and i+1 == p[i+1]:
			swap(i, True)
			ans += 1
		elif i == p[i]:
			ans += 1
	elif i == p[i]:
		ans += 1

print(ans)

Measured memory_bytes: 20800
unittest
{
	assert( [ "84 97 66", "79 89 11", "61 59 7", "7", "89", "7", "87", "79", "24", "84", "30" ].parse.expand.solve == "Yes" );
	assert( [ "41 7 46", "26 89 2", "78 92 8", "5", "6", "45", "16", "57", "17" ].parse.expand.solve == "No" );
	assert( [ "60 88 34", "92 41 43", "65 73 48", "10", "60", "43", "88", "11", "48", "73", "65", "41", "92", "34" ].parse.expand.solve == "Yes" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	long[ 3 ][ 3 ] ass;
	foreach( ref as; ass )
	{
		as = input.front.split.to!( long[] );
		input.popFront;
	}
	auto n = input.front.to!( long );
	auto bs = new long[ n ];
	foreach( ref b; bs )
	{
		input.popFront;
		b = input.front.to!( long );
	}
	return tuple( ass, bs );
}

auto solve( long[ 3 ][ 3 ] ass, long[] bs )
{
	bool[ 3 ][ 3 ] css;
	foreach( y, as; ass )
	{
		foreach( x, a; as )
		{
			foreach( b; bs )
			{
				css[ y ][ x ] = ( a == b );
				if( css[ y ][ x ] ) break;
			}
		}
	}
	
	if( css[ 0 ][ 0 ] && css[ 0 ][ 1 ] && css[ 0 ][ 2 ] ) return "Yes";
	if( css[ 1 ][ 0 ] && css[ 1 ][ 1 ] && css[ 1 ][ 2 ] ) return "Yes";
	if( css[ 2 ][ 0 ] && css[ 2 ][ 1 ] && css[ 2 ][ 2 ] ) return "Yes";
	
	if( css[ 0 ][ 0 ] && css[ 1 ][ 0 ] && css[ 2 ][ 0 ] ) return "Yes";
	if( css[ 0 ][ 1 ] && css[ 1 ][ 1 ] && css[ 2 ][ 1 ] ) return "Yes";
	if( css[ 0 ][ 2 ] && css[ 1 ][ 2 ] && css[ 2 ][ 2 ] ) return "Yes";
	
	if( css[ 0 ][ 0 ] && css[ 1 ][ 1 ] && css[ 2 ][ 2 ] ) return "Yes";
	if( css[ 2 ][ 0 ] && css[ 1 ][ 1 ] && css[ 0 ][ 2 ] ) return "Yes";
	
	return "No";
}


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

#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using ll = long long;

ll n, m, v, p;
vector<ll> a;

bool val(ll points) {
	auto it = upper_bound(all(a), points);
	ll tot = m * (v - 1);
	int cnt = 0;
	bool impossible = false;
	for (int i = distance(a.begin(), it); i <= sz(a) - p; ++i) {
		++cnt;
		if (a[i] > points + m) {
			impossible = true;
			break;
		} else {
			tot -= points + m - a[i];
		}
	}
	
	tot -= ((n - cnt - 1) * m);
	return (!impossible && tot <= 0);
}

ll bsearch(ll l, ll r) {
	if (l == r) return l;
	if (l + 1 == r) {
		if (val(l)) return l;
		return r;
	} else {
		ll mid = (l + r) / 2;
		if (val(mid)) return bsearch(l, mid);
		else return bsearch(mid + 1, r);
	}
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> n >> m >> v >> p;
	a.resize(n);
	for (auto& i : a) cin >> i;
	sort(all(a));
	ll bound = bsearch(0, 1e9);
	auto it = lower_bound(all(a), bound);
	int cnt = 0;
	while (it != a.end()) {
		++cnt, ++it;
	}
	cout << cnt;
}


Measured memory_bytes: 3984
#include<bits/stdc++.h>
#include <chrono>
#include<math.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std::chrono;
using namespace std;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// declaration: ordered_set os;  methods->  1. *os.find_by_order(x)   2. os.order_of_key(k) ->return int

#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<ll,ll>
#define ll long long int
#define ld long double
const ll mod=1e9+7;
const int N=2e6+5;
/*
ll f(ll x, ll n){
    ll r=1;
    while(n>0){
        if(n&1)
        r=(r*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return r;
}

ll fact[N],ifact[N];
void build(){
    fact[0]=1;
    fact[1]=1;
    for(ll i=2;i<N;i++)
    fact[i]=(fact[i-1]*i)%mod;
    fr(i,0,N)
    ifact[i]=f(fact[i],mod-2);
}
ll C(ll n, ll r){
    if(r==0)
    return 1;
    ll ans=fact[n];
    ans=(ans*ifact[r])%mod;
    ans=(ans*ifact[n-r])%mod;
    return ans;
}
vector<vector<ll> > matmul(vector<vector<ll> > v1,vector<vector<ll> > v2){
    vector<vector<ll> > v(6,vector<ll>(6,0));
    fr(i,0,6){
        fr(j,0,6){
            fr(k,0,6)
            v[i][j]=(v[i][j]+ v1[i][k]*v2[k][j])%mod;
        }
    }
    return v;
}
vector<vector<ll> > matf(ll n){
    vector<vector<ll> >z={
    {1,1,1,1,1,1},
    {1,0,0,0,0,0},
    {0,1,0,0,0,0},
    {0,0,1,0,0,0},
    {0,0,0,1,0,0},
    {0,0,0,0,1,0}},
    r={{1,0,0,0,0,0},
    {0,1,0,0,0,0},
    {0,0,1,0,0,0},
    {0,0,0,1,0,0},
    {0,0,0,0,1,0},
    {0,0,0,0,0,1}};

    while(n>0){
        if(n&1){
            r=matmul(r,z);
        }
        z=matmul(z,z);
        n/=2LL;
    }
    return r;
}*/
void solve(){
    int n;
    cin>>n;
    vector<ll> a(1e6,0);
    ll sum=0;
    fr(i,0,n){
        int x;
        cin>>x;
        a[x]++;
        sum+=x;
    }
    int q;
    cin>>q;
    while(q--){
        int b,c;
        cin>>b>>c;
        sum-=a[b]*(ll)b;
        sum+=a[b]*(ll)c;
        a[c]+=a[b];
        a[b]=0;
        cout<<sum<<endl;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
//    build();
    int t=1;
//    cin>>t;
    while(t--)
    solve();

}


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

int f;

inline int getint() {
    int s = 0, x = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') x = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * x;
}

inline void mergeTwoInts() {
    int x = getint(), y = getint();
    int ty = y;
    while (y) x *= 10, y /= 10;
    f = x + ty;
}

int main() {
    mergeTwoInts();
    for (int i = 1; i <= 317; ++i) if (f == i * i) {puts("Yes"); return 0;}
    puts("No");
    return 0;
}


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

const int N = 2e5 + 10;
int n, mark[N], dp[N];
vector <int> adj[N];

void dfs(int v, int c) {
	mark[v] = c;
	for (int u : adj[v])
		if (!mark[u])
			dfs(u, c + 1);
}

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for (int i = 1; i < n; i++) {
		int v, u;
		cin >> v >> u;
		v--; u--;
		adj[v].push_back(u);
		adj[u].push_back(v);
	}
	dfs(0, 1);
	
	int v = 0;
	for (int i = 0, mx = 0; i < n; i++)
		if (mark[i] > mx)
			mx = mark[i], v = i;
	memset(mark, 0, sizeof mark);
	dfs(v, 1);
	
	int ans = 0;
	for (int i = 0; i < n; i++)
		ans = max(ans, mark[i]);
	
	dp[1] = 1;
	for (int i = 3; i < N; i++)
		if (!dp[i - 1] || !dp[i - 2])
			dp[i] = 1;
	
	if (dp[ans])
		cout << "First";
	else
		cout << "Second";
}

Measured memory_bytes: 20608
import java.io.*;
import java.util.*;
public class Main {
    private static MyScanner scanner;

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

    private void solve() {
        try {
            int N = scanner.nextInt();
            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = scanner.nextInt();
            }
            Arrays.sort(A);
            long[] sum = new long[N];
            sum[0] = A[0];
            for (int i = 1; i < N; i++) {
                sum[i] = sum[i-1] + A[i];
            }
            int count = 1;
            for (int i = N - 2; i >= 0; i--) {
                if (A[i+1] <= sum[i] * 2) {
                    count++;
                } else {
                    break;
                }
            }
            System.out.println(count);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }

        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 46980
N, H = input().strip().split(' ')
N, H =[int(N),int(H)]
L =list()
for i in range(0,N):
    X, Y = input().strip().split(' ')
    X, Y =[int(X), int(Y)]
    L.append([X,Y])

L0 = list()
for i in range(0,N):
    L0.append(L[i][0])

L1 = list()
for i in range(0,N):
    L1.append(L[i][1])

M = max(L0)
L2 = list()

for i in range(0,N):
    if L1[i] > M:
        L2.append(L1[i])

L2 = sorted(L2)

L2 = L2[::-1]

count = 0

for i in range(0,len(L2)):
    if H > 0:
        H -= L2[i]
        count += 1
        if H <= 0:
            print(count)

if H > 0:
    if H % M == 0:
        count += H//M
        print(count)
    else:
        count = count + H//M + 1
        print(count)

Measured memory_bytes: 23076
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <queue>
#include <iomanip>
#include <iterator>

#define MOD 1000000007
#define INF 1000000001

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}


ll llpow(ll n, int a) {
    if (a == 0) {
        return 1;
    } else if (a % 2 == 0) {
        return llpow(n*n, a/2);
    } else {
        return n * llpow(n, a-1);
    }
}

int main(int argc, char const *argv[]) {
    ll X;
    cin >> X;

    bool found = false;
    ll A, B;
    for (A = 1;; ++A) {
        ll A_5 = llpow(A, 5);
        // print(A, A_5, A_5 - llpow(A-1, 5));
        if (A_5 - llpow(A-1, 5) > X) {
            break;
        }
        for (B = -A; B <= A; ++B) {
            ll B_5 = llpow(B, 5);
            if (A_5 - B_5 == X) {
                found = true;
                break;
            }
        }
        if (found) break;
    }

    cout << A << " " << B << endl;

    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  using P = pair<Int, string>;
  vector<P> v;
  for(Int i=0;i<n;i++){
    string s;Int x;
    cin>>s>>x;
    v.emplace_back(x,s);
  }
  sort(v.begin(),v.end());
  Int m,k=0,p=-1;
  cin>>m;
  for(Int i=0;i<m;i++){
    string s;
    cin>>s;
    while(k<n&&v[k].first<=p) k++;
    while(k<n&&v[k].second!=s) k++;
    if(k==n){
      cout<<"No"<<endl;
      return 0;
    }
    p=v[k].first;
  }
  cout<<"Yes"<<endl;
  
  return 0;
}



Measured memory_bytes: 12292
import java.util.Scanner;
import java.util.Arrays;

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

        int k = sc.nextInt();
        for (int i = 0; i < n; i++) {
            price[i] = sc.nextInt();
        }
        Arrays.sort(price);

        int ans = 0;

        for (int i = 0; i < k; i++) {
            ans += price[i];
        }

        System.out.println(ans);
    }
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; long long x; cin >> n >> x;
    long long b[n], l[n], u[n];
    long long req = 0;
    vector<pair<long long, int>> vp; 
    for (int i = 0; i < n; i++) {
        cin >> b[i] >> l[i] >> u[i];
        req += l[i] * b[i];
        vp.emplace_back(u[i]*x-(u[i]-l[i])*b[i], i);
    }
    sort(vp.rbegin(), vp.rend());
    vector<long long> sum(n+1, 0);
    for (int i = 0; i < n; i++) {
        sum[i+1] = sum[i] + vp[i].first;
    }
    long long ans = 1e18;
    for (int i = 0; i < n; i++) {
        long long remain, curr;
        if (sum[i+1] < req) {
            auto j = upper_bound(sum.begin(), sum.end(), req+vp[i].first) - sum.begin();
            j--;
            remain = req - (sum[j] - vp[i].first);
            curr = (j - 1) * x;
        } else {
            auto j = upper_bound(sum.begin(), sum.end(), req) - sum.begin();
            j--;
            remain = req - sum[j];
            curr = j * x;
        }
        int j = vp[i].second;
        long long d = min(b[j], (remain+l[j]-1)/l[j]);
        remain -= d * l[j], curr += d;
        if (remain > 0) {
            d = min(x-b[j], (remain+u[j]-1)/u[j]);
            remain -= d * u[j], curr += d;
        }
        if (remain <= 0) ans = min(ans, curr);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4976
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>

typedef long long ll;
using namespace std;

int main()
{
    int n, t, a, b, k=1001;
    cin >> n >> t;

    for(int i=0; i<n; i++){
        cin >> a >> b;
        if(a < k && b <= t){
            k = a;
        }
    }

    if(k == 1001){
        cout << "TLE" << endl;
    } else {
        cout << k << endl;
    }

  
    return 0;
}

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

int main() {
  int A,B;
  cin >> A >> B;
  if(A>=13){
    cout << B << endl;
  }
  else if(A>=6){
    cout << B/2 << endl;
  }
  else {
    cout << 0 <<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
void ABC150(void);
void ABC151(void);
void ABC152(void);
void ABC153(void);
void ABC154(void);
void ABC155(void);
void ABC156(void);
void ABC157(void);
void ABC158(void);
void ABC159(void);

int main(void){
    ABC150();
}

void ABC150(){
    int k,x;
    cin>>k>>x;
    if(500*k>=x)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
n = int(input())
ab = [[int(i) for i in input().split()] for j in range(n)]

wa_a_b = []

for i in range(n):
    wa_a_b.append([ab[i][0]+ab[i][1],ab[i][0],ab[i][1]])
    
wa_a_b.sort(reverse=True)

ans = 0

for i in range(n):
    if i % 2 == 0:
        ans += wa_a_b[i][1]
    else:
        ans -= wa_a_b[i][2]
        
print(ans)

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

int main() {
  string A,B,C;
  cin>>A>>B>>C;
  reverse(A.begin(),A.end());
  reverse(B.begin(),B.end());
  reverse(C.begin(),C.end());
  char next = A[A.size()-1];
  A.pop_back();
  bool flag=true;
  while(flag){
    if(next=='a'){
      if(A.size()==0){
        puts("A");
        return 0;
      }
      else {
        next = A[A.size()-1];
        A.pop_back();
      }
    }
    
    else if(next=='b'){
      if(B.size()==0){
        puts("B");
        return 0;
      }
      else {
        next = B[B.size()-1];
        B.pop_back();
      }
    }
    
    else if(next=='c'){
      if(C.size()==0){
        puts("C");
        return 0;
      }
      else {
        next = C[C.size()-1];
        C.pop_back();
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
///not today

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

#define SZ(x) (int)(x).size()
#define pb push_back
#define LL long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
//#define int long long
#define pipii pair<int, pair<int, int> >
#define pf push_front
#define accept_sho ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int32_t main(){
    int n;
    cin >>n;
    int l = 0, r = n;
    string sr, sl;
    cout <<0 <<endl;
    cin >>sr;
    sl = sr;
    if(sr == "Vacant")
        return false;
    while(r - l > 1){
        int mid = (r + l)/ 2;
        string smid;
        cout <<mid <<endl;
        cin >>smid;
        if(smid == "Vacant")
            return false;
        if((sl == smid and (mid - l)% 2) or (sl != smid and !((mid - l)% 2))){
           r = mid;
           sr = smid;
        }
        else{
            l = mid;
            sl = smid;
        }
    }
    return false;
}


Measured memory_bytes: 852
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
	string s;
	cin >> s;
	int flag1=0;
	int flag2=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='C')flag1=1;
		if(flag1==1&&s[i]=='F')flag2=1;
	}
	if(flag2==1)cout << "Yes" <<endl;
	else cout << "No" <<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <cstring>

// ---------- PBDS -----------------

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
// slow but fast ORZ :)
// ----------------------------------

using namespace std;
using namespace __gnu_pbds; 

#define MEM(a, b) memset(a, (b), sizeof(a))
#define ALL(a) a.begin(), a.end()
#define MP(a, b) make_pair(a, b)
#define PB(a) push_back(a)
#define EB(a) emplace_back(a) // care when use
#define boost ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0),cout << fixed << setprecision(10);
// #define ll long long int
#define int long long int

#define DEBUG

#ifdef DEBUG

    #define debug(args...)(Debugger()) , args

    class Debugger{
        public:
        Debugger(const std::string& _separator = " | ") :
        first(true), separator(_separator){}

        template<typename ObjectType> Debugger& operator , (const ObjectType& v)
        {
            if(!first)
                std::cerr << separator;
            std::cerr << v;
            first = false;
            return *this;
        }
        ~Debugger() {  std::cerr << std::endl;}

        private:
        
        bool first;
        std::string separator;
    };

#else
    #define debug(args...)
#endif


void solve(){

	int l, r, d;
	cin >> l >> r >> d;

	cout << (r/d) - ((l-1)/d) << "\n";

}


int32_t main(){

	boost;
	
	int T;

	// cin >> T;
	T = 1;
	
	while(T--){
		solve();
	}
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main(){
	int n;
	int t[100];
	int ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
		ans += t[i];
	}
	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		cout << ans - (t[a] - b) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p;

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

int main()
{
  ll A,B,tmp;
  cin >> A >> B;
  if(A<=B){
    tmp=B;
    B = A;
    A = tmp;
  }
  for (ll i = 0; i < A; i++) {
    cout << B;
  }
  cout << "" << endl;
}

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

typedef pair<int, int> P;
typedef long long ll;
const int INF = 100000000;

ll gcd( ll a, ll b ){//最大公約数
    ll tmp;
    if( a < b ) { tmp = a; a = b; b = tmp; }
    if( b < 1 ) return -1;

    if( a % b == 0 ) return b;
    return gcd( b, a % b );
}

ll lcm(ll a, ll b){//最小公倍数
    return a * b / gcd(a, b);
}


//入力

int main(){

    string s, t;
    int n;
    cin >> n;
    cin >> s;
    cin >> t;

    string ans = "";

    for(int i=0; i < n; i++){
        ans += s[i];
        ans += t[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
countM=0
countA=0
countR=0
countC=0
countH=0
countL=[countM, countA, countR, countC, countH]
index=0
while index < n:
    nameL = list(input())
    if nameL[0] == "M":
        countL[0]+=1
    elif nameL[0] == "A":
        countL[1]+=1
    elif nameL[0] == "R":
        countL[2]+=1
    elif nameL[0] == "C":
        countL[3]+=1
    elif nameL[0] == "H":
        countL[4]+=1
    index+=1

LLL =[]
for count in countL:
    if count!=0:
        LLL.append(count)
if len(LLL) < 3:
    print(0)
else:
    if len(LLL) == 3:
        ans=1
        for l in LLL:
            ans*=l
    elif len(LLL) == 4:
        ans = LLL[0]*LLL[1]*LLL[2] + LLL[0]*LLL[1]*LLL[3]+ LLL[0]*LLL[2]*LLL[3] + LLL[1]*LLL[2]*LLL[3]
    else:
        ans = LLL[0]*LLL[1]*LLL[2] + LLL[0]*LLL[1]*LLL[3]+ LLL[0]*LLL[1]*LLL[4] + LLL[0]*LLL[2]*LLL[3] + LLL[0]*LLL[2]*LLL[4] + LLL[0]*LLL[3]*LLL[4] + LLL[1]*LLL[2]*LLL[3] + LLL[1]*LLL[2]*LLL[4] + LLL[1]*LLL[3]*LLL[4] + LLL[2]*LLL[3]*LLL[4]
    print(ans)

Measured memory_bytes: 3188
if __name__ == '__main__':
    n = int(input())
    voted = {}
    for i in range(n):
        s = input()
        if s in voted:
            voted[s] += 1
        else:
            voted[s] = 1

    # print(voted)

    max_count = 0
    max_list = []
    for k, v in voted.items():
        if max_count == v:
            max_list.append(k)
        elif max_count < v:
            max_list = [k]
            max_count = v

    # print(max_list, max_count)

    for j in sorted(max_list):
        print(j)

Measured memory_bytes: 32984
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;

int main()
{
  string s; 
  cin >> s;
  vector<int> a;
  REP(i,SZ(s)){
    a.push_back(s[i]);
  }
  string r;
  vector<int> t;
  if (SZ(s)==26){
    for(int i=25;i>=0;i--){
      
      sort(all(t));   
      REP(j,SZ(t)){
        if(a[i]<t[j]){
          r = s.substr(0,i) + (char)t[j];
          goto final;
        }
      } 
      t.push_back(a[i]);
       
       
    } 
    r = "-1";
  }
  else{
  sort(all(a));
    for(int i=0;i<=25;i++){
       if(a[i] != i+97){
         r = s + ((char)(i+97)); 
         break;
       } 
    }
  }
  final:
  cout << r << endl; 
}



Measured memory_bytes: 256