akhauriyash/Code-Regression huggingface dataset:
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::*;
use std::iter::FromIterator;
use num::integer;

fn main() {
    input! {
        a: [usize]
    }

    let mut primes = vec![2, 3, 5, 7, 11];
    'b: for i in 13..=999 {
        for &p in &primes {
            if i % p == 0 {
                continue 'b;
            }
        }
        primes.push(i);
    }

    let mut factor = std::collections::HashSet::new();

    let mut pw = true;

    'c: for &n in &a {
        let mut mn = n;
        for &p in &primes {
            if mn % p == 0 {
                if factor.contains(&p) {
                    pw = false;
                    break 'c;
                } else {
                    factor.insert(p);
                }
                while mn % p == 0 {
                    mn /= p;
                }
            }
        }

        if mn != 1 && factor.contains(&mn) {
            pw = false;
            break 'c;
        } else {
            factor.insert(mn);
        }
    }

    let gcd = a.iter().copied().fold1(integer::gcd).unwrap();

    if pw {
        println!("pairwise coprime");
    } else if gcd == 1 {
        println!("setwise coprime");
    } else {
        println!("not coprime");
    }
}


Measured memory_bytes: 17548
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    for(ll k = K; k <= N + 1; k++){
        ans += (((N - k + 1) * k) % mod + 1) % mod;
        ans %= mod;
        //cout << ans << "\n";
    }
    cout << ans;
    return 0;
}

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

int main () {
  int N;
  cin >> N;
  
  vector<int> d(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  
  int result = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      result += d.at(i) * d.at(j);
    }
  }
  
  cout << result;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using i64 = long long;
  
int const MAXN=1100;
int const DX[]={-1,0,1,0};
int const DY[]={0,-1,0,1};
int const OP[]={2,3,0,1};

int n,m,a,b;
int f[MAXN][MAXN];
int was[MAXN][MAXN];
int T;

bool findpair(int x,int y) {
  if (was[x][y]==T) return false;
  was[x][y]=T;
  rep(i,0,4) {
    int px=x+DX[i];
    int py=y+DY[i];
    int pp;
    a-=i%2==1;
    b-=i%2==0;
    if (px<0 || px==n || py<0 || py==m || a<0 || b<0) { goto cont; }
    pp=f[px][py];
    if (pp!=-1) {
      int nx=px+DX[pp];
      int ny=py+DY[pp];
      if (nx<0 || nx==n || ny<0 || ny==m) { throw; }
      a+=pp%2==1;
      b+=pp%2==0;
      if (!findpair(nx,ny)) {
        a-=pp%2==1;
        b-=pp%2==0;
        goto cont;
      }
    }

    f[x][y]=i;
    f[px][py]=OP[i];
    return true;

    cont:
    a+=i%2==1;
    b+=i%2==0;
  }
  return false;
}
  
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);
  
  cin>>n>>m>>a>>b;
  memset(f,~0,sizeof(f));
  
  if (n%2==1) {
    int t=min(a,m/2);
    rep(i,0,t) {
      f[n-1][i*2]=3;
      f[n-1][i*2+1]=1;
    }
    a-=t;
  }
  if (m%2==1) {
    int t=min(b,n/2);
    rep(i,0,t) {
      f[i*2][m-1]=2;
      f[i*2+1][m-1]=0;
    }
    b-=t;
  }
  
  rep(i,0,n/2) rep(j,0,m/2) {
    if (a==0) {
      if (b>0) {
        b-=1;
        f[i*2][j*2]=2;
        f[i*2+1][j*2]=0;
      }
      if (b>0) {
        b-=1;
        f[i*2][j*2+1]=2;
        f[i*2+1][j*2+1]=0;
      }
    }
  
    if (a>0) {
      a-=1;
      f[i*2][j*2]=3;
      f[i*2][j*2+1]=1;
    }
    if (a>0) {
      a-=1;
      f[i*2+1][j*2]=3;
      f[i*2+1][j*2+1]=1;
    }
  }

  rep(i,0,n) rep(j,0,m) {
    if ((i+j)%2==1 && (a>0 || b>0) && f[i][j]==-1) { T+=1, findpair(i,j); }
  }

  if (a>0||b>0) {
    // cerr<<"NO"<<endl;
    cout<<"NO"<<endl;
    return 0;
  }

  // cerr<<"YES"<<endl;
  cout<<"YES\n";
  rep(i,0,n) {
    rep(j,0,m) {
      switch (f[i][j]) {
        case 0:  cout<<'v'; break;
        case 1:  cout<<'>'; break;
        case 2:  cout<<'^'; break;
        case 3:  cout<<'<'; break;
        default: cout<<'.';
      }
    }
    cout<<'\n';
  }
  
  return 0;
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = (s); i < (n); i++)

struct Node { int parent, left, right; };
Node T[100001];
int depth[100001];

void rec(int u, int p) {
  depth[u] = p;
  if(T[u].right != -1) rec(T[u].right, p);
  if(T[u].left != -1) rec(T[u].left, p+1);
}

void print(int u) {
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].parent << ", ";
  cout << "depth = " << depth[u] << ", ";
  if(T[u].parent == -1) cout << "root";
  else if(T[u].left == -1) cout << "leaf";
  else cout << "internal node";
  cout << ", [";
  for(int i = 0, c = T[u].left; c != -1; i++, c = T[c].right) {
    if(i) cout << ", ";
    cout << c;
  }
  cout << "]" << "\n";
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  int n, v, k, c, l, r;
  cin >> n;
  rep(i, 0, n) T[i].parent = T[i].left = T[i].right = -1;
  rep(i, 0, n) {
    cin >> v >> k;
    rep(j, 0, k) {
      cin >> c;
      if(j == 0) T[v].left = c;
      else T[l].right = c;
      l = c;
      T[c].parent = v;
    }
  }
  rep(i, 0, n) {
    if(T[i].parent == -1) r = i;
  }
  rec(r, 0);
  rep(i, 0, n) print(i);
}


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

typedef struct {int max; int min;} MMpair;

MMpair maxmin(vector<int> data, int left, int right);

MMpair maxmin(vector<int> data, int left, int right){
    MMpair tmp;
    MMpair ll, rr;

    if((right - left) <= 1){
        if(data[left] > data[right]){
            tmp.max = data[left];
            tmp.min = data[right];
        }else{
            tmp.max = data[right];
            tmp.min = data[left];
        }
        return tmp;
    }

    ll = maxmin(data, left, (right - left) / 2 + left);
    rr = maxmin(data, (right - left) / 2 + left + 1, right);

    if(ll.max > rr.max) tmp.max = ll.max;
    else tmp.max = rr.max;

    if(ll.min < rr.min) tmp.min = ll.min;
    else tmp.min = rr.min;

    return tmp;
}

int main(){
    int n;

    while(cin >> n, n != 0){
        vector<int> exam;
        MMpair result;
        for(int i=1; i<=n; i++){
            int sum = 0;
            for(int j=1; j<=5; j++){
                int tmp;
                cin >> tmp;
                sum += tmp;
            }
            exam.push_back(sum);
        }
        result = maxmin(exam, 0, exam.size()-1);
        cout << result.max << " " << result.min << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main() {
	int n, a[200005], i, t;
	long long s = 0;
	scanf("%d %d", &n, &t);
	for(i = 1; i <= n; i++) scanf("%d", &a[i]);
	for(i = 2; i <= n; i++) {
		if(a[i] - a[i - 1] < t) s += a[i] - a[i - 1];
		else s += t;
	 }
	 printf("%lld\n",  s +  t);
	 return 0;
}
			

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define all(a)  a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define _for(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

using namespace std;

int N, M, A, B;

long long factorial[300005];

long long Power(long long base, long long expo){
    long long res = 1;
    while(expo > 0){
        if(expo % 2 == 1){
            res = (res * base) % mod;
        }
        expo >>= 1;
        base = (base * base) % mod;
    }
    return res % mod;
}

void init(){
   factorial[0] = 1ll;
   for(int n = 1; n <= 300000; ++n){
      factorial[n] = (factorial[n - 1] * n) % mod;
   }
}

long long get(int x, int y){
   x -= 1;
   y -= 1;
   long long p = factorial[x + y];
   long long q = Power(factorial[x], mod - 2);
   long long r = Power(factorial[y], mod - 2);
   p = p * q;
   p %= mod;
   p = p * r;
   p %= mod;
   return p;
}

int main(){
   cin >> N >> M >> A >> B;   
   long long res = 0ll;
   init();
   for(int n = 1; n <= N - A; ++n){
      res += (get(n, B) * get(N - n + 1, M - B)) % mod;
      res %= mod;
   }
   cout << res << endl;
   return 0;
}

Measured memory_bytes: 2560
def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

A, B = map(int, input().split())

def checker(n): # int => int list
    s = format(n, 'b')
    l = len(s)
    res = [0]*l
    for i in range(l):
        if i == l - 1:
            hoge = n // 4
            if n == hoge * 4 + 1 or n == hoge * 4 + 2:
                res[i] = 1
        else:
            if s[i] == "1":
                res[i] = (int(s[i+1:], 2) + 1) % 2
    return res

a = checker(A-1) if A > 0 else [0]
b = checker(B)

if len(a) < len(b):
    tmp = a
    a = b
    b = tmp

b = [0 for _ in range(len(a) - len(b))] + b

ans = ""
for i in range(len(a)):
    ans += str(a[i] ^ b[i])
ans = int(ans, 2)
print(ans)


Measured memory_bytes: 38384
N = input()
Len = abs(len(N))
Fir = N[Len-1]
if Fir=="2" or Fir=="4" or Fir=="5" or Fir=="7" or Fir=="9":
    print("hon")
if Fir=="0" or Fir=="1" or Fir=="6" or Fir=="8":
    print("pon")
if Fir=="3":
    print("bon")

Measured memory_bytes: 8988
#include <vector>
#include <cstdio>
using namespace std;
typedef pair<int,int>pii;
main(){
	int n,x,i,q;
	for(;scanf("%d%d",&n,&x),n;printf("%d\n",x)){
		vector<pii>v;
		v.push_back(make_pair(x,1));
		for(i=1;i<n;i++){
			pii p=v.back();
			scanf("%d",&x);
			if(x==p.first)v.back().second++;
			else if(v.pop_back(),i&1){
				if(q=0,v.size())q=v.back().second,v.pop_back();
				v.push_back(make_pair(x,q+p.second+1));
			}else{
				v.push_back(p),v.push_back(make_pair(x,1));
			}
		}
		for(x=i=0;i<v.size();i++)if(!v[i].first)x+=v[i].second;
	}
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(int _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 300

using namespace std;

int n, Ma, Mb, Mc; double dn;
double d[maxn+5][maxn+5][maxn+5];///EV pt a manca NU ajunge in a,b,c
bool viz[maxn+5][maxn+5][maxn+5];

double idiv (int a, int b) {
  double d = (1.0*a)/(1.0*b);
  return d;
}

double Dp (int a, int b, int c) {
  if (a == 0 && b == 0 && c == 0) return 0.0;
  if (max({a,b,c}) > n) return 0.0;
  if (viz[a][b][c]) return d[a][b][c];
  viz[a][b][c] = 1;
  d[a][b][c] = idiv(n, a+b+c);
  if (a > 0) d[a][b][c] += idiv(a,a+b+c)*Dp(a-1,b,c);
  if (b > 0) d[a][b][c] += idiv(b,a+b+c)*Dp(a+1,b-1,c);
  if (c > 0) d[a][b][c] += idiv(c,a+b+c)*Dp(a,b+1,c-1);
  return d[a][b][c];
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  int i, j, x, z;
  for (i = 0; i < n; i++) {
    cin >> x;
    if (x == 1) Ma++;
    if (x == 2) Mb++;
    if (x == 3) Mc++;
  }
  cout << fixed << setprecision(12) << Dp(Ma,Mb,Mc);
  return 0;
}


Measured memory_bytes: 174592
#include <stdio.h>
int prime(int x){
  int i;
  if(x < 2) return 0;
  if(x == 2) return 1;
  if(x % 2 == 0) return 0;
  for(i = 3;i * i <= x;i += 2)
    if(x % i == 0) return 0;
 
  return 1;
}
 
int main(){
  int   i,n, c = 0, a;
  scanf("%d", &n);
  for(i = 0;i < n;i++){
    scanf("%d", &a);
    c += prime(a);
  }
  printf("%d\n", c);
  return 0;
}


Measured memory_bytes: 2096
#include <iostream>
#include <algorithm>
#define INF (2 << 28)
using namespace std;

int main(){

  int n, num[101][101], sum[101][101] = {0};
  
  cin >> n;
  for(int i = 0; i < n; i++)
    for(int j = 0; j < n; j++)
      cin >> num[i][j];
  
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + num[i - 1][j - 1];
    }
  }

  int res = -INF;
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      for(int k = i; k <= n; k++){
        for(int l = j; l <= n; l++){
          res = max(res, sum[k][l] - sum[i-1][l] - sum[k][j-1] + sum[i-1][j-1]);
        }
      }
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 1248
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,m=map(int,input().split())
    edges=[[] for _ in range(n)]
    for _ in range(m):
        s,t=map(int,input().split())
        s-=1; t-=1
        edges[s].append(t)

    # 確率DP
    p=[0]*n
    p[0]=1.0
    for v in range(n):
        for nv in edges[v]:
            p[nv]+=p[v]/len(edges[v])

    # 期待値DP
    E=[0]*n
    for v in range(n-2,-1,-1):
        for nv in edges[v]:
            E[v]+=E[nv]
        E[v]=1+E[v]/len(edges[v])

    ans=E[0]
    for v in range(n):
        if(len(edges[v])<=1): continue
        # 各vに対して、辺vwのうちE[w]が最大のものを削除する
        w=max(*((E[w],w) for w in edges[v]))[1]
        dE=0
        deg=len(edges[v])
        for nv in edges[v]:
            if(nv==w): dE-=E[nv]/deg
            else: dE+=E[nv]/(deg-1)/deg
        ans=min(ans,E[0]+p[v]*dE)

    print(ans)
resolve()

Measured memory_bytes: 53980
N = int(input())
A = [int(i) for i in input().split()]
INF = 2 * 10 ** 5
dp = [0] * INF
ans = 0
for i in range(N):
    i_i_ = i + 1 - A[i]
    if 0 < i_i_ < INF:
        ans += dp[i_i_]
    i_ = i + 1 + A[i]
    if 0 < i_ < INF:
        dp[i_] += 1

print(ans)

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

ll MOD = 998244353;

// s2 >= s1?
bool compare_strs(int K, vi& s1, vi& s2) {
    for(int i=0;i<K;i++) {
        if (s2[i] > s1[i]) return true;
        if (s2[i] < s1[i]) return false;
    }
    return true;
}

bool check_pref(int K, vi& X, int N) {
    vi pref(K);
    vi nstr(N);
    for (int i=0;i<N/K;i++) {
        for (int j=0;j<K;j++) {
            if (i%2 == 0) nstr[K*i + j] = X[j];
            else nstr[K*i + j] = 1-X[j];
        }
    }
    return compare_strs(N, nstr, X);
}

ll eval_pref(int K, vi& X) {
    ll pow = 1;
    ll ans = 0;
    for (int i=K-1;i>=0;i--) {
        if (X[i] == 1) {
            ans += pow;
            ans %= MOD;
        }
        pow *= 2;
        pow %= MOD;
    }
    return ans;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N;
    cin >> N;
    string Xs;
    cin >> Xs;

    vi X(N);
    for (int i=0;i<N;i++) X[i] = Xs[i] - '0';

    vi ofacs;
    vll ocnts;
    for (int i=1;i<=N;i+=2) {
        if (N%i == 0) {
            ofacs.push_back(N/i);

            ll cnt = eval_pref(N/i, X);
            if (check_pref(N/i, X, N)) cnt++;
            //cout << N/i << " " << cnt << endl;
            ocnts.push_back(cnt);
        }
    }

    reverse(ofacs.begin(), ofacs.end());
    reverse(ocnts.begin(), ocnts.end());

    ll ans = 0;

    for(int i=0;i<ofacs.size();i++) {
        for(int j=i+1;j<ofacs.size();j++) {
            if (ofacs[j] % ofacs[i] == 0) {
                ocnts[j] -= ocnts[i];
                ocnts[j] = (ocnts[j] + MOD) % MOD;
            }
        }

        ans += 2*ofacs[i]*ocnts[i];
        ans %= MOD;
    }

    cout << ans << endl;




    return 0;
}

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

typedef struct{
  char name[10];
  int time;
} process;

int main(){
  int head=0,end,ead,count=0,n,q;
  process* p;
  int i;
  scanf("%d%d",&n,&q);
  end=n;
  p=(process*)malloc(sizeof(process)*(n+1));
  for(i=0;i<n;i++){
    scanf("%s",p[i].name);
    scanf("%d",&p[i].time);
  }
  while(head!=end){
    if(p[head].time<=q){
      count+=p[head].time;
      p[head].time=0;
      printf("%s %d\n",p[head].name,count);
    }
    else{
      p[head].time-=q;
      count+=q;
    }
    head++;
    if(head==n+1)
      head=0;
    if(head==0)
      ead=n;
    else
      ead=head-1;
    if(p[ead].time!=0){
      p[end]=p[ead];
      end++;
    }
    if(end==n+1)
      end=0;
  }  
  return 0;
}

Measured memory_bytes: 1384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 1000; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j])%mod;
//       }
//     }
//   }
//   return 0;
// }


// int factorial(int n){
//   if(n == 0) return 1;
//   return n*factorial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   pascal_triangle();
//   return memo[n][k];
// }

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}







//二項係数(mod剰余)----------------------------

// const int MAX = 3000010;
// const int M = 1000000007;

// vector<ll> fac(MAX); //n!(mod M)
// //a,bの範囲的にこれだけ配列を用意していけば十分
// vector<ll> ifac(MAX); //k!^{M-2} (mod M)

// ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//     ll ans = 1;
//     while(n != 0){
//         if(n&1) ans = ans*x % M;
//         x = x*x % M;
//         n = n >> 1;
//     }
//     return ans;
// }

// ll COMinit(){
//   //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
//   fac[0] = 1;
//   ifac[0] = 1;
//   for(ll i = 0; i<MAX; i++){
//     fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
//     ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
//   }
//   return 0;
// }

// ll COM(ll a, ll b){ //aCbをmod計算
//   if(a == 0 && b == 0)return 1;
//   if(a < b || a < 0)return 0;
//   ll tmp = ifac[a-b]* ifac[b] % M;
//   return tmp * fac[a] % M;
// }

//-----------------------------------------



int main(){
  ll H;
  cin >> H;
  ll K = 0;
 
  while(1){
    H/=2;
    if(H) K++;
    else break;
  }
  ll ans = pow(2,K+1) -1 ;
  printf("%lld\n",ans);
  return 0;
}




Measured memory_bytes: 384
from collections import deque

def divider(m):
  i = 1
  s = deque()
  g = deque()
  while i**2 < m:
    if m % i == 0:
      s.append(i)
      g.appendleft(m//i)
    i += 1
  if i**2 == m:
    s.append(i)
  s += g
  return s
        

N, M = map(int, input().split())
D = divider(M)
ans = 0
for d in D:
  if d*N <= M:
    ans = d
  else:
    break
print(ans)

Measured memory_bytes: 3316
/*input
bus

*/


 
#include <bits/stdc++.h>
using namespace std;
 
 
 
#define int long long int
#define rep(i,n) \
    for(int i = 0; i < n; i++)
#define rep2(i, a, b) \
    for(int i = a; i < b; i++)
#define all(c) \
    c.begin(), c.end()
#define init(arr, num) \
    memset(arr, num, sizeof(arr))
#define fast\
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inputFile \
    freopen("input.txt", "r", stdin); 
#define outputFile \
    freopen("output.txt", "w", stdout);
#define modM 1000000007
#define PI 3.1415926535897932
#define F first
#define S second  
#define pb push_back  
#define INF 3e18
#ifdef gaviria
#define TRACE
#endif
#ifdef TRACE
#define trace(...) _f(#VA_ARGS, __VA_ARGS_)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
 
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< ll, ll > ii;
typedef unordered_set<int> usi;
 
 
 
ll n,i,j,k,m,c;

void solve()
{
   string a;
   cin>>a;
   if(a[a.size()-1]=='s')
   {
    a=a+"es";
   }
   else a=a+"s";
   cout<<a;
  }

 
 
 
signed main()
{// inputFile;


    fast;
    int T = 1;
    // cin >> T;
    ll h=T;
    while(T--){
 
        solve();
        cout<<endl;
 
     
        
        
 
    }
    
    
    return 0;
 
}

Measured memory_bytes: 3648
#include<stdio.h>




int main()
{
	int pm ,pe ,pj ;

	int n ;
	while( scanf( "%d" ,&n ) )
	{
		if( n == 0 )
		{
			return 0 ;
		}


		while( n-- )
		{
			scanf( "%d %d %d" ,&pm ,&pe ,&pj ) ;



			if(

				( pm > 99 || pe > 99 || pj > 99 ) ||
				( pm + pe >= 180 		) ||
				( pm + pe + pj >= 240		)

								)
			{
				puts( "A" ) ;
			}


			else if(
					( pm + pe + pj >= 210 				) ||
					( pm + pe + pj >= 150 && ( pm > 79 || pe > 79 ) )

											)
			{
				puts( "B" ) ;
			}


			else
			{
				puts( "C" ) ;
			}
		}
	}
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define PF first
#define PS second
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;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 100000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main() {
  IN(ld,N);
  N /= 3;
  ld ans = N*N*N;
  std::cout << std::fixed;
  OUT(ans);
}



Measured memory_bytes: 256
#include <cstdio>

int main (void) {
    int h, w;
    scanf ("%d %d", &h, &w);
    int cnt = 0;
    for (int i = 1; i <= h; ++i) {
        getchar ();
        for (int j = 1; j <= w; ++j) {
            char ch = getchar ();
            if (ch == '#') ++cnt;
        }
    }
    puts ((cnt == h + w - 1) ? "Possible" : "Impossible");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  map<int,int> mp;

  for (int i = 1; i <= 4; ++i) {
    mp[i] = 0;
  }
  for (int i = 0; i < 3; ++i) {
    int a,b;
    cin >> a >> b;
    mp[a] += 1;
    mp[b] += 1;
  }

  for (auto itr : mp) {
    if (itr.second == 0 or itr.second > 2) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int64_t GetLayer(int64_t n) {
    return std::pow(2, n + 2) - 3;
}

int64_t GetPatty(int64_t n) {
    return std::pow(2, n + 1) - 1;
}

int64_t solve(int64_t n, int64_t x) {
    if (n == 0) {
        return (x > 0) ? 1 : 0;
    } else if (x == 1)
        return 0;
    else if (x <= GetLayer(n - 1) + 1) {
        return solve(n - 1, x - 1);
    } else if (x == 2 + GetLayer(n - 1)) {
        return GetPatty(n - 1) + 1;
    } else if (2 + GetLayer(n - 1) < x && x <= GetLayer(n - 1) * 2 + 2) {
        return GetPatty(n - 1) + 1 + solve(n - 1, x - 2 - GetLayer(n - 1));
    } else if (x = 3 + 2 * GetLayer(n - 1)) {
        return GetPatty(n - 1) * 2 + 1;
    }
}

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    int64_t n;
    int64_t x;
    cin >> n >> x;
    if (n == 0) {
        cout << 1 << endl;
        return 0;
    }
    cout << solve(n, x) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pr pair<ll, ll>
#define tp tuple<ll, ll, ll>
using namespace std;
long long int mod = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n, m;
    cin >> n >> m;
    ll a[n], sum = 0;
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    sort(a, a + n);
    reverse(a, a + n);
    ll flag = 0;
    double val = (double)sum / (4 * (double)m);
    for (ll i = 0; i < m; i++)
    {
        if ((double)a[i] < val)
            flag = 1;
    }
    if (flag == 1)
        cout << "No\n";
    else
        cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys
n,m = map(int,input().split())
 
turo = [[] for i in range(n)]
q = deque()
his = [False]*n
for i in range(m):
    a,b = map(int,input().split())
    turo[a-1].append(b-1)
    turo[b-1].append(a-1)
 
par = [i for i in range(n)]
rank = [sys.maxsize for i in range(n)]
rank[0] = 0
q.append(0)
 
while len(q) > 0:
    #print(q)
    room = q.popleft()
    
    if not his[room] :
        his[room] = True
    else:
        continue
    for room2 in turo[room]:
        if rank[room] < rank[room2]:
            q.append(room2)
            par[room2] = room
            rank[room2] = rank[room]+1
 
if len(his) < n:
    print("No")
    exit()
 
print("Yes")
for i in range(1,n):
    print(par[i]+1)

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

int main() {
    int x, a, b;
    cin >> x >> a >> b;

    if(min(abs(a - x), abs(b - x)) == abs(a - x)) cout << "A" << endl;
    else cout << "B" << endl;

    return 0;
}

Measured memory_bytes: 256
m = input()
b = input()
x = int(0)
a = list()

n, m = m.split(' ')
n = int(n)
m = int(m)

b = b.split(' ')
for i in range(len(b)):
    a.append(int(b[i]))

list.sort(a, reverse = True)

for i in range(len(a)):
    x += int(a[i])

for i in range(m):
    if int(a[i]) < x / (4 * m):
        print('No')
        exit()

print('Yes')


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

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

  int ans = 0;
  ll size = S.size();
  for (ll i = 0; i < size; i++) {
    ans = (ans + (S[i] - '0')) % 9;
  }
  cout << (ans ? "No" : "Yes") << endl;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int fun(int n){
    if(n%2==0){
        return n/2;
    }
    else{
        return 3*n+1;
    }
}
int main(){
    int s;
    cin>>s;
    set<int> ans;
    ans.insert(s);
    int n=s,i;
    for(i=0;i!=ans.size();i++){
        ans.insert(fun(n));
        n=fun(n);
    }
    cout<<i+1<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	while(true){
	int n;
	cin >> n;
	if(n == 0) return 0;
	string S;
	cin >> S;
	for(int q=0; q<n; q++){
		string next = "";
		int now = 0;
		char l = '-';
		for(int i=0; i<S.size(); i++){
			if(S[i] != l){
				if(now > 0) next+= to_string(now) + l;
				l = S[i];
				now = 0;
			}
			now++;
		}
		if(now > 0) next+= to_string(now) + l;
		S = next;
	}
	cout << S << endl;
	}

	return 0;
}



Measured memory_bytes: 3336
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  vector<int> a(3);
  for (int i = 0; i < 3; ++i) cin >> a[i];
  sort(a.begin(), a.end(), greater<int>());
  int ret = max(a[0] + 10 * a[1] + a[2], a[0] * 10 + a[1] + a[2]);
  cout << ret << endl;
  return 0;
}


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

typedef long long int ll;

void solve1(ll a, ll b, ll c, const vector<string> &inputs, vector<char> &ans) {
    vector<char> f(0);
    for (int i = 0; i < (int)inputs.size(); i++) {
        if (inputs[i] == "AB") {
            if (a == b && i < (int)inputs.size() - 1) {
                if (inputs[i+1] == "AC") {
                    a++; b--; ans.push_back('A');
                } else {
                    a--; b++; ans.push_back('B');
                }
            } else if (a > b) {
                a--; b++; ans.push_back('B');
            } else {
                a++; b--; ans.push_back('A');
            }
        } else if (inputs[i] == "AC") {
            if (a == c && i < (int)inputs.size() - 1) {
                if (inputs[i+1] == "AB") {
                    a++; c--; ans.push_back('A');
                } else {
                    a--; c++; ans.push_back('C');
                }
            } else if (a > c) {
                a--; c++; ans.push_back('C');
            } else {
                a++; c--; ans.push_back('A');
            }
        } else {
            if (b == c && i < (int)inputs.size() - 1) {
                if (inputs[i+1] == "AB") {
                    b++; c--; ans.push_back('B');
                } else {
                    b--; c++; ans.push_back('C');
                }
            } else if (b > c) {
                b--; c++; ans.push_back('C');
            } else {
                b++; c--; ans.push_back('B');
            }
        }
        if (a < 0 || b < 0 || c < 0) {
            ans = f;
            return;
        }
    }
    return ;
}

void solve2(ll a, ll b, ll c, const vector<string> &inputs, vector<char> &ans) {
    vector<char> f(0);
    for (int i = 0; i < (int)inputs.size(); i++) {
        if (inputs[i] == "AB") {
            if (a > b) {
                a--; b++; ans.push_back('B');
            } else {
                a++; b--; ans.push_back('A');
            }
        } else if (inputs[i] == "AC") {
            if (a > c) {
                a--; c++; ans.push_back('C');
            } else {
                a++; c--; ans.push_back('A');
            }
        } else {
            if (b > c) {
                b--; c++; ans.push_back('C');
            } else {
                b++; c--; ans.push_back('B');
            }
        }
        if (a < 0 || b < 0 || c < 0) {
            ans = f;
            return;
        }
    }
}


int main () {
    ll n, a, b, c; cin >> n;
    cin >> a >> b >> c;
    vector<string> inputs(n);
    for (int i = 0; i < n; i++) {
        cin >> inputs[i];
    }
    vector<char> ans;
    if (a + b + c == 2) {
        solve1(a, b ,c, inputs, ans);
    } else {
        solve2(a, b, c, inputs, ans);
    }
    if (ans.size() == 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        for (int i = 0; i < (int)ans.size(); i++){
            cout << ans[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5500
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String []args)
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        if(d==25)
            System.out.println("Christmas");
        else if(d==24)
            System.out.println("Christmas Eve");
        else if(d==23)
            System.out.println("Christmas Eve Eve");
        else if(d==22)
            System.out.println("Christmas Eve Eve Eve");

    }
}


Measured memory_bytes: 21332
from math import gcd

n = int(input())
a = list(map(int, input().split()))
l = [a[-1], a[0]]
r = [a[-1]]
for x in a[1:-1]:
    l.append(gcd(l[-1], x))
for x in a[-2:0:-1]:
    r.append(gcd(r[-1], x))
r = r[::-1]
r.append(a[0])
print(max(gcd(l[i], r[i]) for i in range(n)))

Measured memory_bytes: 21788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
int  A1,A2,A3;
cin>>A1>>A2>>A3;
if(A1+A2+A3>=22){
  cout<<"bust"<<"\n";
}
else{
  cout<<"win"<<"\n";
}
return 0;
}

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

int stoi(std::string);
std::string itos(int);

int main(){
    int sum,digits[200]={0};
    std::string input,output;


    std::ios::sync_with_stdio(false);

    input = "";
    for (int i=0;i<200;i++){
        sum = 0;

        for (int j=0;j<2;j++){
            if((int)std::cin.eof()) goto end;
            std::cin >> input;
            sum += stoi(input);
        }
        output = itos(sum);
        digits[i] = (int)output.length();
    }
    end:
    for (int i=0;digits[i];i++){
        std::cout << digits[i] << std::endl;
    }
}

int stoi(std::string s){
    std::stringstream ss;
    int i;
    ss << s;
    ss >> i;
    return i;
}

std::string itos(int i){
    std::stringstream ss;
    std::string str;
    ss << i;
    ss >> str;
    return str;
}

Measured memory_bytes: 3116
N = int(input())
a_list = list(map(int, input().split()))
a_list.sort(reverse=True)

res = 0

for i in range(N):
    if i % 2 == 0:
        res += a_list[i]
    if i % 2 == 1:
        res -= a_list[i]

print(res)


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

int up(int *a , int *b){
  return *(int *)a - *(int *)b;
}

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

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

  qsort(a,n,sizeof(int),up);
  int dai = a[n/2] , syo = a[n/2 -1];
  
  for(int i = 0;i < n;i ++){
    if(b[i] >= dai){
      printf("%d\n",syo);
    }
    else if(b[i] <= syo){
      printf("%d\n",dai);
    }
  }
   return 0;
}

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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

// bool lunlun(int i)
// {
//     int last = i%10;
//     i/=10;
//     while(i)
//     {
//         int rem = i%10;
//         if(abs(rem-last) > 1)
//         {
//             return false;
//         }
//         last = rem;
//         i/=10;
//     }
//     return true;
// }

int findnex(int a)
{
    vector<int> ans;
    while(a)
    {
        int rem = a%10;
        ans.pb(rem);
        a/=10;
    }

    // reverse(ans.begin(),ans.end());
    int flag = -1;
    f1(i,0,ans.size()-1)
    {
        if( abs (ans[i]+1-ans[i+1])  <2 && ans[i]<9)
        {
            ans[i]++;
            flag = i;
            break;
        }
    }
    if(flag == -1 && ans[ans.size()-1]<9)
    {
        flag = ans.size()-1;
        ans[ans.size()-1]++;
    }
    if(flag!=-1)
    {
        f2(i,flag-1,0)
        {
            ans[i] = max(0ll, ans[i+1]-1);
        }
        int num = 0;
        f2(i,ans.size()-1,0)
        {
            num*=10;
            num+=ans[i];
        }
        return num;
    }
    else
    {
        int num = 10;
        f2(i,ans.size()-2,0)
        {
            num*=10;
            num+=0;
        }
        return num;
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    cin>>k;
    int a[k+1];
    a[1] = 1;
    f1(i,2,k+1)
    {
        a[i] = findnex(a[i-1]);
        // cout<<i<<gp<<a[i]<<endl;
    }
    cout<<a[k]<<endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

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

  Scanner sc;
  int N = 0;
  int answer = 0;

  // 標準入力用のコンストラクタ
  public Main(Scanner sc) {
    this.sc = sc;
    N = sc.nextInt();
  }

  // 判定処理
  int solve() {
      for (int i = 0; i < N; ++i){
        answer += i+1;  //１人目の子供(配列の要素数0)→１個・・・N人目の子供(配列の要素数N-1)→N個
      }
      
      return answer;
  }

  // 回答の表示
  void show(int answer) {
        System.out.println(answer);
      
  }
    
}

Measured memory_bytes: 35760
#include<iostream>
#include<queue>

using namespace std;
typedef pair<int,int> P;
int main(){
	int n,q; cin >> n >> q;
	n++;	
	int a[n];
	priority_queue<P> p;
	
	for(int k=0;k<n+1;k++){
		a[k] = 0;
	}

	int s,v;
	for(int i=0;i<q;i++){
		cin >> s >> v;
		a[s] += v;
		p.push(P(a[s],-s));

		for(;;){
			P t = p.top();
			if(t.first == a[-t.second]){
			cout << -t.second << " " << t.first << endl; break; }
			p.pop();
		}
	}
return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int n, x;
    cin >> n >> x;

    vector<int> m(n);
    rep(i, n) cin >> m[i];
    sort(all(m));

    int su = 0;
    rep(i, n) su += m[i];

    cout << n + (x - su) / m[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define pii pair<int, int>
#define plli pair <lli, lli>
#define F(i,n) for(lli (i)=0;(i)<(n);(i)++)
#define FR(i,n) for(lli (i)=(n)-1;(i)>=0;(i)--)
#define FSG(i,a,b) for(lli (i)=(a);(i)<(b);(i)++)
#define FSGR(i,a,b) for(lli (i)=(b)-1;(i)>=(a);(i)--)
#define VAL(n) cout << n << endl;
#define VALD(n) cout << #n << ": " << n << endl;

int main(){
  int N;
  cin >> N;
  int h[N];
  int flag = true;
  int cnt = 0;
  F(i,N){
    cin >> h[i];
    if(i!=0){
      if(h[i] < h[i-1]){
        cnt++;
      }
      else if (h[i] > h[i-1]){
        cnt = 0;
      }
      if(h[i-1] - h[i] > 1){
        flag = false;
      }
      if(cnt > 1){
        flag = false;
      }
    }
  }

  if(flag){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <stdlib.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
typedef long double ld;
signed main(){
string s;
cin >> s;
if(s=="ABC"){
    cout << "ARC";
}else{
    cout << "ABC";
}

}

Measured memory_bytes: 3624
#include<stdio.h>
#include<math.h>

int ispn(int x){
  int i;
  if(x < 2) return 0;
  else if(x == 2) return 1;//2は素数
  if(x%2 == 0) return 0;//偶数は除外
  for(i=3; i*i<= x;i+=2){
    if(x%i == 0) return 0;
}
  return 1;
}

int main(){
  int n,i,p,cnt=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&p);
    if(ispn(p)) cnt++;
      }
  printf("%d\n",cnt);
}




Measured memory_bytes: 2032
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def II():int(input())

def main():
    a,b=MI()
    if a+b>=10:
        print("error")
    else:
        print(a+b)
main()

Measured memory_bytes: 3060
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let [n,a,b]=nrin(3)
  // let a=nin()
  out(min(n*a, b))
}
main()

Measured memory_bytes: 7372
#include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

int table[10][10];
int solve(int r,int c,int *rdata,int *cdata){
  bool ur[10]={false},uc[10]={false};
  int ret = 0;

  rep(i,r){
    rep(j,c){
      if ( ur[i] == false && uc[j]==false && 
	   rdata[i]==cdata[j])ret+=rdata[i],ur[i]=uc[j]=true;
    }
  }

  rep(i,r)if(ur[i] == false)ret+=rdata[i];
  rep(i,c)if(uc[i]==false)ret+=cdata[i];
  return ret;
}


main(){
  int r,c;
  int rdata[10],cdata[10];
  while(cin>>r>>c && r){
    rep(i,r)cin>>rdata[i];
    rep(j,c)cin>>cdata[j];
    cout << solve(r,c,rdata,cdata)<<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
int dp[100003]={},vis[100003]={},ans=0;
vector<int> adj[100003];
int dfs(int curr)
{
  if(vis[curr]==1) { return dp[curr]; }
  else
    {
      // cout<<curr<<"\n";
      vis[curr]=1;
    }
      for(int child:adj[curr])
      {
        dp[curr]=max(dp[curr],1+dfs(child));
      }
      ans=max(ans,dp[curr]);
      // cout<<"curr="<<curr<<"dp="<<dp[curr]<<"\n";
      return dp[curr];
    // }
}
int32_t main()
{  ios_base::sync_with_stdio(false); cin.tie(NULL);
   int i,n,m,x,y;cin>>n>>m;
   for(i=0;i<m;i++)
  {
    cin>>x>>y;
    adj[x].push_back(y);
  }
  for(i=1;i<=n;i++)
  {if(vis[i]!=1) dfs(i);}
  cout<<ans;
}


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

int main() {
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  int max = 0;
  int j;
  for (int i = 0; i <= n - 2; i++) {
    if (max < a.at(i + 1) - a.at(i)) {
      max = a.at(i + 1) - a.at(i);
      j = i;
    }
  }
  int sum = 0;
  if (max < k - a.at(n - 1) + a.at(0))
    cout << k - (k - a.at(n - 1) + a.at(0)) << endl;
  else
    cout << k - (a.at(j + 1) - a.at(j)) << endl;
}

Measured memory_bytes: 1024