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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

// 人生ね
inline int add(unsigned x, int y) {
  x += y;
  if(x >= mod) x -= mod;
  return (x);
}

inline int mul(int a, int b) {
  unsigned long long x = (long long) a * b;
  unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
  asm("divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod));
  return (m);
}

int N, K, V[600];
int64 pre[600][600];
int64 dp[600][600];

int64 rec(int l, int r) {
  l %= N;
  r %= N;
  if(pre[l][r] == 0) return 0;
  if(l == r) return 0;
  if((l + 1) % N == r) return pre[l][r];
  if(~dp[l][r]) return dp[l][r];
  int64 ret = 0;
  if(l == 0 && r == N - 1) {
    for(int m = 0; m < N; m++) {
      for(int n = 0; n < N; n++) {
        if((m + N - 1) % N == n) continue;
        if(m <= n && m >= 1) continue;
        ret = add(ret, mod - mul(rec(m, n), pre[(n + 1) % N][(m + N - 1) % N]));
      }
    }
  } else if(l > r) {
    for(int m = l; m < r + N; m++) {
      ret = add(ret, mod - mul(rec(l, m), pre[(m + 1) % N][r % N]));
    }
  } else {
    for(int m = l; m < r; m++) {
      ret = add(ret, mod - mul(rec(l, m), pre[(m + 1) % N][r % N]));
    }
  }
  ret = add(ret, pre[l][r]);
  return dp[l][r] = ret;
}

bool v[600];

int64 LatteMalta(int l, int r) {
  memset(v, false, sizeof(v));
  if(l > r) r += N;
  for(int i = l; i <= r; i++) {
    v[i % N] = true;
  }
  int space = 0;
  for(int i = l; i <= r; i++) {
    if(V[i % N] == -1) {
      ++space;
    } else {
      if(!v[V[i % N]]) return 0;
    }
  }
  if(space & 1) return 0;
  int64 ret = 1;
  while(space > 0) {
    --space;
    ret = mul(space, ret);
    --space;
  }
  return ret;
}

int main() {
  memset(V, -1, sizeof(V));
  memset(dp, -1, sizeof(dp));

  cin >> N >> K;
  N *= 2;
  for(int i = 0; i < K; i++) {
    int p, q;
    cin >> p >> q;
    --p, --q;
    V[p] = q;
    V[q] = p;
  }
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) {
      pre[i][j] = LatteMalta(i, j);
    }
  }

  int64 ret = rec(0, N - 1);

  for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) {
      if((i + N - 1) % N == j) continue;
      if((j + 1 + N - 1) % N == (i + N - 1) % N) continue;
      (ret += rec(i, j) * pre[(j + 1) % N][(i + N - 1) % N] % mod) %= mod;
    }
  }
  cout << ret << endl;
}


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

int main(){
    int N;
    cin >> N;
    int a = 0;
    if(N < 2){
        a = 1;
    }else if (N < 4){
        a = 2;
    }else if (N < 8){
        a = 4;
    }else if (N < 16){
        a = 8;
    }else if (N < 32){
        a = 16;
    }else if (N < 64){
        a = 32;
    }else{
        a = 64;
    }

    cout << a << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end(), greater<int>());
    int A=0, B=0;
    for (int i = 0; i < (N / 2); i++ ) {
        A += a.at(i*2);
        B += a.at(i*2+1);
    }
    if (N % 2 == 1) A += a.at(a.size()-1);

    cout << A - B << endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>



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

using namespace std;
int n;
string s;

int main(){
  cin >> n;
  s = to_string(n);
  int k =0;
  REP(i,s.size()){
    k += s[i]-'0';
  }
  if(n%k==0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int N;
  rd(N);
  wt_L((N-1)/2);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191108-1

// --- original code ---
// {
//   int N;
//   rd(N);
//   wt((N-1)/2);
// }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
string s,t;
int tot;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>s>>t;
	for(int i=0;i<s.size();i++) if(s[i]!=t[i]) tot++;
	cout<<tot<<endl;
	return 0;
}


Measured memory_bytes: 3776
import re
a = input()
b = input()
c = re.search('(\d+)\s(\d+)', a)
d = int(c.group(1))
e = int(c.group(2))
result = ''
for n in range(d):
    if n == e - 1:
        r = str(b[n]).lower()
        result += r
    else:
        result += b[n]
print(result)


Measured memory_bytes: 3188
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}


 main()

{
    fast
    int n,m;
    cin>>n>>m;
    int cnt=0;
    int a[n+43];
    int sum=0;
    f(i,1,n)
    {
        cin>>a[i];
        sum+=a[i];
    }
    int val=(sum+(4*m)-1)/(4*m);
    f(i,1,n)
    {
        int x=a[i];
        if(x>=val)cnt++;
    }
    if(cnt>=m)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;

}













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

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

    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for(int i = 1; i <= s.size(); i++) {
        if(s[i] != s[i - 1])
            ans++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3728
import java.util.*;
 
public class Main {
    static long mod = (long)Math.pow(10,9)+7;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        System.out.println(solve(N,M));
    }
    static long solve(int N, int M){
        if(Math.abs(N-M)>=2){
            return 0;
        }
        if(Math.abs(N-M)==1){
            return factorial(N)*factorial(M)%mod;
        }
        return 2*factorial(N)*factorial(M)%mod;
    }
    static long factorial(int X){
        long r = 1;
        for(int i=2; i<=X; i++){
            r*=i;
            r%=mod;
        }
        return r;
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
using namespace std;
 
int main(){
  int N,Q;
  string S;
  cin>>N>>Q;
  cin>>S;
  int dp[N];
  int l;
  int r;
  int ans;
  
  dp[0]=0;
  for(int i=1;i<N;i++){
    if(S[i-1]=='A' && S[i]=='C'){
      dp[i]=1+dp[i-1];
    }else{
      dp[i]=dp[i-1];
    }
  }
  
  for(int i=0;i<Q;i++){
    cin>>l>>r;
    ans = dp[r-1]-dp[l-1];
    cout<<ans<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <cstdlib>
#include <climits>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

#define FOR(var,start,end) for(int var=start; var<end; var++)
#define REP(var,cnt) FOR(var,0,cnt)

int main(void) {
	string a1, a2;
	cin >> a1 >> a2;
	
	string b1, b2;
	b1 = a1; reverse(b1.begin(), b1.end());
	b2 = a2; reverse(b2.begin(), b2.end());
	
	if ( a1 == b2 && a2 == b1 ) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }
	
	return 0;
	
}

Measured memory_bytes: 764
#include <stdio.h>

int main() {
	int Cards[4][13], cnt, t_num;

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			Cards[i][j] = 1;
		}
	}

	char cha;
	scanf("%d", &cnt);
	
	for (int i = 0; i < cnt; i++) {
		scanf("%c", &cha);
		scanf("%c %d", &cha, &t_num);
		if (cha == 'S') {
			Cards[0][t_num - 1] = 0;
		}
		else if (cha == 'H') {
			Cards[1][t_num - 1] = 0;
		}
		else if (cha == 'C') {
			Cards[2][t_num - 1] = 0;
		}
		else if (cha == 'D') {
			Cards[3][t_num - 1] = 0;
		}
		else{printf("Error root\n");}
	}

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			if (Cards[i][j] == 1) {
				if (i == 0) {
					printf("S %d\n", j + 1);
				}
				else if (i == 1) {
					printf("H %d\n", j + 1);
				}
				else if (i == 2) {
					printf("C %d\n", j + 1);
				}
				else if (i == 3) {
					printf("D %d\n", j + 1);
				}
				else {}
			}
		}
	}

	return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=1e5+5;
pair< ll , ll > a[505];
ll ans[505*505];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>a[i].first;
        a[i].second=i;
        ans[a[i].first]=a[i].second;
    }
    sort(a+1,a+n+1);
    ll now=1;
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<a[i].second;j++){
            while(ans[now] && now<=n*n)now++;
            if(now>n*n)return cout<<"No"  , 0;
            ans[now]=a[i].second;
        }
        if(now > a[i].first )return cout<<"No" , 0;
    }
    now=n*n;
    for(ll i=n;i>=1;i--){
        for(ll j=a[i].second+1;j<=n;j++){
            while(ans[now] && now>=0 )now--;
            ans[now]=a[i].second;
        }
        if(now<a[i].first)return cout<<"No" , 0;
    }

    for(ll i=1;i<=n*n;i++)if(!ans[i])return cout<<"No" , 0;

    cout<<"Yes\n";
    for(ll i=1;i<=n*n;i++)cout<<ans[i]<<" ";
}



Measured memory_bytes: 3200
n = gets.chomp.to_i
digit = n.to_s.split("")

r = 0
for i in (1 .. digit.length) do
	next if (i % 2 == 0)
	s = 10 ** (i - 1)
	s = 1 if (i == 1)
	e = (10 ** i) - 1
	e = n if(i == digit.length)
	r += (e - s + 1)
end

puts r


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

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

Measured memory_bytes: 256
# O(K log K) solution
# use -score for O(1) pop

require 'set'

_, _, _, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
bs = gets.split.map(&:to_i)
cs = gets.split.map(&:to_i)

as.sort!.reverse!
bs.sort!.reverse!
cs.sort!.reverse!

# priority queue like
comb = Set.new
ans = []

score = ->(a, b, c) { as[a] + bs[b] + cs[c] }

init = [0, 0, 0]
comb << [score[*init], *init]

k.times do
  t = comb.max_by(&:first)
  comb.delete(t)
  s, a, b, c = t
  ans << s

  opts = [
    [a + 1, b, c],
    [a, b + 1, c],
    [a, b, c + 1],
  ]
  opts.select! { |abc| score[*abc] rescue false }
  opts.map! { |abc| [score[*abc], *abc] }
  comb.merge(opts)
end

p(*ans)


Measured memory_bytes: 5368
#include <stdio.h>

int	sqrt(int nb)
{
	int i;

	i = 1;
	while (i <= nb)
	{
		if (i % 2)
			nb -= i;
		i++;
	}
	return (i);
}

int	prime(int nb)
{
	int i;

	if (nb < 2)
		return (0);
	if (nb == 2)
		return (1);
	i = 2;
	while (i <= sqrt(nb))
	{
		if (nb % i == 0)
			return (0);
		i++;
	}
	return (1);
}

int	next_prime(int nb)
{
	while (1)
	{
		if (!prime(nb))
			nb++;
		if (prime(nb))
			break ;
	}
	return (nb);
}

int	main(void)
{
	int x;
	scanf("%d", &x);
	printf("%d", next_prime(x));
	return (0);
}


Measured memory_bytes: 128
n = int(input())
s = str(input())

east = s.count("E")
west = 0
ans = 300000
for i in range(n):
    if s[i] == "E":
        east -= 1
    ans = min(ans, east + west)
    if s[i] == "W":
        west += 1

print(ans)


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

int main(int argv, char *argc[]){
    int midexam, termexam, retest, sum;
    
    while(1){
        scanf("%d %d %d\n", &midexam, &termexam, &retest);
        
        if((-1 == midexam) & (-1 == termexam) & (-1 == retest)) break;
        
        sum = midexam + termexam;
        
        if((-1 == midexam) | (-1 == termexam)) printf("F\n");
        else if(80 <= sum) printf("A\n");
        else if(65 <= sum & 80 > sum) printf("B\n");
        else if((50 <= sum & 65 > sum) | (30 <= sum & 50 > sum & 50 <= retest))printf("C\n");
        else if(30 <= sum & 50 > sum) printf("D\n");
        else if(30 > sum) printf("F\n");
    }
    
    return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using P = pair<long long,int>;
int n, a;
long long dp[2005][2005], ans;
P p[2005];
int main(){
	scanf("%d", &n);
	rep(i,n){
		scanf("%d", &a);
		p[i] = P{a, i};
	}
	sort(p, p+n, greater<P>());
	for(int i=1; i<=n; i++) for(int j=0; j<=i; j++){
		dp[i][j] =max((j?dp[i-1][j-1] + p[i-1].first * (p[i-1].second - (j-1)):0), (i!=j?dp[i-1][j] + p[i-1].first * (n-(i-j)-p[i-1].second):0));
	}
	rep(i,n+1) ans = max(ans, dp[n][i]);
	printf("%lld\n", ans);
}

Measured memory_bytes: 26364
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		// String[] strArr = str.split("\\s+");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);

		int X = Integer.parseInt(str);
		int ans = 0;
		ans += (X / 500) * 1000;
		X = X % 500;
		ans += (X / 5) * 5;
		System.out.println(ans);

	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


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


int main() {
    vector <int> a(100);
    int N;
    int sum1 = 0;
    int sum2 = 0;
    cin >> N;
    for(int i=0;i<N;++i){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    
    for(int i=0;i<N;++i){
        if(i%2==0){
            sum1 += a.at(i);
        }
        else{
            sum2 += a.at(i);
        }
        
    }
    cout << sum1-sum2 <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

signed main(){
    ll n;
    string s;
    cin >> n >> s;
    ll cnt[3] = {},ans = 0;

    rep(i,0,n){
        ll temp = 0;
        switch(s[i]){
            case 'G': temp++;
            case 'B': temp++;
        }
        cnt[temp]++;
    }
    ans = cnt[0]*cnt[1]*cnt[2];

    rep(i,1,n){
        rep(j,0,n-i*2){
            if(s[j] != s[j+i] && s[j+i] != s[j+i*2] && s[j] != s[j+i*2]){
                ans--;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node{
    int key;
    Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
    Node *cur = nil->next;
    while(cur != nil && cur->key != key){
        cur = cur ->next;
    }
    return cur;
}

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList(){
    Node *cur = nil->next;
    int isf = 0;
    while(1){
        if(cur==nil) break;
        if(isf++>0)printf(" ");
        printf("%d",cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(Node *t){
    if(t ==nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteKey(int key){
    deleteNode(listSearch(key));
}

void insert(int key){
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main(){
    int key,n,i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d",&n);
    init();
    for(i=0;i<n;i++){
        scanf("%s%d",com,&key);
        if(com[0]=='i'){insert(key); np++; size++;}
        else if(com[0]=='d'){
            if(strlen(com) > 6){
                if(com[6]=='F') deleteFirst();
                else if(com[6]=='L') deleteLast();
            }
            else{
                deleteKey(key); nd++;
            }
            size--;
        }
    }
    printList();
}

Measured memory_bytes: 32216
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>
#include <iomanip>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  for(int N, M; cin >> N >> M && (N|M);) {
    bool f = 0;
    rep(i, M) {
      int _; cin >> _;
      f |= _ == 1;
    }
    printf("%.10f\n", f ? 0 : N / 2.0);
  }

  
  return 0;
}

Measured memory_bytes: 3140
# https://takeg.hatenadiary.jp/entry/2019/11/22/212816
# https://drken1215.hatenablog.com/entry/2019/10/20/032700

import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0

for a in range(N):
    for b in range(a+1, N):
        c = bisect.bisect_left(L, L[a] + L[b])
        # print(a, b, c)
        ans += max(c-(b+1), 0)
        # print(ans)

print(ans)


Measured memory_bytes: 74220
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e14;

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

    vector<ll> a(n);
    ll sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }

    ll s1 = 0, s2;
    ll ans = INF;
    rep(i, n) {
        s1 += a[i];
        s2 = sum - s1;
        ans = min(ans, abs(s1 - s2));
    }

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

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
// #define DEBUG 100
 
using namespace std;
using ll = unsigned long long;
using pii = pair<int, int>;
 
const int oo = 1e9 + 7;
const ll mod = 1e9 + 7,maxn = 100010;
const double PI = acos(-1);
 
int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0); 
    int x, y, a[] = {1, 3, 5 ,7 ,8, 10, 12};
    cin >> x >> y;
 
    int cnt = 0;
 
    for (int i=0; i<7; i++){
        if (x == a[i] || y == a[i]) cnt++;
    }
    if (cnt == 2) {
        cout << "Yes" << endl;
        return 0;
    }
    if (cnt == 1 || x == 2 || y == 2) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
    return 0;
}

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

#define vi vector<int>
#define vl vector<long long>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define vp vector<P>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPD(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORD(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define INF 1e18
#define INFTY 1e9
const int mod = 1e9+7;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

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

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

//cout << fixed << setprecision(10) << y << endl;
struct edge {int to, cost;};
vector< vector<edge> > es;
const int MAX_N = 10010;

int main() {
    ll A;
    string s;
    ll B = 0;
    cin >> A;
    cin >> s;
    B += (s[0]-'0')*100;
    B += (s[2]-'0')*10;
    B += (s[3]-'0');
    ll res = A*B;
    res /= 100;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int mod = 1e9+7;
ll gcd(ll a,ll b){
    if(b==0)
    return a;return gcd(b,a%b);
}
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){
        if(pow&1==1){
            ans = ans*base;
            ans = ans%mod;
        }
        base *= base;base%=mod;
        pow/=2;
    }return ans;
}
ll inv(ll x){
    return expo(x,mod-2);
}
 
const int M = 2e5 + 5;


int main(){
    int n, k;
    cin >> n >> k;
    vector <ll> vec1, vec2;
    ll ans1 = 1LL;
    for(int i = 0; i < n; i++){
        ll n1;
        cin >> n1;
        if(n1 >= 0) vec1.push_back(n1);
        else vec2.push_back(n1);
        if(k == n){
            ans1 = (ans1*n1)%mod;
        }
    }
    if(k == n){
        if(ans1 < 0) ans1 += mod;
        cout << ans1;
        return 0;
    }
    if(vec1.size() == 0){
        sort(vec2.begin(), vec2.end());
        reverse(vec2.begin(), vec2.end());
        ll ans = 1LL;
        if(k%2){
           for(int i = 0; i < k; i++){
               ans = (ans*vec2[i])%mod;
               //cout << ans << endl;
           }
           //cout << ans << " || " << endl;
           if(ans < 0) ans += mod;
           cout << ans;
        } else{
            for(int i = vec2.size()-1; i >= vec2.size()-k; i--){
                 ans = (ans*vec2[i])%mod;
            }
            cout << ans;
        }
        return 0;
    }
    if(vec2.size() == 0){
        ll ans = 1LL;
         sort(vec1.begin(), vec1.end());
        // cout << vec1.size()-k << "|" << endl;
         int n1 = vec1.size();
        for(int i = vec1.size()-1; i >= n1-k; i--){
                 ans = (ans*vec1[i])%mod;
                 //cout << ans << endl;
        }
        cout << ans;
        return 0;
    }
    sort(vec1.begin(), vec1.end());
    sort(vec2.begin(), vec2.end());
    
    int ind1 = max((int)vec1.size()-k, 0);
    int ind2 = max(0, k - (int)vec1.size()); 
    if(ind2%2){
        ind2++; ind1++;
    }
    while(ind1+1 < vec1.size() && ind2+1 < vec2.size()){
          if(vec1[ind1]*vec1[ind1+1] < vec2[ind2]*vec2[ind2+1]){
              ind1 += 2; ind2 += 2;
          } else break;
    }
    ll ans = 1LL;
    for(int i = 0; i < ind2; i++) ans = (ans*vec2[i])%mod;
    for(int i = ind1; i < vec1.size(); i++) ans = (ans*vec1[i])%mod;
    
    cout << ans;
    
}


Measured memory_bytes: 5380
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



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

	int n, k, sum;
	cin >> n >> k >> sum;
	vector<int> a(n);
	if(sum == pow(10, 9)) fill(all(a), 1);
	else fill(all(a), sum+1);
	rep(i, k) a[i] = sum;
	rep(i, n) cout << a[i] << " ";
	return 0;
}

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

int main() {
  int  X, Y;
  cin >> X >> Y;
  
  if ( X==1 || X==3 || X==5 || X==7 || X==8 || X==10 || X==12 ) {
    if ( Y==1 || Y==3 || Y==5 || Y==7 || Y==8 || Y==10 || Y==12 ) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  if ( X==2 ) {
    if ( X==Y ) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  if ( X==4 || X==6 || X==9 || X==11 ) {
    if ( Y==4 || Y==6 || Y==9 || Y==11 ) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353,INF=1e18;



int main() {
    int x,y;
    cin>>x>>y;
    if(y>=2*x && y<=4*x && y%2==0){
        cout<<"Yes"<<endl;
    }
    else{cout<<"No"<<endl;}
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

int main(){
  ll A,B;cin>>A>>B;
  cout<<A*B<<endl;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int>A(n);
    vector<ll>a;
    rep(i,n){
        cin >> A[i];
    }
    rep(i,n){
        ll sum = 0;
        for(int j = i; j< n; j++){
            sum += A[j];
            a.push_back(sum);
        }
    }
    //for(auto x:a)cout << x << endl;
    ll ans = 0;
    for(int i = 60; i>=0; i--){
        int c = 0;
        rep(j,a.size()){
            if(a[j]&(1LL<<i))c++;
        }
        if(c>=k){
            ans += (1LL<<i);
            rep(j,a.size())if((a[j]&(1LL<<i)) == 0){
                a[j] = 0;
            }
        }
    }
    cout << ans << endl;
}


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

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

    int half = (n+1) / 2;
    string ans;
    if(half < k){
        ans = "NO";
    } 
    else{
        ans = "YES";
    }

    cout << ans << endl;
}

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

int partition(int a[],int p,int r){
    int x=a[r],i=p-1;
    for(int j=p;j<r;j++){
        if(a[j]<=x){
            swap(a[++i],a[j]);
        }
    }
    swap(a[++i],a[r]);
    return i;
}

int main(){
    int n,a[NMAX];
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    int q=partition(a,0,n-1);
    for(int i=0;i<n;i++){
        if(i) cout<<' ';
        if(i==q) cout<<'[';
        cout<<a[i];
        if(i==q) cout<<']';
    }
    cout<<endl;
}


Measured memory_bytes: 3468
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1};
vl dy={1,-1,0,0};

//素因数分解O(√n)
map<ll,ll>prime_factor(ll n){
  map<ll,ll>res;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}

const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
//finvが階乗の逆元

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n, ll mod) {
  
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}



int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  string s,t;cin>>s>>t;
  ll cnt=0;
  rep(i,s.size()){
    if(s[i]!=t[i])cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3792
class UnionFind:
  def __init__(self, N):
    self.r = [-1]*N
  
  def root(self, x):
    if self.r[x] < 0:
      return x
    else:
      self.r[x] = self.root(self.r[x])
      return self.r[x]
  
  def unite(self, x, y):
    x = self.root(x)
    y = self.root(y)
    if x == y:
      return False
    else:
      if self.r[x] > self.r[y]:
        x, y = y, x
      self.r[x] += self.r[y]
      self.r[y] = x
      return True
    
  def size(self, x):
    return -1*self.r[self.root(x)]
  
  def print(self):
    print(self.r)


N, M = map(int, input().split())

UF = UnionFind(N)

for _ in range(M):
  a, b = map(int, input().split())
  UF.unite(a-1, b-1)

ans = 0
for i in range(N):
  ans = max(ans, UF.size(i))

print(ans)

Measured memory_bytes: 14500
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;



int main() {
	int n;
	cin >> n;
	vector<int>x(n),ans(n);
	rep(i, n) {
		scanf("%d", &x[i]);
	}
	ans = x;
	sort(all(x));
	int ans1 = x[n / 2 - 1];
	int ans2 = x[n / 2];
	
	rep(i, n) {
		int answer = 0;
		if (ans[i] <= ans1) {
			answer = ans2;
		}
		else {
			answer = ans1;
		}
		printf("%d\n", answer);
	}

}



Measured memory_bytes: 3712
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

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

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

    //cout << fixed << setprecision(15);

    string s;
    cin >> s;

    int cnt = 0, ans = 0;
    int n = s.size();
    for (int i = 0; i < n; ++i)
    {
        if (s[i] == 'g')
        {
            if (cnt)
            {
                ans++;
                cnt--;
            }
            else
            {
                cnt++;
            }
        }
        else
        {
            if (!cnt)
            {
                ans--;
                cnt++;
            }
            else
            {
                cnt--;
            }
        }
    }

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
    cin >> a >> b;
    if ((a%2==0 and b%2==0) or (a%2==1 and b%2==1)) cout << (a+b)/2 << endl;
    else cout << "IMPOSSIBLE" << endl;
 
    return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 1001001001;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

const int MAX = 999999 + 1;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

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

    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    // __| がA |`が Bとする
    int b = (2 * y - x) / 3;
    int a = y - 2 * b;

    assert(2 * a + b == x);
    assert(2 * b + a == y);
    COMinit();
    ll ans = COM(a + b, a);

    cout << ans << endl;

}



Measured memory_bytes: 23808
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  long n,k;
  cin >> n >> k;
  vector<pair<long,long>> p(n);
  long a,b;
  rep(i,n){
    cin >> a >> b;
    p.at(i).first = a;
    p.at(i).second = b;
  }
  sort(p.begin(),p.end());
  rep(i,n){
    k -= p.at(i).second;
    if(k <= 0){
      cout << p.at(i).first << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1792
#include <iostream>
#include <queue>
#include <string>
using namespace std;


int main()
{
    string s;
    int k;
    priority_queue<int> que;
    while(cin >> s, s != "end"){
        if(s == "insert"){
            cin >> k;
            que.push(k);
        } else {
            cout << que.top() << endl;
            que.pop();
        }
    }
}

Measured memory_bytes: 5980
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int A = line[0];
            int B = line[1];
            if (A == 1)
            {
                A = 14;
            }
            if (B == 1)
            {
                B = 14;
            }

            string ans = "";
            if (A > B)
            {
                ans = "Alice";
            }
            else if (B > A)
            {
                ans = "Bob";
            }
            else
            {
                ans = "Draw";
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int N=3009;
int main()
{
    FASTINOUT;
    char a;
    cin>>a;
    if (a>='a'&&a<='z')
        cout<<'a';
    else
        cout<<'A';
    return 0;
}


Measured memory_bytes: 3608
import java.util.*;
public class Main {
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    
    long minCapacity = Long.MAX_VALUE;
    int minCapacityIndex = 0;
    long[] capacity = new long[5];
    for (int i = 0; i < 5; i++) {
      capacity[i] = sc.nextLong();
      if (capacity[i] < minCapacity) {
        minCapacity = capacity[i];
        minCapacityIndex = i;
      }
    }
    
    long ans = (N-1) / minCapacity + 5;

    System.out.println(ans);
  }  
}

Measured memory_bytes: 21844
import java.util.*;
class Main {
  public static void main (String[] args)  {
    
    Scanner sc = new Scanner(System.in);
    
    int n=sc.nextInt();
    double t=sc.nextDouble();
    double a=sc.nextDouble();
    
    double h=0;
    double x=0;
    
    double tmp=100000;
    
    int ans=0;
    
    
    for(int i=1; i<n+1;i++){
      h=sc.nextDouble();
      x=t-h*6/1000;
      if( Math.abs(x-a)<tmp){
        tmp=Math.abs(x-a);
        ans=i;
        }
     }
     
     
      System.out.println(ans);
     


  }
}

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

int main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  long long num, ans = 0;
  priority_queue<long long>p, q, r;
  priority_queue<long long, vector<long long>, greater<long long>>s;
  for (int i = 0; i < A; i++) {
    cin >> num;
    p.push(num);
  }
  for (int i = 0; i < B; i++) {
    cin >> num;
    q.push(num);
  }
  for (int i = 0; i < C; i++) {
    cin >> num;
    r.push(num);
  }
  if (A < X) {
    for (int i = 0; i < X-A; i++) {
      num = r.top();
      r.pop();
      s.push(num);
    }
    while (!p.empty()) {
      num = p.top();
      p.pop();
      s.push(num);
    }
  }
  else {
    for (int i = 0; i < X; i++) {
      num = p.top();
      p.pop();
      s.push(num);
    }
  }
  if (B < Y) {
    for (int i = 0; i < Y-B; i++) {
      num = r.top();
      r.pop();
      s.push(num);
    }
    while (!q.empty()) {
      num = q.top();
      q.pop();
      s.push(num);
    }
  }
  else {
    for (int i = 0; i < Y; i++) {
      num = q.top();
      q.pop();
      s.push(num);
    }
  }
  while ((!r.empty()) && (!s.empty())) {
    if (r.top() > s.top()) {
      s.pop();
      s.push(r.top());
      r.pop();
    }
    else {
      break;
    }
  }
  while (!s.empty()) {
    ans += s.top();
    s.pop();
  }
  cout << ans;
}

Measured memory_bytes: 4724
import java.util.Scanner;
class Main{
  public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  String s = sc.next();
  String t = sc.next();
  int a = Integer.parseInt(sc.next());
  int b = Integer.parseInt(sc.next());
  String u = sc.next();
  if(s.equals(u)){
  a--;
  }else{
  b--;
  }
  System.out.println(a+" "+b);
  }
}

Measured memory_bytes: 23380
#include <iostream>
#include <algorithm>

int main()
{
        int x[3];
        std::cin >> x[0] >> x[1] >> x[2];

        std::sort(std::begin(x), std::end(x));
        std::cout << (x[2] * 10 + x[1] + x[0]) << std::endl;
}

Measured memory_bytes: 256
#a,b=map(int,input().split())
s=input()
n=len(s)
wayA=[0,0,0,0]
wayB=[0,0,0,0]
wayC=[0,0,0,0]
hatena=0
MOD=1000000007
for c in s:
	if c=="A":
		wayA[0]=wayA[0]+1
	if c=="B":
		wayB[0]=wayB[0]+wayA[0]
		wayB[1]=wayB[1]+wayA[1]
	if c=='C':
		wayC[0]=wayC[0]+wayB[0]
		wayC[1]=wayC[1]+wayB[1]
		wayC[2]=wayC[2]+wayB[2]
	if c=='?':
		wayC[1]=wayC[1]+wayB[0]
		wayC[2]=wayC[2]+wayB[1]
		wayC[3]=wayC[3]+wayB[2]
		wayB[1]=wayB[1]+wayA[0]
		wayB[2]=wayB[2]+wayA[1]
		wayA[1]=wayA[1]+1
		hatena=hatena+1
	for z in range(0,4):
		wayA[z]=wayA[z]%MOD
		wayB[z]=wayB[z]%MOD
		wayC[z]=wayC[z]%MOD
ans=0
for i in range(0,4):
	p3=1
	for k in range(0,hatena-i):
		p3=p3*3
		p3=p3%MOD
	ans=ans+p3*wayC[i]
ans = ans%1000000007
print(int(ans))

Measured memory_bytes: 3444
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int n; cin >> n;
  vector<map<char, int>> S(n, map<char, int>());
  rep(i, n) { 
    string s_tmp; cin >> s_tmp;
    rep(j, s_tmp.length()) S[i][s_tmp[j]]++;
  }

  for (auto x: S[0]) {
    int tmp = x.second;
    rep(i, n) tmp = min(tmp, S[i][x.first]);
    rep(i, tmp) cout << x.first;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	ll out = 1;
	int n; cin >> n;
	queue<int> q;
	int isp[1001];
	fill(isp, isp + 1001, 1);
	for (int i = 2; i <= n; i++) {
		if (isp[i]) {
			q.push(i);
			for (int j = 2*i; j <= n; j += i) {
				isp[j] = 0;
			}
		}
	}
	while (!q.empty()) {
		int x = q.front(); q.pop();
		int csum = 1;
		int cop = n;
		while (cop) {
			cop /= x; csum += cop;
		}
		out = out * (ll)csum%MOD;
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>    
#include <cstring>
#include <array>
#include <cctype>
#include <string.h>
#include <vector>
#include <limits.h>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cassert>
#include <algorithm>
#include <functional>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <stdio.h>
#include <bitset>
using namespace std;
#define PI 3.14159265359
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) FOR(i,0,n)
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const int INF = 1<<29;
typedef long long ll;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ll a,b;

int main(){
	ios_base::sync_with_stdio(false); //Fast I/O
	cin.tie(NULL);
	//freopen("in.txt","r",stdin);
	//freopen("output.txt","w",stdout);	

	cin >> a >> b;

	int ans=0;

	for(int i=1;i<=b-a;i++)
		ans+=i;
	ans-=b;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())
T,A = [0 for i in range(N)],[0 for i in range(N)]
for i in range(N):
    T[i],A[i] = map(int,input().split())
a = 1
b = 1
for i in range(N):
    low = 0
    high = 10**18
    while high - low > 1:
        x = (high + low) // 2
        if a <= T[i] * x and b <= A[i] * x:
            high = x
        else:
            low = x
    a = high * T[i]
    b = high * A[i]
print(a + b)

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long 
int INF=INT_MAX;
int main(){
  ll n;
  cin>>n;
  vector<int>a(n);
  multiset<int>m;
  rep(i,n)cin>>a[i];
  int kotae=0;
  rep(i,n){
    auto Iter = m.lower_bound(a[i]);
    if(Iter!=m.begin())m.erase(--Iter);
    m.insert(a[i]);
  }
  kotae=m.size();
  cout<<kotae<<endl;
  return 0;
}


Measured memory_bytes: 8240
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, m, a[100100], i, ans=0, hyou=0;
    double ki;
    cin >> n >> m;
    for(i=0;i<n;i++){
        cin >> a[i];
        hyou+=a[i];
    }
    ki=(double)hyou/(4*m);
    for(i=0;i<n;i++){
        if(a[i]>=ki) ans++;
    }
    if(ans>=m) cout << "Yes" <<endl;
    else cout << "No" <<endl;
    return 0;
}

Measured memory_bytes: 256