akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int wlands[100][100];
void wfill(int i,int j,int w,int h)
{
  if(0<=i && i<w && 0<= j && j<h && wlands[j][i] == '.'){
    wlands[j][i]='W';
    wfill(i-1,j,w,h);
    wfill(i+1,j,w,h);
    wfill(i,j-1,w,h);
    wfill(i,j+1,w,h);
  }
}
int blands[100][100];
void bfill(int i,int j,int w,int h)
{
  if(0<=i && i<w && 0<= j && j<h && blands[j][i] == '.'){
    blands[j][i]='B';
    bfill(i-1,j,w,h);
    bfill(i+1,j,w,h);
    bfill(i,j-1,w,h);
    bfill(i,j+1,w,h);
  }
}
int main(void)
{
  for(;;){
    string line;
    int w,h,answer=0,white=0,black=0;
    cin >> w >> h;
    if(!w&&!h) return 0;
    REP(j,h){
      cin >> line;
      REP(i,w){
	wlands[j][i]=line[i];
	blands[j][i]=line[i];
	if(line[i] == 'W') white--;
	if(line[i] == 'B') black--;
      }
    }
    REP(j,h){
      REP(i,w){
	if(wlands[j][i]=='W'){
	  wfill(i-1,j,w,h);
	  wfill(i+1,j,w,h);
	  wfill(i,j-1,w,h);
	  wfill(i,j+1,w,h);
	}
	if(blands[j][i]=='B'){
	  bfill(i-1,j,w,h);
	  bfill(i+1,j,w,h);
	  bfill(i,j-1,w,h);
	  bfill(i,j+1,w,h);
	}
      }
    }
    REP(j,h){
      REP(i,w){
	if(wlands[j][i]=='W' && blands[j][i]!='B') white++;
	if(wlands[j][i]!='W' && blands[j][i]=='B') black++;
      }
    }
    cout << black << ' ' << white << endl;
  }
}

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


int main () {
    ll n; cin >> n;
    vector <ll> v;
    ll aux;
    for(ll i = 0; i < n; i++) {
        cin >> aux;
        v.push_back(aux);
    }

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

    ll resp = v[v.size()-1];
    ll resp_i = n-2;
    ll num = resp_i/2;
    ll i;
    for(i = 0; i < num; i++) {
        resp += 2*(v[v.size()-i-2]);
    }
    if(resp_i%2 != 0) {
        resp += v[v.size()-i-2];
    }
    
    cout << resp << endl;
    return 0;
}

Measured memory_bytes: 5360
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pa = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const long double EPS = 1e-11;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//--------------------------------------------------------------------------------//
//factl
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;
}

ll mod = 1e9 + 7;
vl factl(1e6 + 1, 1), invl(1e6 + 1, 1);
ll factl_init(ll num) {
    for (ll i = 1; i < 1e6 + 1; i++) factl[i] = factl[i - 1] * i % mod;
    invl[0] = modpow(factl[factl.end() - factl.begin() - 1], mod - 2, mod);
    repe(i, 1, 1e6 + 1) invl[i] = invl[i - 1] * (ll)(1e6 - i + 1) % mod;
    reverse(all(invl));
}

ll comb(ll a, ll b) {
    return factl[a] * invl[b] % MOD * invl[a - b] % MOD;
}

int main() {
    init();
    ll N;
    cin >> N;
    vl X(N);
    rep(i, N) cin >> X[i];

    vl sum(N + 1, 0);
    rep(i, N) sum[i + 1] = sum[i] + i + 1;
    factl_init(N);
    vl d(N - 1);
    rep(i, N - 1) d[i] = X[i + 1] - X[i];
    vl seed(N, 1);
    repe(i, 2, N)
        seed[i] = (seed[i - 1] * i + factl[i - 1]) % mod;

    ll ans = 0;
    repe(i, 1, N) {
        ans += d[i - 1] * seed[i] % mod * factl[N - 1] % mod * invl[i] % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<ll> a(n+1),b(n+1);

    REP(i,n){
        cin>>a[i]>>b[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    if(n%2==1){
        cout<<b[(n+1)/2]-a[(n+1)/2]+1<<endl;
        return 0;
    }else{
        cout<<(b[n/2+1]+b[n/2])-(a[n/2]+a[n/2+1])+1<<endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 6416
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Exawizards2019A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            int C = int.Parse(input[2]);

            if ((A == B) && (A == C))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}


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

int str_cmp(const void *a, const void *b) {
    return strcmp(*(char **)a, *(char **)b);
}

int main(void) {
    int a, b;
    scanf("%d %d", &a, &b);
    char *str_a = calloc(b + 1, 1);
    char *str_b = calloc(a + 1, 1);
    char *strtable[2] = {str_a, str_b};

    memset(str_a, '0' + a, b);
    memset(str_b, '0' + b, a);

    qsort(strtable, 2, sizeof(char *), str_cmp);

    printf("%s\n", strtable[0]);
}


Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var O, E, r string
	fmt.Scan(&O, &E)
	for i := 0; i < 50; i++ {
		if i+1 <= len(O) {
			r += O[i : i+1]
		}
		if i+1 <= len(E) {
			r += E[i : i+1]
		}
	}
	fmt.Println(r)
}

Measured memory_bytes: 512
from itertools import permutations
import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

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 SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    def dig(x):
        s=str(x)
        return sum(int(c) for c in s)
    n,a,b=MI()
    ans=0
    for x in range(1,n+1):
        if a<=dig(x)<=b:ans+=x
    print(ans)

main()


Measured memory_bytes: 3316
/*
          ,     \    /      ,
         / \    )\__/(     / \
        /   \  (_\  /_)   /   \
   ____/_____\__\@  @/___/_____\____
  |             |\../|              |
  |              \VV/               |
  |        ------hoi-------         |
  |_________________________________|
   |    /\ /      \\       \ /\    |
   |  /   V        ))       V   \  |
   |/     `       //        '     \|
   `              V                '
*/

#include <bits/stdc++.h>

#define ld long double
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define f first
#define se second
#define Speedforce boost();
#define fop(s1, s2) freopen(s1, "r", stdin);freopen(s2, "w", stdout);

using namespace std;

void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const int N = 1e6;
const ll inf = 1e9 + 7;
const ld PI = acos(-1);

ll bin_pow(ll x, ll y){
    ll res = 1, base = x;
    while(y){
        if(y & 1){
            res *= base;
            res %= inf;
        }
        base *= base;
        base %= inf;
        y /= 2;
    }
    return res;
}

int n, T, ans;
ll d[N][35];
vector <ll> b;
vector <pair <ll, ll> > a;

bool cmp(pair <ll, ll> x, pair <ll, ll> y){
    return x.f * y.se > x.se * y.f;
}

int main(){
    Speedforce
    //fop("", "")
    cin >> n >> T;
    T++;
    for(int i = 1;i <= n;i ++){
        int x, y;
        cin >> x >> y;
        y++;
        if(x){
            a.pb(mp(x, y));
        }
        else{
            b.pb(y);
        }
    }
    sort(a.begin(), a.end(), cmp);
    sort(b.begin(), b.end());
    for(int i = 1;i <= 30;i ++){
        d[0][i] = T + 1;
    }
    d[0][0] = 1;
    for(int i = 1;i <= a.size();i ++){
        for(int j = 0;j <= 30;j ++){
            d[i][j] = d[i - 1][j];
            if(j){
                d[i][j] = min(d[i][j], d[i - 1][j - 1] * (a[i - 1].f + 1) + a[i - 1].se);
            }
            if(d[i][j] > T){
                d[i][j] = T + 1;
            }
        }
    }
    for(int i = 0;i <= 30;i ++){
		if (d[a.size()][i] > T){
			break;
		}
		int t = d[a.size()][i], cur = i;
		for(int i = 0;i < b.size();i ++){
            int x = b[i];
			if (t + x > T){
				break;
			}
			t += x;
			cur ++;
		}
		ans = max(ans, cur);
	}
	cout << ans;
}


Measured memory_bytes: 59116
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int main() {
    string s;
    cin >> s;
    int mn = 1 << 30;
    int ans = mn;
    rep(i, s.size() - 2){
        int is = stoi(s.substr(i, 3));
        if(abs(753 - is) < mn){
            ans = abs(753 -is);
            mn = abs(753 -is);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		String[] kaikyu=new String[11];
		float[] jyougen=new float[11];


		kaikyu[0]="light fly";
		kaikyu[1]="fly";
		kaikyu[2]="bantam";
		kaikyu[3]="feather";
		kaikyu[4]="light";
		kaikyu[5]="light welter";
		kaikyu[6]="welter";
		kaikyu[7]="light middle";
		kaikyu[8]="middle";
		kaikyu[9]="light heavy";
		kaikyu[10]="heavy";

		jyougen[0]=48.0f;
		jyougen[1]=51.0f;
		jyougen[2]=54.0f;
		jyougen[3]=57.0f;
		jyougen[4]=60.0f;
		jyougen[5]=64.0f;
		jyougen[6]=69.0f;
		jyougen[7]=75.0f;
		jyougen[8]=81.0f;
		jyougen[9]=91.0f;
		jyougen[10]=114514f;

		Scanner sc=new Scanner(System.in);
		String str="";
		float nyuryoku=0f;

		while(sc.hasNext()) {
			str=sc.next();
			nyuryoku=Float.parseFloat(str);

			for(int i=0; i<11; i++) {
				if(nyuryoku<=jyougen[i]) {
					System.out.println(kaikyu[i]);
					break;
				}
			}
		}


	}
}


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

int main() {
	int A,B;
	cin >> A >> B;
	if(A==1){
		if(B==2){
			cout << 3 << endl;
		}else cout << 2 << endl;
	}else if(A==2){
		if(B==1){
			cout << 3 << endl;
		}else cout << 1 << endl;
	}else {
		if(B==2){
			cout << 1 << endl;
		}else cout << 2 << endl;
	}
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation
#include<complex>
#include<math.h>
#include<sstream>
#include<stdio.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep2(i, j, n) for (int i = j; i < (int)(n); i++)
using ll = long long int;
int main() {
	int A, B, H, M;
	cin >> A >> B >> H >> M;
	constexpr double PI = 3.1415926535897932;
	double rad = abs(PI * H / 6 - 11 * PI * M / 360);
	rad = min(rad, PI * 2 - rad);
	printf("%.15Lf", (long double)sqrt(A * A + B * B - 2 * A * B * cos(rad)));
}


Measured memory_bytes: 4140
#include<stdio.h>
#include<string.h>
int main(void){
  int N;
  scanf("%d",&N);
  int i;
  double x,sum=0;
  char u[3];
  for(i=0;i<N;i++){
    scanf("%lf %s",&x,u);
    if(strcmp(u,"JPY")==0) sum+=x;
    if(strcmp(u,"BTC")==0) sum+=x*380000.0;
  }
  printf("%f",sum);
  return 0;
}

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

int main() {
  long long int n, k, ans;
  cin >> n >> k;
  ans = min(n%k, k-n%k);
  cout << ans << endl;
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

double atanx(double a, double b) {
  double c, r;
  c = sqrt(a * a + b * b);
  r = acos(a / c);
  dump(c, a/c, r);
  return r;
}

void solve() {
  ll a, b, x;
  cin >> a >> b >> x;
  dump(a, b, x);
  b *= (a * a);
  a *= (a * a);
  dump(a, b, x);
  if (x * a * 2 < a * b) {
    ll a2, b2, c2, d2;
    c2 = x * a * 2;
    b2 = b * b;
    dump(b2, c2);
    double r = atan2((double)b2, (double)c2) * 180.0 / M_PI;
    dump(r);
    cout << r << endl;
  } else {
    ll a2, b2, c2, d2;
    c2 = x * a * 2 - a * b;
    b2 = b * a;
    d2 = b2 - c2;
    a2 = a * a;
    double r = atan2((double)d2, (double)a2) * 180.0 / M_PI;
    dump(r);
    cout << r << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    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;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int K=in();
    int T=in();
    int m;m=0;
    int a;
    REP(i,T){
        cin>>a;
        m=max(a,m);
    }
    int ans;
    if(K%2==0){
        if(m<=K/2){
            ans=0;
        }else{
            ans=(m-K/2)*2-1;
        }
    }else{
        if(m<=(K+1)/2){
            ans=0;
        }else{
            ans=(m-(K+1)/2)*2;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

main() {
  int64_t L0 = 2, L1 = 1;
  int N;
  cin >> N;

  for (int i = 0; i < N - 1; i++) {
    int64_t mem = L1;
    L1 = L0 + L1;
    L0 = mem;
  }
  cout << L1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int A[4000];
ll dp[4000][4000];
int main() {
  ios::sync_with_stdio(false);
  int N, S;
  cin >> N >> S;
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  dp[0][0] = 1;
  ll MOD = 998244353;
  ll ret = 0;
  for (int i=0; i<N; i++) {
    for (int j=0; j<=S; j++) {
      dp[i+1][j] = dp[i][j];
    }
    for (int j=0; A[i] + j<=S; j++) {
      dp[i+1][A[i]+j] = (dp[i+1][A[i]+j] + dp[i][j]) % MOD;
    }
    dp[i+1][A[i]] = (dp[i+1][A[i]] + i) % MOD;
    ret = (ret + dp[i+1][S]) % MOD;
  }
  cout << ret << endl;
}

Measured memory_bytes: 94208
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 500005
#define P 998244353
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int n, m, ans, fac[MAXN*2], ifac[MAXN*2];

inline int add(int x, int y) {return x+y>=P?x+y-P:x+y;}

inline int ksm(int x, int y)
{
    int sum=1;
    while(y)
    {
        if(y&1) sum=1LL*sum*x%P;
        x=1LL*x*x%P, y>>=1;
    }
    return sum;
}

void init()
{
    ifac[0]=ifac[1]=fac[0]=fac[1]=1;
    for(rint i=2; i<=n+m; ++i) ifac[i]=1LL*ifac[P%i]*(P-P/i)%P;
    for(rint i=2; i<=n+m; ++i)
    {
        ifac[i]=1LL*ifac[i-1]*ifac[i]%P;
        fac[i]=1LL*fac[i-1]*i%P;
    }
}

int comb(int x, int y)
{
    return 1LL*fac[x]*ifac[y]%P*ifac[x-y]%P;
}

int main()
{
    scanf("%d%d", &n, &m);
    if(n<m) swap(n, m);
    init();
    for(rint i=1; i<=m; ++i) ans=add(ans, 1LL*comb(i*2, i)*comb(n+m-i*2, n-i)%P);
    ans=1LL*ans*ksm(2LL*comb(n+m, m)%P, P-2)%P;
    printf("%d\n", add(ans, n));
    return 0;
}

Measured memory_bytes: 7936
#ifndef DEBUG
#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

    Int x, k, d;
    cin >> x >> k >> d;
    if (x < 0) {
        x = -x;
    }

    Int ans = 0;
    if (x == 0) {
        if (k & 1) {
            ans = d;
        } else {
            ans = 0;
        }
    } else {
        if (x / d < k) {
            k -= x / d;
            x %= d;
            if (k & 1) {
                ans = min(x + d, abs(x - d));
            } else {
                ans = x;
            }
        } else {
            ans = x - k * d;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3648
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Scanner;
 
public class Main{
	
	static final Scanner sc=new Scanner(System.in);
	public static void main(String[]args){
        int N=sc.nextInt();
        long[]a=new long[N];
        for(int i=0;i<N;i++){
                a[i]=sc.nextLong();
        }
        long[]s=new long[N];
        s[0]=a[0];
        for(int i=1;i<N;i++){
                s[i]=s[i-1]+a[i];
        }
        long min=1000000000;
        long r=0;
        for(int i=0;i<N-1;i++){
                r=s[N-1]-s[i];
                if(Math.abs(r-s[i])<min){
                        min=Math.abs(r-s[i]);
                }

        }
        if(N==2){
                min=Math.abs(a[0]-a[1]);
        }
        System.out.println(min);


		
	}
}


Measured memory_bytes: 79740
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e18;
using namespace std;
typedef long long ll;
int main() {
  string s;
  ll a;
  cin >> a;
  cin >> s;

  if (a >= 3200) {
    cout << s;
  } else {
    cout << "red";
  }
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    int N,M; cin>>N>>M;
    vector<vector<ll>>ab(N,vector<ll>(2));
    rep(i,N)cin>>ab[i][0]>>ab[i][1];
    sort(ab.begin(),ab.end());
    ll cnt=0,ans =0;
    rep(i,N){
        cnt+=ab[i][1];
        if(cnt>=M){
            ans+=(M-cnt+ab[i][1])*ab[i][0];
            break;
        }
        else ans+=ab[i][0]*ab[i][1];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 8832
#include <iostream>
#include <vector>
#include <cmath>
#include <map>

using namespace std;

int main() {

    int n, tmp, sum=1;
    int count =0;
    map<int, int> dicEven;
    map<int, int> dicOdd;

    int maxEven=0; //
    int maxValueEven;  //最大頻度の値
    int maxOdd=0;
    int maxValueOdd;


    cin>>n;

    for(int i=0; i<n; ++i)
    {
        cin >> tmp;
        if(i%2==0)
        {
            dicEven[tmp]+=1;
        }
        else
        {
            dicOdd[tmp]+=1;
        }

        sum *= tmp;
    }

    if(sum==pow(tmp, n))
    {
        cout<<n/2<<endl;
        return 0;
    }

    for(auto& it : dicEven)
    {
        if(maxEven < it.second)
        {
            maxEven = it.second;
            maxValueEven = it.first;
        }

    }

    for(auto& it : dicOdd)
    {
        if(maxOdd < it.second)
        {
            maxOdd = it.second;
            maxValueOdd = it.first;
        }

    }

    int changeEven=0;
    int changeOdd=0;

    for(auto& it : dicEven)
    {
        if(it.first!=maxValueEven)
            changeEven+=it.second;
    }

    for(auto& it : dicOdd)
    {
        if (it.first != maxValueOdd)
            changeOdd += it.second;
    }


    if(maxValueEven!=maxValueOdd)
        cout<<changeOdd+changeEven<<endl;
    else
    {
        int maxEvenSecond=0;
        int maxValueEvenSecond;
        int maxOddSecond=0;
        int maxValueOddSecond;

        for(auto& it : dicEven)
        {
            if(maxEvenSecond < it.second && it.first!=maxValueEven)
            {
                maxEvenSecond = it.second;
                maxValueEvenSecond = it.first;
            }

        }

        for(auto& it : dicOdd)
        {
            if(maxOddSecond< it.second && it.first!=maxValueOdd)
            {
                maxOddSecond = it.second;
                maxValueOddSecond = it.first;
            }

        }

        int changeEvenSecond=0;
        int changeOddSecond=0;

        for(auto& it : dicEven)
        {
            if(it.first!=maxValueEvenSecond)
                changeEvenSecond+=it.second;
        }

        for(auto& it : dicOdd)
        {
            if (it.first != maxValueOddSecond)
                changeOddSecond += it.second;
        }

        cout<<min(changeEven+changeOddSecond, changeOdd+changeEvenSecond)<<endl;
    }




    return 0;
}

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

using namespace std;

const int N = 200000+7;
int n,m;
vector<int>G[N];
int dep[N],vis[N];
bool bfs(){
    queue<pair<int ,int> >q;
    q.push(make_pair(1,0));
    vis[1]=1;
    while(!q.empty()){
        pair<int ,int> u=q.front();q.pop();
        if(u.first == n){
            return (u.second<=2) ;
        }
        for(int i=0,to;i<G[u.first].size();i++){
            to = G[u.first][i];
            if(vis[to]) continue;
            vis[to]=1;
            q.push(make_pair(to,u.second+1));
        }
    }
    return false;
}
void add(int x,int y){
    G[x].push_back(y);
    G[y].push_back(x);
}
int main(){

    cin>>n>>m;
    for(int i=1;i<=n;i++) G[i].clear();
    for(int i=1,x,y;i<=m;i++){
        scanf("%d%d",&x,&y);
        add(x,y);
    }

    if(bfs()) cout<<"POSSIBLE";
    else    cout<<"IMPOSSIBLE";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 13552
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var S = Console.ReadLine().ToCharArray();

        var T = Console.ReadLine().ToCharArray();
        var sDict = new Dictionary<char, int>();
        var tDict = new Dictionary<char, int>();

        var charCount = 0;
        var count = 0;

        var sArray = new int[S.Length];
        var tArray = new int[T.Length];

        foreach (var c in S)
        {
            if (sDict.ContainsKey(c))
            {
                sArray[count] = sDict[c];
            }
            else
            {
                sDict.Add(c, charCount);
                sArray[count] = sDict[c];
                charCount++;
            }
            count++;
        }

        charCount = 0;
        count = 0;

        foreach (var c in T)
        {
            if (tDict.ContainsKey(c))
            {
                tArray[count] = tDict[c];
            }
            else
            {
                tDict.Add(c, charCount);
                tArray[count] = tDict[c];
                charCount++;
            }
            count++;
        }

        var flag = true;

        for(var i = 0; i < S.Length; i++)
        {
            if(sArray[i] != tArray[i])
            {
                flag = false;
            }
        }

        if (flag)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }

        Console.Read();
    }


}



Measured memory_bytes: 17120
#!/bin/ruby

a, b, k = gets.chomp.split(" ").map(&:to_i)

divide = 1
cnt = 0
dividable_numbers = []
while true
  if a % divide == 0 && b % divide == 0
    dividable_numbers << divide
    cnt += 1
    divide += 1
  else
    divide += 1
  end
  break if divide > a || divide > b
end
puts dividable_numbers[-k]


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

#define ll long long
#define ull unsigned long long
#define mii make_pair<int, int>
#define mll make_pair<ll, ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define all(v) (v).begin(), (v).end()

ofstream out("debug.txt");

const int MxN = 1e5, md = 1e9 + 7;

vvi adj;
vb vis;

int BFS(int s)
{
    queue<int> q;
    q.push(s);
    vis[s] = 1;
    int count = 1;
    while (!q.empty())
    {
        int t = q.front();
        q.pop();
        for (int i = 0; i < adj[t].size(); ++i)
            if (!vis[adj[t][i]])
            {
                vis[adj[t][i]] = 1;
                q.push(adj[t][i]);
                ++count;
            }
    }
    return count;
}

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

    int n, m;
    cin >> n >> m;

    adj = vvi(n);
    vis = vb(n, 0);

    int mi = n, ma = 0;

    for (int i = 0; i < m; ++i)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    for (int i = 0; i < n; ++i)
        if (!vis[i])
        {
            int tt = BFS(i);
            mi = min(mi, tt);
            ma = max(ma, tt);
        }

    cout << ma;
}

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

int main()
{
double x1,y1,x2,y2,ans2;
double ans;
cin >> x1 >> y1 >> x2 >> y2;
ans2=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
ans=pow(ans2,0.5);
cout << fixed << setprecision(5) << ans;
}




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

using namespace std;

int main()
{
    string s,t;
    cin>>s>>t;
    int n=s.size();
    int m=t.size();
    int minm=INT_MAX;
    for(int i=0;i<n-m+1;i++)
    {
        int count=0;
        for(int j=0;j<m;j++)
        {
            if(s[i+j]!=t[j]) count++; 
        }
        minm=min(minm,count);
    }
    cout<<minm;

    return 0;
}


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

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

    if(a > b){
        while(a > 0){
            cout << b;
            a--;
        }
    }
    else{
        while(b > 0){
            cout << a;
            b--;
        }
    }

    cout << endl;
}

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

int main() {
  int n;
  cin >> n;
  if (n%10 == 2 || n%10 == 4 || n%10==5 || n%10==7 || n%10==9){
    cout << "hon" << endl;
  }
  else if (n%10 == 0 || n%10 == 1 || n%10==6 || n%10==8){
    cout << "pon" << endl;
  }
  else{
    cout << "bon" << endl;
  }
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
	int H; int W; int h; int w;
	while (~scanf("%d%d%d%d", &H, &W, &h, &w)) {
		if (H % h == 0 && W % w == 0) {
			puts("No");
			continue;
		}
		vector<vector<ll>> sum(H + 1, vector<ll>(W + 1));
		vector<vi> ans(H, vi(W));
		rep(i, H) rep(j, W) {
			ll t = sum[i + 1][j] + sum[i][j + 1] - sum[i][j];
			int x;
			if (i + 1 < h || j + 1 < w) {
				x = i == 0 && j == 0 ? 1000000 : 0;
			} else {
				ll u = sum[i + 1 - h][j + 1] + sum[i + 1][j + 1 - w] - sum[i + 1 - h][j + 1 - w];
				//t + x - u < 0
				//x < u - t
				x = (int)(u - t) - 1;
			}
			ans[i][j] = x;
			sum[i + 1][j + 1] = t + x;
		}
		assert(sum[H][W] > 0);
		rer(i, 0, H - h) rer(j, 0, W - w)
			assert(sum[i + h][j + w] - sum[i][j + w] - sum[i + h][j] + sum[i][j] < 0);
		puts("Yes");
		rep(i, H) {
			for (int j = 0; j < W; ++ j) {
				if (j != 0) putchar(' ');
				printf("%d", ans[i][j]);
			}
			puts("");
		}
	}
	return 0;
}


Measured memory_bytes: 5248
def parse(l):
    name, time = l.split()
    return (name, int(time))


n, q = map(int, input().split())
queue = list(parse(input()) for _ in range(n))
time = 0

while queue:
    (name, remain_time) = queue.pop(0)
    if remain_time > q:
        time += q
        queue.append((name, remain_time - q))
    else:
        time += remain_time
        print(name, time)

Measured memory_bytes: 14160
using System;
using System.Collections.Generic;
using System.Linq;
 
static class MainClass {
  public static void Main (string[] args) {
    var N = long.Parse(Console.ReadLine());
    var list = Console.ReadLine().Split(' ').Select(long.Parse).ToList();
    var ans = new List<long>();
    var c = 0;
    var min = list.Max() + 1;
    for(var i = 0; i < N; i++){
      if(min > list[i]){
        min = list[i];
        c++;
      }
    }

    Console.WriteLine(c); 
  }

  static long ModPow (long a, long n, long p) {
    if(n == 1) return a % p;

    if (n % 2 == 1) return (a * ModPow(a, n - 1, p)) % p;

    var t = ModPow(a, n / 2, p);
    return (t * t) % p;
  }

  static long Combination(long n, long a){
    var ary1 = Enumerable.Range((int)n - (int)a + 1, (int)a);
    var ary2 = Enumerable.Range(1, (int)a);
    return ary1.Aggregate((e, next) => e * next) / ary2.Aggregate((e, next) => e * next);
  }

}


Measured memory_bytes: 35676
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <limits>
#include <ctype.h> 
#include <stdio.h> 
#include <set> 
#include <iomanip>
#include <vector>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '

const int INF = 1e9 + 5;

int main() {
    int h = 0, n = 0;
    cin >> h >> n;
    vector<int> dp(h+1, INF);
    dp[0] = 0;
    for(int i = 0; i < n; ++i){
        int value = 0, cost = 0;
        cin >> value >> cost;
        for(int j = 0; j <= h; ++j){
            int k = min(h, value + j);
            dp[k] = min(dp[k], dp[j]+cost);
        }
    }
    cout << dp[h] << endl;    

    return 0;
} 


Measured memory_bytes: 256
n=int(input())
#V[u]=[k,[v],d,f]
V=[[0,[],0,0]]
for i in range(n):
    v=[int(i) for i in input().split(" ")]
    u=v.pop(0)
    k=v.pop(0)
    v.sort()
    V.append([k,v,0,0])


def is_finished(Id):
    k=V[Id][0]
    v=V[Id][1]
    for i in range(k):
        if V[v[i]][2]==0:
            return v[i]
    return -1

time=1

while time<=2*n:
 for i in range(1,n+1):
     if V[i][2]==0:
         cur=i
         log=[i]
         break

 while len(log)>0:
    if V[cur][2]==0:
        V[cur][2]=time
        time+=1


    x=is_finished(cur)
    if x!=-1:
        cur=x
        log.append(cur)
    else:
        try:
            log.pop(-1)
            V[cur][3]=time
            time+=1
            if V[cur][3]==V[cur][2]:
                time+=1
                V[cur][3]+=1

            cur=log[-1]
        except:
            pass
for i in range(1,n+1):
    print(i,V[i][2],V[i][3])

Measured memory_bytes: 7820
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	int n,lc=0,hc=0;
	char c;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>c;
		if(c=='R')
			hc++;
		else if(c=='B')
			lc++;
	}
		
	if(hc>lc)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
N=int(input())
ls=input().split()
l=[ int(v) for v in ls ]

l.sort(reverse=True)

A=0
B=0
for i in range(N):
    if i% 2 == 0:
        A+=l[i]
    else :
        B+=l[i]
print(A-B)
   

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,k;
  cin>>a>>b>>k;
  long long numa=a-k;
  if(numa>0){
    cout<<numa<<" "<<b<<endl;;
  }else{
    long long numb=b+numa;
    if(numb>0){
      cout<<"0 "<<numb<<endl;;
    }else{
      cout<<"0 0"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    private static void solver(InputReader sc, PrintWriter out) throws Exception {
       double pi = 3.14;
        int r =  sc.nextInt();
        out.println(2 * pi * r);
    }
    private static boolean helper(long x){
        double ans = Math.sqrt(x);
        return ans%1!=0;
    }

    private static int gcd(int a, int b){
        if(b==0)
            return a;
        return gcd(b, a%b);
    }
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int[] readIntArray(int n){
            int arr[] = new int[n];
            for(int i=0;i<n;i++) arr[i] = nextInt();
            return arr;
        }
    }
}
class Pair  {
    int x;
    int y;

    Pair(int x, int y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair pair = (Pair) o;
        return x == pair.x &&
                y == pair.y;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }
}

Measured memory_bytes: 33284
void main(){int n,a[64],i;a[0]=a[1]=1;a[2]=2;for(i=3;i<31;i++)a[i]=a[i-1]+a[i-2]+a[i-3];for(;;){scanf("%d",&n);if(n==0)break;printf("%d\n",a[n]/3650+1);}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int a,b,c;cin>>a>>b>>c;
    cout<<(((b*10+c)%4)?"NO":"YES")<<endl;
}

Measured memory_bytes: 3600
#include <cstdio>
#include <algorithm>
char s[101];
int a[100], N, O = 101;
int check()
{
	int L = N;
	while (std::count(a, a + L, 1) != L)
	{
		for (int i = 0; i < L - 1; i++)
			a[i] |= a[i + 1];
		L--;
	}
	return N - L;
}
int main()
{
	scanf("%s", s);
	while (s[N])
		N++;
	for (char i = 'a'; i <= 'z'; i++)
	{
		for (int j = 0; j < N; j++)
			a[j] = s[j] == i;
		O = std::min(O, check());
	}
	printf("%d\n", O);
	return 0;
}


Measured memory_bytes: 128
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

Int Ceil(Int a, Int b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return Floor(a, b) + 1;
    }
}

Int digits(Int n) {
    return (Int)to_string(n).size();
}

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

    int n;
    cin >> n;
    n *= 2;
    vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    sort(l.begin(), l.end(), greater<>());

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (i & 1) {
            ans += l[i];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N, M; cin >> N >> M;
    vector<int> b(N+1);
    for(int i=0; i<N+1; i++) b[i] = 0;
    for(int i=0; i<M; i++){
        int x, y; cin >> x >> y;
        b[x]++, b[y]++;
    }

    for(int i=1; i<=N; i++) cout << b[i] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, n) for(ll i=0;i<n;i++)
#define r(i, n) for(ll i=n-1;i>=0;i--)
#define forr(i, x, y) for(ll i=x;i<y;i++)
ll fastpower(ll a,ll n){
    ll res=1;
    while(n>0){
        if(n&1){
            res=(res*a)%1000000007;
        }
        a=(a*a)%1000000007;
        n>>=1;
    }
    return (res);
}
ll binomial(ll n,ll k){
    ll res=1;
    
    f(i,k){
        res=(res*(n-i))%1000000007;
        
    }
    f(i,k){
        res=(res*fastpower(i+1,1000000005))%1000000007;
    }
    return res;
}
int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans=(fastpower(2,n)-binomial(n,a)-binomial(n,b)-1+1000000007+1000000007)%1000000007;
   
    cout<<ans;

}

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

const int KMAX = 5005;

int n, k;
int mars[KMAX][KMAX];

int query(int l1, int c1, int l2, int c2)
{
   return mars[l2][c2] - mars[l1 - 1][c2] - mars[l2][c1 - 1] + mars[l1 - 1][c1 - 1];
}

int main()
{
   cin >> n >> k;
   for (int i = 1; i <= n; i++)
   {
      int x, y;
      char tip;
      cin >> x >> y >> tip;
      if (tip == 'B') // il facem W
         x += k;
      x = x % (2 * k) + 1;
      y = y % (2 * k) + 1;
      mars[x][y]++;
      mars[x][y + 2 * k]++;
      mars[x + 2 * k][y]++;
      mars[x + 2 * k][y + 2 * k]++;
   }

   /*for (int i = 1; i <= 2 * k; i++)
   {
      for (int j  = 1; j <= 2 * k; j++)
         cout << mars[i][j] << " ";
         cout << "\n";
   }
   return 0;*/

   for (int i = 1; i <= 4 * k; i++)
      for (int j = 1; j <= 4 * k; j++)
         mars[i][j] += mars[i][j - 1] + mars[i - 1][j] - mars[i - 1][j - 1];

   /*for (int i = 1; i <= 2 * k; i++)
   {
      for (int j  = 1; j <= 2 * k; j++)
         cout << mars[i][j] << " ";
         cout << "\n";
   }
   return 0;*/

   int rez = 0;
   for (int i = 1; i <= 2 * k; i++)
      for (int j = 1; j <= 2 * k; j++)
         rez = max(rez, query(i, j, i + k - 1, j + k - 1) + query(i + k, j + k, i + 2 * k - 1, j + 2 * k - 1));
   cout << rez;
   return 0;
}


Measured memory_bytes: 80128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);
 
using namespace std;
 
namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;
 
int p[100010];
int root(int x){
	if(x == p[x]) return x;
	return p[x] = root(p[x]);
}
bool merge(int a, int b){
	a = root(a); b = root(b);
	if(a == b) return 0;
	p[b] = a;
	return 1;
}
void check(bool cond){
	cout << (cond ? "Yes" : "No") << endl;
	exit(0);
}
 
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	ll n, m, q; cin >> n >> m >> q;
	ll k = n;
	rep(i, n) p[i] = i;
	vector<pi> c1;
	rep(i, q){
		int a, b, c; cin >> a >> b >> c;
		if(c) c1.emplace_back(a, b);
		else if(merge(a, b)) k--;
	}
	for(pi i : c1) if(root(i.first) == root(i.second)) check(0);
	
	ll lim = k * (k - 1) / 2 + n - k;
	if(!c1.size()) check(m <= lim);
	check(n <= m && m <= lim && k >= 3);
	
	return 0;
}

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

signed main() {
  int n, m;
  cin >> n >> m;
  int h[100000];
  bool isBad[100000] = {0};
  for(int i = 0; i < n; i++){
    cin >> h[i];
  }
  int good = n;
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if(h[a] == h[b]){
      if(!isBad[a]){
        isBad[a] = true;
        good--;
      }
      if(!isBad[b]){
        isBad[b] = true;
        good--;
      }
      continue;
    }
    if(h[b] > h[a] && !isBad[a]){
      good--;
      isBad[a] = true;
    }else if(h[b] < h[a] && !isBad[b]){
      good--;
      isBad[b] = true;
    }
  }
  cout << good << endl;
}

Measured memory_bytes: 4108
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef vector<vector<int>> Graph;
void add_edge(Graph& g, int from, int to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

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

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

	ll a,b,c,d; cin >> a >> b >> c >> d;

	cout << max(max(a*c, b*d), max(a*d, b*c)) << endl;
}



Measured memory_bytes: 3652