akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
using namespace std;

 ll mod=1e9 +7;


const ll M=200006;
ll f[M],inv[M];
ll expo(ll base,ll exponent){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
void compute(){
    f[0]=1;
    rep(i,1,M-1){
        f[i]=(1LL*i*f[i-1])%mod;
    }
    inv[M-1]=expo(f[M-1],mod-2);
    for(ll i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%mod;
    }
}
ll C(ll n,ll r){
    return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;
}

vector<bool>  prime(1000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=1000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=1000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

int main()
{

	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
 //    #endif

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // compute();

    ll tests=1,t=1;
   // cin>>tests;
    while(tests--)
    {
    	int i,j,x,n,ans,val=102;
    	cin>>x>>n;
    	int a[101]={0};
    	for(i=0;i<n;i++)
    	{
    		cin>>j;
    		a[j]++;
    	}
    	for(i=x;i<=100;i++)
    	{
    		if(a[i]>0) continue;
    		if(val>i-x)
    		{
    			val=i-x;
    			ans=i;
    		}
    		break;
    	}
    	for(i=x;i>=0;i--)
    	{
    		if(a[i]>0) continue;
    		if(val>=x-i)
    		{
    			val=x-i;
    			ans=i;
    		}
    		break;
    	}
    	if(val>101-x) {val=101-x;ans=101;}
    	if(val>x+1) {ans=-1;}
    	cout<<ans;



    }

	return 0;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int value;
  vector<pair<int, int>> p;
  for(int i = 1; i <= n; i++)
  {
    cin >> value;
    p.push_back(make_pair(value, i));
  }
  sort(p.begin(), p.end());
  for(int i = 0; i < n; i++)
  {
    cout << (p[i]).second << " ";
  }
  return 0;
}


Measured memory_bytes: 1780
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
int gcd(int x, int y) {
	if (y == 0)return x;
	else return gcd(y, x%y);
}
using namespace std;
signed main() {
	ll a, b;
	cin >> a >> b;
	if (b%a == 0)cout << a + b << endl;
	else cout << b - a << endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define ULL unsigned long long
using namespace std;

int main() {
    int a[100];
    int n; scanf("%d", &n);
    int sum = 0;
    for (int i=0; i<n; i++) {
        scanf("%d", a+i);
        sum += a[i];
    }
    int m; scanf("%d", &m);
    for (int i=0; i<m; i++) {
        int t = sum;
        int p, x;
        scanf("%d %d", &p, &x);
        t  = t - a[p-1] + x;
        printf("%d\n", t);
    }
    return 0;
}

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

int main() {
  int a;
  cin >> a;
  int b = a / 100; //100の位
  int c = (a / 10) - b * 10; //１０の位
  int d = a - b * 100 - c * 10; //1の位
  cout << b + c + d << endl;
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 30.09.2017 15:59:34       
**/
#include <bits/stdc++.h>

using namespace std;

inline void add(int &a, int b, int md) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b, int md) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b, int md) {
#if !defined(_WIN32) || defined(_WIN64)
  return (long long) a * b % md;
#endif
  unsigned long long x = (long long) a * b;
  unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
  asm(
    "divl %4; \n\t"
    : "=a" (d), "=d" (m)
    : "d" (xh), "a" (xl), "r" (md)
  );
  return m;
}

inline int power(int a, long long b, int md) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a, md);
    }
    a = mul(a, a, md);
    b >>= 1;
  }
  return res;
}

inline int inv(int a, int md) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

template<typename T>
T extgcd(T a, T b, T &x, T &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  T p = b / a;
  T g = extgcd(b - p * a, a, y, x);
  x -= p * y;
  return g;
}

template<typename T>
bool diophantine(T a, T b, T c, T &x, T &y, T &g) {
  if (a == 0 && b == 0) {
    if (c == 0) {
      x = y = g = 0;
      return true;
    }
    return false;
  }
  if (a == 0) {
    if (c % b == 0) {
      x = 0;
      y = c / b;
      g = abs(b);
      return true;
    }
    return false;
  }
  if (b == 0) {
    if (c % a == 0) {
      x = c / a;
      y = 0;
      g = abs(a);
      return true;
    }
    return false;
  }
  g = extgcd(a, b, x, y);
  if (c % g != 0) {
    return false;
  }
  T dx = c / a;
  c -= dx * a;
  T dy = c / b;
  c -= dy * b;
  x = dx + (T) ((__int128) x * (c / g) % b);
  y = dy + (T) ((__int128) y * (c / g) % a);
  g = abs(g);
  return true;
}

bool crt(long long k1, long long m1, long long k2, long long m2, long long &k, long long &m) {
  k1 %= m1;
  if (k1 < 0) k1 += m1;
  k2 %= m2;
  if (k2 < 0) k2 += m2;
  long long x, y, g;
  if (!diophantine(m1, -m2, k2 - k1, x, y, g)) {
    return false;
  }
  long long dx = m2 / g;
  long long delta = x / dx - (x % dx < 0);
  k = m1 * (x - dx * delta) + k1;
  m = m1 / g * m2;
  assert(0 <= k && k < m);
  return true;
}

int get_phi(int m) {
  int phi = m;
  int tmp = m;
  for (int i = 2; i * i <= tmp; i++) {
    if (tmp % i == 0) {
      phi /= i;
      phi *= (i - 1);
      while (tmp % i == 0) {
        tmp /= i;
      }
    }
  }
  if (tmp > 1) {
    phi /= tmp;
    phi *= tmp - 1;
  }
  return phi;
}

long long solve(int a, int m) {
  if (m == 1) {
    return 30;
  }
  int phi = get_phi(m);
  int g = __gcd(m, phi);
  long long k = solve(a, g);
  int value = power(a, k, m);
  long long res, z;
  assert(crt(k, phi, value, m, res, z));
  while (res < 30) {
    res += z;
  }
  return res;
}

int main() {
  int tt;
  scanf("%d", &tt);
  while (tt--) {
    int a, m;
    scanf("%d %d", &a, &m);
    long long k = solve(a, m);
    cout << k << endl;
    assert(power(a, k, m) == k % m);
  }
  return 0;
}


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

namespace AtCoder.Abc
{
    class A_165_WeLoveGolf
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            int k = int.Parse(Console.ReadLine());
            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long a = inputLongArray[0];
            long b = inputLongArray[1];

            for (long i = a; i <= b; i++)
            {
                if (i % k == 0)
                {
                    Console.WriteLine("OK");
                    break;
                }
                else if (i == b)
                {
                    Console.WriteLine("NG");
                }
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28076
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)

int main() {
  int N; cin >> N ;
  
  ll sum=0;
  int end;

  for(int i=1;i<=N;i++){
    sum+=i;
    if(sum>=N){
      end=i; break;
    }
  }
  
  int err=sum-N;
  
  for(int i=1;i<=end;i++)
   if(i==err) continue;
   else cout << i << endl;
      
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main(){
  int n, f, t = 0, h = 0;
  char c1[101], c2[101];
  scanf("%d", &n);
  while(n--){
    scanf("%s%s", c1, c2);
    f = strcmp(c1, c2);
    if(!f) t++,h++;
    else if(f > 0) t += 3;
    else if(f < 0) h += 3;
  }
  printf("%d %d\n", t, h);
  return 0;
}


Measured memory_bytes: 2088
#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>;

const double eps = 1e-9;
bool equal(double a, double b) { return abs(a-b) < eps;}

struct V {
  double x, y;
  V(double x=0, double y=0) : x(x), y(y) {}
  V operator+(const V& p) const { return V(x+p.x, y+p.y);}
  V operator-(const V& p) const { return V(x-p.x, y-p.y);}
  V operator*(double a) const { return V(x*a, y*a);}
  double sqrNorm() const { return x*x+y*y;}
  double norm() const { return sqrt(sqrNorm());}
  V rotate90() const { return V(y, -x);}
};

struct Circle {
  V o; double r;
  Circle(V o=V(), double r=0) : o(o), r(r) {}
  vector<V> xp(const Circle& c) {
    V v = c.o-o;
    double l = v.norm();
    if (equal(l, 0)) return {};
    if (equal(l+r+c.r, max({l,r,c.r})*2)) {
      return {o + v*(r/l)};
    }
    if (l+r+c.r < max({l,r,c.r})*2) return {};
    double x = -(c.r*c.r - l*l - r*r) / (2*l);
    double y = sqrt(r*r - x*x);
    V mid = o + v*(x/l);
    v = v.rotate90();
    return {mid + v*(y/l), mid - v*(y/l)};
  }
  bool isInside(const V& p) {
    return (p-o).norm() < r+eps;
  }
};

int main() {
  int n, k;
  cin >> n >> k;
  if (k == 1) {
    cout << 0 << endl;
    return 0;
  }
  vector<Circle> c(n);
  rep(i,n) {
    cin >> c[i].o.x >> c[i].o.y >> c[i].r;
  }
  double l = 0, r = 400000;
  rep(ti,100) {
    double x = (l+r)/2;
    vector<V> ps;
    rep(i,n) ps.push_back(c[i].o);
    rep(i,n)rep(j,i) {
      Circle a = c[i], b = c[j];
      a.r = x/a.r;
      b.r = x/b.r;
      auto tmp = a.xp(b);
      ps.insert(ps.end(), tmp.begin(), tmp.end());
    }
    bool ok = false;
    for (V p : ps) {
      int cnt = 0;
      rep(ci,n) {
        Circle nc = c[ci];
        nc.r = x/nc.r;
        if (nc.isInside(p)) cnt++;
      }
      if (cnt >= k) ok = true;
    }
    if (ok) r = x; else l = x;
  }
  printf("%.10f\n", r);
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    int n,t[102],v[102],m=0;
    double w[50000],z=0;
    cin>>n;
    t[0]=0;
    for(int i=1;i<=n;i++){
        cin>>t[i];
        t[i]+=t[i-1];
    }
    for(int i=1;i<=n;i++){
        cin>>v[i];
    }
    m=t[n]*2;
    int a=1;
    w[0]=0;
    for(int i=1;i<=m;i++){
        while((i+1)/2>t[a]){
            a++;
        }
        w[i]=min((double)w[i-1]+0.5, (double)v[a]);
    }
    a=n;
    w[m]=0;
    for(int i=m-1;i>=0;i--){
        while(i/2<t[a-1]){
            a--;
        }
        w[i]=min((double)w[i+1]+0.5, min(w[i],(double)v[a]));
    }
    //cout<<setprecision(20)<<z<<endl;
    for(int i=1;i<=m;i++){
        z+=(w[i]+w[i-1])/4;
        //cout<<"---"<<i<<":"<<w[i]<<endl;
    }

    cout<<setprecision(20)<<z<<endl;

}


Measured memory_bytes: 512
using namespace std;
#include <bits/stdc++.h>
#define frr(i, r, l) for(int i = r; i >= l; --i)
#define fr(i, l, r) for(int i = l; i < r; ++i)
#define forit(it, type, var) for(type::iterator it = var.begin(); it != var.end(); it++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define MEMS(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define m_p make_pair
#define pb push_back
#define ll long long
#define ld long double
typedef pair<ll, ll> iPair; 
priority_queue< ll, vector <ll> , greater<ll>>pq1,pq2;
#define maxN 1000000000000000000
ll power(ll a,ll b){ll res=1;while(b>0){res*=a;b--;}return res;}
int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,a[200005];
    cin>>n;
    fr(i,0,n)
    {
        cin>>x;
        a[i]=x;
    }
    ll sum=0;
    fr(i,1,n)
    {
        if(a[i]>=a[i-1])
        continue;
        sum+=a[i-1]-a[i];
        a[i]=a[i-1];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 5192
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

double f(int n, int k){
  double ret = 0;
  for(int i = 1; i <= n; i++){
    double temp = i;
    double p = (double) 1 / n;
    while(temp < k){
      p /= 2;
      temp *= 2;
    }
    ret += p;
  }
  return ret;
}

int main(void){
  int n, k;
  cin >> n >> k;
  printf("%.15lf\n", f(n, k));
  return 0;
}


Measured memory_bytes: 256
lines=readlines(open("/dev/fd/0"))
input()=shift!(lines)
int(s::String)=parse(Int,s)
int(s::SubString{String})=parse(Int,s)
int(s::Array{SubString{String},1})=map(int,s)
function main()
    INF=2^60
    a,b,q=input()|>split|>int
    s=Array{Int}(a+2)
    s[1],s[a+2]=-INF,INF
    for i in 2:a+1
      s[i]=int(input())
    end
    t=Array{Int}(b+2)
    t[1],t[b+2]=-INF,INF
    for i in 2:b+1
      t[i]=int(input())
    end
    for _ in 1:q
        x=int(input())
        m=INF
        i=searchsortedlast(s,x)
        j=searchsortedlast(t,x)
        for v in view(s,i:i+1)
            for w in view(t,j:j+1)
                m=min(m,abs(x-v)+abs(v-w),abs(x-w)+abs(w-v))
            end
        end
        println(m)
    end
end
main()

Measured memory_bytes: 172260
#include <cstdlib>
#include <iostream>
#include <typeinfo>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int &i : a)
    cin >> i;
  vector<int> num(n, 0);
  for (int i : a)
  {
    num.at(i - 1)++;
  }
  int count = 0;
  for (int i : num)
  {
    if (i > 0)
      count++;
  }
  sort(num.begin(), num.end());
  count -= k;
  int ans = 0;
  int c = 0;
  for (int i : num)
  {
    if(i>0){
      c++;
      ans += i;
    }
    if(c>=count){
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
typedef string::const_iterator State;

string expression(State &begin);
string letter(State &begin);

string letter(State &begin){
	int next=0;
	while(*begin=='+' || *begin=='-'){
		if(*begin=='+')next++;
		else next--;
		begin++;
	}
	next=(next+*begin-'A'+26000)%26;
	string res="";
	res+=next+'A';
	begin++;
	return res;
}


string expression(State &begin){
	string str="";
	while(1){
		if(*begin=='+' || *begin=='-' || (*begin>='A' && *begin<='Z')){
			str+=letter(begin);
		}else if(*begin=='['){
			begin++;
			string st=expression(begin);
			begin++;
			reverse(st.begin(),st.end());
			str+=st;
		}else break;
	}
	return str;
}

bool flag=false;
string str,res;

void dfs(int v){
	if(v==str.size()){
		State begin=str.begin();
		string kt=expression(begin);
		if(!flag || kt<res){
			res=kt;
			flag=true;
		}
	}else{
		if(str[v]=='?'){
			for(int i=0;i<26;i++){
				str[v]='A'+i;
				dfs(v+1);
			}
			str[v]='?';
		}else dfs(v+1);
	}
}

int main(void){
	while(1){
		cin >> str;
		if(str==".")break;
		flag=false;
		dfs(0);
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
input = sys.stdin.readline

# bisect_left(lists, 3)
# bisect_right(lists, 3)

def main():
	A, B, C = map(int, input().split(" "))

	if A < C and B > C:
		print("Yes")
		sys.exit()
	if B < C and A > C:
		print("Yes")
		sys.exit()
	
	print("No")

	
	
if __name__ == "__main__":
	main()
	

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

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

const int INF = 1001001001001001001LL;

const int DX[4] = {0, 1, 0, -1};
const int DY[4] = {-1, 0, 1, 0};

signed main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    vector<int> one(61), zero(61);
    for (int i = 0; i < 61; i++) {
        for (int j = 0; j < N; j++) {
            if (A[j] >> i & 1) {
                one[i]++;
            } else {
                zero[i]++;
            }
        }
    }

    vector<vector<int>> dp(61, vector<int>(2, INF));
    auto rec = [&](auto fun, int i, bool less) -> int {
        if (i == -1) return 0;
        auto &DP = dp[i][less];
        if (DP != INF) return DP;
        int ret = 0;
        if (less) {
            // 1
            chmax(ret, fun(fun, i - 1, true) + (1LL << i) * zero[i]);
            // 0
            chmax(ret, fun(fun, i - 1, true) + (1LL << i) * one[i]);
        } else {
            if (K >> i & 1) {
                // 1
                chmax(ret, fun(fun, i - 1, false) + (1LL << i) * zero[i]);
                // 0
                chmax(ret, fun(fun, i - 1, true) + (1LL << i) * one[i]);
            } else {
                // 0
                chmax(ret, fun(fun, i - 1, false) + (1LL << i) * one[i]);
            }
        }
        return DP = ret;
    };
    cout << rec(rec, 60, false) << endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    vector<int> vec;
    cin >> n;
    imfor(i, n) {
        int a;
        cin >> a;
        vec.push_back(-a); 
    }
    sort(vec.begin(), vec.end());
    int cnt = 0;
    int al = 0;
    int bo = 0;
    for (int x : vec) {
        cnt++;
        if (cnt % 2 == 1) {
            al += -x;
        }
        else { 
            bo += -x;
        }
    }
    cout << al - bo << endl;
}

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

public class Main{
	static boolean map[][] = new boolean[11][11];
	static int x = 1, y = 1, vec = 0;
	static int dir[] = new int[]{3, 0, 1, 2};
	static int dx[][] = new int[][]{{1, 0, -1, 0}, {2, 0, -2, 0}};
	static int dy[][] = new int[][]{{0, 1, 0, -1}, {0, 2, 0, -2}};
	static String opr[] = new String[]{"R", "D", "L", "U"};
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		Main app = new Main();
		char str[];
		
		int tmp;
		for(int i = 0; i < 9; i++){
			str = reader.readLine().toCharArray();
			if(i % 2 == 0){
				for(int j = 0; j < 4; j++){
					tmp = str[j] - '0';
					if(tmp == 1){
						map[(i / 2) * 2 + 1][j * 2 + 1] = true;
						map[(i / 2) * 2 + 1][(j + 1) * 2] = true;
						map[(i / 2) * 2 + 1][(j + 1) * 2 + 1] = true;
					}
				}
			}else{
				for(int j = 0; j < 5; j++){
					tmp = str[j] - '0';
					if(tmp == 1){
						map[(i / 2 + 1) * 2][j * 2 + 1] = true;
						map[(i / 2 + 1) * 2 + 1][j * 2 + 1] = true;
					}
				}
			}
		}
		app.solve();
		
		reader.close();
	}
	
	public void solve(){
		int tmp;
		boolean next = true;
		while(next){
			for(int i = 0; i < 4; i++){
				tmp = (dir[vec] + i) % 4;
				if(map[y + dy[0][tmp]][x + dx[0][tmp]]){
					y += dy[1][tmp];
					x += dx[1][tmp];
					
					vec = tmp;
					System.out.print(opr[tmp]);
					if(x == 1 && y == 1) next = false;
					break;
				}
			}
		}
		System.out.println();
	}
}

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

int main()
{
    int n; cin>>n;
    array<int, 3> a; for(auto& e: a) cin>>e;
    vector<int> L(n); for(auto& e: L) cin>>e;

    int res=1<<30;
    for(int i=0; i<(1<<(2*n)); ++i) {
        array<int, 3> sum={}, cnt={};
        for(int j=0; j<n; ++j) {
            int m=(i>>(2*j))&3;
            if (m==3) continue;
            sum[m]+=L[j];
            cnt[m]++;
        }
        if (count(begin(cnt), end(cnt), 0)>0) continue;
        int cost=0;
        for(int j=0; j<3; ++j) {
            cost+=abs(sum[j]-a[j]);
            if (cnt[j]>1) cost+=10*(cnt[j]-1);
        }
        res=min(res, cost);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
n, m, q = map(int,input().split())
LR = [list(map(int,input().split())) for _ in range(m)]
PQ = [list(map(int,input().split())) for _ in range(q)]

# 二次元累積和
rui = [[0] * (n + 1) for _ in range(n + 1)]
for l, r in LR:
  rui[l][r] += 1

for i in range(n):
  for j in range(n+1):
    rui[i+1][j] += rui[i][j]

for i in range(n+1):
  for j in range(n):
    rui[i][j+1] += rui[i][j]

for i, j in PQ:
  print(rui[j][j] + rui[i-1][i-1] - rui[j][i-1] - rui[i-1][j])

Measured memory_bytes: 77172
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i > (b); --i)
#define SZ(a) a.size()
#define ll long long
#define ull unsigned long long
using namespace std;

int main() {

	int N=0;
	int X=0;

	cin >> N >> X;

	int m[100];
	int sum = 0;
	int min = 1001;

	FOR(i, 0, 100)
		m[i] = 1001;
	FOR(i, 0, N) {
		cin >> m[i];
		sum += m[i];
		if (m[i] < min) 
			min = m[i];
	}
	
	
	int additional = 0;
	X -= sum;

	additional = X / min;

	cout << N + additional << endl;

	system("pause");
	return 0;
}

Measured memory_bytes: 504
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int H = cin.nextInt();
        int W = cin.nextInt();
        Console.WriteLine(new string('#', W + 2));
        for (int i = 0; i < H; i++)
        {
            Console.WriteLine("#" + cin.next() + "#");
        }
        Console.WriteLine(new string('#', W + 2));
    }

}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


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


namespace TestApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine()
                .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(x => int.Parse(x))
                .ToList();
            if ((str[0] * str[1])%2 == 0)
                Console.WriteLine("Even");
            else
                Console.WriteLine("Odd");
        }
    }

}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a<=5){
        cout<<"0";
    }
    else if(a>12){
            cout<<b;
    }
    else if(6<=a||a<=12){
        cout<<b/2;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{

  public static int[][][] residents = new int[4][3][10];
  static int b,f,r,v;
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      for (int i=0; i<n; i++) {
      b = sc.nextInt();
      f = sc.nextInt();
      r = sc.nextInt();
      v = sc.nextInt();
      residents[b-1][f-1][r-1] += v;
      }
      for(int j = 0; j<4; j++){
        for(int k = 0; k<3; k++){
          for(int l = 0; l<10 ; l++) {
            System.out.print(" " + residents[j][k][l]);
          }
          System.out.println();
        }
        if (j != 3) {
        System.out.println("####################");
        }
      }
  }
}



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

int cnt = 0;
int n;
void dfs (long long a, int use) {
    if (a > n) return;
    if (use == 0b111) cnt++;
    dfs(a*10 + 7, use | 0b100);
    dfs(a*10 + 5, use | 0b010);
    dfs(a*10 + 3, use | 0b001);
}

int main() {
    cin >> n;
    dfs(0, 0);
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll dp[105][100005];
ll w[105],v[105];
ll n,k;
ll func(int i,int j){
    if(i>=n){
        return 0;
    }
    if(j>k)
        return 0;

    if(dp[i][j]!=-1)
        return dp[i][j];

    ll ans=1e9;

    if(j+w[i]>k){
        ans=func(i+1,j);
    }
    else{
        ans=max(func(i+1,j),func(i+1,j+w[i])+v[i]);
    }
    return dp[i][j]=ans;
}
int main(){
    cin>>n>>k;

    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++)
        cin>>w[i]>>v[i];

    cout<<func(0,0);
}

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

const int INF = 1e9;

int main() {
  char b;
  cin>>b;
  if(b=='A') {
    cout<<('T')<<endl;;
  }else if(b=='C'){
    cout<<('G')<<endl;;
  }else if(b=='G'){
    cout<<('C')<<endl;;
  }else if(b=='T'){
    cout<<('A')<<endl;;
  }

}

Measured memory_bytes: 256
import math

dish=[int(input()) for _ in range(5)]
count={str(i%10):[] for i in range(10,-1,-1)}
for t in dish:
	one=t%10
	count[str(one)].append(t)

ans=0
d=0
for k,v in count.items():
	if v!=[]:
		for c in v:
			if d>3:
				ans+=c
			else:
				ans+=math.ceil(c/10)*10
				d+=1
print(int(ans))

Measured memory_bytes: 9088
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

string S;

int main() {
	cin >> S;
	LL N = S.size();
	LL ans = N * (N - 1) / 2 + 1;
	map<char, LL>mp;
	for (LL i = 0; i < N; ++i) {
		mp[S[i]]++;

	}
	for (auto p : mp) {
		ans -= p.second * (p.second - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<b){
		if(b<c){
		printf("Yes\n");
	}
		else{
		printf("No\n");
 
	}
}
	else{
	printf("No\n");
}
	return 0;
}

Measured memory_bytes: 580
N = int(input())
A = [int(i) for i in input().split()]

A.sort()
size = A[0]
cnt = 1
for i in range(1, N):
    if size*2 >= A[i]:
        cnt += 1
    else:
        cnt = 1
    size = size + A[i]
print(cnt)


Measured memory_bytes: 63984
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
 
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値
 
ll dp[MX][MX];
inline void chmax(ll& a, ll b) {
  a = max(a, b);
}
 
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define PB push_back
 
 
int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n);
    rep(i,n) cin >> p.at(i);
    sort(ALL(p));
    ll ans = 0;
    rep(i,k) ans+= p.at(i);
    cout << ans << endl;
}

Measured memory_bytes: 3632
macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();input_inner!{iter, $($r)*}};($($r:tt)*) => {let mut s = {use std::io::Read;let mut s = String::new();std::io::stdin().read_to_string(&mut s).unwrap();s};let mut iter = s.split_whitespace();input_inner!{iter, $($r)*}};
}

macro_rules! input_inner {($iter:expr) => {};($iter:expr, ) => {};($iter:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($iter, $t);input_inner!{$iter $($r)*}};
}

macro_rules! read_value {($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};($iter:expr, usize1) => {read_value!($iter, usize) - 1};($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};
}

const TAX: f64 = 1.08;
const TAX_INV: f64 = 1.0/1.08;

fn main() {
    input!{
        n: usize,
    }
    let notax = (n as f64) * TAX_INV;
    let notax_ceil = notax.ceil();
    let notax_floor = notax.floor();
    if n == (notax_ceil*TAX) as usize {
        println!("{}", notax_ceil as usize);
    } else if n == (notax_floor*TAX) as usize {
        println!("{}", notax_floor as usize);
    } else {
        println!(":(");
    }
}


Measured memory_bytes: 2572
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
Max = 0

for i in range(N):
    if V[i] <= C[i]:
        continue
    X,Y = V[i],C[i]
    tmpMax = X - Y
    for j in range(i+1,N):
        if V[j] <= C[j]:
            continue
        if Max < (X + V[j]) - (Y + C[j]):
            X = X + V[j]
            Y = Y + C[j]
            tmpMax = X - Y
    if Max < tmpMax:
        Max = tmpMax
        
print(Max)

Measured memory_bytes: 3064
n, q = map(int, input().split())
stack = [[] for _ in range(n)]

for _ in range(q):
    query = list(map(int, input().split()))
    if query[0] == 0:
        stack[query[1]].append(query[2])
    elif query[0] == 1:
        if stack[query[1]] == []:
            pass
        else:
            print(stack[query[1]][0])
    elif query[0] == 2:
        if stack[query[1]] == []:
            pass
        else:
            stack[query[1]].pop(0)



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repab(i, a, b) for (int i = a; i <= (int)(b); i++)
#define ll long long
#define vec vector
#define pb push_back
#define ft first
#define sd second
#define all(vec) vec.begin(), vec.end()
#define endl "\n"

typedef pair<int, int> P;

const int MOD = 1e9 + 7;
const int INF = 1001001001;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};

//--//--//--//--//--//--//--//--//--//--//--//

const int A = 1000005;

int main(){
  int n;
  cin >> n;
  vec<int> a(n);
  vec<int> c(A);
  rep(i, n){
    cin >> a[i];
    c[a[i]]++;
  }

  bool pairwise = true;
  for(int i = 2; i < A; i++){
    int cnt = 0;
    for(int j = i; j < A; j += i){
      cnt += c[j];
    }
    if(cnt > 1){
      pairwise = false;
    }
  }

  if(pairwise){
    cout << "pairwise coprime" << endl;
    return 0;
  }

  int g = 0;
  rep(i, n){
    g = gcd(g, a[i]);
    if(g == 1){
      cout << "setwise coprime" << endl;
      return 0;
    }
  }

  cout << "not coprime" << endl;
  
  return 0;
}

Measured memory_bytes: 11108
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = a;i < n;i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;


ull gcd(ull a,ull b){
	if(!b) return a;
	return gcd(b,a%b);
}

int main(){
	ull n,cnt = 0;
	cin >> n;
	ull a[n],type = 0;
	
	rep(i,0,n){
		cin >> a[i];
		
		if(type == 2){
			if(a[i] < a[i-1]){
				type = 0;
			}
		}
		if(type == 3){
			if(a[i] > a[i-1]){
				type = 0;
			}
		}
		if(type == 1){
			if(a[i] > a[i-1]){
				type = 2;
			}
			else if(a[i] < a[i-1]){
				type = 3;
			}
		}
		if(type == 0){
			cnt++;
			type = 1;
		}
		
	}
	
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<queue>

using namespace std;
vector<int> ans;
typedef pair <int, int> P;

int  main(){
  int W,H;
  cin >> W >> H;
  int tate[4] = {0,1,0,-1};
  int yoko[4] = {1,0,-1,0};
  while(W){
    int count = 0;
    queue < P > zahyou;
    vector< vector<int> > room(H, vector<int>(W));
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
        char a;
        cin >> a;
        if(a == '.')room[i][j] = 1;
        else if(a == '@'){
          zahyou.push( P (i,j) );
          room[i][j] = 1;
        }
        else room[i][j] = 0;
      }
    }
    while(zahyou.size()){
      pair<int, int> now = zahyou.front();
      zahyou.pop();
      if(room[now.first][now.second] == 1){
        count++;
        room[now.first][now.second] = 0;
        for(int i = 0; i < 4 ; i++){
          if(now.first+tate[i]>=0 && now.first+tate[i] < H && now.second+yoko[i] >= 0 && now.second+yoko[i] < W && room[now.first+tate[i]][now.second+yoko[i]] == 1)
            zahyou.push( P (now.first+tate[i], now.second+yoko[i]));
        }
      }
    }
    ans.push_back(count);
    cin >> W >> H;
  }
  for(int i = 0 ; i < ans.size(); i++)
    cout << ans[i] << endl;
}



Measured memory_bytes: 3116
# coding: utf-8


# n_run = 0
# ans = -1


def rec(x, digit, K):
    # global n_run, ans
    global candidates

    # if ans > 0:
    #     return None
    # # print(x)
    # if len(str(x)) > digit:
    #     return None
    
    if len(str(x)) == digit:
        candidates.append(x)
        return None
        # n_run += 1

    # if n_run == K:
    #     # print(x)
    #     ans = x
    #     # print(type(x))
    #     # input()
    #     return x
        
    tail = int(str(x)[-1])
    if tail == 0:
        rec(10*x + 0, digit, K)
        rec(10*x + 1, digit, K)
    elif tail == 9:
        rec(10*x + 8, digit, K)
        rec(10*x + 9, digit, K)
    else:
        rec(10*x + tail-1, digit, K)
        rec(10*x + tail, digit, K)
        rec(10*x + tail+1, digit, K)


def main():
    global candidates

    K = int(input())

    # def rec(x, digit):
    #     if len(str(x)) > digit:
    #         return None
            
    #     global n_run

    #     if len(str(x)) == digit:
    #         n_run += 1

    #     if n_run == K:
    #         return x

    #     tail = int(str(x)[0])
    #     if tail == 0:
    #         rec(10*x + 0)
    #         rec(10*x + 1)
    #     elif tail == 9:
    #         rec(10*x + 8)
    #         rec(10*x + 9)
    #     else:
    #         rec(10*x + tail-1)
    #         rec(10*x + tail)
    #         rec(10*x + tail+1)

    n_run = 0
    n_digit = 1
    while True:  # 桁数についてのループ
        candidates = []
        for x in range(1, 10):
            rec(x, n_digit, K)
            
            # if ans > 0:
            #     return ans
            # print("BBB")
        if n_run + len(candidates) >= K:
            return candidates[K-n_run-1]
        
        n_run += len(candidates)
        n_digit += 1
        # print("CCC")
    # print("DDD")


print(main())


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

using namespace std;

int dp[3001][3001];

int main() {
  int N,T; cin >> N >> T;
  vector<pair<int,int> > ab(N);
  for(auto&a:ab) cin >> a.first >> a.second;
  sort(ab.begin(),ab.end());
  int ans=0;
  for(int i=1;i<=N;++i) {
    for(int j=0;j<T;++j) {
      ans=max(ans,dp[i-1][j]+ab[i-1].second); //最後に注文する料理がi-1
      if(j<ab[i-1].first) dp[i][j]=dp[i-1][j];
      else dp[i][j]=max(dp[i-1][j],dp[i-1][j-ab[i-1].first]+ab[i-1].second);
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 35456
N,M = map(int,input().split())
if N >= M:
  print(0)
  exit()
X = list(map(int,input().split()))
X.sort()
dis = []
for i in range(M-1):
  dis.append(X[i+1] - X[i])
dis.sort()
print(sum(dis[:len(dis)-(N-1)]))

Measured memory_bytes: 13960
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	while (1) {
		int n; cin >> n;
		if (n == -1)break;
		else if (n == 0) {
			cout << 0 << endl;
		}
		else {
			string st;
			while (n) {
				st.push_back(n%4 + '0');
				n /= 4;
			}
			reverse(st.begin(), st.end());
			cout << st << endl;
		}
	}
	return 0;
}

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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

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

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*
    add utility Algorithm
*/


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

    ll X;
    cin >> X;

    ll ans = 100;
    ll tmp = 0;
    while (ans < X) {
        ans = (ll)(ans * (double)1.01);
        tmp++;
    }

    cout << tmp << endl;

    return 0;
}


Measured memory_bytes: 3664
#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)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;

struct Node {
  int key;
  Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k) {
  Node *y = NIL, *x = root, *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    }
    else {
      x = x->right;
    }
  }

  z->parent = y;
  if (y == NIL) {
    root = z;
  }
  else {
    if (z->key < y->key) {
      y->left = z;
    }
    else {
      y->right = z;
    }
  }
}

void preorder(Node *u) {
  if (u == NIL) return;
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);
}

void inorder(Node *u) {
  if (u == NIL) return;
  inorder(u->left);
  cout << " " << u->key;
  inorder(u->right);
}

void print() {
  inorder(root);
  cout << endl;
  preorder(root);
  cout << endl;
}

bool find(int k) {
  Node *x = root;
  while (x!= NIL && x->key != k) {
    if (k < x->key) {
      x = x->left;
    }
    else {
      x = x->right;
    }
  }
  if (x != NIL) return true;
  else return false;
}

int main() {
  int q, k;
  cin >> q;
  string com;
  rep(i, q) {
    cin >> com;
    if (com[0] == 'i') {
      cin >> k;
      insert(k);
    }
    else if (com[0] == 'p') {
      print();
    }
    else {
      cin >> k;
      if (find(k)) cout << "yes" << endl;
      else cout << "no" << endl;
    }
  }


  
  return 0;
}


Measured memory_bytes: 21904
#include <stdio.h>
#define M 1000000007
typedef long long LL;

LL qpow(LL x, int y)
{
	if(!y) return 1;
	LL t = qpow(x, y >> 1);
	t = t * t % M;
	if(y & 1) t = t * x % M;
	return t;
}

int main() 
{
	int n, a, b, i, x;
	LL ans, f1 = 1, f2 = 1, t;
	
	scanf("%d%d%d", &n, &a, &b);
	ans = qpow(2, n) - 1;
	for(i = 1, x = n; i <= a; i++, x--){
		f1 = f1 * (LL)i % M;
		f2 = f2 * (LL)x % M;
	}
	t = f2 * qpow(f1, M - 2) % M;
	ans -= t;
	if(ans < 0) ans += M;
	for( ; i <= b; i++, x--){
		f1 = f1 * (LL)i % M;
		f2 = f2 * (LL)x % M;
	}
	t = f2 * qpow(f1, M - 2) % M;
	ans -= t;
	if(ans < 0) ans += M;
	printf("%lld\n", ans);	
			
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>

using namespace std;

int main(){
	char c[3];
	string s[3];
	for(int i = 0; i < 3; i++){
		cin >> s[i];
	}

	for(int i = 0; i < 3; i++){
		c[i] = toupper(s[i][0]);
		cout << c[i];
	}
	
	cout << endl;
	
	return 0;
}

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

using namespace std;

using int64 = long long;

int main() {
  int N, K, A[1000];
  cin >> N >> K;
  for(int i = 0; i < N; i++) cin >> A[i];

  auto check = [&](int64 V) {
    int64 ret = 0;
    for(int i = 0; i < N; i++) {
      int64 all = 0;
      for(int j = i; j < N; j++) {
        all += A[j];
        if((all & V) >= V) ++ret;
      }
    }
    return ret >= K;
  };

  int64 bit = 0;
  for(int64 i = 50; i >= 0; i--) {
    if(check(bit | (1LL << i))) bit |= 1LL << i;
  }
  cout << bit << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const double PI  =3.141592653589793238463;
long long mod = 1000000007;
int stringToInteger(string x){
    int gg=0;
    stringstream geek(x);
    geek >> gg;
    return gg;
}

ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}
bool prime[100005];
void seive()
{  memset(prime,true,sizeof(prime));
    for(int i=2;i*i<=100005;i++)
    {
         if(prime[i]==true) {
        for(int j=2*i;j<=(100005);j+=i)
           { prime[j]=false;}
           }

    }
}








ll f[5000001];

ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a;
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD;
 	b /= 2;
 	}
 return x;
}

/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}

ll C(ll n, ll r, ll MOD)
{

 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
vector<int>v[200005];
int val[200005]={0};
void dfs(int i,int p)
{
    for(auto j:v[i]){
        if(j!=p) {
            val[j]+=val[i];
            dfs(j,i);
        }
    }
}
int main()
{
    int n,q;
    cin>>n>>q;
    for(int i=0;i<n-1;i++)
    {
        int a;int b; cin>>a>>b;
        v[a].pb(b); v[b].pb(a);
    }
    for(int i=0;i<q;i++)
    {
        int m,v; cin>>m>>v; val[m]+=v;
    }
    dfs(1,0);
    for(int i=1;i<=n;i++ ) cout<<val[i]<<" ";

}









Measured memory_bytes: 24192
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

const int INF = (int)1e9;

void calc(int n){
  char c[101];
  int have[10]={0},ba=0;
  
  scanf("%s",c);

  for(int i=0;i<100;i++){
    if(c[i]=='M'){
      have[i%n]++;
    }else if(c[i]=='S'){
      ba += have[i%n] + 1;
      have[i%n] = 0;
    }else{
      have[i%n] += ba + 1;
      ba = 0;
    }
  }

  sort(have,have+n);

  for(int i=0;i<n;i++){
    cout << have[i] << " ";
  }
  cout << ba << endl;

  return;
}
  

int main(){
  int n;

  while(1){
    scanf("%d",&n);

    if(n==0) break;
    calc(n);
  }

  return 0;
}

Measured memory_bytes: 1228
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

MOD = 10**9 + 7

S = read().rstrip().decode('utf-8')

num = [0,0,0,0,0,0]
ques = [0,0,0,0,0,0]
for i,x in enumerate(S[::-1]):
    i %= 6
    if x == '?':
        ques[i] += 1
    else:
        num[i] += int(x)

ten = np.array([1]*10+[0,0,0],dtype=np.uint64)

def power(n):
    # (1+x+...+x^9)^n, x^13=1
    if n == 0:
        x = np.zeros(13,dtype=np.uint64)
        x[0] = 1
        return x
    x = power(n//2)
    x = np.convolve(x,x) % MOD
    x[0:12] += x[13:25]; x = x[:13]; x[x>=MOD] -= MOD
    if n&1:
        x = np.convolve(x,ten)
        x[0:12] += x[13:25]; x = x[:13]; x %= MOD
    return x

dp = [power(n) for n in ques]

pow10 = [1,10,9,12,3,4]

x = power(0)
for i,y in enumerate(dp):
    p = pow10[i]
    y[p*np.arange(13)%13] = y.copy()
    x = np.convolve(x,y) % MOD
    x[0:12] += x[13:25]; x = x[:13]; x[x>=MOD] -= MOD

n = sum(p*n for p,n in zip(pow10,num))%13

answer = x[(18-n)%13]
print(answer)

Measured memory_bytes: 12684
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

int cmp(const void *a, const void *b){
    if(*(ll*)a > *(ll*)b)return 1;
    else return -1;
}

const ll INF = 1000000000000000000ll;
ll n, a[100100];

main(){
    scanf("%lld", &n);
    for(int i=0; i<n; i++){
        scanf("%lld", &a[i]);
    }
    qsort(a, n, sizeof(ll), cmp);
    __int128_t ans = 1;
    for(int i=0; i<n; i++){
        ans *= a[i];
        if(ans > INF){
            ans = -1ll;
            break;
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 3100
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse=True)
    retval = 0
    memo = {}
    for a in A:
        pair_created = False
        for i in range(30, 0, -1):
            s = pow(2, i)
            if a < s and (s-a) in memo and memo[s-a]:
                memo[s-a] -= 1
                pair_created = True
                break
        if pair_created:
            retval += 1
            continue
        if a not in memo:
            memo[a] = 0
        memo[a] += 1
    print(retval)


if __name__ == "__main__":
    main()


Measured memory_bytes: 106960
#include <iostream>
#define LARGE 20000000
using namespace std;

int h,w;
int map[50][50];
int n[50][50]; // (i,j)ÂÃÂsÂÂ­ÂÂÂÃÂÃÂÂ¬ÂÃÂZÂ~ÂÃÂÂ

void pr( int a[50][50] ){
  for( int i=0;i<h;i++ ){
    for( int j=0;j<w;j++ )
      cout << a[i][j] << " ";
    cout << endl;
  }
}
int main(){
  char c;

  cin >> h >> w;
  for( int i=0;i<h;i++ )
    for( int j=0;j<w;j++ ){
      cin>> c;
      map[i][j] = c-'0';
    }
  //  pr( map );
  
  int k,l;
  for( int i=0;i<h;i++ ){
    for( int j=0;j<w;j++ ){
      if( i>0 ) k=n[i-1][j];   else k=LARGE;
      if( j>0 ) l=n[i][j-1];   else l=LARGE;
      if( !i && !j ) k=0;
      n[i][j] = min( k,l ) + map[i][j];
    }
    //    pr(n);
  }
  cout << n[h-1][w-1] << endl;
  //  pr( n );

  return 0;
}

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

int main(){
  int W, H, x, y;
  cin >> W >> H >> x >> y;
  
  double area = (double)W*H/2;
  if(W == x+x && H == y+y){
    cout << area << " 1";
  }else{
    cout << area << " 0";
  }
  return 0;
}

Measured memory_bytes: 256