akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
	string X;
	cin >> X;
	int N = X.size();
	int t = 0;
	int s = 0;
	vector<char> v;
	FOR(i,0,N){
		if(!v.size()){
			v.pb(X[i]);
			continue;
		}
		if(v[v.size()-1] == 'S'){
			if(X[i] == 'T')v.pop_back();
			else v.pb('S');
		}
		else{
			v.pb(X[i]);
		}
	}
	cout << v.size() << endl;
}

Measured memory_bytes: 788
#include<stdio.h>
int main(void)
{
  int r,D,x;
  int i;
  
  scanf("%d%d%d",&r,&D,&x);
  
  int array[10]={x};
  if((2<=r && r<=5) && (1<=D && D <=100) && (D<x && x<=200)){ 
  	for(i=0;i<10;i++){
      array[i+1]=r*array[i]-D;
      printf("%d ",array[i+1]);
  	}
  }
  return 0;
}

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

bool IsPrime(int n) {
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            return false;
        }
    }
  return true;  /* ダミー: 全て素数と判定 */
}

int main(void){
   int count = 0;
   int n;
   cin >> n; /* n個整数を読む */
   for(int i = 0; i < n; i++) {
       int p;
       cin >> p;
       if(IsPrime(p)) {
          count++;/* ここは自分で埋める */
       }
   }
   cout << count << endl;
   return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

  string s;
  cin >> s;
  string k = "keyence";
  int score = 0;
  REP(i, 7)
  {
    if(s[i]==k[i]){
      score++;
    }else{
      break;
    }
  }
  REP(i, 7)
  {
    if(s[s.length()-i-1]==k[k.length()-i-1]){
      score++;
    }else{
      break;
    }
  }
  if(score>=7){
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
}


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


int main(){
    long n,w;
  cin>>n>>w;
  long e[n],v[n],mx=0;
  for (long i=0;i<n;i++){
     cin>>e[i]>>v[i];
     mx+=v[i];
  }
  long dp[mx+1];
  for (long i=0;i<=mx;i++)
   dp[i]=1000000000;
 // memset(dp,INT_MAX,sizeof(dp));
  dp[0]=0;
  for (long i=0;i<n;i++)
     for (long j=mx-v[i];j>=0;j--)
        dp[j+v[i]]=min(dp[j+v[i]],dp[j]+e[i]);
  long res=0;
  for (long i=0;i<=mx;i++)
      if (dp[i]<=w)
        res=max(res,i);
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  cin >> a;
  int p = 0;
  for(int i = 0; i < (a.size()-1)/2;i++){
    if(a.at(i) != a.at(a.size()-i-1) || a.at(i) != a.at((a.size()-1)/2-i-1) ){
      p = 1;}}
    if(p == 1){cout << "No" << endl;}
    else{cout << "Yes" << endl;}
    
}

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

int main()
{
  string s,t;
  cin>>s>>t;
  int ans,x,y;
  x=s.size();
  y=t.size();
  ans=1008;
  for(int i=0;i<=x-y;i++)
  {
    int a=0;
    for(int j=0;j<y;j++)
    {
      if(s.at(i+j)!=t.at(j))
        a++;
    }
    ans=min(ans,a);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
char s[100000];
int flag;
int main()
{
    cin>>s;
    for(char a='a';a<='z';a++)
    {
        flag=0;
        for(int i=0;i<strlen(s);i++)
        {
            if(s[i]==a)
            {
                flag=1;
            }
        }
        if(flag==0)
        {
            printf("%c\n",a);
            return 0;
        }
    }
    printf("None\n");
    return 0;
}

Measured memory_bytes: 384
import itertools
L = input()
s = ['+','-']
t = ['+','-']
u = ['+','-']
for a, b, c in itertools.product(s, t, u):
   f = L[0] + a + L[1] + b + L[2] + c + L[3] 
   if eval(f) == 7:
       print(f+'=7')
       exit(0)

Measured memory_bytes: 3060
import std.stdio;
import std.string;
import std.algorithm;
import std.functional;
import std.conv;

enum long INF = long.max/5;

void main() {
  while(solve()){}
}

bool solve() {
  int n = readln.chomp.to!int;
  if (n == 0) return false;

  long[] as = new long[n];
  foreach(i; 0..n) {
    as[i] = readln.chomp.to!long;
  }

  kadane!(
    long, max, -INF, "a+b", 0
  )(as).writeln;

  return true;
}

T kadane(
  T,              // 型
  alias plusFun,  // 加法の２項演算
  T plusIdentity, // 加法の単位元
  alias multFun,  // 乗法の２項演算
  T multIdentity  // 乗法の単位元
)(T[] as) {
  alias _plusFun = binaryFun!plusFun;
  alias _multFun = binaryFun!multFun;
  T res = plusIdentity;
  T s = multIdentity;
  foreach(a; as) {
    s = _plusFun(_multFun(s, a), a);
    res = _plusFun(res, s);
  }
  return res;
}



Measured memory_bytes: 2460
#!python3

iim = lambda: map(int, input().rstrip().split())

from heapq import heappush, heappop

def calc(N, A, B, C, D):
    abc = [(2, A), (3, B), (5, C),]
    ans = N * D
    ans2 = min(2*D, D+A)

    dq = []

    heappush(dq, (0, N))
    seen = set()
    while dq:
        cost, rest = heappop(dq)

        if rest in seen:
            continue
        else:
            seen.add(rest)

        if rest <= 2:
            if rest == 1:
                cost += D
            elif rest == 2:
                cost += ans2
            else:
                cost += -rest * D
            ans = min(ans, cost)
            continue

        if cost >= ans:
            continue

        for r, co1 in abc:
            a1, a2 = divmod(rest, r)

            if a2 == 0:
                heappush(dq, (cost+co1, a1))
                continue

            a3 = r - a2
            if a2 == a3:
                heappush(dq, (cost + co1 + a3*D, a1+1))
            elif a2 > a3:
                a1 += 1
                a2 = a3

            cd = a2 * D
            if (rest - a1) * D < co1 + cd:
                ans = min(ans, rest*D + cost)
            else:
                co2 = cost + co1
                heappush(dq, (co2 + cd, a1))

    return ans


def resolve():
    T = int(input())
    S = [list(iim()) for i in range(T)]


    ans = []
    for s in S:
        ans.append(calc(*s))

    print(*ans, sep="\n")

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 10280
//long long -> ll
//http://web.mit.edu/~ecprice/acm/acm08/notebook.html#file12
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include<bits/stdc++.h>
typedef long long ll;
#define w first
#define v second
#define REP(i,sss,eee) for(long long i=sss;i<=eee;++i)
#define pb push_back
#define pii pair<long long,long long>
#define vi vector<long long>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define inf 1000000000000000
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}
#define mx 100010
/*****************default********************/
std::vector<pii> inp;
std::vector<std::vector<ll>> dp;
int main(){
	long long n,maxw;cin>>n>>maxw;
	inp.resize(n);
	dp.resize(n,std::vector<long long>(mx,inf));
	REP(i,0,n-1)
	{
		cin>>inp[i].w>>inp[i].v;
	}
	REP(i,0,n-1){dp[i][0]=0;dp[0][inp[0].v]=inp[0].w;}
	for(long long val=1;val<(mx-5);++val)
	{
		for(long long ix=1;ix<n;++ix)
		{
			if(val>=(inp[ix].v))
			{
				dp[ix][val]=MIN(dp[ix-1][val],(dp[ix-1][(val-(inp[ix].v))]+inp[ix].w));
			}
			else
			{
				dp[ix][val]=dp[ix-1][val];
			}
		}
	}
	for(long long val=100000;val>=0;--val)
	{
		REP(i,0,n-1){if(dp[i][val]<=maxw){cout<<val<<"\n";return 0;}}
	}
}

Measured memory_bytes: 79488
def main():
    inf = 1000000000
    n,m = map(int,input().split())
    d = [[inf]*n for _ in range(n)]
    for _ in range(m):
        a,b,c = map(int,input().split())
        d[a][b] = c
    dp = [[inf]*n for _ in range(1<<n)]
    dp[0][0] = 0
    for bits in range(1<<n):
        for i in range(n):
            if bits&(1<<i):continue
            for j in range(n):
                dp[(1<<i)|bits][i] = min(dp[(1<<i)|bits][i],dp[bits][j]+d[i][j])
    if dp[(1<<n)-1][0]==inf:print (-1)
    else                   :print (dp[(1<<n)-1][0])


if __name__ == '__main__':
    main()




Measured memory_bytes: 19800
#include <iostream>
#include <cstdio>
#define ABS(n) (((n)>0)?(n):(-(n)))
using namespace std;
int main()
{
  int n,h,m,l,s,d;
  cin >> n;
  while(n--){
    scanf("%d:%d",&h,&m);
    s = m * 12;
    l = 60 * h + m;
    d = ABS(l-s);
    if(d > 360) d = 720 - d;
    if(d < 60) cout << "alert" << endl;
    else if(180 <= d && d <= 360) cout << "safe" << endl;
    else cout << "warning" << endl;
  }
  return 0;
}

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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"
#define int ll

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

  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  sort(rng(A));
  reverse(rng(A));
  ll ans=0;
  map<int,int>m;
  for(auto it:A)m[it]++;
  for(int i=0;i<N;i++){
    int k=1;while(k<=A[i])k*=2;
    m[A[i]]--;
    if(m[k-A[i]]>0&&m[A[i]]>=0){
      m[k-A[i]]--;
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 26880
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#define ll long long
using namespace std;

int main()
{
    ll n, ans = 0;
    cin >> n;
    vector<ll> a(n);
    map<ll, ll> mp;
    ll left = 0, right = 0;
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (ll i = 0; i < n;i++){
        mp[a[i]]++;
    }
    for(auto p:mp){
        ll x = p.first;
        ll n = p.second;
        if(n<x){
            ans += n;
        }
        else{
            ans += n - x;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 7040
#include <iostream>
#include <map>
using namespace std;
long long n,m,a[100005],c[100005];
map<long long,long long> mp;
int main()
{
 cin>>n>>m;
 for(int i=1;i<=n;i++)
  cin>>a[i];
 for(int i=1;i<=n;i++)
 {
  c[i]=c[i-1]+a[i];
  c[i]%=m;
  mp[c[i]]++;
 }
 long long ans=mp[0];
 if(mp[0]>1)ans+=mp[0]*(mp[0]-1)/2;
 mp[0]=0;
 for(int i=1;i<=n;i++)
  if(mp[c[i]])
   ans+=mp[c[i]]*(mp[c[i]]-1)/2,mp[c[i]]=0; 
 cout<<ans;
 return 0;
}

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

#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, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

int main(){
  ll X, K, D;
  cin >> X >> K >> D;
  X = abs(X);
  if(X / D > K){
    cout << X - K*D << endl;
    return 0;
  }
  if(D > X){
    if(K % 2){
      cout << D - X << endl;
    }
    else{
      cout << X << endl;
    }
    return 0;
  }
  K -= X / D;
  X = X % D;
  if(K % 2){
    cout << D - X << endl;
  }
  else{
    cout << X << endl;
  }
  return 0;
}


Measured memory_bytes: 3556
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
double A, B, H, M;

int main() {
  cin >> A >> B >> H >> M;
  double pi = 3.141592653589793;
  double arg = abs((11 * M - 60 * H) * pi / 360);
  double arg2 = min(arg, 2 * pi - arg);
  double c = sqrt(A * A + B * B - 2 * A * B * cos(arg2));
  cout << std::fixed << std::setprecision(12) << c << endl;
  return 0;
}

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

using namespace std;

int main()
{
	int n; scanf("%d", &n);

	vector<int> a(n);

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

	vector<vector<long long> > dp(n, vector<long long>(n, 0)); // [i, j]

	for (int i = 0; i < n; i++)
	{
		dp[0][i] = a[i];
	}

	for (int i = 1; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (i % 2)
			{
				if (a[j] > a[(j + i + 1) % n])
				{
					dp[i][j] = dp[i - 1][(j + 1) % n];
				}

				if (a[(j + i) % n] > a[(j + n - 1) % n])
				{
					dp[i][j] = max(dp[i][j], dp[i - 1][j]);
				}
			}
			else
			{
				dp[i][j] = max(dp[i - 1][j] + a[(j + i) % n], dp[i - 1][(j + 1) % n] + a[j]);
			}
		}
	}

	long long ret = 0;

	for (int i = 0; i < n; i++)
	{
		ret = max(ret, dp[n - (2 - n % 2)][i]);
	}

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

	return 0;
}

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

int main() {
	string t;
	cin >> t;
	rep(i, t.size()) {
		if (t[i] == '?') cout << 'D';
		else cout << t[i];
	}
	cout << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    // dp1[k]: 上からk桁目まで確定させ，その時点でA+BがL以下だとわかっているもの
    // dp2[k]: 上からk桁目まで確定させ，その時点でA+BがL以下だとわかっていないもの
    string L; cin >> L;
    ll N = L.size();
    ll dp1[N + 1], dp2[N + 1];
    dp1[0] = 0; dp2[0] = 1;
    rep(i, L.size()){
        if (L[i] == '1'){
            dp2[i + 1] = 2 * dp2[i]; // (0, 1) or (1, 0)
            dp1[i + 1] = 3 * dp1[i] + dp2[i]; // (0, 0) の場合だけdp2から遷移してくる, 確定している場合は繰り上がりを出さなければ何でも良い
        } else {
            dp2[i + 1] = dp2[i]; // (0, 0)しか選択肢が無い，(繰り上がりはNGなので未確定のものは増えない)
            dp1[i + 1] = 3 * dp1[i];
        }
        dp1[i + 1] %= MOD; dp2[i + 1] %= MOD;
    }
    // rep(i, N + 1){cout << dp1[i] << " ";} cout << endl;
    // rep(i, N + 1){cout << dp2[i] << " ";} cout << endl;

    cout << (dp1[N] + dp2[N]) % MOD << endl;
}


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 2000
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n, k, c = map(int, input().split())
S = [1 if a == "o" else 0 for a in input()]
count = 0
X = [0] * n
Y = [0] * n
i = 0
while i < n:
    if S[i]:
        count += 1
        X[i] = 1
        i += c + 1
    else:
        i += 1
if count > k:
    exit()
i = n - 1
while i >= 0:
    if S[i]:
        Y[i] = 1
        i -= c + 1
    else:
        i -= 1
for i in range(0, n):
    if X[i] and Y[i]:
        print(i + 1)

Measured memory_bytes: 9380
import java.util.*;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int ans[] = new int [n];
		for(int i=0;i<n-1;i++) {
			int now = scan.nextInt();
			ans[now-1] += 1; 
		}
		for(int i=0;i<n;i++) {
			System.out.println(ans[i]);
		}
		
		
		
	}	
	
	
	//最小公約数
	/*
	static int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	*/
	
}


Measured memory_bytes: 60352
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  int cnt=0;
  cin>>s;
  for(int i=0;i<15;i++){
    if(s[i]=='x'){
      cnt++;
    }

  }
  if(cnt>=8){
    cout<<"NO";
  }else{
    cout<<"YES";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main () {
    int N, R, ans;
    cin >> N >> R;
    if (N < 10) {
      ans = R + 100 * (10 - N);
    } else {
      ans = R;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	string s,t ;
	cin >> s >> t ;
	vvll dp(s.size()+1,vll(t.size()+1,0)) ;
	for(int i=1;i<=s.size();i++){
		for(int j=1;j<=t.size();j++){
			if(s.at(i-1)==t.at(j-1)){
				dp.at(i).at(j) = dp.at(i-1).at(j-1)+1 ;
			}else{
				dp.at(i).at(j) = max(dp.at(i-1).at(j),dp.at(i).at(j-1)) ;
			}
		}
	}
	ll cnt = dp.at(s.size()).at(t.size()) ;
	string ans = "" ;
	int posi=s.size(),posj=t.size() ;
	ll sub = posi ;
	while(cnt>0){
//		cout << posi << " " << posj << endl ;
		if(dp.at(posi).at(posj)==cnt&&dp.at(posi-1).at(posj)!=cnt&&dp.at(posi).at(posj-1)!=cnt){
			ans += s.at(posi-1) ;
			cnt-- ;
			posi-- ;
			posj-- ;
			sub = posi ;
		}else{
			posi-- ;
			if(posi==0){
				posj-- ;
				posi = sub ;
			}
		}
	}
	reverse(all(ans)) ;
	/*for(int i=1;i<=s.size();i++){
		for(int j=1;j<=t.size();j++){
			cout << dp.at(i).at(j) << (j==t.size()?'\n':' ') ;
		}
	}*/
	cout << ans << endl ;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, H;
    cin >> N >> H;

    int free = -1;
    vector<int> once(N);
    for (int i = 0; i < N; i++) {
        int t;
        cin >> t >> once[i];
        free = max(free, t);
    }
    sort(once.begin(), once.end(), less<int>());
    once.erase(once.begin(), upper_bound(once.begin(), once.end(), free));
    reverse(once.begin(), once.end());

    int total = 0;
    for (size_t i = 0; i < once.size(); i++) {
        H -= once[i];
        total++;
        if (H <= 0) { break; }
    }
    if (H > 0) {
        total += (H + (free - 1)) / free;
    }
    cout << total << endl;

    return 0;
}


Measured memory_bytes: 640
a = [input().split() for m in range(2)]
z=a[1]
b=[int(s) for s in z]
c=int(a[0][0])
cnt=0
while True:
    for i in range(c):

        if b[i]!=0:

            for j in range(i,c):

                if b[j]==0:
                    break

                b[j]-=1
                j+=1

            cnt+=1
            break

    if sum(b)==0:
        break
    
print(cnt)



    
    





Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; string S; cin >> N >> S;

    int sumw = count(ALL(S), '.');
    int ans = sumw, b = 0, w = 0;
    REP(i, 0, N) {
        if (S[i] == '.') w++;
        else b++;

        ans = min(ans, b + sumw - w);
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> Pair;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

string S;

int main() {
    cin >> S;
    REP(i, 1 << 3) {
        string ans = {S[0]};
        ll tmp = stoll(S.substr(0, 1)), now = 1;
        REP(j, 3) {
            if(i & 1 << j) {
                string s = S.substr(now, (j + 1) - now + 1);
                tmp += stoll(s);
                now = j + 2;
                ans += "+" + s;
            } else {
                string s = S.substr(now, (j + 1) - now + 1);
                tmp -= stoll(s);
                now = j + 2;
                ans += "-" + s;
            }
        }
        ans += S.substr(now, 4 - now) + "=7";
        if(tmp == 7) {
            cout << ans << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define PI 3.1415926535897932384626433832795028
#define INF (1<<29)
#define LINF (1LL<<60)
using namespace std;
using INT = long long;
using P = pair<int,int> ;

int main(){
    string s,ab,ar;
    ab = "ABC";
    ar = "ARC";
    cin >> s;
    if(s==ab){
        cout << ar <<endl;
    }
    else cout << ab << endl;
	return 0;
}



Measured memory_bytes: 3592
K, N = map(int, input().split())
A = input().split()
AA = []
for a in A:
    AA.append(int(a))
MAX = K - AA[-1] + AA[0]
for i in range(len(AA) - 1):
    if AA[i+1] - AA[i] > MAX:
        MAX = AA[i+1] - AA[i]
print (K - MAX)

Measured memory_bytes: 26000
//ITP_1_2_C
#include<iostream>
using namespace std;

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

Measured memory_bytes: 1168
#include <bits/stdc++.h> 
#define ll long long
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define mp make_pair
#define PII pair<ll,ll>
#define PLL pair<long long,long long>
#define pq priority_queue
#define M map
#define UM unordered_map
#define graph unordered_map<ll,vector<ll>>
#define graphw unordered_map<ll,vector<pair<ll,ll>>>
#define V vector
#define mod 1000000007
#define inf 3000000000000000007ll
#define P pair
#define Fast ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) signed(a.size())
#define FIXED cout << fixed << setprecision(12)
#define L list
#define D deque
#define ld long double
using namespace std;
// pair operation
template<class T, class U>istream& operator>>(istream& in, pair<T,U> &rhs){in >> rhs.first;in >> rhs.second;return in;}
template<class T, class U>ostream& operator<<(ostream& out,const pair<T,U> &rhs){out << rhs.first;out << " ";out << rhs.second;return out;}
template<class T, class U>pair<T,U> operator+(pair<T,U> &a, pair<T,U> &b){return pair<T,U>(a.first+b.first,a.second+b.second);}
template<class T, class U>pair<T,U> operator-(pair<T,U> &a, pair<T,U> &b){return pair<T,U>(a.first-b.first,a.second-b.second);}
// Linear STL
// VECTOR
template<class T>istream& operator>>(istream& in, vector<T> &a){for(auto &i: a)cin >> i;return in;}
template<class T>ostream& operator<<(ostream& out, const vector<T> &a){for(auto &i: a)cout << i << " ";return out;}
// SET
template<class T>ostream& operator<<(ostream& out, const set<T> &a){for(auto &i: a)cout << i << " ";return out;}
template<class T>ostream& operator<<(ostream& out, const unordered_set<T> &a){for(auto &i: a)cout << i << " ";return out;}
template<class T>ostream& operator<<(ostream& out, const multiset<T> &a){for(auto &i: a)cout << i << " ";return out;}
// MAP
template<class T,class U>ostream& operator<<(ostream& out, const map<T,U> &a){for(auto &i: a)cout << "(" << i.first << ", " << i.second << "(\n";return out;}
template<class T,class U>ostream& operator<<(ostream& out, const unordered_map<T,U> &a){for(auto &i: a)cout << "(" << i.first << ", " << i.second << "(\n";return out;}

int main() {
    Fast;
    ll t=1;
    // cin>>t;
    while(t--){
        ll x,y,r,g,c;
        cin>>x>>y>>r>>g>>c;
        ll val=x+y;
        pq<ll> p[2];
        for(ll i=0;i<r;i++){
            ll a;
            cin>>a;
            p[0].push(a);
        }
        for(ll i=0;i<g;i++){
            ll a;
            cin>>a;
            p[1].push(a);
        }
        pq<ll> ret;
        while(x--){
            ret.push(p[0].top());
            p[0].pop();
        }
        while(y--){
            ret.push(p[1].top());
            p[1].pop();
        }
        for(ll i=0;i<c;i++){
            ll a;
            cin>>a;
            ret.push(a);
        }
        ll ans=0;
        while(val--){
            ans=ans+ret.top();
            ret.pop();
        }
        cout<<ans;
    }
}


Measured memory_bytes: 8048
#include <stdio.h>
#define mod 1000000009
#define e 32769

char s[1010][1010];
char data1[1010][1010];
int tttthassh[1010][1010];

int main(){
	int n,m,a,b;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)scanf(" %s",s[i]);
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf(" %s",data1[i]);
	long po=1;
	for(int j=0;j<b;j++)po=po*e%mod;
	long pop=1;
	for(int i=0;i<a;i++)pop=pop*po%mod;
	for(int j=0;j<m;j++){
		long hhhhhhash=0;
		for(int i=0;i<a;i++)hhhhhhash=(hhhhhhash*po+s[i][j])%mod;
		for(int i=a;i<=n;i++){
			tttthassh[i-a][j]=hhhhhhash;
			hhhhhhash=((hhhhhhash*po+s[i][j]-s[i-a][j]*pop)%mod+mod)%mod;
		}
	}
	long thash=0;
	for(int i=0;i<a;i++)for(int j=0;j<b;j++)thash=(thash*e+data1[i][j])%mod;

	for(int i=0;i<=n-a;i++){
		long hhhhhhash=0;
		for(int j=0;j<b;j++)hhhhhhash=(hhhhhhash*e+tttthassh[i][j])%mod;
		for(int j=b;j<=m;j++){
			if(thash==hhhhhhash)printf("%d %d\n",i,j-b);
			hhhhhhash=((hhhhhhash*e+tttthassh[i][j]-tttthassh[i][j-b]*po)%mod+mod)%mod;
		}
	}
	return 0;
}



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

namespace mondai0015
{
	class Program
	{
		static void Main(string[] args)
		{
			var	n	= int.Parse( Console.ReadLine() );
			for( int i = 0; i < n; i++ ) {
				var	num1	= Console.ReadLine();
				var	num2	= Console.ReadLine();
				var	sum		= Add( num1, num2 );
				if( (num1.Length > 80) || (num2.Length > 80) || (sum.Length > 80) ) {
					Console.WriteLine( "overflow" );
				} else {
					Console.WriteLine( sum );
				}
			}		
		}


		// 文字列数値の加算（正の整数のみ）
		static string Add( string s1, string s2 )
		{
			int	s1_len	= s1.Length;
			int	s2_len	= s2.Length;
			int	len;
			if( s1_len > s2_len ) {
				len	= s1_len;
			} else {
				len	= s2_len;
			}
			
			string	ans		= "";
			int		carry	= 0;
			for( int i = 0; i < len; i++ ) {
				int	s1_val;
				if( i < s1_len ) {
					s1_val	= int.Parse( s1.Substring( s1_len - i - 1, 1 ) );
				} else {
					s1_val	= 0;
				}
				int	s2_val;
				if( i < s2_len ) {
					s2_val	= int.Parse( s2.Substring( s2_len - i - 1, 1 ) );
				} else {
					s2_val	= 0;
				}
				int	val	= s1_val + s2_val + carry;
				carry	= val / 10;
				ans	= (val % 10) + ans;
			}
			if( carry == 1 ) {
				ans	= "1" + ans;
			}
			return( ans );
		}
	}
}

Measured memory_bytes: 5864
# -*- codinf: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))
ans = 1

for a in A:
  if a == 0:
    print(0)
    exit()

for a in A:
  ans *= a
  if ans > 10**18:
    print(-1)
    exit()
print(ans)

Measured memory_bytes: 88220
n = int(input())
list1 = list(map(int,input().split()))
"""
for i in range(2):
	for i in range(n-1):
		if list1[i] < 0 and list1[i+1] < 0:
			list1[i] = abs(list1[i])
			list1[i+1] = abs(list1[i+1])
		elif (list1[i] < 0 and (abs(list1[i]) > abs(list1[i+1]))) or \
		(list1[i+1] < 0 and (abs(list1[i+1]) > abs(list1[i]))):
			list1[i] = list1[i]*-1
			list1[i+1] = list1[i+1]*-1


"""
count = 0
for i in range(n):
	if list1[i] < 0:
		count += 1
		list1[i] = abs(list1[i])
if count%2 == 0:
	print(sum(list1))
else:
	list1.sort()
	print(sum(list1)-list1[0]*2)

Measured memory_bytes: 64880
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int func(string s){
    return __stoi( s.substr(1,s.size()-1)   );
}


void BubbleSort(string c[],int N){
    for(int i=0;i<N;++i){
        for(int j=N-1;j>i;--j){
            if( func(c[j-1]) > func(c[j]) ){
                swap(c[j-1],c[j]);
            }
        }
    }
}

void SelectionSort(string c[],int N){
    for(int i=0;i<N;++i){
        int minj = i;
        for(int j=i+1;j<N;++j){
          if(  func(c[minj]) > func(c[j]) ){  
            minj = j;
          }
        }
        swap(c[i],c[minj]);
    }
}


int main(){
  int N; cin>>N;
  string c[N];
  string d[N];
  REP(i,N){
    cin >> c[i];
    d[i] = c[i];
  }
  BubbleSort(c,N);
  SelectionSort(d,N);
  
  REP(i,N){
    if(i<N-1){ cout << c[i] << " ";}
    else{ cout << c[i] <<"\n"; }
  }
  cout << "Stable\n";
  bool ok = true;
  REP(i,N){
    if(ok && c[i]!=d[i]){ ok = false; }
    if(i<N-1){ cout << d[i] <<" ";}
    else{ cout << d[i] <<"\n"; }
  }
  cout << (ok?"Stable":"Not stable") <<"\n";
}


Measured memory_bytes: 3144
import heapq
import numpy as np
from numba import njit,i8,b1

h,w = map(int,input().split())
sh,sw = map(int,input().split())
gh,gw = map(int,input().split())
s = np.array([list(input()) for _ in range(h)]) == "#"

@njit(i8(i8,i8,i8,i8,i8,i8,b1[:,:]))
def solve(h,w,sh,sw,gh,gw,s):

    sh-=1; sw-=1; gh-=1; gw-=1;

    INF = 10**7
    dist = [[INF]*w for _ in range(h)]
    dist[sh][sw] = 0
    q = [(0,sh,sw)]
    while q:

        d,vsh,vsw = heapq.heappop(q)

        for dh in range(-2,3):
            for dw in range(-2,3):
                newh = vsh+dh
                neww = vsw+dw
                if newh<0 or h<=newh or neww<0 or w<=neww: continue
                if dh == 0 and dw==0: continue
                if s[newh][neww] : continue


                if abs(dh)+abs(dw)==1:
                    if dist[newh][neww] > d:
                        dist[newh][neww] = d
                        if newh == gh and neww == gw:
                            return d
                        heapq.heappush(q,(d,newh,neww))
                else:
                    if dist[newh][neww] > d+1:
                        dist[newh][neww] = d+1
                        heapq.heappush(q,(d+1,newh,neww))
    if dist[gh][gw] == INF:
        return -1
    else: return dist[gh][gw]
        
print(solve(h,w,sh,sw,gh,gw,s))

Measured memory_bytes: 124456
#include <bits/stdc++.h>
#define endl '\n'
#define LL long long
#define LD long double
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define debug(x) cerr << #x << " is " << x << endl;
using namespace std;
int const MAXN = 2e6 + 9;
int main(){
    ios_base::sync_with_stdio (0),cin.tie(0);
    int m, k;
    cin >> m >> k;
    if ( k == 0){
          for (int i = 0; i < (1 << m); i++)
                    cout << i << ' ' << i << ' ';
        return 0;
    }
    bool cond = false;
    int s = 0;
    for (int i = 0; i < (1 << m); i++){
        if( i == k ) continue;
        s ^= i;
    }
    cond = ( s == k );
    if (!cond){
        cout << -1;
        return 0;
    }
    deque<int> dq;
    dq.push_back(k);
    for(int i = 0; i < (1 << m); i++){
        if (i == k) continue;
        dq.push_back(i);
        dq.push_front(i);
    }
    dq.push_front(k);
    for(auto cur : dq) cout << cur << ' ';
}

Measured memory_bytes: 2944
# -*- coding: utf-8 -*-
from sys import stdin
from collections import Counter

s_in = lambda: stdin.readline()[:-1] # s = s_in()
d_in = lambda: int(stdin.readline()) # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()

n = d_in()
v_arr = ds_in()

e_arr = []
o_arr = []
for i in range(n//2):
    e_arr.append(v_arr[2*i])
    o_arr.append(v_arr[2*i+1])

e_c = Counter(e_arr)
o_c = Counter(o_arr)

if len(e_c) == 1:
    e_m = e_c.most_common(n=1)
    if len(o_c) == 1:
        o_m = o_c.most_common(n=1)
        if e_m[0] == o_m[0]:
            print(n // 2)
        else:
            print(0)
    else:
        o_m = o_c.most_common(n=2)
        if e_m[0] == o_m[0]:
            print(n//2 - o_m[1][1])
        else:
            print(n//2 - o_m[0][1])
else:
    e_m = e_c.most_common(n=2)
    if len(o_c) == 1:
        o_m = o_c.most_common(n=1)
        if e_m[0] == o_m[0]:
            print(n//2 - e_m[1][1])
        else:
            print(n//2 - e_m[0][1])
    else:
        o_m = o_c.most_common(n=2)
        if e_m[0] != o_m[0]:
            print(n - e_m[0][1] - o_m[0][1])
        else:
            print(n - e_m[0][1] - max(e_m[1][1], o_m[1][1]))


Measured memory_bytes: 19096
N = int(input())
arr = sorted(list(map(int,input().split())))
b = {}
for i in arr:
  if i not in b:
      b[i] = 1
  else:
      b[i] += 1
h = 0
w = 0
b1 = sorted(b)[::-1]
for i in b1:
    if b[i] >= 4:
        if h < i:
            h = i
            w = i
            break
        else:
            w = i
            break
    elif b[i] >= 2:
        if h == 0:
            h = i
        else:
            w = i
            break
        
print(h*w)


Measured memory_bytes: 17932
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

struct Shop{
	string name;
	int point, num;
	
	bool operator<(const Shop &another) const{
		return name == another.name ? point > another.point : name < another.name;
	}
	
};

int main() {

	int N;
	
	cin >> N;
	
	Shop shop[N];
	
	for(int i = 0; i < N; i++){
		shop[i].num = i + 1;
		cin >> shop[i].name >> shop[i].point;
	}
	
	sort(shop, shop + N);

	for(auto itr : shop){
		cout << itr.num << endl;
	}

	return 0;
}

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

using namespace std;
typedef long long ll;

ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}

ll lcm(ll x, ll y) {
  return x * y / gcd(x, y);
}

int f(ll x) {
  int cnt = 0;
  while (x % 2 == 0) {
    cnt++;
    x /= 2;
  }
  return cnt;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i] /= 2LL;
  }

  int t = f(a[0]);
  a[0] >>= t;
  for (int i = 1; i < n; ++i) {
    if (f(a[i]) != t) {
      puts("0");
      return 0;
    }
    a[i] >>= t;
  }
  m >>= t;
  ll l = 1;
  for (int i = 0; i < n; ++i) l = lcm(l, a[i]);
  if (l > m) {
    puts("0");
    return 0;
  }

  m /= l;
  ll ans = (m + 1) / 2;
  cout << ans << endl;
  return 0;
}


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

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

    int maxA = 0;
    for (int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        data[tmp]++;
        maxA = (maxA < tmp) ? tmp : maxA;
    }
    int maxCnt = 0;
    for (int i = 1; i < 99999; i++)
    {
        int sum = data[i-1]+data[i]+data[i+1];
        maxCnt = (maxCnt < sum) ? sum : maxCnt;
    }

    cout << maxCnt;
    
    
}

Measured memory_bytes: 4004
#include <iostream>
using namespace std;
/* にゃーん  */


int main(){
    int n,y,t = 0,min=1145141919;
    int na[100]={0};
    cin >> n >> y;
    for(int i = 0; i < n; i++){
        cin >> na[i];
        if(min> na[i]){
            min = na[i];
        }
        t += na[i];
    }
    cout << n + (y-t)/min << endl;
    return 0;
}


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

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define pi 3.14159265358979323846

using namespace std;

int main(){
	int tmp;
	for( int i = 0; i < 5; i++ ){
		cin >> tmp;
		if( tmp == 0 )	cout << i + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 3552
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>  // assert(x>=10), 部分点問題
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <set>

#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
#define SORT(v,n) sort(v,v+n)
#define VSORT(v) sort(all(x))
#define FILL(v, value) (v+(sizeof(v) / sizeof *(v)), value);
#define inf 999999999
#define dbg(x) cout<<#x<<":"<<x<<endl;
#define pb(a) push_back((a))
#define mp(a) make_pair((a))
#define pi 2*acos(0.0)
#define in scanf
#define out printf
#define fi first
#define se second

// --
#define bit(n) (1LL<<(n)) // 左bitシフト
// --

using namespace std;

typedef long long llong;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<llong, pll> plp;

const int MOD=1000000007;
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};  // 右下左上


int main(int argc, char**argv){
  long n;
  cin >> n;
  vector<long> A;
  rep(i, n){
    long tmp;
    cin >> tmp;
    A.push_back(tmp);
  }
  sort(all(A));
  long max_size = A[n-1];
  long ok_min_index = n-1;
  rep(i, n){
    if (2 * A[i] >= max_size) {
      ok_min_index = i;
      break;
    }
  }

  long ans = (n-1) - ok_min_index + 1;
  // dbg(ans);

  long accumulation[n];
  rep(i, n) accumulation[i] = 0;
  // rep(i, n) dbg(A[i]);
  rep(i, n){
    if (i == 0) accumulation[i] = A[i];
    else accumulation[i] = accumulation[i-1] + A[i];
    // dbg(accumulation[i]);
  }
  // dbg(ok_min_index);
  for (long ix = ok_min_index-1; ix >= 0; ix--){
    // dbg(accumulation[ix]);
    // dbg(A[ix+1]);
    if (2 * accumulation[ix] >= A[ix+1]){
      ans++;
    }
    else break;
  }

  cout << ans << endl;

  // int ans = 1; // originally max size
  //
  // int accumulation[n];
  // rep(i, n) accumulation[i] = 0;
  // rep(i, n){
  //   if (i == 0) accumulation[i] = A[i];
  //   else accumulation[i] = accumulation[i-1] + A[i];
  // }
  // for (int ix = n-2; ix >= 0; ix--){
  //   if (2 * accumulation[ix] >= A[ix+1]){
  //     ans++;
  //   }
  //   else break;
  // }
  //
  // cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1908
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let l: usize = itr.next().unwrap().parse().unwrap();
    let r: usize = itr.next().unwrap().parse().unwrap();
    let d: usize = itr.next().unwrap().parse().unwrap();

    let mut ans = 0;
    for i in l..=r {
        if i % d == 0 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

int main() {
   long long n;
   cin >> n;
   long long ans=n-1;
   for (long long i = 2;i<=sqrt(n);i++){
       if (n%i==0){
           ans = min(ans,i+n/i-2);
       }
   }
   cout << ans << endl;

}



Measured memory_bytes: 256
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	var max int
	var ans int
	for i := 0; i < 5; i++ {
		in, _ := strconv.Atoi(readLine())
		if max < (10-in%10)%10 {
			max = (10 - in%10) % 10
		}
		ans += in + (10-in%10)%10
	}
	ans = ans - max
	fmt.Println(ans)
}


Measured memory_bytes: 3456
#include <math.h>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;

#define MAX 1000000
int a[MAX];

int main()
{
	int n;
	a[0] = a[1] = 0;
	a[2] = 1;
	a[3] = 2;
	for (int i = 4; i < MAX; i++)
	{
		bool ok = true;
		for (int j = 2; j < sqrt(i) + 0.1; j++)
		{
			if (i % j == 0)
			{
				a[i] = a[i - 1];
				ok = false;
				break;
			}
		}
		if (ok)
			a[i] = a[i - 1] + 1;
	}

	while (cin >> n)
		cout << a[n] << endl;
	
	return 0;
}

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

from fractions import math

ans=0

if n>=k:
    ans += 1 - (k-1)/n

for i in range(1,n+1):
    if i<=k-1:
        exp = math.ceil(math.log2(k/i))
        p_i = (1/n) * ((1/2)**exp)
        ans += p_i

print(ans)

Measured memory_bytes: 5048
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if (s.length() == 2) {
			System.out.println(s);
		} else {
			System.out.println(String.valueOf(s.charAt(2))+String.valueOf(s.charAt(1))+String.valueOf(s.charAt(0)));
		}
	}
}

Measured memory_bytes: 21844
N = int(input())
a = [int(i) for i in input().split()]

def cal(x,ans):
    if len(x) == 0 :
        print(ans)
        return ans
    else :
        y = [i for i in x if i %2 == 0]
        for i in range(len(y)):
            y[i] /= 2.0
        ans += len(y)
        cal(y, ans)


cal(a,0)

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    ll N;
    cin>>N;
    if (N==0) {
        cout<<0<<endl;
        return 0;
    }

    vector<ll> base(35);
    REP(i,35) {
        if (i == 0) base[i] = 1;
        else {
            base[i] = base[i-1] * -2;
        }
    }

    string ans;
    int i = 0;
    while(N) {
        if (N%(2*abs(base[i]))) {
            ans.pb('1');
            N -= base[i];
        }
        else {
            ans.pb('0');
        }
        i++;
    }
    reverse(ALL(ans));
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
  int N,A,B,C,D;cin>>N>>A>>B>>C>>D;
  string s;cin>>s;
  int i,j;
  int right=max(C,D);
  for(i=A-1;i<right-1;i++){
    if(s[i]=='#' and s[i+1]=='#'){
      cout<<"No"<<endl;
      return 0;
    }
  }
  if(C<D){
    cout<<"Yes"<<endl;
    return 0;
  }
  else{
    for(i=B-1;i<min(C,D);i++){
      if(s[i]=='.' and s[i-1]=='.' and s[i+1]=='.'){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
    cout<<"No"<<endl;
  }

}


Measured memory_bytes: 640