akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
const int N=123456;
vector<int> vec[N];
int pre[N];
int flag,n;
int dis[N];
int ans;
void dfs_1(int c,int f,int u){
	pre[c]=f;
	dis[c]=u;
	if(flag){
		return;
	}
	if(c==n){
		flag=1;
		return;
	}
	for(int x:vec[c]){
		if(x!=f){
			dfs_1(x,c,u+1);
		}
	}
}
void dfs_2(int c,int f){
	ans++;
	for(int x:vec[c]){
		if(x!=f){
			dfs_2(x,c);
		}
	}
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		vec[u].push_back(v);
		vec[v].push_back(u);
	}
	flag=0;
	dfs_1(1,0,0);
	int s=n,f;
	int d=dis[n]/2;
	//cout << "d==" << d << endl;
	while(s!=1){
		f=s;
		//cout << "s==" << s << endl;
		s=pre[s];
		if(dis[s]==d){
			break;
		}
	}
	//cout << "ss==" << s << endl;
	//cout << "f===" << f << endl;
	ans=0;
	dfs_2(s,f);
	//cout << "ans==" << ans << endl;
	if((n-ans)<ans){
		puts("Fennec");
	} else {
		puts("Snuke");
	}
	return 0;
}


Measured memory_bytes: 11776
#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<algorithm>

using namespace std;

#define T int t, q=0; scanf("%d", &t); while(q++<t)
#define ll long long
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll x,y,z,a,b,c,sum,ans,total,cnt,n,m,k,p,kase,i;
string s1,s2;
#define N 100001
#define MX 1000000001



int main()
{

        cin>>n;
        if(n<=1000)cout<<1000-n<<endl;
        else if(n>1000 && 2000>=n)cout<<2000-n<<endl;
        else if(n>2000 && 3000>=n)cout<<3000-n<<endl;
        else if(n>3000 && 4000>=n)cout<<4000-n<<endl;
        else if(n>4000 && 5000>=n)cout<<5000-n<<endl;
        else if(n>5000 && 6000>=n)cout<<6000-n<<endl;
        else if(n>6000 && 7000>=n)cout<<7000-n<<endl;
        else if(n>7000 && 8000>=n)cout<<8000-n<<endl;
        else if(n>8000 && 9000>=n)cout<<9000-n<<endl;
        else if(n>9000 && 10000>=n)cout<<10000-n<<endl;





    return 0;
}
// Happy Coding  (:


Measured memory_bytes: 3632
/**********************************************************/
/**            Bismillahir-rahmanir-rahim                **/
/**  In the name of Allah, the Beneficent, the Merciful. **/
/**********************************************************/
/****@author: Sayed Sohan, CSE 13th batch(2016), MBSTU*****/
/**********************************************************/

#include <bits/stdc++.h>
using namespace std;
//              Typedefs
typedef long long               ll;
typedef unsigned long long      ull;

//              Templates
template<class T>               using min_heap = \
                                priority_queue<T, \
                                std::vector<T>, std::greater<T>>;

//              Basic-Defs
#define PB                      push_back
#define MP                      make_pair
#define SP                      " "
#define NL                      "\n"
#define all(v)                  v.begin(), v.end()

//              DEBUG--SECTION
#define DE                      cout<<"HERE\n";
#define DE1(x)                  cout<<x<<"###\n";
#define DE2(x,y)                cout<<x<<"####"<<y<<"\n";
#define Pause                   system("pause");

//              Functions
#define clr(arr,value)          memset(arr,value,sizeof(arr))
#define __FAST_IO               ios_base::sync_with_stdio(0);\
                                cin.tie(0);cout.tie(0);
#define NUM1(x)                 __builtin_popcount(x)
#define LCM(x,y)                (x*y)/__gcd(x,y)

//              Sizes--Math     0123456789
#define MOD                     1000000007   //1e9+7 
#define MAX                     100050      
#define INF                     1e18
#define PI                      acos(-1)
#define eps                     1e-6

//** your code goes from here


int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //__FAST_IO;
    
    ll i,j,k,n,m,T; //basic variables

    cin>>n>>k;
    unordered_map<ll,ll> mp,mp2;
    for(i=0;i<n;i++){
    	ll x;
    	cin>>x;
    	mp[i+1] = x;

    }
    bool vis[n+3] = {0};
    ll cur = 1;
    vector<ll> v;
    ll x = 0;
    i = 0;
    mp2[1] = i++;
    v.PB(1);
    while(vis[cur]==0){
    	vis[cur] = 1;
    	x = mp[cur];
    	if(vis[x]) break;
    	v.PB(x);
    	cur = x;
    	mp2[x] = i++;
    }
    if(k<v.size()){
    	cout<<v[k]<<NL;
    }
    else{
    	k = k-mp2[x];
    	ll c = v.size()-mp2[x];
    	k = k%c;
    	k = k+mp2[x];
    	//cout<<c<<NL;
    	cout<<v[k]<<NL;
    }



    /// Don't forget to set array size....
    return 0;
}




Measured memory_bytes: 21316
N=int(input())
H=list(map(int,input().split()))
m=0
ans=0
i=1
while i<N:
  while i<N and H[i]>=H[i-1]:
    i+=1
  ans+=H[i-1]-m
  while i<N and H[i]<=H[i-1]:
    i+=1
  m=H[i-1]
if N==1:
  print(H[0])
elif H[-1]>m:
  print(ans+H[-1]-m)
else:
  print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ull unsigned long long
using namespace std;
ll x;
int cnt;
int main(){
    cin>>x;
    ull now=100;
    while(now<x){
        long double o=now*1.0/100.0;
        ull oo=floor(o);
        now+=o;
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int w = scan.nextInt();
        int a = scan.nextInt();
        int b = scan.nextInt();
        int ans = 0;
        if(b + w < a){
            ans = a - (b + w);
        }else if(a + w < b){
            ans = b - (a + w);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

int main(){
    ll N=in();
    ll a[N];
    rep(i, N){
        cin>>a[i];
    }
    sort(a, a+N);
    ll b[N];
    rep(i, N){
        if(i==0) b[i]=a[i];
        else b[i]=a[i]+b[i-1];
    }
    int i;
    for (i=N-1;i>0;i--){
        if(b[i]>b[i-1]*3){
            break;
        }
    }
    std::cout<<N-i<<endl;
}

Measured memory_bytes: 1792
# coding: utf-8

def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
    
ans = 0
n = int(input())
for i in range(n):
    if is_prime(int(input())):
        ans += 1
    
print(ans)

Measured memory_bytes: 7664
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll minv(ll x){
    return mpow( x, MOD-2 );
}

void solve()
{
    ll n, K;
    scanf("%lld%lld", &n, &K);
    ll ans = 0;
    ll i;
    for (i = K; i <= n+1; i++) {
        ll ans0 = i * (i - 1) %MOD *minv(2) %MOD;
        ll ans1 = i * (n - (i - 1) + n) % MOD *minv(2) % MOD;
        ll ans2 = (ans1 - ans0 + 1 + MOD) % MOD;

        ans = (ans + ans2) % MOD;
    }
    printf("%lld\n", ans);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 1732
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string S;
    cin >> S;
    int N = S.size();
    vector<vector<ll>> dp(N+1, vector<ll>(13, 0));
    dp[0][0] = 1;
    REP(i, N){
        int c;
        if(S[i] == '?') c = -1;
        else c = S[i] - '0';
        REP(j, 10){
            if(c != -1 && c != j) continue;
            REP(k, 13){
                (dp[i+1][(k * 10 + j) % 13] += dp[i][k]) %= MOD;
            }
        }
    }
    pr(dp[N][5]);
}

Measured memory_bytes: 13696
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
int cnt[100000];
int main() {
	int N, Q;
	cin >> N >> Q;
	string S;
	cin >> S;
	for (int i = 1; i < S.size(); i++) {
		if (S[i - 1] == 'A' && S[i] == 'C') cnt[i]++;
	}
	for (int i = 1; i < S.size(); i++) cnt[i] += cnt[i - 1];
	for (int i = 0; i < Q; i++) {
		int l, r;
		cin >> l >> r;
		l--; r--;
		cout << cnt[r] - cnt[l] << endl;
	}
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
#define MAX 500005
using namespace std;

ll n, k;

int main()
{
    cin >> n >> k;
    if(!n){
        cout << 0 << endl;
        return 0;
    }
    if(n < k) cout << min(n, k-n) << endl;
    else cout << min(n%k, k-(n%k)) << endl;

    return 0;
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

void dfs(vector<vector<int>> &g, vector<int> &p, int x = 0){
    for(auto&& i : g[x]){
        if(p[i] != -1) continue;
        p[i] = p[x] ^ 1;
        dfs(g, p, i);
    }
}

int main(){
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    for(int i = 0; i < n - 1; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    vector<int> p(n, -1);
    p[0] = 0;
    dfs(g, p);
    vector<vector<int>> node(2);
    for(int i = 0; i < n; i++){
        node[p[i]].push_back(i);
    }
    if(node[0].size() > node[1].size()){
        swap(node[0], node[1]);
    }
    
    vector<int> ans(n);
    // vector<bool> used(n);
    if(node[0].size() <= n / 3){
        int x = 3;
        for(auto&& i : node[0]){
            ans[i] = x;
            x += 3;
        }
        if(x > n){
            x = 1;
        }
        for(auto&& i : node[1]){
            ans[i] = x;
            if(x % 3 == 0){
                x += 3;
                if(x > n){
                    x = 1;
                }
            }else{
                x++;
                if(x % 3 == 0){
                    x++;
                }
            }
        }
    }else{
        int x = 1;
        for(auto&& i : node[0]){
            ans[i] = x;
            x += 3;
            if(x % 3 == 1 && x > n){
                x = 3;
            }
        }
        if(x > n){
            x = 2;
        }
        for(auto&& i : node[1]){
            ans[i] = x;
            x += 3;
            if(x % 3 == 0 && x > n){
                x = 2;
            }
        }
    }
    cout << ans[0];
    for(int i = 1; i < n; i++){
        cout << " " << ans[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 18676
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const int MOD=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }
	void init(int n) { par.assign(n, -1); }

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

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

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

int main() {
	long long N, M; cin >> N >> M;
	vector<int> A(M), B(M);
	for (int i = 0; i < M; ++i) {
		cin >> A[i] >> B[i], --A[i], --B[i];
	}

	UnionFind uf(N);
	long long cur = N * (N-1) / 2;
	vector<long long> res;
	for (int i = 0; i < M; ++i) {
		res.push_back(cur);

		int a = A[M-1-i], b = B[M-1-i];
		if (uf.issame(a, b)) continue;

		long long sa = uf.size(a), sb = uf.size(b);
		cur -= sa * sb;
		uf.merge(a, b);
	}

	reverse(res.begin(), res.end());
	for (int i = 0; i < res.size(); ++i) cout << res[i] <<endl;
}


Measured memory_bytes: 3444
#![allow(unused_macros, unused_imports, dead_code, non_snake_case)]

use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

macro_rules! from_line {
    ($($a:ident : $t:ty),+) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
            assert!(_it.next().is_none());
        }
    };
}

fn main() {
    loop {
        from_line!(m:usize, nmin:usize, nmax:usize);
        if m == 0 { break; };
        let mut b: Vec<usize> = Vec::new();
        for _ in 0..m {
            from_line!(v:usize);
            b.push(v);
        }
        b.sort();
        b.reverse();
        let mut ans = nmin;
        let mut gap = b[nmin-1] - b[nmin];
        for i in nmin..nmax+1 {
            if gap <= b[i-1] - b[i] {
                ans = i;
                gap = b[i-1] - b[i];
            }
        }
        println!("{}", ans);
    }
}



Measured memory_bytes: 5056
# coding: utf-8
# Your code here!
"""
Binary indexed tree
0-indexed, 関数は閉区間
0からの区間加算、1点更新
"""
class BIT: #0-indexed
    def __init__(self, n):
        self.tree = [0]*(n+1)
        self.tree[0] = None
#        self.element = [0]*(n+1)
    def sum(self, i): #a_0 + ... + a_{i} #閉区間
        s = 0; i += 1
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
    def range(self,l,r): #a_l + ... + a_r 閉区間
        return sum(r) - sum(l-1) 
    def add(self, i, x):
        i += 1
        while i <= n:
            self.tree[i] += x
            i += i & -i
        # self.element[i] += x
    #def get(self,i): return element[i]        
    
###########################################
# http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3791366
###########################################

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n = int(input())
xyi = [[int(i) for i in readline().split()]+[j] for j in range(n)]
#xyi = []
#for i in range(n):
#    a = [int(i) for i in readline().split()]
#    xyi.append(a+[i])

dame_x = [0]*n
dame_y = [0]*n
dame_xy = [0]*n

MOD = 998244353

sxyi = sorted(xyi, key = lambda x: x[1]) # zaatu の逆写像
modosu = [i for x,y,i in sxyi]
zaatu = [0]*n
for j,zj in enumerate(modosu):
    zaatu[zj] = j

pow2 = [1]*(n+1)
for i in range(n):
    pow2[i+1] = pow2[i]*2%MOD

for j, (x,y,i) in enumerate(sxyi):
    dame_y[i] = pow2[j]-1 + pow2[n-j-1]-1

xyi.sort()
#print(pow2)

bit = BIT(n)
for j, (x,y,i) in enumerate(xyi):
    dame_x[i] = pow2[j] -1 + pow2[n-j-1]-1
    c = bit.sum(zaatu[i])
    dame_xy[i] += pow2[c]-1 + pow2[j-c]-1
    bit.add(zaatu[i],1)
        
bit = BIT(n)
for j, (x,y,i) in enumerate(reversed(xyi)):
    c = bit.sum(zaatu[i])
    dame_xy[i] += pow2[c]-1 + pow2[j-c]-1
    bit.add(zaatu[i],1)
        
        
#print(dame_x,"\n",dame_y,"\n",dame_xy)

ans = n*(pow2[n]-1)%MOD
for dx,dy,dxy in zip(dame_x,dame_y,dame_xy):
    ans += - dx - dy + dxy


print(ans%MOD)    








Measured memory_bytes: 122104
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    cpp();
    string s, t;
    cin>>s>>t;
    ll ans = 0;
    for(ll i=0; i<s.size(); i++){
        if(s[i]!=t[i]){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 3872
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.List.Split
import Data.Char
import Data.Ord
import Data.Array.IO

readInt = read :: String -> Int
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete

wf arr range = forM_ range $ \k -> forM_ range $ \i -> forM_ range $ \j -> update <$> readArray arr (i,j) <*> readArray arr (i,k) <*> readArray arr (k,j) >>= writeArray arr (i,j)
  where
    update a b1 b2 = min a $ b1 + b2

cost arr (-1) = return 0
cost arr n = readArray arr (n,1)

main = do
    [h, w] <- getInts
    arr <- concat <$> replicateM 10 getInts >>= newListArray ((0,0),(9,9)) :: IO (IOUArray (Int,Int) Int)
    wf arr [0..9]
    concat <$> replicateM h getInts >>= sequence . map (cost arr) >>= print . sum



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

vector<int> to[10007];
vector<int> color(10007);
stack<int> ans;

void dfs(int u){
    color[u] = 1;
    for (int i = 0; i < to[u].size(); i++){
        int v = to[u][i];
        if(color[v] == 0){
            dfs(v);
        }
    }
    ans.push(u);
}

int main() {
    int V, E; cin >> V >> E;
    rep(i, E){
        int s, t; cin >> s >> t;
        to[s].push_back(t);
    }

    for (int i = 0; i < V; i++){
        if(color[i] == 0){
            dfs(i);
        }
    }

    while(!ans.empty()){
        int x = ans.top(); ans.pop();
        cout << x << endl;
    }



    return 0;
}


Measured memory_bytes: 3836
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
	cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	cout << head;
	if (sizeof...(tail) != 0) cout << " ";
	print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
	for (auto& a : vec) {
		cout << a;
		if (&a != &vec.back()) cout << " ";
	}
	cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
	for (auto& vec : df) {
		print(vec);
	}
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int a, b, c;
	cin >> a >> b >> c;
	print(a+b>=c ? "Yes" : "No");
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


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

int main(){
	long long n,m;
	cin>>n>>m;
	long long inf=1000000007;
	if(abs(n-m)>1){
	    cout<<0<<endl;
	    return 0;
	}
	long long ans1=1,ans2=1;
	for(int i=n;i>0;i--){
	    ans1*=i;
	    ans1%=inf;
	}
	for(int i=m;i>0;i--){
	    ans2*=i;
	    ans2%=inf;
	}
	if(n==m) cout<<(ans1*ans2*2)%inf<<endl;
	else cout<<(ans1*ans2)%inf<<endl;
	
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A, B = 1, 1
    for _ in range(N):
        t, a = (int(i) for i in input().split())
        mul = max(-(-A//t), -(-B//a))
        A = t*mul
        B = a*mul
    print(A+B)


if __name__ == '__main__':
    main()


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

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

int a, b, c;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << ' ' << b << ' ' << c << endl;
    
    return 0;
}


Measured memory_bytes: 256
import queue


def main():
    N, W = map(int, input().split())

    dp = [[-float('inf') for _ in range(W + 1)] for _ in range(N + 1)]

    for i in range(W + 1):
        dp[0][i] = 0

    v = []
    w = []

    for _ in range(N):
        a, b = map(int, input().split())
        v.append(a)
        w.append(b)

    for i in range(N):
        for j in range(W + 1):

            dp[i + 1][j] = dp[i][j]

            if w[i] <= j:
                dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j])

    print(dp[N][W])

    return


if __name__ == '__main__':
    main()



Measured memory_bytes: 43852
W,a,b = map(int, input().split())

if a > b:
    if a < b+W:
        ans = 0
    else:
        ans = a - (b+W)
elif a < b:
    if b < a+W:
        ans = 0
    else:
        ans = b-(a+W)
else:
    ans = 0
print(ans)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int hei[110];

int main() {
	int W,Q;
	while(cin>>W>>Q){
		if(W==0&&Q==0)break;
		memset(hei,-1,sizeof(hei));
		string str;
		int id,w;
		int i;
		for(i=0;i<Q;i++){
			cin>>str;
			if(str=="s"){
				cin>>id>>w;
				int j;
				int k;
				bool ok;
				for(j=0;j<W;j++){
					ok=true;
					for(k=0;k<w;k++){
						if(j+k>=W||hei[j+k]!=-1){
							ok=false;
							break;
						}
					}
					if(ok){
						for(k=0;k<w;k++){
							hei[j+k]=id;
						}
						cout<<j<<endl;
						break;
					}
				}
				if(j==W)cout<<"impossible\n";
			}else{
				cin>>id;
				int j;
				for(j=0;j<W;j++){
					if(hei[j]==id){
						hei[j]=-1;
					}
				}
			}
		}
		cout<<"END\n";
	}
	return 0;
}

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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


template <typename T>
struct SegmentSet{
    set<pair<T, T>> s;
    set<pair<T, T>> s_rev;
    SegmentSet(){}
    // [l, r)を追加する
    void insert(T l, T r){
        auto iter = get(l).second;
        if(iter != s.end() && iter->first <= l && r <= iter->second)
            return;
        vector<pair<T, T>> erase_elm;
        for(auto it = s.lower_bound(make_pair(l, numeric_limits<T>::min())); it != s.end() && it->first <= r; ++it)
            erase_elm.emplace_back(*it);
        for(auto it = s_rev.lower_bound(make_pair(l, numeric_limits<T>::min())); it != s_rev.end() && it->first <= r; ++it)
            erase_elm.emplace_back(it->second, it->first);
        for(auto& p : erase_elm){
            chmin(l, p.first);
            chmax(r, p.second);
            s.erase(p);
            s_rev.erase(make_pair(p.second, p.first));
        }
        s.emplace(l, r);
        s_rev.emplace(r, l);
    }
    // xが含まれるような区間を返す
    pair<bool, typename set<pair<T, T>>::const_iterator> get(T x){
        auto it = s.lower_bound(make_pair(x, numeric_limits<T>::min()));
        if(it != s.begin())
            --it;
        return make_pair(x < it->second, it);
    }
    set<pair<T, T>>& operator*(){return s;}
};


signed main(){
    i64 n, x, d;
    cin >> n >> x >> d;

    if(d == 0){
        cout << (x == 0 ? 1 : n + 1) << endl;
        return 0;
    }
    if(d < 0){
        d = -d;
        x -= (n - 1) * d;
    }

    auto div = [&d](i64 y){
        if(y >= 0)
            return make_pair(y % d, y / d);
        i64 up = (-y + d - 1) / d;
        i64 mo = y + (-y + d - 1) / d * d;
        i64 div = -up;
        return make_pair(mo, div);
    };

    int sum = 0;
    map<i64,SegmentSet<i64>> v;
    for(i64 k = 0; k <= n; ++k){
        i64 pre = k * x;
        i64 mo, su;
        tie(mo, su) = div(pre);
        i64 mi = k * (k - 1) / 2;
        i64 ma = (n - 1) * k - k * (k - 1) / 2;
        sum += ma - mi + 1;
        v[mo].insert(su + mi, su + ma + 1);
    }
    i64 ans = 0;
    for(auto& p : v){
        for(auto& e : *p.second){
            ans += e.second - e.first;
        }
        for(auto it = (*p.second).begin(); next(it) != (*p.second).end(); ++it)
            assert(it->second < next(it)->first);
    }
    cout << ans << endl;
}



Measured memory_bytes: 53376
N = int(input())
ans = [0]*36

def bit(inp,ans):
    if inp == 0:
        ans[0] = 0
        inp2 = 0
    
    if inp > 0:
        b = [1,5,21,85,341,1365,5461,21845,87381,349525,1398101,5592405,22369621,89478485,357913941,1431655765]
        pcount = 0
        for ii in range(len(b)):
            if inp <= b[ii]:
                inp2 = inp - 4**ii
                break
            pcount = pcount + 1
        ans[pcount*2] = 1
        
    if inp < 0:
        b2 = [-2,-10,-42,-170,-682,-2730,-10922,-43690,-174762,-699050,-2796202,-11184810,-44739242,-178956970,-715827882,-2863311530]
        pcount = 0
        for ii in range(len(b2)):
            if inp >= b2[ii]:
                inp2 = inp + 2 * (4**ii)
                break
            pcount = pcount + 1
        ans[pcount*2+1] = 1
        
    return inp2,ans

    
while N != 0:
    N,ans = bit(N,ans)

fi = ans[::-1]
fistr = [str(n) for n in fi]
m = ''.join(fistr)
mm = int(m)

print(mm)

Measured memory_bytes: 3064
from bisect import bisect_left, bisect_right

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
c.sort()

res = 0
for j in b:
  res += bisect_left(a, j) * (n - bisect_right(c, j))
print(res)

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

constexpr long long mod = 1000000007;

#define rep(i, n) for (int i = 0; i < n; i++)

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

    ll n;
    cin >> n;
    vector<pair<ll, ll>> p(n);
    rep(i, n){
        ll a, b;
        cin >> a >> b;
        p[i] = make_pair(b, a);
    }

    sort(p.begin(), p.end());

    ll cnt = 0;

    bool b = true;
    rep(i, n) {
        cnt += p[i].second;

        if(cnt>p[i].first){
            b = false;
            break;
        }
    }

    if(b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define INF 1<<30

int N, M;
vector<vector<pair<int, int>>> G;
vector<int> W;
bool ok;

void dfs(int s){
    if(ok == false) return;

    for(auto p : G[s]){
        int t = p.first;
        int d = p.second;
        int dd = W[s] + d;
        if(W[t] != INF && W[t] != dd){
            ok = false;
            return;
        }
        if(W[t] == INF){
            W[t] = dd;
            dfs(t);
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    G.resize(N); W.resize(N, INF);
    for(int i=0; i<M; i++){
        int L, R, D;
        cin >> L >> R >> D;
        L--; R--;
        G[L].push_back(make_pair(R, D));
        G[R].push_back(make_pair(L, -D));
    }
    ok = true;
    for(int i=0; i<N; i++)
        if(W[i] == INF){
            W[i] = 0;
            dfs(i);
        }

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

Measured memory_bytes: 11136
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

#define all(x) x.begin(), x.end()

// Order Statistic Tree

/* Special functions:

        find_by_order(k) --> returns iterator to the kth largest element counting from 0
        order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
ordered_set;

const int MAXN = 2e5+7;

int a[3][MAXN];

void cant() {
    cout << "No" << endl;
    exit(0);
}

int perm[MAXN];
int flipped[MAXN];

typedef long long LL;
vector< int >parts[2];
//ordered_set bam[2];
ordered_set dan[2];
//LL cnt[2];
int xoor[2];

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

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }

    for (int j = 0; j < n; j++) {
        if (a[0][j] < a[2][j]) {
            if (a[0][j] != a[1][j]-1) cant();
            if (a[2][j] != a[1][j]+1) cant();
            flipped[j] = 0;
        } else {
            if (a[0][j] != a[1][j]+1) cant();
            if (a[2][j] != a[1][j]-1) cant();
            flipped[j] = 1;
        }
        perm[j] = a[1][j]/3;
    }

    for (int i = 0; i < n; i++) {
        parts[i&1].push_back(perm[i]);
//        bam[i&1].insert(perm[i]);
    }

    sort(all(parts[0]));
    sort(all(parts[1]));

    for (int i = 0; i < parts[0].size(); i++) {
        if (i > 0) {
            if (parts[1][i-1] > parts[0][i]) cant();
        }
        if (i < parts[1].size()) {
            if (parts[0][i] > parts[1][i]) cant();
        }
    }

//    cout << "sort ok" << endl;
//    for (int i = 0; i < n; i++) cout << perm[i] << " ";
//    cout << endl;
//    for (int i = 0; i < n; i++) cout << flipped[i] << " ";
//    cout << endl;

    for (int i = n-1; i >= 0; i--) {
        int v = i&1;
        xoor[v] ^= flipped[i];

        int way = dan[v].order_of_key(perm[i]);
        dan[v].insert(perm[i]);

//        cout << i << " => " << way << endl;
        xoor[v^1] ^= way&1;
    }

//    for (int i = 0; i < n; i++) cout << flipped[i] << " ";
//    cout << endl;

    if (xoor[0] || xoor[1]) cant();

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 7292
import std.string;
import std.conv;
import std.array;
import std.stdio;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.stdio;

void main() {
	int n, k;
	readf("%s %s\n", &n, &k);

	auto a = readln.chomp.split(' ').map!(to!int).array;

	bool f(int x) {
		// 一番長いのをx以下にできるか
		// 全部をx以下にするために切る回数<=k
		long now;

		foreach (e;a) {
			now += (e - 1) / x;
		}

		return now <= k;
	}

	int ng = 0, ok = 10 ^^ 9;
	while (ok - ng > 1) {
		auto middle = (ng + ok) / 2;

		if (f(middle)) {
			ok = middle;
		} else {
			ng = middle;
		}
	}
	writeln(ok);
}


Measured memory_bytes: 9592
#include <iostream>
using namespace std;
int main(){


int a,b;//変数を宣言


cin>>a>>b;//外部入力から変数を二つ読み込む

cout<<a*b<<" "<<2*(a+b)<<endl;


//面積空白スペース周の長さ改行を出力
return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
ll ans;
map<ll,vector<P> > a;

int main() {
  ll n,x,d;
  cin >> n >> x >> d;
  
  if(d == 0) {
    if(x == 0) {
      cout << 1 << endl;
    }
    else {
    cout << n + 1 << endl;
    }
    return 0;
  }
  if(d < 0) {
    x = -x;
    d = -d;
  }

  
  for(ll i = 0; i <= n; i++) {
    ll X = i * x % d;
    ll L = i * x + i * (i - 1) / 2 * d;
    ll R = i * x + (2 * n * i - i * i - i) / 2 * d;
    //cout << X << "   "<< L <<"   "<< R << "   "<<ans<<endl;
    a[X].push_back(P(L,R));
  }

  for(auto itr = a.begin(); itr != a.end(); ++itr) {
    vector<P> tmp = itr->second;
    sort(tmp.begin(),tmp.end());
    ll l = tmp[0].first;
    ll r = tmp[0].second;
    for(int i = 0; i < tmp.size(); i++) {
      if(tmp[i].first <= r) {
	r = max(r,tmp[i].second);
      }
      else {
	ans += (r - l) / d + 1;
	r = tmp[i].second;
	l = tmp[i].first;
      }
    }
    	ans += (r - l) / d + 1;
  }

  cout << ans << endl;
}
	
    
    


Measured memory_bytes: 22144
a1, b1 = input().split()
a2, b2 = input().split()
a3, b3 = input().split()
town = [a1, b1, a2, b2, a3, b3]
if town.count('1')>=3 or town.count('2')>=3 or town.count('3')>=3 or town.count('4')>=3:
    print('NO')
elif town.count('1')==0 or town.count('2')==0 or town.count('3')==0 or town.count('4')==0:
    print('NO')
else:
    print('YES')

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int max_n = 1000;
int h, w;
string s[max_n];

bool u[max_n][max_n];
int vx[4] = {1, 0, -1, 0};
int vy[4] = {0, 1, 0, -1};

ll bc;
ll wc;

void dfs(int x, int y, bool b){
	u[x][y] = true;
	if(b){
		bc++;
	}else{
		wc++;
	}

	for(int i = 0; i < 4; i++){
		int nx = x + vx[i];
		int ny = y + vy[i];

		if(0 <= nx && nx < h && 0 <= ny && ny < w && !u[nx][ny]){
			if(b){
				if(s[nx][ny] == '.') dfs(nx, ny, !b);
			}else{
				if(s[nx][ny] == '#') dfs(nx, ny, !b);
			}
		}
	}
}

void sout(){
	rep(i, h){
		rep(j, w){
		   cout << s[i][j];
	   }
	   cout << endl;
	}
}


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

	cin >> h >> w;
	rep(i, h) cin >> s[i];
	rep(i, h) rep(j, w) u[i][j] = false;

	ll ans = 0;
	rep(i, h){
		rep(j, w){
			bc = 0;
			wc = 0;
			if(!u[i][j]){
				dfs(i, j, s[i][j] == '#');
			}
			ans += bc * wc;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 13312
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <math.h>

using namespace std;

#define NUM 1000001

int main(){
	int* table = new int[NUM];
	int limit;

	for(int i=0; i < NUM;i++)table[i] = 1;
	table[0] = 0;
	table[1] = 0;

	limit = sqrt(NUM);

	for(int i=2;i<=limit;i++){
		if(table[i] == 1){
			for(int k=2*i;k < NUM; k += i){
				table[k] = 0;
			}
		}
	}

	int a,d,n,count;

	while(true){
		scanf("%d %d %d",&a,&d,&n);
		if(a == 0 && d == 0 && n == 0)break;

		count = 0;
		for(int i=1; i<= 1000000; i++){
			if(table[a+(i-1)*d] == 1)count++;
			if(count == n){
				printf("%d\n",a+(i-1)*d);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 7044
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int X,Y,A,B,C;
  cin >> X >> Y >> A >> B >> C;
  vector<ll> a(A),b(B),c(C);
  for(int i=0; i<A; i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end(),greater<ll>());
  for(int i=0; i<B; i++){
    cin >> b[i];
  }
  sort(b.begin(),b.end(),greater<ll>());
  for(int i=0; i<C; i++){
    cin >> c[i];
  }
  sort(c.begin(),c.end(),greater<ll>());
  priority_queue<int,vector<int>,greater<int>> que;
  for(int i=0; i<X; i++){
    que.push(a[i]);
  }
  for(int i=0; i<Y; i++){
    que.push(b[i]);
  }
  for(int i=0; i<C; i++){
    ll v = que.top();
    que.pop();
    chmax(v,c[i]);
    que.push(v);
  }
  ll ans = 0;
  while(que.size()){
    ans += que.top();
    que.pop();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3832
#include<iostream>
using namespace std;
int prime[1000000];
bool is_prime[1000001];

int sieve(int n){
  int p=0;
  for(int i=0;i<=n;i++)is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;
  for(int i=0;i<=n;i++){
    if(is_prime[i]==true){
      prime[p++]=i;
      for(int j=2*i;j<=n;j+=i)is_prime[j]=false;
    }
  }
  return p;
}



int main(){
  int n;
  while(cin>>n,n)
    cout<<sieve(2*n)-sieve(n)<<endl;
  return 0;
}

Measured memory_bytes: 1492
#include<stdio.h>
int main(void)
{
	int x1,y1,z1,w1,x2,y2,z2,w2;
	int x3=0,y3=0,z3=0,w3=0;
	int n,i;
	while(1){
		scanf("%d",&n);
		if(n==0)
		break;
		for(i=0;i<n;i++){
			scanf("%d%d%d%d%d%d%d%d",&x1,&y1,&z1,&w1,&x2,&y2,&z2,&w2);
			x3=(x1*x2)+((y1*y2)*(-1))+((z1*z2)*(-1))+((w1*w2)*(-1));
			y3=(x1*y2)+(y1*x2)+(z1*w2)+((w1*z2)*(-1));
			z3=(x1*z2)+((y1*w2)*(-1))+(z1*x2)+(w1*y2);
			w3=(x1*w2)+(y1*z2)+((z1*y2)*(-1))+(w1*x2);
			printf("%d %d %d %d\n",x3,y3,z3,w3);
		}
	}
	return 0;
}

Measured memory_bytes: 600
N, M = [int(i) for i in input().strip().split()]
L = [0] * M
R = [0] * M
for i in range(M):
    L[i], R[i] = [int(i) for i in input().strip().split()]

LL, RR = L[0], R[0]
is_zero = False
for i in range(1, M):
    if RR < L[i]:
        is_zero = True
        break
    elif LL <= L[i] <= RR:
        LL = max(LL, L[i])
        RR = min(RR, R[i])
    elif L[i] < LL <= R[i]:
        RR = min(RR, R[i])
    else:
        is_zero = True
        break

if is_zero:
    print(0)
else:
    print(RR - LL + 1)


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    ll n = in();
    if (n % 2 == 1)
    {
        cout << 0 << endl;
        return;
    }

    ll ans = 0;
    ans += n / 10;
    for (ll i = 50; i <= n; i *= 5)
    {
        ans += n / i;
    }
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<cmath>
#include<map>
#define ll long long
using namespace std;
int main(){
	int n;
	string s;
	cin>>n>>s;
	for(int i=0;i<s.size();i++){
		char c=s[i]+n;
		if(s[i]+n>'Z'){
			c=s[i]+n+'A'-'Z'-1;
		}
		cout<<c;
	}
	return 0;
}

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

int main()
{
	int n, a, b, ans = 0;
	cin >> n >> a >> b;
	for(int i = 1; i <= n; i++)
	{
		int cnt = 0;
		string str = to_string(i);
		for(auto&& j : str)
		{
			cnt += j - '0';
		}
		ans += i * (a <= cnt && cnt <= b);
	}
	cout << ans << "\n";
}


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

string u;
double x;
double ans=0.0;
int N;

int main() {
    cin >> N;
    for (int i=0; i<N; ++i) {
        cin >> x >> u;
        if (u == "JPY") ans += x;
        else ans += 380000.0 * x;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import bisect

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()

BC = {}
for i in range(N):
  rank = N - bisect.bisect_right(C, B[i])
  BC[B[i]] = rank
#print(BC)
BCS = [0 for _ in range(N)]
BCS[N-1] = BC[B[N-1]]
for i in range(N-2,-1,-1):
  BCS[i] =  BCS[i+1] + BC[B[i]]
#print(BCS)

ans = 0
for i in range(N):
  rank = bisect.bisect_right(B, A[i])
  if rank < N:
    ans += BCS[rank]
print(ans)

Measured memory_bytes: 118324
#include <bits/stdc++.h>
using namespace std;
int n;
const int N = (int) 3e5;
int a[N], b[N];
int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    int ans = 0;
    long long need = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] < b[i]) {
            ans++;
            need += b[i] - a[i];
        }
    }
    vector<int> free;
    for (int i = 0; i < n; i++) {
        if (a[i] > b[i]) {
            free.push_back(a[i] - b[i]);
        }
    }
    sort(free.begin(), free.end());
    reverse(free.begin(), free.end());
    for (auto x: free) {
        if (need == 0) {
            break;
        }
        long long take = min(need, 1ll * x);
        need -= take;
        ans++;
    }
    if (need > 0) {
        cout << "-1\n";
        return 0;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>

static const int N = 100;

int min(int a,int b){
  if(a>b)return b;
  else return a;
}

int main(){
  int i,j,k,l,n,p[N + 1],m[N+1][N+1];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }
  for(i=1;i<=n;i++)m[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j = i+l-1;
      m[i][j]=(1<<21);
      for(k=i;k<=j-1;k++){
	m[i][j] = min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }
  printf("%d\n",m[1][n]);

  return 0;
}

  
      



Measured memory_bytes: 2052
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[110];
    rep(i, N) cin >> A[i];
    int ans = 1;
    rep(i, N) ans *= 3;
    int t = 1;
    rep(i, N) {
        if (A[i] % 2 == 0) t *= 2;
    }
    cout << ans - t << endl;

    

    return 0;
}


Measured memory_bytes: 256