akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}

struct Complex {
	double x, y;
	Complex operator+=(const Complex &o) {x+=o.x; y+=o.y; return *this;}
	Complex operator/=(double k) {x/=k; y/=k; return *this;}
};
Complex operator+(const Complex &a, const Complex &b) {return {a.x+b.x, a.y+b.y};}
Complex operator-(const Complex &a, const Complex &b) {return {a.x-b.x, a.y-b.y};}
double abs(const Complex &z) {return sqrt(z.x*z.x+z.y*z.y);};
Complex operator*(const Complex &a, double k) {return {a.x*k, a.y*k};}
Complex operator*(const Complex &a, const Complex &b) {return {a.x*b.x-a.y*b.y, a.x*b.y+a.y*b.x};}
Complex operator/(const Complex &a, const Complex &b) {
	double l=b.x*b.x+b.y*b.y;
	return {(a.x*b.x+a.y*b.y)/l, (a.y*b.x-a.x*b.y)/l};
}
Complex cis(double a) {return {cos(a), sin(a)};}

const int N=3000;
const double PI=acos(-1);
int n, l, t[N];
Complex p[N], ans;
int main() {
	scanf("%d%d", &n, &l);
	for(int i=0; i<n; ++i) scanf("%d", t+i);
	std::sort(t, t+n);
	for(int i=0; i<n; ++i) p[i]=cis(2*PI*t[i]/l);
	for(int i=0; i<n; ++i) {
		Complex sum={0, 0};
		for(int j=i+1; j<i+n; ++j) {
			Complex v=p[j%n]-p[i], m=cis(PI*((double)(t[i]+t[j%n])/l+j/n+1));
			v/=abs(v);
			ans+=sum/v*(p[j%n]-m)+m*(j-i-1);
			sum+=v;
		}
	}
	ans/=1.0l*n*(n-1)*(n-2)/2;
	printf("%.18lf %.18lf\n", ans.x, ans.y);
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int n; cin >> n;
  int a[n]; rep(i,n) cin >> a[i];
  sort(a,a+n);
  int r0 = 0;
  pii ans = {a[n-1], a[0]};
  for (int i=0;i<n-1;i++){
    int r = min(a[i], a[n-1]-a[i]);
    if (r>r0) {
      r0 = r;
      ans.second = a[i];
    }

  }

  cout << ans.first << " " << ans.second << endl;

  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3984
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 35;
const int MAXK = 510;
const int MAXQ = 200010;

int n, W, a[MAXN], b[MAXN], dp[31010], dp2[MAXN][MAXN][3*MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> W;
    FOR(i,1,n) cin >> a[i] >> b[i];
    ll s = 0;
    FOR(i,1,n) s += a[i];
    if (s <= W) {
        int res = 0;
        FOR(i,1,n) res += b[i];
        cout << res;
        return 0;
    }
    if (W < a[1]) {
        cout << 0;
        return 0;
    }
    if (a[1] >= 300) {
        int g = W / a[1];
        int r = W % a[1];
        r = min(r, 300);

        //cout << g << " " << r << endl;

        FORE(i,n,1) a[i] -= a[1];

        // FOR(i,1,n) cout << a[i] << ' ' << b[i] << ' ';
        // cout << endl;

        FOR(i,1,n)
            FOR(j,1,g)
                FOR(k,0,300) {
                    dp2[i][j][k] = dp2[i-1][j][k];
                    if (k >= a[i]) dp2[i][j][k] = max(dp2[i][j][k], dp2[i-1][j-1][k-a[i]] + b[i]);
                }
        int res = 0;
        FOR(i,0,g-1) 
            FOR(j,0,300) res = max(res, dp2[n][i][j]); 
        FOR(j,0,r) res = max(res, dp2[n][g][j]);
        cout << res;
    }
    else {
        dp[0] = 0;
        FOR(i,1,n)
            FORE(j,W,a[i]) dp[j] = max(dp[j], dp[j - a[i]] + b[i]);
        int res = 0;
        FOR(j,0,W) res = max(res, dp[j]);
        cout << res;
    }
    return 0;
}

Measured memory_bytes: 14336
# -*- coding: utf-8 -*-


def main():
    h, w = map(int, input().split())
    n = int(input())
    a = list(map(int, input().split()))
    c = [[0 for _ in range(w)] for __ in range(h)]
    k = 0

    for j in range(h):
        if j % 2 == 0:
            for i in range(w):
                c[j][i] = k + 1
                a[k] -= 1

                if a[k] == 0:
                    k += 1
        else:
            for i in range(w - 1, -1, -1):
                c[j][i] = k + 1
                a[k] -= 1

                if a[k] == 0:
                    k += 1

    for ci in c:
        print(' '.join(map(str, ci)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9404
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);

  for(int i=0;i<n;i++)
  	cin >> a.at(i);

  vector<int> b(n);
  for(int i=0;i<n;i++){
  	b.at(a.at(i)-1) = i+1;
  }

  for(int i=0;i<n;i++) cout << b.at(i) << endl;
}

Measured memory_bytes: 1536
r,g,b,n = map(int,input().split())

ans = 0
rmax = n//r
gmax = n//g
for i in range(rmax+1):
    for j in range(gmax+1):
        rest = n-r*i-g*j
        if rest<0: break
        if rest%b==0: ans += 1

print(ans)


Measured memory_bytes: 3060
#include<cstdio>
#include<cctype>
#include<cstring>
#include<utility>
#include<algorithm>
#define fi first
#define se second
namespace IO
{
    char ibuf[(1<<21)+1],*iS,*iT;
    char Get(){return (iS==iT? (iT=(iS=ibuf)+fread(ibuf,1,(1<<21)+1,stdin),(iS==iT? EOF:*iS++)):*iS++);}
    int read(){int x=0,c=Get();while(!isdigit(c))c=Get();while(isdigit(c))x=x*10+c-48,c=Get();return x;}
}
using IO::read;
using std::pair;
using pi=pair<int,int>;
const int N=200007,M=5000007;
int n,a[N],val[N],sum[N],mx[2],mn[2][2],c[2][2];pi pos[N];
char ans[N];
struct BIT
{
    int t[N],top;pi stk[M];
    void add(int p,int v){for(;p<=n;p+=p&-p)stk[++top]={p,t[p]},t[p]=std::max(t[p],v);}
    int ask(int p){int r=-1e9;for(p=std::min(p,n);p;p^=p&-p)r=std::max(r,t[p]);return r;}
    void undo(int p){for(;top>p;--top)t[stk[top].fi]=stk[top].se;}
}t[2];
int main()
{
    n=read();
    for(int i=1,x=n+1;i<=n;++i) if(x>(a[i]=n+1-read())) x=a[i],val[i]=2; else val[i]=1;
    memset(t[1].t,0x8f,sizeof t[1].t);
    for(int i=n;i;--i) sum[i]=sum[i+1]+(val[i]==2);
    for(int i=n;i^1;--i)
    {
	for(int j=0;j<2;++j) mx[j]=std::max(0,t[j].ask(a[i]));
	for(int j=0,x;j<2;++j) x=mx[j]+val[i],t[x&1].add(a[i],x);
	pos[i]={t[0].top,t[1].top};
    }
    mn[0][0]=mn[0][1]=n+1;
    for(int i=1,now=0;i<=n;++i)
    {
    	now^=1;
        if(i<n)	t[0].undo(pos[i+1].fi),t[1].undo(pos[i+1].se);
	for(int j=0,f;j<2;++j)
	{
	    memcpy(mn[now],mn[now^1],8),memcpy(c[now],c[now^1],8);
	    if(a[i]<mn[now^1][j]) mn[now][j]=a[i],c[now][j]=c[now^1][j]+1;
	    f=i==n? (c[now][0]==c[now][1]):0;
	    if(i<n)
	    {
		for(int k=0,x;k<2;++k)
		{
		    x=c[now][k]-c[now][k^1]+sum[i+1];
		    if(x>=0&&x<=t[x&1].ask(mn[now][k^1])) {f=1;break;}
		}
	    }
	    if(f) {ans[i]='0'+j;break;}
    	}
    	if(!ans[i]) return !printf("-1");
    }
    for(int i=1;i<=n;++i) putchar(ans[i]);
}


Measured memory_bytes: 85504
#include <bits/stdc++.h>
using namespace std;
 
int get_top(int n){
  int c=0;
  int k = n;
  while(1 <= k){
    k /= 10;
    c++;
  }
  int top;
  int d = (std::pow(10,(c-1)));
  return(n/d);
}

int get_tail(int n){
  return(n%10);
}
 
int main() {
  int N;
  cin >> N;
  int count = 0;
  for(int i=1; i<10; i++){
    for(int j=0; j<10; j++){
      int a = 0;
      int b = 0;
      for(int k=0; k<N; k++){
        int m = k+1;
        if((get_top(m) == i)&&(get_tail(m) == j)){
          a++;
        }
        if((get_tail(m) == i)&&(get_top(m) == j)){
          b++;
        }
      }
      count += a*b;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	students := make(Students, n)
	for i := 1; i <= n; i++ {
		fmt.Scan(&students[i-1].order)
		students[i-1].num = i
	}
	sort.Sort(students)

	for _, v := range students {
		fmt.Println(v.num)
	}
}

type Student struct {
	num   int
	order int
}

type Students []Student

func (s Students) Len() int {
	return len(s)
}

func (s Students) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s Students) Less(i, j int) bool {
	return s[i].order < s[j].order
}


Measured memory_bytes: 7040
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////////////////
int n,ans=0;
cin >> n;
int l[n][2];
for(int i=0;i<n;i++){
    cin >> l[i][0] >> l[i][1];
}

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

cout << ans << endl;



////////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#include<vector>
using namespace std;
int main(){
    int a,b;cin>> a >> b;
    if(a>8 || b>8)
        cout << ":(" << endl;
    else
        cout << "Yay!" << endl;   
}

Measured memory_bytes: 256
n = int(input())

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

min_v = min(a, b, c, d, e)

ans = 5
if n % min_v == 0:
    ans += n // min_v - 1
else:
    ans += (n // min_v)

print(ans)


Measured memory_bytes: 3060
# A,BC,他
S = input()
S = S.replace('BC','X')


# BCの左にAがいくつあるかを持つ
cnt_A = 0
answer = 0
for s in S:
  if s == 'A':
    cnt_A += 1
  elif s =='X':
    answer += cnt_A
  else:
    cnt_A = 0
print(answer)

Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int s=0,a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a>c)
		swap(a,c);
	if(b>c)
		swap(b,c);
	if(a>b)
		swap(a,b);
	s+=c-b;
	a+=c-b;
	if((c-a)%2==0)
		s+=(c-a)/2;
	else
		s+=(c-a+1)/2+1;
	printf("%d",s);
	return 0;
} 

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

int num[200010],sum[200010],cnt[200010],n,m,ans;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline void print(int x)
{
	static char s[233];
	if (!x) { putchar('0');putchar('\n');return; }
	int tot=0;
	for (;x;x/=10) s[++tot]=x%10+'0';
	for (;tot;tot--) putchar(s[tot]);
	putchar('\n');
}

int main()
{
	n=rd();m=rd();
	for (int i=1;i<=n;i++) num[i]=rd();
	ans=0;
	for (int i=1;i<=n;i++) cnt[num[i]]++;
	for (int i=1;i<=n;i++) for (int j=max(1,i-cnt[i]+1);j<=i;j++) sum[j]++;
	for (int i=1;i<=n;i++) if (!sum[i]) ans++;
	while (m--)
	{
		int x=rd(),y=rd();
		cnt[num[x]]--;
		if (num[x]-cnt[num[x]]>0)
		{
			sum[num[x]-cnt[num[x]]]--;
			if (!sum[num[x]-cnt[num[x]]]) ans++;
		}
		num[x]=y;
		cnt[num[x]]++;
		if (num[x]-cnt[num[x]]+1>0)
		{
			if (!sum[num[x]-cnt[num[x]]+1]) ans--;
			sum[num[x]-cnt[num[x]]+1]++;
		}
		print(ans);
	}
	return 0;
}

Measured memory_bytes: 3712
n = int(input())
lis = list(map(int,input().split()))
ans = 0
key = 0
cou = 0
for i in range(n):
    if i+1 == lis[i]:
        if key == 0:
            key = 1
            cou = 1
            ans += 1
    if cou == 1:cou = 0
    else:key = 0
print(ans)

Measured memory_bytes: 14008
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>

int main()
{
    int N;
    std::cin >> N;

    int a = 0;
    bool flag = false;
    for (int i = 0; i < N; ++i) {
        std::cin >> a;
        if (a % 2 != 0) {
            flag = true;
            std::cout << "first" << std::endl;
            return 0;
        }
    }

    std::cout << "second" << std::endl;

    return 0;
}

Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 555;

int n;
int co;
int cost[35][35];
long long dp[4][35];
vector < int > colors[4];


int main () {
    scanf("%d%d" , &n , &co);
    for(int i = 1; i <= co; i++){
        for(int j = 1; j <= co; j++){
            int x;
            scanf("%d" , &x);
            cost[i][j] = x;
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            int x;
            scanf("%d" , &x);
            colors[(i+j)%3].push_back(x);
        }
    }
    for(int idx = 0; idx < 3; idx++){
        for(int to = 1; to <= co; to++){
            for(int j = 0; j < colors[idx].size(); j++){
                dp[idx][to] += cost[colors[idx][j]][to];
            }
        }
    }
    long long best = 1e11;
    for(int a = 1; a <= co; a++){
        for(int b = 1; b <= co; b++){
            for(int c = 1; c <= co; c++){
                if(a == b || b == c || a == c)
                    continue;
                best = min(best , dp[0][a] + dp[1][b] + dp[2][c]);
            }
        }
    }
    printf("%lld\n" , best);
}


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

int main(){
    int a[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> a[i][j];
        }
    }
    
    if(a[0][0]-a[0][1]==a[1][0]-a[1][1]&&a[1][0]-a[1][1]==a[2][0]-a[2][1]){
        if(a[0][1]-a[0][2]==a[1][1]-a[1][2]&&a[1][1]-a[1][2]==a[2][1]-a[2][2]){
            if(a[0][0]-a[1][0]==a[0][1]-a[1][1]&&a[0][1]-a[1][1]==a[0][2]-a[1][2]){
                if(a[1][0]-a[2][0]==a[1][1]-a[2][1]&&a[1][1]-a[2][1]==a[1][2]-a[2][2])
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
k=parse(Int,readline())
function main()
  ans=1
  now=mod(7,k)
  while now!=0
    ans+=1
    now=mod(7+now*10,k)
    if ans>10^6;ans=-1; break; end
  end
  println(ans)
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

Measured memory_bytes: 200180
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ll  long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vi vector<int>
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i : c)
#define pii pair< int,int >
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
#define er(x) cout << x << " "
#define err(x,y) cout << x << " "<<y
using namespace std;

const ll MAX =  1000 * 1000 ;
const int dx[] = { 1, -1 , 0 , 0  };
const int dy [] = { 0 ,0 , 1 , -1  };
const int MOD = 1000 * 1000 * 1000 + 7 ;
const int N = 301 ;
const int INF = INT_MAX ;
const int M = 200005;
int main ( ){


ll  n , k ;
cin >> n >> k ; 
std::vector<ll> h (n);
for (auto &x : h )
	cin >> x ; 

sort( rall(h)) ; 
ll sum = 0 ; 
for ( int i = k ; i < n ; ++i )
	sum += h[i] ; 

cout << sum ; 
return 0 ;

}


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

int c,g;

int hcount(int n,int sum,int bf){
	if(n==0){
		if(sum==g){
			c++;
		}
	}
	else{
		for(int i=bf+1;i<10;i++){
			hcount(n-1,sum+i,i);
		}
	}
	return 0;
}

int main(){
	int n;
	while( scanf("%d %d",&n,&g)!=EOF){
		if(n==0&&g==0)break;
		c=0;
		hcount(n,0,-1);
		printf("%d\n",c);
	}
			
	return 0;
}

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

int main() {
    vector<vector<int>> c(3, vector<int>(3));
    pair<int,int> d;
    bool ok = 1;
    rep(i,3)
        rep(j,3)
            cin >> c.at(i).at(j);
    
    d.first = c.at(0).at(1)-c.at(0).at(0);
    d.second = c.at(0).at(2)-c.at(0).at(1);

    rep(i,2) {
        if(c.at(i+1).at(1)-c.at(i+1).at(0)!=d.first)
            ok = 0;
        if(c.at(i+1).at(2)-c.at(i+1).at(1)!=d.second)
            ok = 0;
    }

    if(ok)
        cout << "Yes";
    else
        cout << "No";
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
ll inv(ll a){return modpow(a,mod-2);}
int main(){
    ll n;cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    ll ans=0;
    ll sum=0;
    ll fac=1;
    REP(i,1,n+1)fac=fac*i%mod;
    REP(i,1,n+1)sum=(sum+fac*inv(i))%mod;
    rep(i,n){
        ans=(ans+sum*v[i])%mod;
        sum+=inv(i+2)*fac%mod+mod-inv(n-i)*fac%mod;
        sum%=mod;
    }
    out(ans);
}

Measured memory_bytes: 1024
hash={}
coord={}
h,w,d=gets.split.map(&:to_i)
h.times{|x|
  gets.split.map(&:to_i).each_with_index{|a,y|
    coord[a]=[x,y]
  }
}
gets.to_i.times{
  l,r=gets.split.map(&:to_i)
  m=l%d
  m=d if m==0
  unless hash[m]
    dp=[0]
    mm=m
    px,py=coord[mm]
    while mm+d<=h*w
      mm+=d
      nx,ny=coord[mm]
      dp<<dp.last+(nx-px).abs+(ny-py).abs
      px,py=nx,ny
    end
    hash[m]=dp
  end
  puts hash[m][(r-m)/d]-hash[m][(l-m)/d]
}

Measured memory_bytes: 24444
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>

using namespace std;

int main() {
  long long n;
  cin >> n;
  if (n == 0) {
    cout << "0" << endl;
    return 0;
  }
  string s;
  for (int i = 0; n != 0; i++) {
    if (n % 2 != 0) {
      s = '1' + s;
      if (i % 2 == 0) {
        n--;
      } else {
        n++;
      }
    } else {
      s = '0' + s;
    }
    n >>= 1;
  }
  cout << s << endl;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

# define fr(a,b) for(int i = a; i < b; i++)
# define rep(i,a,b) for(int i = a; i < b; i++)

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;


void solve(){
    int n;
    cin >> n;
    if(n%1000){
        int r = n%1000;
        cout << 1000 - r;
        return ;
    }
    cout << 0;
    return;
}
int main(){
	fast
	int t=1;
	//cin >> t;
	while(t--){
             solve();
    }

	R 0;
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename T> struct BIT {
    int S;
    vector<T> v;

    BIT<T>(int _S) {
        S = _S;
        v.resize(S+1);
    }

    void update(int i, T k) {
        for(i++; i <= S; i += i&-i)
            v[i] = v[i] + k;
    }

    T read(int i) {
        T sum = 0;
        for(i++; i; i -= i&-i)
            sum = sum + v[i];
        return sum;
    }

    T read(int l, int r) {
        return read(r) - read(l-1);
    }

    /*
     * Returns in O(logS) the first index i such that read(i) >= sum.
     * Returns S if no such i exists.
     * Requires that read(i) is non-decreasing in i.
     */
    int lower_bound(T sum) {
        T res = 0;
        int inx = 0;
        for (int i = 31 - __builtin_clz(S); i >= 0; i--) {
            if ((inx + (1 << i) <= S) && res + v[inx + (1 << i)] < sum) {
                inx += 1 << i;
                res += v[inx];
            }
        }
        return inx;
    }
};

ll inversions(vi& vals) {
    BIT<int> bit(sz(vals));
    ll res = 0;
    for (int v : vals) {
        res += bit.read(v + 1, sz(vals) - 1);
        bit.update(v, 1);
    }
    return res;
}

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

    string S;
    cin >> S;

    vvi app(26);
    for (int i = 0; i < sz(S); i++)
        app[S[i] - 'a'].push_back(i);

    int mid = -1;
    vi vals;
    vector<pair<int, int>> locs;

    for (int c = 0; c < 26; c++) {
        for (int i = 0; i < sz(app[c]) - 1 - i; i++) {
            vals.push_back(sz(vals));
            locs.push_back({ app[c][i], app[c][sz(app[c]) - 1 - i] });
        }
        if (sz(app[c])&1) {
            if (mid != -1) { cout << -1 << endl; return 0; }
            mid = app[c][sz(app[c])/2];
        }
    }

    sort(all(vals), [&locs](int i, int j) {
        auto pi = locs[i], pj = locs[j];
        //if (pi.first < pj.first && pj.second < pi.second) return true;
        //if (pj.first < pi.first && pi.second < pj.second) return false;
        return pi < pj;
    });

    vi left, right;
    for (int i : vals) {
        left.push_back(locs[i].first);
        right.push_back(locs[i].second);
    }

    if (mid != -1) left.push_back(mid);
    reverse(all(right));
    left.insert(left.end(), all(right));

    cout << inversions(left) << endl;

    return 0;
}



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


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

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    int k;
    cin>>k;
    ll sum=0;
    repA(i,1,k)
    {
        repA(j,1,k)
        {
            repA(d,1,k)
            {
                sum+=gcd(i,gcd(j,d));
            }
        }
    }
    cout<<sum<<'\n';
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
void solve(vector<int> &a,int k){
  bool dp[k+1];
  memset(dp,0,sizeof(dp));
  for(int i=1;i<=k;i++){
  	for(int mov:a){
      if(mov>i)continue;
      if(dp[i-mov]==0)dp[i]=1;
      
    }
  
  }
  dp[k]?cout<<"First"<<endl:cout<<"Second"<<endl;
}

int main(){
	int n,k;
  	cin>>n>>k;
  	vector<int> a(n);
  	for(int i=0;i<n;i++)cin>>a[i];
  	solve(a,k);



	return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    map<int, int> mm;
    for (int i = 0; i < n; i++) {
        int in;
        cin >> in;
        mm[in]++;
    }
    vector<pair<int, int>> vec;
    for (auto &x : mm) {
        vec.push_back({x.second, x.first});
    }
    sort(vec.begin(), vec.end());
    if (vec.size() <= k)
        return cout << 0, 0;
    int cnt = vec.size();
    ll res = 0;
    int idx = 0;
    for (int i = 0; i < vec.size()  - 1; i++) {
        if (cnt == k)
            break;
        cnt--;
        res += vec[i].first;
    }
    cout << res;
    return  0;
}

Measured memory_bytes: 11764
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n, a, b;
  cin>>n>>a>>b;
  for(int i = a; i <= b; i++)
    if(i%n == 0)
    {
      cout<<"OK";return 0;
    }
  cout<<"NG";
  return 0;
}

Measured memory_bytes: 3604
// Winners don't quit and Quitters don't win
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 998244353
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int i,ans,x;
    for(i=1;i<=5;++i){
    	cin>>x;
    	if(x==0){
    		ans=i;
		}
	}
	cout<<ans;
}

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

int main() {
  int a, b;

  cin >> a;
  cin >> b;

  if (a < b)
    cout << "a " << "<"  << " b" << endl;
  if (a > b)
    cout << "a " << ">"  << " b" << endl;
  if (a == b)
    cout << "a " << "==" << " b" << endl;

  return 0;
}

Measured memory_bytes: 3108
///HELLO THERE~!
///CREATED BY MD SADMAN MEHEDI SIVAN(IUT CSE[SWE'19])

#include<bits/stdc++.h>
using namespace std;

#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define READ            freopen("input.txt","r",stdin);
#define WRITE           freopen("red.txt","w",stdout);

using ll=long long;
using ull=unsigned long long;
const double pi = 2*acos(0.0);
const long long MX = 2e5+7;

int main()
{
    long long n;
    ll k;
    cin >> n >> k;

    ll a[n];

    long long flag = 0;


    ll max = 0;


    for(long long i = 0; i < n; i++)
    {
        cin >> a[i];
        if(max < a[i])
        {
            max = a[i];
        }
        if(a[i] == k)
        {
            flag = 1;
        }
    }

    if(flag==1)
    {

        cout << "POSSIBLE" << endl;
        return 0;

    }



    if(flag == 0)
    {
        ll b = a[0];
        for(ll i = 1; i < n; i++)
        {
            b = __gcd(b, a[i]);

            if(b == 1)
            {
                break;
            }
        }

        if(k % b == 0 && k <= max)
        {
            flag = 1;
        }
    }

    if(flag == 0)
    {
        cout << "IMPOSSIBLE" << endl;
    }
    else
    {
        cout << "POSSIBLE" << endl;
    }
}


Measured memory_bytes: 4304
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    long n=sc.nextInt();
    String s=sc.next();
    int count=0;
    for (int i=0;i<n-2;i++) {
      if (s.charAt(i)=='A'&&s.charAt(i+1)=='B'&&s.charAt(i+2)=='C') {
        count++;
      }
    }

    System.out.println(count);
  }
}


Measured memory_bytes: 23124
#include <cstdio>

using namespace std;

typedef long long ll;

static const ll MOD = 1e9 + 7;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    ll N;

    scanf("%lld", &N);

    ll ans = 1;
    ll i;

    for (i = 1; i <= N; i++) ans = (ans * i) % MOD;

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


int main() {
    ll l, r; cin >> l >> r;

    if (r - l >= 2019) cout << 0 << endl;
    else {
        ll res = 2018;
        for (ll i=l;i<r;++i) {
            for (ll j=i+1;j<=r;++j) {
                res = min(res, (i * j) % 2019);
            }
        }
        cout << res << endl;
    }
    
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	private static List<Integer> getStrings(Scanner sc, int num) {
		List<Integer> stringList = new ArrayList<>();
		while(num>0) {
			int nextInt = sc.nextInt();
			stringList.add(nextInt);
			num--;
		}
		return stringList;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> array = getStrings(sc, n);
		array.sort(Integer::compareTo);
		Map<Integer, Integer> set = new HashMap();
		int max = array.get(array.size()-1);
		int count = 0;
		for (int i = 0; i < array.size(); i++) {
			int m = array.get(i);
			if (!set.containsKey(m)) {
				for (int j = 1; j <= max / m + 1; j++) {
					set.put(m * j, 1);
				}
			} else {
				int temp = set.get(m);
				set.put(m, temp+1);
			}

		}
		for (int i = 0; i < array.size(); i++) {
			if (set.get(array.get(i)) == 1) {
				count++;
			}
		}
		System.out.println(count);
		return;
	}

}




Measured memory_bytes: 124068
s = input()
flag = 0
if s[0]==s[1]:
  if s[2]==s[3] and s[0]!=s[2]:
    flag=1
elif s[0]==s[2]:
  if s[1]==s[3] and s[0]!=s[1]:
    flag=1
elif s[0]==s[3]:
  if s[1]==s[2] and s[0]!=s[1]:
    flag=1

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

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<math.h>
#include<string.h>
#include<set>
#include<algorithm>
using namespace std;

int main() {
    long n,x;
    cin>>n>>x;

    long a[110];
    for(int i=0;i<n;++i) cin>>a[i];

    sort(a,a+n);
    long p=0;
    if(x>=a[0]){
        for(long j=0;j<n;++j){
            if(x < a[j]) break;
            x -= a[j];
            ++p;
        }
        if(x > 0 and p == n) --p;
        cout<<p<<endl;
    }
    else cout<<"0"<<endl;
    
}





Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int N;
  scanf("%d", &N);
  
  int k;
  for(k = 0; k * (k - 1) <= 2 * N; k++);
  k--;
  
  int able = (k * (k - 1) == 2 * N);
  
  if(able){
    int S[k][N];
    int index[k];
    for(int i = 0; i < k; i++) index[i] = 0;
    
    int n = 1;
    for(int i = 0; i < k - 1; i++){
      for(int j = i + 1; j < k; j++){
        S[i][index[i]] = n;
        S[j][index[j]] = n;
        index[i]++;
        index[j]++;
        n++;
      }
    }
    
    puts("Yes");
    printf("%d\n", k);
    for(int i = 0; i < k; i++){
      printf("%d", index[i]);
      for(int j = 0; j < index[i]; j++){
        printf(" %d", S[i][j]);
      }
      printf("\n");
    }
  }else puts("No");
  
  return 0;
}

Measured memory_bytes: 173312
package main

import (
	"bufio"
	"fmt"
	"os"

	"github.com/emirpasic/gods/lists/arraylist"
)

type Robot struct {
	ID  int
	X   int64
	L   int64
	Min int64
	Max int64
}

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var n int
	fmt.Fscan(r, &n)

	list := arraylist.New()
	for i := 0; i < n; i++ {
		var x, l int64
		fmt.Fscan(r, &x, &l)
		robot := &Robot{
			ID:  i,
			X:   x,
			L:   l,
			Min: x - l,
			Max: x + l,
		}
		list.Add(robot)
	}

	comparator := func(a, b interface{}) int {
		aAseerted := a.(*Robot)
		bAsserted := b.(*Robot)
		switch {
		case aAseerted.Max > bAsserted.Max:
			return 1
		case aAseerted.Max < bAsserted.Max:
			return -1
		default:
			return 0
		}
	}
	list.Sort(comparator)

	var tmp int64
	var count int
	listIt := list.Iterator()

	for listIt.Next() {
		robot := listIt.Value().(*Robot)
		if tmp == 0 || robot.Min >= tmp {
			count++
			tmp = robot.Max
		}
	}

	fmt.Fprintln(w, count)
}


Measured memory_bytes: 11352
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

const ll M = 1000000007;

ll modpow(ll x,ll k){
	if(k == 0)return 1;
	ll tmp = modpow(x,k/2);
	tmp *= tmp; tmp %= M;
	if(k%2 == 1){
		tmp *= x;
		tmp %= M;
	}
	return tmp;
}

ll f[52];
ll f_inv[52];

int main(){
	f[0] = 1;
	for(int i = 1 ; i < 52 ; i ++){
		f[i] = f[i-1]*i;
		f[i] %= M;
	}
	for(int i = 0 ; i < 52 ; i ++){
		f_inv[i] = modpow(f[i],M-2);
	}
	
	ll N;
	cin >> N;
	
	ll ret = 0;
	static ll dp[52][52][52][52] = {};
	dp[0][1][1][0] = 1;
	for(int i = 0 ; i < 51 ; i ++){
		for(int j = 0 ; j <= N ; j ++){
			for(int k = 0 ; k < 52 ; k ++){
				for(int l = 0 ; l < 52 ; l ++){
					if(dp[i][j][k][l] == 0)continue;
					//cout << i << " " << j << " " << k << " " << l << " " << dp[i][j][k][l] << endl;
					if(j == N){
						dp[i][j][k][l] %= M;
						dp[i][j][k][l] *= f_inv[k]; dp[i][j][k][l] %= M;
						dp[i][j][k][l] *= f_inv[l]; dp[i][j][k][l] %= M;
						ret += dp[i][j][k][l]; if(ret>=M)ret-=M; continue;
					}
					dp[i][j][k][l] %= M;
					for(int s = 0 ; s < 52 ; s ++){
						for(int t = 0 ; t < 52 ; t ++){
							if(s+t == 0 || k+t-s < 0 || l+s-t < 0)continue;
							if(j+s+t > N)continue;
							ll hoge = f_inv[k+t-s]*f_inv[l+s-t]; hoge %= M;
							hoge *= dp[i][j][k][l]; hoge %= M;
							dp[i+1][j+s+t][s][t] += hoge;
						}
					}
				}
			}
		}
	}
	cout << (ret*f[N])%M << endl;
}



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

using namespace std;
using ll  = long long;
using pii = pair<int, int>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int D, G;
  cin >> D >> G;
  vector<pii> PD(D + 1);
  for (int i = 0; i < D; i++) {
    ll p, d;
    cin >> p >> d;
    PD[i] = make_pair(p, d);
  }

  ll ans = 1 << 29;
  for (int bit = 0; bit < (1 << D); bit++) {
    ll sum   = 0;
    ll count = 0;
    for (int i = 0; i < D; i++) {
      if ((bit >> i) & 1) {
        sum += (i + 1) * 100 * PD[i].first + PD[i].second;
        count += PD[i].first;
      }
    }

    if (sum >= G) ans = min(ans, count);

    for (int i = D - 1; i >= 0; i--) {
      if ((bit >> i) & 1) continue;
      for (int j = 0; j < PD[i].first; j++) {
        sum += (i + 1) * 100;
        count++;
        if (sum >= G) {
          ans = min(ans, count);
          break;
        }
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

int main() {
  int k, n, b;
  cin >> k >> n;
  int m = 0;
  vector<int> a(n, 0);
  vector<int> v(n, 0);
  rep(i, 0, n) {
    cin >> a[i];
    if(i != 0) {
      v[i] = a[i] - a[i-1];
    } 
    if(m < v[i] && i != 0) {
      m = v[i];
    }
  }
  v[0] = k - a[n-1] + a[0];
  if(m < v[0]) {
    m = v[0];
  }
  cout << k - m;
}

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

namespace ABC129
{
    class E
    {
        static void Main(string[] args)
        {
            const int m = 1000000007;

            string L = Console.ReadLine();
            char[] c = L.ToCharArray();
            int N = c.Length;

            long counter = 1;
            long digit = 1;
            for (int i = N - 1; i >= 0; i--)
            {
                if (c[i] == '1')
                {
                    counter = counter * 2 + digit; counter %= m;
                }

                digit *= 3;
                counter %= m;
                digit %= m;
            }

            Console.WriteLine(counter);

        }

    }
}


Measured memory_bytes: 13176
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;

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

int main() {

    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    ll G = C*D/__gcd(C,D);
    ll H = A-1;
    ll out = B-(B/C + B/D - B/G);
    if(A!=1) out -= H-(H/C + H/D - H/G);
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static boolean check(String str , int[] patt) {
		int pointer = 0;
		for(int i=0;i<str.length();i++) {
			if(str.charAt(i)-'0'==patt[pointer]) {
				pointer++;
			}
			if(pointer==3) {
				return true;
			}
		}
		return false;
	}
	
	public static void solve() {
		int n=s.nextInt();
		String str=s.next();
		int[] patt  =new int[3];
		int count = 0;
		for(int i=0;i<=9;i++) {
			for(int j=0;j<=9;j++) {
				for(int k =0;k<=9;k++) {
					patt[0]=i;
					patt[1]=j;
					patt[2]=k;
					if(check(str,patt)) {
						count++;
					}
				}
			}
		}
		out.println(count);
	}

	public static void main(String[] args) {
		out = new PrintWriter(new BufferedOutputStream(System.out));
		s = new FastReader();
		solve();
		out.close();
	}

	public static FastReader s;
	public static PrintWriter out;

	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	
}


Measured memory_bytes: 22996
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <functional>

using namespace std;

int BipartiteGraph(const vector<vector<int>> &g) {
        int n = g.size();
        vector<int> color(n, -1);
        int cnt = 0;
        function<bool (int, int, int)> dfs = [&](int u, int prev, int c) {
                color[u] = c;
                if (c == 1) cnt ++;
                for (auto v : g[u]) if (v != prev) {
                        if (color[v] == -1) {
                                if (!dfs(v, u, 1 - c)) return false;
                        } else if (color[v] != 1 - c) {
                                return false;
                        }
                }
                return true;
        };
        if (!dfs(0, -1, 0)) return -1;
        return cnt;
}

int main() {
        int n, m;
        scanf("%d %d", &n, &m);
        vector<vector<int>> g(n);
        for (int i = 0; i < m; i ++) {
                int a, b;
                scanf("%d %d", &a, &b);
                a --, b --;
                g[a].push_back(b);
                g[b].push_back(a);
        }
        int cnt = BipartiteGraph(g);
        if (cnt == -1) printf("%lld\n", (long long) n * (n - 1) / 2 - m);
        else printf("%lld\n", (long long) cnt * (n - cnt) - m);
        return 0;
}


Measured memory_bytes: 6784
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


mod=1000000007
def combinations_count_mod(n, r):
    r = min(r, n - r)
    numer = reduce(lambda x,y: x*y%mod, range(n, n - r, -1), 1)
    denom = pow( reduce(lambda x,y: x*y%mod, range(1, r + 1), 1) , mod-2, mod)
    return numer * denom % mod


def main():
    n,m = map(int,input().strip().split())
    print(n*m)


if __name__ == '__main__':
    main()

Measured memory_bytes: 78352
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
const int INF = 10000000;

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

//2362
int main(){
	string s;
	cin>>s;
	string ec[2] ={"egg", "chicken"};
	vii v;
	vi u;
	int last = -1;
	for(int i = 0; i < s.size(); i++){
		for(int j = 0; j < 2; j++){
			if(s[i] == ec[j][0]){
				if(j == last){
					v.pb(u);
					u.clear();
					u.pb(j);
				}
				else{
					u.pb(j);
					last = j;
				}
				i += ec[j].size() - 1;
			}
		}
	}
	v.pb(u);
	int m = 0;
	for(int i = 1; i < v.size(); i++){
		if(v[m].size() < v[i].size()) m = i;
	}

	cout<<ec[v[m][v[m].size() - 1]]<<endl;

}

Measured memory_bytes: 1244
#include <iostream>

using namespace std;

int main() {
    int i,h,m,s;

    cin >> i;
    h = i / 3600;
    m = (i % 3600) / 60;
    s = i % 60;

    cout << h << ":" << m << ":" << s << endl;

    return 0;
}

Measured memory_bytes: 1168
N=gets.to_i

p 0
base = s = gets.chomp
if s == 'Vacant'
  exit 0
end

left = 0
right = N
loop do
  center = (right+left)/2
#  STDERR.puts [left,right,center].to_s
  p center
  STDOUT.flush
  s = gets.chomp
  if s == 'Vacant'
    break
  elsif (center.even? && s == base) || (center.odd? && s!=base)
    left = center + 1
  else
    right = center
  end
end



Measured memory_bytes: 4168