akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int modPow(long long a, long long n, long long p) {//0でバグる
	if (n == 1) return a % p;
	if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
	long long t = modPow(a, n / 2, p);
	return (t * t) % p;
}

ll comb(ll n, ll p) {
	if (p * 2 > n) p = n - p;
	if (p > n - p) p = n - p;
	ll a = 1, b = 1;
	rrep(i, p + 1) {
		a = (a * (n - i + 1)) % mod;
		b = (b * i) % mod;
	}
	return a * (modPow(b, mod - 2, mod)) % mod;
}

ll fact(ll a) {
	ll res = 1;
	for (int i = 1; i <= a; ++i) (res *= i) %= mod;
	return res % mod;
}

ll perm(ll a, ll b) {
	if (a < 0 || a < b) return 0;
	return comb(a, b) * fact(b) % mod;
}

int n, k;
vector<int> g[100005];
ll ans;

void dfs(int v, int p = -1) {
	for (auto& c : g[v]) {
		if (c == p) continue;
		dfs(c, v);
	}
	ll a = 0;
	if (v == 0) {
		a += perm(k - 1, (int)g[v].size());
	}
	else {
		a += perm(k - 2, (int)g[v].size() - 1);
	}
	(ans *= a) %= mod;
	return;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k;
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	ans = k;
	dfs(0);
	cout << ans << endl;
	return 0;
}


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

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

const long long MOD = 1000000007;

int main(){
  int k,n,l;
  int ans=0,ml=0;
  cin >> k >> n;
  vector<int> a(n);
  rep(i,n) cin >> a.at(i);
  rep(i,n-1){
    l=a.at(i+1)-a.at(i);
    ml=max(l,ml);
  }
  l=a.at(0)+(k-a.at(n-1));
  ml=max(l,ml);
  ans=k-ml;
  cout << ans<<endl;
    
}


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

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

    string s;
    cin >> s;

    lint q;
    cin >> q;

    vector<lint> k(q);
    for(auto& elem : k)  cin >> elem;

    for(lint i=0; i<k.size(); i++) {
        deque<char> dq;
        lint ans = 0, m = 0, dm = 0, d_all = 0;
        for(lint right=0; right<n; right++) {
            if(dq.size() >= k[i]) {
                lint l = dq.front(); dq.pop_front();
                if(l == 'M')  m--;
                if(l == 'D')  d_all--, dm-=m;
            }

            lint r = s[right];
            dq.push_back(r);
            if(r == 'C')  ans += dm;
            if(r == 'M')  dm += d_all, m++;
            if(r == 'D')  d_all++;
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 2312
#include<stdio.h>
int main(){
  int n,a,i,b[200010]={};
  scanf("%d",&n);
  for(i=1;i<n;i++){
    scanf("%d",&a);
    b[a]++;
  }
  for(i=0;i<n;i++)printf("%d\n",b[i+1]);
  return 0;
}
  


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

int main(){
  int n;
  cin >> n;
  
  long long min, max;
  cin >> min;
  max = min;
  
  for(int i = 0; i < n-1; i++){
    long long a;
    cin >> a;
    if(max < a) max = a;
    else if(a < min) min = a;
  }
  
  cout << max - min << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<int,int>mp;
int a[123456];
int main()
{
    int n  , i , j , k ;
    scanf("%d",&n);
    for(i = 0 ; i < n ; i++)
    {
        scanf("%d",&a[i]);
        mp[a[i]]++;

    }
    sort(a,a+n,greater<int>());
    int cnt = 0 ;
    long long  prev = 1 ;
    for(i = 0 ; i < n ; i++)
    {
        if(mp[a[i]]>=2 )
        {
            cnt ++;
            if(cnt >= 2 )
            {
                printf("%lld\n", prev*(long long)a[i]);
                return 0 ;
            }
            prev = a[i];
            mp[a[i]]-=2;
        }
    }
    cout << 0 ;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if ((10 * b + c) % 4 == 0) {
        cout << "YES" << endl;
        return 0;
    } else {
        cout << "NO" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n,a[25],v[25],b[25];
	int j[25]={};
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i]>>v[i];
		b[a[i]-1]=v[i];
	}
	sort(b,b+n);
	for(int i=0;i<n;i++){
		if(v[i]==b[n-1]){
			j[a[i]]++;
		}
	}
	for(int i=1;i<=n;i++){
		if(j[i]!=0){
			cout<<i<<" "<<b[n-1]<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3152
N,T = map(int, raw_input().split())
A = map(int, raw_input().split())
x = 10**9
y = 0
ans = 0
for a in A:
    t = a-x
    if t>y:
        y = t
        ans = 0
    if t==y:
        ans += 1
    x = min(x, a)
print ans


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

using namespace std;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) v.size()
#define f first
#define s second
#define FOR(i, a) for(int i = 0; i < (int) a.size(); i++)

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

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

	int h, w, n; cin >> h >> w >> n;

	int ans1 = (n%h == 0 ? n/h : n/h+1), ans2 = (n%w == 0 ? n/w : n/w+1);
	cout << min(ans1, ans2) << '\n';

	return 0;
}

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

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b<b+a&&a+b<a+c)
	{
		cout<<a+b;
	}
	else if(b+c<a+b&&b+c<a+c)
	{
		cout<<b+c;
	}
	else if(c+a<b+a&&c+a<c+b)
	{
		cout<<c+a;
	}
	else
	{
		cout<<a+b;
	}
	return 0;
}

Measured memory_bytes: 3172
#include<iostream>
#include<string.h>
#include<algorithm>
#include<utility>
#include<unordered_map>
#include<vector>
#include<math.h>
#include<set>
using namespace std;
// bool findPossibleOrNot(int** edges,int n,int* visited,int currentIndex,int count1,int count2,int count3,int n1,int n2,int n3,int currentColour)
// {
//     visited[currentIndex] = currentColour;
//     if(currentColour==1)
//     {
//         if(count2)
//     }
//     else if(currentColour==2)
//     {

//     }
//     else
//     {

//     }
// }
// int main()
// {
//     int n;
//     cin>>*edges = new int*[n];
//     for(int i=0;i<n;i++)
//     {
//         edges[i] = new int[n]{0};
//     }
//     int e;
//     cin>>e;
//     while(e--)
//     {
//         int x,y; 
//         cin>>x>>y;
//         edges[x][y] = 1;
//         edges[y][x] = 1;
//    }
//    int n1,n2,n3;
//    cin>>n1>>n2>>n3;
//    int *visited = new int[n]{0};
//    bool ans = findPossibleOrNot(edges,n,0,visited,0,0,0,n1,n2,n3,1)<<endl;
//    if(ans==true){
//     cout<<"YES"<<endl;
//     for(int i=0;i<n;i++)
//     {
//         cout<<visited[i]<<" ";
//     }
//    }
//    else
//    {
//     cout<<"NO"<<endl;
//    }
// }
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(s.size()>n)
    {
        cout<<s.substr(0,n)<<"..."<<endl;
    }
    else
    {
        cout<<s<<endl;
    }

}

Measured memory_bytes: 3628
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)
	fmt.Print(run(a, b))
}

func run(a, b int) int {
	x, y := a, b
	for i := 0; i < 1000000; i++{
		if x > y {
			y += b
		} else if y > x {
			x += a
		} else {
			return x
		}
	}
	return 0
}


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

public class Main {
	  public static void main (String args[]) throws Exception
	  {
	    Scanner cin = new Scanner(System.in);
	    int a = cin.nextInt(), b = cin.nextInt();
	    int c = a*b;
	    if(c%2==0){
	    	System.out.println("Even");
	    }else{
	    	System.out.println("Odd");
	    }
	  }	
}

Measured memory_bytes: 19924
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <deque>
using namespace std;
typedef long long int ll;

struct Dice{
    int a,b,c,d,e,f;
};

void rotate(Dice &D,char c){
    int tmp;
    if(c=='N'){
        tmp=D.a;D.a=D.b;D.b=D.f;D.f=D.e;D.e=tmp;
    }
    if(c=='S'){
        tmp=D.a;D.a=D.e;D.e=D.f;D.f=D.b;D.b=tmp;
    }
    if(c=='W'){
        tmp=D.a;D.a=D.c;D.c=D.f;D.f=D.d;D.d=tmp;
    }
    if(c=='E'){
        tmp=D.a;D.a=D.d;D.d=D.f;D.f=D.c;D.c=tmp;
    }
}

void spin(Dice &D){
    int tmp;
    tmp=D.b;D.b=D.c;D.c=D.e;D.e=D.d;D.d=tmp;
}

bool same(Dice &D,Dice &E){
    if(D.a==E.a&&D.b==E.b&&D.c==E.c&&D.d==E.d&&D.e==E.e&&D.f==E.f)return true;
    else return false;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    Dice D,E;
    cin >> D.a >> D.b >> D.c >> D.d >> D.e >> D.f;
    cin >> E.a >> E.b >> E.c >> E.d >> E.e >> E.f;
    bool ok=0;
    for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            if(same(D,E))ok=1;
            spin(E);
        }
        rotate(E,'N');
    }
    rotate(E,'E');
    for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            if(same(D,E))ok=1;
            spin(E);
        }
        rotate(E,'N');
    }
    if(ok){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3212
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX = 200000;

int main()
{

    int loop, R[MAX];

    cin >> loop;

    for (int i = 0; i < loop; i++)
        cin >> R[i];

    int maxv = -2000000000;
    int minv = R[0];

    for (int i = 1; i < loop; i++)
    {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
}


Measured memory_bytes: 3860
#include <iostream>
#include <string>
#include <algorithm>
#define int long long
using namespace std;

signed main() {
    int n,k,d;
    cin >> n >> k;/*
    while(n > abs(n-k)){
        n = abs(n-k);
        cout << n << endl;
    }*/
    d = n/k;
    n -= d*k;
    while(n > abs(n-k)){
        n = abs(n-k);
    }
    cout << n;

    return 0;
}

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

int countDigits(int64_t N) {
  int digits = 0;

  while (N > 0) {
    digits++;
    N /= 10;
  }

  return digits;
}

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

  int min_digits = countDigits(n);
  for (int64_t a = 1; a * a <= n; a++) {
    if (n % a == 0) {
      int64_t b = n / a;
      int f = max(countDigits(a), countDigits(b));
      min_digits = min(min_digits, f);
    }
  }

  cout << min_digits << endl;
  return 0;
}

Measured memory_bytes: 256
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

import java.util.ArrayList;
import java.util.List;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		//文字列読込み
		Scanner sc = new Scanner(System.in);

		//結果格納
		int scInt;	//1行
		int[] check  = new int[101];
		int max = 0;

		while (sc.hasNext()) {
			//1行読込み
			scInt = sc.nextInt();
			check[scInt] = check[scInt] + 1;	
			if (max < check[scInt]) {
				max = check[scInt];
			}
		}
		
		for (int i = 1; i < 101; i++) {
			if (check[i] == max) {
				System.out.println(i);
			}
		}
	}
}


Measured memory_bytes: 26224
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.stream.IntStream;

public class Main {
	final static long MOD = 998244353L;
	
	class Node {
		HashMap<Integer, Long> V = new HashMap<>();
		
		void addP(int n){
			V.put(n, V.getOrDefault(n,0L)+1);
			if (V.get(n) == 0L) V.remove(n);
		}
		
		void addM(int n){
			V.put(n, V.getOrDefault(n,0L)-1);
			if (V.get(n) == 0L) V.remove(n);
		}
	}
	
	public Main() {
		FastScanner scanner = new FastScanner();
		int N = scanner.nextInt();
		int K = scanner.nextInt();
		
		int[][] S = new int[K][2];
		IntStream.range(0, K).forEach( i -> {
			S[i][0] = scanner.nextInt();
			S[i][1] = scanner.nextInt();
		});
		
		Node[] DP = new Node[N+1];
		IntStream.rangeClosed(1, N).forEach( i -> DP[i] = new Node());
		
		IntStream.range(1, N).forEach( i -> {
			IntStream.range(0, K).forEach(k -> {
				if (i+S[k][0]   <= N) DP[i+S[k][0]  ].addP(i);
				if (i+S[k][1]+1 <= N) DP[i+S[k][1]+1].addM(i);
			});
		});
		
		long NUM[] = new long[N+1];
		NUM[1] = 1L;
		long SUM = 0L;
		for (int n = 2; n <= N; n++) {
			for (int i : DP[n].V.keySet() ) {
				SUM = (SUM + NUM[i]*DP[n].V.get(i)%MOD) % MOD;
				if (SUM < 0) SUM += MOD;
			}
			NUM[n] = SUM;
		}
		
		System.out.println(NUM[N]);
	}
	
	public static void main(String[] args) {
		new Main();
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private int readByte() {
		if (hasNextByte()) return buffer[ptr++];
		else return -1;
	}
	
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
		return hasNextByte();
	}
	
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 253368
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n, a, cnt[4] = {};
    cin >> n;
    while (n--) {
        cin >> a;
        cnt[a%4]++;
    }
    a = cnt[1]+(cnt[2]&1)+cnt[3];
    if (cnt[0]+1 >= a) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;
#define all(a) a.begin(), a.end()
#define eall(a) a.begin()+1, a.end()
#define show(ans)  cout << ans << endl;

long x[11][11];
int main(){
long N, D;
cin >> N >> D;
erep(i, N){
    erep(j, D) cin >> x[i][j];
}
long cnt = 0;
map<long, bool> mp;
erep(i, 10000) mp[i*i] = true;

erep(i, N-1){
    for(long j = i+1; j <= N; j++){
        long sum = 0;
        erep(k, D){
            sum += pow(abs(x[i][k]-x[j][k]), 2);
        }
        if(mp[sum] == true) cnt++;
    }
}
show(cnt);


return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define mod 1000000007
#define pb push_back
#define VJ ios_base::sync_with_stdio(false);cin.tie(NULL);
// #define mp make_pair()
#define vi(x) vector<int>x
#define vl vector<long long int>
#define vc vector<char> 
#define Memset(a,num,l,r) for(int iii=l;iii<=r;iii++) a[iii]=num;
#define Printwithspace(a,l,r)for(int iii=l;iii<=r;iii++) cout<<a[iii]<<" ";
#define PrintwithNewline(a,l,r) for(int iii=l;iii<=r;iii++) cout<<a[iii]<<endl;
#define MAX 100005
using namespace std;



void solve(){
	int d,t,s;cin>>d>>t>>s;
	double time=(float)d/(float)s;
	if(time>t){
		cout<<"No"<<endl;
	}
	else 
		cout<<"Yes"<<endl;
	
}

int main(){
	 #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	 #endif
	VJ
	solve();
	return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#ifdef dremix
    #define p(x) cerr<<#x<<" = "<<x<<endl;
    #define p2(x,y) cerr<<#x<<" , "<<#y<<" = "<<x<<" , "<<y<<endl;
    #define pp(x) cerr<<#x<<" = ("<<x.F<<" , "<<x.S<<")"<<endl;
    #define pv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u<<", ";cerr<<"}"<<endl;
    #define ppv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u.F<<"-"<<u.S<<", ";cerr<<"}"<<endl;
#else
    #define p(x)
    #define p2(x,y)
    #define pp(x)
    #define pv(x)
    #define ppv(x)
#endif
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int maxp = 22;
const ld EPS = 1e-18;
const ll INF = 1e18;
const int MOD = 1e9+7;
const int N = 2e5+1;

struct DSU{
    vector<int> par,siz;
    int cnt;

    void init(int n){
        cnt = n;
        par.assign(n+1,0);
        siz.assign(n+1,1);
        iota(par.begin(),par.end(),0);
    }

    int find(int x){
        return (par[x]==x) ? x : par[x] = find(par[x]);
    }

    bool merge(int x, int y){
        x = find(x);
        y = find(y);
        if(x==y)return false;
        if(siz[x]<siz[y])
            swap(x,y);

        siz[x] += siz[y];
        par[y] = x;
        cnt--;
        return true;
    }

};


int main(){
fastio

int n,m;
cin>>n>>m;

DSU dsu;
dsu.init(n);

for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    dsu.merge(x,y);
}

cout<<dsu.cnt-1<<endl;


}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    ll n;
    cin >> n;
    if(n % 2){
        cout << 0 << endl;
        return 0;
    }

    ll res = 0;
    ll div = 10;
    for(; div <= n; div *= 5){
        res += n / div;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split())) 
count = 0

def search(key, left, right):
  if right - left <= 1:
    return False

  mid = (left + right) // 2
  if S[mid] == key:
    return True

  if key < S[mid]:
    return search(key, left, mid)
  else:
    return search(key, mid, right)

for t in T:
  if search(t, 0, n):
    count += 1

print(count)




Measured memory_bytes: 16708
def Initialize(head, tail):
    head, tail = 0, 0
    return head, tail

def IsEnpty(head, tail):
    return head == tail

def IsFull(head, tail):
    global MAX
    return head == (tail + 1) % MAX

def Enqueue(Q, x, y, head, tail):
    global MAX
    if IsFull(head, tail):
        return None
    Q[tail][0], Q[tail][1] = x, y
    if tail + 1 == MAX:
        tail = 0
    else:
        tail += 1
    return head, tail

def Dequeue(Q, head, tail):
    global MAX
    if IsEnpty(head, tail):
        return None
    x, y = Q[head][0], Q[head][1]
    if head + 1 == MAX:
        head = 0
    else:
        head += 1
    return x, y, head, tail

n, q = map(int, input().split())
MAX = n + 2
Q = [['', 0] for _ in range(MAX)]
head, tail = 0, 0
result = []
z = 0
for i in range(n):
    x, y = input().split()
    head, tail = Enqueue(Q, x, int(y), head, tail)
while IsEnpty(head, tail) != True:
    if Q[head][1] <= q:
        x, y, head, tail = Dequeue(Q, head, tail)
        result.append([x, y + z])
        z += y
    else:
        Q[head][1] -= q
        x, y, head, tail = Dequeue(Q, head, tail)
        head, tail = Enqueue(Q, x, y, head, tail)
        z += q
for i in range(n):
    print(*result[i], sep=' ')


Measured memory_bytes: 20600
#include <bits/stdc++.h>
#define Stop { cout << "-1\n"; return 0; }

using namespace std;

typedef long long ll;
const int Nmax = 1e5 + 5;

map<ll, int> mp;
vector<int> v[Nmax];
ll d[Nmax], Sum;
int t[Nmax], w[Nmax], level[Nmax];
int n, i, node, dad, root;

void dfs(int node)
{
    for(auto it : v[node])
    {
        level[it] = level[node] + 1;
        dfs(it);
        w[node] += w[it];
    }
    Sum += level[node];
}

bool verif()
{
    int i;
    for(i=1; i<=n; ++i)
    {
        w[i] = 1;
        v[t[i]].push_back(i);
    }

    dfs(root);

    if(Sum != d[root]) return 0;

    for(i=1; i<=n; ++i)
        if(i != root)
            if(d[i] != d[t[i]] + n - 2 * w[i]) return 0;
    return 1;
}

int main()
{
 ///   freopen("input", "r", stdin);
    cin.sync_with_stdio(false);

    cin >> n;
    for(i=1; i<=n; ++i) cin >> d[i], mp[d[i]] = i, w[i] = 1;

    root = mp.begin() -> second;

    for(auto it = mp.rbegin(); it != mp.rend(); ++it)
    {
        node = it->second;
        dad = mp[ d[node] - n + 2 * w[node] ];

        if(node == root) dad = 0;
            else if(!dad) Stop;
        if(dad == node) Stop;

        t[node] = dad;
        w[dad] += w[node];
    }

    if(!verif()) Stop;

    for(i=1; i<=n; ++i)
        if(t[i]) cout << t[i] << ' ' << i << '\n';
    return 0;
}


Measured memory_bytes: 17408
#include<iostream>
#include<stdlib.h>
int main(void){
    int a,b,home;
    std::cin>>home>>a>>b;
    if(abs(home-a)<abs(home-b)){
        std::cout<<"A"<<std::endl;
    }else{
        std::cout<<"B"<<std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

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

import collections
c = collections.Counter(a)

# print(n)
# print(a)

# l = [0] * (n + 1)
# ll  = [0] * (n + 1)

l = {}
ll = {}

# for i in range(n):
#     l[a[i]] += 1
#     ll[a[i]] = int((l[a[i]] * (l[a[i]] - 1)) / 2)
    
# print(c)
    
for key, value in c.items():
    l[key] = value
    ll[key] = int((value * (value - 1)) / 2)
    
# print(l)
# print(ll)
    
# print(l)
# print(ll)

c_sum = sum(ll.values())
for i in range(n):
    v = l[a[i]]
    vv = ll[a[i]]
    vvv = int(((v - 1) * (v - 2)) / 2)
    # print(vvv)
    print(c_sum - (vv - vvv))

Measured memory_bytes: 37944
#include<iostream>
#include <cmath>
#include <cstdio>
using namespace std;

string s[3];

int judge(int x){
	int next = s[x][0];
	s[x].erase(s[x].begin());
	return next-'a';
}
int main(){
	int turn=0;
	for(int i=0;i<3;i++)cin >> s[i];
	while(!s[turn].empty()){
		turn = judge(turn);
	}
	printf("%c\n",'A'+turn);
}


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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}


int main(void){
    int a, b;
    scanf("%d %d", &a, &b);
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 ){
        printf("Possible\n");
    }else{
        printf("Impossible\n");
    }

    return 0;
    
}


Measured memory_bytes: 128
x, n=map(int, input().split())
p = list(map(int, input().split()))

if x in p:
    y = x - 1
    while y in p:
        y -= 1
    z = x + 1
    while z in p:
        z += 1
    # print(y,z)
    if(abs(y-x) == abs(z-x)):
        print(y)
    elif(abs(y-x) > abs(z-x)):
        print(z)
    else:
        print(y)
else:
    print(x)
# print(x,n)
# print(p)

Measured memory_bytes: 9204
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, d;
  cin >> h >> w >> d;
  if (d % 2 == 1) {
    // ITIMATU
    REP(i, 0, h) {
      string s(w, 'R');
      REP(j, 0, w) {
	if ((i + j) % 2 == 0) {
	  s[j] = 'B';
	}
      }
      cout << s << "\n";
    }
    return 0;
  }
  REP(i, 0, h) {
    string s(w, '.');
    REP(j, 0, w) {
      int p = (i - j + 500 * d) % (2 * d);
      int q = (i + j) % (2 * d);
      p /= d;
      q /= d;
      assert (p <= 1);
      assert (q <= 1);
      s[j] = "RGYB"[2 * p + q];
    }
    cout << s << "\n";
  }
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a = n % 10;
	int b = n / 10 % 10;
	int c = n / 100 % 10;
	int d = n / 1000;
	if (d + c + b + a == 7)
		cout << d << "+" << c << "+" << b << "+" << a << "=7" << endl;
	else if (d + c + b - a == 7)
		cout << d << "+" << c << "+" << b << "-" << a << "=7" << endl;
	else if (d + c - b + a == 7)
		cout << d << "+" << c << "-" << b << "+" << a << "=7" << endl;
	else if (d + c - b - a == 7)
		cout << d << "+" << c << "-" << b << "-" << a << "=7" << endl;
	else if (d - c + b + a == 7)
		cout << d << "-" << c << "+" << b << "+" << a << "=7" << endl;
	else if (d - c + b - a == 7)
		cout << d << "-" << c << "+" << b << "-" << a << "=7" << endl;
	else if (d - c - b + a == 7)
		cout << d << "-" << c << "-" << b << "+" << a << "=7" << endl;
	else if (d - c - b - a == 7)
		cout << d << "-" << c << "-" << b << "-" << a << "=7" << endl;
	else
		exit(-1);
	return 0;
}

Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 1e+6+5;
int big = 1e+18+3;
int mod = 1e+9+7;

signed main()
{
    IOS;
      
    string s; cin>>s;
    int n = s.size();
    vector<int>ind[2019];

    int ar[n+1];

    repa(i,1,n)
        ar[i] = (int)s[i-1] - (int)'0'; 
    
    int ans = 0;
    int curmod = 0;
    int tv = 1;

    for (int i = n; i>=1; i--)
    {
        curmod+=ar[i]*tv;
        curmod%=2019;

        ind[curmod].pb(i);

        tv*=10;
        tv%=2019;

        if (!curmod)
            ans++;
    }

    int finmod = curmod;

    repa(i,0,2018)
        sort(all(ind[i]));

    curmod = 0;

    int tenmod[n+3];

    tenmod[0] = 1;

    repa(i,1,n+1)
    {
        tenmod[i] = tenmod[i-1]*10;
        tenmod[i]%=2019;
    }


    repa(i,1,n)
    {
        curmod+=ar[i]*tenmod[n-i];
        curmod%=2019;

        int req = ( finmod - curmod + 2019 )%2019;
        req%=2019;

        int key = i+2;
      //  debug2(i,req);

        if (ind[req].size() && lower_bound(all(ind[req]), key)!=ind[req].end())
        {
            int index = lower_bound(all(ind[req]), key) - ind[req].begin();
            ans+=ind[req].size() - index;
        }

        if (curmod==0)
            ans++;
    }

    if (!finmod)
        ans--;
    cout<< ans <<endl;


}

Measured memory_bytes: 9144
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main(){
    int x,a,b;
    cin >> x >> a >> b;
    if(-a+b<=0)cout << "delicious" << endl;
    else if(-a+b<=x)cout << "safe" << endl;
    else cout << "dangerous" << endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

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

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

int N; int c[10][10];
void input()
{
    cin>>N;
    return;
}
int max_digit(int n)
{
    while(n>=10){
        n/=10;
    }
    return n;
}
int min_digit(int n)
{
    return n%10;
}
void solve()
{
    int ans=0;
    rep(i,10) rep(j,10){
        int tmp=0;
        rrep(k,1,N+1){
            if(max_digit(k)==i&&min_digit(k)==j) ++tmp;
        }
        c[i][j]=tmp;
    }
    rep(i,10) rep(j,10) ans+=c[i][j]*c[j][i];
    cout<<ans<<endl;
    return;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <string>
using namespace std;




int main()
{
	int a, b;
	cin >> a >> b;
	if (a <= 8 && b <= 8)
		cout << "Yay!" << endl;
	else
		cout << ":(" << endl;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll mod = 10e9+7;

#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prtd(n, var)  cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl

//----------------------------------------------------------------
class Graph{

public:
  vector<vector<int>> tree;
  vector<int> check;
  int ans;
  Graph(int n){
    tree.resize(n);
    initCheck(n);
    ans = 0;
  }
  ~Graph(){}

  void addpath(int m){
    int a, b, c;
    rep(i,m){
      cin >> a >> b >> c;
      a--;b--;
      tree[a].push_back(b);
      tree[b].push_back(a);
    }
  }

  void initCheck(int n){
    check.assign(n, false);
  }

  void dfs(int v){
    check[v] = true;
    for(auto next_v : tree[v]){
      if(check[next_v]) continue;
      dfs(next_v);
    }
  }
};

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

  Graph g(n);

  g.addpath(m);

  rep(j,n){
    if(g.check[j]){
      continue;
    } else {
      g.ans++;
      g.dfs(j);
    }

  }

  prt(g.ans);

}


Measured memory_bytes: 8064
#coding: UTF-8

N = int(input())

zorome = 0
flag = 0
for i in range(N):
  #i回目ゾロ目か
  D = list(map(int,input().split()))
  if D[0] == D[1]:
    zorome += 1
  else:
    zorome = 0
  if zorome >=3:
    print('Yes')
    flag = 1
    break
if flag ==0:
  print('No')

Measured memory_bytes: 9176
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;
#define SAY_YES cout<<"YES"<<endl;
#define SAY_Yes cout<<"Yes"<<endl;
#define SAY_NO cout<<"NO"<<endl;
#define SAY_No cout<<"No"<<endl;
#define IFYES(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;} 
#define IFYes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;} 
#define IFyes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"yes"<<endl;}else{cout<<"no"<<endl;} 

const long long int mod=1000000007;
const long long int INF=99999999999999999;




long long int N,M,K,S,P[2000],tmp,x=-1,y=-1,z=-1;


vector<long long int>Q;
int main() {
	cout << fixed << setprecision(18);
    cin>>K>>S;
    for(int i=0;i*10000<=S;i++){
        for(int j=0;i*10000+j*5000<=S;j++){
            if(i+j+(S-(i*10000+j*5000) )/1000==K ){
                x=i;
                y=j;
                z=(S-(i*10000+j*5000) )/1000;
            }
        }
    }
    cout<<x<<" "<<y<<" "<<z<<endl;
    
} 


Measured memory_bytes: 256
import fractions

N,start = map(int, input().split())

a = list(map(int, input().split()))
a = list(map(lambda x: abs(x-start),a))
a.sort()
D = a[0]

for i in range(1,len(a)):
  diff = a[i] - a[i-1]
  D = fractions.gcd(diff, D)

  if D == 1:
    print('1')
    exit()

print(D)


Measured memory_bytes: 89748
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

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

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



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

	cin >> a >> b >> c >> k;
	vector<int> data(3);

	data[0] = a;
	data[1] = b;
	data[2] = c;

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

	rep(i, 0, k) {
		data[2] *= 2;
	}

	int ans = 0;

	rep(i, 0, 3) {
		ans += data[i];
	}
	
	cout << ans << endl;
	
	

}
	

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

int mp[555][555];
int seica[555][555];
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
int dir;

int main(){
	REP(i,555)REP(j,555)mp[i][j] = -1;
	int h,w;cin >> h >> w;
	REP(i,h){
		REP(j,w){
			cin >> mp[i+1][j+1];
		}
	}
	int x = 1,y = 1;
	vector<pair<pair<int,int>,pair<int,int>>> ans;
	REP(i,h*w-1){
		if(mp[y+dy[dir]][x+dx[dir]] == -1)dir = (dir+1)%4;
		if(mp[y][x] % 2 == 1){
			ans.PB(MP(MP(y,x),MP(y+dy[dir],x+dx[dir])));
			mp[y][x]--;
			mp[y+dy[dir]][x+dx[dir]]++;
		}
		seica[y][x] = mp[y][x];
		seica[y+dy[dir]][x+dx[dir]] = mp[y+dy[dir]][x+dx[dir]];
		mp[y][x] = -1;
		y += dy[dir];
		x += dx[dir];
	}
	
	cout << ans.size() << endl;
	REP(i,ans.size()){
		cout << ans[i].FI.FI << ' ' << ans[i].FI.SE << ' ' << ans[i].SE.FI << ' ' << ans[i].SE.SE << endl;
	}
	
	/*
	REP(i,h){
		REP(j,w){
			cout << seica[i+1][j+1] << ' ';
		}
		cout << endl;
	}
	*/
	
	return 0;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repm(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    int a, b;
    cin >> a >> b;

    //true -> pos, false -> neg
    //bool sign = true;

    if ((a <= 0 && 0 <= b))
    {
        cout << "Zero" << endl;
    }
    else if (0 < a || (abs(b) - abs(a) + 1) % 2 == 0)
    {
        cout << "Positive" << endl;
    }
    else
        cout << "Negative" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}

signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int x[5];
    rep(i,5)cin>>x[i];
    rep(i,5){
        if(x[i]==0){
            cout<<i+1<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define what_is(x) cerr<<#x <<" is "<<x<<endl;
#define ll long long 
#define gcd(a,b) __gcd(a,b)
#define pi 2*acos(0.0)
//use emplace_back() instead of push_back()
template<typename T>
void print(T t)
{
	for(const auto& e:t)cout<<e<<" ";
	cout<<endl;
}
ll nod(ll n) 
{ 
    return floor(log10(n) + 1); 
} 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,d1,d2,f=1;
	cin>>n;
	ll ans=0;
	ll cnt=0;
	for(ll i=0;i<n;i++)
	{
		cin>>d1>>d2;
		if(d1==d2)cnt++;
		else
		cnt=0;
		ans=max(ans,cnt);
	}
	if(ans>=3)cout<<"Yes\n";
	else
	cout<<"No\n";	
	return 0;
}


Measured memory_bytes: 3632
N, M = map(int, input().split())
H = list(map(int, input().split()))

t = [0] * N

for _ in range(M):
    A, B = map(int, input().split())
    t[A-1] = max(t[A-1], H[B-1])
    t[B-1] = max(t[B-1], H[A-1])

result = 0
for i in range(N):
    if H[i] > t[i]:
        result += 1
print(result)



Measured memory_bytes: 20116
#include <iostream>
#include <vector>
#include <boost/foreach.hpp>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
  vector<int>a(n);
  for(int i=0; i<n; i++)  cin >> a[i];
  sort(a.begin(), a.end());
  for(int i=0; i<n-1; i++){
    if(a[i]==a[i+1]){
      cout << "NO" << endl;
      exit(0);
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>

using namespace std;
 
int main(){
	double a, b, c, d, e, f ;
	double x, y;

	while(cin >>a >> b >> c >> d >> e >> f ){
		x = (c*e - b*f)/(a*e - b*d);
		y = (c*d - a*f)/(b*d - a*e);

		if(x==0) x=0;
		if(y==0) y=0;

		printf("%.3f %.3f\n", x, y);
	}
}



Measured memory_bytes: 3176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();

			if (op.equals("?"))
				break;

			int c = 0;

			switch (op) {
			case "+":
				c = a + b;
				break;
			case "-":
				c = a - b;
				break;
			case "*":
				c = a * b;
				break;
			case "/":
				c = a / b;
				break;
			}
			System.out.println(c);
		}
	}
}


Measured memory_bytes: 26180
#include <iostream>

using namespace std;

typedef long long ll;

int main() {
    ll x, y, z, w, n;
    cin >> x >> y >> z >> w >> n;
    ll l1 = min(4 * x, 2 * x + y);
    l1 = min(l1, min(2 * y, z));
    ll l2 = min(2 * l1, w);

    ll ans = 0;
    if (n >= 2){
        ans += l2 * (n / 2);
        n %= 2;
    }
    ans += l1 * n;

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

Measured memory_bytes: 256
n, y = map(int, input().split())
swi = 0

for a in range(y//10000 + 2):
    b = (y - 1000 * n - 9000 * a) // 4000
    c = n - a - b
    if a + b + c == n and 10000 * a + 5000 * b + 1000 * c == y and a >= 0 and b >= 0 and c >= 0:
        print(a, b, c)
        swi = 1
        break
if swi == 0:
    print(-1, -1, -1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define N 1000005
using namespace std;

typedef long long ll;

ll n, top1, top2, ans1, ans2, a;

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld",&n);
	for(int i = 1; i <= n; i++){
		scanf("%lld",&a);
		top1 += a;
		top2 += a;
		if(top1 == 0 or (i%2)^(top1 > 0) ){
			ans1 += (top1 > 0)?top1+1:-top1+1;
			top1 = (i%2 == 0)?-1:1;
		}

		if(top2 == 0 or (i%2 == 0)^(top2 > 0) ){
			ans2 += (top2 > 0)?top2+1:-top2+1;
			top2 = (i%2 == 1)?-1:1;
		}
	}
	printf("%lld\n", min(ans1, ans2));
	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        new Main();
    }
    Scanner in = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);

    int h, w, n;
    int[] a;
    int[][] grid;

    Main() {
        h = in.nextInt();
        w = in.nextInt();
        n = in.nextInt();
        a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = in.nextInt();
        
        int at = 0;
        grid = new int[h][w];
        for (int i = 0; i < h; i++) {
            boolean dir = i%2 == 0;
            for (int j = 0; j < w; j++) {
                if (dir)
                    grid[i][j] = at+1;
                else
                    grid[i][w-j-1] = at+1;
                a[at]--;
                if (a[at] == 0)
                    at++;
            }
        }

        for (int[] row : grid) {
            for (int cell : row)
                out.print(cell+" ");
            out.println();
        }
        out.close();
    }
}

Measured memory_bytes: 29980
n=int(input())
vector1=[int(x) for x in input().split()]
vector2=[int(x) for x in input().split()]
for i in range(1,4):
    print("{0:.8f}".format(sum([abs(a-b)**i for a,b in zip(vector1,vector2)])**(1/i)))
print("{0:.8f}".format(max([abs(a-b) for a,b in zip(vector1,vector2)])))

Measured memory_bytes: 7796
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;

using namespace std;

int main(){
    string s;
    cin >> s;
    for (char c = 'a';c<='z';c++){
        int cnt=count(all(s),c);
        if (cnt==0) {
            cout << c << endl;
            return 0;
        }
        
    }
    cout << "None" << endl;
    
}

Measured memory_bytes: 512
n=int(input())
a,b = map(int,input().split())
p = map(int,input().split())



list1 = []
list2 = []
list3 = []

for i in p:
    if i<=a:
        list1.append(i)
    elif i<=b:
        list2.append(i)
    else:
        list3.append(i)


if len(list1)>=len(list2):
    if len(list2)>=len(list3):
        print(len(list3))
    else:
        print(len(list2))
else:
    if len(list1)>=len(list3):
        print(len(list3))
    else:
        print(len(list1))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

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

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);

	if(a%b == 0)return(b);

	else return(gcd(b, a%b));
}

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

    ll l, r;
    l = r = 1;
    rep(i, n){
        ll t, a;
        cin >> t >> a;

        if(t >= l && a >= r){
            l = t, r = a;
        }
        else {
            ll t_m = l / t;
            ll a_m = r / a;
            
            if(l % t > 0)t_m++; 
            if(r % a > 0)a_m++; 

            ll max_m = max(t_m, a_m);

            l = t * max_m, r = a * max_m;
        }
    }
    cout << l + r << endl;
}

Measured memory_bytes: 3604