akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

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

    int k;
    cin >> n >> k;
    int a[n];
    rep(i, n)   cin >> a[i];
    
    int kind = 1, cnt = 1;
    
    sort(a, a + n);
    //printArray(a, n);
    
    int num[n]; //それぞれの数の個数（連想配列ではない）
    rep(i, n)   num[i] = 0;
    
    int j = 0;
    FOR(i, 1, n){
        if(a[i - 1] != a[i]){
            kind++;
            num[j] = cnt;
            j++;
            cnt = 1;
        }else    cnt++;
        
        if(i == n - 1)  num[j] = cnt;
    }
    //printArray(num, n);
    sort(num, num + n);
    //printArray(num, n);
    //tmpは文字列にあった数の種類からkを引いた数。
    int tmp = max(kind - k, 0);
    
    int cnt2 = 0, sum = 0;
    for(int i = 0; ; i++){
        if(num[i] == 0) continue;
        if(cnt2 == tmp)    break;
        //cout << num[i] << endl;
        sum += num[i];
        cnt2++;
    }
    
    cout << sum << endl;
}

Measured memory_bytes: 1792
import math

A, B, H, M = map(int, input().split())
theta = (2*math.pi / 12) * H + (2*math.pi / (12*60)) * M - (2*math.pi / 60) * M
C = (A**2 + B**2 - 2*A*B*math.cos(theta))**(1/2)
print(C)

Measured memory_bytes: 9500
#include<iostream>
#include<utility>
#include<vector>
#include<algorithm>
using namespace std;
#define llong long long

int main()
{
   int N, M;
   cin >> N >> M;
   vector<pair<int, int>> drink(N);
   for(int i = 0; i < N; i++)
   {
      cin >> drink[i].first >> drink[i].second;
   }
   sort(drink.begin(), drink.end());
   llong ans = 0;
   for(int i = 0; i < N; i++)
   {
      int buy = min(M, drink[i].second);
      ans += (llong)buy*drink[i].first;
      M -= buy;   
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 1024
#include <stdint.h>
#include <array>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <limits>
#include <tuple>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstdio>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

int main() {
  string S;
  cin >> S;
  int n = count(S.begin(), S.end(), 'N');
  int s = count(S.begin(), S.end(), 'S');
  int e = count(S.begin(), S.end(), 'E');
  int w = count(S.begin(), S.end(), 'W');
  if (n > 0 || s > 0) {
    if (n * s == 0) {
      std::cout << "No" << std::endl;
      return 0;
    }
  }
  if (e > 0 || w > 0) {
    if (e * w == 0) {
      std::cout << "No" << std::endl;
      return 0;
    }
  }
  std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

        final int MAX = 10000002;

        boolean[] isPrime = new boolean[MAX + 1];
        Arrays.fill(isPrime, true);
        isPrime[0] = isPrime[1] = false;

        for (int i = 2; i <= MAX; i++) {
            if ( !isPrime[i] ) {
                continue;
            }
            for (int j = i + i; j <= MAX; j += i) {
                isPrime[j] = false;
            }
        }

        while (sc.hasNextInt()) {
            int N = sc.nextInt();
            int ans = 0;

            for (int p = 3; p <= N; p++) {
                if ( !isPrime[p] ) {
                    continue;
                }

                if ( isPrime[p + 2] ) {
                    ans += 2;
                }
            }

            System.out.println(ans);
        }
    }
}



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

#include <iostream>

inline int min(int x, int y) {return x < y ? x : y;}
inline long min(long x, long y) {return x < y ? x : y;}
inline int max(int x, int y) {return x > y ? x : y;}
inline long max(long x, long y) {return x > y ? x : y;}

using namespace std;

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

    int N = S.length();
    int r = 0, b = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == '0') ++r;
        else if (S[i] == '1') ++b;
    }

    cout << min(r, b) * 2 << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,t[101],m,p[101],x[101],z[101];
    cin>>n;
    for(int i=0;i<n;i++)
        {
            cin>>t[i];
            z[i]=t[i];
        }
    cin>>m;
    for(int i=0;i<m;i++)
        cin>>p[i]>>x[i];
    for(int i=0;i<m;i++)
    {
        z[p[i]-1] = x[i];
        int sum=0;
        for(int i=0;i<n;i++)
        {
            sum+=z[i];
            z[i]=t[i];
        }
        cout<<sum<<endl;
    }
    return 0;
}




Measured memory_bytes: 256
h,w=map(int, input().split())
s=[list(input()) for i in range(h)]

blackCnt=0
for i in s:
  for j in i:
    if j=="#":
      blackCnt+=1


#スタートをキューに格納
q=[[0,0]]
route=[[1,0],[0,1],[-1,0],[0,-1]]
visited = [[0 for i in range(w)] for j in range(h)]
visited[0][0]=1
cnt=0
while q:
  
  for _ in range(len(q)):
    x,y = q.pop(0)
    
    for i in range(4):
      nx, ny = x+route[i][0], y+route[i][1]
      #条件に合致すれば追加
      if 0<=nx<h and 0<=ny<w and visited[nx][ny] == 0 and s[nx][ny] != '#':
        q.append([nx,ny])
        visited[nx][ny]=1
  cnt+=1
  if visited[h-1][w-1]==1:
    print(w*h-cnt-1-blackCnt)
    exit()
print(-1)

Measured memory_bytes: 8844
// #include<iostream>
// using namespace std;
//
// int main(){
//   string s;cin>>s;
//   string ans="AC";
//   ans=s[0]=='A'&&s[2]=='C'?ans:"WA";
//   int cnt=0;
//   int L=s.size()
//   for(int i=1;i<L;i++){
//     if(isupper(s[i])){
//       if(i==1||i==L-1||s[i]!='C'){
//         ans="WA";
//       }
//       cnt++;
//     }
//   }
//   if(cnt!=1){
//     ans="WA";
//   }
//   cout<<ans<<endl;
//   return 0;
// }
#include<iostream>
using namespace std;
int main(){
  string s;cin>>s;
  int l=s.size();
  string ans="AC";
  if(s[0]!='A'){
    ans="WA";
  }
  int cnt=0;
  for(int i=1;i<l;i++){
    if(isupper(s[i])){
      if(i==1||i==l-1||s[i]!='C'){
        ans="WA";
      }
      ++cnt;
    }
  }
  if(cnt!=1){
    ans="WA";
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
from collections import Counter
import math
input = sys.stdin.readline

N = int(input())
s = [input().strip() for _ in range(N)]
ans = []
for word in s:
    temp = []
    for letter in word:
        temp.append(letter)
        temp.sort()
    temp2 = ''
    for value in temp:
        temp2 += value
    ans.append(temp2)
fin = Counter(ans)
out = 0
for value in fin.values():
    if value > 1:
        out += int(math.factorial(value) / math.factorial(value-2) / 2)
print(out)

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

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        sc.close();
        for(int i=1;i<=n;i++){
            if((int)(i*1.08)==n){
                System.out.println(i);
                System.exit(0);
            }
        }
        System.out.println(":(");
    }
}

Measured memory_bytes: 21844
n,t = map(int,input().split())
ct = [list(map(int,input().split())) for _ in range(n)]
ct.sort(key = lambda x:x[1])
ans = 10**9
for path in ct:
  if path[1] > t:
    break
  else:
    ans = min(ans ,path[0])
print(ans if ans != 10**9 else "TLE")
      

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin>>s;
    int l=s.size();
    bool zzz=0;
    for(int i=0;i<l;i++) {
        if(s[i]=='C') {
            for(int j=i+1;j<l;j++) {
                if(s[j]=='F') {
                    zzz=1;
                }
            }
        }
    }
    if(zzz==1) {
        cout<<"Yes";
    } else {
        cout<<"No";
    }
}

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

int main() {

	int N;
  int ans=0;
  cin >> N;
  vector<int> VV(N);
  vector<int> CC(N);
  for (int i = 0; i<N; i++){
    cin >> VV.at(i);
  }
  for (int i = 0; i<N; i++){
    cin >> CC.at(i);
  }
  for (int i=0; i<N; i++){
    if ( VV.at(i) - CC.at(i) > 0){
      ans = ans + VV.at(i) - CC.at(i);
    }
  }
  cout << ans << endl;
  
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define sz(x) ((int)(x).size())

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
const ll MOD = 1000000007;
//const ll MOD = 998244353;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.12lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

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


//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; 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;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}

ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}

//約数の列挙O(√n)
vector<ll> divisor(ll n){
    vector<ll> res(0);
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            if(i != n/i) res.push_back(n/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

void solve(){
  ll a, b, c;
  cin >> a >> b >> c;
  if(c - a - b < 0){
    cout << "No" << endl;
    return;
  }
  if(4 * a * b < (c - a - b) * (c - a - b)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 3005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int ri[MAXN],f[2][MAXN];
int N,M;
char s[MAXN];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &x,int y) {
    x = inc(x,y);
}
void Solve() {
    read(N);read(M);
    scanf("%s",s + 1);
    int l,r;
    for(int i = 1 ; i <= M ; ++i) {
	read(l);read(r);
	ri[l] = max(ri[l],r);
    }
    int p = 0,all = 0;
    int cur = 0;
    f[cur][0] = 1;
    
    for(int i = 1 ; i <= N ; ++i) {
	if(p < i - 1) {p = i - 1;}
	if(ri[i] > p) {
	    all += ri[i] - p;
	    int a = 0,b = 0;
	    for(int j = p + 1 ; j <= ri[i] ; ++j) {
		if(s[j] == '0') ++a;
		else ++b;
	    }
	    p = ri[i];
	    memset(f[cur ^ 1],0,sizeof(f[cur ^ 1]));
	    for(int j = a ; j <= N ; ++j) f[cur ^ 1][j] = f[cur][j - a];
	    cur ^= 1;
	}
	if(!all) continue;
	memset(f[cur ^ 1],0,sizeof(f[cur ^ 1]));
	for(int j = 0 ; j <= all ; ++j) {
	    if(j < all) update(f[cur ^ 1][j],f[cur][j]);
	    if(j >= 1) update(f[cur ^ 1][j - 1],f[cur][j]);
	}
	--all;
	cur ^= 1;
    }
    out(f[cur][0]);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int red=0,blue=0;
  string c;
  cin >> c;
  for(int i=0;i< c.size();i++){
    if(c[i] == '0')red++;
    else blue++;
  }
  //cout << red << blue << " ";
  cout << 2 * min(red,blue) << endl;
  return 0;
}


Measured memory_bytes: 512
program Spp
    implicit none
    integer(16),allocatable :: a(:)
    integer :: n, i
    integer(16) :: ans = 0, t = 0
    read *, n
    allocate(a(n))
    read *, a(1:n)
    t = sum(a(1:n))
    do i = 1, n-1
        t  = t - a(i)
        ans = ans + t * a(i)
    end do
    ans = mod(ans, 1000000007)
    print *, ans
end program

Measured memory_bytes: 6172
from itertools import permutations

n = int(input())
xy = []
for i in range(n):
    x, y = map(int, input().split())
    xy.append((x, y))

# xy = [(x, y) for (x, y) in map(int, input().split())]

# print(xy)

path_length = 0
pxy = permutations(xy)
c = 0

for p in pxy:
    c += 1
    for (x1, y1), (x2, y2) in zip(p, p[1:]):
        path_length += ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
ans = path_length / c
# print(c)
print(ans)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;

ll largestAreaHistogram(vi v){
  ll N=v.size();
  stack<pii> st; st.push({0,v[0]});
  ll ans=v[0];
  FOR(i,1,N) {
    ll tmp=i;
    while(st.size()&&st.top().second>v[i]) {
      ans=max(ans,st.top().second*(i-st.top().first));
      tmp=st.top().first;
      st.pop();
    }
    st.push({tmp,v[i]});
  }
  while(st.size()) {ans=max(ans,st.top().second*(N-st.top().first)); st.pop();}
  return ans;
}

int main(){
  ll N; cin>>N;
  vi h(N); REP(i,N) cin>>h[i];
  cout<<largestAreaHistogram(h)<<endl;
}

Measured memory_bytes: 6124
N = int(input())
data = {}
for i in range(1, N + 1):
  s, p = input().split()
  p = int(p)
  if s in data.keys():
    data[s][p] = i
  else:
    data[s] = {p : i}

for s in sorted(data.keys()):
  for p in reversed(sorted(data[s].keys())):
    print(data[s][p])


Measured memory_bytes: 3064
/*----------------by syr----------------*/
/*
  -----  -----  -----
  |   |  |---|    _/
  |   |  | \_    /
  -----  |   \  -----

  |---\  \   /  |\  /|
  |   |   \_/   | \/ |
  |   |   / \   |    |
  |---/  /   \  |    |
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i,x,y) for(int i=(x);i<(y);++i)
#define REP(i,x,y) for(int i=(x);i<=(y);++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pii;

const int INF=1e9+7;
const int maxn=305;

int n;
int a[maxn],num[3];
double dp[maxn][maxn][maxn];

int main(){
	scanf("%d",&n);
	FOR(i,0,n) scanf("%d",a+i),++num[a[i]];
	dp[0][0][0]=0;
	REP(sum,0,n){
		REP(k,0,n){
			REP(j,0,n){
				int i=sum-k-j;
				if(!i&&!j&&!k) continue;
				if(i<0||j<0||k<0) continue;
				dp[i][j][k]+=1.0*n/(i+j+k);
				if(i) dp[i][j][k]+=1.0*i/(i+j+k)*(dp[i-1][j][k]);
				if(j) dp[i][j][k]+=1.0*j/(i+j+k)*(dp[i+1][j-1][k]);
				if(k) dp[i][j][k]+=1.0*k/(i+j+k)*(dp[i][j+1][k-1]);
//				printf("i=%d j=%d k=%d %.10f\n",i,j,k,dp[i][j][k]);
			}
		}
	}
	printf("%.10lf\n",dp[num[1]][num[2]][num[3]]);
	return 0;
}


Measured memory_bytes: 219392
import sys
 
while True:
    h, w = [ int( val ) for val in sys.stdin.readline().split( " " ) ]
    if 0 ==h and 0 == w:
        break
    pa = [ "#", "." ]
    ouput = []
    for i in range( h ):
        for j in range( w ):
            ouput.append( pa[(i+j)&1] ) 
        ouput.append( "\n" )    
    print( "".join( ouput ) )

Measured memory_bytes: 7004
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

int64_t A;
double_t B;

void solve()
{
    std::cin >> A >> B;
	int64_t ans = (A * int64_t(B * 100 + 0.5)) / 100;
	std::cout << ans << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

pint a[100001];
ll ans[100001];
int main(){
    int n,ai;
    cin>>n;
    rep(i,n){
        cin>>ai;
        a[i]=mp(ai,i);
    }
    sort(a,a+n,greater<pint>());
    int mn=1000100010;
    FOR(i,1,n+1){
        mn=min(a[i-1].second,mn);
        ans[mn]+=(ll)i*(a[i-1].first-a[i].first);
    }
    rep(i,n) cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 2688
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vint cnt(26,INF);
    vector<string> s(n);
    REP(i,n){
        cin >> s[i];
    }
    REP(k,26){
        char c = ('a'+k);
        REP(i,n){
            int t = 0;
            for(char ci : s[i]){
                if(ci==c){
                    t++;
                }
            }
            cnt[k] = min(cnt[k], t);
        }
    }
    REP(k,26){
        REP(i,cnt[k]){
            cout << (char)('a'+k);
        }
    }
    cout << endl;

    return 0;
}

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

int main(void) {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int n = 5;

	vector<int> time{a, b, c, d, e};
	vector<int> nextTime(5);
	for (int i = 0; i < n; i++) {
		if(time[i] % 10 == 0) nextTime[i] = time[i];
		else nextTime[i] = time[i] - time[i] % 10 + 10;
		// nextTime[i] = (time[i] + 9) / 10 * 10;
	}
	int bestTime = 1e9;
	for (int i = 0; i < n; i++) {
		int sumTime = 0;
		for (int j = 0; j < n; j++) {
			if (i == j) {
				sumTime += time[j];
			} else {
				sumTime += nextTime[j];
			}
		}
		bestTime = min(bestTime, sumTime);
	}
	cout << bestTime << endl;
	return 0;
}

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

using namespace std;


vector< int > g[150000];
double ee[150000], ans[1500000];

void dfs1(int idx, int par)
{
  double ret = 0;
  int child = 0;

  for(int &to : g[idx]) {
    if(to == par) continue;
    dfs1(to, idx);
    ret += ee[to];
    ++child;
  }
  ee[idx] = 1;
  if(child >= 1) ee[idx] += ret / child;
}

void dfs2(int idx, double d_par, int par)
{
  vector< pair< int, int > > d_child;
  double ret = 0;
  for(int &to : g[idx]) {
    if(to == par) ret += d_par;
    else ret += ee[to];
  }
  ans[idx] = ret / g[idx].size();
  for(int &to : g[idx]) {
    if(to == par) continue;
    dfs2(to, 1.0 + (ret - ee[to]) / max(1, (int) g[idx].size() - 1), idx);
  }
}

int main()
{
  int N;
  cin >> N;
  for(int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  dfs1(0, -1);
  dfs2(0, 0, -1);
  for(int i = 0; i < N; i++) {
    cout << fixed << setprecision(10) << ans[i] << endl;
  }
}

Measured memory_bytes: 20096
//# pragma GCC optimize("Ofast,no-stack-protector")
//# pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
# pragma GCC optimize("Ofast")
# pragma GCC optimization ("unroll-loops")
# include "bits/stdc++.h"
/*
# include <ext/pb_ds/tree_policy.hpp>
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/rope>
*/
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

/*
using namespace __gnu_pbds;
using namespace __gnu_cxx;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
Tree<int>tr;
*/

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# define LOCAL
# define sim template < class c
# define ris return * this
# define dor > debug & operator <<
# define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define show(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int gcd(int a, int b)
{
if(b) return gcd(b,a%b);
return a;
}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int32_t main(){_
	//freopen("input","r",stdin);
	int n;
	cin >> n;
	rc(n * n * n);
	return 0;
}











Measured memory_bytes: 892
def solve():
    S = input()
    non_x = ''
    num_x = []
    cnt = 0
    for s in S:
        if s == 'x':
            cnt += 1
        else:
            non_x += s
            num_x.append(cnt)
            cnt = 0
    num_x.append(cnt)
    if non_x != non_x[::-1]:
        return -1
    N = len(num_x)
    ans = 0
    for i in range(N):
        ans += abs(num_x[i]-num_x[-i-1])
    return ans//2
print(solve())


    



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

P p[500000];
int calc(P*a, int n) {
	if (n == 1)return INT_MAX;
	int x = a[n / 2].first;
	int d = min(calc(a, n / 2), calc(a + n / 2, n - n / 2));
	inplace_merge(a, a + n / 2, a + n, [](const P&a, const P&b) {return a.second < b.second; });
	rep(i, n) {
		if (abs(a[i].first - x)*abs(a[i].first - x) >= d)continue;
		for (int j = i + 1; j < n; j++) {
			int dx = a[i].first - a[j].first;
			int dy = a[i].second - a[j].second;
			if (dy*dy >= d)break;
			d = min(d, dx*dx + dy*dy);
		}
	}
	return d;
}
int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d%d", &p[i].first, &p[i].second);
	sort(p, p + n);
	printf("%d\n", calc(p, n));
}

Measured memory_bytes: 12544
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]


N, K = map(int, input().split())
if K % 2 == 1:
    hoge = N // K
    print(hoge * hoge * hoge)
else:
    hoge = N // K
    half = hoge
    if K * hoge + K // 2 <= N:
        half += 1

    ans = hoge * hoge * hoge
    ans += half * half * half
    print(ans)


Measured memory_bytes: 3060
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val nmx = inputs(0).split(" ").map(_.toInt)
  val n = nmx(0)
  val m = nmx(1)
  val x = nmx(2)
  val books = inputs.tail.map(_.split(" ").map(_.toInt))

  println(solve(n, m, x, books))

  def solve(n: Int, m: Int, x: Int, books: Seq[Array[Int]]): Int = {
    var minPrice = Int.MaxValue
    // n冊を、全組み合わせ出す
    (1 to n).foreach { i =>
      books.combinations(i).foreach { booksComb =>
        val understanding = scala.collection.mutable.ArrayBuffer.fill(m)(0)
        var price = 0
        booksComb.map { book =>
          price = price + book.head
          book.tail.zipWithIndex.foreach { case (point, i) =>
            understanding.update(i, understanding(i) + point)
          }

          if(understanding.filter(_ < x).size == 0 && minPrice > price) {
            minPrice = price

          }
        }
      }
    }

    if(minPrice == Int.MaxValue) {
      -1
    } else {
      minPrice
    }
  }
}

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

int main() {
    char s[12];
    fgets(s, 12, stdin);
    int length = strlen(s);
    s[length] = '\0';
    int min = 1000;
    for (int i=0; i<length-3; i++) {
        int buf = 100 * (s[i] - '0') + 10 * (s[i+1] - '0') + s[i+2] - '0';
        int buf2 = abs(buf - 753);
        if (buf2 < min) min = buf2;
    }
    printf("%d\n", min);
    return 0;
}


Measured memory_bytes: 128
H, W = map(int, input().split())
S = [input() for _ in range(H)]

L = [[0]*W for _ in range(H)]
R = [[0]*W for _ in range(H)]
U = [[0]*W for _ in range(H)]
D = [[0]*W for _ in range(H)]

for h in range(H):
    for w in range(W):
        if S[h][w] == "#":
            L[h][w] = 0
        elif w == 0:
            L[h][w] = 1
        else:
            L[h][w] = L[h][w-1]+1

        if S[h][W-w-1] == "#":
            R[h][W-w-1] = 0
        elif W-w-1 == W-1:
            R[h][W-w-1] = 1
        else:
            R[h][W-w-1] = R[h][W-w]+1

        if S[h][w] == "#":
            U[h][w] = 0
        elif h == 0:
            U[h][w] = 1
        else:
            U[h][w] = U[h-1][w]+1

        if S[H-h-1][w] == "#":
            D[H-h-1][w] = 0
        elif H-h-1 == H-1:
            D[H-h-1][w] = 1
        else:
            D[H-h-1][w] = D[H-h][w]+1

light_num = [[0]*W for _ in range(H)]
for h in range(H):
    for w in range(W):
        light_num[h][w] = L[h][w]+R[h][w]+U[h][w]+D[h][w]

print(max([max(l) for l in light_num])-3)


Measured memory_bytes: 211716
n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
b = list(set(a))
b.sort(reverse=True)
l = len(b)
c = [0 for _ in range(l)]
prei = b[0]
j = 0
for i in a:
    if i != prei:
        j += 1
    c[j] += 1
    prei = i
x = []
for i in range(l):
    if c[i] >= 2:
        x.append(b[i])
    if c[i] >= 4:
        x.append(b[i])
if len(x) >= 2:
    ans = x[0] * x[1]
    print(ans)
else:
    print(0)


Measured memory_bytes: 14672
#include <bits/stdc++.h>
#define int long long
#define INT_MAX INT64_MAX
#define INT_MIN INT64_MIN
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcount
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
        factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int fun(int num){
    int ans = 0;
    int temp = 5;
    while(num/temp){
        ans += num/temp;
        temp *= 5;
    }
    return ans;
}
vector<int> v[100001];
bool visited[100001];
int level[100001];
int parent[100001];
int levelchild[100001];
int n, x, y;
void dfs(int node){
    visited[node] = true;
    levelchild[node] = level[node];
    for(int i=0; v[node].size()>i; i++){
        if(!visited[v[node][i]]){
            parent[v[node][i]] = node;
            level[v[node][i]] = level[node] + 1;
            dfs(v[node][i]);
            levelchild[node] = max(levelchild[node], levelchild[v[node][i]]);
        }
    }
}
signed main(){
    cin >> n >> x >> y;
    if(x == y){
        cout << 0 << endl;
        return 0;
    }
    for(int i=0; n-1>i; i++){
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    level[y] = 0;
    parent[y] = y;
    dfs(y);
    int mx = 0;
    int p = x;
    int pivot = 0;
    while(level[x] - level[p] < level[p] - level[y]){
        if(levelchild[p] >= mx){
            if(levelchild[p] != mx){
                pivot = p;
            }
            mx = levelchild[p];
            p = parent[p];
        }else{
            break;
        }
    }
    int ans = mx-1;
    cout << ans << endl;
}



Measured memory_bytes: 13568
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  string S;
  std::cin >> S;
  bool flag = true;
  for(int i=1;i<=S.size();i++){
    if(i%2==1&&S[i-1]=='L')flag = false;
    if(i%2==0&&S[i-1]=='R') flag = false;
  }
  std::cout << (flag?"Yes":"No") << '\n';
  return 0;
}


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

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    int n, x, t;
    cin>>n>>x>>t;
    cout<<t*(n/x + (n%x!=0))<<endl;
    return 0;
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)

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

int main(void) {
    int n, k, num, ans;
    array<int, 200000> a = {0};
    cin >> n >> k;
    REP(i, n){
        cin >> num;
        a[num]++;
    }
    sort(a.begin(), a.end(), greater<int>());

    ans = 0;
    REP(i, n){
        if(i+1 > k && a[i] >= 1) ans+=a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int dp[50];

int fib(int n) {
    if (n == 0 || n == 1) {
        return dp[n] = 1;
    }
    if (dp[n] != -1) {
        return dp[n];
    }
    return dp[n] = fib(n - 1) + fib(n - 2);
}

int main() {
    int n, i;
    for (i = 0; i < 50; i++) {
        dp[i] = -1;
    }
    
    scanf("%d", &n);
    printf("%d\n", fib(n));
    
    return 0;
}


Measured memory_bytes: 2140
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int h,w;
  for(int i=0; i<10000; i++) {
      cin >> h >> w;
      if(h==0&&w==0) {
          return 0;
      }
      for(int j=0; j<h; j++) {
          for(int k=0; k<w; k++) {
              if(j==0||j==h-1||k==0||k==w-1) {
                  cout << "#";
              }
              else {
                  cout << ".";
              }
          }
          cout << endl;
      }
      cout << endl;
  }
}


Measured memory_bytes: 3108
import java.util.*;

public class Main{
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String w = sc.next();
	int app[] = new int[26];
	Arrays.fill(app,0);
	for ( int i = 0; i < w.length(); i++ ) {
	    app[w.charAt(i)-'a']++;
	}
	boolean f = true;
	for ( int i = 0; i  < 26; i++ ) {
	    if ( app[i] % 2 == 1 ) {
		f = false;
		break;
	    }
	}
	if(f) System.out.println("Yes");
	else System.out.println("No");
    }
}


Measured memory_bytes: 23764
from decimal import Decimal
N = int(input())
X = []
btc_rate = Decimal("380000.0")
for _ in range(N):
    x, u = list(input().split())
    X.append([Decimal(str(x)), u])

ans = 0
for i in range(N):
    amount = X[i][0]
    unit = X[i][1]
    if unit == 'JPY':
        ans += amount
    else:
        ans += btc_rate * amount

print(ans)

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

using namespace std;

const int maxN = 2e5 + 100;
const int module = 1e9 + 9;

void enter()
{
    freopen("solve.inp","r",stdin);
    freopen("solve.out","w",stdout);
}
void solve()
{
   int a, b;
   cin >> a >> b;
   for (int i = 0; i <= 100; i++) {
       if (i * a - (i - 1) >= b) {
        cout << i;
        return;
       }
   }
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //enter();
    solve();
}


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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <queue>
#include <stack>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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 gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

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

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  REP(i, n) cin >> p[i];
  REP(i, x+10){
    int x1 = x - i;
    int x2 = x + i;
    bool flag = false;
    bool flag2 = false;
    REP(j, n){
      if (p[j] == x1) flag = true;
    }
    if (!flag){
      cout << x1 << endl;
      return 0;
    }
    REP(j, n){
      if (p[j] == x2) flag2 = true;
    }
    if (!flag2){
      cout << x2 << endl;
      return 0;
    }}
  return 0;
}



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

int main() {

  long long X;
  cin >> X ;

    long long i=1;
    long long tot=100;
    while(true){
        tot=tot+tot/100;

        if(tot >= X){
            cout << i << endl;
            break;

        }
        i++;
    }


  
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

const ll mod = 1000000007ll;
ll modpow(ll x, ll y, ll m){
    if(y == 0ll)return 1ll;
    ll res = 1ll, tmp = x;
    while(y){
        if(y&1) res = res * tmp % m;
        tmp = tmp * tmp % m;
        y >>= 1;
    }
    return res;
}
ll pom(ll x, ll y){return modpow(x, y, mod);}
int prime[1001001];
bool is_prime[1001001];
int sieve(int n){
    int p = 0;
    for(int i=0; i<=n; i++)is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for(int i=2; i<=n; i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j = 2*i; j<=n; j+=i)is_prime[j] = false;
        }
    }
    return p;
}

int n, a, b[1001001];
ll ans = 0, lcm = 1;

int main(){
    sieve(1001001);
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d", &a);
        int j=2, m = a;
        while(j*j <= m){
            if(is_prime[j]){
                if(m % j == 0){
                    int cnt = 0;
                    while(m % j == 0){
                        cnt++;
                        m /= j;
                    }
                    if(cnt > b[j]){
                        ll tmp = pom(j, cnt-b[j]);
                        ans = ans * tmp % mod;
                        lcm = lcm * tmp % mod;
                        b[j] = cnt;
                    }
                }
            }
            j++;
        }
        if(m > 1 && b[m] == 0){
            ans = ans * m % mod;
            lcm = lcm * m % mod;
            b[m] = 1;
        }
        ans = (ans + lcm*pom(a, mod-2)%mod) % mod;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 6016
#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int b;
  cin >> b;
  for(int i=0;i<s.size()-1;i++){
    int c = 'z'-s[i]+1;
    if(s[i]!='a'&&c<=b){
      s[i] = 'a';
      b -= c;
    }
  }
  b %= 26;
  for(int i=0;i<b;i++){
    if(s[s.size()-1]=='z') s[s.size()-1] = 'a';
    else s[s.size()-1]++;
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 512
N, X, Y = gets.split.map{|i|i.to_i}
dist = Array.new(N - 1){0}
N.times{|i|
    (i + 1 .. N - 1).each{|j|
        #warn "i%dj%d" % [i, j]
        d = j - i
        s = (X  - 1 - i).abs + (Y  - 1 - j).abs + 1
        #warn "d%ds%d" % [d, s]
        if d < s
            dist[d - 1] += 1
        else
            dist[s - 1] += 1
        end
    }
}
#warn dist.inspect
puts dist


Measured memory_bytes: 1788
from collections import Counter


n = int(input())
a = list(map(int, input().split()))
c = Counter(a) # Count num and construct dictionary
c = sorted(c.items(), key=lambda x:x[0]) # align key
ans = 0
isOK = [True] * (10**6+1)

for k, v in c:
    if not isOK[k]:
        continue

    if v > 1:
        for i in range(k, len(isOK), k):
            isOK[i] = False
        continue

    ans += 1
    for i in range(2*k, len(isOK), k):
        isOK[i] = False

print(ans)

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

using namespace std;
using lint = long long;

int main(void)
{
	lint N, M;
	cin >> N >> M;
	lint sum = 0;
	if (N == 1 && M == 1){
		sum = 1;
	}
	else if (N == 1){
		sum = M - 2;
	}
	else if(M == 1){
		sum = N - 2;
	}
	else{
		sum = (M - 2) * (N - 2);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace B.Cakes_and_Donuts
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            int ans = 0;

            for (int i = 0; i <= N; i += 4)
                for (int j = 0; j <= N - i; j += 7)
                    if ((i + j) == N)
                    {
                        ans++;
                        break;
                    }

            if (ans > 0)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13140
#include  <stdio.h>

int main (void)
{
	int x,y;
	
	while(1){
		
		scanf("%d %d\n",&x,&y);
		
		if( x<y ){
			printf("%d %d\n",x,y);
		}
		else if( x==0 && y ==0 ){
			break;
		}else{
			printf("%d %d\n",y,x);
		}
		}
	}

Measured memory_bytes: 604
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for (int i=(n)-1;i>=0;i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define REPS(i,f,n) for (int i=(f)-1;i>=(n);i--)
const int mod = 1e9;

bool flag[100100];
int num[100100];
int main(void){
	int n, m; cin >> n >> m;
	vint x(m), y(m);
	rep(i, m){
		int tmp1, tmp2; cin >> tmp1 >> tmp2;
		tmp1--; tmp2--;
		x[i] = tmp1; y[i] = tmp2;
	}
	rep(i, 100100){
		num[i] = 1;
		flag[i] = false;
	}
	flag[0] = true;
	// printf("-------\n");
	for (int i = 0; i < m; ++i){
		int s = x[i], d = y[i];
		// printf("%d %d\n", s, d);
		if(flag[s] == true && num[s] >= 2){
			// printf("1\n");
			flag[d] = true;
			num[s]--; num[d]++;
		}else if(flag[s] == true && num[s] == 1){
			// printf("2\n");
			flag[d] = true; flag[s] = false;
			num[s]--; num[d]++;
		}else{
			// printf("3\n");
			num[s]--; num[d]++;
		}
	}

	ll ans = 0;
	rep(i, 100100){
		// printf("%d\n", i);
		// if(flag[i]) printf("%d true %d\n", i, num[i]);
		if(flag[i] == true && num[i] >= 1) ans++;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1536
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());

        final int mx = 1100001;
        int hurui[] = new int[mx];

        for (int i = 2;i < Math.sqrt(mx);i++) {
            int ni = i;
            ni += i;
            while(ni < mx) {
                hurui[ni]++;
                ni+=i;
            }
        }

        for(int i=n;i<mx;i++) {
            if(hurui[i] == 0) {
                System.out.print(i);
                break;
            };
        }

    }
}

Measured memory_bytes: 40496
#include<iostream>
#include<algorithm>
using namespace std;
constexpr auto maxn=200005;
string a[maxn];
int b[maxn];
int main() {
	int n,cnt=0;
	int max1 = -1;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		b[i] = 1;
	}
	sort(a + 1, a + n + 1);
	for (int i = 2; i <= n; i++) {
		if (i == n && a[n - 1] == a[n])
			b[n] = cnt + 2;
		if (a[i] == a[i - 1]) {
			cnt++;
			b[i - 1] = 0;
		}
		
		else {
			b[i - 1] = cnt+1;
			cnt = 0;
		}
	}
	for (int i = 1; i <= n; i++) {
		max1 = max(max1, b[i]);
	}
	for (int i = 1; i <= n; i++) {
		if (b[i] == max1)
			cout << a[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 15104
n = int(input())

def divisor(n: int) -> list:
    list_of_divisor = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            list_of_divisor.append(i)
            if i != n//i:
                list_of_divisor.append(n//i)
    # list_of_divisor.sort()
    return list_of_divisor

ans = 0
for i in range(1, n+1, 2):
    li = divisor(i)
    if len(li) == 8:
        ans += 1

print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define max_n 1000000

using namespace std;

void solve()
{
	string s;
	cin>>s;
	if(s=="ABC")cout<<"ARC"<<endl;
	else cout<<"ABC"<<endl;
}

int32_t main() 
{
	IOS	
	ll T=1;
	// cin>>T;
	for(ll i=1;i<=T;++i)
	{		
		// cout<<"Case #"<<i<<": ";
    	solve();
	}
	return 0;
}

Measured memory_bytes: 3612