akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
  ll n,m,k;
  cin >> n >> m >> k;
  vector<ll> a(n+1,0), b(m+1,0);
  ll total1=0, total2=0;
  for(int i=1; i<=n; i++){
    int tmp;
    cin >> tmp;
    total1 += tmp;
    a[i] = total1;
  }
  for(int i=1; i<=m; i++){
    int tmp;
    cin >> tmp;
    total2 += tmp;
    b[i] = total2;
  }
  int ans = 0;
  rep(i,n+1){
    int left=-1, right=b.size();
    ll amari = k - a[i];
    if(amari<0) continue;
    while(right-left>1){
      int mid = left + (right-left)/2;
      if(b[mid] <= amari) left = mid;
      else right = mid;
    }
    ans = max(ans, i + left);
  }
  cout << ans << endl;
}


Measured memory_bytes: 6412
#include <algorithm>
#include <iostream>
#include <string>

int main() {
  int x[3];
  std::cin >> x[0] >> x[1] >> x[2];
  std::sort(x, x + 3);
  std::cout << std::to_string(x[0] + x[1]) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,c,x,z;
	scanf("%d",&z);
	for(x=0;x<z;x=x+1){
		scanf("%d%d%d",&a,&b,&c);
		if(a*a+b*b==c*c){printf("YES\n");}
		else if(a*a+c*c==b*b){printf("YES\n");}
		else if(b*b+c*c==a*a){printf("YES\n");}
		else{printf("NO\n");}
	}
  return 0;
}    

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

bool check(int n) {
    inc(i, 0, n+1){
        if(i*i == n){
            return true;
        }
    }
    return false;
}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n, d;cin >> n >> d;
    vector<vector<int>> x(n);
    inc(i, 0, n){
        inc(j, 0, d){
            int xx;cin >> xx;
            x[i].pb(xx);
        }
    }
    int ans = 0;
    inc(i, 0, n){
        inc(j, i+1, n){
            int sum = 0;
            inc(k, 0, d){
                int hoge = x[i][k]-x[j][k];
                sum += hoge*hoge;
            }
            if(check(sum)){
                ans++;
            }
            //cout << sum << " " << check(sum) << endl;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
c = [1]
fnx = {(0, 0): 0, (0, 1): 1}


def run(N, X):
    '''
    Fn(X)をレベルNバーガーの下からX層のパティの数とする
    C(N)をレベルNバーガーの層の数とする
    C(N) = 3 + 2*C(N-1)
    X=1のとき、Fn(X) = 0
    1<X<=C(N-1)+1のとき、Fn(X) = Fn-1(X-1)
    X=C(N-1)+2のとき、Fn(X) = Fn-1(C(N-1)) + 1
    C(N-1)+2<X<=2*C(N-1)+2のとき、Fn(X) = Fn-1(C(N-1)) + Fn-1(X-C(N-1)-2) + 1
    X = 2*C(N-1)+3のとき、Fn(X) = 2*Fn-1(C(N-1)) + 1
    '''
    for i in range(N):
        c.append(3+2*c[i])
    return get_fnx(N, X)


def get_fnx(N, X):
    if (N, X) in fnx.keys():
        return fnx[(N, X)]
    if X <= 1:
        return 0
    elif X <= c[N-1] + 1:
        return get_fnx(N-1, X-1)
    elif X == c[N-1] + 2:
        return get_fnx(N-1, c[N-1]) + 1
    elif X <= 2*c[N-1] + 2:
        return get_fnx(N-1, c[N-1]) + get_fnx(N-1, X-c[N-1]-2) + 1
    else:
        return 2*get_fnx(N-1, c[N-1]) + 1


def main():
    N, X = map(int, input().split())
    print(run(N, X))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]
x,y = map(int,input().split())
if x==y:
    print("Yes")
else:
    if A.count(x)==1 and A.count(y)==1:
        print("Yes")
    elif B.count(x)==1 and B.count(y)==1:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
using namespace std;
struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;

// 4つのHashを用いる場合はこのようになる
// vector<long long> mod{999999937LL, 1000000007LL, 1000000021LL, 1000000103LL};

/*
 * H[l,r) := 文字列S[l,r)のhash値
 * B := 基数
 *
 * S := 長さmの文字列
 * H[0,m) = (s[0]*B^(m-1) + s[1]*B^(m-2) + ... + s[m-1]*B^0) % MOD
 *
 * H[l,r) = H[0,r) - H[0,l) (mod注意)
 */

struct RollingHash{
    static const int hash_size = 1;
    vector<long long> mod{999999937LL, 1000000007LL};
    const long long base = 9973;
    string s;
    vector<long long> pw[hash_size];
    vector<long long> hs[hash_size]; // hs[i] := s[0,i)のhash値
    RollingHash(const string s_){
        s = s_;
        int n = s.size();
        for(int i=0;i<hash_size;i++){
            pw[i].resize(n+1);
            pw[i][0] = 1;
            for(int j=0;j<n;j++) pw[i][j+1] = pw[i][j] * base % mod[i];

            hs[i].resize(n+1);
            hs[i][0] = 0;
            for(int j=0;j<n;j++) hs[i][j+1] = ((hs[i][j] * base) % mod[i] + s[j]) % mod[i];
        }
    }

    long long get(int l,int r,int i) const {
        long long m = mod[i];
        return ((hs[i][r] - (hs[i][l]*pw[i][r-l])%m)%m+m)%m;
    }

    bool match(int l1, int r1, int l2, int r2) const {
        for(int i=0;i<hash_size;i++){
            if(get(l1,r1,i) != get(l2,r2,i)) return false;
        }
        return true;
    }

    /* 他の文字列のHashと比較 */
    bool match(int l, int r,const RollingHash& p, int pl, int pr) const {
        for(int i=0;i<hash_size;i++){
            if(get(l,r,i) != p.get(pl,pr,i)) return false;
        }
        return true;
    }
};

// AOJ ALDS1_14_B
int main(){
    string s1,s2;
    cin >> s1 >> s2;
    RollingHash rh1(s1);
    RollingHash rh2(s2);
    int n = s1.size();
    int m = s2.size();

    for(int i=0;i+m<=n;i++){
        if( rh1.match(i,i+m,rh2,0,m) ){
            cout << i << endl;
        }
    }
}



Measured memory_bytes: 20820
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,m,l,r,a,b;
    cin >> n >> m;
    l = 1;
    r = n;
    REP(i,0,m) {
        cin >> a >> b;
        l = max(l,a);
        r = min(r,b);
    }
    cout << max(0, r - l + 1) << endl;
}

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

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<assert.h>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define de_x(x) cout<< #x <<"->debug_val: "<<x<<endl;
#define de_ve(x) for(auto it: x) cout<<it<<" ";
#define rep(i,a,n) for (int i=a;i<n;i++)
#define _rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef double db;
//std::mt19937 mrand(random_device{}());
//int rnd(int x) { return mrand() % x ; }
const ll mod=1e7;
ll ksm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int _,n,m;
/***********************/
void run(){
}
int main(){
//    for(scanf("%d",&_);_;_--) run();
    cin>>n>>m>>_;
    cout<<(_-1)/max(n,m)+1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
string s;
vector<ll> pos;
vector<ll> ans;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>s;
    int n=s.length();
    pos.pb(-2);
    rep(i,0,n-1){
        if(s[i]=='R'&&s[i+1]=='L'){
            pos.pb(i);
        }
    }
    pos.pb(n);
    ll m=sz(pos);
    ans.resize(n);
    rep(i,1,m-1){
        int res=pos[i];
        while(res>=0&&s[res]=='R'){
            res--;
        }
        ll r=pos[i]-res-1;
        res=pos[i]+1;
        while(res<n&&s[res]=='L'){
            res++;
        }
        ll l=res-pos[i]-2;
        ans[pos[i]]=r/2+(l+1)/2+1;
        ans[pos[i]+1]=(r+1)/2+l/2+1;
    }
    for(auto &e: ans){
        cout <<e<<" ";
    }
    cout <<"\n";
}

Measured memory_bytes: 1864
A, B, H, M = gets.split.map(&:to_i)

angle_a = (H * 30 + M * 0.5) % 360
angle_b = (H * 360 + M * 6) % 360
angle_c = [(angle_a - angle_b).abs, (angle_a - angle_b - 360).abs].min

ans = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(angle_c * Math::PI / 180))
puts ans


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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int k = sc.NextInt();
        int[] p = sc.IntArray();

        p = p.OrderBy(i => i).ToArray();

        long answer = 0;
        for (int i = 0; i < k; i++)
        {
            answer += p[i];
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 28592
x1,y1,x2,y2=gets.split.map &:to_i
dx, dy = x2-x1, y2-y1
x3, y3 = x2-dy, y2+dx
dx, dy = x3-x2, y3-y2
x4, y4 = x3-dy, y3+dx
puts [x3, y3, x4, y4]*" "

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

#define INF 1000000000

int main() {
    int n;
    cin >> n;
    int row[n], col[n];
    fill(row, row+n, 0);
    fill(col, col+n, 0);
    char a;
    bool black[n][n];
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            cin >> a;
            black[i][j] = (a == '#');
            row[i] += black[i][j];
            col[j] += black[i][j];
        }
    }
    if (all_of(row, row+n, [](int r) { return r == 0; })) {
        cout << -1 << '\n';
        return 0;
    }
    int ans = INF;
    for (int i=0; i<n; i++) {
        int cnt = 0;
        for (int j=0; j<n; j++) {
            if (black[i][j]) {
                if (col[j] < n) cnt++;
            }
            else {
                if (i >= j && col[i] == 0) {
                    cnt++;
                    col[i] = 1;
                }
                cnt += 2;
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for ( auto blockTime = make_pair(chrono::high_resolution_clock::now(), true);blockTime.second;\
debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false)
#define li long long int
#define ld long double
#define eb push_back
#define pb pop_back
#define INF 1e18+10
#define MINF -1e18-10
#define rep(i,a,b) for(li i=a;i<b;i++)
#define size(a) a.size()
#define rev(a) reverse(a.begin(),a.end())
#define len(a) a.length()
#define f first
#define s second
#define sort(a) sort(a.begin(),a.end())
#define vli vector<li>
#define vvli vector<vli >
#define pli pair<li,li>199
#define vpli vector<pli>
#define inp(t) li t;cin>>t; while(t--)
using namespace std;
const li mod = 1e9+7;
const long int MAXN = 2e5+100;
#define PI 3.14159265358979323846264338327950

li power(li a, li b) { a%=mod; li ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
li add(li a,li b) { return (((a%mod)+(b%mod))%mod);}
li sub(li a,li b) { return (((a%mod)-(b%mod))%mod);}
li mul(li a,li b) { return (((a%mod)*(b%mod))%mod);}

void solve()
{
  li a;
  cin>>a;

  li t = 1000;
  while(t<a)
  {
    t+=1000;
  }

  cout<<t-a<<endl;
}
int main()
{
    IOS;

    solve();
    return 0;
}

Measured memory_bytes: 3640
D = int(input())
C = [int(i) for i in input().split()]
scores = [[int(i) for i in input().split()] for j in range(D)]
t = [int(input()) for i in range(D)]

ans = []
S = 0
last = [0]*26
for d in range(1,D+1):
    S += scores[d-1][t[d-1]-1]
    last[t[d-1]-1] = d
    for i in range(26):
        S -= C[i] * (d - last[i])
    ans.append(S)
print("\n".join(map(str, ans)))

Measured memory_bytes: 9368
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if(b-a<=k&c-a<=k&d-a<=k&e-a<=k&c-b<=k&d-b<=k&e-b<=k&d-c<=k&e-c<=k&e-d<=k){cout << "Yay!" << endl;}else{cout << ":(" << endl;}
    return 0;
}

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

int main(){
 int N, K;
 int x=1;
 cin >> N >> K;
  
 for (int i = 0; i < N; i++) {
   if ((x*2) < (x+K)) x *= 2;
    else x += K;
   }
 cout << x << endl;
  
 return 0;
}

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

#define SIGN_LENGTH 9
#define CIPHER_NUM 32
#define CODE_MAX 801
#define NUL 0x00
#define INITIALIZE 0
#define TEXT_MAX 101
#define FIVE 5

typedef struct cipher
{
	char charcter_change_sign[SIGN_LENGTH];
	char sign_change_charcter[SIGN_LENGTH];
	char charcter;
}CIPHER;

int main(void)
{
	
	CIPHER code[CIPHER_NUM] = {
		{"100101","00000",'A'},
		{"10011010","00001",'B'},
		{"0101","00010",'C'},
		{"0001","00011",'D'},
		{"110","00100",'E'},
		{"01001","00101",'F'},
		{"10011011","00110",'G'},
		{"010000","00111",'H'},
		{"0111","01000",'I'},
		{"10011000","01001",'J'},
		{"0110","01010",'K'},
		{"00100","01011",'L'},
		{"10011001","01100",'M'},
		{"10011110","01101",'N'},
		{"00101","01110",'O'},
		{"111","01111",'P'},
		{"10011111","10000",'Q'},
		{"1000","10001",'R'},
		{"00110","10010",'S'},
		{"00111","10011",'T'},
		{"10011100","10100",'U'},
		{"10011101","10101",'V'},
		{"000010","10110",'W'},
		{"10010010","10111",'X'},
		{"10010011","11000",'Y'},
		{"10010000","11001",'Z'},
		{"101","11010",' '},
		{"010001","11011",'.'},
		{"000011","11100",','},
		{"10010001","11101",'-'},
		{"000000","11110",'\''},
		{"000001","11111",'?'}
	};
	
	unsigned short i = INITIALIZE;
	unsigned short j = INITIALIZE;
	unsigned short k = INITIALIZE;
		
	
	char input_text[TEXT_MAX];
	for(i = 0; i < TEXT_MAX; i++)
	{
		input_text[i] = NUL;
	}
	
	while(gets(input_text) != NULL)
	{
		unsigned short text_length = INITIALIZE;
		unsigned short barcode_length = INITIALIZE;
		unsigned int count = INITIALIZE;
		int c = 0;
		int cc = 0;
		char barcode[CODE_MAX];
		char code_fivecut[CODE_MAX / FIVE][FIVE];/*160:5*/

		
		
		for(i = 0; i < CODE_MAX - 1; i++)//配列の最後(800番目)には\0が入るためマイナス1してある
		{
			barcode[i] = NUL;
		}
		
		for(i = 0; i < CODE_MAX / FIVE;i++)
		{
			for(j = 0; j < 5; j++)
			{
				code_fivecut[i][j] = '0';
			}
		}
		
		for(i = 0; i < TEXT_MAX; i++)
		{
			text_length++;
			if(input_text[i] == NUL)
			{
				break;
			}
		}
		
		for(i = 0; i < text_length; i++)
		{
			for(j = 0; j < CIPHER_NUM; j++)
			{
				if(input_text[i] == code[j].charcter)
				{
					strcat(barcode, code[j].charcter_change_sign);
				}
			}
		}
		
		for(i = 0; i < CODE_MAX; i++)
		{
			barcode_length++;
			if( barcode[barcode_length] == '\0')
			{
				break;
			}
		}
		
		
		for(i = 0; i < barcode_length; i++)
		{
			for(j = 0; j < FIVE; j++)
			{
				if(c < barcode_length)
				{
					code_fivecut[i][j] =  barcode[c];
					c++;
				}
			}
		}
		
		for(i = 0;i < CODE_MAX ; i+= 5)
		{
			if(barcode_length <= i)
			{
				count = i / 5;
				break;
			}
		}
		
		for(i = 0; i < count; i++)
		{
			for(j = 0; j < CIPHER_NUM; j++)
			{
				for(k = 0; k < FIVE; k++)
				{
					if(code_fivecut[i][k] == code[j].sign_change_charcter[k])
					{
						cc++;
					}
				}
				if(cc == 5)
				{
					printf("%c",code[j].charcter);
				}
				cc = 0;
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef pair<int, int> P;

// a / b % MOD;
// (a % MOD) * modinv(b, MOD) % MOD

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

// a^n 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()
{
    ll n, a, b;
    cin >> n >> a >> b;

    ll ans = modpow(2, n, MOD);
    ans--;

    ll l = 1, r = 1;
    for (ll i = n; i >= n - a + 1; i--) {
        l *= i;
        l %= MOD;
    }
    repd(i, 1, a + 1) {
        r *= i;
        r %= MOD;
    }

    ans -= (l % MOD) * modinv(r, MOD) % MOD;
    if (ans < 0) ans += MOD;

    l = 1;
    r = 1;
    for (ll i = n; i >= n - b + 1; i--) {
        l *= i;
        l %= MOD;
    }
    repd(i, 1, b + 1) {
        r *= i;
        r %= MOD;
    }

    ans -= (l % MOD) * modinv(r, MOD) % MOD;
    if (ans < 0) ans += MOD;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b,h,m;
    scanf("%d%d%d%d", &a, &b, &h, &m);
    double x1=h*30+m*0.5;
    double x2=m*6;
    double xita = fabs(x1-x2);
    if (xita>180) {
        xita = 360-xita;
    }
    double ans = sqrt(a*a+b*b-2*a*b*cos(xita*acos(-1.0)/180));
 
    printf("%.20lf\n",ans);//
 
    return 0;
}

Measured memory_bytes: 4220
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ll long long
#define pb push_back
#define pf push_front
deque<char> deq;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    char C;
    ll Q;
    ll T,F;
    bool on=false;
    cin >> S >> Q;
    for(auto tmp:S){
        deq.pb(tmp);
    }
    while(Q--){
        cin >> T;
        if(T==1) on^=true;
        else{
            cin >> F >> C;
            if(on ^ (F==1)) deq.pf(C);
            else deq.pb(C);
        }
    }
    string ans;
    for(auto tmp:deq) ans.pb(tmp); 
    if(on) reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1368
#include <stdio.h>
#include <vector>
#define SIZE 200005
  const int mod = (int)1e9 + 7;
  std::vector <int> pol[SIZE];

  inline int add(int a, int b, int mod) {a += b; return a >= mod ? a - mod : a;}
  inline int sub(int a, int b, int mod) {a -= b; return a < 0 ? a + mod : a;}
  inline int mul(int a, int b, int mod) {return (long long int)a * b % mod;}

  std::pair <int,int> dfs(int u, int p=-1) {
           int white=1, black=0;

           for(int v : pol[u]) {
                if(v == p) continue;
                std::pair<int,int> p = dfs(v, u);
                black = add(mul(white, p.first, mod), mul(black, add(p.first, p.second, mod), mod), mod);
                white = mul(white, p.second, mod);
           }

           return {white, add(white, black, mod)};
  }

  int main(void) {
        int n;
        scanf("%d",&n);
        for(int i=0; i<n-1; i++) {
                int a,b;
                scanf("%d %d",&a,&b);
                pol[a].push_back(b);
                pol[b].push_back(a);
        }

        std::pair<int,int> p = dfs(1);
        int ans = add(p.first, p.second, mod);

        printf("%d", ans);
        return 0;
  }











Measured memory_bytes: 14976
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	max := canDiv2(nextInt())
	for i := 1; i < n; i++ {
		max = min(max, canDiv2(nextInt()))
	}
	puts(max)
	wt.Flush()
}

func canDiv2(n int) int {
	ret := 0
	for n&1 == 0 {
		n >>= 1
		ret++
	}
	return ret
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}


Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
/*int min(double *x,int n){
	int i,c=0;
	double ans;
	ans=100005;
	for(i=0; i<n; i++){
		if(ans>x[i]){
			ans=x[i];
			c=i;
		}
	}
	return c;
}*/
int main()
{
	int n,i,c=0;
	double h[1000],max;
	double m=0.006,f,t,a;
	double ans[1005];
	scanf("%d%lf%lf",&n,&t,&a);
	max=1000000.000;
	for(i=0; i<n; i++){
		scanf("%lf",&h[i]);
		f=(h[i]*m);
		f=t-f;
		ans[i]=abs(a-f);
		if(ans[i]<max){
			max=ans[i];
			c=i;
		}
		//printf("%lf\n",ans[i]);
	}
	printf("%d\n",c+1);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;



map<int,map<int,int> > amida;

int main(){
	int n,m,a;

	while(cin>>n>>m>>a){
		if((n|m|a)==0)break;
		
		amida.clear();
		
		for(int i=0;i<m;i++){
			int h,p,q;
			cin>>h>>p>>q;
			
			amida[h][q]=p;
			amida[h][p]=q;
		}
		
		int h=1000;
		
		while(h){
			if(amida[h][a]==0){
				--h;
				continue;
			}
			
			//cout<<a<<endl;
			
			a=amida[h][a];
			--h;
		}
		
		cout<<a<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
 
sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

MOD = 10 ** 9 + 7
N, K = map(int, input().split())
count = Counter()
for i in reversed(range(1, K + 1)):
    c = pow(K // i, N, MOD)
    j = 2
    while i * j <= K:
        c -= count[i * j]
        j += 1
    count[i] = c
print(sum(i * j for i, j in count.items()) % MOD)


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

int main()
{
    data_type t,n,te=0;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    cout<<(n/500)*1000+((n%500)/5)*5<<endl;

    return 0;
}
/*
3
3
.#.
11
...##....##
2
##
*/


Measured memory_bytes: 256
N, A, B = map(int,input().split())

def Sum(n):
    s = str(n)
    t = list(map(int,s))
    return sum(t)

total = 0

for i in range(N + 1):
    if A <= Sum(i) and Sum(i) <= B:
        total += i
        
print(total)

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

int main(){

    int n;
    cin >> n;
    vector<ll> height(n);
    for (int i=0; i<n; i++){
        cin >> height.at(i);
    }

    ll m = height.at(0);
    for (int i=0; i<n; i++){
        if (m - 1 > height.at(i)){
            cout << "No" << endl;
            return 0;
        }
        m = max(m, height.at(i));
    }

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define inf 1000000000
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
const int mod=1e9+7;
int main(){
IOS;
lli n,i;
cin>>n;
lli a[n],ans=0;
for(i=0;i<n;i++){
    cin>>a[i];
}
for(i=0;i<n;i++){
    ans=ans^a[i];
}
if(!ans)
    cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}


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

int main() {
  string s;
  cin >> s;
  int num = s.size();
  int mid = (num / 2) + 1;
  bool flg = false;
  for(int i = 0; i < num; i++){
    if(i == mid){
      break;
    }
    if(s[i] != s[num - i - 1]){
      cout << "No" << endl;
      return 0;
    }
  }
  num /= 2;
  mid /= 2;
  for(int i = 0; i < num; i++){
    if(i == mid){
      break;
    }
    if(s[i] != s[num - i - 1]){
      cout << "No" << endl;
      return 0;
    }
  }
  num = s.size();
  int start = (num + 3) / 2;
  mid = (num + start) / 2;
  for(int i = 0; i < mid; i++){
    if(i + start == mid){
      break;
    }
    if(s[i + start - 1] != s[num - i - 1]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#include<random>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (int)(Y);++(X))
#define reps(X,S,Y) for (int (X) = (int)(S);(X) < (int)(Y);++(X))
#define rrep(X,Y) for (int (X) = (int)(Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (int)(Y)-1;(X) >= (int)(S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7; //998244353

int solve(){
	ll a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	ll x=abs(a-b);
	ll d=v-w;
	if(d<=0) return 0;
	return x<=d*t;
}

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	cout<<(solve()?"YES":"NO") NL;
  return 0;
}


Measured memory_bytes: 3652
def f_silver_fox_vs_monster():
    # 参考: https://atcoder.jp/contests/abc153/submissions/9773604
    from bisect import bisect_right
    import sys
    input = sys.stdin.readline
    N, D, A = [int(i) for i in input().split()]
    Monsters = sorted([[int(i) for i in input().split()] for j in range(N)])

    class BIT(object):
        """Binary Indexed Tree (1-indexed)"""

        def __init__(self, n):
            self.size = n
            self.tree = [0] * (n + 1)

        def sum(self, index):
            """array[1] から array[index] までの和を計算"""
            ret = 0
            while index > 0:
                ret += self.tree[index]
                index -= index & (-index)
            return ret

        def add(self, index, value):
            """array[index] に value を加算"""
            while index <= self.size:
                self.tree[index] += value
                index += index & (-index)

    position = [row[0] for row in Monsters]
    hit_point = [row[1] for row in Monsters]
    # [k]: 左から k 番目の敵を爆発の左端で攻撃したときに届く右端の敵のインデックス
    pos_right = [bisect_right(position, pos + 2 * D) for pos in position]

    ans = 0
    bomb_damage = BIT(N + 1)  # bomb_damage.sum(k): 左から k 番目の敵に与えた累計ダメージ
    for i in range(N):
        hp, damage, right = hit_point[i], bomb_damage.sum(i + 1), pos_right[i]
        if hp - damage > 0:
            num_defeat = (hp - damage + A - 1) // A  # 注目中の敵を倒すのに必要な爆発回数
            ans += num_defeat
            bomb_damage.add(i + 1, num_defeat * A)
            # ここから右の敵はダメージが通っていないことを反映
            bomb_damage.add(right + 1, -num_defeat * A)
    return ans

print(f_silver_fox_vs_monster())

Measured memory_bytes: 94476
from collections import deque
import numpy as np

def bfs(maze, visited, sx, sy):
    if s[sx][sy] == "#":
        return 0
    queue = deque([[sx, sy]])
    visited[sx][sy] = 0
    while queue:
        x, y = queue.popleft()
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_x, new_y = x + j, y + k
            if (new_x < 0 or new_x >= H or new_y < 0 or new_y >= W or 
            visited[new_x][new_y] != -1 or s[new_x][new_y] == "#"):
                continue
            else:
                visited[new_x][new_y] = visited[x][y] + 1
                queue.append([new_x, new_y])
    return max(np.array(visited).flatten())

H, W = map(int, input().split())
s = []
for _ in range(H):
    s.append([i for i in input()])
ans = 0
for i in range(H):
    for k in range(W):
        visited = [[-1 for _ in range(W)] for _ in range(H)]
        ans = max(ans, bfs(s, visited, i, k))
print(ans)

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

int main(){
    int n;
    cin >> n;
    vector<int> ans(3, 0);
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    for (int i = 0; i < n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    int x, y, z;
    for (int i = 0; i < n; i++){
        x = max(ans[1] + a[i], ans[2] + a[i]);
        y = max(ans[0] + b[i], ans[2] + b[i]);
        z = max(ans[0] + c[i], ans[1] + c[i]);
        ans[0] = x;
        ans[1] = y;
        ans[2] = z;
    }
    cout << max({ans[0], ans[1], ans[2]}) << endl;
}

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


int main() {





       string s;

       cin >> s;

       int flag=true;

       if(s[0]!='A') flag=false;


       int cnt=0;
       for(int i=2;i<s.size()-1;i++)
                cnt+=(s[i]=='C');
                
        
        if(cnt!=1) flag=false;


        for(int i=0;i<s.size();i++) {

                if(s[i]=='A'||s[i]=='C') continue;
                if(s[i]>=65&&s[i]<=90) flag=false;

        }

        if(flag) cout << "AC\n";
        else     cout << "WA\n";





}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
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; }

int main(){
    int n;
    cin >> n;
    vector<ll> a(n), sum(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    sum[0] = a[0];
    rep(i,n-1) sum[i+1] = sum[i] + a[i+1];
    ll ans = 1;
    for(int i = n-1; i > 0; i--){
        if (a[i] > sum[i-1] * 2) break;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4756
#include <iostream>
#include <cstdint>
#include <vector>
#include <limits>

int main() {
  std::int_fast64_t n, t;
  std::cin >> n >> t;

  std::int_fast64_t base_a = std::numeric_limits<std::int_fast64_t>::max();
  std::int_fast64_t max_diff = 0;
  std::int_fast64_t result = 0;
  for (std::int_fast64_t i = 0; i < n; ++i) {
    std::int_fast64_t a;
    std::cin >> a;

    if (base_a > a) {
      base_a = a;
    } else {
      if (a - base_a > max_diff) {
        max_diff = a - base_a;
        result = 1;
      } else if (a - base_a == max_diff) {
        ++result;
      }
    }
  }

  std::cout << result << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
int main(){
	ll a,b,x,aw,bw,aa,bb;
	std::cin>> a>>b>>x ;
	aw=a/x;bw=b/x,aa=a%x,bb=b%x;
	if(aa==0)std::cout << bw-aw+1 << std::endl;
	else std::cout <<  bw-aw << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n, k; cin >> n >> k;
    int a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    bool dp[k+1] = {};
    for (int i = 1; i <= k; i++) {
        for (int j = 0; j < n; j++) {
            int x = a[j];
            if (x <= i && !dp[i-x]) { dp[i] = true; break; }
        }
    }
    cout << (dp[k] ? "First" : "Second") << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
ll a[101];
int main() {
	ios_base::sync_with_stdio(false);
	ll k,t; scanf("%lld%lld",&k,&t);
	for (ll i=0;i<t;i++) scanf("%lld",&a[i]);
	ll sum=0;
	for (ll i=0;i<t;i++) sum+=a[i];
	ll largest=0;
	for (ll i=0;i<t;i++) chkmax(largest,a[i]);
	ll rest=sum-largest;
	ll ans=max(0ll,largest-rest-1);
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int N;
  char S[100] = {""};
  cin >> N;
  cin >> S;
  int x = 0;
  int max = 0;
  for(int i = 0; i<N; i++){
    if(S[i] == 'I'){
      if(x+1>max){
        max = x+1;
       }
      x++;
    }else{
      x--;
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	
    public void solve(){
		Scanner sc=new Scanner(System.in);
		int hito,i,ban,uriage;
		for(int a=0; a<4;a++){
			ban=sc.nextInt();
			if(ban==1){
				i=6000;
				}else if(ban ==2){
					i=4000;
				}else if(ban ==3){
					i=3000;
				}else{
					i=2000;
				}
				hito=sc.nextInt();
				uriage=i*hito;
				System.out.println(uriage);
		
			 }
    }
      public static void main(String[] args){
      Main obj = new  Main(); 
      obj.solve();      
  }
}

Measured memory_bytes: 17328
#include <cstdio>

#define MAX 10000
#define NIL -1

struct Node {
    int p, l, r;
};

Node T[MAX];
int n;

void preParse(int u) {
    if (u == NIL) return;
    printf(" %d", u);
    preParse(T[u].l);
    preParse(T[u].r);
}

void inParse(int u) {
    if (u == NIL) return;
    inParse(T[u].l);
    printf(" %d", u);
    inParse(T[u].r);
}

void postParse(int u) {
    if (u == NIL) return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d", u);
}

int main() {
    int v, l, r;
    int root = 0;
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        T[i].p = NIL;
    }

    for (int i = 0; i < n; i++) {
        scanf("%d %d %d", &v, &l, &r);
        T[v].l = l;
        T[v].r = r;
        if (l != NIL) T[l].p = v;
        if (r != NIL) T[r].p = v;
    }

    for (int i = 0; i < n; i++) {
        if (T[i].p == NIL) root = i;
    }

    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");

    return 0;
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define FORE(i,a,b) for (int i=(int)(a);i<=(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define REPE(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VEC;

int main() {
  int N,K;cin>>N>>K;
  vector<int> XS;
  REP(i,N) {
    int x;cin>>x;
    XS.push_back(x);
  }
  int ans = INT_MAX;
  FOR(i,0,N-K+1) {
    int left = XS[i];
    int right = XS[i+K-1];
    if (right < 0) {
      ans = min(ans,-left);
    } else if (left > 0) {
      ans = min(ans,right);
    } else {
      // 小さい方に言ってから、right-left分移動する
      ans = min(ans, min(abs(left),abs(right))+right-left);
    }
  }
  OUT(ans);
  
  return 0;
}

Measured memory_bytes: 892
import itertools


n, m, q = map(int, input().split())
query = []
for i in range(q):
    query.append(list(map(int, input().split())))

choices = list(itertools.combinations_with_replacement([i for i in range(1, m+1)], n))
ans = -1
for choice in choices:
    score = 0
    for q in query:
        if choice[q[1]-1] - choice[q[0]-1] == q[2]:
            score += q[3]
    ans = max(ans, score)
print(ans)

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


int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<int> a(n); rep(i, n) cin >> a[i];
	vector<int> left(n); {
		left[0] = a[0];
		rep(i, n - 1) left[i + 1] = __gcd(left[i], a[i + 1]);
	}
	vector<int> right(n); {
		right[n - 1] = a[n - 1];
		for (int i = n - 1; i >= 1; --i) {
			right[i - 1] = __gcd(right[i], a[i - 1]);
		}
	}

	int ans = 0;
	rep(i, n) {
		if (i == 0) {
			ans = max(ans, right[1]);
		} else if (i == n - 1) {
			ans = max(ans, left[n - 2]);
		} else {
			ans = max(ans, __gcd(left[i - 1], right[i + 1]));
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s=="MON") cout<<6;
	else if(s=="TUE") cout<<5;
	else if(s=="WED") cout<<4;
	else if(s=="THU") cout<<3;
	else if(s=="FRI") cout<<2;
	else if(s=="SAT") cout<<1;
	else cout<<7;
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int cnt=0,mx=0;
    for(int i=0; i<n; i++){
        while(a[i]%2==0&&a[i]!=0){
            a[i]/=2;
            cnt++;
        }
    }
    cout << cnt  << endl;

}

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


int main() {
  int N, M;
  cin >> N >> M;
  vector<int> X(M);

  for(int i = 0; i < M; i++) cin >> X[i];
  sort(X.begin(), X.end());

  vector<int> dis(M - 1);
    if(N >= M) { cout << 0; return 0; } 
  for(int i = 0; i < M - 1; i++) {
      dis[i] = X[i + 1] - X[i]; 
  }

    sort(dis.begin(), dis.end());
    ll sum = 0;
    for(int i = 0; i < M - N; i++) {
        sum += dis[i];
    }

    cout << sum;
    return 0;
}

Measured memory_bytes: 1024
import bisect,sys
from itertools import *
n=range(50001);a=list(n);a[1]=0
for i in range(2,224):a[i*2::i]=[0]*len(a[i*2::i])
p=list(compress(n,a))
for x in sys.stdin:
 x=int(x)
 if x:print(sum(1 for d in p[:bisect.bisect(p,x//2)]if a[x-d]))


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

int main() {
    int A, B, C, X, Y, sum = 0;
    cin >> A >> B >> C >> X >> Y;
    if (X < Y) {
        swap(X, Y);
        swap(A, B);
    }
    if (A > 2 * C) {
        sum += 2 * C * X;
    }
    else if (A + B > C * 2) {
        sum += C * 2 * Y;
        X -= Y;
        sum += A * X;
    }
    else {
        sum += A * X + B * Y;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

#define ll long long

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    sort(A.begin(), A.end(), std::greater<ll>());
    ll ans, a=0, b=0;
    int count = 0;
    int ptr=0;
    while(count<2) {
        if(A[ptr]==A[ptr+1]) {
            if(count==0) {
                a=A[ptr];
                ptr++;
            } else {
                b=A[ptr];
                ptr++;
            }
            count++;
        }
        ptr++;
        if(ptr>=N) break;
    }
    if(count==2) {
        ans = a*b;
    } else {
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}

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

public class Main {
	
	public static boolean isP(String s) {
		int i = 0, j = s.length() - 1;
		while(i < j) {
			if(s.charAt(i) != s.charAt(j))
				return false;
			i++;
			j--;
		}
		
		return true;
	}
	
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		String s = sc.next();
		int mid = s.length() / 2;
		System.out.println((isP(s) && isP(s.substring(0, mid))) ? "Yes" : "No");
		
		pw.flush();
	}

	public static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

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

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >>ty;
    
    int dx = tx - sx;
    int dy = ty - sy;
    
    cout << string(dx, 'R') << string(dy, 'U');
    cout << string(dx, 'L') << string(dy, 'D');
    cout << 'D' << string(dx + 1, 'R') << string(dy + 1, 'U') << 'L';
    cout << 'U' << string(dx + 1, 'L') << string(dy+ 1, 'D') << 'R';
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=100100100100;
const int Inf=1001001001;
const int mod=1000000007;
const double pi=3.141592653589793;
const double mi=0.0000005;
int main(){
    int a,b;cin>>a>>b;
    if(a<10&&b<10){
        cout<<a*b<<endl;
    }
    else cout<<-1<<endl;
}

Measured memory_bytes: 256
# Author: S Mahesh Raju
# Username: maheshraju2020
# Date: 25/07/2020

from sys import stdin,stdout
from math import gcd, ceil, sqrt
from collections import Counter
from bisect import bisect_left, bisect_right
ii1 = lambda: int(stdin.readline().strip())
is1 = lambda: stdin.readline().strip()
iia = lambda: list(map(int, stdin.readline().strip().split()))
isa = lambda: stdin.readline().strip().split()
mod = 1000000007

a, b, c = iia()
k = ii1()
if b > a and c > b:
    print('Yes')
else:
    while b <= a and k > 0:
        b *= 2
        k -= 1
    while c <= b and k > 0:
        c *= 2
        k -= 1
    if b > a and c > b:
        print('Yes')
    else:
        print('No')
        

Measured memory_bytes: 65316