akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
using namespace std;

int main() {
	int n, f[100][10], p[100][11], i, j, k, l, s[10], sum, max=-1000000000;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < 10; j++) {
			scanf("%d", &f[i][j]);
		}
	}
	for (i = 0; i < n; i++) {
		for (j = 0; j <= 10; j++) {
			scanf("%d", &p[i][j]);
		}
	}
	for (i = 1; i < 1024; i++) {
		k = i;
		for (j = 0; j < 10; j++) {
			s[j] = k - (k / 2) * 2;
			k = k / 2;
		}
		sum = 0;
		for (j = 0; j < n; j++) {
			l = 0;
			for (k = 0; k < 10; k++) {
				if (f[j][k] == 1 && s[k] == 1) {
					l++;
				}
			}
			sum += p[j][l];
		}
		if (max < sum) {
			max = sum;
		}
	}
	printf("%d", max);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll N;
	cin >> N;
	VLL A(N, 0);
	for (ll n = 0; n < N; n++ ) {
		cin >> A[n];
	}
	VLL calc(61,0);
	for (ll k = 0; k < 60; k++) {
		ll one = 0;
		ll zero = 0;
		for (ll n = 0; n < N; n++) {
			if ((A[n]>>k)&1)one++;
			else zero++;
		}
		calc[k] = zero * one;
		calc[k] %= MOD;
	}
	ll ans = 0;
	for (ll base = 1, k = 0; k < 60; k++, base *= 2) {
		base %= MOD;
		ans += base * calc[k];
		ans %= MOD;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<stack>
using namespace std;
#define ll long long
#define ull unsigned long long
#define up(i,a,b) for(register int i=(a);i<=(b);i++)
#define down(i,a,b) for(register int i=(a);i>=(b);i--)
#define mem(x,y) memset(x,(y),sizeof x)
#define ff first
#define ss second
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define sc(a) scanf("%d",&a)
#define scl(a) scanf("%lld",&a)
#define scs(a) scanf("%s",a)
#define pr(a,b) printf("%d%c",a,b)
#define prl(a,b) printf("%lld%c",a,b)
#define PQ priority_queue
#define ld long double
#define all(v) v.begin(),v.end()
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

typedef pair<ll,ll> pii;
typedef map<int,int> mii;
typedef vector<int> V;

template<typename T>
T gcd(T a,T b) {
	return !b?a:gcd(b,a%b);
}

inline int read() {
	int input=0,v=1;
	char c=getchar();
	while((c<'0'||c>'9')&&c!='-')c=getchar();
	if(c=='-')v=-1,c=getchar();
	while(c>='0'&&c<='9')input=input*10+c-'0',c=getchar();
	return v*input;
}

ll a[1010],b[1010],c[1010],gg[1000010],ans[3000010];
int cnt[4];
struct node {
	ll val;
	int x,y,z;
	node() {};
	node(ll a,int b,int c,int d):val(a),x(b),y(c),z(d) {};
	bool operator<(const node &a)const {
		if(a.val!=val)return val<a.val;
		if(a.x!=x)return x<a.x;
		if(a.y!=y)return y<a.y;
		return z<a.z;
	}
};
PQ<ll>pq;

int main() {
	int x,y,z,k;
	sc(x),sc(y),sc(z);
	sc(k);

	up(i,1,x)scl(a[i]);
	up(i,1,y)scl(b[i]);
	up(i,1,z)scl(c[i]);

	int cnt=0;
	up(i,1,x)up(o,1,y)gg[++cnt]=a[i]+b[o];
	sort(gg+1,gg+1+cnt,greater<ll>());
	int inf=min(k,cnt);
	cnt=0;
	up(i,1,inf)up(o,1,z)ans[++cnt]=gg[i]+c[o];
	sort(ans+1,ans+1+cnt,greater<ll>());
	up(i,1,k)prl(ans[i],'\n');
}

Measured memory_bytes: 31488
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;







int main() {
    ll n, y;
    cin >> n >> y;
    y /= 1000;
    ll yc = 0;
    
    for (ll i = 0; i < n+1; i++) {
        for(ll j = 0; j < n+1; j++) {
            if (i+j > n) continue;
            yc = 10*i+5*j+(n-(i+j));
            if (yc == y) {
                printf("%lld %lld %lld", i, j, n-(i+j));
                re0;
            }
        }
    }
    
    mes("-1 -1 -1");
    
    
}

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

int main() {
  
  int N; cin >> N; int sumA = 0; int sumB = 0;
  
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) cin >> vec.at(i);
  
  sort(vec.begin(), vec.end());
  
  reverse(vec.begin(), vec.end());
  
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) sumA += vec.at(i);
    else sumB += vec.at(i);
  }
  
  cout << sumA - sumB << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stdlib.h>
//#include<cmath>
//#include<algorithm>
#include<cstring>
//#include<map>
using namespace std;
inline int read()
{
    int p=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9'){p=p*10+c-'0';c=getchar();}
    return f*p;}
bool sq(int N)
{
    for(int i=1;N>0;i+=2)
        N-=i;
    if(N==0)return true;
    else return false;  
}
char a[106],b[106];
int main()
{
	cin>>a>>b;
	strcat(a,b);
	int N=atoi(a);
	bool f=sq(N);
	if(f)cout<<"Yes";
	else cout<<"No";
	return 0;
} 

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A + B >= C) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 384
N = int(input())
result = 0
for i in range(1, (N + 1)):
    if i % 15 == 0:
        'Fizz Buzz'
    elif i % 3 == 0:
        'Fizz'
    elif i % 5 == 0:
        'Buzz'
    else:
        result = result + i
print(result)

Measured memory_bytes: 9064
def main():
    X = int(input())

    for a in range(-200, 201):
        for b in range(-200, 201):
            if pow(a, 5) - pow(b, 5) == X:
                print(a, b)
                return


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


Measured memory_bytes: 9168
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define base 31
#define MOD 1e9+7
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORs(i, a, b) for(int i = a; i >= b; i--)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define __FOR(i, a, b, k) for(int i = a; i <= b; i+= k)
#define __REP(i, a, b, k) for(int i = a; i < b; i+= k)
#define pb push_back
#define _io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define Read_ freopen("input.inp", "r", stdin)
#define Write_ freopen("output.out", "w", stdout);
using namespace std;
typedef pair <int, int> ii;
typedef vector <ii> vii;
#define fi first
#define se second
#define mp make_pair
#define N  500
int n,a[N][N],sum=0;
int main(){
    _io; 
    cin>>n;
    int x=int(sqrt(n));
    if (x*x==n) --x;
    FOR(i,1,x){

        int y=n/i;
        if (y*i==n) --y;
        sum+=(y-i)*2+1;
    }
    cout<<sum;
}




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

using namespace std;

int main(){
  int n,a,b,c,i,j,k;
  string s;
  cin >> s;
  n = 700;
  for(i=0;i<3;i++){
    if(s[i]=='o')n+=100;
  }
  cout << n << endl;
  return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define vuni(v) v.erase(unique(v.begin(), v.end()), v.end());
#define mins(m, s) m.insert(make_pair(s, 1));
#define mfin(m, s) m.find(s) != m.end()

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9 + 7;

int main() {
    ll n, ans;
    ll a[200005];
    cin >> n;
    for(ll i = 0; i < n; i++) {
        cin >> a[i];
    }

    ans = 0;
    for(ll i = 0; i < n - 1; i++) {
        if(a[i + 1] < a[i]) {
            ans += a[i] - a[i + 1];
            a[i + 1] = a[i];
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int count = 0;
    for (int i = 0 ; i < 3; i++)
    {
        count += s[i] == t[i];
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace _8_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            var str = String.Concat(s, s);
            for(var i=0;i<str.Length-t.Length;i++)
            {
                if(str.Substring(i,t.Length) == t)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
        }
    }
}



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

const int C = 26;
const int D = 365;

int d;
int c[C];
int s[D][C];

vector<int> t;

void read() {
  scanf("%d", &d);
  for (int i = 0; i < C; ++i) scanf("%d", &c[i]);
  for (int i = 0; i < d; ++i) {
    for (int j = 0; j < C; ++j) {
      scanf("%d", &s[i][j]);
    }
  }
}

int score[D];
int lst[D];
int eval(vector<int> t) {
  int cur = 0;
  for (int i = 0; i < t.size(); ++i) {
    cur += s[i][t[i]];
    lst[t[i]] = i+1;
    for (int j = 0; j < C; ++j) {
      cur -= (i+1 - lst[j]) * c[j];
    }

    score[i] = cur;
  }

  return cur;
}

void solve() {
  for (int i = 0; i < d; ++i) {
    t.push_back(0);
    for (int j = 1; j < C; ++j) {
      vector<int> nt = t;
      t.back() = j;

      if (eval(nt) > eval(t)) {
        t = nt;
      }
    }
  }

  for (int i = 0; i < 1000; ++i) {
    vector<int> nt = t;
    t[rand() % d] = rand() % C;
    if (eval(nt) > eval(t)) t = nt;
  }
}

void print() {
  for (int i = 0; i < d; ++i) printf("%d\n", t[i] + 1);
}

void printScore() {
  eval(t);
  for (int i = 0; i < d; ++i) printf("%d\n", score[i]);
}

int main() {
  read();
  solve();
  print();
  // printScore();
  return 0;
}


Measured memory_bytes: 3932
#include<iostream>
#include<cstdio>
#define _USE_MATH_DEFINES
#include<math.h>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<map>
#include<unordered_map>
#include<set>
#include <algorithm>
#include <utility>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::pair;
using std::make_pair;
using std::priority_queue;

typedef unsigned long long ull;
typedef long long ll;

#define Prime1 1000000007
#define Prime2 9999973

#define INF 0x7fffffffffffffff

ull i, j, k, l, m, n;
ull H, W, Q;
ull a, b, c, x, y;
ull K,L,N,M;

int main()
{
	cin >> N;
	if (N == 1)
	{
		cout << "3\n";
		return 0;
	}
	string str;
	cin >> str;
	bool tate;
	ull count;

	i = 0;
	if(str[i]==str[i+1])
	{
		count = 6;
		i += 2;
		tate = false;
	}
	else
	{
		count = 3;
		i++;
		tate = true;
	}
	while (i < N)
	{
		if (i == N - 1 || str[i] != str[i + 1])
		{
			if (tate)count = (count * 2) % Prime1;
			i++;
			tate = true;
		}
		else
		{
			if (tate)count = (count * 2) % Prime1;
			else count = (count * 3) % Prime1;
			i += 2;
			tate = false;
		}
	}
	cout << count << '\n';

	return 0;
}


Measured memory_bytes: 256
from math import factorial
n,m = map(int,input().split())
if abs(n-m) >= 2:
  print(0)
elif abs(n-m) == 1:
  print(((factorial(n)%(10**9+7))*(factorial(m)%(10**9+7)))%(10**9+7))
else:
  print((2*(factorial(n) % (10**9+7))**2) %(10**9+7))

Measured memory_bytes: 46960
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int 
main(){
	int i;
	char s[4];
	int N,L,tmp;
	int *agi;int min = 1000;
	scanf("%d",&N);
	scanf("%d",&L);
	agi = (int*)malloc(sizeof(int)*N);
	int sum=0;
	for(i=1;i<=N;i++){
		agi[i-1]=L+i-1;
		if(min>abs(agi[i-1])){
			min=abs(agi[i-1]);
			tmp = i;
		}
		sum += agi[i-1];
	}
	printf("%d\n",sum-agi[tmp-1]);
	free(agi);
 return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define m_k make_pair
#define inf 0x3f3f3f3f
using namespace std;
char s[10];
int main()
{
	scanf("%s",s+1);
	if (s[3]==s[4] && s[5]==s[6]) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# import numpy as np
# from itertools import *
# from collections import *

# S = input().split()
N = int(input())
# K, N = [int(x) for x in input().split()]

li = []

for n in range(N):
    li.append(input())

print(len(set(li)))


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

int main(){
    string S; int w;
    cin >> S >> w;
    int N = S.length();
    for (int i = 0; i < N; i++) {
        if (i % w == 0) {
            cout << S[i];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = list(map(int,input().split()))
w = list()
for _ in range(n):
  w.append(int(input()))

w_sum = sum(w)



def f(p):
  v = 0
  for _ in range(k):
    s = 0
    while s + w[v] <= p:
#      print("add", w[v])
      s += w[v]
      v += 1
      if v == n:
        return v
  return v


def search(a, l, r, f):
  while r - l > 1 :
    m = (l + r) // 2
    v = f(m)
    if  v >= n:
      r = m 
    else:
      l = m
  return r

res = search(n, 0, 10000 * 100000, f)
print(res)




Measured memory_bytes: 9556
#include <iostream>
#include <iostream>
#include <iterator>
#include <vector>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef long double lld;
typedef pair<int,int> pi;
#define lli 			long long int
#define mod				(ll) 1000000007
#define pb 				push_back
#define f(i,s,n) 		for (int i=s;i<n;i++)
#define vii				vector<int>
#define seti      set<int>
#define mapi      map<int,int>
#define mapv      map<int,vii>
#define vll				vector<ll>
#define vpp				vector<pp>
#define vss				vector<string>
#define lcm(a,b)		(a*b)/__gcd(a,b)
#define all(a)			a.begin(),a.end()
#define abs(a) 			a>0?a:-1*a
#define all(a)			a.begin(),a.end()
#define fo(i,a)       for(auto &i:a)
#define bs(v,x)			binary_search(all(v),x)
#define sort(ans)    sort(ans.begin(),ans.end());
#define sortrev(ans) sort(a.begin(), a.end(), greater<int>());
#define vii2d       vector<vector<int>>
#define ms          multiset<int>
void solve()
{
  lli n,k,j;
  cin>>n>>k>>j;
  lli cop=n;
  lli ans=0;
  lli r=abs(n);
  lli step=r/j;
  lli w=0;
  //cout<<step<<endl;
  if (n>=0)
  {  n-=step*j;
    w=n-j;}
  else
  {  n+=step*j;
    w=n+j;}
  k-=step;
  if (k<=0)
  {
    k+=step;
    if (cop>=0)
      cop-=k*j;
    else
      cop+=k*j;
    ans=abs(cop);
    cout<<ans<<endl;
    return;
  }
  if (k%2==0)
  ans=n;
  else
  ans=w;
  ans=abs(ans);
  cout<<ans<<endl;
}
int main()
{
    int t=1;
    //cin>>t;
    int count=1;
    while(t--)
    {
      solve();
      count+=1;
    }
	return 0;
}


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

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> v(n+1,-1);
	int l=0;
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		if(v[l] < a){
			v[l+1]=a;
			l++;
		} else {
			for(int unsigned j=0;j<v.size();j++){
				if(a <= v[j]){
					v[j] = a;
					break;
				}
			}
		}
	}
	cout << l << endl;
	
	return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define req(i, j, n) for(int i = j; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
ll h;
  cin>>h;
  
  ll hh=h;
  ll ans=0;
  ll pen=0;
  ll nom=1;
  for(int i=1;i<=10000;i++){
  if(h%2==1 && h!=1){
    h/=2;
    ans+=nom;
    pen+=nom;
  nom*=2;
  continue;}
    if(h%2==0){
      h/=2;
      ans+=nom;
    nom*=2;
    continue;}
    if(h==1){
      ans+=nom;
    break;}

  }
    
    cout<<ans<<endl;

}

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

int main() {
	int x,a,b;
  	cin >> x >> a >> b;
  
  	int disa = abs(x - a);
  	int disb = abs(x - b);
  
  	if(disa < disb) {
    	cout << "A" << endl;
    }else {
    	cout << "B" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <unordered_map>
using namespace std;

using VI = vector <int> ;
using VVI = vector <VI> ;
const int MAXS = 200010;

char str[MAXS];

int main() {
    int N;
    int P;
    scanf("%d %d", &N, &P);
    scanf("%s", str);

    long long ans = 0;

    // sub(i, j) / 10^(j-1) = (sub(i, end) - sub(j-1, end)) / 10^(j-1)
    // sub(i, j) / 10^(j-1) % P == 0
    // sub(i, j)%P == 0 if 10 co-prime P ( P != 2 and P != 5)

    if (P == 2 || P == 5) {
        int pCnt = 0;

        for (int i = N-1; i >= 0; --i) {
            if ((str[i]-'0')%P == 0) {
                ++pCnt;
            }

            ans += pCnt;
        }
    } else {
        int mul = 1;
        int sum = 0;
        vector<int> rCount(P, 0);

        rCount[0] = 1;

        for (int i = N-1; i >= 0; --i) {
            sum = (sum + (str[i] - '0') * mul) % P;
            // (sum - x) % P == 0
            // sum % P = x
            ans += rCount[sum];

            ++rCount[sum];
            mul *= 10;
            mul %= P;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    const string G = "GREATER";
    const string L = "LESS";
    const string E = "EQUAL";
    
    string a,b;
    cin >> a >> b;
    string ans = E;
    if (a.size() == b.size()) {
        REP(i,a.size()) {
            if (a[i] > b[i]) {
                ans = G;
                break;
            } else if (a[i] < b[i]) {
                ans = L;
                break;
            }
        }
    } else if (a.size() > b.size()) {
        ans = G;
    } else {
        ans = L;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time,heapq
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    n = inp()
    print(math.ceil(n / 1000) * 1000 - n)
    
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)

def counter_elements(a):
    q = dict()
    for i in range(len(a)):
        if a[i] not in q:
            q[a[i]] = 0
        q[a[i]] = q[a[i]] + 1
    return(q)

def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)
 
def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))
 
def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

def transpose(a):
    b = [[0] * len(a) for i in range(len(a))]
    for i in range(len(a)): 
        for j in range(len(a)): 
            b[i][j] = a[j][i]
    return(b)

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
    
    
    
main()

Measured memory_bytes: 63424
#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-1; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
//vector<intなど> 変数名(要素数,初期値)
using namespace std;
typedef long long ll;
typedef long double ld;
const int MAX = 510000;
const int INF =2000000000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
//gcd,lcmセット
ll gcd(ll a, ll b){
   if (a%b == 0) return b;
   else return gcd(b, a%b);
}
ll lcm(ll a, ll b){	
   return a*b/gcd(a, b);
}
int pow_kai(int a, int n){//aのn乗を計算します。
  int x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a;
    }
    a = a*a;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}
// a^n mod を計算する
long long modPow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
// a^{-1} mod を計算する
ll modInv(ll a, ll mod) {
    return modPow(a, mod - 2, mod);
}

// combinationのテーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
 
bool isPrime(ll x){
    int i;
    if(x < 2)return false;
    else if(x == 2) return true;
    if(x%2 == 0) return false;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return false;
    return true;
}
//dfsではvector<vector<int>> g(n);で◎
int main(){
    //COMinit();
    string a,b;
    cin>>a>>b;
    ll m=stoll(a);
    ll n=stoll(b);
    //cout<<"a:"<<m<<",b:"<<n<<endl;
    if(m<n) REP(i,n) cout<<a;
    else REP(i,m) cout<<b;
//答え出力パート
    //cout<<
    cout<<endl;
}

Measured memory_bytes: 256
def read_list(t): return [t(x) for x in input().split()]
def read_line(t): return t(input())
def read_lines(t, N): return [t(input()) for _ in range(N)]

INF = 1<<27
V, E = read_list(int)
edge = [[] for _ in range(V)]
for _ in range(E):
    fr, to, cost = map(int, input().split())
    edge[fr].append((to, cost))

dp = [[INF] * V for _ in range(1<<V)]
dp[(1 << V) - 1][0] = 0
for state in reversed(range((1<<V)-1)):
    for v in range(V):
        for to, cost in edge[v]:
            if not (state >> to & 1):
                dp[state][v] = min(dp[state][v], dp[state | 1 << to][to] + cost)
print(dp[0][0] if dp[0][0] != INF else -1)

Measured memory_bytes: 21256
#include <iostream>

using namespace std;

int main() {
  int x{}, ans{};
  string X;
  cin >> X;
  for (char c : X) {
    if (c == 'T') ++x;
    else --x;
    ans = max(x, ans);
  }
  cout << 2 * ans << endl;
}


Measured memory_bytes: 3700
import java.util.Scanner;

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

        while(true){

            int H = sc.nextInt();
            int W = sc.nextInt();

            if(H == 0 && W == 0){
                break;
            }

            else{
                int i, j;

                for(i=1;i<=H;i++){
                    for(j=1;j<=W;j++){
                        if(i % 2 == j % 2){
                            System.out.print("#");
                        }
                        else{
                            System.out.print(".");
                        }
                    }
                    System.out.println();
                }
                System.out.println();
            }      
        }

        sc.close();

    }

}



Measured memory_bytes: 34844
n = int(input())
a = list(map(int,input().split()))
ans = 0

from collections import defaultdict
dd = defaultdict(int)
for key in a:
    dd[key] += 1
for key in dd.keys():
    #print(key,dd[key])
    if dd[key]>=key:
        ans += dd[key]-key
    else:
        ans += dd[key]
print(ans)

Measured memory_bytes: 21704
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
    int N,D;
    cin>>N>>D;
    vector<vector<double>> X(N,vector<double>(D));
    rep(i,N){
        rep(j,D){
            cin>>X[i][j];
        }
    }
    int cnt=0;
    
    rep(i,N){
        
       for(int j=i+1;j<N;j++){
           int sum=0;
           rep(k,D){
              int d=abs(X[i][k]-X[j][k]);
              sum+=d*d;
           }
           rep(l,sum+1){
               if(l*l==sum){
                   cnt++;
               }
           }
          
       }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3820
import java.util.*;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = n / 100;
		int b = (n % 100) / 10;
		int c = n % 10;
		if(a == 1) {
			a = 9;
		} else if(a == 9){
			a = 1;
		}
		if(b == 1) {
			b = 9;
		} else if(b == 9){
			b = 1;
		}
		if(c == 1) {
			c = 9;
		} else if(c == 9){
			c = 1;
		}
		
		System.out.println(a * 100 + b * 10 + c);
	}
}


Measured memory_bytes: 23636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

#define MAX 200001

int main()
{
  int n;
  int a[MAX], b[MAX];
  int ans = 0;

  cin >> 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 < 29; i++){
    int amod[MAX], bmod[MAX];
    int c = 0;

    for(int j = 0; j < n; j++){
      amod[j] = a[j] % (2<<i);
      bmod[j] = b[j] % (2<<i);
    }

    sort(amod, amod + n);
    sort(bmod, bmod + n);

    for(int j = 0; j < n; j++){
      c += lower_bound(bmod, bmod+n, 2*(1<<i) - amod[j]) - 
            lower_bound(bmod, bmod+n, (1<<i) - amod[j]);
      c += lower_bound(bmod, bmod+n, 4*(1<<i) - amod[j]) - 
            lower_bound(bmod, bmod+n, 3*(1<<i) - amod[j]);
    }

    if(c % 2){
      ans |= (1<<i);
    }
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<stack>
#include<vector>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define pb push_back

typedef long long ll;

const int N = 20010;
int array[N],tmp[N];

void div(int n,int *a,int k){
  int now=1;
  rep(i,k+1){
    a[i]=now/n;
    now=(now%n)*10;
  }
}

void add(int k){
  int carry=0;
  for(int i=k;i>=0;i--){
    array[i]=(array[i]+carry+tmp[i]);
    carry=array[i]/10;
    array[i]%=10;
  }
}

void output(int *a,int k){
  rep(i,k+1){
    cout << a[i];
    if (i==0)cout <<".";
  }
  cout << endl;
}

void solve(int n,int m,int k){
  div(n,array,k+6);
  if (m == 1){
    REP(i,1,n){
      div(i*n,tmp,k+6);
      //output(tmp,k+6);
      add(k+6);
    }
  }
  output(array,k);
}

main(){
  int n,k,m,r;
  while(cin>> n >> k >> m >> r && n){
    solve(n,m,r);
  }
}

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}

struct Vector2D {
  int x, y;
  Vector2D() {}
  Vector2D(int x, int y) : x(x), y(y) {}

  bool operator<(Vector2D v) const { return tie(x, y) < tie(v.x, v.y); }
  bool operator==(Vector2D v) const { return tie(x, y) == tie(v.x, v.y); }
  bool operator>(Vector2D v) const { return tie(x, y) > tie(v.x, v.y); }
  bool operator<=(Vector2D v) const { return tie(x, y) <= tie(v.x, v.y); }
  bool operator>=(Vector2D v) const { return tie(x, y) >= tie(v.x, v.y); }

  Vector2D normalize() {
    if (x == 0) {
      return Vector2D(0, 1);
    }
    if (y == 0) {
      return Vector2D(1, 0);
    }
    int g = __gcd(x, y);
    Vector2D norm(x / g, y / g);
    if (norm.y < 0) norm.x = -norm.x, norm.y = -norm.y;
    return norm;
  }
  Vector2D normalized_orthogonal() {
    if (x == 0) {
      return Vector2D(1, 0);
    }
    if (y == 0) {
      return Vector2D(0, 1);
    }
    int g = gcd(x, y);
    Vector2D ort = Vector2D(-y / g, x / g);
    if (ort.y < 0) ort.x = -ort.x, ort.y = -ort.y;
    return ort;
  }
};

void solution() {
  map<Vector2D, int> m;
  int n;
  cin >> n;
  int pot2[n + 1];
  pot2[0] = 1;
  for (int i = 1; i <= n; i++) pot2[i] = mod(pot2[i - 1] * 2LL, M);
  int lixo = 0;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) {
      lixo++;
      continue;
    }
    Vector2D vec(a, b);
    vec = vec.normalize();
    m[vec]++;
  }
  set<Vector2D> vis;
  int ans = 1LL;
  for (auto p : m) {
    auto vec = p.ff;
    int cnt = p.ss;
    if (vis.count(vec.normalized_orthogonal())) continue;
    vis.insert(vec);
    ans = mod(
        ans * mod(pot2[cnt] + pot2[m[vec.normalized_orthogonal()]] - 1LL, M),
        M);
  }
  ans = mod(ans + lixo - 1LL, M);
  cout << ans << endl;
}

int32_t main() {
  DESYNC;
  solution();
}


Measured memory_bytes: 42552
import math

A,B,H,M=map(int,input().split())
res = float(0)
deg_A = math.pi * (H+M/60) /6
deg_B = math.pi * M/30 
deg_X = abs(deg_A-deg_B)
if deg_X > math.pi:
  deg_X = 2 * math.pi - deg_X
c = 2 * A*B*math.cos(deg_X)
d = A*A + B*B - c
res = d**0.5
print(res)

Measured memory_bytes: 9508
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int l, r;

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

  cin >> l >> r;
  int ans = INF;
  FOR(i, l, min(l + 2019, r + 1)) {
    FOR(j, i + 1, min(l + 2019, r + 1)) {
      ans = min(ans, ((i % 2019) * (j % 2019)) % 2019);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)

int main() {
	int E;
	while(cin>>E&& E>0){
		int j,k,m;
		m = 100000000;
		for(j = 0; j*j<=E;j++){
			for(k=0;k*k*k<=E;k++){
				int i = E - j*j - k*k*k;
				int sum = i+j+k;
				if(m>sum && i >=0){
					m = sum;
				}
			}
		}
		cout<<m<<endl;
	}
	return 0;
}



Measured memory_bytes: 3076
N, M = map(int, input().split())

cnt = [None] + [0] * M
for _ in range(N):
  line = list(map(int, input().split()))
  for a in line[1:]:
    cnt[a] += 1

answer = 0
for c in cnt[1:]:
  if c == N:
    answer += 1
print(answer)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
const int mod=1e6+3;
typedef long long ll;
map<int,int>mp,mmp;
#define inf 0x3f3f3f3f
#define mem(a,b) memset(a,b,sizeof(a))
#define pi acos(-1.0)
void read(int &x)
{
	int f=1;x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=f;
}
ll gcd(ll a,ll b)
{
	return b==0?a:gcd(b,a%b);
}
ll a,b,c,d,sc,sd,so,num,cnt,mu;
int main()
{
   scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
   mu=gcd(c,d);mu=c*d/mu;
   sc=(a/c)*c,sd=(a/d)*d,so=(a/mu)*mu;
  // printf("%lld %lld %lld\n",sc,sd,so);
   num=(b-sc)/c+(b-sd)/d+2;
   if(sc<a)num--;if(sd<a)num--;
  // printf("num=%lld\n",num);
   cnt=(b-so)/mu+1;
   if(so<a)cnt--;
   num-=cnt;
   ll len=b-a+1;
   len-=num;
   printf("%lld\n",len);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        int aa = Integer.parseInt(a);
        int bb = Integer.parseInt(b);
        int count;
        String ss;
        String ans = "";
        if(a.compareTo(b) >0) {
            count = aa;
            ss = b;
        } else {
            count = bb;
            ss = a;
        }
        for(int i=0; i<count; i++) {
            ans += ss;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 39420
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,m,x;
  cin>>n>>m>>x;
  vector<int> a(m);
  int above=0;
  int under=0;
  rep(i,m){
    cin>>a[i];
    if(a[i]<x){
      under++;
    }else{
      above++;
    }
  }
  cout<<min(above,under)<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>


using namespace std;


int main() {
	
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c == 17) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;

	}
		
	
}



Measured memory_bytes: 256
n, h = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]
A.sort(key=lambda x:x[1])
A.sort(reverse=1, key=lambda x:x[0])

#print(A)

B = []
furu = A[0][0]
nage = A[0][1]
for i in range(1,n) :
    if A[i][1] > furu :
        B.append(A[i][1])
B.sort(reverse=1)

#print(B)

ans = 1
h -= nage


i = 0
while h > 0 and i <= len(B)-1 :
    h -= B[i]
    ans += 1
    i += 1

#print(furu)

if h > 0 :
    d = h//furu
    h -= d * furu
    ans += d
if h > 0 :
    h -= furu
    ans += 1
if h + nage <= 0 :
    ans -= 1

print(ans)


Measured memory_bytes: 28904
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=100000+10;
ll x[maxn],d[maxn],c[maxn];
int ans[maxn],now[maxn],o[maxn],sta[maxn];
int i,j,l,t,n,m,top;
ll k;
void mult(int *a,int *b,int *c){
    int i;
    fo(i,1,n) o[i]=a[b[i]];
    fo(i,1,n) c[i]=o[i];
}
int main(){
    scanf("%d",&n);
    fo(i,1,n){
        scanf("%lld",&x[i]);
        d[i]=x[i]-x[i-1];
        ans[i]=now[i]=i;
    }
    scanf("%d%lld",&m,&k);
    fo(i,1,m){
        scanf("%d",&t);
        swap(now[t],now[t+1]);
    }
    top=0;
    while (k){
        sta[++top]=k%2;
        k/=2;
    }
    while (top){
        mult(ans,ans,ans);
        if (sta[top--]) mult(ans,now,ans);
    }
    fo(i,1,n) c[i]=d[ans[i]];
    fo(i,1,n) x[i]=x[i-1]+c[i];
    fo(i,1,n) printf("%lld.0\n",x[i]);
}

Measured memory_bytes: 4864
import sys
from math import gcd
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N,M = MI()
A = LI()

x = sum(a % 2 == 0 for a in A)
if x != N:  # 奇数が含まれたら駄目
    print(0)
    exit()

r = 0
while A[0] % 2 == 0:
    r += 1
    A[0] //= 2
for i in range(1,N):
    if A[i] % (2**r) != 0 or (A[i]//(2**r)) % 2 == 0:  # 2で割り切れる回数が異なるものがあったら駄目
        print(0)
        exit()
    else:
        A[i] //= 2**r

lcm = A[0]
for i in range(1,N):
    lcm = (lcm*A[i])//gcd(lcm,A[i])

a = (lcm*2**r)//2

# a の奇数倍で、M 以下である整数の個数が答え

print(((M//a)+1)//2)


Measured memory_bytes: 85980
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int m=1e9+7;
ll mod(ll x)
{
    return ((x%m+m)%m);
}
ll add(ll a,ll b)
{
    return mod(mod(a)+mod(b));
}
ll mul(ll a,ll b)
{
    return mod(mod(a)*mod(b));
}
int main()
{
    ll n;
    cin>>n;
    vector<ll>a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    vector<ll>b(n+1);
    for(int i=n-1;i>=0;i--)
    {
        b[i]=b[i+1]+a[i];
    }
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        ans=add(ans,mul(a[i],b[i+1]));
    }
    cout<<ans;
}


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

#整数値入力 1文字の入力
def input_one_number():
    return int(input())

#整数値龍力　複数の入力
def input_multiple_number():
    return map(int, input().split())

#整数値龍力　複数の入力(配列)
def input_multiple_number_as_list():
    return list(map(int, input().split()))

#2次元配列入力
def input_map():
    return [list(map(int,list(input()))) for i in range(h)]

#リスト出力
def print_list(list):
    print(*list)
    return

#2次元配列出力
def print_map(maplist):
    for i in maplist:print(*i, sep='')
    return

#素数生成
def generate_primenums():
    n = 100
    primes = set(range(2, n+1))
    for i in range(2, int(n**0.5+1)):
        primes.difference_update(range(i*2, n+1, i))
    primes=list(primes)
    return primes

def memo():
    a=[0]*5
    b=a  #良くない配列のコピー
    b2=a[:]  #1次元のときはコピーはこれで良い
    a[1]=3
    print('b:{}, b2:{}'.format(b,b2))  #b:[0, 3, 0, 0, 0], b2:[0, 0, 0, 0, 0]
    
    import copy
    a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
    b=copy.deepcopy(a)  #2次元配列はこうコピーする
    
    #内包表記奇数のみ
    odd=[i for i in range(100) if i%2==1] #[1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
    
    #二部探索
    import bisect
    a = [1, 2, 3, 5, 6, 7, 8, 9]
    b=bisect.bisect_left(a, 8)
    
    #combinations、組み合わせ、順列
    from itertools import permutations, combinations,combinations_with_replacement,product
    a=['a','b','C']
    print(list(permutations(a)))
    print(list(combinations(a,2)))
    print(list(combinations_with_replacement(a,3)))


#階乗
def kaijo(n):
    import math
    return math.factorial(n)

#選び方（コンビネーション nCr）
def num_combination(n,r):
    import math
    return math.factorial(n) // math.factorial(n - r)


#最大公約数、最小公倍数
def calc_gcd_lcm(a,b):
    import fractions
    GCD=fractions.gcd(a,b)
    lcm=a*b//gcd
    return gcd,lcm

#複数の最大公約数
def calc_gcd_list(l):
    import numpy as np
    return np.gcd.reduce(l)

N = input_one_number()
lst_A = input_multiple_number_as_list()

min = 1000000000

for i in range(N):
    cnt = 0
    a = lst_A[i]
    while a % 2 == 0:
        cnt +=1
        a //= 2
    if min > cnt:
        min = cnt
print(min)


Measured memory_bytes: 3192
n,a,b,c=map(int,input().split())
s_=[input() for i in range(n)]
ans=""
for i in range(n):
    s1,s2=s_[i]
    if s2=="B":
        if a==1 and b==1 and i!=n-1:
            if s_[i+1][0]=="A":
                a,b,ans=(a+1,b-1,ans+"A")
            else:
                a,b,ans=(a-1,b+1,ans+"B")
            continue
        a,b,ans=(a-1,b+1,ans+"B") if a>b else (a+1,b-1,ans+"A")
        if min(a,b)==-1:
            print("No")
            break
    elif s1=="A":
        if a==1 and c==1 and i!=n-1:
            if s_[i+1][1]=="C":
                a,c,ans=(a-1,c+1,ans+"C")
            else:
                a,c,ans=(a+1,c-1,ans+"A")
            continue
        a,c,ans=(a-1,c+1,ans+"C") if a>c else (a+1,c-1,ans+"A")
        if min(a,c)==-1:
            print("No")
            break
    else:
        if c==1 and b==1 and i!=n-1:
            if s_[i+1][1]=="C":
                b,c,ans=(b-1,c+1,ans+"C")
            else:
                b,c,ans=(b+1,c-1,ans+"B")
            continue
        b,c,ans=(b-1,c+1,ans+"C") if b>c else (b+1,c-1,ans+"B")
        if min(b,c)==-1:
            print("No")
            break
else:
    print("Yes")
    for j in range(n):
        print(ans[j])



Measured memory_bytes: 135036
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )
#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

#include <complex>
typedef complex<double> Point;
const double EPS = 1e-8;

// 入力ストリームから実数二つをとって Point へ
istream& operator >> ( istream &s, Point &a )
{
	double r, i;
	s >> r >> i;
	a = Point( r, i );
	return s;
}

// 外積（クロス積）
double cross( const Point &a, const Point &b )
{
	return a.real() * b.imag() - a.imag() * b.real();
}

// CCW 関数　a -> b -> c と進むとき、反時計回りなら -1, 直進なら 0, 時計回りなら 1
int ccw( const Point &a, const Point &b, const Point &c )
{
	if ( cross( ( b - a ), ( c - a ) ) < -EPS )
	{
		return -1;
	}
	else if ( EPS < cross( ( b - a ), ( c - a ) ) )
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

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

	for ( Point a, b, c, p; cin >> a >> b >> c >> p; )
	{
		vector<Point> ps { a, b, c, a };
		int sum = 0;
		REP( i, 0, 3 )
		{
			sum += ccw( ps[i], ps[ i + 1 ], p );
		}
		cout << ( abs( sum ) == 3 ? "YES" : "NO" ) << endl;
	}

	return 0;
}

Measured memory_bytes: 1224
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        StringBuilder sb = new StringBuilder();
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int[] array = new int[num];
        
        for(int i = num - 1; i >= 0; i--){
            array[i] = sc.nextInt();
        }
        
        sb.append(array[0]);
        
        for(int i = 1; i < num; i++){
            sb.append(" " + array[i]);
        }
        System.out.println(sb);
    }
}


Measured memory_bytes: 26272
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD 998244353
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
int main(){
    ll n;
    cin >> n;
    cout << n+(n*n)+(n*n*n) << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
	double num;
	while(cin>>num,num>0){
	    string str;
		for(double i=pow(2,7);i>pow(2,-5);i/=2){
			str+=int(num/i)+'0';
			if(num/i>=1)num-=i;
			if(i==1)str+='.';
		}
		if(num/pow(2,-5)>0)cout<<"NA"<<endl;
		else cout<<str<<endl;
	}
}

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

template <typename T>
void print(const T &v);

int main()
{
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    double hour_s = H * 30 + M * 0.5;
    double minute_s = M * 6;
    double s = min(abs(hour_s - minute_s), 360 - abs(hour_s - minute_s));

    double ax, ay, az, aw, deg_r, pi, unit, unit_r, x, y, z;
    pi = 2.0 * asin(1.0); /* πの値 */
    unit = pi / 180.0;    /* 度 → ラジアン */
    unit_r = 180.0 / pi;  /* ラジアン → 度 */

    deg_r = s * unit;
    double kaku = cos(deg_r);

    double ans = (A * A) + (B * B) - (2 * A * B * kaku);
    ans = sqrt(ans);
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 4256