akhauriyash/Code-Regression huggingface dataset:
N,M = gets.split.map(&:to_i)
res = {}
$inf = 0
M.times {
  a,b,c = gets.split.map(&:to_i)
  res[b-1] ||= {}
  res[b-1][a-1] = -c
  $inf += c.abs*2
}

# bfs reachable vertice from N
$reachable = {}
$reachable[N-1] = 1
fs = {}
fs[N-1] = 1
while true
  nfs = {}
  fs.keys.each{ |f,_|
    rs = res[f]
    next unless rs
    rs.each{ |t,_|
	  next if $reachable[t]
      $reachable[t] = 1
      nfs[t] = 1
    }
  }
  break if nfs.size == 0
  #p nfs.keys
  fs = nfs
end
#p $reachable

es = {}
res.each{ |t,h|
  next unless $reachable[t]
  h.each{ |f,c|
    next unless $reachable[f]
    es[f] ||= {}
    es[f][t] = c
  }
}

def bf(start, nodes, edges)
  froms = nodes.map{ nil }
  ds = (0..1).map{ nodes.map{ $inf } }
  ds[1][start] = ds[0][start] = 0
  (nodes.size-1).times{ |i|
	#p ds
    edges.each{ |u,es|
      es.each{ |v,c|
        next if ds[i&1^1][v] <= ds[i&1][u] + c
        ds[i&1^1][v] = ds[i&1][u] + c
        froms[v] = u
      }
    }
  }
  
  dds = ds[nodes.size&1^1]
  #p dds
  return nil if edges.any?{ |u,es| 
    es.any?{ |v,c|
      #puts "#{dds[u]} + #{c} <? #{dds[v]}"
      dds[u] + c < dds[v]
    }
  }
  
  dds
end

if ds = bf(0, (0...N).to_a, es)
  puts -ds[-1]
else
  puts "inf"
end

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n), b(n);
	rep(i, n) cin >> a[i] >> b[i];

	vector<pair<int, int>> ab(n);
	rep(i, n) ab[i] = make_pair(a[i], b[i]);
	sort(ab.begin(), ab.end());

	long long ans = 0;
	rep(i, n) {
		int buy = min(m, ab[i].second);
		ans += (long long)buy * ab[i].first;
		m -= buy;
	}

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


Measured memory_bytes: 1792
n=int(input().rstrip())
h=input().split(" ")

ans=1
lim=int(h[n-1])
for i in range(n-2,-1,-1):
    h[i]=int(h[i])
    if(lim >h[i]):
        lim=h[i]
    else:
        if(lim+1< h[i]):
            ans=0
if ans==1:
    print("Yes")
else:
    print("No")
        
    

Measured memory_bytes: 11244
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

int main(){
  char buf[1024];
  int N;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d", &N);

  int *A=(int *)malloc(sizeof(int)*N);
  rep(i,N){
    scanf("%d",&A[i]);
  }

  double *B=(double *)malloc(sizeof(double)*N);
  rep(i,N){
    B[i]=1.0/(double)A[i];
  }

  double sum=0;
  rep(i,N){
    sum+=B[i];
  }

  printf("%f\n", 1/sum);


}


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

using namespace std;



int main(){
 long long m;
  cin >> m;
 
 for(long long h=1;h<=3500;h++){
  for(long long n=1;n<=3500;n++){
     long long w=m*h*n;
     long long d=4*h*n-m*n-m*h;
    if(d>0&&w%d==0) {
     cout << h << " " << n << " " << w/d << endl;
      return 0;
    }
  } 
 }
}

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use permutohedron::heap_recursive;
use proconio::input;

fn main() {
    input! {
        n: usize,
    }
    let mut xy = Vec::with_capacity(n);
    for _ in 0..n {
        input! {
            x: i64,
            y: i64,
        }
        xy.push((x, y));
    }

    let mut sumf = 0f64;
    let mut sump = 0;
    let mut data: Vec<usize> = (0..n).collect();
    heap_recursive(&mut data, |p| {
        // println!("{:?}", p);
        for i in 1..n {
            sumf += (((xy[p[i]].0 - xy[p[i - 1]].0).pow(2) + (xy[p[i]].1 - xy[p[i - 1]].1).pow(2)) as f64).sqrt();
        }
        sump += 1;
    });
    println!("{}", sumf / (sump as f64));
}


Measured memory_bytes: 2220
require 'matrix'

vs = 5.times.map { Vector.elements gets.split.map(&:to_i), false }
v, w = vs[3]- vs[2], vs[4] - vs[2]
j = 3.times.max_by {|i| [v, w].count {|u| u[i].zero? } }
x, y, z = Matrix.rows([v, w, 3.times.map {|i| i == j ? 1 : 0 }]).inv * (vs[1] - vs[2])
if z == 0 && 0 <= x && 0 <= y && x + y <= 1
  puts 'MISS'
else
  begin
    x, y, z = Matrix.columns([vs[3] - vs[2], vs[4] - vs[2], vs[0] - vs[1]]).lup.solve(vs[0] - vs[2]).to_a
    puts 0 <= z && z <= 1 && (0 <= x && 0 <= y && x + y <= 1) ? 'MISS' : 'HIT'
  rescue
    puts 'HIT'
  end
end

Measured memory_bytes: 9364
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  vector<int> tab(3, 0);
  cin >> tab[0] >> tab[1] >> tab[2];
  sort(tab.begin(), tab.end());
  cout << tab[0] + tab[1] << endl;
  return 0;
}

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

int main(void){
    int a[10], sum = 0, min = 10;
    for(int i=0;i<5;++i)cin >> a[i];
    for(int i=0;i<5;++i){
        int amari = 0;
        amari = a[i]%10;
        if(amari!=0 && min > amari) min = amari;
        a[i] = (a[i]+9)/10*10;
        sum += a[i];
    }
    cout << sum - (10-min) << endl;
}


Measured memory_bytes: 256
// --------------
// Tejas Pandey  |
// 25 - 07 - 20  |
// ABC M-Solution|
// --------------

#include <bits/stdc++.h>
using namespace std;
     
#define mod 1000000007
#define vi vector<int>
typedef long long int ll;
     
int main (void){
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int x;
  cin >> x;
  cout << 10 - (x/200) << "\n"; 
  return 0;
}


Measured memory_bytes: 3652
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int[] arr=new int[n];
		int sum=0;
		for(int i=0;i<n;i++) {
			arr[i]=sc.nextInt();
			sum+=arr[i];
		}
		boolean flag=false;
		int c=0;
		for(int i=0;i<n;i++) {
			if(arr[i]>=(1/(4.0*m))*sum) {
				c++;
			}
			if(c==m) {
				flag=true;
				break;
			}
		}
		System.out.println(flag? "Yes":"No");
		sc.close();
	}
}


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

using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

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

    int a, b, c;
    cin >> a >> b >> c;
    int ans = b / a;
    if (a > b) {
        cout << "0" << "\n";
    } else {
        if (ans >= c) {
            cout << c << "\n";
        } else {
            cout << ans << "\n";
        }

    }

}















Measured memory_bytes: 3616
A,B,C,X,Y = map(int,input().split())

smaller = X if X < Y else Y
bigger = X if X >= Y else Y
bigger_yen = A if bigger==X else B
cheaper = A if A <B else B
higher = A if A >= B else B

if 2*C >= A + B:
    buy = A*X + B*Y
elif 2*C < A + B:
    if bigger_yen < 2*C:
        buy = smaller*2*C + (bigger-smaller)*bigger_yen
    else:
        buy = bigger*2*C

print(buy)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std; typedef long long ll;
typedef pair<int,int> P; const int INF = 1e9+1;
P min(const P p1, const P p2) {
  if (p1<p2) return p1; else return p2;
}
P operator+(const P p1, const P p2) {
  return make_pair(p1.first+p2.first, p1.second+p2.second);
}
int main() {
  int h,w; cin>>h>>w; string s[h];
  for(int i=0;i<h;i++) cin>>s[i];
  P p[h][w]; fill(p[0], p[h], make_pair(INF,INF));
  if (s[0][0]=='#') p[0][0]=make_pair(0,1);
  else p[0][0]=make_pair(0,0);
  // ひっくり返す数、黒
  P p1={0,1};
  for(int i=0;i<h;i++) {
    for(int j=0;j<w;j++) {
      if (s[i][j] == '#') {
        if (i>0) p[i][j]=min(p[i-1][j]+p1,p[i][j]);
        if (j>0) p[i][j]=min(p[i][j-1]+p1,p[i][j]);
      } else {
        if (i>0) {
          int u1=p[i-1][j].first+(p[i-1][j].second>0);
          p[i][j]=min(make_pair(u1,0), p[i][j]);
        }
        if (j>0) {
          int u1=p[i][j-1].first+(p[i][j-1].second>0);
          p[i][j]=min(make_pair(u1,0), p[i][j]);
        }
      }
    }
  }
  cout<<p[h-1][w-1].first+(p[h-1][w-1].second>0)<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=ll(a);i<int(b);i++)
#define irep(i,a,b) for(int i=int(a);i>=int(b);i--)
using ll = long long;
using namespace std;

int main(){
    int h,w,ans=0,tmp=0;
    cin>>h>>w;
    int LR[2200][2200]={0},RL[2200][2200]={0},UD[2200][2200]={0},DU[2200][2200]={0};
    string s[2200];
    rep(i,0,h)cin>>s[i];

    rep(i,0,h)if(s[i][0]=='.')LR[i][0]=1;
    rep(i,0,w)if(s[0][i]=='.')UD[0][i]=1;
    
    rep(i,0,h){
        rep(j,1,w){
            if(s[i][j]=='.')LR[i][j]=LR[i][j-1]+1;
            else LR[i][j]=0;
        }
        irep(j,w-1,0){
            if(s[i][j]=='.')RL[i][j]=RL[i][j+1]+1;
            else RL[i][j]=0;
        }
    }

    rep(i,0,w){
        rep(j,1,h){
            if(s[j][i]=='.')UD[j][i]=UD[j-1][i]+1;
            else UD[j][i]=0;
        }
        irep(j,h-1,0){
            if(s[j][i]=='.')DU[j][i]=DU[j+1][i]+1;
            else DU[j][i]=0;
        }
    }

     rep(i,0,h){
        rep(j,0,w){
            tmp=0;
            if(s[i][j]=='.')tmp=LR[i][j]+RL[i][j]+UD[i][j]+DU[i][j]-3;
            ans=max(ans,tmp);
        }
    }
    cout<<ans;
}

Measured memory_bytes: 80000
#include<iostream>
#include<vector>
#include<set>
#include<cstring>
using namespace std;

int V;
vector<int> G[1001];
int match[1001];
bool used[1001];

void add_edge(int u,int v){
	G[u].push_back(v);
	G[v].push_back(u);
}

bool dfs(int v){
	used[v] = true;
	for(int i=0;i<G[v].size();i++){
		int u=G[v][i], w=match[u];
		if(w < 0 || !used[w] && dfs(w)){
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

int bipartite_matching(){
	int res = 0;
	memset(match,-1,sizeof(match));
	for(int v=0;v<V;v++){
		if(match[v] < 0){
			memset(used,0,sizeof(used));
			if(dfs(v)){
				res++;
			}
		}
	}
	return res;
}

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


int main(){
	while(true){
		int m,n;
		cin >> m >> n;
		if(m == 0){
			break;
		}
		vector<int> b;
		vector<int> r;
		V = m+n;
		for(int i=0;i<1001;i++){
			vector<int> buf;
			G[i] = buf;
		}
		for(int i=0;i<m;i++){
			int buf;
			cin >> buf;
			b.push_back(buf);
		}
		for(int j=0;j<n;j++){
			int buf;
			cin >> buf;
			r.push_back(buf);
		}

		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++){
				if(gcd(b[i],r[j]) != 1){
					add_edge(i,j+m);
				}
			}
		}
		cout << bipartite_matching() << endl;
	}
}

Measured memory_bytes: 3380
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  ll n;
  cin>>n;

  ll ans=0;
  for(ll i=1;i<=n;i++){
    ans+=i*((n/i)*(n/i+1)/2);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3648
s = int(input())
a = []
a.append(s)
i = 0

while True:

    if a[i] % 2 == 0:
        a.append(a[i]/2)
    else:
        a.append(a[i]*3+1)
    if a[i] == 4:
        print(i+4)
        exit()
    elif a[i] == 2 or a[i] == 1:
        print(i+4)
        exit()

    i += 1

print(a)

Measured memory_bytes: 3060
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
const int oo=2139063143;
const int N=1250;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<20|1],*p1=buf,*p2=buf,obuf[1<<20|1],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }
int del(int x) { return x>=P?x-P:x; }
void add(int &x,int y) { x=del(x+y); }
int n,m,a[N],f[N][N],g[N][N],h[N]; bool vis[N][N];

int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
    
    sc(n),sc(m); n<<=1;
    h[0]=1;
    for (int i=2; i<=1200; i+=2)
        h[i]=(LL)h[i-2]*(i-1)%P;
    for (int i=1; i<=m; i++)
    {
        int x,y; sc(x),sc(y);
        a[x]=y,a[y]=x;
    }
    for (int l=1; l<=n; l++)
        for (int r=l; r<=n; r++)
        {
            bool fg=1;
            for (int i=l; i<=r; i++) if (a[i])
                if (a[i]< l||a[i]> r) { fg=0; break; }
            if (!fg) vis[l][r]=1;
            g[l][r]=r-l+1;
            for (int i=l; i<=r; i++)
                g[l][r]-=a[i]> 0;
        }
    for (int len=2; len<=n; len+=2)
        for (int l=1,r=l+len-1; r<=n; l++,r++) if (!vis[l][r])
        {
            f[l][r]=h[g[l][r]];
            for (int x=l+1; x< r; x+=2)
                add(f[l][r],P-(LL)f[l][x]*h[g[x+1][r]]%P);
        }
    // for (int l=1; l<=n; l++)
    //  for (int r=1; r<=n; r++)
    //      printf ("%d %d %d\n",l,r,f[l][r]);
    int ans=0;
    for (int l=1; l<=n; l++)
        for (int r=l+1; r<=n; r++) if (f[l][r])
            add(ans,(LL)f[l][r]*h[g[1][l-1]+g[r+1][n]]%P);//,printf ("%d %d %d %d %d\n",l,r,f[l][r],h[g[1][l-1]+g[r+1][n]],ans);
    pr(ans);

    return 0;
}


Measured memory_bytes: 11648
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<string>
#include<functional>
#include<utility>
using namespace std;
int main(){
	string str;
	int n,cnt=0; cin >> n >> str;
	for (int i = 0; i < n; ++cnt,++i) {
		int j=i+1;
		while (str[i] == str[j]) {
			++j;
			if (j >= n) break;
		}
		i = j - 1;
	}
	cout << cnt << endl;
	return 0;
}

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

int main() {
    int K, A, B;
    cin >> K >> A >> B;
    for(int i=A; i<=B; i++) {
        if(i%K==0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;

    return 0;
}

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

int main() {
  long n,m;
  cin >> n >> m;
  vector<pair<int,int>> student(n,pair<int,int>());
  vector<pair<int,int>> checkpoint(m,pair<int,int>());
  for(int i=0;i<n;i++) cin >> student[i].first >> student[i].second;
  for(int i=0;i<m;i++) cin >> checkpoint[i].first >> checkpoint[i].second;
  
  for(int i=0;i<n;i++) {
    long ans;
    long min_distance=99999999999;
    for(int j=0;j<m;j++) {
      long distance;
      if(student[i].first>=checkpoint[j].first) distance=student[i].first-checkpoint[j].first;
      else distance=checkpoint[j].first-student[i].first;
      if(student[i].second>=checkpoint[j].second) distance+=student[i].second-checkpoint[j].second;
      else distance+=checkpoint[j].second-student[i].second;
      if(distance<min_distance) {
        min_distance=distance;
        ans=j+1;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

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

    READV(H);
    READV(N);
    FORI(i,0,N)
    {
        READV(x);
        H-=x;
    }
    if(H>0)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    

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


   
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
typedef long long ll;

const ll max_val = 200 * 1e4;

int main(int argc, char* argv[])
{
  ll d, n;
  std::cin >> d >> n;

  int cnt = 0;
  for (int x = 1; x < 1000; x++) {
    if (x % 100 != 0) {
      cnt++;
    }
    if (cnt == n) {
      std::cout << x * (ll)std::pow(100, d) << std::endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 1 << 21;
using pii = std::pair<int, int>;
#define SORT(v) std::sort(v.begin(), v.end())
int main(void) {
	int N;
	std::cin >> N;
	std::vector<long long> a(N);
	for (int i = 0; i < N; i++) {
		std::cin >> a[i];
	}
	int i;
	for (i = N - 1; i >= 0; i -= 2) {
		std::cout << a[i] << " ";
	}
	if (N%2==0) {
		for (i = 0; i < N; i += 2) {
			std::cout << a[i] << " ";
		}
	}else {
		for (i = 1; i < N; i += 2) {
			
			std::cout << a[i] << " ";
		}
	}
	std::cout << std::endl;
	return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define debug(a) cout << #a << ": " << a << endl

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);int n; cin>>n;
	vector<int> p(n);
	for(int i = 0; i<n; i++){
		cin>>p[i];
	}
	int ans = 0;
	int smallest_so_far = n + 1;
	for(int i = 0;i<n; i ++){
		if(smallest_so_far > p[i]){
			ans++;
			smallest_so_far = p[i];
		}
	}
	cout<<ans<<endl;
}
	


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n; i >= 0; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



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

  int n;
  cin >> n;
  vi a(n);
  rep(i,n) {
    cin >> a[i];
    a[i]--;
  }
  int cur = 0;
  int cnt = 0;
  vb seen(n);
  while(cur != 1) {
    if(seen[cur]) {
      cout << -1 << endl;
      return 0;
    }
    seen[cur] = true;
    cnt++;
    cur = a[cur];
  }
  cout << cnt << endl;
}

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

public class Main {

		
	
	public static void main(String[] args) throws Exception{
		BufferedReader  jk =  new BufferedReader(new InputStreamReader( System.in))  ; 
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)) ; 
		StringTokenizer ana = new StringTokenizer(jk.readLine()) ;
		int n =Integer.parseInt(ana.nextToken()) ; 
		int m = Integer.parseInt(ana.nextToken()) ;
		boolean mat[][]= new boolean[n][m] ; 
	    for(int i=0 ; i<n ;i++)
	    {
	    	String s= jk.readLine() ; 
	    	for(int j=0 ; j<m ;j++)
	    	{
	    		if(s.charAt(j)=='.') mat[i][j]=true ;
	    	}
	    }
	    long dp[][]= new long[n][m] ; 
	    dp[0][0] = 1 ;
	    long big = (long) (Math.pow(10, 9)+7) ; 
	    for(int i=1 ;i<n ;i++)
	    {
	    	if(mat[i][0])
	    	{
	    		if(dp[i-1][0]==1) dp[i][0]=1 ; 
	    	}
	    	
	    }
	    for(int j=1 ;j<m ;j++)
	    {
	    	if(mat[0][j])
	    	{
	    		if(dp[0][j-1]==1) dp[0][j]=1 ;
	    	}
	    }
	    for(int i=1 ;i<n ;i++)
	    {
	    	for(int j=1 ; j<m ;j++)
	    	{
	    		if(mat[i][j])
	    		{
	    			long y = dp[i-1][j]+dp[i][j-1] ; 
		    		if(y>=big)  y%=big ;
		    		dp[i][j]= y ; 
	    		}
	    		else dp[i][j]=0 ; 
	    		
	    	}
	    }
	    out.println(dp[n-1][m-1]);

		



		out.flush();
	}
}



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

#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define FOR( e, c ) for ( auto &e : c )

using VI = vector<int>;
using PII = pair<int,int>;
using ll = long long;

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

    priority_queue<PII> q;

    REP(i,0,n){
        int a;cin >> a;
        q.push(make_pair(a,1));
    }

    REP(i,0,m){
        int b,c;cin >> b >> c;
        q.push(make_pair(c,b));
    }

    ll ans = 0;
    REP(i,0,n){
        auto p=q.top(); // 先頭を取得
        q.pop(); // 先頭要素をキューから取り除く
        ans+=p.first;
        p.second--;
        if(p.second>0){
            q.push(p);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2420
#include<stdio.h>
int main(){
  int X,Y;
  scanf("%d%d",&X,&Y);
  
  for(int i=0;i<Y;i++){
    for(int t=0;t<Y;t++){
      if(Y==i*2+t*4 && X==i+t){
        printf("Yes");
        return 0;
      }
    }
  }
  printf("No");
  return 0;
}


Measured memory_bytes: 1720
#include <bits/stdc++.h>
#define MOD 1000000007
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
typedef long long ll;
typedef int64_t in;

using namespace std;


int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if(a==5 && b==5 && c==7 || a==5 && b==7 && c==5 || a==7 && b==5 && c==5){
        cout << "YES" << "\n";
    }else{
        cout << "NO" << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	ab := make([][2]int, n+2)
	for i := 1; i <= n; i++ {
		ab[i] = [2]int{iScan(), iScan()}
	}
	ab[0] = [2]int{0, mod * mod}
	ab[n+1] = [2]int{mod * mod, -1}
	sort.Slice(ab, func(i, j int) bool { return ab[i][0] < ab[j][0] })
	ans := -1
	for i := 0; i < n+1; i++ {
		ans += smaller(ab[i+1][0]-ab[i][0], ab[i][1]-ab[i+1][1])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5932
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int building[][][]= new int[4][3][10];
        int n=sc.nextInt();
        while(n-->0){
            building[sc.nextInt()-1][sc.nextInt()-1][sc.nextInt()-1]+=sc.nextInt();
        }
        for(int i=0;i<4;i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 10; k++) {
                    System.out.print(" "+building[i][j][k]);
                }
                System.out.println();
            }
            if(i<3){
                for (int k = 0; k < 20; k++)System.out.print("#");
                System.out.println();
            }
        }
    }
}




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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; i++) {
        cin >> A.at(i);
    }
    //奇数が奇数個になるときNG
    int odd_cnt = 0;
    for (int i=0; i<N; i++) {
        if (A.at(i) % 2 != 0) odd_cnt++;
    }
    if (odd_cnt % 2 != 0) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;  
}


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

namespace io {
char buf[1<<21], *p1 = buf, *p2 = buf;
inline char gc() {
    if(p1 != p2) return *p1++;
    p1 = buf;
    p2 = p1 + fread(buf, 1, 1 << 21, stdin);
    return p1 == p2 ? EOF : *p1++;
}
#define G gc

#ifndef ONLINE_JUDGE
#undef G
#define G getchar
#endif

template<class I>
inline void read(I &x) {
    x = 0; I f = 1; char c = G();
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = G(); }
    while(c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = G(); }
    x *= f;
}
template<class I>
inline void write(I x) {
    if(x == 0) {putchar('0'); return;}
    I tmp = x > 0 ? x : -x;
    if(x < 0) putchar('-');
    int cnt = 0;
    while(tmp > 0) {
        buf[cnt++] = tmp % 10 + '0';
        tmp /= 10;
    }
    while(cnt > 0) putchar(buf[--cnt]);
}

#define in(x) read(x)
#define outn(x) write(x), putchar('\n')
#define out(x) write(x), putchar(' ')

} using namespace io;

#define ll long long
const int N = 100010;

int ans[N];

int main() {
	int k, x,tot; read(k); read(x); int nk = k;
	for(int i = x; i >= -1000000 && nk; --i,--nk) {
		ans[++tot] = i;
	} nk = k - 1;
	for(int i = x + 1; i <= 1000000 && nk; ++i,--nk)ans[++tot] = i;
	sort(ans+1,ans+tot+1);
	for(int i = 1; i <= tot;++i)printf("%d ", ans[i]);
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
      Scanner scanner = new Scanner(System.in);
      String str = scanner.next();
      
      if(str.indexOf('9') != -1){
		System.out.println("Yes");
      }
      else{
        System.out.println("No");
      }   
	}
}

Measured memory_bytes: 23764
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
const long long MAX = (ll)1e5+100;

int main(void) {
   ll N;
   cin>>N;
   map<ll,ll> A;
   rep(i,0,N) {
      ll a;
      cin>>a;
      A[a] = i+1;
   }
   ll ans = 0;
   for (auto el : A) {
      if (el.first != el.second) ans++;
   }
   if (ans >2) cout<<"NO"<<endl;
   else cout<<"YES"<<endl;




   return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

int main(void){
    int A, B, T;
    cin >> A >> B>>T;
    cout << (T/A)*B << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
//constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

// MOD確認


struct UnionFind{
    vector<int> par;
    vector<ll> S;

    UnionFind(int N):par(N),S(N){
        rep(i,N){
          par[i] = i;
          S[i] = 1;
        }
    }

    int root(int x){
       while(x != par[x]){
        x =  par[x] = par[par[x]];
       }
       return x;
    }
    
    bool same(int x,int y){
      return root(x) == root(y);
    }

    void unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(!same(x,y)){
            S[root(x)] += S[root(y)];
            S[root(y)] = S[root(x)];
        }
        if(rx == ry)return;
        if(S[x] >= S[y]){
          par[ry] = rx;
        }else{
          par[rx] = ry;
        }
    }

    ll SIZE(int x){
        return S[root(x)];
    }
};


ll N,M;
UnionFind UF(100010);
ll A[100010];

int main(){
   cin >> N >> M;
   rep(i,M){
      ll a,b;
      cin >> a >> b;
      a--;b--;
      UF.unite(a,b);
   }
   ll ans = 0;
   rep(i,N){
      if(!A[UF.root(i)]){
         A[UF.root(i)] = 1;
         ans++;
      }
   }
   cout << ans - 1 << endl;
}

Measured memory_bytes: 5244
#include<cstdio>
#include<iostream>
using namespace std;
long long n,ans;
int main()
{
	scanf("%lld",&n);
	
	if(n & 1)
	return 0 & (long long)(puts("0"));
	n>>=1;
	while(n)
	{
		ans+=n/5;
		n/=5;
	}
	
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

#[macro_use]
mod _input {
    use std::fmt;
    use std::io::{self, Read};
    use std::str::{self, FromStr};

    macro_rules! input {
        ($($name:ident : $t:tt),*,) => {
            input!($($name: $t),*)
        };
        ($($name:ident : $t:tt),*) => {
            let mut _scanned = ::_input::Scanned::new(::std::io::stdin(), 1024);
            $(
                let $name = _read_value!(_scanned, $t);
            )*
        };
    }

    macro_rules! _read_value {
        ($scanned:expr, ($($t:tt),*)) => {
            ($(_read_value!($scanned, $t)),*)
        };
        ($scanned:expr, [$t:tt; $n:expr]) => {
            (0..$n).map(|_| _read_value!($scanned, $t)).collect::<Vec<_>>()
        };
        ($scanned:expr, _bytes) => {
            _read_value!($scanned, String).into_bytes()
        };
        ($scanned:expr, _index) => {
            _read_value!($scanned, usize) - 1
        };
        ($scanned:expr, $t:ty) => {
            $scanned.next::<$t>()
        };
    }

    #[derive(Default)]
    pub struct Scanned {
        buf: Vec<u8>,
        pos: usize,
    }

    impl Scanned {
        pub fn new<R: Read>(mut input: R, estimated: usize) -> Self {
            let mut buf = Vec::with_capacity(estimated);
            let _ = io::copy(&mut input, &mut buf).unwrap();
            if buf.last() != Some(&b'\n') {
                buf.push(b'\n'); // input may not end with '\n'
            }
            // https://doc.rust-lang.org/src/core/char/methods.rs.html#906-908
            // assert!(str::from_utf8(&buf).unwrap().bytes().all(|c| u32::from(c) <= 0x7F));
            Scanned { buf: buf, pos: 0 }
        }

        #[inline]
        pub fn next<T: FromStr>(&mut self) -> T
        where
            T::Err: fmt::Debug,
        {
            let mut start = None;
            loop {
                match (self.buf[self.pos], start.is_some()) {
                    (b' ', true) | (b'\n', true) => break,
                    (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                    (_, false) => start = Some(self.pos),
                }
            }
            let target = &self.buf[start.unwrap()..self.pos];
            unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
        }
    }
}

#[allow(dead_code)]
mod output {
    use std::io::{self, BufWriter, StdoutLock, Write as _Write};

    pub fn with_stdout<F: FnMut(&mut BufWriter<StdoutLock>)>(mut f: F) {
        let stdout = io::stdout();
        let mut stdout = BufWriter::new(stdout.lock());
        f(&mut stdout);
        stdout.flush().unwrap();
    }
}

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::Write;
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign,
};
use std::str::{self, FromStr};
use std::{char, cmp, f32, f64, fmt, i16, i32, i64, i8, thread, u16, u32, u64, u8};

fn main() {
    input! {
        x: u32,
    }
    let p = [7, 5, 3].contains(&x);
    println!("{}", if p { "YES" } else { "NO" });
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int N,A,B,C;
int l[9];

void input(){
  cin >> N >> A >> B >> C;
  for(int i=0;i<N;i++) cin >> l[i];
}

int dfs(int i, int a, int b, int c){
  if(i==N){
    if(!a || !b || !c) return INF;
    return abs(a-A)+abs(b-B)+abs(c-C);
  }
  int res = dfs(i+1, a, b, c);
  chmin(res, dfs(i+1, a+l[i], b, c)+(a?10:0));
  chmin(res, dfs(i+1, a, b+l[i], c)+(b?10:0));
  chmin(res, dfs(i+1, a, b, c+l[i])+(c?10:0));
  return res;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  input();
  cout << dfs(0,0,0,0) << endl;
  return 0;
}

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

typedef long long ll;
using namespace std;
using namespace atcoder;

#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define _repi(i, s, n) for(ll i = (ll)(s); i < (ll)n; i++)
#define REP(...) _overload(__VA_ARGS__, _repi, _rep,)(__VA_ARGS__)
#define all(v) (v).begin(),(v).end()
#define UNIQUE(v) (v).erase( unique( all(v) ), (v).end() );
#define MOD 1000000007

int main(){
	ll n, q;	cin >> n >> q;
	fenwick_tree<ll> fw(n);
	ll a;
	REP(i, n){
		cin >> a;
		fw.add(i, a);
	}
	ll tmp[3];
	REP(i, q){
		cin >> tmp[0] >> tmp[1] >> tmp[2];
		if( tmp[0] == 0 ){
			fw.add(tmp[1], tmp[2]);
		}else{
			cout << fw.sum(tmp[1], tmp[2]) << endl;
		}
	}

	return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef double ld;

vector<vector<int> > g;
vector<int> f;

void dfs(int v, int p) {
	if (sz(g[v]) == 1 && g[v][0] == p) {
		f[v] = 0;
		return;
	}
	f[v] = 0;
	for (int to : g[v]) {
		if (to == p) {
			continue;
		}
		dfs(to, v);
		f[v] ^= (f[to] + 1);
	}
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	//ifstream cin("input.txt");

	int n;
	cin >> n;

	g.resize(n);
	f.resize(n);
	for (int i = 0; i < n - 1; ++i) {
		int u, v;
		cin >> u >> v;
		--u, --v;
		g[u].pb(v);
		g[v].pb(u);
	}

	dfs(0, 0);

	cout << (f[0] ? "Alice\n" : "Bob\n");

}

Measured memory_bytes: 12416
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, Q: int, a: "List[int]", b: "List[int]", p: "List[int]", x: "List[int]"):
    conn = [[] for _ in range(N)]
    for i in range(N - 1):
        conn[a[i] - 1].append(b[i] - 1)
        conn[b[i] - 1].append(a[i] - 1)
    plus = [0] * N
    for i in range(Q):
        plus[p[i] - 1] += x[i]

    ret = [0] * N
    def dfs(idx, cur, visited):
        visited[idx] = True
        cur += plus[idx]
        ret[idx] = cur
        for nex in conn[idx]:
            if not visited[nex]:
                dfs(nex, cur, visited)
        return
    visited = [False] * N
    dfs(0, 0, visited)
    print(' '.join([str(r) for r in ret]))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    a = [int()] * (N-1)  # type: "List[int]" 
    b = [int()] * (N-1)  # type: "List[int]" 
    for i in range(N-1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    p = [int()] * (Q)  # type: "List[int]" 
    x = [int()] * (Q)  # type: "List[int]" 
    for i in range(Q):
        p[i] = int(next(tokens))
        x[i] = int(next(tokens))
    solve(N, Q, a, b, p, x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 322504
N = int(input())
lim = int(N ** 0.5)
ans = 0
for i in range(1, lim + 1):
    m = N // i
    quotient = N // m
    while m != 0:
        remainder = N % m
        if N // m != quotient or remainder > i:
            break
        if quotient == remainder:
            ans += m
            break
        m -= 1
print(ans)


Measured memory_bytes: 9428
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

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

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

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

#############
# Main Code #
#############

S = inputS()
s = set(S)

if len(s) == 2:
  if (S[0]==S[1] and S[2]==S[3]) or (S[0]==S[2] and S[1]==S[3]) or (S[0]==S[3] and S[2]==S[1]):
    print("Yes")
    exit()
    
print("No")

Measured memory_bytes: 63980
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}

int main(void){
	int a=in(),b=in(),c=in(),x=in(),i,j,k,t=0;
	rep(i,a+1){
		rep(j,b+1){
			rep(k,c+1){
				if(500*i+100*j+50*k==x)t++;
			}
		}
	}
	print(t);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] value = new int[N];
        int[] weight = new int[N];
        for(int i=0; i<N; i++){
            value[i] = sc.nextInt();
            weight[i] = sc.nextInt();
        }

        //dp配列
        int[][] dp = new int[N+1][W+1];

        for(int i=0; i < N; i++){
            for(int w=0; w <= W; w++){
                if(w >= weight[i]){
                    dp[i+1][w] = Math.max(dp[i][w-weight[i]]+ value[i], dp[i][w]);
                }else{
                    dp[i+1][w] = dp[i][w];
                }
            }
        }

        System.out.println(dp[N][W]);
    }
}


Measured memory_bytes: 31000
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<string> vs(n, "");
	for (int i = 0; i < n; i++) {
		cin >> vs[i];
	}
	unordered_set<string> us;
	for (int i = 0; i < n; i++) {
		if (us.find(vs[i]) != us.end()) {
			cout << "No" << endl;
			return 0;
		}
		if (i > 0 && vs[i][0] != vs[i - 1].back()) {
			cout << "No" << endl;
			return 0;
		}
		us.insert(vs[i]);
	}
	cout << "Yes" << endl;
}


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

#define MOD 10000007
#define f first
#define s second
#define es " "
#define pb push_back
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long int
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int main(){
    fastio;
    double im=0, n;
    cin >> n;
    for(int i=1; i<=n; i++){
        if(i%2!=0){
            im++;
        }
    }
    //cout << im << endl;
    cout.precision(10);
    cout.setf(ios::fixed);
    cout << im/n << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
chk=0
d=[]
for i in range(n):
    d.append(chk+a[i])
    chk=d[-1]
ans=1
for i in range(n-2,-1,-1):
    if d[i]*2>=a[i+1]:
        ans+=1
    else:
        break

print(ans)


Measured memory_bytes: 64664
def main():
    side_length = list(map(int, input().split(" ")))
    even_side = 0
    for i in range(3):
        if side_length[i] % 2 == 0:
            even_side = side_length.pop(i)
            break
    if even_side ** 2 + side_length[0] ** 2 == side_length[1] ** 2:
        print(even_side * side_length[0] // 2)
    else:
        print(even_side * side_length[1] // 2)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
def fctr1(n):
    f = {}
    c = 0
    r = int(n**0.5)
    for i in range(2, r+2):
        while n % i == 0:
            c += 1
            n = n//i
        if c != 0:
            f[i] = c
            c = 0
    if n != 1:
        f[n] = 1
    return f


N = int(input())
p = fctr1(N)
ans = 0
for k, v in p.items():
    c = 0
    while (v-c-1) >= 0:
        c += 1
        v -= c
    ans += c

print(ans)


Measured memory_bytes: 63352
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: u32,
        m: usize,
        sc: [(usize,usize);m],
    }

    let mut start = (10_isize).pow(n-1);
    if n==1 {
        start = 0;
    }

    for i in start..((10_isize).pow(n)){
        let num:Vec<char> = i.to_string().chars().collect();
        let mut flag: bool = true;
        for j in 0..m{
            let index = sc[j].0 - 1;
            if index >= num.len(){
                flag = false;
                break;
            }
            let expect_number = std::char::from_digit(sc[j].1 as u32, 10).unwrap();
            if num[index] != expect_number{
                flag = false;
            }
        }
        if flag {
            println!("{}", i);
            return;
        }
    }
    
    println!("-1");

}

Measured memory_bytes: 4352