akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
def fac(n,a):
  ans = 1
  for i in range(n,n-a,-1):
    ans *= i
    ans %= mod
  return ans
def cmb(n, a, mod):
    ans = fac(n,a)
    inv = fac(a,a-1)
    return (ans*pow(inv,mod-2,mod)) % mod

n,a,b = map(int,input().split())
mod = 10**9 + 7
#他人のコードパクったけど高速化の理由不明
"""
def pow(n,b,mod):
  if n == 0: return 1
  if n % 2: return 2 * pow(n//2,b,mod)**2 % mod
  else: return pow(n//2,b,mod)**2 % mod"""
print((pow(2,n,mod) - 1 - cmb(n,a,mod) - cmb(n,b,mod))%mod)


Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#pragma GCC target("sse4.1")

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n) for (int i = ((int)(n) - 1); i >= 0; --i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef pair<int, int> pii;
typedef vector<pii> vii;
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr);
#else
#define eprintf(args...) ;
#endif

const int mod = 998244353;

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

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

int mult (int a, int b)
{
    return (ll)a * b % mod;
}

int k, n;

bool read ()
{
    if (!(cin >> k >> n))
        return false;

    return true;
}

vi solve ()
{
    vi pairs (2 * k - 1);

    forn (i, k) forn (j, k) if (i < j)
        pairs[i + j]++;

    const int bound = n + k + 1;
    vvi C(bound, vi (bound));

    forn (i, bound)
    {
        C[i][i] = C[i][0] = 1;
        for (int j = 1; j < i; j++)
        {
            C[i][j] = C[i - 1][j - 1];
            add(C[i][j], C[i - 1][j]);
        }
    }

    auto part = [&] (int what, int to) -> int
    {
        if (to == 0)
            return what == 0 ? 1 : 0;
        return C[what + to - 1][to - 1];
    };

    vi pw2 (bound, 1);
    forn (i, bound) if (i)
        pw2[i] = mult(pw2[i - 1], 2);

    vvi pr_part (k + 1, vi (n + 1));
    pr_part[0][0] = 1;

    forn (paired, k)
    {
        int sum = 0;
        forn (curn, n + 1)
        {
            add (pr_part[paired + 1][curn], pr_part[paired][curn]);
            add (pr_part[paired + 1][curn], sum);
            add (sum, mult (2, pr_part[paired][curn]));
        }
    }

    auto add_res = [&] (int tn, int paired, int free) -> int
    {
        int ans = 0;
        forn (i, tn + 1)
            add (ans, mult (pr_part[paired][i], part (tn - i, free)));

        return ans;
    };

    vi ans (2 * k - 1);
    forn (sum, 2 * k - 1)
    {
        const int cur_pr = pairs[sum];

        int &cur = ans[sum];
        const int decr = (sum % 2 == 0 ? 1 : 0);
        {
            assert (k - decr - 2 * cur_pr >= 0);
            forn (take, decr + 1)
                add(cur, add_res (n - take, cur_pr, k - decr - 2 * cur_pr));
        }
    }

    return ans;
}

int32_t main()
{
#ifdef LOCAL
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
    {
        auto ans = solve();
        for (int x : ans)
            cout << x << '\n';

#ifdef LOCAL
        cout << '\n';
#endif // LOCAL
    }

    return 0;
}


Measured memory_bytes: 78720
n,a,b = map(int, input().split())

ans = pow(2,n,10**9+7)

nm= 1
dn = 1

for i in range(a):
  nm = (nm * (n-i)) % (10**9+7)
  dn = (dn * (i+1)) % (10**9+7)

ans = (ans - nm*pow(dn,-1,10**9+7) - 1) % (10**9+7)

for i in range(a,b):
  nm = (nm * (n-i)) % (10**9+7)
  dn = (dn * (i+1)) % (10**9+7)

ans = (ans - nm*pow(dn,-1,10**9+7)) % (10**9+7)

print(ans)

Measured memory_bytes: 9152
program sample
    implicit none
    character(200000)::s
    integer(8) :: i,j,m,n
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) s
    n=len_trim(s)
    allocate(x(n))
    x(:)=1
    do i=1,n-1

        if(s(i:i+1) .eq. 'RR')then
            x(i+2)=x(i+2)+x(i)
            x(i)=0
        end if
    end do
    do i=n,2,-1

        if(s(i-1:i) .eq. 'LL')then
            x(i-2)=x(i-2)+x(i)
            x(i)=0
        end if
    end do

  
    write(*,*) x
  
    stop
end program sample
  



Measured memory_bytes: 4500
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main(int argc, char *argv[])
{
  int n;
  cin >> n;
  for (int i = 1; i <= 9; ++i) {
    for (int j = 1; j <= 9; j++) {
      if (i * j == n) {
        cout << "Yes";
        return 0;
      }
    }
  }
  cout << "No";
}


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

/**
 * Created by kazuki on 2014/06/26.
 */
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int[] numArray,renumArray;
        int[] a = new int[21];
        int num,renum,tmp,L;
        boolean flag;
        int i;

        while(true){
            a[0] = s.nextInt();
            L = s.nextInt();
            if(a[0]==0 && L==0) break;

            numArray = new int[L];
            renumArray = new int[L];
            i=0;
            flag = true;
            while(flag){
                tmp=a[i];
                for(int n=0;n<L;n++){
                    numArray[n]=tmp%10;
                    tmp=tmp/10;
                }

                Arrays.sort(numArray);
                for(int n=0;n<L;n++)
                    renumArray[n]=numArray[L-1-n];

                num=0;
                renum=0;
                for(int n=0;n<L;n++){
                    num+=numArray[n]*Math.pow(10,n);
                    renum+=renumArray[n]*Math.pow(10,n);
                }

                a[++i]=num-renum;

                for(int j=0;j<i;j++){
                    if(a[i]==a[j]){
                        System.out.println(j+" "+a[i]+" "+(i-j));
                        flag=false;
                    }
                }
            }


        }

    }
}

Measured memory_bytes: 20324
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, bb;
    cin>>a>>b;
    bb=b;
    int len=0;
    while (bb!=0){
        bb/=10;
        len++;
    }
    int nou=a*pow(10, len)+b;
    int h=0;
    for(int i=nou; i>0; i--) {
        if(i*i==nou) {
            cout<<"Yes";
            h=1;
        }
    }
    if(h==0){
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 512
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
pragma(inline, true) T[] Reads(T)() { return readln.split.to!(T[]); }
alias reads = Reads!int;
pragma(inline, true) void scan(Args...)(ref Args args) {
    string[] ss = readln.split;
    foreach (i, ref arg ; args) arg = ss[i].parse!int;
}

enum MOD = 2019;
void main() {
    int l, r; scan(l, r);
    if (r - l > 2019) {
        writeln(0);
        return ;
    }
    long ans = long.max;
    foreach(long i; l..r+1) foreach(long j; i+1..r+1) {
        ans = min(ans, (i%MOD*j%MOD) % MOD);
    }
    writeln(ans);
}


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

int main(void){
		int a,b;



		scanf("%d",&a);
    scanf("%d",&b);
    int c[b];

    for(int i = 0;i<b;i++){
      scanf("%d",&c[i]);
    }

    for(int i = 0;i<b;i++){

      a = a - c[i];
    }


    if(a>-1){
    printf("%d\n",a);
  }
  else{
    printf("-1\n");
  }

		return 0;
}


Measured memory_bytes: 1768
w,h,n=map(int,input().split())
t=[tuple(map(int,input().split()))for i in range(n)]
A=C=0
B=w
D=h
for i in range(n):
    if t[i][2]==1:
        A=max(A,t[i][0])
    elif t[i][2]==2:
        B=min(B,t[i][0])
    elif t[i][2]==3:
        C=max(C,t[i][1])
    elif t[i][2]==4:
        D=min(D,t[i][1])
n_h=D-C
n_w=B-A
if n_h<=0 or n_w<=0:
    print(0)
else:
    print(n_h*n_w)

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

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

using namespace std;

struct P{
	int x, y;
};

int h, w;
int m[102][102];

vector<P> neighbor(int x, int y){
	vector<P> c;
	if(y % 2 == 0){
		c = {
			{x - 1, y - 1},
			{x - 1, y},
			{x - 1, y + 1},
			{x, y - 1},
			{x, y + 1},
			{x + 1, y}
		};
	}
	else{
		c = {
			{x - 1, y},
			{x, y - 1},
			{x, y + 1},
			{x + 1, y - 1},
			{x + 1, y},
			{x + 1, y + 1}
		};	
	}
	vector<P> v;
	for(P& p: c){
		if(
			0 <= p.x && p.x <= h + 1 &&
			0 <= p.y && p.y <= w + 1
		){
			v.push_back(p);
		}
	}
	return v;
}

void read(){
	rep(j, w){
		rep(i, h){
			cin >> m[i + 1][j + 1];
		}
	}
}

void dfs(int x, int y){
	m[x][y] = 2;
	vector<P> v = neighbor(x, y);
	for(P& p: v){
		if(m[p.x][p.y] == 0){
			dfs(p.x, p.y);
		}
	}
}

int touch(int x, int y){
	vector<P> v = neighbor(x, y);
	int k = 0;
	for(P& p: v){
		if(m[p.x][p.y] == 2){
			++k;
		}
	}
	return k;
}

int main(){
	cin >> h >> w;
	read();

	dfs(0, 0);
	
	int ans = 0;
	rep(i, h + 2){
		rep(j, w + 2){
			if(m[i][j] == 1){
				ans += touch(i, j);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4032
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <cmath>
#define inf 1<<30
#define maxn 1000010
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define ll long long
inline void read(ll &x){
    x=0;ll f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
using namespace std;
ll a,b;
int main(){
	read(a);read(b);
	if((a*b)%2==0)printf("Even");
	else printf("Odd");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}

int main(void){
    IN(_)printf("%d\n",48-_);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ri register int
#define csi const int&
#define fi first
#define se second
#define pb push_back
using namespace std;
const int rlen=1<<18|1;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
inline int read(){
	int ans=0;
	char ch=gc();
	while(!isdigit(ch))ch=gc();
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	return ans;
}
inline ll readl(){
	ll ans=0;
	char ch=gc();
	while(!isdigit(ch))ch=gc();
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	return ans;
}
inline int Read(char*s){
	int top=0;
	char ch=gc();
	while(ch!='*'&&ch!='.')ch=gc();
	while(ch=='*'||ch=='.')s[++top]=ch,ch=gc();
	return top;
}
namespace modular{
	const int mod=1e9+7;
	inline int add(int a,int b){return (a+=b)<mod?a:a-mod;}
	inline int dec(int a,int b){return (a-=b)<0?a+mod:a;}
	inline int mul(int a,int b){return (ll)a*b%mod;}
	inline void Add(int&a,int b){a=add(a,b);}
	inline void Dec(int&a,int b){a=dec(a,b);}
	inline void Mul(int&a,int b){a=(ll)a*b%mod;}
	inline int ksm(int a,int p){int ret=1;for(;p;p>>=1,Mul(a,a))(p&1)&&(Mul(ret,a),1);return ret;}
	inline int Inv(int x){return ksm(x,mod-2);}
	inline void fix(int&x){x=(x%mod+mod)%mod;}
}
using namespace modular;
template<typename T>inline void ckmin(T&a,const T&b){a>b?a=b:0;}
template<typename T>inline void ckmax(T&a,const T&b){a<b?a=b:0;}
const int N=1<<20|5;
int n,m,all;
int fac[N],ifac[N],pw[N],a[25],f[2][N],cur;
inline void init(){
	fac[0]=fac[1]=ifac[0]=ifac[1]=1;
	for(ri i=2;i<=all;++i){
		fac[i]=mul(fac[i-1],i);
		ifac[i]=mul(ifac[mod-mod/i*i],mod-mod/i);
	}
	for(ri i=2;i<=all;++i)Mul(ifac[i],ifac[i-1]);
	pw[0]=1;
	for(ri i=1;i<=n;++i)pw[i]=pw[i-1]<<1;
}
inline int C(int n,int m){return n<m||m<0?0:mul(fac[n],mul(ifac[m],ifac[n-m]));}
int main(){
	#ifdef ldxcaicai
	freopen("lx.in","r",stdin);
	#endif
	n=read(),m=read(),all=1<<n;
	init();
	for(ri i=1;i<=m;++i)a[i]=read();
	sort(a+1,a+m+1);
	f[cur=0][0]=1;
	for(ri ps=m;ps;--ps){
		cur^=1;
		for(ri s=0;s<all;++s)f[cur][s]=f[cur^1][s];
		for(ri s=0,trans;s<all;++s)if(f[cur^1][s]){
			trans=all-s-a[ps];
			if(trans>=0)for(ri i=0;i<n;++i)if(!(s&pw[i]))
			Dec(f[cur][s|pw[i]],mul(f[cur^1][s],mul(C(trans,pw[i]-1),fac[pw[i]])));
		}
	}
	int res=0;
	for(ri s=0,t;s<all;++s)Add(res,mul(f[cur][s],fac[all-s-1]));
	cout<<mul(res,all);
	return 0;
}

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

using namespace std;
using ll = long long;
const int maxn = 1e5 + 5;

int lst[26], nxt[maxn][26];


int main()
{
    string s, t;
    cin >> s >> t;
    int n = s.length();
    int m = t.length();
    for (int i = 0; i < 26; i++) lst[i] = -1;
    for (int i = 0; i < 26; i++) nxt[n][i] = -1;
    for (int i = n - 1; i >= 0; i--){
        lst[s[i] - 'a'] = i + 1;
        for (int j = 0; j < 26; j++){
            nxt[i][j] = lst[j];
        }
    }
    ll ans = 0;
    ll cur = 0, idx = 0;
    for (int i = 0; i < m; i++){
        if (nxt[idx][t[i] - 'a'] != -1){
            idx = nxt[idx][t[i] - 'a'];
        } else {
            idx = 0;
            if (nxt[idx][t[i] - 'a'] == -1){
                cout << "-1";
                return 0;
            } else {
                cur++;
                idx = nxt[idx][t[i] - 'a'];
            }
        }
    }
    ans = cur * n + idx;
    cout << ans;
    return 0;
}


Measured memory_bytes: 10752
#include<iostream>
using namespace std;
const int N=1e6;
struct Ed{int x,y;}A[N];
int n,tt;
int main()
{
	cin>>n;
	if(n&1)
	{
		for(int i=1;i<=n;i++)
			for(int j=i+1;j<=n;j++)
				if(i+j!=n) A[++tt]=(Ed){i,j};
	}
	else
	{
		for(int i=1;i<=n;i++)
			for(int j=i+1;j<=n;j++)
				if(i+j!=n+1) A[++tt]=(Ed){i,j};
	}
	cout<<tt<<endl;
	for(int i=1;i<=tt;i++)
		printf("%d %d\n",A[i].x,A[i].y);
	return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
#as = gets.chomp.split.map(&:to_i)

cnt = Array.new(n+1,0)
ans = 0
max = Math.sqrt(n)
for x in 1..max do
    for y in 1..max do
        for z in 1..max do
            ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if ans <= n
                cnt[ans] += 1
            end
        end
    end
end

for i in 1..n do
    #puts "N=#{i}のとき"
    puts cnt[i]
end

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


int main()
{
	int n,w;
	cin>>n>>w;
	vector<long long> wt(n);
	vector<long long> p(n);
	for(int i=0;i<n;i++)
	{
		cin>>wt[i]>>p[i];
	}
	
	long long dp[101][100001];
	
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=w;j++)
		{
			if(i==0 or j==0)
			{
				dp[i][j] =0 ;
			}
			else if(wt[i-1]<=j)
			{
				dp[i][j] = max(dp[i-1][j-wt[i-1]]+p[i-1],dp[i-1][j]);
			}
			else
				dp[i][j] = dp[i-1][j];
		}
	}
	
	cout<<dp[n][w];
}

Measured memory_bytes: 79104
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  ll k;
  cin>>s>>k;
  char ans='1';
  for(int i=0;i<k;i++)
  {
    if(s.at(i)!='1')
    {
      ans=s.at(i);
      break;
    }
    
  }
  cout<<ans;
}
  
    


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a[1000000],i,b,c;
while(1){
scanf("%d\n",&b);
if(b==-1){
break;
}
for(i=0;;i++){
if(b<4){
a[i]=b;
break;
}
a[i]=b%4;
b=b/4;
}
c=i;
for(i=c;i>=0;i--){
printf("%d",a[i]);
}
printf("\n");
}
return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

  multiset<int, greater<int>> l;
  multiset<int> r;

  auto smooth_set = [&](){
    const int ls = l.size(), rs = r.size(), ds = abs(ls - rs);

    if(ls < rs){
      copy(r.begin(), next(r.begin(), ds/2), inserter(l, l.end()));
      r.erase(r.begin(), next(r.begin(), ds/2));
    }

    if(rs < ls){
      copy(l.begin(), next(l.begin(), ds/2), inserter(r, r.end()));
      l.erase(l.begin(), next(l.begin(), ds/2));
    }
  };

  ll sum_b  = 0LL, m = 0;
  while(q--){
    int c; cin >> c;
    if(c == 1){
      int a, b; cin >> a >> b; 
      sum_b += b;

      if(l.size() && (a < *l.begin() || *r.begin() < a)){
        m += min(abs(a - *l.begin()), abs(a - *r.begin()));
      } 

      if(a < *l.begin()){
        l.insert(a); l.insert(a);
      } else if(a <= *r.begin()){
        l.insert(a); r.insert(a);
      } else {
        r.insert(a); r.insert(a);
      }

      smooth_set();
    } else {
      if(l.size() == 0) 
        cout << 0 << " " << 0 << endl;
      else 
        cout << *l.begin() << " " << m + sum_b << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 18944
n,m,k = map(int,input().split())

flag = False

for i in range(0,n+1):
    for j in range(0,m+1):
        black = i*(m-j) + j*(n-i)

        if black == k:
            flag = True


if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
	
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define per(i , j , n) for(ll i = j ; i >= n ; i--)

void makeCombiUtil(vector<vector<int> >& ans, 
	vector<int>& tmp, int n, int left, int k) 
{ 
	if (k == 0) { 
		ans.push_back(tmp); 
		return; 
	} 

	for (int i = left; i <= n; ++i) 
	{ 
		tmp.push_back(i); 
		makeCombiUtil(ans, tmp, n, i, k - 1); 

		tmp.pop_back(); 
	} 
} 

vector<vector<int> > makeCombi(int n, int k) 
{ 
	vector<vector<int> > ans; 
	vector<int> tmp; 
	makeCombiUtil(ans, tmp, n, 1, k); 
	return ans; 
} 

int main() 
{ 

	int n,m,q;
	cin >> n >> m >> q;
	vector<vector<int> > ans = makeCombi(m, n);
	ll sum = 0;
	ll a[q],b[q],c[q],d[q];
	for(int i = 0; i < q; i++){ 
		cin >> a[i] >> b[i] >> c[i] >> d[i];

	} 
	ll as = 0;
	for(int i = 0; i < ans.size(); i++){
		ll sum = 0;
		for(int k = 0; k < q; k++){ 
			if(ans[i][b[k] - 1] - ans[i][a[k] - 1] == c[k]) sum += (ll)d[k]; 
		}
		as = max(as,sum);
		
	}
	cout << as;
} 


Measured memory_bytes: 9692
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int main(){
    ll N, A, B;
    cin >> N >> A >> B;

    ll d = A - B;

    vector<ll> h(N);
    for(int i=0;i<N;i++){
        cin >> h[i];
    }

    ll l = 0, r = 1000000010;
    while(r-l > 1){
        ll mid = (l + r) / 2;

        ll rest = mid;
        ll sm = mid * B;
        for(int i=0;i<N;i++){
            if(sm < h[i]){
                rest -= (h[i] - sm + d - 1) / d;
            }
        }
        if(rest >= 0){
            r = mid;
        }else{
            l = mid;
        }
    }
    cout << r << endl;

    return 0;
}

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

int n,sum[105][2],x[105][2];

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&x[i][0]);
    }
    for(int i=1;i<=n;i++){
        scanf("%d",&x[i][1]);
    }
    sum[0][0]=0;
    for(int i=1;i<=n;i++){
        sum[i][0]=sum[i-1][0]+x[i][0];
    }
    sum[n+1][1]=0;
    for(int i=n;i>=1;i--){
        sum[i][1]=sum[i+1][1]+x[i][1];
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        ans=max(ans,sum[i][0]+sum[i][1]);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0;i<n;i++) {
            a[i] = sc.nextInt();
        }

        for (int i : a) {
            if (i % 2 == 1) continue;
            if (i %3 != 0 && i%5 != 0 ){
                System.out.println("DENIED");
                return;
            }
        }
        System.out.println("APPROVED");
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
    int idx = 0;
    char s[3], t[3];
    cin >> s ;
    cin >> t;
    for (int i = 0; i < 3; i++) {
        if (s[i] == t[i]) idx++;
    }
    cout << idx << endl;

}

/* 
g++ -std=c++14 main.cpp
*/

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();

		int result = 0;
		for (int i = 0; i < s.length() - t.length() + 1; i++) {
			int score = 0;
			for (int j = 0; j < t.length(); j++) {

				//System.out.println(s.substring(i + j, i + j + 1) + " " + t.substring(j, j + 1));
				if (s.substring(i + j, i + j + 1).equals(t.substring(j, j + 1))) {
					score++;
				}
			}
			if (result < score) {
				result = score;
			}
		}

		System.out.println(t.length() - result);

	}
}


Measured memory_bytes: 52808
#import numpy as np
N = int(input())
a = [0]+list(map(int,input().split()))
ans = [0]*(N+1)
an = []
for i in range(N,0,-1):
  c =0
  b = [i*j for j in range(2,N//i+1)]
  for j in b:
    c +=ans[j]
  c = c%2
  if c!=a[i]:
    ans[i]=1
    an.append(i)
print(len(an))
for i in range(len(an)):
  print(an[i],end=" ")

Measured memory_bytes: 96476
/*
#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
*/
#include <bits/stdc++.h>

#define iosb ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define BIT(x) __builtin_popcount(x)
#define all(x) x.begin() , x.end()
#define F first
#define S second
#define pb push_back

using namespace std ;

typedef unsigned long long UL ;
typedef long long L ;
typedef string T ;
typedef int I ;

const I MaxN =      1e5+1 ;
const I MOD =       1e9+7 ;
const I inf =       2e9+7 ;
const L INF = 2e18+7 ;

int32_t main()
{
    //freopen(".in" , "r" , stdin) ;
    //freopen(".out" , "w" , stdout) ;
    int a , b ;
    cin >> a >> b ;
    int c = (a*100+7)/8 , d = b*10 ;
    if(c == d)
    {
        cout << c ;
    }
    else
    {
        if(c/10==b)
        {
            cout << c ;
        }
        else if(d*8/100==a)
        {
            cout << d ;
        }
        else
        {
            cout << -1 ;
        }
        
    }
    
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
using namespace std;
/*
#define int ll
#define double long double
*/
int main() {
	ll A, B, N; cin >> A >> B >> N;
	
	ll ans = min(B - 1, N);

	cout << (A * ans / B) - A * (ans / B) << endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  if ( (a + b) % 2 > 0 ) {
    cout << "IMPOSSIBLE" << endl;
  }
  else {
    cout << (a + b)/2 << endl;
  }
}

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

void koch(double x0, double y0, double x1, double y1, int n){
        if(n==0) return;
        double xa = x0*2.0/3.0 + x1*1.0/3.0;
        double ya = y0*2.0/3.0 + y1*1.0/3.0;
        double xc = x0*1.0/3.0 + x1*2.0/3.0;
        double yc = y0*1.0/3.0 + y1*2.0/3.0;
        double xb = xa + (xc-xa)*cos(60.0*M_PI/180.0) - (yc-ya)*sin(60*M_PI/180.0);
        double yb = ya + (xc-xa)*sin(60.0*M_PI/180.0) + (yc-ya)*cos(60*M_PI/180.0);
        koch(x0,y0,xa,ya,n-1);
        cout<<xa<<" "<<ya<<endl;
        koch(xa,ya,xb,yb,n-1);
        cout<<xb<<" "<<yb<<endl;
        koch(xb,yb,xc,yc,n-1);
        cout<<xc<<" "<<yc<<endl;
        koch(xc,yc,x1,y1,n-1);
}


int main(){
        double x0=0.0, y0=0.0, x1=100.0, y1=0.0;
        int n;
        cin >> n;
        cout<<x0<<" "<<y0<<endl;
        koch(x0,y0,x1,y1,n);
        cout<<x1<<" "<<y1<<endl;
        return 0;
}


Measured memory_bytes: 3272
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

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

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


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)

function ss(n)
	m = n
	sum = 0
	for i in 1:5
		sum +=m%(10)
		m = div(m, 10)
	end
	return(sum)
end

function main()
	n = readline() |> split |> x -> parseInt.(x)
	sum = 0
	for i in 1:n[1]
		if n[2] <= ss(i) <= n[3]
			sum += i
		end
	end
	print(sum)
end

main()

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

int main(){
  int k,a,b;
  cin>>k>>a>>b;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      cout<<"OK"<<endl;
      return 0;
    }
  }
  cout<<"NG"<<endl;
  return 0;
}



Measured memory_bytes: 3636
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007    //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

// debug
#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG2(x, y) cout << #x << ": " << x << " " << #y << ": " << y << endl
#define DEBUG_VEC(v)   \
  cout << #v << ":";   \
  REP(i, v.size())     \
  cout << " " << v[i]; \
  cout << endl
#define DEBUG_ARR(v, n) \
  cout << #v << ":";    \
  REP(i, n)             \
  cout << " " << v[i];  \
  cout << endl

ll N, M;
vector< ll > H;
vector< bool > seen;
vector< vector< ll > > R;

signed main()
{

  cin >> N >> M;
  REP(i, N)
  {
    ll hi;
    cin >> hi;
    H.push_back(hi);
  }

  R.assign(N, vector< ll >());
  REP(i, M)
  {
    ll ai, bi;
    cin >> ai >> bi;
    R[ai - 1].push_back(bi - 1);
    R[bi - 1].push_back(ai - 1);
  }

  ll cnt = 0;
  seen.assign(N, false);
  REP(i, N)
  {
    if (seen[i])
    {
      continue;
    }

    bool highest = true;
    seen[i] = true;
    for (auto rv : R[i])
    {
      if (H[i] <= H[rv])
      {
        highest = false;
        break;
      }
    }

    if (highest)
    {
      cnt++;
      for (auto rv : R[i])
      {
        seen[rv] = true;
      }
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 9860
n, k, q = map(int, input().split())
correct = []
for j in range(q):
    correct.append(int(input()))
score = [k-q]*n
for h in range(q):
    score[correct[h]-1] += 1
for i in range(n):
    if score[i] > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 10472
//Twitter@KonoLv1 2020年春卒で現在就職活動中！
 
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
 
int main(void){
    int i,j;            //  ループ文に使用
    int x,y,z;
    int count1,count2,count;   //  カウント用に使用
    int box[256] = {};
    char s[200001] = {};        //  文字列
    char s2[200001] = {};        //  文字列
    int a,b,c;
    a = b = c = i = 0;
    int mode = 0;
    count = count1 = count2 = 0;
 
    //  入力処理
    
    scanf("%s",s);
 
    //  計算処理
    
    while(1){

        if (s[i] == '\0'){
          break;
        }
        if ((i + 1) % 2 == 0){
          // 偶数
          if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D'){
              
          }else{
              mode = 1;
              break;
          }
        }else{
          // 奇数
          if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D'){
              
          }else{
              mode = 1;
              break;
          }
        }

      i++;
    }
 //  出力処理
    if (mode == 0){
        printf("Yes");
    }else{
        printf("No");
    }

}

Measured memory_bytes: 384
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from decimal import Decimal


def main():
    s = input()
    t = input()
    count = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            count += 1
    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 73620
#include <stdio.h>

int main (void)
{
    long a,b,x;
    long cnt;
    scanf("%ld %ld %ld",&a,&b,&x);
    cnt=b/x-a/x+(a%x==0?1:0);
    printf("%ld\n",cnt);
    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> V(N);
    for (int i = 0; i < N; i++)
    {
        cin >> V[i];
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int tmp;
        cin >> tmp;
        if (V[i] - tmp > 0)
        {
            ans += V[i] - tmp;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n,k;
  ll sum=0;
  scanf("%d %d",&n,&k);
  vector<ll> a(n);
  rep(i,n)cin >> a[i];
  sort(a.begin(),a.end());
  rep(i,n-k) sum+=a[i];
  printf("%lld",sum);
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define iter(v, i) for (__typeof__((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fast_io_without_cstdio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define all(v) (v).begin(), (v).end()

#ifdef __linux__
#define gc getchar_unlocked
#define pc putchar_unlocked
#else
#define gc getchar
#define pc putchar
#endif

#if __cplusplus <= 199711L
template<class BidirIt>
BidirIt prev(BidirIt it, typename iterator_traits<BidirIt>::difference_type n = 1) {
    advance(it, -n);
    return it;
}

template<class ForwardIt>
ForwardIt next(ForwardIt it, typename iterator_traits<ForwardIt>::difference_type n = 1) {
    advance(it, n);
    return it;
}
#endif

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ldouble;

const double EPS = 1e-9;
const double PI = 3.141592653589793238462;

template<typename T>
inline T sq(T a) { return a * a; }

//#ifdef LOCAL_MACHINE
//#endif

const int MAX_N = 1e5 + 5;

int deg[MAX_N];

int main() {
    //freopen("", "rt", stdin);
    //freopen("", "wt", stdout);
    int n, m;
    scanf("%d %d", &n, &m);
    while (m--) {
        int a, b;
        scanf("%d %d", &a, &b);
        deg[a]++;
        deg[b]++;
    }
    int odd = 0;
    for (int i = 1; i <= n; i++)
        if (deg[i] & 1)
            odd++;
    puts(odd <= 1 ? "YES" : "NO");
    return 0;
}



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

D = int(input())
C = list(map(int,input().split()))
S = [list(map(int,input().split())) for i in range(D)]

sumC = sum(C)
def score(strategy):
    sat = 0
    last = [0]*26
    for i,ind in enumerate(strategy):
        last = [l+1 for l in last]
        last[ind] = 0
        sat -= sum((c*l for c,l in zip(C,last)))
        sat += S[i][ind]
    return sat

#first = [np.argmax(ds) for ds in S]
first = [i % 26 for i in range(D)]

ans = first
now_score = score(ans)

for i in range(15):
    #samples = np.random.randint(0,26,size=D).tolist()
    for d in range(D):
        temp = ans[:]
        temp[d] = S[d].index(max(S[d]))
        #temp[d] = samples[d]
        new_score = score(temp)
        if new_score > now_score:
            now_score = new_score
            ans = temp

for a in ans:
    print(a+1)



Measured memory_bytes: 73132
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int N; cin >> N;
	vector<int> a(N * 2);
	for (int& x: a) cin >> x;
	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 0; i < N * 2; i += 2)
		ans += a[i];
	cout << ans << endl;
}


Measured memory_bytes: 764
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int i, j;
	int n;

	cin >> n;

	if (n == 25) {
		cout << "Christmas" << endl;
	}
	else if (n == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if (n == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else if (n == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}



	









	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int a[5];
    REP(i, 5)
    cin >> a[i];

    int ma = 0;
    int res = 0;
    REP(i, 5)
    {
        res += ((a[i] + 9) / 10) * 10;
        ma = max(ma, ((a[i] + 9) / 10) * 10 - a[i]);
    }
    res -= ma;

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef long long ll;

int main()
{
	ll n;
	ll a[5];
	ll min_v = 1ll << 60ll;

	scanf("%lld", &n);
	for (int i = 0; i < 5; i++) {
		scanf("%lld", &a[i]);

		if (min_v > a[i]) {
			min_v = a[i];
		}
	}

	printf("%lld\n", n / min_v + (n % min_v ? 1 : 0) + 4);

	return 0;
}


Measured memory_bytes: 128
h, w, a, b = map(int, input().split())

MOD = 1000000007


def modPow(a, x, p):
    res = 1
    while (x > 0):
        if (x % 2 != 0):
            res = (res * a) % p
        a = (a * a) % p
        x /= 2
    return res


fact = [None] * 220000

for i in range(1, 220000):
    fact[0] = 1
    fact[i] = i * fact[i - 1] % MOD
    # inv[i] = modPow(fact[i], MOD-2, MOD)


def ncr(n, r):
    den = fact[n - r] * fact[r] % MOD
    return fact[n] * pow(den, MOD - 2, MOD) % MOD


def number_of_paths(h, w):
    n = h + w - 2
    r = h - 1
    return ncr(n, r)


ans = 0
for i in range(b + 1, w + 1):
    # print('first', h-a, i)
    ans += number_of_paths(h - a, i) * number_of_paths(a, w - i + 1)

print(int(ans % MOD))


Measured memory_bytes: 13556
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//ソートすればいいんですか？
//???
int dp[3000];

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


	int N, T;
	scanf("%d", &N);
	scanf("%d", &T);
	int AB[3000];
	rep(i, N) {
		int a, b;
		scanf("%d %d", &a, &b);
		AB[i] = (a << 12) + b;
	}
	sort(AB, AB + N);

	int saidai = 0;
	rep(i, N) {
		int a = AB[i] >> 12;
		int b = AB[i] & ((1 << 12) - 1);
		chmax(saidai, dp[T - 1] + b);
		for (int j = T - a - 1; j >= 0; j--) {
			chmax(dp[j + a], dp[j] + b);
		}
	}
	printf("%d", saidai);

	Would you please return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int64_t INF = 10000000000;

int main()
{
  int64_t N, a, b, maxp = INF;
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> a >> b;
    maxp = min(maxp, a + b);
  }
  cout << maxp << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long int lli;
const long long int MaxN=200005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	lli arr[MaxN];
	void solve(){
		lli N,i,j,res=0,pasos=0,lim,p,q;
		cin>>N;
		for(i=0;i<N;i++){
			cin>>p>>q;
			arr[i]=p+q;
			res-=q;
		}
		sort(arr,arr+N);
		lim=(N+1)/2;
		for(i=N-1;i>=0;i-=2){
			if(pasos==lim)break;
			res+=arr[i];
			pasos+=1;
		}
		cout<<res;
	}
int main(){
	cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
}

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

int main()
{
  int N;
  int Q;
  std::cin >> N >> Q;
  assert(2 <= N and N <= 1.0e+5);
  assert(1 <= Q and Q <= 1.0e+5);
  std::string S;
  std::cin >> S;
  S.insert(S.begin(), '-');
  assert(static_cast<int>(S.length()) == 1 + N);
  std::vector<int> l(1 + Q);
  std::vector<int> r(1 + Q);
  for (int i = 1; i <= Q; ++i) {
    std::cin >> l[i] >> r[i];
    assert(1 <= l[i] and l[i] <= r[i] and r[i] <= N);
  }

  // Compute cumulative sum
  std::vector<int> sum(1 + N);
  for (int j = 2; j <= N; ++j) {
    sum[j] = sum[j - 1];
    if (S[j - 1] == 'A' and S[j] == 'C')
      sum[j] += 1;
  }

  // Output
  for (int i = 1; i <= Q; ++i) {
    std::cout << sum[r[i]] - sum[l[i]] << std::endl;
  }

  return 0;
}


Measured memory_bytes: 2176
# frozen_string_literal: true

a, b, c = gets.split.map(&:to_i)
k = gets.to_i
count = 0
loop do
  break if b > a

  b *= 2
  count += 1
end

loop do
  break if c > b

  c *= 2
  count += 1
end

puts count <= k ? 'Yes' : 'No'


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

int main() {
  int k, s;
  cin >> k >> s;
  
  int count = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      if (0 <= s-i-j && s-i-j <= k) {
        count += 1;
      }
    }
  }

  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	s.Scan()
	n, _ := strconv.Atoi(s.Text())

	h := make([]int, n)
	for i := 0; i < n; i++ {
		s.Scan()
		h[i], _ = strconv.Atoi(s.Text())
	}

	dp := make([]int, n+1)
	dp[1] = abs(h[1] - h[0])
	for i := 1; i < n-1; i++ {
		dp[i+1] = min(abs(h[i+1]-h[i])+dp[i], abs(h[i+1]-h[i-1])+dp[i-1])
	}

	fmt.Println(dp[n-1])
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}


Measured memory_bytes: 3784
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int x, y; cin >> x >> y;
	int a = 4 * x - y, b = y - 2 * x;
	debug(a, b);
	if ((a >= 0) and (b >= 0) and (a % 2 == 0) and (b % 2 == 0)) cout << "Yes";
	else cout << "No";


	return 0;
}

Measured memory_bytes: 3648
#include <iostream> 
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for (int i = 0; i < N; i++) {
        cin >> p[i];
    } 
    sort(p.begin(), p.end());
    int ans = 0;
    for (int i = 0; i < K; i++) {
        ans += p[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
inline int read() {
	char c = getchar(); int x = 0, f = 1;
	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * f;
}
long long n,m,a;
int main()
{
    cin>>n>>m;
    a=min(n,m/2);
    m=m-n*2;n=0;
    m=max(m,n);
    cout<<a+m/4;
    return 0;
} 

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nm = readln.split.to!(long[]);
    auto N = nm[0];
    auto M = nm[1];
    int[][] G;
    G.length = N;
    foreach (_; 0..M) {
        auto ab = readln.split.to!(int[]);
        auto A = ab[0]-1;
        auto B = ab[1]-1;
        G[A] ~= B;
        G[B] ~= A;
    }

    auto es = new int[](N);
    long x, y, z;
    void walk(int i, int p, int c) {
        c = c == 1 ? 2 : 1;
        foreach (j; G[i]) if (j != p) {
            if (z) return;
            if (es[j] == 0) {
                if (c == 1) {
                    ++x;
                } else {
                    ++y;
                }
                es[j] = c;
                walk(j, i, c);
            } else if ((es[j] == 1 && c == 2) || es[j] == 2 && c == 1) {
                z = 1;
                return;
            }
        }
    }
    es[0] = 1;
    ++x;
    walk(0, -1, 1);

    if (z) {
        writeln(N * (N-1) / 2 - M);
    } else {
        writeln(x * y - M);
    }
}

Measured memory_bytes: 21000