akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

int main(){
    int m,n;
    long long ans1=1,ans2=1,ans=1;
    int div=1000000007;
    while(cin >> m >> n){
    for(int i=0;i<50;i++){
        ans1 *= m;
        if(ans1>div) ans1 = ans1%div;
    }
    for(int j=0;j<n%50;j++){
        ans2 *= m;
        if(ans2>div) ans2 = ans2%div;
    }
    for(int k=0;k<n/50;k++){
        ans *= ans1;
        if(ans>div) ans = ans%div;
    }
    ans *= ans2;
    ans = ans%div;
    cout << ans << endl;
    }
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 1e18
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


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

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void comb_init() {
    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;
    }
}

// 二項係数計算
long long comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,k;
    cin>>n>>m>>k;
    ll ans=0;
    comb_init();
    for(ll i=0;i<n;i++){
        ans += i * (n-i) * m % MOD * m % MOD * comb(n*m-2,k-2) % MOD;
        ans%=MOD;
    }
    for(ll i=0;i<m;i++){
        ans += i * (m-i) * n % MOD * n % MOD * comb(n*m-2,k-2) % MOD;
        ans %= MOD;
    }

    cout<<ans<<endl;
}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

int main()
{

    ll n, t;
    cin >> n >> t;
    for(ll i = 0; i <= n; i++)
    {

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

            ll x = i*10000+j*5000+(n-i-j)*1000;
            if(x==t)
            {

                cout << i << " " << j << " " << n-i-j;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define INF 1000000000000000LL
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	ll A,V,B,W,T;
	cin>>A>>V>>B>>W>>T;
	ll pos1,pos2;
	if(A<=B){
		pos1=A+V*T;
		pos2=B+W*T;
		if(pos1>=pos2){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
	}
	else{
		pos1=A-V*T;
		pos2=B-W*T;
		if(pos1<=pos2){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3652
fla = 0
ans = 0

ket , kaz = map(int,input().split())
num = [-1 for i in range(ket)]
for j in range(kaz):
    s , c = map(int,input().split())
    if num[s-1] == -1:
        num[s-1] = c
    elif num[s-1] != c:
        fla = -1
        break

if fla == 0:
    if num[0] == 0:
        if ket != 1:
            fla = -1
    elif num[0] == -1:
        if ket == 1:
            num[0] = 0
        elif ket != 1:
            num[0] = 1

if fla == 0:
    for i in range(ket-1):
        if num[i+1] == -1:
            num[i+1] = 0
            
if fla == 0:
    for h in range(ket):
        ans +=  num[h]*(10**(ket-h-1))
    print(ans)
elif fla == -1:
    print(-1)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#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 ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    string s,t;
    cin >> n >> s >> t;
    REP(i,n){
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int main(){
    int n,k,x,y;
    scanf("%d%d%d%d",&n,&k,&x,&y);
    if(n >= k){
        printf("%d\n",k * x + (n - k) * y);
    }
    else{
        printf("%d\n",n * x);
    }
}

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    ll A;
    map<int,int> a;
    int c1=0,c2=0,c4=0;
    while(N--) {
        cin >> A;
        if(A%4==0) ++c4;
        else if(A%2==0) ++c2;
        else ++c1;
    }
    if(c2 == 0) {
        if(c1 - 1 <= c4) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else {
        if(c1 <= c4) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(1) {
        c -= b;
        if(c <= 0) {
            output("Yes");
            return 0;
        }
        a -= d;
        if(a <= 0) {
            output("No");
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3692
s=input()
dp=[[0]*13 for _ in range(len(s))]
if s[0]=='?':
  dp[0]=[1]*10+[0]*3
else:
  dp[0][int(s[0])]+=1

MOD=10**9+7
for i in range(1,len(s)):
  if s[i]=='?':
    for j in range(13):
      for k in range(10):
        dp[i][((j*10)%13+k)%13]+=dp[i-1][j]
        dp[i][((j*10)%13+k)%13]%=MOD
  else:
    k=int(s[i])
    for j in range(13):
      dp[i][((j*10)%13+k)%13]+=dp[i-1][j]
      dp[i][((j*10)%13+k)%13]%=MOD
print(dp[-1][5])

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

using namespace std;
typedef long long int ll;

int main()
{
    int n;
    cin >> n;
    vector<pair<int,int>>v(n);
    for(int i = 0; i < n; i++)
    {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(),v.end());
    double len = 0;
    do{
        for(int i = 1; i < n; i++)
        {
            len += sqrt((v[i].first - v[i-1].first)*(v[i].first - v[i-1].first) + (v[i].second - v[i-1].second)*(v[i].second - v[i-1].second));
        }
    }while(next_permutation(v.begin(),v.end()));
    double ans = len;
    for(int i = 1; i <= n; i++)
    {
        ans = ans / i;
    }
    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 3816
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define mod 1000000007 //998244353
#define pb push_back
#define endd '\n'
#define ll long long 
#define mk make_pair 
#define fi first
#define all(a) a.begin(),a.end()
#define test ll int t,o;cin>>o;for(t=1;t<=o;t++)
#define goog(q,aao) cout<<"Case #"<<q<<": "<<aao<<'\n'
#define co(a) cout<<a<<'\n'
#define coo(a,b) cout<<a<<" "<<b<<'\n'
#define cooo(a,b,c) cout<<a<<" "<<b<<" "<<c<<'\n'
#define take_arr ll i,j,k,n;mul_itr;set_itr;cin>>n;ll arr[n];loop(i,n)cin>>arr[i]
#define take ll i,j,k,n;mul_itr;set_itr;cin>>n
#define print(arr,n) for(ll w=0;w<n;w++)cout<<arr[w]<<" ";cout<<'\n'
#define print_dou(arr,n,m) for(ll w=0;w<n;w++){ for(ll o=0;o<m;o++){cout<<arr[w][o]<<" "; }cout<<endd;}
#define dis(w) loop(i,w.size())cout<<w[i]<<" ";cout<<'\n'
#define mem(b,q)  memset(b,q , sizeof(b))
#define set_itr set<ll>:: iterator sitr ,sit
#define mul_itr multiset<ll>:: iterator itr,it
#define map_itr map<ll,ll>:: iterator mitr,mit
#define se second
#define pii pair<int,int>
#define iterate(s,d) for(d=s.begin();d!=s.end();++d)
#define pll pair<long long,long long>
#define vll vector<ll>
#define vpll vector< pair<ll,ll> >
#define vppll vector < pair<ll, pair<ll,ll> > >
#define trace(x) cout<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x,y,z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a,b,c,d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define loop1(i,a,n) for(i=a;i<n; i++) 
#define loop(i,n) for( i=0;i<n;i++)
#define loop2(n,m) for(int p=0;p<n;p++)for(int q=0;q<m;q++)
#define loop3(n,m,l) for(int i=0;i<n;i++)for(int j=0;j<m;j++)for(int k=0;k<l;k++)
#define checkbit(n, b) ((n >> b) & 1)
#define setbits(x) __builtin_popcount(x)  // returns no of set bits in x 
#define maxx 10e18
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(9)
#define prefix_sum(arr,n); for(ll oo=1;oo<n;oo++)arr[oo]+=arr[oo-1];
using namespace std;
ll max(int a,ll b){ return max((ll)a,b);}
ll min(int a,ll b){ return min((ll)a,b);} 
ll min(ll a,int b){ return min(a,(ll)b);}
ll max(ll a,int b){ return max(a,(ll)b);}
/*

   NOTE :
  maxx=*max_element(a,a+n); 
  m=(m-1+n)%n;     move anti-clockwise  beaware : if u use some x instead of one use m=(m-x+ (n/x+1)*n)%n 
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  template <typename T>
  using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  
*/
//int32_t main(){
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    PRECISION;
    ll s,w;
    cin>>s>>w;
    if(w>=s)
    {
    	cout<<"unsafe"<<endd;
	}
	else
	{
		cout<<"safe "<<endd;
	}
    
    
  
    return 0;
}

Measured memory_bytes: 3608
import statistics  # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    N = int(input())
    A, B = [0] * N, [0] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())

    M = statistics.median(B)
    m = statistics.median(A)

    if N % 2 == 0:
        print(int((M-m)//0.5+1))
    else:
        print(M-m+1)


resolve()

Measured memory_bytes: 28820
def main():
    x = str(input())
    num = len(x)
    bottom = x[num - 1]
    if bottom == '2' or bottom == '4' or bottom == '5' or bottom == '7' or bottom == '9':
        print('hon')
    elif bottom == '0' or bottom == '1' or bottom == '6' or bottom == '8':
        print('pon')
    elif bottom == '3':
        print('bon')

main()

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

#define show(x) cerr << #x << " = " << x << endl ;
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define fastio ios_base::sync_with_stdio(0)
#define endl '\n'

const int N = 50;
int arr[N];

int main()
{
	 #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif
	fastio;cin.tie(0);cout.tie(0);
	int n ; cin >> n ;
	for(int i = 0; i <n ; ++i)
		cin >> arr[i];
	long long sum = 0;
	for(int i = 0 ; i < n-1 ; ++i)
	{
		for(int j = i + 1 ; j < n ; ++j)
			sum += 1LL*arr[i]*arr[j];
	}
	cout << sum ;


	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

void swap(int *x,int *y){
    int tmp=*x;
    *x=*y;
    *y=tmp;
}


int main(void){
    int X,Y,Z;

    scanf("%d %d %d",&X,&Y,&Z);

    swap(&X,&Y);
    swap(&X,&Z);

    printf("%d %d %d",X,Y,Z);


    return 0;
}

Measured memory_bytes: 128
import math

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


q = int(input())
l_r = []
for _ in range(q):
    l, r = map(int, input().split())
    l_r.append((l,r))

can = primes(10**5)
like_2017 = []

for m in can:
    limit = (max(can)//2)
    if m > limit :
        break
    if 2*m-1 in can:
        like_2017.append(2*m-1)

count = 0
can_count = []
for i in range(10**5):
    if i in like_2017:
        count += 1
    else:
        pass
    can_count.append(count)

for pair in l_r:
    l = pair[0]
    r = pair[1]
    ans = can_count[r] - can_count[l-1]
    print(ans)

    


Measured memory_bytes: 61784
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
	int n[3] = { 0 };
	int n2 = 0;
	int n3 = 0;
	int eaten = 1;
	scanf("%d%d%d", &n[0], &n[1], &n[2]);
	if (n[2] <= n[0] + n[1])
		printf("%d", n[1] + n[2]);
	else
		printf("%d", n[0]+n[1]+1+n[1]);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>
using namespace std;

int main() {
  int a[2][100];
  int n;
  scanf("%d", &n);
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j  < n; j++) {
      scanf("%d", &a[i][j]);
     }
   }
  for (int i = 1; i < n; i++) {
    a[0][i] += a[0][i - 1];
    a[1][n - i - 1] += a[1][n - i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) { ans = max(a[0][i] + a[1][i], ans); }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		String b=scan.next();
		int ans=0;
		int count=0;
		for(int i=0;i!=a;i++) {
		if(b.charAt(i)=='I') {
			count++;
		}
		else {
			count--;
		}
		if(count>ans) {
			ans=count;
		}
		}
		System.out.println(ans);
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(0, min(b, d) - max(a, c))<< endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  vector<ll> x(n);
  for(int i = 0;i < n;i++)cin >> x[i];
  sort(x.begin(),x.end());
  ll res = 0;
  for(int i = 1;i < n;i++){
    res += min((x[i] - x[i - 1]) * a,b);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1024
from heapq import heapify, heappop, heappush

n, m = map(int, input().split())
a = map(int, input().split())
a = list(map(lambda x: -x, a))
heapify(a)
# print(a)

while m > 0:
    v = heappop(a)
    v *= -1
    v //= 2
    v *= -1
    heappush(a, v)
    m -= 1

print(-sum(a))


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

using namespace std;
typedef long long ll;

ll MOD = 1e9+7;

class mint{
    ll n;
public:
    mint(ll m = 0){
        n = ((m % MOD) + MOD) % MOD;
    }
    mint operator-() const {
        return mint(-n);
    }
    mint& operator+=(const mint& m){
        n += m.n;
        if(n >= MOD) n -= MOD;
        return *this;
    }
    mint& operator-=(const mint& m){
        n += MOD - m.n;
        if(n >= MOD) n -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& m){
        n *= m.n;
        n %= MOD;
        return *this;
    }
    mint operator+(const mint& m) const{
        mint res(*this);
        res += m;
        return res;
    }
    mint operator-(const mint& m) const{
        mint res(*this);
        res -= m;
        return res;
    }
    mint operator*(const mint& m) const{
        mint res(*this);
        res *= m;
        return res;
    }
    mint pow(ll t) const{
        if(t == 0) return mint(1);
        mint m = pow(t>>1);
        m *= m;
        if(t & 1 == 1) m *= *this;
        return m;
    }
    // for prime modulo
    mint inv() const{
        return pow(MOD-2);
    }
    mint& operator/=(const mint& m){
        (*this) *= m.inv();
        n %= MOD;
        return *this;
    }
    mint operator/(const mint& m) const{
        mint res(*this);
        res /= m;
        return res;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.n;
        return os;
    }
};

ll n,a,b;

mint comb(ll s, ll t){
    mint c = mint(1);
    mint d = mint(1);
    for(int i=0;i<t;i++){
        c *= mint(s - (ll)i);
        d *= mint((ll)i + 1);
    }
    return c / d;
}

int main(){
    cin >> n >> a >> b;
    mint x = mint(2);
    x = x.pow(n);
    x -= mint(1);
    mint y = comb(n,a);
    mint z = comb(n,b);
    cout << x - y - z << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

A.sort()
A.reverse()

lim = sum(A) / (4*M)

cnt = 0
for a in A:
	if a >= lim:
		cnt += 1
	else:
		break
if cnt >= M:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <string>

using namespace std;

long long gcd(long long a, long long b);
long long lcm(long long a, long long b);

int main()
{
	int n, m;
	string s, t;
	cin >> n >> m >> s >> t;

	int g = gcd(n, m);
	int p = n / g, q = m / g;
	for (int i = 0; i < g; i++) {
		if (s[i * p] != t[i * q]) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << lcm(n, m) << endl;

	return 0;
}

long long gcd(long long a, long long b)
{
	if (a < b) {
		long long t = a;
		a = b;
		b = t;
	}

	long long r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

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

Measured memory_bytes: 512
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<functional>
#include<bits/stdc++.h>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s, t;
    cin>>s>>t;
    int c=0;
    if(s[0]==t[0])c++;
    if(s[1]==t[1])c++;
    if(s[2]==t[2])c++;
    
    cout<<c<<endl;
    
    return 0;
}

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

int main()
{
    int a, b, c;
    scanf("%d %d %d",&a,&b,&c);
    if (c>=a && c<=b)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,mul=0,sum=0;
cin>>n;
int A[n];
for(int i=0;i<n;i++)
    cin>>A[i];
for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
       mul = A[i]*A[j];
       sum = sum + mul;
    }
}
cout<<sum<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
    {
    	static void Main(string[] args)
    	{
    		string s = Console.ReadLine();
            List<char> usable = new List<char>();
            for(int i=0; i<26; i++) usable.Add((char)('a' + i));
            foreach(char c in s) usable.Remove(c);
            if (usable.Count > 0) Console.WriteLine(s + usable[0].ToString());
            else{
                int i = 25;
                while(true)
                {
                    usable.Add(s[i]);
                    usable.Sort();
                    foreach(char c in usable){
                        if (s[i - 1] < c) {
                            Console.WriteLine(s.Substring(0, i - 1) + c.ToString());
                            return;
                        } 
                    }
                    
                    i--;
                    if (i == 0) {
                        Console.WriteLine(-1);
                        break;
                    }
                }
            }
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 13396
let rec f(x,y)r=match Scanf.scanf"%f,%f
"(fun d t->d,t)with|(0.,0.)->Printf.printf"%d
%d
"(truncate x)(truncate y)|(d,t)->let z=3.141*.r/.180. in f(x+.d*.cos z,y+.d*.sin z)(r-.t);;f(0.,0.)90.

Measured memory_bytes: 2624
package main

import "fmt"

func main() {
	var n int
	var x int
	var count int
	var l, bound []int
	var tmp int

	_, err := fmt.Scan(&n, &x)
	if err != nil {
		fmt.Println("fmt Scan error:", err)
		return
	}
	for i := 0; i < n; i++ {
		_, err := fmt.Scan(&tmp)
		if err != nil {
			fmt.Println("fmt Scan error:", err)
			return
		}
		l = append(l, tmp)
	}

	if n == 1 {
		fmt.Println(1)
		return
	}

	for i := 0; i < n+1; i++ {
		if i == 0 {
			bound = append(bound, 0)
		} else {
			bound = append(bound, bound[i-1]+l[i-1])
		}
	}

	for i := 0; i < len(bound); i++ {
		if bound[i] <= x {
			count++
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 512
#include <stdio.h>

int main() {

  int input = 0;
  int hour = 0;
  int minute = 0;
  int second = 0;

  scanf("%d", &input);

  hour = input /3600;
  minute = (input - hour * 3600) / 60;
  second = input - hour * 3600 - minute * 60;

  printf("%d:%d:%d\n", hour, minute, second);

  return 0;
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}

int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  string s;
  cin>>s;
  rep(i,s.size()){
    for(int j=i+1;j<s.size();j++){
      if(s[i]==s[j]){
        cout<<"no"<<endl;
        return 0;
      }
    }
  }
  cout<<"yes"<<endl;
}
///////////////////////////

Measured memory_bytes: 256
////////////////////////    W H I T E C L O U D    ////////////////////////
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define nn 1000004
int mark[nn+2];
vector<int>prime;
void sieve()
{
    mark[1]=mark[0]=1;prime.push_back(2);
    int i,j,rt;
    rt=sqrt(nn);

    for(i=4; i<nn; i+=4)mark[i]=1;

    for(i=3; i<rt; i+=2)
        if(mark[i]==0)
            for(j=i*i; j<=nn; j+=2*i) mark[j]=1;

    for(i=3; i<=nn; i+=2)
        if(mark[i]==0) prime.push_back(i);
}
ll nod(ll n)
{
    ll i,cnt,ans=1;
    for(i=0; prime[i]*prime[i]<=n; i++)
    {
        cnt=0;
        while(n%prime[i]==0)
        {
            cnt++;n/=prime[i];
        }
        ans*=(cnt+1);
    }
    if(n!=1)ans*=2;
    return ans;
}

int main()
{
    FAST();
    sieve();
    ll n,i,sum=0;
    cin>>n;
    for(i=1; i<n; i++)
    {
        sum+=nod(n-i);
    }
    cout<<sum<<endl;



    return 0;
}







Measured memory_bytes: 7760
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    int N;
    cin >> N;

    vi C(N - 1), S(N - 1), F(N - 1);
    rep(i, N - 1) cin >> C[i] >> S[i] >> F[i];


    rep(i, N)
    {
        int t = 0;
        int pos = i;
        while (pos < N - 1)
        {
            //始発時刻まで待つ
            chmax(t, S[pos]);

            //次の電車まで待つ
            t += (F[pos] - t % F[pos]) % F[pos];

            //電車に乗って次の待ちへ
            t += C[pos];
            pos++;
        }

        cout << t << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define INF 2e9
using namespace std;
typedef long long ll;

int main(){
    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/

bool isPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}


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

	int n;
	cin >> n;

	// 要素数が変わってもn=55の時の組から適当に選べばよい

	vector<int> prime;

	Rep(i, 2, 55556) {
		if (isPrime(i)) prime.push_back(i);
	} // 素数が5600個ある

	// 55個選ぶ
	// 合計が素数なんて少ないんじゃ？
	// 合計が5の倍数を目指す
	// 下一桁が3であるやつを55個探す ← 天才か！！！！

	vector<int> ans(55);
	int cnt = 0;
	for (auto p : prime) {
		if (p % 10 == 3) {
			ans[cnt] = p;
			cnt++;
			if (cnt == 55) break;
		}
	}

	rep(i, n) {
		cout << ans[i] << " ";
	}

	cout << endl;


	return 0;
}

Measured memory_bytes: 384
using System;
using System.Diagnostics;
using System.Linq;
using System.Text;


class Program
{
    public static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var S = Console.ReadLine();
        var cr = S.Count(n => n == 'R');
        var cb = S.Count(n => n == 'B');
        Console.WriteLine(cr > cb ? "Yes" : "No");
    }
}


Measured memory_bytes: 11220
fun main(args:Array<String>) {
    val n = readLine()!!.toInt()
    val buttons = (1..n).map { readLine()!!.toInt() - 1 }

    val light = BooleanArray(n)

    var cur = 0
    for(i in (0..n)) {
        if(cur == 1) {
            println(i)
            return
        }
        cur = buttons[cur]
    }
    println(-1)
}


Measured memory_bytes: 58968
data = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
n = int(input())
for _ in range(n):
    (b,f,r,v) = [int(i) for i in input().split()]
    data[b - 1][f - 1][r - 1] += v
 
for b in range(4):
    for f in range(3):
        for r in range(10):
            print('',data[b][f][r], end='')
        print()
    if b < 3:
        print('#' * 20)

Measured memory_bytes: 7736
import sys
from collections import defaultdict
sys.setrecursionlimit(10 + 2 * 10 ** 5)
 
n, m = map(int, input().split())
 
color = [None] * (n + 1)
for i in range(n + 1):
    color[i] = i
 
def root(x):
    global color
 
    if color[x] == x:
        return x
    color[x] = root(color[x])
    return color[x]
 
def unite(x, y):
    rx = root(x)
    ry = root(y)
    if rx == ry:
        return
    color[rx] = ry
 
for i in range(m):
    a, b = map(int, input().split())
    unite(a, b)
 
cnt = defaultdict(int)
for i in range(n):
    cnt[root(i + 1)] += 1
print(max(cnt.values()))

Measured memory_bytes: 174412
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld  = long double;
using pll = pair<ll, ll> ;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=1LL<<60;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-9; //微調整用（EPSより小さいと0と判定など）
 
#define gcd __gcd //llは受け取ってくれない
int lcm(int a, int b){return a / gcd(a, b) * b;}
#define ALL(a) a.begin(),a.end() //sort(ALL(vec));
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define PB push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに
 
//最大値、最小値を更新する。aよりbのが大きい（小さい）か等しければaを更新してtrueを返す。そうでなければ何もせずfalseを返す chmax(nowmax,x);
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
// ----- template end ---- //
 
// ------- library ------- //


// ----- library end ----- //


int main() {
    
  ll N, P;
  cin >> N >> P;
  
  vector<ll> As(N);
  rep(i, N){
    ll tmp;
    cin >> tmp;
    As.at(i) = tmp;
  }

  ll evens, odds;
  evens = count_if(ALL(As), [](ll x) -> ll {return x % 2 == 0;}); //偶数なら数える
  odds = N - evens;
  
  // MODなしのnCk （DP→lambda式取出）
  // n*nではなくパスカルの三角形分だけ確保することで、メモリをちょっと節約
  ll n_limit = N; //!! nの最大値を設定 !!
  vector<ll> CmbsVec( ( 2 + n_limit ) * ( 1 + n_limit ) / 2 );
  //nCkへのアクセスは .at( ( n + 1 ) * n / 2 + k )
  //n-1まで（1段上）の要素の総数が ( n + 1 ) * n / 2 なので、その次の段のk+1個目を0-indexed (つまり-1)に直すと、この式に
  
  //nC0, nCnは全て1に
  rep(i, n_limit+1){  //n : 0〜n_limitについて
    CmbsVec.at( ( i + 1 ) * i / 2 + 0 ) = 1;  //nC0
    CmbsVec.at( ( i + 1 ) * i / 2 + i ) = 1; //nCn
  }
  
  //n C 1〜n-1を計算 nは2からスタート
  REP(n, 2, n_limit + 1){ //nは2〜n_limitまで全て
    REP(k, 1, n){ //kは1〜n-1
      // nCk = n-1Ck-1 + n-1Ck
      CmbsVec.at( ( n + 1 ) * n / 2 + k ) = CmbsVec.at( n * ( n - 1) / 2 + k - 1 ) + CmbsVec.at( n * ( n - 1 ) / 2 + k );
    }
  }
  
  // nCkを返すlambda式を用意
  auto Comb = [&] (ll n, ll k) -> ll {
    return CmbsVec.at( ( n + 1 ) * n / 2 + k );
  };

//  cout << evens << ' ' << odds << endl;

  ll ans = 0;
  ll twoevens = pow(2, evens);
  if (evens == 0){
    twoevens = 1;
  }
  
  if (P==1 and odds!=0){ //奇数にしたい場合で、oddsがある場合（無ければ不可能）
  //evensからいくつでも、oddsから奇数選ぶ
  //for odds:1～odds(gap2){oddsCi * 2^evens}
    for (ll i=1; i <= odds; i += 2){
      ans += Comb(odds, i) * twoevens;
//      cout << odds << ' ' << i << ' ' << comb(odds, i)<< endl;
    }
  } //奇数にしたい場合で、oddsが無い場合はans==0のままでOK
  else if (P==0){ //偶数にしたい場合
  //evensからいくつでも、oddsから偶数(0でもOK）選ぶ
  //for odds:2～odds(gap2){oddsCi * 2^evens}
    for (ll i=0; i <= odds; i += 2){
      //combは(0, 0)の場合は1を返し、(0, 正)の場合は0を返す
      ans += Comb(odds, i) * twoevens;
    }
  }

  cout << ans << endl;

// -- main() end -- //
}


 


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

template<class T> inline bool chmax(T &a, T b)
{
    if(a < b)
    {
        a = b;
        return true;
    }
    return false;
}

int rec(vector<vector<int>> &mp, vector<int> &cmp, int n, int node)
{
    if(cmp.at(node) != -1) return cmp.at(node);

    int res = 0;
    for(auto i : mp.at(node))
    {
        chmax(res, rec(mp, cmp, n, i) + 1);
    }
    cmp.at(node) = res;
    return res;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> mp(n, vector<int>());
    for(int i=0; i<m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        mp.at(a).push_back(b);
    }

    vector<int> cmp(n, -1);
    int res = 0;
    for(int i=0; i<n; i++)
    {
        chmax(res, rec(mp, cmp, n, i));
    }
    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 9600
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  char a[5];
  scanf("%s", a);
  if (strcmp(a, "SUN") == 0)
    printf("7\n");
  if (strcmp(a, "MON") == 0)
    printf("6\n");
  if (strcmp(a, "TUE") == 0)
    printf("5\n");
  if (strcmp(a, "WED") == 0)
    printf("4\n");
  if (strcmp(a, "THU") == 0)
    printf("3\n");
  if (strcmp(a, "FRI") == 0)
    printf("2\n");
  if (strcmp(a, "SAT") == 0)
    printf("1\n");
}

Measured memory_bytes: 128
l=a=0;r=len(s:=input())-1
while l<r:
  X=((L:=s[l])==(R:=s[r]))
  l+=((L:=(L=='x'))+X>0)
  r-=((R:=(R=='x'))+X>0)
  a+=(X<1)*(L+R>0)
  if X+L+R<1:a=-1;break
print(a)

Measured memory_bytes: 9220
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#define INF 10000000000000
using namespace std;
using ll = long long;
int main() {
	ll n;
	cin >> n;
	vector<pair<ll, ll>> ab(n);
	vector<pair<ll, ll>> gap(n);
	for (ll i = 0; i < n; i++) {
		ll x, y;
		cin >> x >> y;
		gap[i] = make_pair(x + y, i);
		ab[i] = make_pair(y, x);
	}
	sort(gap.rbegin(), gap.rend());

	ll ans = 0;
	bool ok = false;
	for (ll i = 0; i < n; i++) {
		if (ok == false) {
			ans += ab[gap[i].second].second;
			ok = !ok;
		}
		else {
			ans -= ab[gap[i].second].first;
			ok = !ok;
		}
	}
	cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    int A;
    cin >> A;
    if (i % 2 == 1 && A % 2 == 1) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n,k = map(int, input().split())
    a = list(map(int, input().split()))
    db = [a]
    cnt = k.bit_length()
    for c in range(1, cnt):
        temp = [0]*n
        for i in range(n):
            temp[i] = db[c-1][db[c-1][i]-1]
        db.append(temp)

    res = 1
    for i in range(cnt):
        if (k>>i) & 1:
            res = db[i][res-1]
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 176352
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}

ll dig(ll n){
    ll d = 0;
    while(n != 0){
        n/=10;
        d++;
    }
    return d;
}
map<char,int> a;
void solve() {
    ll n,m;
    cin >> n >> m;
    priority_queue <ll> que;

    // 順番は特に関係ない。現在の最大値を削っていく。最大値を高速に計算できるようなデータ構造が良い。
    for(int i = 0;i < n;i++){
        ll a;
        cin >> a;
        que.push(a);
    }

    for(int i = 0;i < m;i++){
        ll p;
        p = que.top()/2;
        que.pop();
        que.push(p);
    }

    ll sum = 0;
    for(int i = 0;i < n;i++){
        sum += que.top();
        que.pop();
    }

    cout << sum << endl;
}


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}



Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,x;
cin>>n>>x;
vector<int>a;
a.push_back(x);
for(int i=0;i<n;i++){
    int m;
    cin>>m;
    a.push_back(m);
}
sort(a.begin(),a.end());
int ans=a[1]-a[0];
for(int i=1;i<n;i++){
    ans=__gcd(ans,a[i+1]-a[i]);
}
cout<<ans<<endl;
}

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

using namespace std;

long long int h;

vector<long long int> data(500010);

long long int left(long long int i) {
	return i*2;
}

long long int right(long long int i) {
	return i*2+1;
}

void maxHeapify(long long int i) {
	//cout << i << endl;
	long long int l = left(i);
	long long int r = right(i);
	long long int largest = l;
	if (l <= h && data[l] > data[i]) {
		largest = l;
	} else {
		largest = i;
	}
	//cout << i << endl;
	if (r <= h && data[r] > data[largest]) {
		largest = r;
	}
	if (largest != i) {
		swap(data[i], data[largest]);
		maxHeapify(largest);
	}
	//cout << i << endl;
}

void buildMaxHeap(void) {
	for (long long int i = h/2; i >= 1; i--) {
		maxHeapify(i);
	}
}

int main() {
	cin >> h;
	for (long long int i = 1; i <= h; i++) {
		cin >> data[i];
	}
	buildMaxHeap();
	for (long long int i = 1; i <= h; i++) {
		cout << ' ' << data[i];
	}
	cout << endl;
	return 0;
}

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

int main()
{
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];

    auto is_bomb = [&](int hi, int wi){
        if(hi < 0 || wi < 0 || hi >= h || wi >= w)
            return false;
        return s[hi][wi] == '#';
    };

    rep(i,h){
        rep(j,w){
            if(s[i][j] != '.') continue;
            
            int cnt = 0;
            for(int dh=-1;dh<=1;++dh)
                for(int dw=-1;dw<=1;++dw)
                    if(is_bomb(i+dh,j+dw)) ++cnt;
            
            s[i][j] = '0' + cnt;
        }
    }

    rep(i,h) cout << s[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
 int n,a,b,c,i,j,s=0;
 scanf("%d%d%d",&n,&a,&b);
 for(i=1;i<n+1;i++){
  j=i;
  c=0;
  while(j!=0){
   c+=j%10;
   j/=10;
  }
  if(c>=a && c<=b) s+=i;
 }
 printf("%d",s);
 return 0;
}

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

long long X, Y, Z, K;

int main()
{
    cin >> X >> Y >> Z >> K;

    vector<long long> A(X), B(Y), C(Z);
    vector<long long> ans;

    for (long long i = 0; i < X; i++)
        cin >> A[i];

    for (long long j = 0; j < Y; j++)
        cin >> B[j];

    for (long long k = 0; k < Z; k++)
        cin >> C[k];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    for (long long i = X - 1; i >= 0; i--)
        for (long long j = Y - 1; j >= 0; j--)
            for (long long k = Z - 1; k >= 0; k--)
                if ((X - i) * (Y - j) * (Z - k) <= K)
                    ans.push_back(A[i] + B[j] + C[k]);

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

    for (long long i = ans.size() - 1, j = 0; i >= 0 && j < K; i--, j++)
        cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 1404
int main()
{
	for(int t,n;__builtin_scanf("%d%d",&t,&n),t;){
		int sum=0;
		while(n--){
			int a,b; __builtin_scanf("%d%d",&a,&b);
			sum+=b-a;
		}
		if(sum>=t)
			__builtin_puts("OK");
		else
			__builtin_printf("%d\n",t-sum);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <fstream>

#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>

#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>

#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */

void solve(istream &cin) {
    ll N;
    cin >> N;
    if(!cin) return;

    ll B, C;
    cin >> B >> C;
    ll ans = min(B / N, C);
    cout << ans << endl;
}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    cerr << "DEBUG MODE" << endl;
    string test_cases = "test.txt";
    auto fs = fstream(test_cases, fstream::in);
    while(fs) {
        solve(fs);
    }
#else
    solve(cin);
#endif
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int dp[2][1222];
int s[2][1222];
int main(void)
{
    int n;
    cin>>n;
    for (int i = 0;i < 2;++i)
        for (int j = 1;j <= n;++j)
            cin>>s[i][j];
    for (int i = 0;i < 2;++i)
        for (int j = 1;j <= n;++j)
        {
            dp[i][j] = s[i][j];
            if (i)
                smax(dp[i][j],dp[i - 1][j] + s[i][j]);
            if (j > 1)
                smax(dp[i][j],dp[i][j - 1] + s[i][j]);
        }
    cout << dp[1][n] << '\n';
    return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll a,b,v,w,t;
  cin>>a>>v;
  cin>>b>>w;
  cin>>t;
  if(abs(a-b)<=(v-w)*t)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}

Measured memory_bytes: 3644