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

typedef long long LL;

const LL lim = (LL)1e18;
const int N = 1e3 + 10;

int T;
LL n, a, b, c, d;
bool done[N];
LL dp[N];
unordered_map<LL, LL> MP;
unordered_set<LL> ST;

struct Node{
	LL val, cost;
	Node(){}
	Node(LL val, LL cost):val(val),cost(cost){}
	bool operator < (const Node &A)const{
		return cost > A.cost;
	}
};

vector<Node> V;
priority_queue<Node> Q;

void add(LL v, LL c){
	if(!MP.count(v) || c < MP[v]){
		MP[v] = c;
		Q.push(Node(v, c));
	}
}

void add2(LL v, LL c){
	if(c < dp[v]){
		dp[v] = c;
		Q.push(Node(v, c));
	}
}

LL mul(LL cur, LL cost, LL num){
	double p = cur + (double)cost * num;
	if(p >= lim)	return lim;
	return cur + cost * num;
}

void init(){
	MP.clear();
	ST.clear();
	while(!Q.empty())	Q.pop();

	Q.push(Node(n, 0));
	MP[n] = 0;
	Node nd;
	V.clear();
	LL val;
	while(!Q.empty()){
		nd = Q.top(); Q.pop();

		if(nd.val < N){
			dp[nd.val] = min(dp[nd.val], nd.cost);
			continue;
		}

		if(ST.count(nd.val)){
			continue;
		}

		ST.insert(nd.val);

		for(int i=0; i<=5; i++){
			for(int j=-1; j<=1; j+=2){
				val = nd.val + i * j;
				if(val < 0)	continue;
				if(val % 2 == 0){
					add(val / 2, mul(nd.cost + a, d, i));
					add(val / 2, mul(nd.cost, d, nd.val - val / 2));
				}
				if(val % 3 == 0){
					add(val / 3, mul(nd.cost + b, d, i));
					add(val / 3, mul(nd.cost, d, nd.val - val / 3));
				}
				if(val % 5 == 0){
					add(val / 5, mul(nd.cost + c, d, i));
					add(val / 5, mul(nd.cost, d, nd.val - val / 5));
				}
			}
		}
	}
}

LL cal(){
	for(int i=0; i<N; i++){
		dp[i] = lim;
		done[i] = 0;
	}
	init();
	
	while(!Q.empty())	Q.pop();

	for(int i=0; i<N; i++){
		if(dp[i] < lim)	Q.push(Node(i, dp[i]));
	}

	LL ret;
	Node nd;

	while(!Q.empty()){
		nd = Q.top(); Q.pop();

		if(nd.val == 0){
			ret = nd.cost;
			break;
		}

		if(done[nd.val])	continue;
		done[nd.val] = 1;

		if(nd.val + 1 < N){
			add2(nd.val+1, dp[nd.val]+d);
		}
		add2(nd.val-1, dp[nd.val]+d);
		if(nd.val % 2 == 0){
			add2(nd.val/2, dp[nd.val]+a);
		}
		if(nd.val % 3 == 0){
			add2(nd.val/3, dp[nd.val]+b);
		}
		if(nd.val % 5 == 0){
			add2(nd.val/5, dp[nd.val]+c);
		}
	}

	return ret;
}

int main(){
	scanf("%d", &T);
	while(T--){
		scanf("%lld %lld %lld %lld %lld", &n, &a, &b, &c, &d);
		printf("%lld\n", cal());
	}
	return 0;
}

Measured memory_bytes: 8472
n,*a=$<.read.split.map &:to_i
r=[0]*n
a.each{|e|r[e]+=1}
res=1
mod=10**9+7
(n-1).step(0, -2){|i|
    res=res*2%mod
    res=0 if (i>0 and r[i]!=2) or (i==0 and r[i]!=1)
}
puts res>>n%2

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

int main(void) {
	int N, K, X, Y;
	scanf("%d%d%d%d", &N, &K, &X, &Y);
	if (N <= K) {
		printf("%d\n", X * N);
	} else {
		printf("%d\n", X * K + Y * (N - K));
	}
	return 0;
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
  int x, y;
  cin >> x >> y;
  if (x + y >= 10) {
    cout << "error" << endl;
  } else {
    cout << x + y << endl;
  }
}

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

using namespace std;
using ll = long long;
using vs = vector<string>;
using pll = pair<ll,ll>;
using vpl = vector<pll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vvb = vector<vb>;

#define R(a,i) for(ll a=0; a < (i); (a)++)
#define FOR(a,i,j) for(ll a=(i); a < (j); (a)++)
#define RD(a,i) for(ll a=(i)-1; (a) >= 0; (a)--)
#define FORD(a,i,j) for(ll a=(j)-1; (a) >= (i); (a)--)

#define xx first
#define yy second
#define pb push_back

#define all(X) begin(X),end(X)
#define sz(X) (X).size()

#define DBG 1
#define TR(X) {if(DBG) cerr << (#X) << " = " << (X) << "\n";}
#define hline {if(DBG) cerr << "----------------------------------------------------------------------" << "\n";}
#define PK(X) {if(DBG) cerr << (X) << "\n";}

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

	ll N, M;
	cin >> N >> M;

	priority_queue<ll> pq;
	FOR(i,0,N){
		ll a;
		cin >> a;
		pq.push(a);
	}

	FOR(i,0,M) {
		ll a = pq.top();
		pq.pop();
		pq.push(a/2);
	}
	ll res = 0;

	while(sz(pq))
	{
		res += pq.top();
		pq.pop();
	}

	cout << res << endl;
}


Measured memory_bytes: 1400
#include <stdio.h>
#include <iostream>
#define FOR(i, n) for (int i = 1; i <= n; i++)
using namespace std;

#define N 100010
#define MOD 1000000007
int n, a[N];
int main() {
#ifdef QWERTIER
  freopen("in.txt", "r", stdin);
#endif
  scanf("%d", &n);
  long long ans = 1, dec = 0;
  FOR (i, n) {
    scanf("%d", &a[i]);
    if (a[i] >= 2*(i-dec)-1) {
      ans = ans * (i-dec) % MOD;
    } else {
      ans = ans * (i - dec) % MOD;
      //printf("%d %d\n", i, dec);
      dec++;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

#define max 100

int main()
{
    long int a, b, k;
    
    scanf("%ld %ld %ld", &a, &b, &k);
    
    if (a<=k) {
        b=b-(k-a);
        a=0;
        if(b<0){
            b=0;
        }
    }else if(a>k){
        a=a-k;
    }
    
    printf("%ld %ld", a, b);
    
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

string bigsum(string A, string B) {
	//A+Bを返す
	vector<char>num(10);
	num = { '0','1','2','3','4','5','6','7','8','9' };
	if (A.size() > B.size()) {
		swap(A, B);
	}
	int a = A.size();
	int b = B.size();
	int size = b + 1;
	reverse(A);
	reverse(B);
	vector<int>V(size, 0);
	rep(i, a) {
		V[i] = (A[i] - '0') + (B[i] - '0');
	}
	for (int i = a; i < b; i++) {
		V[i] = (B[i] - '0');
	}
	rep(i, size - 1) {
		V[i + 1] += (V[i] / 10);
		V[i] %= 10;
	}
	reverse(V);
	int flag = false;
	string ret;
	rep(i, size) {
		if (V[i] == 0 && flag == false)continue;
		else {
			ret.push_back(num[V[i]]);
			flag = true;
		}
	}
	return ret;
}

int main() {
	string A, B;
	while (cin >> A >> B) {
		cout << bigsum(A, B).size() << endl;
	}
}


Measured memory_bytes: 3156
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        
        if((b - a) % 2 == 0) {
            System.out.println((b - a) / 2);
        } else {
            long side1 = a;
            long aCopy = 1;
            long bCopy = b - a;
            side1 += (bCopy - aCopy) / 2;

            long sideN = n - b + 1;
            aCopy = a + (n - b + 1);
            bCopy = n;
            sideN += (bCopy - aCopy) / 2;

            System.out.println(Math.min(side1, sideN));
        }        
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int main(){
	string s;
	cin>>s;
	int N = s.size();
	s = "0" + s;
	if(s[N] == '1'){
		puts("-1");
		return 0;
	}
	rep(i,N) if(s[i] != s[N-i]){
		puts("-1");
		return 0;
	}
	if(s[1] == '0'){
		puts("-1");
		return 0;
	}
	vector<int> v;
	rep1(i,N-1) if(s[i]=='1') v.pb(i);
	v.pb(N);
	int K = v.size();
	rep(i,K-1){
		for(int x=v[i];x<v[i+1];x++) cout<<x<<" "<<v[i+1]<<endl;
	}
}

Measured memory_bytes: 2036
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int s = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < k; i++) {
            sb.append(s + " ");
        }
        int a = s % 2 == 0 ? 999_999_999 : 2;
        for (int i = 0; i < n-k; i++) {
            sb.append(a + " ");
        }
        sb.deleteCharAt(sb.length()-1);
        System.out.println(sb.toString());
        sc.close();

    }

}


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

from bisect import bisect
from math import ceil


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

A, B = [], []
for _ in range(n):
    a, b = map(int, input().split())
    A.append(a); B.append(b)
A.sort(); B.sort()

a = A.pop()
i = bisect(B, a)
B = B[i:]

answer = 0
while B:
    b = B.pop()
    h -= b
    answer += 1
    if h <= 0:
        print(answer)
        exit()
answer += ceil(h / a)

print(answer)


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

const int DIM = 1e5 + 5;

int dp[DIM];

int main( void ) {
    
    string str;
    cin >> str;
    
    dp[0] = 1;
    for( int i = 0; i < str.length(); i ++ ) {
        if( dp[i] == 0 )
            continue;
        
        if( str.length() - i >= 5 && str.substr( i, 5 ) == "dream" )
            dp[i + 5] = 1;
        if( str.length() - i >= 5 && str.substr( i, 5 ) == "erase" )
            dp[i + 5] = 1;
        
        if( str.length() - i >= 7 && str.substr( i, 7 ) == "dreamer" )
            dp[i + 7] = 1;
        if( str.length() - i >= 6 && str.substr( i, 6 ) == "eraser" )
            dp[i + 6] = 1;
    }
    
    if( dp[str.length()] == 1 )
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N=3e2+5;
const ll inf=2e15;
const ll mod=1e9+7;
//题意:n*m地图 n,m<=100,起点S,终点T 'o'表示叶子,每次可以跳到同行或者同列的'o'上,问最少删掉多少个'o'使得S无法到达T? 
//最小割模型,先把图变为二分图,每行每列加上源点和汇点,两边点分别为1~n,1~m
//对叶子'o'(x,y):x-y连接一条边 表示第x行的叶子可以跳到第y列 容量为1:表示删除(x,y)这一个点 
//加上边 S->SX S-SY TX->T,TY->T 容量为inf 不能删除
//现在只要求出从S->T的最大流即可,因为最大流时的图,无增广路即,S->T不存在路径,对应的s-t割为最小割,容量最小. 

char s[N][N]; 
ll n,m,g[N][N];
ll path[N],flow[N],start,End;
queue<int> q;
void init()
{
	memset(g,0,sizeof(g));	
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(s[i][j]=='S')
			{
				g[0][i]=inf;
				g[0][n+j]=inf;	
			}
			if(s[i][j]=='T')
			{
				g[i][n+m+1]=inf;
				g[n+j][n+m+1]=inf;
			}
			if(s[i][j]=='o')
				g[i][n+j]=1,g[n+j][i]=1;
		}
	}
}

ll bfs()
{
	while(!q.empty())
		q.pop();
	memset(path,-1,sizeof(path));
	path[start]=0,flow[start]=inf;
	q.push(start);
	while(!q.empty())
	{
		int t=q.front();
		q.pop();
		if(t==End)
			break;
		for(int i=1;i<=n+m+1;i++)
		{
			if(i!=start && path[i]==-1 && g[t][i])
			{
				flow[i]=min(flow[t],g[t][i]);
				q.push(i);
				path[i]=t;
			}
		}
	}
	if(path[End]==-1)	
		return -1;
	return flow[End];
}
ll Edmonds_Karp()
{
	ll mx_flow=0,step,now,pre;
	while((step=bfs())!=-1)//找不到增广路退出 
	{
		mx_flow+=step;
		now=End;
		while(now!=start)
		{
			pre=path[now];
			g[pre][now]-=step;//更新正向边容量
			g[now][pre]+=step;//更新反向边(Gf走反向边 相当于在G中减小该边流量) 
			now=pre;
		}
	}
	return mx_flow;	
} 
int main()
{
	while(cin>>n>>m)
	{
		for(int i=1;i<=n;i++)
			scanf("%s",s[i]+1);
		init();//建图 
		start=0,End=n+m+1;
		ll ans=Edmonds_Karp();
		if(ans>=inf)
			puts("-1");
		else
			cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef pair<long long,long long> p;

int main(){
  int n,m;cin >> n >> m;
  vector<int> l(m),r(m);for(int i=0;i<m;++i)cin >> l[i] >> r[i];
  int L = *max_element(l.begin(),l.end());
  int R = *min_element(r.begin(),r.end());
  cout << max(R-L+1,0) << endl;
  return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n >> k;
  ans=min(n%k,k-n%k);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
#include <map>
#include <numeric>
#include <string>
using namespace std;
typedef long long int ll;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[4];
    for(int i=0;i<4;i++){
        cin >> a[i];
    }
    sort(a,a+4);
    cout << min(abs(a[0]+a[3]-a[2]-a[1]),abs(a[0]+a[2]-a[1]-a[3])) << endl;
}



Measured memory_bytes: 3236
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define T int
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
auto clk=clock();
 
ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}

double get(ll x){
    ll num = x;
    ll den = 0;
    while(x){
        den += x % 10;
        x /= 10;
    }
    return 1.0 * num / (1.0 * den);

}

int main(){
    IOS
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());


    ll k;
    cin >> k;
    ll cur = 10, d = 10;
    FOR(i,1,k){
        if(i <= 9){
            cout << i << endl;
        }
        else{
            cur += d;
            cout << cur - 1 << endl;
            if(get(cur + d - 1) > get(cur + 10 * d - 1)){
                d *= 10;
            }
        }
    }


    cerr<<endl<<endl<<"Time: "<<fixed<<setprecision(12)<<(long double)(clock()-clk)/CLOCKS_PER_SEC<<" ms"<<endl<<endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <iterator>
#include <queue>
#include <set>
#include <map>

using namespace std;

int N,K;
long long bino[4005][4005];
long long MOD = 998244353;

void init(){
    bino[0][0] = 1;
    for(int i=1;i<=4000;i++){
        bino[i][0] = 1;
        for(int j=1;j<=i;j++){
            bino[i][j] = (bino[i-1][j-1]+bino[i-1][j])%MOD;
        }
    }
}

int f(int x){
    return bino[x+K-1][x];
}

void solve(){
    init();

    cin >> K >> N;
    
    for(int i=2;i<=K+1;i++){
        int x = i/2;
        long long sum = 0;
        for(int j=0;j<=x;j++){
            if(N<j*2)break;
            if(j%2){
                sum -= bino[x][j]*f(N-j*2)%MOD;
                sum = (sum+MOD)%MOD;
            }else{
                sum += bino[x][j]*f(N-j*2)%MOD;
                sum %= MOD;
            }
        }
        cout << sum << '\n';
    }
    for(int i=K;i>=2;i--){
        int x = i/2;
        long long sum = 0;
        for(int j=0;j<=x;j++){
            if(N<j*2)break;
            if(j%2){
                sum -= bino[x][j]*f(N-j*2)%MOD;
                sum = (sum+MOD)%MOD;
            }else{
                sum += bino[x][j]*f(N-j*2)%MOD;
                sum %= MOD;
            }
        }
        cout << sum << '\n';
    }
}

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

    solve();
    return 0;
}



Measured memory_bytes: 123776
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();

		int max = 0;
		int tmp = 0;
		for (int i=0; i<S.length; i++){
			if (S[i] == 'A' || S[i] == 'G' || S[i] == 'C' || S[i] == 'T'){
				tmp += 1;
			}else {
				tmp = 0;
			}
			if (tmp > max){
				max = tmp;
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 22868
#define rep(i,n) for (int i=0;i<(n);i++)
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int main()
{
	int cnt = 0;
	string S;
	string c="CODEFESTIVAL2016";
	cin >> S;
	rep(i, 16)
		if (S[i] != c[i])
			cnt++;
	cout << cnt << endl;

}



Measured memory_bytes: 256
N, M = map(int, input().split())
hills = list(map(int, input().split()))
t_or_f = [True] * len(hills)

for _ in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    
    if hills[a] < hills[b]:
        t_or_f[a] = False
    elif hills[a] > hills[b]:
        t_or_f[b] = False
    else:
        t_or_f[a] = False
        t_or_f[b] = False

print(sum(t_or_f))

Measured memory_bytes: 20048
#include <iostream>

using namespace std;

long long solve(long long x)
{
	long long l = 0;
	long long u = x;
	while (l < u) {
		long long m = (l + u) / 2;
		long long s = (m / 2) * 5 + ((m + 1) / 2) * 6;
		if (s >= x) {
			u = m;
		}
		else {
			l = m + 1;
		}
	}
	return l;
}

int main()
{
	long long x;
	cin >> x;
	cout << solve(x) << endl;
}


Measured memory_bytes: 256
N, *A = map(int, open(0).read().split())

MOD = 10 ** 9 + 7
ans = 0
for bit in range(60):
    ctr = [0, 0]
    for i in range(N):
        ctr[A[i] >> bit & 1] += 1
    ans += (1 << bit) * (ctr[0] * ctr[1])
    ans %= MOD
    
print(ans)


Measured memory_bytes: 156044
#include <iostream>
using namespace std;
int main()
{
    int n, x, count;
    while (1)
    {
        count = 0;
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        for (int i = 1; i <= n-2; i++)
        {
            for (int j = i+1; j <= n-1; j++)
            {
                for (int k = j+1; k <= n; k++)
                {
                    if (i == j || i == k || j == k) continue;
                    if (i + j + k == x)
                    {
                        count++;
                    }
                }
            }
        }
        cout << count << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3080
n = int(input())
n_li = list(map(int, input().split()))

q = int(input())
q_li = list(map(int, input().split()))

ans = [0]*q
tmp_li = []

for i in range(2**n):
    check = [0]*n
    
    for j in range(n):
        if ((i >> j) & 1):
            check[n - 1 - j] = 1
    
    tmp = 0
    for a in range(n):
        if check[a] == 1:
            tmp += n_li[a]
    tmp_li.append(tmp)

for k in range(q):
    if q_li[k] in tmp_li:
        ans[k] = 1
        
for x in ans:
    if x == 1:
        print('yes')
    else:
        print('no')


Measured memory_bytes: 43084
#include <cstdio>
#include <iostream>
#include <string>
#include <cmath>

std::string a, b;
int n, m;
int main(){
	scanf("%d%d", &n, &m);
	a = std::to_string(n);
	b = std::to_string(m);
	
	a += b;
	int res = std::atoi(a.c_str());
	if((int)sqrt(res)*(int)sqrt(res) == res){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <climits>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<long long int>
#define vc vector<char>
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(i = (a); i < (n); i++)
#define fi(i,a,n) for(i = (a); i <= (n); i++)
#define F first
#define S second
int main() {
    ll n;
    cin>>n;
    ll s = 0;
    vector<string> v(n);

    for(ll i=0;i<n;i++){
        string p;
        cin>>p;
        sort(p.begin(),p.end());
        v[i] = p;
        //cout<<p<<endl;
    }



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



    ll t = 1;
    for(ll i=0;i<n-1;i++){

        if(v[i]==v[i+1]){
            t++;
        }
        else{
            s += (t*(t-1))/2;
            t = 1;
        }
    }


    s += (t*(t-1))/2;

    cout<<s<<endl;

}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define FOR(i, b, n) for (int i = b; i <= n; ++i)

using namespace std;
const int MOD = 2019;

void solve(long L, long R) {
  if (R / MOD != L / MOD)
    cout << 0 << endl;
  else {
    int ans = MOD;
    int l = L % MOD;
    int r = R % MOD;
    FOR(i, l, r) {
      FOR(j, i + 1, r) {
	ans = min(ans, i * j % MOD);
      }
    }
    cout << ans << endl;
  }
}

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

  long L, R;
  cin >> L >> R;

  solve(L, R);

  return 0;
}


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

int main(){
  long long n;
  cin >> n;
  long long count = 0;
  long long ma = 1e10;
  bool same = true;
  for (long long i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    if (a != b) same = false;
    count += a;
    if (a > b) {
      ma = min(ma, b);
    }
  }
  if (same) cout << 0 << endl;
  else cout << count - ma << endl;
  return 0;
}


Measured memory_bytes: 256
import queue
import sys
n, m = list(map(int, input().split()))
a, b = zip(*[list(map(int, input().split())) for i in range(m)])

next0 = [[] for i in range(n+1)]
for i in range(m):
    x = min(a[i], b[i])
    y = max(a[i], b[i])
    next0[x].append(y)
    next0[y].append(x)

#print(next0)
#sys.exit()

def search():
    d = [0] * (n+1)
    z = [-1] * (n+1)

    que = queue.Queue()
    que.put(1)

    while not que.empty():
        p = que.get()
        for nx in next0[p]:
            #print(nx)
            if 1 <= nx <= n and d[nx] == 0:
                que.put(nx)
                d[nx] = d[p] + 1
                z[nx] = p
    return d, z

z = search()[1]

if -1 in z[2:]:
    print('No')
else:
    print('Yes')
    for i in z[2:]:
        print(i)

Measured memory_bytes: 144548
import random
from collections import defaultdict
from itertools import accumulate
import sys
input = sys.stdin.readline
n = int(input())
s = input().rstrip()
mod = (1<<61)-1
base = 1000+random.randint(0,100)
power = [1]
for i in range(1,n):
  power.append((power[-1]*base)%mod)
hvalue = [0]
for i in range(n):
  hvalue.append((hvalue[-1]+(ord(s[i])*power[i]))%mod)
def rollinghash(l,r):
  return ((hvalue[r]-hvalue[l])*power[n-r])%mod
def pun(i):
  dc = defaultdict(int)
  if i>n//2:
    return False
  for j in range(n-i+1):
    x = rollinghash(j,i+j)
    if dc[x]:
      rg =dc[x]
      if rg<=j:
        return True
    else:
      dc[x] = i+j
  return False
l=0
r=n//2+1
while l+1<r:
  mi=(l+r)//2
  if pun(mi):
    l=mi
  else:
    r=mi
print(l)


Measured memory_bytes: 5044
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

template<typename ...Ts>
void show(Ts... ts){
  cout<<"#:";
  auto print=[](auto v){cout<<v<<" ";};
  initializer_list<int>{(void(print(ts)),0)...};
  cout<<endl;
}



int main(void){
    ll a;
    ll ans=0;
    string s;
    cin>>s;
    int n=s.size();
    vll N(n+1,0);
    vll A(n+1,0);
    vll AB(n+1,0);
    vll ABC(n+1,0);
    N[0]=1;

    REP(i,1,n+1){
        N[i]=N[i-1];
        A[i]=A[i-1];
        AB[i]=AB[i-1];
        ABC[i]=ABC[i-1];
        switch(s[i-1]){
            case '?':
                N[i]+=2*N[i-1];
                A[i]+=2*A[i-1]+N[i-1];
                AB[i]+=2*AB[i-1]+A[i-1];
                ABC[i]+=2*ABC[i-1]+AB[i-1];
                break;

            case 'A':
                A[i]+=N[i-1];
                break;            

            case 'B':
                AB[i]+=A[i-1];
                break;          
                
            case 'C':
                ABC[i]+=AB[i-1];
                break;            
        }
        N[i]%=mod;
        A[i]%=mod;
        AB[i]%=mod;
        ABC[i]%=mod;
    }
    ans=ABC[n];
    cout<<ans<<endl;
    //solve(t);
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>

using namespace std;
// using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<double,double> pd;
typedef priority_queue<int, vector<int>, greater<int>> min_heap;

// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const double PI = 4*atan(1);
const ll INF = 1e18;
const int MX = 100001;

int a, b, c, d;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> a >> b >> c >> d;
    while (true) {
        c -= b;
        if (c <= 0) {
            cout << "Yes\n";
            return 0;
        }
        a -= d;
        if (a <= 0) {
            cout << "No\n";
            return 0;
        }
    }
}

Measured memory_bytes: 3640
use std::io;

fn main() {
    let _n = read::<i32>();
    let mut a = read_vec::<i32>();

    let count = bubble_sort(&mut a);
    print_vec(a.to_vec());
    println!("{}", count);
}

/// バブルソート
/// 何回更新したかを返す
/// https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/2/ALDS1_2_A
pub fn bubble_sort<T: Ord + Copy + std::fmt::Display>(x: &mut [T]) -> usize {
    let mut flag = true;
    let mut count = 0;
    while flag {
        flag = false;
        for j in 1..x.len() {
            if x[j] < x[j - 1] {
                x.swap(j, j - 1);
                flag = true;
                count += 1;
            }
        }
    }
    count
}

fn print_vec<T: std::fmt::Display>(v: Vec<T>) {
    for a in &v[0..v.len() - 1] {
        print!("{} ", a);
    }
    println!("{}", v[v.len() - 1]);
}

/// 標準入力から一行を読み取り、指定の型に変換する関数
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

/// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut line = String::new();
    io::stdin().read_line(&mut line)
        .ok()
        .expect("Faild to read Vec");
    line.trim().split_whitespace()
        .map(|i| i.parse().ok().unwrap()).collect()
}


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

from collections import Counter

def main():
    n = int(input())
    numbers=[]
    answers=[]
    number=0
    numbers=[int(input()) for _ in range(n)]
    Numbers_col = Counter(numbers)

    for number in Numbers_col.values():
        if number%2!=0:
            answers.append(number)
    print(len(answers))

if __name__=="__main__":
    main()

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

const ll INF = LLONG_MAX;

struct CHT { //from stanic
	using Pair = pair<ll, ll>;
	vector<Pair> deq;              // first * x + second
	int s, t;

	CHT(){}

	void init(int n) { // n : クエリ数
		deq.resize(n);
		s=t=0;
	}

	void add(ll a, ll b) {      // a : 単調減少
		const Pair p(a, b);
		while (s+1<t && check(deq[t-2],deq[t-1],p)) t--;
		deq[t++] = p;
	}

	ll incl_query(ll x) {            // x : 単調増加
		while (s+1<t && f(deq[s], x) >= f(deq[s+1], x)) s++;
		return f(deq[s], x);
	}

private:
	bool isright(const Pair &p1, const Pair &p2, int x) {
		return (p1.second-p2.second) >= x * (p2.first-p1.first);
	}
	bool check(const Pair &p1, const Pair &p2, const Pair &p3) {
		return (p2.first-p1.first)*(p3.second-p2.second) >=
		(p2.second-p1.second)*(p3.first-p2.first);
	}
	ll f(const Pair &p, ll x) {
		return p.first * x + p.second;
	}
} T;

const int MN = 200010;

int N;
ll C;
ll dp[MN];
ll h[MN];

int main() {
	cin >> N >> C;
	rep(i, N) cin >> h[i];

	T.init(N);
	dp[0] = 0;

	for (int i = 1; i < N; ++i) {
		ll a = -h[i-1] * 2;
		ll b = dp[i-1] + h[i-1] * h[i-1];
		T.add(a, b);
		ll val = T.incl_query(h[i]);
		dp[i] = val + h[i] * h[i] + C;
	}

	cout << dp[N-1] << endl;

	return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long 
#define f(z) for(int i=1;i<=z;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<int>
#define pb push_back
#define si set<int>
int cl(int n ,int m) { if(n%m)return n/m + 1 ;else return n/m ;}
int pw(int a,int b){int r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
#define mod  1000000007
#define T() int TT; cin>>TT; while(TT--)
#define P pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 1e6 + 5 ;

signed main(){
	int n ;
	cin >> n ;
	
	for  (int i = 1; i<=n ; i++){
		for ( int j = i+1 ; j<=n ; j++){
			int x = i^j ; 
			int y = x & (x-1) ;
			int ans = log2(x^y) ;
			cout << ans+1 << " " ;
		}
		cout << endl ;
		
	}



}






Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
long long int gcd(long long int a , long long int b)
{
    while(a!=0 && b!=0)
    {
        if(a>b)
            a=a%b;
        else 
            b=b%a;
    }
    if(a==0)
        return b;
    else
        return a;
}
long long int lcm(long long int a , long long int b)
{
    return (a*b)/gcd(a,b);
}
int main()
{
    long long int A , B;
    cin>>A>>B;
    cout<<lcm(A,B);
    return 0;
}


Measured memory_bytes: 256
/*
    Author: Arham_doshi
    @quote "Code like there's no tommorow!"
     ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
    */
    #include <bits/stdc++.h>
     
    #define int         long long
    #define double      long double
    #define pb          push_back
    #define pf          push_front
    #define pii         pair<int,int>
    #define vi          vector<int>
    #define vii         vector<pii>
    #define mi          map<int,int>
    #define mii         map<pii,int>
    #define all(a)      (a).begin(),(a).end()
    #define rall(a)     (a).rbegin(),(a).rend()
    #define x           first
    #define y           second
    #define sz(x)       (int)x.size()
    #define endl        '\n'
    #define hell        998244353 
    #define PI          3.141592653589
    #define bs(v,n)     binary_search(all((v)),(n))
    #define lb(v,n)     lower_bound(all((v)),(n))
    #define ub(v,n)     upper_bound(all((v)),(n))
    #define fo(i,l,u)   for(i=l;i<u;i++)
    #define rfo(i,l,u)  for(i=l;i>=u;i--)
    #define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
    #define _init(b)     memset(b,-1,sizeof(b))
    #define _init0(b)     memset(b,0,sizeof(b))
     
    using namespace std;
     
    int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }  
    bool mod(double a,double b) {return a/b - floor(a/b);}
     
    int occurs(vi v,int n){
    auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}
     
    int logb(int base, int x) {
        return (log(x) / log(base));
    }
     
     
   
     
     
     
    signed main()
    {
        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
        int i,j,w,x,t,n,k,a,b;
        cin>>n>>w;
        int dp[n+1][w+1];
        vii v;
        fo(i,0,n){
            cin>>a>>b;
            v.pb({a,b});
        }
        sort(all(v));
        
        fo(i,0,w+1){
            dp[0][i]=0;
        }
        fo(i,0,n+1){
            dp[i][0]=0;
        }
        
        fo(i,1,n+1){
            a=v[i-1].x;
            b=v[i-1].y;
            fo(j,1,w+1){
                if(j-a>=0){
                    //cout<<1;
                    dp[i][j]=max({dp[i][j-1],(dp[i-1][j-a]+b),dp[i-1][j]});
                }
                else{
                   // cout<<0;
                    dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
                }
                //cout<<dp[i][j]<<" ";
            }
            //cout<<endl;
        }
        
        cout<<dp[n][w];
        
        
        
        return 0;
    }

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


class GFG
{

    public static void Main()
    {

        var inp = Console.ReadLine().Split(' ');

        var a = int.Parse(inp[0]);
        var b = int.Parse(inp[1]);

        Console.Write(a*b);

    }

}




















Measured memory_bytes: 27472
{
  const main = (input: string): void | string | number => {
    const r = _reader(input)
    const [N] = r.nn()
    const a = r.nn()

    let k = 1
    let t = 0

    for (let i = 0; i < N; i++) {
      if (a[i] !== k) {
        t++
      } else {
        k++
      }
    }

    return k === 1 ? -1 : t
  }

  const _reader = (str: string, i = 0) => {
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')
    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  const _getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const _res = main(_getInput())

  if (typeof _res === 'number' || typeof _res === 'string') console.log(_res)
}


Measured memory_bytes: 24272
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int A, B;
	scanf("%d %d", &A, &B);
	int l = 0, u = 10000;
	while (l != u) {
		int m = (l + u) / 2;
		if (m * 2 / 25 < A || m / 10 < B) l = m + 1;
		else u = m;
	}
	if (l * 2 / 25 != A || l / 10 != B) printf("-1");
	else printf("%d", l);
	return 0;
}

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

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

  string s; cin >> s;
  int cnt0 = 0,cnt1 = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '0') cnt0++;
    else cnt1++;
  }

  cout << min(cnt0,cnt1) * 2 << endl;

  return 0;
}


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

int main() {
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);

    long ans = 0;
    for (int i = 0; i < n; i++) {
        long amax = (lower_bound(a, a + n, b[i]) - a), cmin = (upper_bound(c, c + n, b[i]) - c);
        ans += amax  * (n - cmin);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;  //このネームスペースを使う

int main(){
  
  int a,b,c;
  int x;

  cin >> a ;
  cin >> b ;
  cin >> c ;
  
  x = b / a;

  if(x <= c){
  	cout << x ;
  }
  else{
  	cout << c ;
  }


  return 0;
}


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

int main()
{
  int n,W;
  
  cin>>n>>W;
  ll w[n],v[n];
  for(int i=0;i<n;i++)cin>>w[i]>>v[i];
  
  int V=100005;
  ll dp[V];
  ll inf=1e10;
  
  for(int i=0;i<V;i++)dp[i]=inf;
  
  dp[0]=0;
  
  for(int i=0;i<n;i++)
    for(int j=V-1;j>=0;j--){
      if(j>=v[i])
        dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
    }
  ll ans=0;
  for(int i=0;i<V;i++)
    if(dp[i]<=W)ans=i;
  
  
  cout<<ans<<endl;
  
  return 0;
}
  

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

///////////////////////////////////////////
const long long int INF = INT64_MAX;
//const long long int INF = 1000000;
const long long int Mod = 1000000007;
using ll = long long int;
using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
///////////////////////////////////////////////////////////////////////////////////
ll n;
vector<double> a(1000);

int main(){
    cin>>n;
    double sum =0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    sum /= n;
    int j=0;
    double temp=1000;
    rep(i,n){ if(chmin(temp,abs(sum-a[i]))){j=i;} };
    cout<<j<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int ans = getFibonach(n);
        System.out.println(ans);
    }

    private static int getFibonach(int idx) {
        int[] arr = new int[idx + 1];
        arr[0] = 1;
        arr[1] = 1;
        for (int i = 2; i <= idx; i++) {
            arr[i] = arr[i - 1] + arr[i - 2];
        }
        return arr[idx];
    }
}



Measured memory_bytes: 26392
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> Mat;
#define ALL(v) (v).begin(),(v).end()
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

ll mod_pow(ll a, ll n) {
	if (n == 0) return 1;
	if (n % 2 == 0) {
		ll tmp = mod_pow(a, n / 2);
		return (tmp * tmp) % MOD;
	}
	return (a * mod_pow(a, n - 1)) % MOD;
}

vector<ll> fact;
vector<ll> inv_fact;

void comb_init(int n) {
	fact.resize(n + 1);
	inv_fact.resize(n + 1);
	fact[0] = inv_fact[0] = 1;
	for (int i = 1; i <= n; i++) {
		fact[i] = (fact[i - 1] * i) % MOD;
		inv_fact[i] = (inv_fact[i - 1] * mod_pow(i, MOD - 2)) % MOD;
	}
}

ll comb(int n, int k) {
	if (n < k) return 0;
	ll ret = fact[n];
	(ret *= inv_fact[k]) %= MOD;
	(ret *= inv_fact[n - k]) %= MOD;
	return ret;
}

int main() {
	int N, A, B, C;
	cin >> N >> A >> B >> C;
	comb_init(2 * N);
	ll ans = 0;
	for (int M = N; M < 2 * N; M++) {
		ll p = 0;
		ll a = A * mod_pow(A+B, MOD - 2) % MOD;
		ll b = B * mod_pow(A+B, MOD - 2) % MOD;
		p = mod_pow(a, N);
		(p *= mod_pow(b, M - N)) %= MOD;
		ll t = mod_pow(b, N);
		(t *= mod_pow(a, M - N)) %= MOD;
		(p += t) %= MOD;
		(p *= comb(M - 1, N - 1)) %= MOD;
		(ans += p * M%MOD) %= MOD;
	}
	(ans *= 100) %= MOD;
	(ans *= mod_pow(100 - C, MOD - 2)) %= MOD;
	cout << ans << endl;
}


Measured memory_bytes: 3328
// inputに入力データ全体が入る
function Main(input) {
	ans = 0
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.trim().split("\n");
	// n = input[0].split(' ').map((n) => (parseInt(n)))
	input[0] = input[0].replace(/./g, 'x')



	//出力
	console.log(input[0])
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require('fs').readFileSync('./input.txt', 'utf-8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
int n, Q, a[N], last[N], p[N], ans[N], tree[N];
vector < pair < int, int > > q[N];
void upd(int x, int y) {
    if(!x) return;
    while(x <= 2 * n) {
        tree[x] += y;
        x += x & -x;
    }
} 
int cnt(int x) {
    int ans = 0;
    while(x) {
        ans += tree[x];
        x -= x & -x;
    }
    return ans;
}
int cnt(int l, int r) {
    return cnt(r) - cnt(l - 1);
}
int main() {
    scanf("%d%d", &n, &Q);
    for(int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
        a[i + n] = a[i];
    }
    for(int i = 1; i <= 2 * n; ++i) {
        p[i] = last[a[i]];
        last[a[i]] = i; 
    }
    for(int i = 1, l, r; i <= Q; ++i) {
        scanf("%d%d", &l, &r);
        q[r + n].push_back({l + n, i});
    }
    for(int r = 1; r <= 2 * n; ++r) {
        upd(p[r], 1);
        for(auto [l, index] : q[r]) {
            ans[index] = r - l + 1 - cnt(l, r);
        }
    }
    for(int i = 1; i <= Q; ++i) {
        printf("%d\n", ans[i]);
    }
}

Measured memory_bytes: 51728
# -*- coding: utf-8 -*-
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

k = int(input())

ans = 0
for a in range(1, k+1):
    for b in range(a, k+1):
        for c in range(b, k+1):
            if a==b and b==c:
                ans += gcd_list([a, b, c])
            elif a!=b and b!=c:
                ans += gcd_list([a, b, c]) * 6
            else:
                ans += gcd_list([a, b, c]) * 3
print(ans)


Measured memory_bytes: 69956
from math import gcd
from functools import reduce


def main():
    _ = int(input())
    a = list(map(int, input().split()))
    mod = 10 ** 9 + 7

    def lcm(x, y):
        return x * y // gcd(x, y)

    a_lcm = reduce(lcm, a)
    print(sum([a_lcm * pow(aa, mod - 2, mod) % mod for aa in a]) % mod)


if __name__ == '__main__':
    main()


Measured memory_bytes: 76016
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int w,a,b;cin>>w>>a>>b;
  if(a<=b&&b<=a+w||a<=b+w&&b+w<=a+w){
    cout(0);
    return 0;
  }
  int ans=abs(b+w-a);
  int tmp=abs(a+w-b);
  if(ans>tmp)ans=tmp;
  cout(ans);
  return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

/*
ll sub(ll a, ll b, ll k) {
  a %= k;
  b %= k;
  return (a - b + k) % k;
}
*/

ll mod(ll x, ll k) {
  return x > 0 ? x % k : x;
}

int main() {
  in(ll, n, k);
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  map<ll, ll> seen;
  queue<ll> que;
  auto add = [&](ll x) {
    seen[x]++;
    que.push(x);
    if (que.size() == k) {
      ll y = que.front();
      dbg(x, y);
      que.pop();
      seen[y]--;
    }
  };
  add(0);
  ll sum = 0;
  ll ans = 0;
  rep(i, n) {
    sum += a[i];
    ll adj = mod(sum - (i + 1), k);
    ans += seen[adj];
    add(adj);
  }
  out(ans);
}


Measured memory_bytes: 16000
#include <stdio.h>
int main(){
    int n,a,b,c,d,x,y;
    scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
    for(int i=1;;i++){
        if(n<=a*i){
            x=b*i;
            break;
        }
    }
    for(int j=1;;j++){
        if(n<=c*j){
            y=d*j;
            break;
        }
    }
    if(x<y){
        printf("%d\n",x);
    } else {
        printf("%d\n",y);
    }
}


Measured memory_bytes: 2732
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < (int)(n) ; i++)

bool dp[50][100010][2];
long long K;
int ans = 1e9;
void dfs(int pos,int md,int fst){
	if( pos >= 50 ) return;
	if( dp[pos][md][fst]) return; 
	dp[pos][md][fst] = true;
	if(fst==0 and md==0) ans = min(ans,pos);
	for(int i = fst ; i < 10 ; i++){
		dfs(pos+i,(md * 10 + i) %K,0);
	}
}
void solve(long long K){
	::K = K;
	memset(dp,0,sizeof(dp));
	dfs(0,0,1);
	cout << ans << endl;
}

int main(){	
	long long K;
	scanf("%lld",&K);
	solve(K);
	return 0;
}



Measured memory_bytes: 122496