akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)
 
//int dxy[5] = {0, 1, 0, -1, 0};
// cmd
 
signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
 
    Int(n);
    std::cout << (n / 500) * 500 << std::endl;
    return 0;
}


Measured memory_bytes: 3216
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        if (num == 3 || num == 5 || num == 7) WriteLine("YES");
        else WriteLine("NO");
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  ll H, W;
  cin >> H >> W;

  cout << (H == 1 || W == 1 ? 1 : (H * W + 1) / 2) << endl;

  return 0;
}


Measured memory_bytes: 256
def is_prime(n):
    d = n - 1
    d = d // (d & -d)
    L = [2, 7, 61] if n < 1 << 32 else [2, 3, 5, 7, 11, 13, 17] if n < 1 << 48 else [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1:
            continue
        while y != n - 1:
            y = y * y % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1


def prime_factor(n):
    if n == 1:
        return {1: 1}

    pf = dict()
    r = list(range(2, n + 1))

    while n != 1:
        x = r[0]
        cnt = 0
        while n % x == 0:
            n = n // x
            cnt += 1
        if cnt > 0:
            pf[x] = cnt
        r = list(filter(lambda y: y % x != 0, r))

    return pf


def main():
    from collections import defaultdict
    n = int(input())
    d = defaultdict(int)
    for i in range(1, n + 1):
        p = prime_factor(i)
        for k, v in p.items():
            d[k] += v
    
    f2_, f4_, f14_, f24_, f74_ = 0, 0, 0, 0, 0
    for i in d.values():
        if i >= 2:
            f2_ += 1
        if i >= 4:
            f4_ += 1
        if i >= 14:
            f14_ += 1
        if i >= 24:
            f24_ += 1
        if i >= 74:
            f74_ += 1

    ans = f74_ + f24_ * (f2_ - 1) + f14_ * (f4_ - 1) + f4_ * (f4_ - 1) * (f2_ - 2) // 2
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


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

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long
int A,B;
//here begins your code

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

map<int,int> prime_factor(int n){
	map<int,int> ret;
	for(int i = 2; i * i <= n; i++){
		while(n % i == 0){
			ret[i]++;
			n /= i;
		}
	}
	if(n!=1){
		ret[n] = 1;
	}
	return ret;
}

signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> A >> B;
  int g = gcd(A,B);
  map<int,int> res = prime_factor(g);
  cout << res.size() + 1 << endl;
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define pi 3.14159265358979

int main(void) {
  double a, b, c, d, s;
  scanf("%lf%lf%lf", &a, &b, &c);
  c = c / 180 * pi;
  d = sqrt(a * a + b * b - 2 * a * b * cos(c));
  s = a * b / 2 * sin(c);
  printf("%f\n%f\n%f\n", s, a + b + d, s * 2 / a);
  return 0;
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define mo 1000000007
using namespace std;
int n,x,f[10005];
int main(){
	scanf("%d",&n);
	f[0]=1;
	for (int i=1;i<=n;i++){
		scanf("%d",&x);
		for (int j=10000;j>=x;j--)
			f[j]|=f[j-x];
	} 
	for (int i=10000;i;i--)
		if (f[i]&&i%10)
			return printf("%d",i),0;
	puts("0");
} 

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
int par[100000];
int height[100000];
int card[100000];
void init(int n){
  for(int i = 0; i < n; i++){
    par[i] = i;
    height[i] = 0;
    card[i] = 1;
  }
}

int root(int x){
  if(x == par[x]){
    return x;
  } else {
    par[x] = root(par[x]);
    return par[x];
  }
}

bool same(int x, int y){
  return root(x) == root(y);
}

void unite(int x, int y){
  //rankの値はrootだけが正しく持っている
  x = root(x);
  y = root(y);
  if(x == y){
    return;
  }
  if(height[x] > height[y]){
    par[y] = x;
    card[x] += card[y];
  } else {
    par[x] = y;
    card[y] += card[x];
    if(height[x] == height[y]){
      height[x] ++;
    }
  }
}

double x[100];
double y[100];
double z[100];
double r[100];
pair <double, pair<int, int> > edges[100000];

double dist(double x1, double y1, double z1, double x2, double y2, double z2){
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2));
}
int main(void){
  int n;
  while(true){
    cin >> n;
    if(n == 0){
      break;
    }
    for(int i = 0; i < n; i++){
      cin >> x[i] >> y[i] >> z[i] >> r[i];
    }

    init(n);
    int edge_no = 0;
    for(int i = 0; i < n - 1; i++){
      for(int j = i + 1; j < n; j++){
        double cur_dst = dist(x[i], y[i], z[i], x[j], y[j], z[j]) - r[i] - r[j];
        if(cur_dst > 0){
          edges[edge_no] = make_pair(cur_dst, make_pair(i, j));
          edge_no++;
        } else {
          if(!same(i, j)){
            unite(i, j);
          }
        }
      }
    }

    sort(edges, edges + edge_no);
    double ans = 0;
    for(int i = 0; i < edge_no; i++){
      if(!same(edges[i].second.first, edges[i].second.second)){
        ans += edges[i].first;
        unite(edges[i].second.first, edges[i].second.second);
      }
    }
    cout << setprecision(3) << fixed << ans << endl;
  }
  return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int a,b;
    cin>>a>>b;

    int ans=0;
    if(a>=13) ans=b;
    else if(a<=12 && a>=6) ans = b/2;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;

class State
{
public:
  int w, t;
  State(int ww = 0, int tt = 0)
    :w(ww), t(tt) {}
  bool operator < (const State& st) const
  {
    return this->t > st.t;
  }
};

int main()
{
  const int MAX_N = 16;
  const int INF = 1 << 30;

  int N, t[MAX_N][MAX_N+1], cost[1 << MAX_N];
  bool visited[1 << MAX_N];

  while (scanf("%d", &N) != EOF) {
    if (N == 0)
      break;
    
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N+1; ++j)
        scanf("%d", &t[i][j]);
    }
    
    for (int i = 0; i < (1 << MAX_N); ++i) {
      cost[i] = INF;
      visited[i] = false;
    }

    priority_queue<State> que;
    que.push(State());
    cost[0] = 0;
    while (!que.empty()) {
      State st = que.top();
      que.pop();

      if (__builtin_popcount(st.w) == N) {
        printf("%d\n", st.t);
        break;
      }

      if (cost[st.w] < st.t || visited[st.w])
        continue;

      visited[st.w] = true;
      for (int i = 0; i < N; ++i) {
        if ((st.w & (1 << i)) == 0) {
          int minTime = t[i][0];
          for (int j = 0; j < N; ++j) {
            if (st.w & (1 << j))
              minTime = min(minTime, t[i][j+1]);
          }

          if (cost[(st.w | (1 << i))] > st.t + minTime) {
            cost[(st.w | (1 << i))] = st.t + minTime;
            que.push(State((st.w | (1 << i)), st.t + minTime));
          }
        }
      }
    }

  }
  return 0;
}

Measured memory_bytes: 1648
#include <bits/stdc++.h>
#include<iomanip>
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define N 310
using namespace std;

int n,x,a[4];
double dp[N][N][N];

int main()
{
    cin>>n; FOR(i,0,n) cin>>x,a[x]++;
    FOR(k,0,n+1)
    {
        FOR(j,0,n+1)
        {
            FOR(i,0,n+1)
            {
                if(i+j+k==0 || i+j+k>n) continue;
                dp[i][j][k]=1;
                if(i) dp[i][j][k]+=i*dp[i-1][j][k]/n;
                if(j) dp[i][j][k]+=j*dp[i+1][j-1][k]/n;
                if(k) dp[i][j][k]+=k*dp[i][j+1][k-1]/n;
                dp[i][j][k]*=(double)n/(i+j+k);
            }
        }
    }
    cout<<fixed<<setprecision(14)<<dp[a[1]][a[2]][a[3]]<<'\n';
 
    return 0;
}

Measured memory_bytes: 225536
from collections import Counter

def get_prime_factors(x):
    out = []
    if x < 1:
        return out
    while not x%2:
        out.append(2)
        x //= 2
    i = 3
    while i*i <= x:
        if not x%i:
            out.append(i)
            x //= i
        else:
            i += 2
    if x != 1:
        out.append(x)
    return out

def main():
    n = int(input())
    primes = Counter(get_prime_factors(n))
    ans = 0
    for k, v in primes.items():
        num = 1
        while v >= num:
            ans += 1
            v -= num
            num += 1
    print(ans)
    

if __name__ == "__main__":
    main()

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

int main() {
  long long n,k=0;
  bool a[40];
  cin>>n;
  if(n==0)cout<<0<<endl;
  else {
    for(int i=0;i<40;i++){
      if(n%2==0){
        a[i]=false;
        n/=2;
      }
      else{
        a[i]=true;
        if(i%2==0)n=(n-1)/2;
        else n=(n+1)/2;
      }
      k++;
      if(n==0)break;
    }
    for(int i=k-1;i>=0;i--){
      cout<<a[i];
    }
    cout<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

vector<int> z_algorithm(string s){
	// z[i] : s[i]から始まるsの部分列でsのprefixと一致するもののうち最長のものの長さ
	int n = s.length();
	vector<int> z(n,0);

	int l=0,r=0;
	z[0] = n;
	for (int i = 1; i < n; i++){
		if(i>r){
			l=i,r=i;
			while(r<n && s[r]==s[r-l]) r++;
			z[i]=r-l;
			r--;
		}else{
			int k = i-l;
			if(z[k]<r-i+1){
				z[i]=z[k];
			}else{
				l=i;
				while(r<n && s[r]==s[r-l]) r++;
				z[i]=r-l;
				r--;
			}
		}
	}
	return z;
}

int main()
{	
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=0;
	for (int i = 0; i < n; i++){
		string t = s.substr(i,n-i);
		vector<int> z = z_algorithm(t);

		for (int j = i+1; j < n; j++){
			if(z[j-i]<=j-i && z[j-i]>=ans) ans=z[j-i];
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
import java.awt.Point;
import java.util.*;
import java.util.stream.IntStream;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt(), k = scanner.nextInt();
        Point[] s = IntStream.range(0, n)
                .mapToObj(i -> new Point(scanner.nextInt(), scanner.nextInt()))
                .sorted(Comparator.<Point>comparingInt(p -> p.y).reversed())
                .toArray(Point[]::new);
        Stack<Long> stack = new Stack<>();
        boolean[] used = new boolean[n + 1];
        long tSum = 0, dSum = 0, ans;
        for (int i = 0; i < k; i++) {
            if (used[s[i].x]) {
                stack.push((long)s[i].y);
            } else {
                used[s[i].x] = true;
                tSum++;
            }
            dSum += s[i].y;
        }
        ans = dSum + tSum * tSum;
        for (int i = k; i < n && !stack.empty(); i++) {
            if (!used[s[i].x]) {
                used[s[i].x] = true;
                tSum++;
                dSum += s[i].y - stack.pop();
                ans = Math.max(ans, dSum + tSum * tSum);
            }
        }
        System.out.println(ans);
    }
}

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

int main()
{
	int n;
	cin >> n;
	int arr[n];
	for(int i=0;i<n;i++)
    {
        cin >> arr[i];
    }
    long Max=arr[0],ans=0;
    for(int i=1;i<n;i++)
    {
        if(Max>arr[i])
            ans+=Max-arr[i];
        else
            Max=arr[i];
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4372
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
  
  int n, m=0; cin>>n; n*=2;
  int s[n]; for(int &i:s) cin>>i;
  sort(s, s+n);
  for(int i=0; i<n-1; i+=2)
    m+=min(s[i], s[i+1]);
  
  cout<<m;
}

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

struct UF{
  int par[10000];
  int size[10000];
  void init(int n){
    for(int i=0;i<n;i++){
      par[i]=i;
      size[i]=1;
    }
  }
  int find(int x){
    if(x==par[x])return x;
    return par[x]=find(par[x]);
  }
  void unite(int x,int y){
    x=find(x),y=find(y);
    if(x==y)return;
    if(size[x]<size[y])swap(x,y);
    par[y]=x;
    size[x]+=size[y];
  }
  bool same(int x,int y){
    return ( find(x)==find(y) );
  }
};

struct edge{
  int from;
  int to;
  int A;
  int B;
};

int N,M;
vector<edge> edges;

bool check(double K){
  typedef pair<double,int> P;
  vector<P> tmp;

  for(int i=0;i<(int)edges.size();i++){
    edge e=edges[i];

    tmp.push_back(  P( (double)e.B-(double)e.A*K , i ) );
  }
  sort(tmp.begin(),tmp.end());
  reverse(tmp.begin(),tmp.end());
  UF uf;
  uf.init(N);
  
  double sum=0;
  for(int i=0;i<(int)tmp.size();i++){
    edge e=edges[ tmp[i].second ];
    
    if( uf.same(e.from,e.to ) ){
      sum+=tmp[i].first;
    }else{
      uf.unite(e.from,e.to);
    }
  }

  if(uf.size[ uf.find(0) ]!=N)return false;
  return ( sum<=0.0 );
}

int main(){
  cin>>N>>M;
  for(int i=0;i<M;i++){
    int from,to,A,B;
    cin>>from>>to>>A>>B;
    edges.push_back( (edge){from,to,A,B} );
  }

  double left=0, right=1e7, mid;
  for(int i=0;i<100;i++){
    mid=(left+right)/2.0;
    if( check(mid) )right=mid;
    else left=mid;
  }
  printf("%.10f\n",left);
  return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
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; }
const ll INF = 1LL << 60;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const ll mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
    ll n,a,b; cin >> n >> a >> b;
    vector<int> nb(40);
    int i=0;
    int n2= n;
    while(n2>0){
        if (n2 & 1) nb[i]=1;
        n2>>=1;
        i++;
        //cout << n << endl;
    }
    vector<mint> pow2(36);
    pow2[0]=2;
    rep(i,36) pow2[i+1] = pow2[i]*pow2[i];
    mint ans = 1;
    rep(i,36){
        if (nb[i]==1){
            ans*=pow2[i];
        }
    }
    mint nca=1;
    rep(i,a){
        nca*=(n-i);
    }
    //cout << nca.x << endl;
    for(ll i=1; i<=a; i++){
        nca /= i;
    }
    mint ncb = 1;
    rep(i,b){
        ncb*=(n-i);
    }
    repi(i,1,b+1){
        ncb /= i;
    }
    //cout << ans << " " << nca.x  << " " << ncb.x << endl;
    ans = ans - nca - ncb -1;
    cout << ans.x << endl;


    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <map>

using namespace std;

#define ll long long
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define pb(x) push_back(x)

ll power(int x, unsigned int y){
    ll res = 1;
    while(y > 0){
        if(y & 1) res = res * x;
        y >>= 1;
        x *= x;
    }
    return res;
}

void solve(){
    int n, k;
    cin >> n >> k;
    int arr[n] = {0};
    for(int i = 0; i < k; i++){
        int d; cin >> d;
        for(int i = 0; i < d; i++){
            int x; cin >> x;
            x--;
            arr[x]++; 
        }
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(!arr[i]) ans++;
    }
    cout << ans;
}

int main(){


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    solve();

}

Measured memory_bytes: 3640
<?php
$S = trim(fgets(STDIN));
$K = (int)trim(fgets(STDIN));
$result = "";
$c = 0;
for($i=0;$i<strlen($S);$i++) {
  if($S[$i] == "1"){
    $c++;
    if($c == $K){
    	$result = $S[$i];
      	break;
    }
  }else{
    $result = $S[$i];
    break;
  }
}
echo $result;
?>

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

#ifdef DEBUG
#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))

#define LOGM(msg) (cerr << (msg))

#define LOGV(vec, sep) {                                        \
    cerr << #vec << " =";                                       \
    for (const auto& v : (vec)) cerr << " " << v;               \
    cerr << (sep); }

#define LOGA(arr, N, sep) {                                     \
        cerr << #arr << " =";                                   \
        for (int i = 0; i < N; ++i) cerr << " " << (arr)[i];    \
        cerr << (sep); }

#define LOGA2(arr, N, M, sep) {                                 \
        cerr << #arr << " =\n";                                 \
        for (int i = 0; i < N; ++i) {                           \
            for (int j = 0; j < M; ++j)                         \
                cerr << (arr)[i][j] << " ";                     \
            cerr << endl;                                       \
        } cerr << (sep); }
#else
#define LOG(var, sep)
#define LOGM(msg)
#define LOGV(vec, sep)
#define LOGA(arr, N, sep)
#define LOGA2(arr, N, M, sep)
#endif

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

class UFDS
{
private:
    std::vector<int> size, ps;

public:
    UFDS(int N) : size(N + 1, 1), ps(N + 1)
    {
        std::iota(ps.begin(), ps.end(), 0);
    }

    int find_set(int x) const
    {
        return x == ps[x] ? x : find_set(ps[x]);
    }

    bool same_set(int x, int y)
    {
        return find_set(x) == find_set(y);        
    }

    int union_set(int x, int y)
    {
        if (same_set(x, y))
            return 0;

        int p = find_set(x);
        int q = find_set(y);

        if (size[p] < size[q])
            std::swap(p, q);

        ps[q] = p;
        size[p] += size[q];

        return size[p];
    }

};


ll solve(int N, const vector<ll>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;

    UFDS ufds(N);
    int ans = 1;

    while (M--)
    {
        int u, v;
        cin >> u >> v;

        ans = max(ans, ufds.union_set(u, v));
    }
        
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 4844
using System;
using System.Linq;

namespace ABC154
{
    class C
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int Alen = A.Length;
            if (Alen == A.Distinct().ToArray().Length) Console.WriteLine("YES");
            else Console.WriteLine("NO");

        }
    }
}


Measured memory_bytes: 39624
#include<stdio.h>
#include<stdlib.h>
int max(int x,int y){
 if(x>y)return x;
  else return y;
}
int sort(int *a,int *b){
return *b-*a;
}

int main(void){
int n;
  scanf("%d",&n);
  int a[n],b[n];
  for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
    b[i]=a[i];
  }
  int h=0;
  long long ans=0;
  for(int i=0;i<n;i++){
	h=max(h,a[i]);
    ans+=h-a[i];
  }
  printf("%lld",ans);
  return 0;
}

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

using namespace std;
using ll = long long;

const ll INF = 1LL << 58;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<ll> W(N), V(N);
  for (int i = 0; i < N; i++) {
    cin >> W[i] >> V[i];
  }
  vector<vector<ll>> dp(N + 1, vector<ll>(100000 + 1, INF));
  dp[0][0] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 100000 + 1; j++) {
      dp[i + 1][j] = dp[i][j];
      if (j - V[i] >= 0)
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - V[i]] + W[i]);
    }
  }
  for (int i = 100000; i >= 0; i--) {
    if (dp[N][i] > M) continue;
    cout << i << '\n';
    break;
  }
  return 0;
}


Measured memory_bytes: 80256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    long a;
    long flg=0;
    cin >> a;
    string str=to_string(a);
    for(long i=0;i<str.length();i++){
        if(str[i] =='7'){
            flg=1;
        }
    }
    
    if(flg == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define mod 1000000007
#define inf 9999999999999999ll
#include <bits/stdc++.h>
using namespace std;
bool comp(ii &a,ii &b)
{
    return a.F*b.S<b.F*a.S;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll h,n;
    cin>>h>>n;
    vi a(n),b(n);
    for(ll i=0;i<n;i++)
        cin>>a[i]>>b[i];
    ll ans=0;

    vi dp(h+1,inf);
    dp[0]=0;
    for(ll i=0;i<n;i++)
    {
        dp[min(a[i],h)]=min(dp[min(a[i],h)],b[i]);
    }
    // trv(dp);
    for(ll i=h-1;i>=0;i--)
    {
        // tr1(i);
        dp[i]=min(dp[i+1],dp[i]);
    }
    // trv(dp);
    for(ll i=1;i<=h;i++)
    {
        ll price=dp[i];
        for(ll j=2*i;j<=h;j+=i)
        {
            price+=dp[i];
            dp[j]=min(dp[j],price);
        }
    }
    for(ll i=0;i<=h;i++)
    {
        for(ll j=0;j<=i;j++)
        {
            dp[i]=min(dp[i],dp[j]+dp[i-j]);
        }
    }
    cout<<dp[h]<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll k, q;
  cin >> k >> q;
  vector<ll> d2(k);
  REP(i, k) { cin >> d2[i]; }
  while (q--) {
    ll n, x, m;
    cin >> n >> x >> m;
    vector<ll> d(k), s(k + 1, 0);
    REP(i, k) {
      d[i] = d2[i] % m;
      if (d[i] == 0) {
        d[i] = m;
      }
      s[i + 1] = s[i] + d[i];
    }
    n--;
    ll t = x + (n / k) * s[k] + s[n % k];
    ll ans = n - (t / m - x / m);
    cout << ans << endl;
  }
}

Measured memory_bytes: 512
public class Main {
  private static void solve() {
    int a = ni();
    int b = ni();

    StringBuilder x = new StringBuilder();
    StringBuilder y = new StringBuilder();

    for (int i = 0; i < a; i++) {
      x.append(b);
    }
    for (int i = 0; i < b; i++) {
      y.append(a);
    }

    System.out.println(x.toString().compareTo(y.toString()) < 0 ? x : y);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 22228
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; }
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; }
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; }
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
void print(void) { cout << endl; }
template <class Head> void print(Head&& head) { cout << head; print(); }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << " "; print(forward<Tail>(tail)...); }
template <class T> void chmax(T& a, const T b) { a = max<T>(a, b); }
template <class T> void chmin(T& a, const T b) { a = min<T>(a, b); }
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }

int main() {
	ll N, K; cin >> N >> K;
	V<ll> A(N); REP(i, N) cin >> A[i];
	V<ll> bit(60,0),bitK(60,0);
	REP(i, N) REP(j, 60) if (A[i] & (1LL << j)) bit[j]++;
	REP(j, 60) if (K & (1LL << j)) bitK[j]++;

	int flg = 0;
	V<ll> dp(60,0);
	for(ll i = 59; 0 <= i; --i){
		if(bit[i] >= N - bit[i]){
			dp[i] = 0;
			if (bitK[i]) flg = 1;
		}
		else{
			if (flg) dp[i] = 1;
			else{
				if (bitK[i]) dp[i] = 1;
				else dp[i] = 0;
			}
		}
	}
	ll X = 0,ans = 0;
	REP(i, 60) X += (dp[i] << i);
	REP(i, N) ans += A[i]^X;
	cout << ans << endl;
	
	return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  char c;
  cin >> c;

  if (c >= 'a' && c <= 'z')
    cout << 'a' << endl;
  else
    cout << 'A' << endl;

  return 0;
}


Measured memory_bytes: 3608
//%std
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
inline ll read()
{
	ll out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
const int P=1e9+7;
int add(int a,int b)
{
	return (a+b>=P)?(a+b-P):(a+b);
}
void inc(int &a,int b)
{
	a=add(a,b);
}
int mul(int a,int b)
{
	return 1LL * a * b % P; 
}
const int K=60;
int n,c[K];
int main()
{
	n=read();
	for(int i=1;i<=n;++i)
	{
		ll x=read();
		for(int j=0;j<K;++j)
			c[j]+=(x>>j)&1LL;
	}
	int ans=0,pw=1;
	for(int i=0;i<K;++i)
	{
		inc(ans,mul(pw,mul(c[i],n-c[i])));
		pw=mul(pw,2);
	}
	cout<<ans<<endl;
	return 0;
}


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

ll g1(ll n, int p){
	if(n == 0) return 0;
  	return n/p + g1(n/p, p);
}

ll g2(ll n, int p){
  	if(n%2 == 1) return 0;
  
  	ll res = g1(n/2, p);
  	if(p == 2) res += n/2;
  	return res;
}
 
int main(){
	ll n;
  	cin >> n;
  
  	ll ans = min(g2(n, 2), g2(n, 5));
  	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1e9+7;
ll add(ll a,ll b){return (a+b)%mod;}
int N,W,sum=0;
int t[201];
ll dp[201][10001];

ll solve(){
  if(sum<=W||W<t[N])return 1;
  ll res=0;
  dp[0][0]=1;
  for(int i=1;i<=N;i++){
    sum-=t[i];
    for(int j=0;j<=W;j++){
      dp[i][j]=dp[i-1][j];
      if(sum+j<=W&&W<t[i]+sum+j)res=add(res,dp[i][j]);
      if(j-t[i]>=0)dp[i][j]=add(dp[i][j],dp[i-1][j-t[i]]);
    }
  }
  return res;
}

int main(){
  cin>>N>>W;
  for(int i=1;i<=N;i++){
    cin>>t[i];
    sum+=t[i];
  }
  sort(t+1,t+1+N);
  reverse(t+1,t+1+N);
  cout<<solve()<<endl;
  return 0;
}

Measured memory_bytes: 16788
#C問題
#UnionFind
def find(A,x):
    p = A[x]
    if p == x:
        return x
    a = find(A,p)
    A[x] = a
    return a
 
def union(A, x, y):
    if find(A,x) > find(A,y):
        bx, by = find(A,y), find(A,x)
    else:
        bx, by = find(A,x), find(A,y)
    A[y] = bx
    A[by] = bx

import heapq

W,H = map(int,input().split())
PQ = []
for i in range(W+H+1):
    if i == W+1:
        continue
    pq = int(input())
    heapq.heappush(PQ,[pq,i,i+1])

#print(PQ)
w = W+1
h = H+1
ans = 0
V = [i for i in range(H+W+2)]

while PQ:
    e,s,t = heapq.heappop(PQ)
    if find(V,s) != find(V,t):
        union(V,s,t)
        if s < W: #P
            ans+=(e*h)
            w-=1
        else:#Q
            ans+=(e*w)
            h-=1
            
print(ans)

Measured memory_bytes: 50688
package main

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

var sc = bufio.NewScanner(os.Stdin)

type Request struct {
	x, y  int
	color string
}

type White struct {
	x, y int
}

var wh [4001][4001]int32
var sum [4001][4001]int32
var i, j int32

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	N := nextInt()
	K := nextInt()
	for i = 0; i < N; i++ {
		x := nextInt()
		y := nextInt()
		c := nextString()
		if c == "W" {
			y += K
			log.Println(x, y, c)
		}
		wh[y%(2*K)][x%(2*K)]++
	}
	for i = 0; i <= 4*K; i++ {
		for j = 0; j <= 4*K; j++ {
			wh[i][j] = wh[i%(2*K)][j%(2*K)]
		}
	}
	for i = 0; i <= 4*K; i++ {
		for j = 0; j <= 4*K; j++ {
			sum[i][j] = wh[i][j]
			if i-1 >= 0 {
				sum[i][j] += sum[i-1][j]
			}
			if j-1 >= 0 {
				sum[i][j] += sum[i][j-1]
			}
			if i-1 >= 0 && j-1 >= 0 {
				sum[i][j] -= sum[i-1][j-1]
			}
		}
	}
	var ans int32
	for i = 0; i <= 2*K; i++ {
		for j = 0; j <= 2*K; j++ {
			var tmp int32
			tmp += get(i, j, i+K-1, j+K-1)
			tmp += get(i+K, j+K, i+2*K-1, j+2*K-1)
			ans = max(ans, tmp)
		}
	}
	fmt.Println(ans)
}

func get(x1, y1, x2, y2 int32) int32 {
	res := sum[y2][x2]
	if x1 > 0 {
		res -= sum[y2][x1-1]
	}
	if y1 > 0 {
		res -= sum[y1-1][x2]
	}
	if x1 > 0 && y1 > 0 {
		res += sum[y1-1][x1-1]
	}
	return res
}
func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int32 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return int32(i)
}
func max(a ...int32) int32 {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}


Measured memory_bytes: 130560
N = int(input())
W = [int(i) for i in input().split()]
first_W = 0
last_W = 0
ans = 100000
for i in range(N):
    first_W, last_W = sum(W[0:i+1]), sum(W[i+1:N])
    if(ans > abs(first_W - last_W)):
        ans = abs(first_W - last_W)
print(ans)


Measured memory_bytes: 3060
h,w=map(int,input().split())
s=[[x for x in input()] for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] =='#':
            continue
        cnt=0
        for k in range(-1,2):
            if i+k<0 or i+k>=h:
                continue
            for l in range(-1,2):
                if j+l<0 or j+l>=w:
                    continue 
                if s[i+k][j+l]=='#':
                    cnt+=1
        s[i][j]=str(cnt)
for i in range(h):
    print(''.join(s[i]))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
  int64_t N;
  cin>>N;
  string k;
  while(N>0){
    N--;
    k=(char)(N%26+'a')+k;
    N/=26;
  }
  cout<<k<<endl;
  return 0;
}

Measured memory_bytes: 3588
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;
const int Maxn = 1e5;

int N;
ll A[Maxn + 5] = {-1};
pair<ll, int> t[20];

int main() {
#ifdef LOACL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	scanf("%d", &N);
	for(int i = 1; i <= N; i++)
		scanf("%lld", &A[i]);
	sort(A + 1, A + N + 1);
	int cnt = 0;
	for(int i = 1; i <= N; i++) {
		if(A[i] == A[i - 1])
			t[cnt].second++;
		else t[++cnt].second = 1, t[cnt].first = A[i];
		if(cnt > 3) {
			puts("No");
			return 0;
		}
	}
	if(cnt == 3) {
		if(t[1].second == t[2].second && t[2].second == t[3].second &&
			(t[1].first ^ t[2].first ^ t[3].first) == 0)
				puts("Yes");
		else puts("No");
	} else if(cnt == 2) {
		if(t[1].first == 0 && t[1].second * 2 == t[2].second)
			puts("Yes");
		else puts("No");
	} else if(cnt == 1) {
		if(t[1].first == 0) puts("Yes");
		else puts("No");
	}
	return 0;
}
/*
a special data:
input:
1
6
1 1 2 3 1 0
output:
No
*/

Measured memory_bytes: 896
n,m = map(int,input().split())
py = sorted([list(map(int,input().split()))+[i] for i in range(m)])
cnt = 1
ans_list = [['0'*(6 - len(str(py[0][0])))+str(py[0][0])+'000001',py[0][2]]]
for i in range(1,m):
  ans = '0'*(6 - len(str(py[i][0])))
  ans += str(py[i][0])
  if py[i-1][0] == py[i][0]:
    cnt += 1
  else:
    cnt = 1
  ans += '0'*(6 - len(str(cnt)))
  ans += str(cnt)
  ans_list.append([ans,py[i][2]])
ans_list = sorted(ans_list,key=lambda x:x[1])
for i in ans_list:
  print(i[0])

Measured memory_bytes: 42636
#include<bits/stdc++.h>
using namespace std;
const int maxn=100005;
int n,x[maxn];
long long w;
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&x[i]),w+=abs(x[i]-x[i-1]);
	w+=abs(x[n]);
	for(int i=1;i<=n;i++)
		printf("%lld\n",w-abs(x[i]-x[i-1])-abs(x[i+1]-x[i])+abs(x[i+1]-x[i-1]));
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int t[210];
int a[210];
int b[210];
int c[210];

int dp[210][210];

int main(void){
	int n,d;
	cin >> n >> d;
	for(int i=0;i<n;++i) cin >> t[i];
	for(int i=0;i<d;++i) cin >> a[i] >> b[i] >> c[i];

	for(int i=0;i<n-1;++i){
		for(int j=0;j<d;++j){
			if(t[i]<a[j]||b[j]<t[i])
				continue;
			for(int k=0;k<d;++k){
				if(t[i+1]<a[k]||b[k]<t[i+1])
					continue;
				dp[i+1][k]=max(dp[i+1][k],dp[i][j]+abs(c[k]-c[j]));
			}
		}
	}

	int ans=0;
	for(int i=0;i<d;++i) ans=max(ans,dp[n-1][i]);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1332
package main

import (
	"bufio"
	"flag"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	"strings"
)

func (p *problem) solve() {
	N := p.NextInt()
	A := p.NextInts()

	var cnt, sum, r int
	for l := 0; l < N; l++ {
		cnt += max(r-l, 0)
		for r < N && A[r]&sum == 0 {
			sum += A[r]
			cnt++
			r++
		}
		sum -= A[l]
	}
	p.PrintInt(cnt)
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

var (
	debug  bool
	output string
)

func main() {
	flag.BoolVar(&debug, "debug", false, "Print debug logs")
	flag.BoolVar(&debug, "d", false, "Print debug logs")
	flag.StringVar(&output, "output", "stdout", "Specify output target (Default: stdout)")
	flag.StringVar(&output, "o", "stdout", "Specify output target (Default: stdout)")
	flag.Parse()

	if debug {
		out := os.Stdout
		if output != "stdout" {
			logfile, err := os.OpenFile(output, os.O_CREATE|os.O_WRONLY, 0666)
			if err != nil {
				panic(err)
			}
			defer logfile.Close()
			out = logfile
		}
		log.SetOutput(out)
	} else {
		log.SetOutput(ioutil.Discard)
	}

	p := problem{
		in:  bufio.NewReader(os.Stdin),
		out: bufio.NewWriter(os.Stdout),
	}
	p.solve()

	if err := p.out.Flush(); err != nil {
		panic(err)
	}
}

type problem struct {
	in  *bufio.Reader
	out *bufio.Writer
}

func (p *problem) PrintInt(d int) {
	p.Printf("%d\n", d)
}

func (p *problem) Printf(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, format, a...); err != nil {
		panic(err)
	}
}

func (p *problem) Printfln(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, fmt.Sprintf("%v\n", format), a...); err != nil {
		panic(err)
	}
}

func (p *problem) NextInt() int {
	return stoi(p.Next())
}

func (p *problem) NextInts() []int {
	line := p.NextSSLine()
	ds := make([]int, len(line))
	for i, s := range line {
		ds[i] = stoi(s)
	}
	return ds
}

func (p *problem) NextSSLine() []string {
	return strings.Split(p.Next(), " ")
}

// Next reads line and return string.
func (p *problem) Next() string {
	var b []byte
	for {
		l, pre, err := p.in.ReadLine()
		if err != nil {
			panic(err)
		}
		b = append(b, l...)
		if !pre {
			break
		}
	}
	return string(b)
}

func stoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		fmt.Println(i)
		fmt.Println(err)
	}
	return i
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define debug(x) cout << #x << " = " << x << endl
#define print(x) cout << x << endl;
const ll MOD = 1000000007;

ll modInv(ll a, ll p)
{
    ll b = p, u = 1, v = 0;
    while (b)
    {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= p;
    if (u < 0)
        u += p;
    return u;
}

ll modComb(ll n, ll r, ll p)
{
    ll ans = 1;
    for (ll i = 1; i <= r; i++)
    {
        ans = (ans * (n - i + 1)) % p;
        ans = (ans * modInv(i, p)) % p;
    }

    return ans;
}

int main()
{
    int X, Y;
    cin >> X >> Y;

    if ((X + Y) % 3)
    {
        cout << 0 << endl;
        return 0;
    }

    if (Y > 2 * X)
    {
        cout << 0 << endl;
        return 0;
    }

    if (X > 2 * Y)
    {
        cout << 0 << endl;
        return 0;
    }

    ll stairs = (X + Y) / 3;
    ll ans = modComb(stairs, X - stairs, MOD);
    cout << ans << endl;
}


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

int main(){

  int n, m, p;

  while(cin >> n >> m >> p, n|m|p){
    int x[1100];
    int sum = 0;
    for(int i = 1; i <= n; i++){
      cin >> x[i];
      sum += x[i];
    }
    if(x[m] == 0){
      cout << 0 << endl;
    }else{
      int score = sum * (100 - p);
      cout << score / x[m] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 2968
if __name__ == '__main__':
  
  S = input()
  comp_num = 753
  min = 10000000000000000
  for i in range(0, len(S)-2):
    temp = int (S[i]+S[i+1]+S[i+2])
    tempmin = abs(comp_num - temp)
    
    if tempmin <= min:
      min = tempmin
  print(min)


      

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

using namespace std;

#define ll long long

int main() {
    string a;
    int h, j;
    cin >> h >> j;
    vector<string> v;
    for (int i = 0; i < h; i++) {
        string b;
        cin >> b;
        v.push_back(b);
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < v.size(); i++) {
        a += v[i];
    }
    cout << a;
}


Measured memory_bytes: 3640