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

using namespace std;
typedef long long LL;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL A, B, C, D; cin >> A >> B >> C >> D;
	LL S1 = A*B;
	LL S2 = C*D;
	printf("%lld\n", max(S1, S2));
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main(){
        ll n,k,q,i,idx;
        cin >> n >> k >> q;
        vector<int> a(n);
        for(i=0;i<q;++i){
                cin >> idx;
                ++a.at(idx-1);
        }
        for(i=0;i<n;++i){
                if(a.at(i)+k-q>0) cout << "Yes" << endl;
                else cout << "No" << endl;
        }
        return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B ;
  
  C = A * B;
  D = C % 2;
    
    if(D == 1){
      cout << "Odd" << endl;
    }
  
    else{
      cout << "Even" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll l, r;
  cin >> l >> r;
  if (r - l > 2020) r = l + 2020;
  ll ans = 2018;
  for(ll i = l; i <= r; i++) {
    for(ll j = i + 1; j <= r; j++) {
      ans = min(ans, i*j%2019);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int A,B;

int main(){
    cin>>A>>B;
    cout<<(A%3==0||B%3==0||(A+B)%3==0?"Possible":"Impossible")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
using namespace std;


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


int main(){
  int a, b;
  cin >> a >> b;
  int ans = abs(a - b);
  if(ans % 2 == 0){
    cout << ans / 2 + min(a, b) << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  
}


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

int main() {
    int N; cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S.at(i);
    }
    sort(S.begin(), S.end());
    vector<pair<string, int>> ans(N);
    ans.at(0).first = S.at(0);
    ans.at(0).second = 1;
    int j = 0, M = 1;
    for (int i = 1; i < N; i++) {
        if (S.at(i) == ans.at(j).first) {
            ans.at(j).second++;
            M = max(M, ans.at(j).second);
        }
        else {
            j++;
            ans.at(j).first = S.at(i);
            ans.at(j).second = 1;
        }
    }
    
    for (int i = 0; i < N; i++) {
        if (ans.at(i).second == M) {
            cout << ans.at(i).first << endl;
        }
    }
}

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

using namespace std;

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

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;

int main() {
    int n,m;
    cin>>n>>m;
    vector<vector<int>> d;
    rep(i,m){
        int k;
        cin>>k;
        vector<int> d1;
        rep(j,k){
            int s;
            cin>>s;
            d1.push_back(s);
        }
        d.push_back(d1);
    }
    int p[m];
    rep(i,m){
        cin>>p[i];
    }

    int ans=0;
    for (int i=0;i<(1<<n);i++){
        bitset<10> s(i);
        int b=1;
        for (int j=0;j<m;j++){
            int c=0;
            for (int x:d[j]){
                if (s.test(x-1)){
                    c+=1;
                }
            }
            if (c%2!=p[j]){
                b=0;
                break;
            }
        }
        if (b){
            ans+=1;
        }
    }
    cout<<ans<<endl;

    return 0;
}


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

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main()
{
	ll N, M; cin >> N >> M;
	ll cnt = 0;
	if (M >= 2 * N) {
		cnt += N;
		M -= 2 * N;
		cnt += M / 4;
	}
	else {
		cnt += M / 2;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
a = list(input())
b = list(input())
f = False
x = []
if len(a)> len(b):
    b.append(0)
    f = True
for i in range(len(a)):
    x.append(a[i])
    x.append(b[i])
if f:
    x.pop()
print("".join(x))

Measured memory_bytes: 61944
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

   int a,b,c,d;
   cin>>a>>b>>c>>d;
   while(true){
     c -= b;
     if(c <= 0){
      cout<<"Yes"<<endl;
      return 0;
     }
     a -= d;
     if(a <= 0){
      cout<<"No"<<endl;
      return 0;
     }
   }
  return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 3e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1);
const int MOD = 998244353;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 200005;
const int MAXV = 3;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        int x = read<int>();
        if ((i & 1) && (x & 1)) cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}

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

int main() {
	int n; cin >> n;
	int b, f, r, v;
	int room[5][4][11] = { 0 };

	for (int i = 0; i < n; ++i) {
		cin >> b >> f >> r >> v;
		room[b - 1][f - 1][r - 1] += v;
	}

	for (int i = 0; i < 4; ++i) {
		for (int j = 0; j < 3; ++j) {
			for (int k = 0; k < 10; ++k) printf(" %d", room[i][j][k]);
			printf("\n");
		}
		if(i < 3) printf("####################\n");
	}
}


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


namespace 競プロCS {
    class ABC162C {
        static void Main() {
            int k = int.Parse(Console.ReadLine());
            int total = 0;
            for (int a = 1; a <= k; a++) {
                for (int b = 1; b <= k; b++) {
                    for (int c = 1; c <= k; c++) {
                        total += gcd(c, gcd(b, a));
                    }
                }
            }

            Console.WriteLine(total);
        }
        private static int gcd(int a, int b) {
            int ans = a % b;
            if (ans == 0) {
                return b;
            }
            return gcd(b, ans);
        }
    }

}


Measured memory_bytes: 27536
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int nums[] = new int [n];
			int count = 0;
			for (int i = 0; i < n; i++) {
				int temp = sc.nextInt();
				if (temp != i+1) {
					count++;
				}
			}

			if (count == 2 || count == 0) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}

	}

}

Measured memory_bytes: 23764
#include <stdio.h>
int main() {
    int n, A[4] = {0};
    char c;
    scanf("%i%*c", &n);
    for (int i = 0; i < n; i++) {
        scanf("%c", &c);
        if (c == 'A') {
            A[0]++;
            scanf("%*c%*c");
        }
        if (c == 'W') {
            A[1]++;
            scanf("%*c%*c");
        }
        if (c == 'T') {
            A[2]++;
            scanf("%*c%*c%*c");
        }
        if (c == 'R') {
            A[3]++;
            scanf("%*c%*c");
        }
    }
    printf("AC x %i\n\WA x %i\n\TLE x %i\n\RE x %i", A[0], A[1], A[2], A[3]);
}


Measured memory_bytes: 1704
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

const int N = 100100;

int l[N], r[N], idl[N], idr[N];
int pass[N];


bool cmpl(int a, int b) {
	return l[a] > l[b];
}

bool cmpr(int a, int b) {
	return r[a] < r[b];
}

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

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

	sort(idl, idl+n, cmpl);
	sort(idr, idr+n, cmpr);


	memset (pass, 0, sizeof pass);
	int pl = 0, pr = 0;
	int at = 0;
	long long ans1 = 0;
	for (int i = 0; i < n; ++i) {
		if(i%2 == 0) {
			while(pass[idl[pl]] && pl < n) {
				pl++;
			}
			if(pass[idl[pl]] == 0){
				pass[idl[pl]] = 1;
				if(l[idl[pl]] <= at && at <= r[idl[pl]]) {
					continue;
				} 
				else if(abs(l[idl[pl]] - at) > abs(r[idl[pl]] - at) ){
					ans1 +=  abs(r[idl[pl]] - at);
					at = r[idl[pl]];
				}
				else {
					ans1 +=  abs(l[idl[pl]] - at);
					at = l[idl[pl]];
				}
			}
		}
		else {
			while(pass[idr[pr]] && pr < n) {
				pr++;
			}
			if(pass[idr[pr]] == 0){
				pass[idr[pr]] = 1;
				if(l[idr[pr]] <= at && at <= r[idr[pr]]) {
					continue;
				} 
				else if(abs(l[idr[pr]] - at) > abs(r[idr[pr]] - at) ){
					ans1 +=  abs(r[idr[pr]] - at);
					at = r[idr[pr]];
				}
				else {
					ans1 +=  abs(l[idr[pr]] - at);
					at = l[idr[pr]];
				}
			}		
		}
	}
	ans1 += abs(at);
	memset (pass, 0, sizeof pass);
	pl = 0, pr = 0;
	at = 0;
	long long ans2 = 0;
	for (int i = 0; i < n; ++i) {
		if(i%2 == 1) {
			while(pass[idl[pl]] && pl < n) {
				pl++;
			}
			if(pass[idl[pl]] == 0){
				pass[idl[pl]] = 1;
				if(l[idl[pl]] <= at && at <= r[idl[pl]]) {
					continue;
				} 
				else if(abs(l[idl[pl]] - at) > abs(r[idl[pl]] - at) ){
					ans2 +=  abs(r[idl[pl]] - at);
					at = r[idl[pl]];
				}
				else {
					ans2 +=  abs(l[idl[pl]] - at);
					at = l[idl[pl]];
				}
			}
		}
		else {
			while(pass[idr[pr]] && pr < n) {
				pr++;
			}
			if(pass[idr[pr]] == 0){
				pass[idr[pr]] = 1;
				if(l[idr[pr]] <= at && at <= r[idr[pr]]) {
					continue;
				} 
				else if(abs(l[idr[pr]] - at) > abs(r[idr[pr]] - at) ){
					ans2 +=  abs(r[idr[pr]] - at);
					at = r[idr[pr]];
				}
				else {
					ans2 +=  abs(l[idr[pr]] - at);
					at = l[idr[pr]];
				}
			}		
		}
	}
	ans2 += abs(at);
	printf("%lld\n", max(ans1, ans2));
}

Measured memory_bytes: 2176
#include<stdio.h>

int prime(int x)
{
    int i;

    if(x==1) return 0;
    if(x==2) return 1;
    if(x!=2&&x%2==0) return 0;

    for(i=3;i*i<=x;i+=2){
        if(x%i==0) return 0;
    }

    return 1;
}

int main(void)
{
    int count,a,n,d,i;

    while(scanf("%d%d%d",&a,&d,&n),a+d+n){

        count=0;

        for(i=0;;i++){
//            if((a+i*d)%2==0) continue;
            if(prime(a+i*d)){
                count++;
            }
            if(count==n){
                break;
            }
        }

        printf("%d\n",a+i*d);
    }
    return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a,b,count=0;
  cin>>a>>b;
  for(int c=0;c<=a;c++){
    for(int d=0;d<=a;d++){
      int e=b-c-d;
      if(e>=0 and e<=a){
          count++;
        }
      }
    }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x; 
}
#define MN 5000
#define MM 200
int a[MN+5],b[MN+5][MM+5],q[MM+5][MN+5],qn[MM+5];
long long c[MN+5],ans,s;
int main()
{
	int n,m,i,j,x;
	n=read();m=read();
	for(i=1;i<n;++i)a[i]=read();
	for(i=1;i<=n;++i)for(j=1;j<=m;++j)b[i][j]=read();
	for(i=n;i;--i)
	{
		for(j=1;j<=m;++j)
		{
			while(x=q[j][qn[j]],qn[j]&&b[i][j]>=b[x][j])
				c[x]-=b[x][j],c[q[j][--qn[j]]]+=b[x][j];
			c[q[j][++qn[j]]=i]+=b[i][j];c[x]-=b[i][j];
		}
		for(j=i,s=0;j<=n;s-=a[j++])ans=max(ans,s+=c[j]);
	}
	printf("%lld",ans);
}

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

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

  for (int i = 0; i < n; i ++) {
    if (s.substr(i, n - i) == t.substr(0, n - i)) {
      break;
    } else {
      ans ++;
    }
  }

  cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  for(int i=0; i<N; i++){
    cin >> s.at(i); 
  }
  int M;
  cin >> M;
  vector<string> t(M);
  for(int i=0; i<M; i++){
    cin >> t.at(i); 
  }
  
  map<string, int> yen;
  for(string str : s){
    if(yen.count(str)){
      yen.at(str)++;
    }
    else{
      yen[str] = 1;
    }
  }
  for(string str : t){
    if(yen.count(str)){
      yen.at(str)--;
    }
    else{
      yen[str] = -1;
    }
  }

  int maximum = 0;
  for(pair<string, int> p : yen){
    int v = p.second;
    maximum = max(maximum, v);
  } 
  
  cout << maximum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> vct(n);
  for(int i=0;i<n;i++) cin >> vct[i];
  sort(vct.begin(),vct.end());
  reverse(vct.begin(),vct.end());
  int A=0;
  int B=0;
  for(int i=0;i<n;i++){
      if(i%2==0){
          A+=vct[i];
      }else{
          B+=vct[i];
      }
  }
  cout<<A-B<<endl;
  }

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

int barrel[200000];

int main() {
    int n;
    cin >> n;
    int t;
    for(int i = 0; i < n ;i++) {
        scanf("%d", &t);
        barrel[t]++;
    }
    int cnt = 0;
    for(int i = 0; i < 200000; i++) {
        if(barrel[i] > 1) {
            cnt += barrel[i] - 1;
        }
    }
    if(cnt % 2 == 1) {
        cnt++;
    }
    cout << n-cnt << endl;
}


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

ll mod = 1e9+7;

ll dp[101][100001];
ll a[100];
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int j = 0; j <= k; j++)
    dp[0][j] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      dp[i][j] = (dp[i-1][j]-(j > a[i-1] ? dp[i-1][j-a[i-1]-1] : 0) + (j ? dp[i][j-1] : 0))%mod;
    }
  }
  cout << ((dp[n][k]-(k ? dp[n][k-1] : 0))%mod+mod)%mod << endl;
}


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

int main(){
    long long a,b,t, res=2020;

    cin>>a>>b;
    b=min(b,a+2019);
    for(long i=a; i<=b; i++){
        for(long j=i+1;j<=b; j++){
            t=(i*j)%2019;
            res= min(t, res);
        }
    }
    cout<<res;


return 0;
}


Measured memory_bytes: 256
n = int(input())
l = ['a','b','c','d','e','f','g','h','i','j']

def dfs(res,i):
    if len(res)==n:
        print(res)
        return
    for k in range(i):
        dfs(res+l[k],i)
    dfs(res+l[i],i+1)

dfs('',0)

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

int main()
{
    int n;
    cin>>n;
    if(n<0)
    {
        EXIT_FAILURE;
    }
    else if(n<1200)
    {
        cout<<"ABC"<<endl;
    }
    else if(n>=1200&&n<2800)
    {
        cout<<"ARC"<<endl;
    }
    else if(n>=2800&&n<=4208)
    {
        cout<<"AGC"<<endl;
    }
}

Measured memory_bytes: 256
import java.io.*;
	import java.util.*;
    class Main
    {
      public static void main(String args[])throws IOException
      {
        int i,s1=0,s2=0,s,m,n;
        BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
        Scanner sc =new Scanner(System.in);
        //n=Integer.parseInt(input.readLine());
        //m=Integer.parseInt(input.readLine());
        n=sc.nextInt();
        m=sc.nextInt();
        for(i=1;i<m;i++)
        {
          s1=s1+i;
        }
        for(i=1;i<n;i++)
        {
          s2=s2+i;
        }
        s=s1+s2;
        System.out.println(s);
      }
    }

Measured memory_bytes: 20820
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(a, b):
	return a * b // gcd (a, b)

def solve():
    n = int(input())
    clocks = [int(input()) for _ in range(n)]
    ans = clocks[0]
    for i in clocks[1:]:
        ans = lcm(ans, i)
    print(ans)

solve()

Measured memory_bytes: 2940
// D - Powerful Discount Tickets
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,n) for(int i=0;i<(n);++i)

int main(){
	int N,M; cin>>N>>M;

	priority_queue<int> A;
	rp(i, N){ int a; cin>>a; A.push(a); }

	rp(i,M){ int a = A.top(); A.pop(); A.push(a/2); }

	ll ans = 0;
	rp(i,N){ ans += A.top(); A.pop(); }
	cout<< ans <<endl;
}

Measured memory_bytes: 892
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

int main()
{
  char S[11];
  scanf( "%s", S );
  S[3] = '8';

  printf( "%s\n", S );

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,ans=35,i;
    cin>>n;
    ll a;
    for (i=0;i<n;i++)
    {
        cin>>a;
        int cnt=0;
        while (a%2==0)
        {
            cnt++;
            a>>=1;
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var n = next(), d = next();
  var ans = 0;
  var dd = d*d;
  for(var i = 0; i < n; i++){
    var x = next(), y = next();
    if(x*x + y*y <= dd)ans++;
  }
  return ans;
}

Measured memory_bytes: 61808
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x;
    cin, x;
    x -= 400;
    x /= 200;
    print(8 - x);
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
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; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

ll solve(ll h, ll w) {
  ll ans = INF;
  for (int x = 1; x < h; x++) {
    ll a = x * w;
    ll b = ((h - x) / 2) * w;
    ll c = h * w - a - b;
    if (a != 0 && b != 0 && c != 0) chmin(ans, max(max(a, b), c) - min(min(a, b), c));
    b = (h-x) * (w/2);
    c = h * w - a - b;
    if (a != 0 && b != 0 && c != 0) chmin(ans, max(max(a, b), c) - min(min(a, b), c));
  }
  return ans;
}

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

  ll h, w;
  cin >> h >> w;

  if (h > w) swap(h, w);

  if (h % 3 == 0 || w % 3 == 0) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = solve(h, w);
  chmin(ans, solve(w, h));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v); // 再帰的に探索
    }
}

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b,c;
        cin >> a >> b >> c;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    // 全頂点が訪問済みになるまで探索
    int count = 0;
    seen.assign(N, false);
    for (int v = 0; v < N; ++v) {
        if (seen[v]) continue; // v が探索済みだったらスルー
        dfs(G, v); // v が未探索なら v を始点とした DFS を行う
        ++count;
    }
    cout << count << endl;
}

Measured memory_bytes: 10368
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(H: int, W: int, K: int):
    if W == 1:
        print(1)
        return 
    ## dp1[i][j] = H=１の時i->jに行く引き方
    ## 4→5と5→4の弾き方は同じ
    dp1 = [[0]*W for _ in range(W)]

    for i in range(2): 
        for j in range(W):
            # tmp[i][0] = iまでの見た時iに線引いてないものの総数
            # tmp[i][1] = iまでの見た時iに線引いているものの総数
            tmp = [[-1]*2 for _ in range(W-1)]
            if i == 0 or j == W-1: ## j -> j
                tmp[0][0] = 1
                if j == 0:
                    tmp[0][1] = 0
                else: ## 両隣にedgeがあってはいけない
                    if j != W-1: tmp[j][1] = 0
                    tmp[j-1][1] = 0
                    if tmp[0][1] != 0: tmp[0][1] = 1

                for k in range(0,W-2):
                    tmp[k+1][0] = tmp[k][0] + tmp[k][1] ## 前の幅に引いてても引いてなくてもいける
                    if tmp[k+1][1] == -1: 
                        tmp[k+1][1] = tmp[k][0] ## 前の幅に引いてない時のみいける。元々zeroが入ってたらパス
                
                dp1[j][j] = sum(tmp[-1])

            else: # j-> j+1
                if j == 0: 
                    tmp[0][1] = 1
                    tmp[0][0] = 0                    
                else:
                    tmp[j][0] = 0 ## jには絶対引いてなくてはならない
                    if j < W-2: tmp[j+1][1] = 0
                    tmp[j-1][1] = 0
                    if tmp[0][1] != 0:
                        tmp[0][1] = 1
                    tmp[0][0] = 1

                for k in range(0,W-2):
                    if tmp[k+1][0] == -1:
                        tmp[k+1][0] = tmp[k][0] + tmp[k][1] ## 前の幅に引いてても引いてなくてもいける
                    if tmp[k+1][1] == -1: 
                        tmp[k+1][1] = tmp[k][0] ## 前の幅に引いてない時のみいける。元々zeroが入ってたらパス
                dp1[j][j+1] = sum(tmp[-1])


    # dp2[h][w] = 高さhのときにw-1にいる弾き方の総数
    dp2 = [[0]*W for _ in range(H+1)]
    dp2[1] = dp1[0]
    for h in range(1,H):
        for k in range(W):
            if k >= 1 and k < W-1:
                dp2[h+1][k] = dp1[k-1][k]*dp2[h][k-1] + dp1[k][k]*dp2[h][k] + dp1[k][k+1]*dp2[h][k+1]
            elif k>=1:
                dp2[h+1][k] = dp1[k-1][k]*dp2[h][k-1] + dp1[k][k]*dp2[h][k]
            elif k <W-1:
                dp2[h+1][k] = dp1[k][k]*dp2[h][k] + dp1[k][k+1]*dp2[h][k+1]


    print(dp2[H][K-1]%MOD)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(H, W, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3192
a, b, k = map(int, input().split())

if (a - k) < 0: 
    res_a = 0
    if (b + a - k) < 0:
        res_b = 0
    else:
        res_b = b+a-k
else:
    res_b = b
    res_a = a - k
print(str(res_a) + ' ' +str(res_b))        

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  int N,ans=0;
  cin >> N;
  FOR(i,1,N+1){
    int c = 0;
    if(i%2)FOR(j,1,i+1){
      if(i%j == 0){
        c++;
      }
    }
    if(c == 8)ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;

bool compare_by_b(pair<int,string> a, pair<int,string> b) {
	if (a.first != b.first) {
		return a.first > b.first;
	}
	else {
		return a.second < b.second;
	}
}

int main()
{
	ll N,M;
	cin >> N >> M;
	fore(i,0,M){
		ll t;
		cin >> t;
		N=N-t;
	}
	if(N>=0){
		cout << N << endl;
	}
	else{
		cout << "-1" << endl;
	}

}

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

int main(void){
    string s;
    cin >> s;
    int i,j,count;
    for(i = 0;s[i] != 'A';i++);
    for(j = i;j < s.size();j++)if(s[j] == 'Z')count = j;
    cout << count + 1 - i << endl;
}

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))

int main(){
    FAST
    int d, t, s; cin >> d >> t >> s;
    if(s*t >= d){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    long long n;

    cin >> n;

    vector<pair<long long,long long> > v;

    for(long long i = 0 ; i < n ; i++) {

        long long x;

        cin >> x;

        long long y;

        cin >> y;

        v.push_back({x,y});

    }

    long long cnt=0;

    long long res=0;

    for(long long i = 0 ; i < v.size() ; i++) {

        if(v[i].first==v[i].second) {

            cnt++;

        } else {

            res=max(res,cnt);

            cnt=0;

        }

    }

    res=max(res,cnt);

    if(res>=3) {

        cout << "Yes" <<'\n';

    } else {

        cout << "No" <<'\n';

    }

    return 0;

}



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

int main() {
  int n;
  cin >> n;
  vector<int>a(n-1),cnt(n+2);
  rep(i,n){
    cin >> a[i];
    cnt[a[i]]++;
  }
  rep(i,n) cout << cnt[i+1] << endl;
  return 0;
}


Measured memory_bytes: 4840
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val input = readLine()!!.split(" ").map { it.toInt() }
    val inputSorted = input.sortedDescending()

    var restSum = 0
    for (i in 1 until n) {
        restSum += inputSorted[i]
    }

    if (restSum > inputSorted[0]) print("Yes") else print("No")
}


Measured memory_bytes: 38000
def solve(n):
 dp = [9999999]*100005
 dp[0] = 0
 for i in range(1,n+1):
  dp[i] = min(dp[i],dp[i-1]+1)
  tmp = 6
  
  while (i-tmp >= 0):
    dp[i] = min(dp[i],dp[i-tmp]+1)
    tmp *= 6
  tmp2 = 9
  while (i-tmp2 >= 0):
    dp[i] = min(dp[i],dp[i-tmp2]+1)
    tmp2 *= 9
 print(dp[n])

n = int(input())
solve(n)


Measured memory_bytes: 3828
#include <stdio.h>
int main (){
char s[100000];
scanf ("%s",s);
  if (strlen(s)%2==0){
for (int i=0;i<strlen(s)/2;i++){
printf ("%c",s[2*i]);
}
  }
  else{
  for (int i=0;i<(1+strlen(s))/2;i++){
printf ("%c",s[2*i]);
}
  }
return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import collections
import copy


def solve(N: int, A: "List[int]"):
    C = collections.Counter(A)
    S = sum([int(i * (i-1)) / 2 for i in C.values()])
    for k in range(len(A)):
        c = C[A[k]]
        print(int(S - (c * (c-1) / 2) + ((c-1) * (c-2) / 2)))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 36020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 2000000000;

int n;
int l[1000];

int main(){
  cin >> n;
  rep(i, 2*n) cin >> l[i];
  sort(l, l+2*n);
  ll ans = 0;
  rep(i, n) ans += l[2*i];
  cout << ans <<endl;
}
  

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 2005
#define P 998244353
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int n, ans, r[MAXN], b[MAXN], c[MAXN*2][MAXN*2], f[MAXN][MAXN];
char s[MAXN];

int main()
{
    scanf("%s", s+1);
    n=strlen(s+1);
    c[0][0]=1;
    for(rint i=1; i<=n*2; ++i)
        for(rint j=0; j<=i*2; ++j) c[i][j]=(c[i-1][j-1]+c[i-1][j])%P;
    for(rint i=1; i<=n; ++i)
    {
        if(s[i]=='0') r[i]=2;
        if(s[i]=='1') r[i]=b[i]=1;
        if(s[i]=='2') b[i]=2;
        r[i]+=r[i-1], b[i]+=b[i-1];
    }
    f[0][0]=1;
    for(rint i=1; i<=n; ++i)
        for(rint j=max(0, i-b[i]); j<=min(i, r[i]); ++j)
        {
            f[i][j]=(f[i][j]+f[i-1][j])%P;
            if(j) f[i][j]=(f[i][j]+f[i-1][j-1])%P;
        }
    for(rint i=max(0, n-b[n]); i<=min(i, r[n]); ++i) ans=(ans+1LL*c[n][r[n]-i]*f[n][i]%P)%P;
    printf("%d\n", ans);
    return 0;
}

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

int main(){
    
    int a,b,c;
    int k;
    cin >> a >> b >> c >> k;

    for(int i=0; i<k; i++){
        if(a>=b) b*=2;
        else c*=2;
    }
    if(a<b && b<c) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
typedef char Bool;
#define true 39
#define false 0 
typedef long long int64;
typedef unsigned long long uint64;
typedef int int32;
typedef unsigned int uint32;
typedef unsigned char byte;

#include <stdio.h>

int main()
{
	int n;
	scanf("%d", &n);
	int a = n / 1000, b = n % 1000;
	printf("%d", ((b) ? a + 1 : a)*1000-n);
	return 0;
}

Measured memory_bytes: 1732
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

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

    int N, W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    int maxv = 0;
    REP(i, N) {
        cin >> w[i] >> v[i];
        maxv += v[i];
    }

    vector<vector<ll>> dp(N + 1, vector<ll>(maxv + 1, INF32));
    dp[0][0] = 0;

    REP(i, N) {
        REP(sum, maxv + 1) {
            if (sum - v[i] >= 0)
                chmin(dp[i + 1][sum], dp[i][sum - v[i]] + w[i]);
            chmin(dp[i + 1][sum], dp[i][sum]);
        }
    }

    ll ans = 0;
    REP(i, maxv + 1) {
        if (dp[N][i] <= W)
            ans = i;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 80256
import java.util.Scanner;

/**
 * Vampirish Night
 *  URL:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1019&lang=jp
 *
 * @author Igari Kazuya
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ
		Scanner sc = new Scanner(System.in);
		int n,k;
		while(true){
			n = sc.nextInt();
			k = sc.nextInt();

			if(n==0 && k==0){
				break;
			}

			int[][] array = new int[n+1][k];
			for(int i=0;i<n+1;i++){
				for(int j=0;j<k;j++){
					array[i][j] = sc.nextInt();
				}
			}

			for(int i=1;i<n+1;i++){
				for(int j=0;j<k;j++){
					array[0][j] -= array[i][j];
				}
			}

			boolean flag = true;
			for(int i=0;i<k;i++){
				if(array[0][i] < 0){
					flag = false;
				}
			}

			if(flag){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}
	}

}

Measured memory_bytes: 0
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    t=[0]*N
    x=[0]*N
    y=[0]*N
    for i in range(N):
        t[i],x[i],y[i]=map(int,readline().split())

    nt=[]
    nx=[]
    ny=[]
    for i in range(N):
        if i==0:
            nt.append(t[0])
            nx.append(x[0])
            ny.append(y[0])
        else:
            nt.append(t[i]-t[i-1])
            nx.append(x[i]-x[i-1])
            ny.append(y[i]-y[i-1])

    for i in range(N):
        if nt[i]<abs(nx[i])+abs(ny[i]):
            print("No")
            break
        elif nt[i]%2!=(abs(nx[i])+abs(ny[i]))%2:
            print("No")
            break
    else:
        print("Yes")
if __name__=="__main__":
    main()

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    int H[N]; rep(i, N) cin >> H[i];
    int ans = 0;
    while(true){
        int res = 0;
        rep(i, N){
            int temp = i;
            while(i < N && H[i] > 0){
                H[i]--;
                i++;
            }
            if(temp != i) res++;
        }
        if(res == 0) break;
        ans += res;
    }
    cout << ans << endl;
    return 0;
}

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

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y // 2) ** 2 % mod
    else            : return power(x, y // 2) ** 2 * x % mod

mod = 10 ** 9 + 7

N = 10 ** 6
factorial = [1]
for i in range(1, N):
    factorial.append(factorial[i - 1] * i % mod)

inverseFactorial = [0] * N
inverseFactorial[N - 1] = power(factorial[N - 1], mod - 2)
for i in range(N - 2, -1, -1):
    inverseFactorial[i] = inverseFactorial[i + 1] * (i + 1) % mod

def comb(x, y):
    return factorial[x] * inverseFactorial[y] * inverseFactorial[x - y] % mod

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

facts = factorization(m)

if m == 1:
    print(1)
else:
    ans = 1
    for a, b in facts:
        ans *= comb(n+b-1, b)
        ans %= mod
    print(ans)


Measured memory_bytes: 150096
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception{
        boolean[] notPrime = new boolean[1000000];
        int[] counts = new int[1000000];
        for (int i = 2; i < 1000000; i++) {
            counts[i] += counts[i - 1];
            if (notPrime[i]) {
                continue;
            }
            counts[i]++;
            for (int j = 2; i * j < 1000000; j++) {
                notPrime[i * j] = true;
            }
        }
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        while (true) {
            String s = br.readLine();
            if (s == null) {
                break;
            }
            sb.append(counts[Integer.parseInt(s)]).append("\n");
        }
        System.out.print(sb);
    }
}


Measured memory_bytes: 29668
S = input()
l, r =  map(int, [S[:2], S[2:]])

if 1 <= l <= 12 and 1 <= r <= 12:
  print("AMBIGUOUS")
elif 1 <= l <= 12 and (r == 0 or r > 12):
  print("MMYY")
elif (l == 0 or l > 12) and 1 <= r <= 12:
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t,ans;
  cin>>s>>t;
  if (s.size()>t.size()) ans="GREATER";
  else if (s.size()<t.size()) ans="LESS";
  else {
    if (s>t) ans="GREATER";
    else if (s<t) ans="LESS";
    else ans="EQUAL";
  }
  cout<<ans<<endl;
}

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

int main(void){
    int ans, N, n;
    string S;
    cin >> S;
    N = S.size();
    n = 0;
    for(int i = 0; i < N; i++){
        if(i%2 == 0 && S[i] == '0'){
            n++;
        }else if(i%2 == 1 && S[i] == '1'){
            n++;
        }
    }
    ans = n <= N-n ? n : N-n;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
N = int(input())
*a, = map(int, input().split())
colors = [0]*8
top = 0
for i in range(N):
    if a[i] < 3200:
        colors[a[i]//400] += 1
    else:
        top += 1

m = 0
for c in colors:
    if c > 0:
        m += 1
print(max(1, m), m+top)


Measured memory_bytes: 38384
n = int(input())
t,x,y = 0,0,0

for i in range(n):
    T,X,Y = map(int,input().split())
    dt,dx,dy = T-t,abs(X-x),abs(Y-y)
    if dt - (dx + dy) < 0 or (dt - (dx + dy))%2 == 1:
        print("No")
        exit()
    t,x,y = T,X,Y

print("Yes")

Measured memory_bytes: 9144
import scala.io.Source
import scala.annotation.tailrec

object Main{
  def main(args: Array[String]){
    val lines = for{
      in <- Source.stdin.getLines.toVector
    }yield in.toInt

    println(rec(lines.tail, Int.MinValue, Int.MaxValue))
  }

  @tailrec
  def rec(vec: Vector[Int], preMax: Int, preMin: Int): Int ={
    if(vec.length == 1) preMax
    else {
      val min = Math.min(preMin, vec.head)
      rec(vec.tail, Math.max(vec.tail.head - min, preMax), Math.min(preMin, min))
    }
  }
}

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

using namespace std;

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

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

int main() {
    int a, b, h;
    cin >> a >> b >> h;
    int ans = (a + b) * h / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
int n,a[20];
double dp[21][200000],inf=1e10;
int main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n+1) rep(j,200000) dp[i][j]=inf;
	dp[0][1]=0;
	rep(i,n){
		rep1(j,200000-1){
			for(int k=1;k*j<200000;k++){
				double dif=abs((double)(a[i]-k*j)/a[i]);
				dp[i+1][k*j]=min(dp[i+1][k*j],max(dp[i][j],dif));
			}
		}
	}
	double ans=inf;
	rep(j,200000) ans=min(ans,dp[n][j]);
	printf("%.10f\n",ans);
}

Measured memory_bytes: 33984
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
#define INF 2000000000
#define REP(i,b,n) for(int i = (b); i < n; i++)
#define rREP(i,b,n) for(int i = n; i >= b; i--)
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const string lowercase = "abcdefghijklmnopqrstuvwxyz";
const string uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int gcd(int a, int b){return b ? gcd(b, a % b): a;}

int main()
{
    int n;
    cin >> n;
    vi x, y, h, x0, y0;
    REP(i,0,n){
        int xi, yi, hi;
        cin >> xi >> yi >> hi;
        x.push_back(xi); y.push_back(yi); h.push_back(hi);
    }

    REP(cx,0,101){
        REP(cy,0,101){
            vi hcent;
            int hmin = INF;
            REP(i,0,n){
                int ht = h[i]+abs(x[i]-cx)+abs(y[i]-cy);
                hcent.push_back(ht);
                hmin = min(hmin, ht);
            }
            bool valid = true;
            REP(i,0,n){
                if(h[i]>0 && hcent[i]!=hmin) valid = false;
            }
            if(valid){
                printf("%d %d %d\n", cx, cy, hmin);
                return 0;
            }
        }
    }
    return 0;
}


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

class SegmentTree {
private:
	long long Size;
	pair<long long, long long> Unit;
	vector<pair<long long, long long> > Node;
public:
	SegmentTree(long long N, pair<long long, long long> X) : Unit(X) {
		Size = 1;
		while (Size < N) Size *= 2;
		Node.assign(Size * 2, Unit);
	}
	void update(long long L, long long R, long long T, long long X) {
		long long NOWS = Size;
		while (L < R) {
			if (L & 1) {
				Node[L + NOWS] = { T, X };
				L++;
			}
			if (R & 1) {
				Node[R + NOWS - 1] = { T, X };
				R--;
			}
			L >>= 1, R >>= 1, NOWS >>= 1;
		}
	}
	long long query(long long X) {
		long long MAXT = Unit.first, ANS = Unit.second;
		long long NOWS = Size;
		while (NOWS > 0) {
			if (MAXT < Node[X + NOWS].first) {
				MAXT = Node[X + NOWS].first;
				ANS = Node[X + NOWS].second;
			}
			if (X & 1) X--;
			X >>= 1, NOWS >>= 1;
		}
		return ANS;
	}
};

int main() {
	long long N, Q;
	cin >> N >> Q;
	SegmentTree Seg(N, { -1, (1LL << 31) - 1 });
	for (int i = 0; i < Q; i++) {
		long long COM;
		cin >> COM;
		if (COM == 0) {
			long long S, T, X;
			cin >> S >> T >> X;
			Seg.update(S, T + 1, i, X);
		}
		else {
			long long X;
			cin >> X;
			cout << Seg.query(X) << endl;
		}
	}
}


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

int main() {
	int n;
	cin >> n;
	n = n % 10;
	if (n == 3)cout << "bon" << endl;
	else if (n == 0 || n == 1 || n == 6 || n == 8)cout << "pon" << endl;
	else cout << "hon" << endl;
		
	return 0;
}


Measured memory_bytes: 3636