akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int H,W;
int dp [400] [200] [200];
const int INF = 1e9;

bool in_range(int x,int y){
	return x >= 0 && x < W && y >= 0 && y < H;
}

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

	cin >> H >> W;
	vector< vector<int> > A(H,vector<int>(W));
	FOR(i,0,H) FOR(j,0,W){
		cin >> A [i] [j];
	}

	fill(dp [0] [0],dp [H + W] [0],-INF);
	dp [0] [0] [0] = A [0] [0];
	FOR(i,0,H + W - 1) FOR(j,0,W) FOR(k,0,W) if(dp [i] [j] [k] >= 0){
		FOR(l,0,4){
			int x1 = j + l / 2,y1 = i - x1 + 1,x2 = k + l % 2,y2 = i - x2 + 1;
			if(in_range(x1,y1) == false || in_range(x2,y2) == false) continue;
			int add;
			if(x1 == x2 && y1 == y2){
				add = A [y1] [x1];
			}
			else{
				add = A [y1] [x1] + A [y2] [x2];
			}
			chmax(dp [i + 1] [x1] [x2],dp [i] [j] [k] + add);
		}
	}

	cout << dp [H + W - 2] [W - 1] [W - 1] << endl;

	return 0;
}


Measured memory_bytes: 62976
n = int(input())
count = 0
f = False
for i in range(n):
  d1, d2 = [int(x) for x in input().split()]
  if d1 == d2:
    count += 1
  else:
    count = 0
  if count == 3:
    f = True
if f:
  print("Yes")
else :
  print("No")

Measured memory_bytes: 9128
#include <stdio.h>

int main()
{
	int all = 0;
	for(int i = 0; i < 4; i++)
	{
		int w;
		scanf("%d",&w);
		all += w;
	}
	printf("%d\n%d\n",all / 60,all % 60);
	return 0;
}

Measured memory_bytes: 1024
A,B,C = list(map(int,input().split()))
if A == B == C and A%2 == 0 :
    print(-1)
elif A == B == C and A%2 == 1 :
    print(0)
else :
    cnt=0
    while A%2==B%2==C%2==0:
        total=A+B+C
        A=total//2-A//2
        B=total//2-B//2
        C=total//2-C//2
        cnt+=1
    print(cnt)


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

int n,k,now=1;

int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++){
		if(now<k) now*=2;
		else now+=k;
	}
	cout<<now<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,i,c=1;
	scanf("%d %d",&a,&b);
	for(i=0;i<b;i++){
		c=c*2;
	}
	printf("%d",c*1900*b+(a-b)*100*c);
	return 0;
}

Measured memory_bytes: 128
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  string S,T;
  cin >> S >> T;
  if(T.find(S)==0) cout << "Yes" << endl;
  else cout << "No" << endl;

  
  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
using namespace std;
using cd = complex<double>;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
//     tree_order_statistics_node_update>;
 
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
typedef long long int ll;
typedef long double ld;
const ll N = 5e5+9;
// const ll m = 1e9 + 7;
// const ll inf= 1e14;
const ll mod =998244353;
const double PI = acos(-1);
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define pld pair<ld,ld>
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif  
    int t = 1;
    // cin>>t;
    while(t--){
        string s,t;
        cin>>s>>t;
        ll n = s.size();
        ll ans = 0;
        for(int i = 0;i<n;i++){
            if(s[i]!=t[i]){
                ans++;
            }
        }
        cout<<ans<<'\n';
    }
} 

Measured memory_bytes: 3736
#include<stdio.h>
int main(void) {
	double a[100];
	double a2[100];
	double a3 = 0;
	int b;
	scanf("%d", &b);

	for (int i = 0; i < b; i++) {
		scanf("%lf", &a[i]);
		a2[i] = 1 / a[i];
		a3 += a2[i];
	}
	printf("%lf", 1 / a3);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
//素因数分解
void soinsuuBunkai(int x,int y[]){
	for(int m=2;m<x;m++){
		if(x%m==0){
			x++;
			soinsuuBunkai(x,y);
			return;
		}
	}
	y[0]=x;
}

int main(void){
	int x;
	scanf("%d",&x);
	int sosuu[1];
	soinsuuBunkai(x,sosuu);
	printf("%d",sosuu[0]);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;

ll n, k, a, b;
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	map<ll, ll>::iterator it;
	
	map<ll, ll> m;
	
	cin >> n >> k;
	ll p = n;
	while (p--) {
		cin >> a >> b;
		m[a] += b;
	}
	for (it = m.begin(); it != m.end(); it++) {
		k -= it -> se;
		if (k <= 0) {
			cout << it -> fi;
			break;
		}
	}
	
}

Measured memory_bytes: 4224
N=int(input())
lis=[0,0,0,0]
for i in range(N):
  tmp=input()
  if tmp=="AC":
    lis[0]+=1
  elif tmp=="WA":
    lis[1]+=1
  elif tmp=="TLE":
    lis[2]+=1
  else:
    lis[3]+=1
print("AC x "+str(lis[0]))
print("WA x "+str(lis[1]))
print("TLE x "+str(lis[2]))
print("RE x "+str(lis[3]))

Measured memory_bytes: 9216
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    int w, h, x, y;

    cin >> w >> h >> x >> y;

    int ans;
    if(x + x == w && y + y == h){
       ans = 1;
    }
    else{
        ans = 0;
    }
    
    cout << double(w) * double(h) / 2  << ' ' << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 2e18;

map <ll, ll> mp;
ll a, b, c, d;
ll rec(ll x)
{
	if(x == 0) return 0;
	if(x == 1) return d;
	if(mp[x]) return mp[x];
	ll res1, res2, res3;
	if(x % 2 == 0) res1 = rec(x / 2) + a;
	else res1 = min(rec(x / 2) + a + d * (x % 2), rec(x / 2 + 1) + a + d * (2ll - x % 2));
	
	if(x % 3 == 0) res2 = rec(x / 3) + b;
	else res2 = min(rec(x / 3) + b + d * (x % 3), rec(x / 3 + 1) + b + d * (3ll - x % 3));
	
	if(x % 5 == 0) res3 = rec(x / 5) + c;
	else res3 = min(rec(x / 5) + c + d * (x % 5), rec(x / 5 + 1) + c + d * (5ll - x % 5));
	
	mp[x] = min({res1, res2, res3});
	if(inf64 / d >= x) mp[x] = min(mp[x], d * x);
	return mp[x];
}
int main()
{
	boost;
	ll t, n;
	cin >> t;
	while(t--)
	{
		cin >> n >> a >> b >> c >> d;
		cout << rec(n) << '\n';
		mp.clear();
	}
}


Measured memory_bytes: 4440
#include <stdio.h>
#include <stdint.h>

int main() {
  uint64_t N;
  scanf("%lu", &N);

  uint64_t T, _T, A, _A;
  scanf("%lu %lu", &T, &A);
  for(uint64_t i=1;i<N;i++) {
    scanf("%lu %lu", &_T, &_A);
    uint64_t r = T/_T > A/_A ? (T+_T-1)/_T : (A+_A-1)/_A;
    T = _T * r;
    A = _A * r;
  }
  printf("%lu\n", T+A);

  return 0;
}


Measured memory_bytes: 128
#include<iostream>

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

using namespace std;

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

    cout << (k / 2) * ((k + 1) / 2) << endl; //3 / 2 = 1(偶数の個数), 4 / 2 = 2(奇数の個数)
                                             //6 / 2 = 3(偶数の個数), 7 / 2 = 3(奇数の個数)
}

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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VS s(n);
    int ans = 0;
    int a_cnt = 0;
    int b_cnt = 0;
    int ba_cnt = 0;
    REP(i, n) {
        cin >> s[i];
        REP(j, s[i].size() - 1) if (s[i].substr(j, 2) == "AB") ans++;
        if (s[i].front() == 'B' and s[i].back() == 'A')
            ba_cnt++;
        else if (s[i].front() == 'B')
            b_cnt++;
        else if (s[i].back() == 'A')
            a_cnt++;
    }
    if (ba_cnt > 0) {
        ans += ba_cnt - 1;
        if (a_cnt > 0) {
            ans++;
            a_cnt--;
        }
        if (b_cnt > 0) {
            ans++;
            b_cnt--;
        }
        ans += min(a_cnt, b_cnt);
    } else {
        ans += min(a_cnt, b_cnt);
    }
    cout << ans << ln;
    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>

int cresc(const void *a, const void *b){
    if (*(int*)a == *(int*)b)
        return 0;
    else
        if (*(int*)a > *(int*)b)
            return 1;
        else
            return -1;
}

int main(){
    int vet[3];
    for (int i = 0; i < 3; i++){
        scanf("%d", &vet[i]);
    }
    qsort(vet, 3, sizeof(int), cresc);
    if (vet[0] == 5 && vet[1] == 5 && vet[2] == 7)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] as = br.readLine().split(" ");
		long n = Long.parseLong(as[0]);
		long k = Long.parseLong(as[1]);
		long result = 0;
		if(n%k == 0) {
			result = 0;
//		}else if(k%n == 0) {
//			result = n;
		}else {
			result = Math.min(n%k, Math.abs(k-n%k))  ;
		}
		System.out.println(result);
	}

}


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

vector<int> h;
int dp[(int)1e5 + 5];
int n;

int solve(int i) {
    if (i == n - 1) {
        return 0;
    } else if (i >= n)
        return 1e9;
    if (dp[i] == -1) {
        dp[i] = min(solve(i + 1) + abs(h[i + 1] - h[i]),
                    solve(i + 2) + abs(h[i + 2] - h[i]));
    }
    return dp[i];
}

int main(void) {
    memset(dp, -1, sizeof(dp));
    cin >> n;
    h.resize(n);
    for (auto &i : h)
        cin >> i;
    h.push_back(0);
    cout << solve(0) << "\n";
}

Measured memory_bytes: 3324
#include <stdio.h>
	int main(void){
		int n,i,j,k,b[250],f[250],r[250],v[250];
		int d1[250][250],d2[250][250],d3[250][250],d4[250][250];
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d %d %d %d",&b[i],&f[i],&r[i],&v[i]);
		}
		for(i=0;i<3;i++){
			d1[i][j]=0;
			d2[i][j]=0;
			d3[i][j]=0;
			d4[i][j]=0;
		}
		for(k=0;k<n;k++){
			if(b[k]==1){
				d1[f[k]-1][r[k]-1]+=v[k];
			}else if(b[k]==2){
				d2[f[k]-1][r[k]-1]+=v[k];
			}else if(b[k]==3){
				d3[f[k]-1][r[k]-1]+=v[k];
			}else if(b[k]==4){
				d4[f[k]-1][r[k]-1]+=v[k];
			}
		}
			for(i=0;i<3;i++){
				for(j=0;j<10;j++){
					printf(" %d",d1[i][j]);
				}
				printf("\n");
			}
			printf("####################\n");
			for(i=0;i<3;i++){
				for(j=0;j<10;j++){
					printf(" %d",d2[i][j]);
				}	
				printf("\n");
			}
			printf("####################\n");
			for(i=0;i<3;i++){
				for(j=0;j<10;j++){
					printf(" %d",d3[i][j]);
				}	
				printf("\n");
			}
	 		printf("####################\n");
	 		for(i=0;i<3;i++){
				for(j=0;j<10;j++){
					printf(" %d",d4[i][j]);
				}
				printf("\n");
			}	
	return 0;
}

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

using namespace std;

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

const long long MOD = 1e9 + 7;
const int INF = 1e9;
const double EPS = 1e-9;

int main() {
  int a;
  string s;
  cin >> a >> s;
  if (a < 3200) cout << "red" << endl;
  else cout << s << endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
int insum(int n){
    int sum=0;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0){
            sum+=2;
            if(i==sqrt(n)) sum--;
        }
    }
    return sum;
}
int main(){
    int n;
    cin >> n;
    int a,b,c,result=0,karesult=0;
    rep(i, n-1){
        c=i+1;
        karesult=insum(n-c);
        result+=karesult;
    }
    cout << result << endl;
}


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

#define int long long

using namespace std;
#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 pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

string s,t;
vint start(111,-1);
vint goal(111,-1);

signed main(){
    cin>>s>>t;
    
    rep(i,0,s.size()){
        int a=s[i]-'a';
        int b=t[i]-'a';
        if(start[a]!=-1||goal[b]!=-1){
            if(start[a]!=b||goal[b]!=a){
                cout<<"No"<<endl;
                return 0;
            }
        }
        else {
            start[a]=b;
            goal[b]=a;
        }
    }
    cout<<"Yes"<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 776
#include<stdio.h>
int main(void){
    int i,ans=0;
    char a[3],b[3];
    scanf("%s",a);
    scanf("%s",b);
    for(i=0;i<3;i++){
        if(a[i]==b[i])ans++;
    }
    printf("%d\n",ans);
    return 0;
}

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

int N;
vector<pair<int, int>> R, B;

void solve(){
	sort(R.begin(), R.end());
	sort(B.begin(), B.end());

	vector<bool> r(N, false);
	int ans = 0;

	for(int i = 0; i < N; i++){
		int c = B[i].first, d = B[i].second;
		int k = -1, maxy = -1;
		for(int j = 0; j < N; j++){
			int a = R[j].first, b = R[j].second;
			if(a >= c) break;
			if(b >= d) continue;
			if(r[j]) continue;
			if(b > maxy){
				k = j;
				maxy = b;
			}
		}
		if(k != -1){
			ans++;
			r[k] = true;
		}
	}
	cout << ans << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	for(int i = 0; i < N; i++){
		int a, b; cin >> a >> b;
		R.emplace_back(a, b);
	}
	for(int i = 0; i < N; i++){
		int c, d; cin >> c >> d;
		B.emplace_back(c, d);
	}
	solve();
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A, B] = [int(input_raw[0]), int(input_raw[1])]
    if A >= 13:
        print B
    elif A >= 6:
        print B/2
    else:
        print 0

if __name__ == '__main__':
    main()


Measured memory_bytes: 2932
def dijkstra(s,n,w,cost):
    #始点sから各頂点への最短距離
    #n:頂点数,　w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0
    
    while True:
        v = -1
        #まだ使われてない頂点の中から最小の距離のものを探す
        for i in range(n):
            if (not used[i]) and (v == -1):
               v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
               break
        used[v] = True
               
        for j in range(n):
               d[j] = min(d[j],d[v]+cost[v][j])
    return d

################################

h,w = map(int, input().split()) 

n=10
w=81

cost = [[float("inf") for i in range(n)] for i in range(n)] 
#cost[u][v] : 辺uvのコスト(存在しないときはinf この場合は10**10)
for i in range(10):
    clist = list(map(int, input().split()))
    clist[i]=99999
    #print(clist)
    for j in range(len(clist)):
        if clist[j]!=99999:
            cost[j][i]=clist[j]

costs=dijkstra(1,n,w,cost)
kotae=0
for i in range(h):
    alist = list(map(int, input().split()))
    for al in alist:
        if al!=-1:
            kotae+=costs[al]

print(kotae)

Measured memory_bytes: 40428
H,W=gets.chomp.split(" ").map(&:to_i)
rets=[]
cf=false
H.times do |h|
    array=gets.chomp.split(" ").map(&:to_i)
    array[-1]+=1 if cf
    cf=false
    W.times do |w|
        break if h==H-1 && w==W-1
        if array[w].odd?
            if w+1==W
                cf=true
                rets.push("#{h+1} #{w+1} #{h+2} #{w+1}")
            else
                array[w+1]+=1
                rets.push("#{h+1} #{w+1} #{h+1} #{w+2}")
            end
        end
    end
end
puts rets.length
rets.each {|r| puts r}


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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a;ans%=MD; a=a*a;a%=MD; b=b>>1;}	return ans;}
template <typename T> 
T Min(T a,T b){ return a<b?a:b; }
template <typename T>
T Max(T a,T b){ return a>b?a:b; }
vector<ll> fact(200001);
vector<ll> inv(200001);
void init(){
	fact[0]=1;inv[0]=1;
	for(int i=1;i<=200000;++i) {fact[i]=(fact[i-1]*i)%MD;inv[i]=binpow(fact[i],MD-2);}
	
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	//ll n;cin>>n; vl a(n); repi(i,n) cin>>a[i];
	ll h,w,a,b;cin>>h>>w>>a>>b;
	init();
	ll ans=0,ans2=0;
	for(ll j=b;j<w;++j){
		// out of j+h-a +w-2+a-j
		ans=fact[j+h-a-1]*inv[h-a-1];
		ans%=MD;
		ans*=inv[j];
		ans%=MD;
		ans*=fact[a-1+w-j-1];
		ans%=MD;
		ans*=inv[a-1];
		ans%=MD;
		ans*=inv[w-1-j];
		ans%=MD;
		
		ans2+=ans;
		ans2%=MD;
	}
	db(ans2);
	//vector<vector<ll> > dp(h);
	//vector<ll> p(w,0);
	//repi(i,h) dp[i]=p;
	
	/*
	int test1;cin>>test1;while(test1--){ 
		
	 }
	 //*/
return 0;
}
/*
1  1  1  1  1  1  1  1  1  
1  2  3  4  5  6  7  8  9  
1  3  6 10 15 21 28 36 45
0  0  0 10 25 46 74 110 155
0  0  0 10 35 81 
0  0  0
*/


Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
signed main(){
        int n;
        scanf("%lld",&n);
        for(int i=0;i<n;i++){
                double x1, y1, x2, y2, x3, y3, x4, y4;
                scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
                double c1 = (y2-y1)/(x2-x1);
                double c2 = (y4-y3)/(x4-x3);
                if((x2-x1==0 && x4-x3==0) || fabs(c1-c2) <= 1E-10) printf("YES\n");
                else printf("NO\n");
        }
        return 0;
}

Measured memory_bytes: 3112
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}
// fold was added in D 2.071.0.
template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
        static if (S.length < 2) {
            return reduce!fun(seed, r);
        } else {
            return reduce!fun(tuple(seed), r);
        }
    }
}

void main() {
    int W, H, N;
    readf("%d %d %d\n", &W, &H, &N);
    int[][] grid = new int[][](W+1, H+1);
    N.times!({
        int x, y, a;
        readf("%d %d %d\n", &x, &y, &a);
        a==1 ? {
            grid[0][0]++;
            grid[x][0]--;
            grid[0][H]--;
            grid[x][H]++;
        }() : a==2 ? {
            grid[x][0]++;
            grid[W][0]--;
            grid[x][H]--;
            grid[W][H]++;
        }() : a==3 ? {
            grid[0][0]++;
            grid[W][0]--;
            grid[0][y]--;
            grid[W][y]++;
        }() : {
            grid[0][y]++;
            grid[W][y]--;
            grid[0][H]--;
            grid[W][H]++;
        }();
    });
    foreach(i; 0..W) foreach(j; 1..H) {
        grid[i][j] += grid[i][j-1];
    }
    foreach(i; 1..W) foreach(j; 0..H) {
        grid[i][j] += grid[i-1][j];
    }
    grid[0..$-1].map!"a[0..$-1]".join.count!"a==0".writeln;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SZ(x) (int)(x).size()
#define mset(a,x) memset(a,x,sizeof(a))
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"
#define OUT(x) cout<<(x)<<"\n"
#define FASTIO cin.tie(0),ios::sync_with_stdio(0)
#define pb push_back
#define mp make_pair

int x, y;

int main() {
    cin>>x>>y;
    if(x == y){ OUT(0); return 0; }

    int xx = -x, yy = -y;
    int ans = 1<<30;

    if(x <= y)
        ans = min(ans, y - x);
    if(xx <= y)
        ans = min(ans, y + x + 1);
    if(x <= yy)
        ans = min(ans, yy - x + 1);
    if(xx <= yy)
        ans = min(ans, yy - xx + 2);

    OUT(ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int p[n];
    for(int i = 0; i < n; i++){
      cin >> p[i];
    }

    int count = 0;

    
    for(int i = 0; i < n; i++){
      if(i+1 != p[i]){
        count ++;
      }
    }
    if(count == 0 || count == 2){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()!!
    val t = readLine()!!

    var ans = s.toCharArray()
    var tOk = false
    for (i in s.length-t.length downTo 0) {
        ans = s.toCharArray()
        tOk = true
        for (j in t.indices) {
            if (s[i+j] == '?' || s[i+j] == t[j]) {
                ans[i+j] = t[j]
            } else {
                tOk = false
                break
            }
        }
        if (tOk) break
    }
    if (tOk) {
        println(ans.joinToString("").replace("?","a"))
    } else {
        println("UNRESTORABLE")
    }
}


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

int main(){
  int N ; 
  cin >> N ; 
  vector<int> a(N) ; 
  int over = 0 ;
  int cnt = 0 ; 
  
  for(int i = 0 ; i < N ; i++){
    cin >> a.at(i) ; 
    a.at(i) = a.at(i)/400 ;
    if(a.at(i) >= 8){
      over++ ; 
    }
    else{
      int T = 0 ; 
      for(int j = 0 ; j <= i ; j++){
        if(a.at(i) == a.at(j)){
          T++ ; 
        }
      }
      if(T == 1){
      cnt++ ; 
      }
    }

    //cout << a.at(i) << " " << cnt << endl ; 
  }
  
  if(cnt == 0 ){
    cout << 1  ; 
  }
  else {
    cout << cnt  ;   
  }
  
  
  //if(cnt == 8){
  //  cout << " " << cnt << endl ; 
  //  return 0 ; 
  //
  //}
  if(  over > 0 ){
    cnt = cnt + over ; 
    //if(cnt > 8 ){
   //   cnt = 8 ; 
    }
    
  
  
  cout << " " << cnt << endl ; 
  return 0 ; 
  


  
}

Measured memory_bytes: 3612
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
   
//#include <x86intrin.h>
#include <bits/stdc++.h>   
 
using namespace std;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, m, a[1001], b[1001], c[1001][1001], dp[(1 << 20)];

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n >> m;
   for (int i = 0; i < m; i ++) {
      cin >> a[i] >> b[i];
      for (int j = 0; j < b[i]; j ++)
         cin >> c[i][j], c[i][j] --;
   }
   fill (dp + 1, dp + (1 << n), mod);
   for (int i = 0; i < m; i ++) {
      for (int mask = 0; mask < (1 << n); mask ++) {
         if (dp[mask] == mod) continue;
         int nmask = mask;
         for (int j = 0; j < b[i]; j ++) {
            nmask |= (1 << c[i][j]);
         }
         dp[nmask] = min (dp[nmask], dp[mask] + a[i]);
      }
   }
   int ans = dp[(1 << n) - 1];
   if (ans == mod) ans = -1;
   cout << ans;
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

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

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

	int N; cin >> N;
	double a[110];
	double z = 0;
	for (int i = 0;i < N; i++) {
		cin >> a[i];
		z += 1 / a[i];
	}
	cout << 1 / z;
}

Measured memory_bytes: 256
//==================================================================================================
// Name        : SAO.cpp
// Author      : lotus.eater086
// Copyright   : If you're reading this then this warning is for you. Every word you read of this 
//               useless fine print is another second of your life. Don't you've other things to do?
//               Is your life so empty that you honestly can't think of a better way to spend these
//               moments ? Or are you so impressed with authority that you give respect and 
//               credence to all who claim it ? Do you read everything you're supposed to read ? Do
//               you think everything you're supposed to think ? Buy what you're told you should 
//               want ? Get out of your apartment . Meet a member of the opposite sex. Stop the 
//               excessive shopping and self-improvement . Quit your boring job.
//               Start a fight. Prove you're alive. If you don't claim your humanity you'll become a
//               statistic. You've been warned !

// Description : 
// Date        : 2019-08-06
// Time        : 20:40:17
// Directory   : c:\Users\Lenovo\cpPractise\deliberatePractise\code_folder\.vscode
// FilePath    : c:\Users\Lenovo\cpPractise\deliberatePractise\code_folder\.vscode\SAO.cpp
//==================================================================================================
    

#include <bits/stdc++.h>
#define LL long long
#define endl "\n"

using namespace std ;
    
//
template < typename T >

inline T read( T &x )
{

    x = 0 ;

    int f = 0 ;

    char ch = getchar() ;

    while( ch < '0' || ch > '9' )  {

        f |= ( ch == '-' ) , ch = getchar() ;

    }

    while( ch >= '0' && ch <= '9' )  {

        x = ( x << 1 ) + ( x << 3 ) + ch - '0' , ch = getchar() ;

    }

    return x = f ? -x:x ;

}
//

void solve( void )
{

    int n ;

    cin >> n ;

    vector<int> v(n) ;

    for( int i = 0 ; i < n ; i++ )  cin >> v[i] ;

    if( n == 1 )  cout << "Yes\n" ;

    else  {

        int flag = 0 ;

        for( int i = n-2 ; i >= 0 ; i-- )  {

            if( v[i] > v[i+1] && v[i]-1 == v[i+1] ) v[i]-- ;

            else if( v[i] > v[i+1] )  flag = 1 ;

        }

        if(flag)  cout << "No\n" ;

        else  cout << "Yes\n" ; 

    }

}

int main( void )

{

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

   

    if( 0 )  {

        int t = 100 ;

        for( int i = 1 ; i <= t ; i++ )  solve() ;

    }

    else  {

        solve() ;

    }

   

    return 0 ;

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[3]={};
  	char b[3]={};
   cin>>a;
   cin>>b;
   int i,count=0;
  for(i=0;i<3;i++){
  if(a[i]==b[i])
    count++;
  else
    continue;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{    
    string n;
    cin >> n;
    
    string ans = "No";
    for(int i=0; i<3; ++i){
        if(n[i] == '7'){
            ans = "Yes";
        }
    }

    cout << ans << endl;
    return 0;
}

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

int main(){
   int N=0;
   cin >> N;
   vector<int> x(N);
   vector<int> y(N);
   int m=0;
   
   for(int i=0; i<N; i++){
       cin >> x.at(i) >> y.at(i);
   }

   int zmax=x.at(0)+y.at(0);
   int zmin=x.at(0)+y.at(0);
   int wmax=x.at(0)-y.at(0);
   int wmin=x.at(0)-y.at(0);


   for(int i=0; i<N; i++){
       if(zmax<x.at(i)+y.at(i)){
           zmax=x.at(i)+y.at(i);
       }

       if(zmin>x.at(i)+y.at(i)){
           zmin=x.at(i)+y.at(i);
       }
   }

   for(int i=0; i<N; i++){
       if(wmax<x.at(i)-y.at(i)){
           wmax=x.at(i)-y.at(i);
       }

       if(wmin>x.at(i)-y.at(i)){
           wmin=x.at(i)-y.at(i);
       }
   }

   m=max(zmax-zmin,wmax-wmin);
   cout << m << endl;
}

Measured memory_bytes: 4824
import java.util.Scanner;

public class Main {
	long count = 0;

	public static void main(String[] args) {
		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] A = new int[n];
		for (int i = 0; i < n; i++) {
			A[i] = scanner.nextInt();
		}
		int part = partition(A, 0, n - 1);
		for (int i = 0; i < n; i++) {
			if (part == i) {
				System.out.print("[" + A[i] + "]");
			} else {
				System.out.print(A[i]);
			}
			System.out.print(i == n - 1 ? "\n" : " ");
		}
	}

	private int partition(int[] a, int p, int r) {
		int work;
		int i = p - 1;
		for (int j = p; j < r ; j++) {
			if (a[j] <= a[r]) {
				i++;
				work = a[i];
				a[i] = a[j];
				a[j] = work;
			}
		}
		work = a[i + 1];
		a[i + 1] = a[r];
		a[r] = work;
		return i + 1;
	}
}

Measured memory_bytes: 64436
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res

def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,b = LI()
    print(max(a+b,a-b,a*b))
    return

#B
def B():
    k,x = LI()
    ans = []
    for i in range(x-k+1,x+k):
        ans.append(i)
    print(*ans)
    return

#C
def C():
    def f(s):
        res = [0]*m
        for i in s:
            res[alp.index(i)] += 1
        return res
    alp = list("abcdefghijklmnopqrstuvwxyz")
    m = len(alp)
    n = I()
    s = [input() for i in range(n)]
    d = defaultdict(lambda : 0)
    for i in s:
        d[tuple(f(i))] += 1
    ans = 0
    for i in d.values():
        ans += (i*(i-1))//2
    print(ans)
    return

#D
def D():
    n,m = LI()
    g = LIR(n)
    g.sort(key = lambda x:x[0])
    ans = 0
    f = [1]*n
    j = 0
    q = []
    for i in range(m)[::-1]:
        while j < n and m-g[j][0] >= i:
            a,b = g[j]
            heappush(q,(-b,a))
            j += 1
        if q:
            x,a = heappop(q)
            if i+a <= m:
                ans -= x
    print(ans)
    return

#E
def E():
    def dfs(x,f):
        for y,w in v[x]:
            if f[y]:
                if dp[y] < dp[x]+w:
                    f[y] = 0
                    dp[y] = dp[x]+w
                    dfs(y,f)
                    f[y] = 1
            else:
                if dp[y] < dp[x]+w:
                    dp[y] = float("inf")
                    dfs(y,f)
    n,m,p = LI()
    v = [[] for i in range(n)]
    for i in range(m):
        a,b,c = LI()
        a -= 1
        b -= 1
        v[a].append((b,c-p))
    f = [1]*n
    dp = [-float("inf")]*n
    dp[0] = 0
    f[0] = 0
    dfs(0,f)
    ans = dp[n-1]
    if ans == float("inf") or ans == -float("inf"):
        print(-1)
    elif ans < 0:
        print(0)
    else:
        print(ans)
    return

#F
def F():
    def comb(a,b):
        return fact[a]*inv[b]*inv[a-b]%p

    p = I()
    a = LI()
    fact = [1]
    for i in range(p-1):
        fact.append(fact[-1]*(i+1)%p)
    inv = [1]*p
    inv[p-1] = pow(fact[p-1],p-2,p)
    for i in range(1,p)[::-1]:
        inv[i-1] = inv[i]*i%p
    b = [0]*p
    for i in range(p):
        ai = a[i]
        if ai:
            b[0] += ai
            k = 1
            for j in range(p):
                c = ai*comb(p-1,j)*k%p
                k *= i
                if k >= p:
                    k %= p
                if j%2:
                    b[p-1-j] += c
                else:
                    b[p-1-j] -= c
                b[p-1-j] %= p
    print(*b)
    return

#Solve
if __name__ == "__main__":
    F()


Measured memory_bytes: 45680
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to) 
int main() {
	string s;
	int x=0, y=0;
	while(cin >> s) {
		int a[3];
		int p = s.find(",", 0);
		int q = s.find(",", p + 1);
		a[0] = atoi(s.substr(0, p).c_str());
		a[1] = atoi(s.substr(p + 1, q - p).c_str());
		a[2] = atoi(s.substr(q + 1).c_str());
		sort(a, a+2);
		if(a[0] * a[0] + a[1] * a[1] == a[2] * a[2]) x++;
		else if(a[0] == a[1]) y++;
	}
	cout << x << endl;
	cout << y << endl;
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	int march[5];
	rep(i,0,5)march[i] = 0;
	rep(i,0,n){
		string temp;
		cin >> temp;
		if(temp[0] == 'M')march[0]++;
		else if (temp[0] == 'A')march[1]++;
		else if (temp[0] == 'R')march[2]++;
		else if (temp[0] == 'C')march[3]++;
		else if (temp[0] == 'H')march[4]++;
	}
	int comb[10] = {7,11,13,14,19,21,22,25,26,28};
	long long dans[10];
	rep(i,0,10)dans[i] =1; 
	long long ans = 0;
	rep(i,0,10){
		int temp = comb[i];
		rep(j,0,5){
			if(temp & 1){
				// puts("pit in!");
				dans[i] *= march[j];
			}
			temp = temp >> 1;
		}
	}
	rep(i,0,10)ans += dans[i];
	cout << ans << endl;
	// rep(i,0,n)cout << march[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

ll solve(){
    ll res = 0;
    ll N; cin >> N;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    if(A[0] != 0) return -1;
    for(int i = 1; i < N;i++){
        if(A[i-1] < A[i] && (A[i] - A[i-1]) != 1) return -1;
        if(A[i] > A[i-1]){
            res++;
        }else {
            res += A[i];
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 1792
import sys
from itertools import accumulate
import math

def main():
  input=sys.stdin.readline
  n=int(input())
  A=list(map(int,input().split()))
  dp=[[math.inf]*n for _ in range(n)]
  for i in range(n):
    dp[i][i]=0
  #print(*dp,sep="\n")
  accA=list(accumulate([0]+A))
  #print(accA)
  for L in reversed(range(n)):
    dpL=dp[L]
    for R in range(L+1,n):
      dpL[R]=min([dpL[k-1]+dp[k][R] for k in range(L+1,R+1)])+accA[R+1]-accA[L]
  #print(dp)
  print(dp[0][-1])
main()

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

using namespace std;
#define ull unsigned long long
#define si short int
#define ll long long
#define pii pair<int, int>

/*-----------------------------------------------------MATH------------------------------------------------*/
inline ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

inline int pwm(ll xx, ll pow, int MD) {
    if (pow < 0) { pow = pow % (MD - 1) + MD - 1; }
    ll mlt = 1;
    while (pow) {
        if (pow & 1) {
            mlt *= xx;
            mlt %= MD;
        }
        xx *= xx;
        pow >>= 1;
        xx %= MD;
    }
    return (int) mlt;
}

inline ll gcdex(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll xx, yy;
    ll gc = gcdex(b, a % b, yy, xx);
    x = xx;
    y = yy - (a / b) * xx;
    return gc;
}

inline int inv(ll r, int _mod) { return pwm(r % _mod, _mod - 2, _mod); }

/*-----------------------------------------------------MATH------------------------------------------------*/

const int inf = 1e9;
const int MAXN = 2e5 + 10;
ll mod = 1e9+7;
vector<ll> summ;
vector<ll> deg2;
vector<ll> deg3;
vector<ll> c;
void solve() {
    int n;
    cin>>n;
    deg2.resize(2*n+2);
    deg3.resize(n+1);
    c.resize(n);
    for(int i=0;i<n;i++) cin>>c[i];
    sort(c.begin(), c.end());
    deg2[0]=1;
    for(int i=1;i<2*n+2;i++) {
        deg2[i]=deg2[i-1]*2;
        deg2[i]%=mod;
    }
    ll ans=0;
    for(int k=1;k<=n;k++){
        ll summ=k*deg2[2*n-1];
        ll sum2=(k-1)*deg2[2*n-2];
        summ%=mod;
        sum2%=mod;
        summ-=sum2;
        summ%=mod;
        summ*=c[n-k];
        summ%=mod;
        ans+=summ;
        ans%=mod;
    }
    cout<<(ans%mod+mod)%mod;

}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n = 1;
    for (int i = 0; i < n; i++) solve();
    return 0;
}

Measured memory_bytes: 6528
#include <iostream>

int main()
{
    int a, b;
    std::cin >> a >> b;
    if (a > b) {
        std::cout << "a > b" << std::endl;
    } else if (a < b) {
        std::cout << "a < b" << std::endl;
    } else {
        std::cout << "a == b" << std::endl;
    }
    return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  ll h, w;
  cin >> h >> w;
  if (h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  }
  ll ans = (h * w + 1) / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))

ans = 0

for i in range(1, n - 1):
    if p[i] < p[i + 1] and p[i] > p[i - 1]:
        ans += 1
    elif p[i] > p[i + 1] and p[i] < p[i - 1]:
        ans += 1


print(ans)


Measured memory_bytes: 3060
#include <cstdio>

using namespace std;

int main(void){
  int n,maxd,x,a[10000];
  int cnt;
  
  scanf("%d%d%d", &n, &maxd, &x);
  for (int i=0; i<n; i++) scanf("%d", &a[i]);
  
  cnt = 0;
  for (int i=0; i<n; i++){
    for (int d=1; d<=maxd; d+=a[i]){
      cnt++;
    }
  }
  printf("%d\n", cnt + x);
  
  return 0;
}

Measured memory_bytes: 128
import math
#https://qiita.com/snow67675476/items/e87ddb9285e27ea555f8
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

a,b = map(int,input().split())
g = math.gcd(a,b)
if g==1:
    print(1)
else:
    yakusu = factorization(g)
    print(len(yakusu)+1)

Measured memory_bytes: 9440
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <stdio.h>
#include <queue>
#include <cmath>
#include <utility>
#include <map>

using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);++i)

int i, j, k;
int main() {
	string S;
	cin >> S;
	int a=0, b=0;
	for (i = 0; i < S.size();i++) {
		if (S[i] == '0')
			a++;
		else
			b++;
	}
	cout << min(a, b)*2;


	return 0;
}

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

int main() {
    int N;
    long long K;
    cin >> N >> K;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    
    long long x = 0;
    for (int s = 43; s >= 0; s--) {
        int a = 0, b = 0;
        for (int i = 0; i < N; i++) {
            if (A[i]bitand(1LL<<s)) a++;
            else b++;
        }
        if (a > b or (x|(1LL<<s)) > K) continue;
        x |= (1LL<<s);
    }
    
    long long ans = 0;
    for (int i = 0; i < N; i++) ans += (A[i]^x);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
	}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	int n,k;
    cin >> n >> k;
    cout << ((2*k-1)<=n?"YES\n":"NO\n");
	return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    int c;
    cin >> c;
    
    vector<int> s = vector<int>(n, 0);
    vector<int> t = vector<int>(n, 0);
    vector<int> cn = vector<int>(n, 0);
    
    for (int i = 0; i < n; ++i)
    {
        cin >> s[i];
        cin >> t[i];
        cin >> cn[i];
    }
    vector<int> time = vector<int>(200002, 0);
    
    for (int ch = 1; ch < 31; ++ch)
    {
        vector<int> timetmp = vector<int>(200002, 0);
        for (int i = 0; i < n; ++i)
        {
            if (cn[i] == ch)
            {
                for (int j = (2 * s[i] - 1); j < (2 * t[i]); ++j)
                {
                    timetmp[j]++;
                }
            }
        }
        for (int j = 0; j < timetmp.size(); ++j)
        {
            if (timetmp[j] > 0)
            {
                time[j]++;
            }
        }
    }
    
    int ret = 0;
    for (int i = 0; i < time.size(); ++i)
    {
        ret = max(ret, time[i]);
    }
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 2944
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
        int nums[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
      	int k = sc.nextInt();
      
      	System.out.println(nums[k-1]);      	        
	}
}

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

#define MAX 2000000
#define INFTY (1<<30)

int H,A[MAX+1];

void maxHeapify(int i){
    int l,r,largest,a;
    l=2*i;
    r=2*i+1;
    if(l<=H&&A[l]>A[i]) largest = l;
    else largest =i;
    if(r<=H&&A[r]>A[largest]) largest =r;
    
    if(largest!=i){
        a = A[i];
        A[i]=A[largest];
        A[largest]=a;
        maxHeapify(largest);
    }
}

int extract(){
    int maxv;
    if(H<1)return -INFTY;
    maxv=A[1];
    A[1]=A[H--];
    maxHeapify(1);
    return maxv;
}


void increaseKey(int i,int key){
    int a;
    if(key < A[i]) return;
    A[i]=key;
    while(i>1&&A[i/2]<A[i]){
        a=A[i];
        A[i]=A[i/2];
        A[i/2]=a;
        i=i/2;
    }
}


void insert(int key){
    H++;
    A[H]=-INFTY;
    increaseKey(H, key);
}


int main(){
    int key;
    char com[10];
    
    while(1){
        scanf("%s",com);
        if(com[0]=='e'&&com[1]=='n') break;
        if(com[0]=='i'){
            scanf("%d",&key);
            insert(key);
        }else {
            printf("%d\n",extract());
        }
    }
    return 0;
}



Measured memory_bytes: 5672
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int X;
  cin >> X;

  if(X == 2) {
    cout << 2 << endl;
    return 0;
  }

  for(int i = X;i < 200000;i++) {
    bool can = true;
    for(int j = 2;j < i;j++) {
      if(i % j == 0) {
        can = false;
        break;
      }
    }
    if(can) {
      cout << i << endl;
      return 0;
    }
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <utility>
#include <algorithm>
#include <vector>

using namespace std;
typedef std::pair<long, long> P;

bool comp(P& lhs, P& rhs) {
    return lhs.second < rhs.second;
}

int main() {
    int N;
    cin >> N;
    
    vector<P> pair_vec;

    long a, b;

    for (int i = 0; i < N; i++) {
        cin >> a >> b;
        pair_vec.push_back(P(a, b));
    }
    
    sort(pair_vec.begin(), pair_vec.end(), comp);

    long limit_time = 0;
    long work_time = 0;

    bool flag = true;

    for (int i = 0; i < N; i++) {
        limit_time = pair_vec[i].second;
        work_time += pair_vec[i].first;
        if (limit_time < work_time) {
            flag = false;
            break;
        }
    }

    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 6128