akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	int s, w;
	cin >> s >> w;
	if(w>=s)cout << "unsafe" << endl;
	else cout <<"safe" << endl;
	return 0;
}


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

using namespace std;

#define     ll long long
#define     nl '\n'
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define     mod             100000000
#define     space           100005

vector<ll> pwx(61);
void cal(ll x){ pwx[0] = 1; for(ll i = 1; i < 61 ; i++)pwx[i] = x*pwx[i-1]; }

int main(){
    // boost;
    
    // cal(2);

    ll n;
    cin >> n;
    cout << n + n*n + n*n*n << nl;    
    
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;

int N, M;
int A, T;
int main(void){
    cin >> N >> M;
    REP(i,M) {
        cin >> A;
        T += A;
    }
    cout << max(-1, N - T) << endl;
    return 0;
}



Measured memory_bytes: 3624
def main():
    import sys
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    N = int(input())
    An = [int(x) for x in input().strip().split()]
    if N == 0:
        if An[0] == 1:
            print(1)
        else:
            print(-1)
        exit()
    if An[0] != 0:
        print(-1)
        exit()
    ans = 1
    node = 1
    total = sum(An)
    for n, a in enumerate(An[1:], start=1):
        node_ = min(total, node * 2)
        ans += node_
        node = node_ - a
        if node_ < 0:
            print(-1)
            exit()
        total -= a

    if node != 0:
        print(-1)
    else:
        print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 20148
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=1;i<=101;i++)
	{
		if(a*i%b==c)
		{
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
import Control.Applicative

populate core n left =
  take (n-2) left++core++drop (n-2) left

solve n x m | x == 1 = "No\n"
            | x == m = "No\n"
            | otherwise = unlines $ ("Yes":) $ map show $ populate [x-1,x,x+1] n $ [1..x-2]++[x+2..m]

main = do
  [n,x] <- map read.words <$> getLine :: IO [Int]
  let m = 2*n-1
  putStr $ solve n x m


Measured memory_bytes: 9212
from fractions import gcd
a, b = map(int, input().split())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
print(len(set(prime_factorize(gcd(a, b)))) + 1)

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;

#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        cout << it << " ";        \
    }                             \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
#define mod 1000000007
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second

int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
vector<vec> ans(1e6 + 5);
//vec val1;
int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vec v;
    for (int i = 2; i <= sqrt(n);i++){
        if(n%i==0){
            if(i*i==n)
                v.pb(i);
            else{
                v.pb(i);
                v.pb(n / i);
            }
        }
    }
    int ans = 1;
    //deb1a(v);
    fo(i,v.size()){
        int temp = n;
        while(temp%v[i]==0)
            temp /= v[i];
        if(temp%v[i]==1)
            ans++;
        //deb(temp);
    }
    //deb(ans);
    n--;
    for (int i = 2; i <= sqrt(n);i++){
        if(n%i==0){
            if(i*i==n)
                ans++;
            else{
                ans += 2;
            }
        }
    }
    if(n-1>1)
        ans++;
    cout << ans;
}


Measured memory_bytes: 23808
#include <stdio.h>

#define int long long

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

signed main(){
	int N, i, T, LCM = 1;
	scanf("%lld", &N);
	for(i = 0; i < N; i++){
		scanf("%lld", &T);
		LCM *= T / gcd(LCM, T);
	}
	printf("%lld\n", LCM);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <complex>
#include <iterator>
using namespace std;

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

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define repfn(i, a, cont, next) \
  for(auto i = (a); [=](){return(cont);}(); i = [=](){return(next);}())
#define repby(i, a, b, step) repfn(i, a, i < b, i + step)
#define repab(i, a, b) repby(i, (a), (b), 1)
#define rep(i, n) repab(i, 0, (n))
#define pb push_back
#define sz(c) int((c).size())

int main(int argc, char **argv)
{
  int N;
  vi v(3);
  cin >> N;
  while (N--) {
    cin >> v[0] >> v[1] >> v[2];
    sort(all(v));
    if (v[0]*v[0] + v[1]*v[1] == v[2]*v[2])
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

main()
{
    int n; cin>>n;
    int mx=0;
    bool f=true;

    rep(i,n)
    {
        int a;
        cin>>a;
        mx=max(mx,a);
        if(mx-a>1)f=false;
    }
    if(f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
c=[[int(i) for i in input().split()] for j in range(3)]
ans='No'
for x in range(101):
  for y in range(101):
    for z in range(101):
      d=[]
      d.append([c[0][j]-x for j in range(3)])
      d.append([c[1][j]-y for j in range(3)])
      d.append([c[2][j]-z for j in range(3)])
      if sum(len(set(d[i][j] for i in range(3))) for j in range(3))==3:
             ans='Yes'
print(ans)

Measured memory_bytes: 57048
#include<bits/stdc++.h>
#define int long long
using namespace std;
vector<int> w[120001];
int n,m,s,d[120001],f[120001],cnt[120001],need[120001];
void dfs(int u,int p,int dep)
{
	if(dep&1)s++,cnt[u]++;
	else need[u]++;
	d[u]=dep;f[u]=p;
	for(int v:w[u])
		if(v!=p)dfs(v,u,dep+1),cnt[u]+=cnt[v],need[u]+=need[v];
}
inline void add(int u,int k){while(u)cnt[u]+=k,u=f[u];}
int p[120001],b,e;
int find(int x){return p[x]==x?x:p[x]=find(p[x]);}
inline int eval(int k)
{
	if(k)add(b,k),add(e,-k);
	int ans=0;
	for(int i=2;i<=n;i++)ans+=abs(need[i]-cnt[i]);
	if(k)add(b,-k),add(e,k);
	return ans;
}
signed main()
{
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++)p[i]=i;
	for(int i=0;i<m;i++)
	{
		int u,v;
		scanf("%lld%lld",&u,&v);
		int x=find(u),y=find(v);
		if(x==y)b=u,e=v;
		else w[u].push_back(v),w[v].push_back(u),p[x]=y;
	}
	dfs(1,0,0);
	if(m==n-1)printf("%lld\n",s*2!=n?-1:eval(0));
	else if((d[b]-d[e])&1)
	{
		if(s*2!=n)return puts("-1"),0;
		int l=-n,r=n,ans=1<<30;
		while(l+5<=r)
		{
			int l3=(l+l+r)/3,r3=(l+r+r)/3,vl=eval(l3)+abs(l3),vr=eval(r3)+abs(r3);
			if(vl<vr)r=r3;
			else l=l3;
		}
		for(int i=l;i<=r;i++)ans=min(ans,eval(i)+abs(i));
		printf("%lld\n",ans);
	}
	else
	{
		if((n-s-s)%2)return puts("-1"),0;
		int k=(n-s-s)/2;
		add(b,k);add(e,k);
		printf("%lld\n",abs(k)+eval(0));
	}
	return 0;
}


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

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


Measured memory_bytes: 3548
#include "bits/stdc++.h"

using namespace std;

void Main() {
    int n;
    cin >> n;
    vector<int> a(n, 0);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    sort(a.begin(), a.end());
    int maxA = a.back();
    int midA = 0;
    if (maxA % 2 == 0) {
        int half = maxA / 2;
        if (a[0] >= half) {
            midA = a[0];
        }
        else {
            for (int i = 1; i < n - 1; ++i) {
                if (a[i - 1] < half && half <= a[i]) {
                    midA = (half - a[i - 1] < a[i] - half) ? a[i - 1] : a[i];
                    break;
                }
            }
        }
    }
    else {
        // The closest to (maxA / 2) or (maxA / 2 + 1) in a
        int half0 = maxA / 2;
        int half1 = half0 + 1;
        auto it = upper_bound(a.begin(), a.end(), half0);
        int closest;
        if (it != a.begin()) {
            closest = *prev(it);
        }
        else {
            closest = *it;
        }
        it = lower_bound(a.begin(), a.end(), half1);
        if (*it - half1 < half0 - closest) {
            closest = *it;
        }
        midA = closest;
    }
    cout << maxA << " " << midA << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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


vector<ll> fac(300001);
vector<ll> ifac(300001);

ll mod_pow(ll x,ll n,ll mod){//x^n(mod mod)
    ll ans=1;
    while(n!=0){
        if(n&1)ans=ans*x%mod;//例えば、n=5の場合、n=0b101となり、xを2^0回掛けた後に、xを2^2回かける。
                             //x^5=x^(2^2)+x^(2^0)
        x=x*x%mod;//計算量を減らすために、xの累乗計算は
        n=n>>1;//ひとつ上のbitの判定をするためにビットシフト
    }
    return ans;
}


ll mod_c(ll a,ll b,ll mod){
    if(a==0 && b==0) return 1;
    if(a<b||a<0) return 0;
    ll tmp=ifac[a-b]*ifac[b]%mod;
    return tmp*fac[a]%mod;
}


int main(){
    const ll mod=998244353;
    ll n,m,k;
    ll ans=0;
    ll col=m;
    cin>>n>>m>>k;

    fac[0]=1;
    ifac[0]=1;

    for (ll i=0;i<300000;i++){
        fac[i+1]=fac[i]*(i+1)%mod;
        ifac[i+1]=ifac[i]*mod_pow(i+1,mod-2,mod)%mod;//(i+1)!^-1 =(i+1)!^(M-2)=(i+1)^(M-2) * (i!)^(M-2) #(mod M)
    }

    for(ll x=0;x<=k;x++){
        ans+=mod_c(n-1,x,mod)*m%mod*mod_pow(m-1,n-x-1,mod)%mod;
    }
    cout<<ans%mod<<endl;
    return 0;
}




Measured memory_bytes: 7852
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int i = sc.nextInt();
		
		// 計算
		int result = n - i + 1;
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 23120
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
int GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
ll dp[55][55];
void init(){
 for(int i=0;i<=52;i++)dp[i][i]=1;
for(int i=0;i<=52;i++){
    dp[i+1][0]=dp[i][0];
    for(int j=1;j<i+1;j++){
        dp[i+1][j]=dp[i][j-1]+dp[i][j];
    }
}
}
int main(){
  int n,a,b;
  cin>>n>>a>>b;
  init();
  V<double> d(n);
  for(int i=0;i<n;i++)cin>>d[i];
  sort(all(d),greater<double>());
  double sum=0;
  for(int i=0;i<a;i++)sum+=d[i];
  cout<<sum/a<<"\n";
  dp[0][0]=1;
  int cnt=0,cn;
  for(int i=0;i<n;i++){
    if(d[i]==d[a-1])cnt++;
    if(d[i]>d[a-1])cn++;
  }
  ll ans=0;
  if(d[0]==d[a-1]){
    for(int i=a;i<=b;i++)ans+=dp[cnt][i];
  }
    else ans+=dp[cnt][a-cn];
  cout<<ans<<"\n";
}

Measured memory_bytes: 256
/*      Welcome to my Code      */
 
#include <bits/stdc++.h>
#define ll                      long long int
#define i(a,n)                  int a=n;
#define l(a,n)                  ll a=n;
#define d(a,n)                  double a=n;
#define s(a)                    string a;
#define c(a)                    ll a; cin>>a;a
#define cd(a)                   double a; cin>>a;
#define cs(a)                   string a; cin>>a;
#define ci(a)                   cin>>a;
#define co(a)                   cout<<a;
#define cos(a)                  cout<<a<<" "
#define con(a)                  cout<<a<<endl
#define yes                     cout<<"YES"<<endl
#define no                      cout<<"NO"<<endl
#define nl                      cout<<endl
#define ca(arr,n)               for(ll i=0;i<n;i++) cin>>arr[i]
#define caa(arr,n)              c(n); ll arr[n]; for(ll i=0;i<n;i++) cin>>arr[i];
#define f0(i,a,n)               for(ll i=a;i>=n;i--)
#define f(i,n)                  for(ll i=0;i<n;i++)
#define f1(i,a,n)               for(ll i=a;i<n;i++)
#define lcm(a,b)                (a*b)/__gcd(a,b)
#define T                       ll t=1; cin>>t; while(t--)
#define fast                    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ret(x)                  return cout<<x,0;
 
using namespace std;
 
int main()
{
    fast;
    c(x);c(k);c(d);
    x=abs(x);
    if(x/d>=k) con(x-(k*d));
    else
    {
        k=k-x/d;
        if(k%2!=0) con(abs(x%d-d));
        else con(x%d);
    }
    return 0;
}
 
/*It's not who I am underneath, but what I do that defines me
 
MMMMMMMMMMMMMMMMMMMMM.                             MMMMMMMMMMMMMMMMMMMMM
 `MMMMMMMMMMMMMMMMMMMM           M\  /M           MMMMMMMMMMMMMMMMMMMM'
   `MMMMMMMMMMMMMMMMMMM          MMMMMM          MMMMMMMMMMMMMMMMMMM'
     MMMMMMMMMMMMMMMMMMM-_______MMMMMMMM_______-MMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
     .MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM.
    MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
                   `MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM'
                          `MMMMMMMMMMMMMMMMMM'
                              `MMMMMMMMMM'
                                 MMMMMM
                                  MMMM
                                   MM
*/

Measured memory_bytes: 3672
program sample
    implicit none
    character(100)::s,t
    integer(8) :: i,j,k,m,n
    integer(8)::a,b,c,d
    integer(8),allocatable::x(:),y(:)
  
    read(*,*) k
    a=k
    do i=1,100
        a=a/2
        if(a==0)then
            a=i
            exit
        endif
    end do
    write(*,*)2**a-1

    stop
end program sample
  



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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

void solve(long long N, long long W, std::vector<long long> w, std::vector<long long> v) {
    vi dp(W + 1, -1);
    dp[0] = 0;

    rep(i, N) {
        rep(jj, W + 1) {
            int j = W - jj;
            if (j - w[i] >= 0 and dp[j - w[i]] != -1) {
                chmax(dp[j], dp[j - w[i]] + v[i]);
            }
        }
    }
    int ans = 0;
    rep(i, W + 1) chmax(ans, dp[i]);
    cout << ans << endl;
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    long long N;
    scanf("%lld", &N);
    long long W;
    scanf("%lld", &W);
    std::vector<long long> w(N);
    std::vector<long long> v(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &w[i]);
        scanf("%lld", &v[i]);
    }
    solve(N, W, std::move(w), std::move(v));
    return 0;
}


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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;

int main(){
    int n; cin>>n;
    map<string, int> yay;
    rep(i, n){
        string now; cin>>now;
        yay[now]++;
    }
    int ans = 0;
    for(auto i = yay.begin(); i != yay.end(); i++) ans++;
    cout<<ans <<endl;
}


Measured memory_bytes: 19120
#include <iostream>
#include <string>
#include <stdio.h>
#define llint long long int

using namespace std;

llint s;

int getKeta(llint n)
{
	int ret = 0;
	for(; n > 0; n /= 10) ret++;
	return ret;
}

llint intpow(int a, int b)
{
	llint seki = 1;
	for(; b > 0; b--) seki *= a;
	return seki;
}

llint count(llint n)
{
	int keta = getKeta(n);
	llint ret = keta * n;
	
	llint sub = 0;
	for(int i = 1; i < keta; i++){
		sub = sub * 10 + 9;
		ret -= sub;
	}
	
	for(int i = 1; i <= keta - 1; i++){
		ret -= (intpow(10, i) - 1) / 3 * i;
		ret -= (intpow(10, i) - 1) / 5 * i;
		ret += (intpow(10, i) - 1) / 15 * i;
		ret += (intpow(10, i-1) - 1) / 3 * i;
		ret += (intpow(10, i-1) - 1) / 5 * i;
		ret -= (intpow(10, i-1) - 1) / 15 * i;
	}
	
	ret -= n / 3 * keta;
	ret -= n / 5 * keta;
	ret += n / 15 * keta;
	ret += (intpow(10, keta-1) - 1) / 3 * keta;
	ret += (intpow(10, keta-1) - 1) / 5 * keta;
	ret -= (intpow(10, keta-1) - 1) / 15 * keta;
	
	ret += n / 3 * 4;
	ret += n / 5 * 4;
	
	return ret;
}

string makestr(llint n)
{
	string ret;
	char buf[256];
	
	for(llint i = n; i < n + 40; i++){
		if(i % 3 == 0) ret += "Fizz";
		if(i % 5 == 0) ret += "Buzz";
		if(i % 3 && i % 5){
			sprintf(buf, "%lld", i);
			ret += buf;
		}
	}
	return ret;
}

int main(void)
{
	cin >> s;
	
	llint left = 0, right = 90000000000000000, mid;
	while(right > left + 1){
		mid = (left + right) / 2;
		if(count(mid) < s){
			if(count(mid + 1) >= s){
				left = mid;
				break;
			}else{
				left = mid+1;
			}
		}else{
			right = mid;
		}
		
		//cout << left << ", " << right << endl;
	}
	
	cout << makestr(left+1).substr(s - count(left) - 1, 20) << endl;
	return 0;
}

Measured memory_bytes: 3356
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;
int main()
{
	int n,l;cin>>n>>l;
	if((l<0&&n+l-1>0)||(l==0)||(n+l-1==0))
	{
		int ans=0;
		for(int i=0;i<n;i++) ans+=(l+i);
		cout<<ans<<endl;
	}
	else if(n+l-1>0&&l>0)
	{
		int ans=0;
		for(int i=0;i<n;i++) ans+=(l+i);
		cout<<ans-l<<endl;
	}
	else
	{
		int ans=0;
		for(int i=0;i<n;i++) ans+=(l+i);
		cout<<ans-(n+l-1)<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=next[i])
#define repvc(i,vc) for(int i=0,_sz=vc.size();i<_sz;++i)
using namespace std;
 
const int INF=1<<30;
typedef long long ll;
 
inline int read()
{
	int ret=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0'&&ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}
 
struct Edge{
	int a,b;
	Edge(int a=0,int b=0):a(a),b(b){}
};
 
vector<Edge>vc;
 
int main()
{
	int n,k;cin>>n>>k;
	if(k>(n-1)*(n-2)/2) {
		cout<<-1<<endl;
		return 0;
	}
 
	int cur=0;
	rep(i,2,n)
	{
		vc.push_back(Edge(i,1));
		cur=cur+i-2;
		if(cur==k){
			rep(j,i+1,n) rep(k,1,j-1) vc.push_back(Edge(j,k));
			break;
		}
		if(cur>k)
		{
			rep(j,2,2+(cur-k)-1) vc.push_back(Edge(i,j));
			rep(j,i+1,n) rep(k,1,j-1) vc.push_back(Edge(j,k));
			break;
		}
	}
	cout<<vc.size()<<"\n";
	rep(i,0,vc.size()-1) 
	cout<<vc[i].a<<" "<<vc[i].b<<"\n";
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main(){
	string a,b;
  	cin>>a>>b;
  	lli n1,n2;
  	cin>>n1>>n2;
  	string s;cin>>s;
  	if(s==a)	cout<<n1-1<<" "<<n2<<endl;
  	else	cout<<n1<<" "<<n2-1<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python

import sys

n=int(sys.stdin.readline())
a= [ int(x)-1 for x in sys.stdin.readline().split() ]
tot= 0
for x in sys.stdin.readline().split(): tot+=int(x)
c= [ int(x) for x in sys.stdin.readline().split() ]
#
for i in range(1,n):
    if a[i-1]+1==a[i]: tot+= c[a[i-1]]
print( tot )        


Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#define PI 3.141592653589
#define N_MAX 200

int main()
{
  int a[N_MAX+1][N_MAX+1];
  int c, r, i, j, k, tmp;
  scanf("%d %d",&c,&r);
  for(i = 0; i <= c; i++)
    {
      for(j = 0; j <= r; j++)
	{
	  if(i == c)
	    {
	      for(k = 0; k < c; k++)
		{
		  a[c][j] += a[k][j];
		}
	    }
	  else if(j == r)
	    {
	      for(k = 0; k < r; k++)
		{
		  a[i][r] += a[i][k];
		}
	    }
	  else
	    {
	      scanf("%d",&tmp);
	      a[i][j] = tmp;
	    }
	}
    }
  for(i = 0; i <= c; i++)
    {
      for(j = 0; j <= r; j++)
	{
	  printf("%d",a[i][j]);
	  if(j != r) printf(" ");
	}
      printf("\n");
    }
  return 0;
}

Measured memory_bytes: 688
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

ll nPrS(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--){
        ret *= i;
        ret %= MOD;
    }
    return ret;
}

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

    if(n < m - 1 || m < n - 1){
        cout << 0 << endl;
        return 0;
    }

    ll tmp1 = nPrS(n, n);
    ll tmp2 = nPrS(m, m);

    if(n == m){
        cout << tmp1 * tmp2 * 2 % MOD << endl;
    } else {
        cout << tmp1 * tmp2 % MOD << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=1e5+5;
int ans[maxn];
int s[maxn];
typedef pair<int,int> ii;
priority_queue<ii> pq;
signed main() {
    int n;
    cin>>n;
    for(int i=1 ; i<=n ; i++) {
        int a;
        cin>>a;
        pq.push(ii(a,i));
        s[i]=1;
    }
    while(pq.size()>1) {
        int t1=pq.top().first;
        int id1=pq.top().second;
        pq.pop();
        int t2=pq.top().first;
        int id2=pq.top().second;
        pq.pop();
        ans[id1]+=s[id1]*(t1-t2);
		pq.push(ii(t2,min(id1,id2)));
		s[min(id1,id2)]+=s[max(id1,id2)];
    }
    ans[1]+=n*pq.top().first;
    for(int i=1 ; i<=n ; i++) cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 6636
num_bags, congr_factor = list(map(int, input().split()))
bags = list(map(int, input().split()))
odd_bags = len([bag for bag in bags if (bag % 2 == 1)])

if congr_factor == 0 and odd_bags == 0:
  print(2 ** num_bags)
elif congr_factor == 1 and odd_bags == 0:
  print(0)
else:
  print(2 ** (num_bags-1))


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

 int main() {
   int A, B;
     cin >> A >> B;
     int res = 0;
     if (A >= 13) {
       res = B;
     } else if (A >= 6) {
       res = B/ 2;
     }

   cout << res << '\n';
 }


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

const int MAX = 100000;
const int INF = 1073741823; // 10^30-1、使わない辺とかに用いる

bool check(int *h, int N, int A, int B, int X) {
	int64_t bomb = 0;
	for (int i = 0;i < N;i ++) {
		bomb += max((int64_t)0, (h[i] - (int64_t) B * X + A - B - 1) / (A - B));
	}
	return bomb > X;
}

int binarySearch(int min, int max, int *h, int N, int A, int B) {
	for (int mid = min + (max - min >> 1);max - min > 1;mid = min + (max - min >> 1)) {
		if (check(h, N, A, B, mid)) min = mid;
		else max = mid;
	}
	return max;
}

int main() {
	int N, A, B, h[MAX];
	cin >> N >> A >> B;
	for (int i = 0;i < N;i ++) cin >> h[i];
	cout << binarySearch(0, INF, h, N, A, B);
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

まず、先に爆発回数を決め打つ
そうすると各魔物に直撃させるべき回数が一意に定まるので、その回数で足りるか判定できる
これは単調性があるので、二分探索をすると答えが出てくるよ

直撃させるべき回数: Xが爆発回数だとするとh[i] ≦ A * y + B * (X - y)におけるyの最小値
つまり(h[i] - BX) / (A - B) ≦ yより、左辺の端数切り上げを求めれば良い
1≦Bなので最低でも1ダメージは受ける、つまりmax(h)が爆発回数の上限なのでこれよりは少ない→int型
*/

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

template < typename T > void coutVector(vector<T> v){for(int i=0;i<int(v.size());++i){if(i>0)cout<<" "<<v[i];else cout<<v[i];}cout<<endl;}
template < typename T > void coutVectorWithEndl(vector<T> v){for(int i=0;i<int(v.size());++i){cout<<v[i]<<endl;}}
template < typename T > vector<T> cinVector(int n) {vector<T> res(n);for(int i=0;i<n;++i){cin>>res[i];}return res;}


const ll MOD = 1e9+7;

int main() {
    int N, M; cin >> N >> M;
    vector<pair<int, char>> sc;
    repp(i, 0, M) {
        int s;char c; cin >> s >> c;
        sc.push_back(make_pair(s, c));
    }
    int res = 1000;
    repp(i,0,1000) {
        string s = to_string(i);
        if ((int)s.size() != N) continue;
        bool ok = true;
        repp(j, 0, M) {
            ok &= s[sc[j].first - 1] == sc[j].second;
        }
        if (ok) res = min(res, i);
    }
    if (res > 999) cout << -1 << endl;
    else cout << res << endl;
}


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

const int MOD = 998244353;

void solve_test() {
	int a, b;
	cin >> a >> b;
	cout << a * b << '\n';
}

int main() {
	int T;
	T = 1;
	for (int t = 1; t <= T; t++)
		solve_test();

	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int main(){
    int n;
    cin>>n;
    vector<int> h(n+1);
    rep(i,n){
        cin>>h.at(i+1);
    }
    vector<int> dp(n+1);
    dp.at(1)=0;
    dp.at(2)=abs(h.at(2)-h.at(1));
    for (int i=3;i<=n;i++){
        dp.at(i)=min(dp.at(i-2)+abs(h.at(i)-h.at(i-2)),dp.at(i-1)+abs(h.at(i)-h.at(i-1)));
    }
    cout<<dp.at(n)<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int a,b,c;
    cin>>a>>b>>c;
    if ((a<=c && c<=b) || (b<=c && c<=a))
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

Measured memory_bytes: 256
N,M,K = map(int,raw_input().split(" "))

def f():
    for i in range(N+1):
        for j in range(M+1):

            nn = j
            mm = i
            if mm*M + nn*N - 2 * mm*nn == K:
                return "Yes"
    return "No"

print f()


Measured memory_bytes: 2692
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
    double PI = acos(-1);
    double rad,a,b,C,S,L,h;

    cout << fixed << setprecision(12);
    cin >> a >> b >> C;
    rad = C * PI / 180;
    S = a * b *  sin(rad) / 2;
    cout << S << endl;
    C = sqrt(pow(a,2) + pow(b,2) - (2 * a * b * cos(rad)));
    L = a + b + C;
    cout << L << endl;
    h = b * sin(rad);
    cout << h << endl;
    return 0;
}



Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int solve(int n){
    int ans=0;
    while(n>0){
        ans++;
        n/=10;
    }
    return ans;
}
int main(){
    int n;
    cin>>n;
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(solve(i)%2) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
def binary_search(S, key):
    left = 0
    right = n
    while left < right:
        mid = (left + right) // 2
        if S[mid] == key:
            return True
        elif S[mid] > key:
            right = mid
        else:
            left = mid + 1
    return False

print(sum(binary_search(S, key) for key in T))


Measured memory_bytes: 16716
Module B
    Sub Main(ByVal args() As String)
        Dim n As Integer = Integer.Parse(Console.ReadLine())
        Dim arr() As String = Split(Console.ReadLine())
        Dim i, wk As Integer
        For i = 0 To n - 1
            wk = arr(i)
            If (wk Mod 2 = 0) AndAlso (wk Mod 3 <> 0) AndAlso (wk Mod 5 <> 0) Then
                Console.WriteLine("DENIED")
                Return
            End If
        Next
        Console.WriteLine("APPROVED")
    End Sub
End Module

Measured memory_bytes: 13532
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string.h>
#include <deque>
#define REP(i,j,n) for(int i=j;i<n;i++)
#define SORT(x) sort(x.begin(),x.end())

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	if (n - m < 0)cout << 0 << endl;
	else cout << n - m << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

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

    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (m[a] == 1)
        {
            cout << "NO" << endl;
            return 0;
        }
        m[a]++;
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 9600
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: usize,
        s: [String; n],
    }
    let mut count = 0;
    for si in s.iter() {
        let m = si.matches("AB").collect::<Vec<_>>();
        count += m.len();
    }
    let mut a_only : usize = 0;
    let mut b_only : usize = 0;
    let mut a_and_b = 0;
    for si in s.iter() {
        if si.starts_with("B") && si.ends_with("A") {
            a_and_b += 1;
        } else {
            if si.starts_with("B") {
                b_only += 1;
            }
            if si.ends_with("A") {
                a_only += 1;
            }
        }
    }
    if a_and_b > 0 {
        count += a_and_b - 1;
        if b_only > 0 {
            count += 1;
            b_only -= 1;
        }
        if a_only > 0 {
            count += 1;
            a_only -= 1;
        }
    }
    count += if a_only > b_only { b_only } else { a_only };
    println!("{}", count);
}



Measured memory_bytes: 4352
def main():
    N = int(input())
    H = list(map(int, input().split()))
    dp = [0] * (N)
    dp[0] = 0
    dp[1] = abs(H[1] - H[0])
    for i in range(2, N):
        dp[i] = min([dp[i-2] + abs(H[i] - H[i-2]), dp[i-1] + abs(H[i] - H[i-1])])
    print(dp[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 84380
#include<stdio.h>
int main(void)
{
	int a1,a2,a3,a4,a5,a6,a7,b1,b2,b3,b4,b5,b6,b7,x,y,z;
	scanf("%d %d",&a1,&b1);
	scanf("%d %d",&a2,&b2);
	scanf("%d %d",&a3,&b3);
	scanf("%d %d",&a4,&b4);
	scanf("%d %d",&a5,&b5);
	scanf("%d %d",&a6,&b6);
	scanf("%d %d",&a7,&b7);
	printf("%d\n",a1-b1);
	printf("%d\n",a2-b2);
	printf("%d\n",a3-b3);
	printf("%d\n",a4-b4);
	printf("%d\n",a5-b5);
	printf("%d\n",a6-b6);
	printf("%d\n",a7-b7);
	return 0;
}


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

int main()
{
  int A,B,C,D;  
  int count=0;
  cin >> A >> B >> C >> D;
  vector<int> sum(101);
  
  for(int i=A;i<=B;i++){
    sum.at(i)+=1;
  }
  for(int i=C;i<=D;i++){
    sum.at(i)+=1;
  }
  
  for(int i=0;i<101;i++){
    if(sum.at(i)==2) count++;
  }
  count = count-1;
  if(count == -1) count=0;
    cout << count << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int p=(c+b-1)/b;
  int q=(a+d-1)/d;
  if(p<=q){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3640
N = 5 * 10**8


def f(x):
    return x


M = 10**5
arr = list(range(M))
for i in range(N):
    t = (i + i * i - i) % M  # 四則演算
    b = arr[t]  # 配列ランダムアクセス
    b = f(b)  # 関数呼び出し

# 答え
a = int(input())
print(a + a**2 + a**3)


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

def solve():
    L, R = list(map(int, input().split()))
    MOD = 2019

    if (R-L) >= 2019:
        print(0)
        return

    L %= MOD
    R %= MOD

    ans = MOD
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            ans = min(ans, (i*j)%MOD)
            if ans == 0:
                print(ans)
                return
    print(ans)
    

if __name__ == "__main__":
    solve()


Measured memory_bytes: 3064
from collections import deque
N = int(input())
a = deque(map(int, input().split()))
a.append(0)
a.appendleft(0)

s = sum([abs(a[i+1]-a[i]) for i in range(len(a)-1)])
for i in range(1,N+1):
    ans = s-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1])
    print(ans)

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vector<pair<pair<int,int>,bool>> r(n), b(n);
    rep(i, n){
        int x, y;
        cin >> x >> y;
        r[i] = make_pair(make_pair(y,x),false);
    }
    rep(i, n){
        int x, y;
        cin >> x >> y;
        b[i] = make_pair(make_pair(x,y),false);
    }

    int cnt = 0;
    sort(b.begin(), b.end());
    sort(r.rbegin(), r.rend());
    for(auto& bp : b){
        for(auto& rp : r){
            if(bp.first.first > rp.first.second and bp.first.second > rp.first.first and !rp.second){
                bp.second = true;
                rp.second = true;
                cnt++;
                break;
            }
        }
    }

    ppp(cnt);

    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=[0]
a= a + list(map(int,input().split()))
v=[[] for i in range(n+1)]
for t in range(m):
	x,y=map(int,input().split())
	v[x].append(y)
	v[y].append(x)
ans=0
for i in range(1,n+1):
	c=1
	for j in v[i]:
		if a[j]>=a[i]:
			c=0
	if c:
		ans+=1
print(ans)

Measured memory_bytes: 29392
N,M = map(int,input().split())
city_list = sorted([[list(map(int,input().split())),i] for i in range(M)])
ID = city_list[0][0]
num = 0
ans = []
for i in range(M):
  if ID != city_list[i][0][0]:
    ID = city_list[i][0][0]
    num = 0
  num += 1
  ans.append([city_list[i][1],'{0:06d}'.format(ID)+'{0:06d}'.format(num)])
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i][1])

Measured memory_bytes: 53684
import collections
 
 
class Node(object):
 
  def __init__(self):
    self.value = 0
    self.edges = [] 
 
def main():
  n = int(input())
  nodes = [Node() for _ in range(n)]
 
  for _ in range(n - 1):
    a, b = map(int, input().split())
    nodes[a - 1].edges.append(nodes[b - 1])
    nodes[b - 1].edges.append(nodes[a - 1])
 
  values = list(map(int, input().split()))
  values.sort(reverse=True)
 
  print(sum(values[1:]))
 
  queue = collections.deque()
  queue.append(nodes[0])
  index = 0
 
  while len(queue) != 0:
    node = queue.popleft()
    node.value = values[index]
    index += 1
 
    queue.extend(n for n in node.edges if n.value == 0)
 
  print(' '.join(str(n.value) for n in nodes))
 
 
if __name__ == '__main__':
  main()
 

Measured memory_bytes: 7408
N = int(input())
A = list(map(int,input().split()))
money = 1000
kabu = 0
for i in range(N-1):
    if A[i+1] < A[i]:
        money += A[i] * kabu
        kabu = 0
    else:
        kabu += money//A[i]
        money -= A[i] * (money//A[i])
    #print(kabu,money)
money += A[-1] * kabu


print(money)


Measured memory_bytes: 61940
import Control.Applicative
import Data.List (sort,groupBy)

main = do
  _ <- getLine :: IO String
  ls <- map read.words <$> getLine :: IO [Int]
  print $ sum.map (snd.head).groupBy (\a b->fst a`div`2==fst b`div`2) .zip [0..] . sort $ ls


Measured memory_bytes: 1020
n = int(input())
if n == 2:
    print(1)
    exit()
def ele(n):
    L = [n]
    for i in range(2, int(n**0.5)+1):
        cur = n
        while cur%i == 0:
            cur = cur//i
            L.append(i)
            L.append(n//i)
    L = list(set(L))
    return L
ans = ele(n-1)
t = ele(n)
for i in range(len(t)):
    temp = n
    while temp%t[i] == 0:
        temp = temp//t[i]
    if temp%t[i] == 1:
        ans.append(t[i])
print(len(ans))


Measured memory_bytes: 3828
#pragma GCC optimize "trapv"
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ld long double
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
int main()
{
    fio;
    ll n;
    cin>>n;
    if(n%1000==0)
    cout<<0<<endl;
    else
    cout<<((n/1000+1)*1000)-n<<endl;
}

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


void solver() {
  int a, b;
  cin >> a >> b;

  int a_tax, b_tax;
  for(int v = 1; v <= 10000; v++) {
    a_tax = floor(v * 0.08);
    b_tax = floor(v * 0.1);

    if (a == a_tax && b == b_tax) {
      cout << v << "\n";
      return;
    }
  }
  cout << -1 << "\n";
  return;
}

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


Measured memory_bytes: 256
def t_shift(rem):
    h = m = s = 0
    if rem >= 3600:
        h = rem / 3600
        rem -= 3600*h
    if rem >= 60:
        m = rem / 60
        rem -= 60*m
    s = rem
    print str(h).rjust(2, '0') + ":" + str(m).rjust(2, '0') + ":" + str(s).rjust(2, '0')

while True:
    h, m, s = map(int, raw_input().split())
    if h == m == s == -1:
        break
    rem1 = 7200 - 3600*h - 60*m - s
    rem2 = 3*rem1
    t_shift(rem1)
    t_shift(rem2)

Measured memory_bytes: 6264
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define NN (ll)(1e17+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
ll N,W;
vector <pair<ll,ll>> v;
ll dp[1000005][100];
ll fn(ll ind,ll mark,ll sum)
{
    if(dp[sum][ind]!=-1)
     return dp[sum][ind];
    if(ind==N-1)
    {
        if(mark)
        {
            if(v[ind].ff+sum<=W)
             return dp[sum][ind]=v[ind].ss;
        }
        return dp[sum][ind]=0;
    }
    if(mark)
    {
        if(v[ind].ff+sum<=W)
         return dp[sum][ind]=max(v[ind].ss+max(fn(ind+1,0,sum+v[ind].ff),fn(ind+1,1,sum+v[ind].ff)),max(fn(ind+1,0,sum),fn(ind+1,1,sum))); 
    }
    return dp[sum][ind]=max(fn(ind+1,0,sum),fn(ind+1,1,sum));
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   memset(dp,-1,sizeof(dp));
   //cin>>TT;
   while(TT--)
   {   
       cin>>N>>W;
       ll i,x,y;
       for(i=0;i<N;i++)
       {
           cin>>x>>y;
           v.pb(Mp(x,y));
       }
       //for(i=0;i<N;i++)
        //cout<<dp[i][0]<<" "<<dp[i][1]<<"\n"; 
       ll ans=max(fn(0,0,0),fn(0,1,0));
       cout<<ans<<"\n";
       //for(i=0;i<N;i++)
        //cout<<dp[i][0]<<" "<<dp[i][1]<<"\n";
   }
}

Measured memory_bytes: 781568
#import collections
A,B = map(int,input().split())
if A>0:
    A-=1
else:
    A=0

Alis = []
Blis = []

for n in range(1,41) :
    temp = (A // 2**n)*(2**(n-1))
    t2 = A%(2**n)
    if t2 >= 2**(n-1):
        t2 %= 2**(n-1)
        t2 += 1
        temp += t2
    Alis.append(temp)

for n in range(1,41) :
    temp = (B // 2**n)*(2**(n-1))
    t2 = B%(2**n)
    if t2 >= 2**(n-1):
        t2 %= 2**(n-1)
        t2 += 1
        temp += t2
    Blis.append(temp)

res = 0
for n in range(len(Alis)) :
    res += (2**n)*((Blis[n] - Alis[n])%2)
print(res)

Measured memory_bytes: 3064