akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << endl;}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int main() {
	var(int, n, a, b);
	print(min(n * a, b));
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
  string s,t;
  int n,a=0,b=0,c,d;
  cin>>s>>t>>n;
  P sp[s.size()+1],tp[t.size()+1];
  sp[0]=tp[0]=P(0,0);
  for(int i=1;i<=s.size();i++){
    if(s[i-1]=='A') a++;
    else b++;
    sp[i]=P(a,b);
  }
  a=0,b=0;
  for(int i=1;i<=t.size();i++){
    if(t[i-1]=='A') a++;
    else b++;
    tp[i]=P(a,b);
  }
  for(int i=0;i<n;i++){
    cin>>a>>b>>c>>d;
    if(((sp[b].first-sp[a-1].first)-(sp[b].second-sp[a-1].second)-((tp[d].first-tp[c-1].first)-(tp[d].second-tp[c-1].second)))%3==0){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }
}

Measured memory_bytes: 2432
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
using namespace std;
using u8t = std::uint64_t;
using i8t = std::int64_t;
using vi8t = std::vector<i8t>;
#define F3(I,A,B) for(i8t I=A,I##_N=B;I<I##_N;I++)
#define F(I,N) F3(I,0,N)
#define FR(I,N) for(i8t I=N;I--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;

i8t mod_pow(u8t x,u8t y,u8t mod){
  u8t r=1;
  while (y){
    if(y&1)r=r*x%mod;
    y>>=1;
    x=x*x%mod;
  }
  return r;
}

int main() {
  u8t mod=1'000'000'007;
  R(N)R(K);

  //P(mod_pow(K,N,mod));

  vi8t Z(K+1);
  F3(i,1,K+1)
    Z[i]=mod_pow(K/i,N,mod);

  vi8t E(K+1);
  for(int i=K;i>=1;i--){
    i8t z=Z[i];
    for(int j=2;j<=K;j++){
      if(i*j>K)break;
      z += mod - E[i*j];
    }
    E[i]=z%mod;
  }

  i8t ans=0;
  F3(i,1,K+1){
    ans = (ans+i*E[i])%mod;
  }
  P(ans);
  return 0;
}


Measured memory_bytes: 4804
#include <bits/stdc++.h>
using namespace std;
#define int long long int
vector<pair<int,int> > g[100001];
int par[100001];
int rank1[100001];
int find(int a){
	if(a==par[a]) return a;
	return par[a]=find(par[a]);
}
void merge(int a,int b){
	a=find(a),b=find(b);
	if(rank1[a]>rank1[b]){
		par[b]=a;
		rank1[a]+=b;
	}
	else{
		par[a]=b;
		rank1[b]+=a;
	}
}
int32_t main() {
	int n;
	cin>>n;
	vector<pair<int,int>> v,v2;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		v.push_back({a,i});
		v2.push_back({b,i});
		par[i]=i;
		rank1[i]=0;
	}
	sort(v.begin(),v.end());
	sort(v2.begin(),v2.end());
	vector<pair<int,pair<int,int>>> edges;
	for(int i=0;i<n-1;i++){
		g[v[i].second].push_back({v[i+1].second,v[i+1].first-v[i].first});
		g[v[i+1].second].push_back({v[i].second,v[i+1].first-v[i].first});
		edges.push_back({v[i+1].first-v[i].first,{v[i].second,v[i+1].second}});
	}
	for(int i=0;i<n-1;i++){
		g[v2[i].second].push_back({v2[i+1].second,v2[i+1].first-v2[i].first});
		g[v2[i+1].second].push_back({v2[i].second,v2[i+1].first-v2[i].first});
		edges.push_back({v2[i+1].first-v2[i].first,{v2[i].second,v2[i+1].second}});
	}
	sort(edges.begin(),edges.end());
	int cost=0;
	for(auto z:edges){
		int x=find(z.second.first),y=find(z.second.second);
		if(x!=y){
			cost+=z.first;
			merge(x,y);
		}
	}
	cout<<cost;
}

Measured memory_bytes: 22236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  int n= max(max(A,B),C);
  int m=n;
  for(int i=0;i<K;i++){
     m*= 2;
  }
  cout << A+B+C-n+m << endl;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    int b[n];
    rep(i, n) b[i] = 1;
    bool r[n] = {0};
    r[0] = 1;

    rep(i, m) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        if (r[x]) r[y] = 1;
        b[x] -= 1;
        b[y] += 1;
        if (b[x] == 0) r[x] = 0;
    }

    cout << count(r, r + n, 1) << endl;
    return 0;
}


Measured memory_bytes: 768
#include<iostream>

int main()
{
	int n, k;
	int a, b;
	
	std::cin >> n >> k;
	for( int i = 0; i < k; i++ ){
		std::cin >> a >> b;
		std::cout << std::min( a - 1, std::min( n - a, std::min( b - 1, n - b ) ) ) % 3 + 1 << std::endl;
	}

 	return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int main() {
	int K, S;
	cin >> K >> S;

	int count = 0;

	for (int x = 0; x <= K; x++) {
		for (int y = 0; y <= K; y++) {
			int z = S - x - y;
			if (0 <= z && z <= K) count++;
		}
	}

	cout << count << endl;

	return 0;
}


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

using namespace std;


int main(){
	
	int n;
	map<string,int>F1;
	cin>>n;
	while(n--){
		string s;
		cin>>s;
		F1[s]=1;
	}
	
	int m,f=0;
	cin>>m;
	while(m--){
		string s;
		cin>>s;
		if(F1[s]){
			f++;
			if(f%2)cout<<"Opened by "<<s<<endl;
			else cout<<"Closed by "<<s<<endl;
		}
		else{
			cout<<"Unknown "<<s<<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int a,b,c,k;
  cin>>a>>b>>c>>k;
  long long int ans;
  if(k>=a) { ans=a; k-=a; }
  else { cout<<k; return 0; }
  if(b<k) k-=b;
  else { cout<<ans; return 0; }
  cout<<ans-k;


}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
using namespace std;
const int SIZE=5*1e5;
const int INF=1<<30;
LL A[SIZE],B[SIZE],C[SIZE];
string s;
bool solve(){
	cin >> s;
	REP(i,s.size()){
		A[s[i]-'a']++;
	}
	if(abs(min(A[0],min(A[1],A[2]))-max(A[0],max(A[1],A[2])))<=1) return true;
	else return false;
}
int main(){
	if(solve())
		cout << "YES" << endl;
	else 
		cout << "NO" << endl;
 
	return 0;
}

Measured memory_bytes: 2560
import sys
input = sys.stdin.buffer.readline
import numpy as np

def main():
	N,A = map(int,input().split())
	x = list(map(int,input().split()))
	for i in range(N):
		x[i] -= A

	base = 50*50
	dp = np.zeros(base*2+1,dtype=int)
	dp[base] = 1
	for num in x:
		if num == 0:
			use = dp.copy()
			dp += use
		elif num > 0:
			use = dp[:-num].copy()
			dp[num:] += use
		else:
			use = dp[-num:].copy()
			dp[:num] += use

	print(dp[base]-1)

if __name__ == "__main__":
	main()

Measured memory_bytes: 12520
#include <iostream>
#include <stdio.h>
#include <string.h>

#define MAX 100
//#define NIL -1

struct Node {
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;
int n;

void insert(int val) {
    Node *y = NIL;
    Node *x = root;
    Node *z = new Node();
    
    z->key = val;
    z->left = NIL;
    z->right = NIL;
    
    while (x != NIL) {
        y = x;
        if (z->key > x->key) {
            x = x->right;
        } else {
            x = x->left;
        }
    }
    z->parent = y;
    
    if ( y == NIL ) {
        root = z;
    } else if ( y->key > z->key ) {
        y->left = z;
    } else {
        y->right = z;
    }
}

void preorder(Node *u) {
    if (u == NIL) return;
    
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

void inorder(Node *u) {
    if (u == NIL) return;
    
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void print() {
    inorder(root);
    printf("\n");
    preorder(root);
    printf("\n");
}

int main() {
    int val;
    char moji[10];
    
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%s", moji);
        if (moji[0] == 'i') {
            scanf("%d", &val);
            insert(val);
        } else {
            print();
        }
    }
    
    return 0;
}

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

signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
 
    ll n;
    cin>>n;
    vector<int> prime(n+1,1);
    for(int i=2;i<=n;i++){
        if(prime[i]){
            for(int j=i+i;j<=n;j+=i){
                prime[j]=0;
            }
        }
    }
    prime[0]=0,prime[1]=1;


    ll a[n+1]={};
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    ll cnt=0;
    ll ans[n+1]={};
    vector<int> t;

    for(int i=n;i>=1;i--){
        if(a[i] && ans[i]%2==0){
            ans[i]++;
            cnt++;
            t.push_back(i); 
            ans[1]++;           
            if(!prime[i]){
                for(int j=2;j*j<=i;j++){
                    if(i%j==0){
                        ans[j]++;
                        if(j!=i/j) ans[i/j]++;
                    }
                }
            }
            
        }
        else if(a[i]==0 && ans[i]%2==1){
            ans[i]++;
            cnt++;
            ans[1]++;
            t.push_back(i);      
            if(!prime[i]){
                for(int j=2;j*j<=i;j++){
                    if(i%j==0) {
                        ans[j]++;
                        if(j!=i/j) ans[i/j]++;
                    }
                }
            }
        }
    }
    
    cout<<cnt<<endl;
    for(auto i:t){
        cout<<i<<" ";
    }
    cout<<endl;

    
}

Measured memory_bytes: 5368
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)
// コンパイル　g++ -std=c++17 a.cpp

int main() {
    ll n;
    cin >> n;
    cout << (n+1) / 2 << endl;

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        out.println(new BufferedReader(new InputStreamReader(in)).readLine().toUpperCase());
    }
}

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

int main(){
	int n;
	cin>>n;
	
	vector<int> a(n*2);
	for(int i=0;i<n*2;i++){
		cin>>a[i];
	}
	
	sort(a.begin(),a.end());
	
	
	int ans=0;
	for(int i=0;i<n*2;i+=2){
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
int u[1100000];
vector<int> y;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=0;
  cin >>a>>b;
  c=a+b,d=a-b,e=a*b;
  cout <<max(c,max(d,e))<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
struct RSQ {
	int n;
	vector<int>d;
	RSQ(int m) {
		for (n = 1; n < m; n <<= 1);
		d.assign(2 * n, 0);
	}
	void add(int i, int x) {
		for (int j = (n + i); j > 0; j >>= 1)d[j] += x;
	}
	int getsum(int a, int b, int k = 1, int l = 0, int r = -1) {
		if (r == -1)r = n;
		if (r <= a || b <= l)return 0;
		if (a <= l&&r <= b)return d[k];
		else return getsum(a, b, 2 * k, l, (l + r) / 2) + getsum(a, b, 2 * k + 1, (l + r) / 2, r);
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	RSQ rsq(n);
	rep(i, 0, q) {
		int com, x, y; cin >> com >> x >> y;
		if (com)cout << rsq.getsum(x - 1, y) << endl;
		else rsq.add(x - 1, y);
	}
	return 0;
}

Measured memory_bytes: 4844
n=int(input())
s=input()
ans,a=0,[]
for i in range(n):
    if s[i] not in a:
        a+=[s[i]]
        b=[]
        for j in range(i+1,n):
            if s[j] not in b:
                b+=[s[j]]
                c=[]
                for k in range(j+1,n):
                    if s[k] not in c:
                        c+=[s[k]]
                        ans+=1
print(ans)

Measured memory_bytes: 9216
X = int(input())
if 400 <= X and X<=599:
    print(8)
elif 600 <=X and X<=799:
    print(7)
elif 800 <=X and X<=999:
    print(6)
elif 1000 <=X and X<=1199:
    print(5)
elif 1200 <=X and X<=1399:
    print(4)
elif 1400 <=X and X<=1599:
    print(3)
elif 1600 <=X and X<=1799:
    print(2)
elif 1800 <=X and X<=1999:
    print(1)

Measured memory_bytes: 9192
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<cstring>
using namespace std;
int n,x;
map<int,int> m;
priority_queue<int,vector<int>,less<int> > q; 
int read(){
    int ans=0,f=1;
    char ch=getchar();
    while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){ans=ans*10+ch-'0';ch=getchar();}
    return ans*f;
}
int main(){
	std::ios::sync_with_stdio(false);
	n=read();
	for (int i=0;i<n;i++)	x=read(),m[x]++;
	map<int,int>::iterator it;
	for (it=m.begin();it!=m.end();it++)
		if (it->second>1) q.push(it->first);
	if (q.empty()) {cout<<0;return 0;}
	int a=0,b=0;
	a=q.top();q.pop();
	it=m.begin();
	if (q.empty())
		{if (it->second<4){cout<<0;return 0;}else {cout<<1ll*a*a;return 0;}}
	b=q.top();q.pop();
	if (m[a]>3) cout<<1ll*a*a;else	cout<<1ll*a*b;
	return 0;
}

Measured memory_bytes: 4992
def rec(L):
    return sum([d for a, b, c, d in X if L[b] - L[a] == c]) if len(L) > N else max([rec(L + [i]) for i in range(L[-1], M)])

N, M, Q = map(int, input().split())
X = []
for _ in range(Q):
    a, b, c, d = map(int, input().split())
    X.append((a, b, c, d))
print(rec([0]))

Measured memory_bytes: 9212
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define pi (acos(-1))

int main()
{
    int n, k;
    std::cin >> n >> k;
    double ans = 0.0;
    for (int i = 1; i <= n; ++i)
    {
        double t = 1.0 / n;
        ll cur_score = i;
        while (cur_score < k)
        {
            cur_score *= 2;
            t /= 2.0;
        }
        ans += t;
    }

    std::cout << std::setprecision(12) << ans << std::endl;

    return 0;
}

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

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using int128 = __int128;
using cint = cpp_int;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ull MAX = ULONG_MAX;
#define endl '\n'
#define space ' '
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << endl;                                                          \
    }

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define each(i, a) for (auto &&i : a)
#define rep(i, n) inc(i, 0, n - 1)

// Stream
#define input(a) scanf("%lld", &(a))
#define output(a) printf("%lld\n", (a))
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }

ll N, M, X, A, C;

signed main() {
    cin >> N;
    rep(i, N) {
        cin >> A;
        if(abs(A) > M) {
            M = abs(A);
            X = i + 1;
            C = A > 0;
        }
    }
    if(M == 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << 2 * (N - 1) << endl;
    rep(i, N) if(i + 1 != X) cout << X << ' ' << i + 1 << endl;
    if(C) inc(i, 1, N - 1) cout << i << ' ' << i + 1 << endl;
    else dec(i, N - 1, 1) cout << i + 1 << ' ' << i << endl;
}

// for compilation: g++ -O3 -o _ _.cpp -std=c++17

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

using namespace std;

typedef long long Int;

Int func(Int x, Int y, Int z)
{
	return (y / z - (x - 1) / z);
}

Int ct(Int p)
{
	Int i, j;
	Int res = 0;
	for (i = 1, j = 1; i * 10 - 1 < p; i *= 10, j++){
		res += func(i, i * 10 - 1, 1) * j;
		res -= func(i, i * 10 - 1, 3) * j;
		res -= func(i, i * 10 - 1, 5) * j;
		res += func(i, i * 10 - 1, 15) * j;
		res += (func(i, i * 10 - 1, 3) + func(i, i * 10 - 1, 5)) * 4;
	}
	res += func(i, p, 1) * j;
	res -= func(i, p, 3) * j;
	res -= func(i, p, 5) * j;
	res += func(i, p, 15) * j;
	res += (func(i, p, 3) + func(i, p, 5)) * 4;
	return (res);
}

string fb(Int x)
{
	if (x % 15 == 0) return ("FizzBuzz");
	if (x % 3 == 0) return ("Fizz");
	if (x % 5 == 0) return ("Buzz");

	char s[64];
	sprintf(s, "%lld", x);
	return ((string)s);
}

int main()
{
	Int n;

	scanf("%lld", &n);

	Int l = 1, r = 100000000000000000ll;

	while (l != r){
		Int m = (l + r + 1) / 2;
		if (ct(m) <= n) l = m;
		else r = m - 1;
	}

	Int p = ct(l) - fb(l).size() + 1;
	string s;
	for (int i = 0; i <= 9; i++) s += fb(l + i);

	for (int i = 0; p < n + 20; p++, i++) if (n <= p) printf("%c", s[i]);

	printf("\n");

	return (0);
}

Measured memory_bytes: 1232
class SegTree:  # モノイドに対して適用可能、Nが2冪でなくても良い
    def __init__(self,N,seg_func,unit):
        self.N = 1 << (N-1).bit_length()
        self.func = seg_func
        self.unit = unit
        self.tree = [self.unit]*(2*self.N)

    def build(self,init_value):  # 初期値を[N,2N)に格納
        for i in range(len(init_value)):
            self.tree[i+self.N] = init_value[i]
        for i in range(self.N-1,0,-1):
            self.tree[i] = self.func(self.tree[i << 1],self.tree[i << 1 | 1])

    def set_val(self,i,x):  # i番目(0-index)の値をxに変更
        i += self.N
        self.tree[i] = x
        i >>= 1
        while i:
            self.tree[i] = self.func(self.tree[i << 1],self.tree[i << 1 | 1])
            i >>= 1

    def fold(self,L,R):  # [L,R)の区間取得
        L += self.N
        R += self.N
        vL = self.unit
        vR = self.unit
        while L < R:
            if L & 1:
                vL = self.func(vL,self.tree[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.func(self.tree[R],vR)
            L >>= 1
            R >>= 1
        return self.func(vL,vR)


import sys
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N,K = MI()
ST = SegTree(300001,max,0)

# dp[i][j] = A1~Ai を用いて、末尾が j になり条件を満たす数列の長さの最大値
# dp[i][j] = 1+max(dp[i-1][Ai-K],…,dp[i-1][Ai+K]) if j == Ai else dp[i-1][j]
# この dp をセグメントツリーにのせて考える

for i in range(N):
    a = I()
    ST.set_val(a,1+ST.fold(max(0,a-K),min(300000,a+K)+1))

print(ST.fold(0,300001))


Measured memory_bytes: 103904
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] strArray = new String[2];
    int h, w;
    StringBuilder sb = new StringBuilder();
    while(true) {
      strArray = br.readLine().split(" ");
      h = Integer.parseInt(strArray[0]);
      w = Integer.parseInt(strArray[1]);
      if (h == 0 && w == 0) {
        break;
      }
      for(int i = 0;i < h;i++) {
        for(int j = 0;j < w;j++) {
          if(i % 2 == 0) {
            if (j % 2 == 0) {
              sb.append("#");
            }else {
              sb.append(".");
            }
          }else {
            if(j % 2 == 0) {
              sb.append(".");
            }else {
              sb.append("#");
            }
          }
        }
        sb.append("\n");
      }
      sb.append("\n");
    }
    System.out.print(sb);
  }
}

Measured memory_bytes: 25484
#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;
const int mod=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  cout<<a[N-1]-a[0]<<endl;
  return 0;
}

Measured memory_bytes: 3564
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let n: usize = sc.read();
    let h: usize = sc.read();
    let w: usize = sc.read();
    let mut edges = vec![];
    for _ in 0..n {
        let r = sc.read::<usize>() - 1;
        let c = sc.read::<usize>() - 1;
        let a = sc.read::<u64>();
        edges.push((a, r, c + h));
    }
    edges.sort();

    let mut ans = 0;
    let mut uf = UnionFind::new(h + w);
    for (a, r, c) in edges.into_iter().rev() {
        let r = uf.find(r);
        let c = uf.find(c);
        if r == c {
            if uf.sizes[r] > uf.edges[r] {
                uf.edges[r] += 1;
                ans += a;
            }
        } else {
            if uf.edges[r] + uf.edges[c] + 1 <= uf.sizes[r] + uf.sizes[c] {
                uf.unite(r, c);
                ans += a;
            }
        }
    }

    println!("{}", ans);
}

pub struct UnionFind {
    parent: Vec<usize>,
    sizes: Vec<usize>,
    size: usize,
    edges: Vec<usize>,
}

impl UnionFind {
    pub fn new(n: usize) -> UnionFind {
        UnionFind {
            parent: (0..n).map(|i| i).collect::<Vec<usize>>(),
            sizes: vec![1; n],
            size: n,
            edges: vec![0; n],
        }
    }

    pub fn find(&mut self, x: usize) -> usize {
        if x == self.parent[x] {
            x
        } else {
            let px = self.parent[x];
            self.parent[x] = self.find(px);
            self.parent[x]
        }
    }

    pub fn unite(&mut self, x: usize, y: usize) -> bool {
        let parent_x = self.find(x);
        let parent_y = self.find(y);
        if parent_x == parent_y {
            return false;
        }

        let (large, small) = if self.sizes[parent_x] < self.sizes[parent_y] {
            (parent_y, parent_x)
        } else {
            (parent_x, parent_y)
        };

        self.parent[small] = large;
        self.sizes[large] += self.sizes[small];
        self.sizes[small] = 0;

        self.edges[large] += self.edges[small] + 1;
        self.edges[small] = 0;

        self.size -= 1;
        return true;
    }
}
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

ll mod = 1e9 + 7;

int main() {
    string s; cin >> s;
    int n = s.length();
    int a[1 << 17];
    for(int i=0; i<n; i++) {
        int ln = i;
        while(i + 1 < n && s[i] == s[i + 1]) i++;
        int len = i - ln + 1;
        if(s[i] == 'L') {
            a[ln] += (len + 1) / 2;
            a[ln - 1] += len / 2;
        }
        else {
            a[i] += (len + 1) / 2;
            a[i + 1] += len / 2;
        }
    }
    for(int i=0; i<n; i++) cout << a[i] << " ";
}


Measured memory_bytes: 4116
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
    if(b==0)return a;
    else return gcd(b,a%b);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a,b;
    cin>>a>>b;
    cout<<((long long)(a/gcd(a,b)))*b<<endl;
    return 0;
}


Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b) = get!(usize, usize);
    let s = get!(String).chars().collect::<Vec<_>>();
    if s.len() != a+b+1 || s[a] != '-' {
        println!("No");
        return;
    }
    for i in 0..a+b+1 {
        if i != a && (s[i] < '0' || s[i] > '9') {
            println!("No");
            return;
        }
    }
    println!("Yes");
}

Measured memory_bytes: 2164
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<pair<pair<string, int>, int>> v(n);
  rep(i, n){
    string s;
    int p;
    cin >> s >> p;
    v[i] = make_pair(make_pair(s, -p), i + 1);
  }
  sort(v.begin(), v.end());
  for(auto a : v){
    cout << a.second << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  if (n%1000!=0) {
  int a = n/1000+1;
  cout << a*1000-n << endl;
  }
  if (n%1000==0) {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    unsigned long long int H, W, a = 0, b = 0; cin >> H >> W;
    if (H % 2 == 0) a = H / 2;
    else a = H / 2 + 1;
    if (W % 2 == 0) b = W / 2;
    else b = W / 2 + 1;
    unsigned long long int x = H - a, y = W - b;
    if (W == 1 || H == 1) {
        printf("%d\n", 1);
        return 0;
    }
    unsigned long long int ans = (a * b) + (x * y);
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 3616
#include<stdio.h>
#define SIZE 100001
#define TRUE 1
#define FALSE 0

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

typedef struct{
  int head;
  int tail;
  process p[SIZE];
}queue;
  
void enqueue(queue *enq,process x){
  enq->p[enq->tail] = x;
  if(enq->tail+1 == SIZE-1) enq->tail=0;
  else enq->tail++;
}

process dequeue(queue *deq){
  process p=deq->p[deq->head];
  
  if(deq->head+1 == SIZE-1) deq->head=0;
  else deq->head++;

  return p;
}

int isEmpty(queue q){
  if(q.tail == q.head) return TRUE;
  else return FALSE;
}

int main(){
  queue p;
  process x;
  int i;
  int n,q,sum=0;
  
  scanf("%d%d",&n,&q);
  for(i=0;i<n;i++){
    scanf("%s",p.p[i].name);
    scanf("%d",&p.p[i].time);
  }
   p.head = 0;
   p.tail = n;
  while(!isEmpty(p)){
    x = dequeue(&p);
    if(x.time<=q) sum+=x.time;
    else sum+=q;
    x.time -= q;
    if(x.time>0) enqueue(&p,x);
    else printf("%s %d\n",x.name,sum); 
  }  
  return 0;
}



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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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 n,m;
string s[111];
void solve(){
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		cin >> s[i];
		s[i] = '#'+s[i]+'#';
	}
	s[0] = s[n+1] = s[1];
	for(int i = 0; i <= m+1; i++){
		s[0][i] = s[n+1][i] = '#';
	}
	
	priority_queue<pair<P,P>,vector<pair<P,P>>,greater<pair<P,P>>> q;
	q.push(make_pair(P(0,0),P(1,1)));
	int used[111][111] = {0};
	for(int i = 0; i < 111; i++) fill(used[i], used[i]+111, INF);
	while(!q.empty()){
		pair<P,P> p = q.top(); q.pop();
		int x = p.second.first, y = p.second.second;
		int c = p.first.first, d = p.first.second;
		if((s[x][y] == '#') ^ (d == 1)) c++;
		if(x == n && y == m){
			cout << (c+1)/2 << endl;
			break;
		}
		if(used[x][y] <= c) continue;
		used[x][y] = c;
		int nx = x+1, ny = y;
		if(nx <= n && ny <= m){
			q.push(make_pair(P(c,s[x][y]=='#'),P(nx,ny)));
		}
		nx = x, ny = y+1;
		if(nx <= n && ny <= m){
			q.push(make_pair(P(c,s[x][y]=='#'),P(nx,ny)));
		}
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  int n,m;
  cin >> n >> m;
  vi data(m);
  rep(i,m) cin >> data[i];
  int sum = 0;
  rep(i,m) sum += data[i];
  int ans = n-sum;
  if(ans >= 0) cout << ans;
  else cout << -1;
  hinata;
}

Measured memory_bytes: 3696
#include <iostream>
#include <string>
using namespace std;

int main()
{
	char sastr;
	sastr = 'a' - 'A'; //大文字と小文字の差
	string str;
	char newch;
	getline(cin,str);	
	for (int i = 0 ; i < str.size() ; i++)
	{
		if (( str[i] >= 'a') && ('z' >= str[i]))
		{
			newch =+ str[i] - sastr;
		} else 
		{
			newch =+ str[i];
		}
		cout << newch;	
	}
	cout <<endl;
	return 0;
}

Measured memory_bytes: 1168
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m;char a,b;cin>>n>>m>>a>>b;
	vs in(n);
	rep(i,n)cin>>in[i];
	vvi G(26,vi(26,inf));
	rep(i,26)G[i][i]=0;
	
	rep(i,n){
		char s;
		bool h=false;
		rep(j,m){
			if(in[i][j]=='-'&&!h){
				s=in[i][j-2]-'A';
				h=true;
			}else if(in[i][j]!='-'&&h){
				h=false;
				G[s][in[i][j+1]-'A']=
					G[in[i][j+1]-'A'][s]=1;
//				cout<<(char)(s+'A')<<" "<<in[i][j+1]<<endl;
			}
		}
	}
	rep(j,m){
		char s;
		bool h=false;
		rep(i,n){
			if(in[i][j]=='|'&&!h){
				s=in[i-2][j]-'A';
				h=true;
			}else if(in[i][j]!='|'&&h){
				h=false;
				G[s][in[i+1][j]-'A']=
					G[in[i+1][j]-'A'][s]=1;
//				cout<<(char)(s+'A')<<" "<<in[i+1][j]<<endl;
			}
		}
	}
	
	
	rep(k,26)rep(i,26)rep(j,26)
		G[i][j]=min(G[i][k]+G[k][j],G[i][j]);
		
	cout<<G[a-'A'][b-'A']<<endl;
}







Measured memory_bytes: 3228
/*
 * ARC096_D.cpp
 *
 *  Created on: May 17, 2018
 *      Author: 13743
 */
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}

lng x[100000];
lng v[100000];

lng pt[100000];
lng ptRev[100000];

lng pm[100000];
lng pmR[100000];

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

	int N;
	lng C;
	cin >> N >> C;
	REP(i, N) {
		cin >> x[i] >> v[i];
	}

	lng taken = 0;
	REP(i, N) {
		taken += v[i];
		pt[i] = taken - x[i];
	}
	taken = 0;
	FORD(i, N-1, 0) {
		taken += v[i];
		ptRev[N-1-i] = taken - (C-x[i]);
	}

	pm[0] = pt[0];
	pmR[0] = ptRev[0];
	FOR(i, 1, N-1) {
		pm[i] = max(pm[i-1], pt[i]);
		pmR[i] = max(pmR[i-1], ptRev[i]);
	}

	lng opt = max(pm[N-1], pmR[N-1]);
	opt = (opt > 0) ? opt : 0;
	REP(i, N-1) {
		opt = max(opt, pt[i] - x[i] + pmR[N-2-i]);
		opt = max(opt, ptRev[i] - (C-x[N-1-i]) + pm[N-2-i]);
	}
	cout << opt << endl;
}






Measured memory_bytes: 5120
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, M = LI()
    AB = [LI() for _ in range(N)]

    W = [[] for _ in range(M + 1)]
    for a, b in AB:
        if 0 <= M - a:
            W[M-a].append(b)
    # print(W)

    # 選択肢の少ない後ろの日付から決めていく
    ans = 0
    hq = []
    for i in reversed(W):
        for j in i:
            heapq.heappush(hq, -j)
        if hq:
            ans -= heapq.heappop(hq)

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 38592
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long  long
#define INF 0x3f3f3f3f
#define pll pair<long long , long long>
const int MAX=1e6+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
vector<int>adj[MAX];
int prime[MAX];
int main() 
{
	
	int cnt =0;
	int n;
	cin>>n;
	int f=0;
	for(int i=0;i<n;i++){
		int x, y;
		cin>>x>>y;
		if(x==y){
			cnt = cnt+1;
		}
		else{
			cnt = 0;
		}
		if(cnt>=3)
			f=1;

	}
	if(f)
		cout<<"Yes";
	else
		cout<<"No";

}


Measured memory_bytes: 27072
#include<stdio.h>
int main()
{
    int n, b[512], f[512], r[512], v[512];
    int j[4][3][10] = { 0 };
    int a=0,i,m,k;

    scanf("%d",&n);
    for (i = 0; i < n; i++){
        scanf("%d%d%d%d",&b[i],&f[i],&r[i],&v[i]);
    }
    for (i = 0; i < n; i++){
        j[b[i]-1][f[i]-1][r[i]-1]+=v[i];
    }
    for (i = 0; i < 4; i++){
        if (a)printf("####################\n");
        for (m = 0; m < 3; m++){
            for (k = 0; k < 10; k++){
                printf(" %d",j[i][m][k]);
            }
            printf("\n");
            a = 1;
        }
    }
    return 0;
}

Measured memory_bytes: 2716
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.parents = [i for i in range(n+1)]
        self.size = [1]*(n+1)
    def find(self,x):
        if self.parents[x]==x:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]
    def unite(self,x,y):
        xRoot = self.find(x)
        yRoot = self.find(y)
        if xRoot == yRoot:
            return
        if self.size[xRoot]>self.size[yRoot]:
            self.parents[yRoot] = xRoot
        else:
            self.parents[xRoot] = yRoot
            if self.size[xRoot] == self.size[yRoot]:
                self.size[yRoot]+=1

N = int(input())
edges = []
nodes = []
for i in range(N):
    x,y = map(int,input().split())
    nodes.append((i,x,y))
nodes.sort(key=lambda x: x[1])
for i in range(1,N):
    w = nodes[i][1]-nodes[i-1][1]
    edges.append((w,nodes[i][0],nodes[i-1][0]))
nodes.sort(key=lambda x: x[2])
for i in range(1,N):
    w = nodes[i][2] - nodes[i-1][2]
    edges.append((w,nodes[i][0],nodes[i-1][0]))
edges.sort()
tree = UnionFind(N)
cost = 0
for w,a,b in edges:
    if tree.find(a) != tree.find(b):
        tree.unite(a,b)
        cost += w
print(cost)

Measured memory_bytes: 124836
n, t = map(int, input().split())
ct = []
for i in range(n):
    c, time = map(int, input().split())
    ct.append([c, time])
min_t = t
cost = float('inf')
cnt = 0
for i in range(n):
    if ct[i][1] > t:
        cnt += 1
    else:
        if cost >= ct[i][0]:
            min_t = ct[i][1]
            cost = ct[i][0]
if cnt == n:
    print('TLE')
else:
    print(cost)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n);
  bool zero = false;
  rep(i, n) {
    cin >> A[i];
    if(A[i] == 0) zero = true;
  }
  if(zero) {
    cout << 0 << endk;
    return 0;
  }
  ll ans = 1;
  rep(i, n) {
    if(A[i] > (ll)1e+18/ans) {
      cout << -1 << endk;
      return 0;
    }
    ans *= A[i];
  }
  cout << ans << endk;
  return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[105];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M, X;
    cin >> N >> M >> X;
    REP(i, M) {
        cin >> A[i];
    }

    ll ans = INF;
    {
        ll s = 0;
        for (ll i = X; i < N; ++i) {
            REP(j, M) {
                if (A[j] == i)
                    s++;
            }
        }
        ans = std::min(ans, s);
    }
    {
        ll s = 0;
        for (ll i = X; i >= 0; --i) {
            REP(j, M) {
                if (A[j] == i)
                    s++;
            }
        }
        ans = std::min(ans, s);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e17
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll adj1[305][305]={0},adj2[305][305]={0};
	for(int i=0; i<=300; i++){
		for(int j=0; j<=300; j++){
			if(i!=j){
				adj1[i][j]=inf;
				adj2[i][j]=inf;
			}
	}
    }
	int n,m,l;
	cin>>n>>m>>l;
	for(int i=0; i<m; i++){
		ll a,b,c;
		cin>>a>>b>>c;
		adj1[a][b]=c;
		adj1[b][a]=c;
	}
	for(int k=1; k<=n; k++){
		for(int i=1; i<=n; i++){
			for(int j=1; j<=n; j++){
				adj1[i][j]=min(adj1[i][j],adj1[i][k]+adj1[k][j]);
			}
		}
	}
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			if(adj1[i][j]<=l){
				adj2[i][j]=1;
			}
		}
	}
    	for(int k=1; k<=n; k++){
		for(int i=1; i<=n; i++){
			for(int j=1; j<=n; j++){
				adj2[i][j]=min(adj2[i][j],adj2[i][k]+adj2[k][j]);
			}
		}
	}
	int q;
	cin>>q;
	while(q--)
	{
		int a,b;
		cin>>a>>b;
		if(adj2[a][b]>=inf)
		 cout<<"-1\n";
		else
		 cout<<adj2[a][b]-1<<"\n";
	}
	return 0;
}

Measured memory_bytes: 5108
#include <cmath>
#include <iostream>
#include <string>

using namespace std;
typedef long long lint;

lint N;
lint ans;

void resolve()
{
    cin >> N;

    string S = to_string(N);
    int keta = S.length();

    ans = 0;
    if (N % 2 == 0) {
        lint i = 1;
        while (1) {
            lint tmp = N / ((lint)pow(5, i) * 2);
            if (tmp == 0) break;
            ans += tmp;
            i++;
        }
    }

    cout << ans << endl;
}

int main()
{
    resolve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int H, W;
	cin >> H >> W;
	vector<vector<bool>> red(H, vector<bool>(W)), blue(H, vector<bool>(W));

	for (int i = 0; i < H; ++i){
		for (int j = 0; j < W; ++j){
			if (i % 2)	red[i][j] = true;
			else	blue[i][j] = true;
		}
		red[i][0] = true;
		red[i][W - 1] = false;
		blue[i][W - 1] = true;
		blue[i][0] = false;
	}

	for (int i = 0; i < H; ++i){
		for (int j = 0; j < W; ++j){
			char t;
			cin >> t;
			if (t == '#'){
				red[i][j] = blue[i][j] = true;
			}
		}
	}

	for (int i = 0; i < H; ++i){
		for (int j = 0; j < W; ++j){
			if (red[i][j])	cout << '#';
			else	cout << '.';
		}
		cout << endl;
	}
	cout << endl;
	for (int i = 0; i < H; ++i){
		for (int j = 0; j < W; ++j){
			if (blue[i][j])	cout << '#';
			else	cout << '.';
		}
		cout << endl;
	}
	cin >> H;
	return 0;
}


Measured memory_bytes: 896
#include<cmath>
#include<cstdio>
#include<cassert>
#include<cstring>
#include<algorithm>
#define MN 51
#define Cx 0.03
#define Cy 0.03
#define eps 1e-7
using namespace std;

int read_p,read_ca;
inline int read(){
    read_p=0;read_ca=getchar();
    while(read_ca<'0'||read_ca>'9') read_ca=getchar();
    while(read_ca>='0'&&read_ca<='9') read_p=read_p*10+read_ca-48,read_ca=getchar();
    return read_p;
}
int n,m;
int main(){
	register int i;
	n=read();m=read();
	if (n==1) n=14;
	if (m==1) m=14;
	if (n<m) puts("Bob");else if (n==m) puts("Draw");else puts("Alice");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int getint() {
	char C;
	while (!isdigit(C = getchar()));
	int A = C - '0';
	while (isdigit(C = getchar())) A = A * 10 + C - '0';
	return A;
}

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


	int N;
	N = getint();
	int A[200000];
	ll B[200001], C;
	B[0] = 0;
	C = 0;

	vector<int> V;
	V.pb(0);
	rep(i, N) A[i] = getint();
	ll mae = A[0];
	rep(i, N) {
		ll a = A[i];
		B[i + 1] = B[i];
		if (mae >= a) {
			a *= 4;
			while (mae >= a) {
				V.pb(0);
				a *= 4;
			}
			V[(int)V.size() - 1]++;
		}
		else {
			while (mae < a) {
				int kari = V[(int)V.size() - 1];
				B[i + 1] += kari;
				if (V.size() > 1) {
					V.pop_back();
					V[(int)V.size() - 1] += kari;
				}
				mae *= 4;
			}
			V[(int)V.size() - 1]++;
		}
		mae = A[i];
	}
	V.clear();
	mae = A[N - 1];
	V.pb(0);
	ll kotae = 2 * B[N] + N;
	for (int i = N - 1; i >= 0; i--) {
		ll a = A[i];
		if (mae >= a) {
			a *= 4;
			while (mae >= a) {
				V.pb(0);
				a *= 4;
			}
			V[(int)V.size() - 1]++;
		}
		else {
			while (mae < a) {
				int kari = V[(int)V.size() - 1];
				C += kari;
				if (V.size() > 1) {
					V.pop_back();
					V[(int)V.size() - 1] += kari;
				}
				mae *= 4;
			}
			V[(int)V.size() - 1]++;
		}
		mae = A[i];
		kotae = min(kotae, 2 * B[i] + 2 * C + i);
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 2560