akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <sstream>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>

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

class Calc {
    ll a;
    vector<pair<ll, ll>> primes;

  public:
    vector<pair<ll, ll>> decompositPrime(ll n) {
        ll prev = 0;
        a = 2;
        while (n >= a * a) {
            if (n % a == 0) {
                if (prev != a) {
                    primes.push_back(make_pair(a, 1));
                    prev = a;
                } else {
                    primes[primes.size() - 1].second++;
                }
                n /= a;
            } else {
                a++;
            }
        }
        if (prev != n) {
            primes.push_back(make_pair(n, 1));
        } else {
            primes[primes.size() - 1].second++;
        }
        return primes;
    }
};

// 1,2 -> 1
// 3,4,5 -> 2
// 6,7,8,9 -> 3
// 10,11,12,13,14 -> 4
// 15,... -> 5

int main() {
    ios::sync_with_stdio(false);

    ll n;
    cin >> n;

    if (n == 1ll) {
        cout << 0 << endl;
        return 0;
    }

    Calc c;
    vector<pair<ll, ll>> primes = c.decompositPrime(n);

    const int N = 100;
    vector<int> dp(N * (N + 1) / 2);
    int base = 1;
    for (int limit = 2; limit < N; limit++) {
        for (int i = 0; i < limit; i++) {
            dp[base + i] = limit - 1;
        }
        base += limit;
    }
    // for (int i = 0; i < 20; i++) {
    //     printf("%d->%d\n", i, dp[i]);
    // }

    ll ans = 0;
    for (auto p : primes) {
        // printf("%lld^%lld *", p.first, p.second);
        ans += dp[p.second];
    }

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


Measured memory_bytes: 3212
#include<stdio.h>

int main()
{
	int N,i;
	int s[100005]={0};
	while(scanf("%d",&N)!=EOF)
	{
		int q=0;
		int t=0;
		for(i=1;i<=N;i++)
		{
			scanf("%d",&s[i]);
		}
		
		for(i=1;i<=N;i++)
		{
			if(s[i]==i)
			{
				int x;
				x=s[i];
				s[i]=s[i+1];
				s[i+1]=x;
				t++;
			}
		}
		if(s[N]==N) t++;
		printf("%d\n",t);
	}
	
}

Measured memory_bytes: 512
<?php
$ac = 0;
$wa = 0;
$tle = 0;
$re = 0;

$num = trim(fgets(STDIN));

for($i=0; $i<$num; $i++){
    $text = trim(fgets(STDIN));
    if($text == "AC"){
        $ac += 1;
    }elseif($text == "WA"){
        $wa += 1;
    }elseif($text == "TLE"){
        $tle += 1;
    }else{
        $re += 1;
    }
}

echo "AC x ".$ac."\n";
echo "WA x ".$wa."\n";
echo "TLE x ".$tle."\n";
echo "RE x ".$re."\n";
?>

Measured memory_bytes: 15936
import math
X = int(input())

def is_prime(x):
    if x < 2:
        return False
    for i in range(2,int(math.sqrt(x)+1)):
        if x % i == 0:
            return False
    return True

def check(X):
    for i in range(X,10**100):
        if is_prime(i):
            return i
    
print(check(X))


Measured memory_bytes: 3064
using System;
using System.IO;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(Solve());
        Console.Out.Flush();
    }

    static object Solve() {
        var s = Console.ReadLine();
        var len = s.Length;
        var isScanning = false;
        var start = 0;
        var result = -1;
        for (int i = 0; i < len; i++) {
            if (s[i] == 'A' && !isScanning) {
                isScanning = true;
                start = i;
            }
            if (s[i] == 'Z' && start != -1) {
                result = Math.Max(result, i - start + 1);
            }
        }
        return result;
    }
}

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

int Partition(std::vector<int>& List, int p, int r);

int Partition(std::vector<int>& List, int p, int r)
{
    int x = List[r];
    int i = p - 1;
    int Temp;
    
    for(int j = p; j < r; j++){
        if(List[j] <= x){
            i++;
            Temp    = List[i];
            List[i] = List[j];
            List[j] = Temp;
        }
    }
    Temp    = List[i + 1];
    List[i + 1] = List[r];
    List[r] = Temp;
    
    return i + 1;
}

int main(void){
    int Num, Temp, q;
    std::cin >> Num;
    
    std::vector<int> List;
    List.clear();
    for(int i = 0; i < Num; i++){
        std::cin >> Temp;
        List.push_back(Temp);
    }
    
    q = Partition(List, 0, List.size() - 1);
    
    for(int i = 0; i < List.size(); i++){
        if(i > 0)   std::cout << " ";
        
        if(i == q){
            std::cout << "[" << List[i] << "]";
        } else{
            std::cout << List[i];
        }
    }
    std::cout << std::endl;
}

Measured memory_bytes: 3344
#include <iostream>
#include <string>

int main()
{
	std::string str;
	std::cin >> str;

	int n = 26;
	int a[ n ] = { 0 };

	for( int i = 0; i < str.size(); i++ ) {
		int idx = str[ i ] - 'a';
		a[ idx ] += 1;
	}

	int minidx = -1;
	for( int i = 0; i < n; i++ ) {
		if( a[ i ] == 0 ) {
			minidx = i;
			break;
		}
	}

	if( minidx < 0 ) {
		std::cout << "None" << std::endl;
	}
	else {
		std::cout << (char)( 'a' + minidx ) << std::endl;
	}
	return 0;
}




Measured memory_bytes: 512
#include <stdio.h>

int main(void){
	int ans,a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	ans = a+b;
	if(b+c<ans)ans=b+c;
	if(c+a<ans)ans=c+a;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n;
	cin>>n;
	vvi in(n,vi(4));
	rep(i,n)rep(j,4)cin>>in[i][j];
	vi x,y;
	rep(i,n)rep(j,4)if(j%2)y.pb(in[i][j]);
					else x.pb(in[i][j]);
	sort(all(x));sort(all(y));
	x.erase(unique(all(x)),x.end());
	y.erase(unique(all(y)),y.end());
	
	vvi tmp=in;
	rep(i,n)rep(j,4)if(j%2)tmp[i][j]=lower_bound(all(y),tmp[i][j])-y.begin();
					else tmp[i][j]=lower_bound(all(x),tmp[i][j])-x.begin();
	vvi field(x.size(),vi(y.size()));

	rep(i,n){
		field[tmp[i][0]][tmp[i][1]]++;
		field[tmp[i][2]][tmp[i][1]]--;
		field[tmp[i][0]][tmp[i][3]]--;
		field[tmp[i][2]][tmp[i][3]]++;
	}
	rep(i,x.size())loop(j,1,y.size())field[i][j]+=field[i][j-1];
	rep(j,y.size())loop(i,1,x.size())field[i][j]+=field[i-1][j];
	
	//loop(j,tmp[i][0],tmp[i][2])loop(k,tmp[i][1],tmp[i][3])

	ll out=0;
	rep(i,x.size())rep(j,y.size())if(field[i][j])
		out+=(ll)(x[i+1]-x[i])*(y[j+1]-y[j]);
	cout<<out<<endl;
}

Measured memory_bytes: 65728
N, Y = list(map(int, input().split()))
c = 0
for i in range(N+1):
    for j in range(N-i+1):
        if 10000 * i + 5000 * j + 1000 * (N-i-j) == Y:
            print(i, j, (N-i-j))
            c = 1
            break
    if c == 1:
        break
if c == 0:
    print(-1, -1, -1)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
    using namespace std;
    int main(){
    cin.tie(NULL);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    if(s.find("AC")<=s.size()) cout<<"Yes"<<'\n';
    else cout<<"No"<<'\n';
    return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

i64 S;

void solve(){
  pair<i64,i64> ans = {S,1};
  rep(i,1,S){
    if(i * (i - 1) / 2 > S) break;
    i64 a = (2 * S - i * i + i) / 2 / i;
    if((a * 2 + i - 1) * i == S * 2 && a > 0){
      ans = {a,i};
    }
  }

  cout << ans.first << " " << ans.second << endl;
}

int main(){
  while(cin >> S , S){
    solve();
  }
}



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

long long n;
long long a[60] = {0};
long long now = 0, num = 0, p = 0, cnt = 0;
long long ans[2][120] = {0};

void solve();

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    a[i] = x;
    if(abs(num) <= abs(x)) {
      num = x;
      p = i;
    }
  }
  solve();
  cout << cnt << endl;
  for(int i = 0; i < cnt; ++i) {
    cout << ans[0][i] + 1 << " " << ans[1][i] + 1 << endl;
  }
  return 0;
}

void solve() {
  if(num == 0) return;
  for(int i = 0; i < n; ++i) {
    if(a[i] == num)
      continue;
    else if((i == 0 && a[i] == -num && num > 0) ||
            (i == n - 1 && a[i] == -num && num < 0)) {
      ans[0][cnt] = p;
      ans[1][cnt] = i;
      ++cnt;
      a[i] += num;
    }
    ans[0][cnt] = p;
    ans[1][cnt] = i;
    ++cnt;
    a[i] += num;
  }
  if(num > 0) {
    now = 0;
    while(now < n - 1) {
      if(a[now] > a[now + 1]) {
        ans[0][cnt] = now;
        ans[1][cnt] = now + 1;
        ++cnt;
        a[now + 1] += a[now];
      }
      ++now;
    }
  }
  else {
    now = n - 1;
    while(now > 0) {
      if(a[now] < a[now - 1]) {
        ans[0][cnt] = now;
        ans[1][cnt] = now - 1;
        ++cnt;
        a[now - 1] += a[now];
      }
      --now;
    }
  }
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int,P> PP;
struct edge { int to; int cost; };
int dp[1005][1005];
int kj[1006], kji[1006];
int modpow(int x, int n, int md) {
	if (!n)return 1;
	int res = modpow(x*x%md, n / 2, md);
	if (n & 1)res = res*x%mod;
	return res;
}
int comb(int r, int c) {
	if (r < c || c < 0)return 0;
	return kj[r] * kji[c] % mod*kji[r - c] % mod;
}
signed main() {
	kj[0] = 1;
	for (int i = 1; i <= 1001; i++)kj[i] = kj[i - 1] * i%mod;
	rep(i, 1001)kji[i] = modpow(kj[i], mod - 2, mod);
	int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
	dp[0][0] = 1;
	for (int I = 0; I <= b - a; I++) {
		int i = I + a;
		rep(j, n+1) {
			dp[I + 1][j] += dp[I][j];
			dp[I + 1][j] %= mod;
			for (int k = c; k <= d; k++) {
				int t = i*k + j;
				if (t > n)break;
				dp[I + 1][t] += dp[I][j] * (kj[n-j]*kji[n-t]%mod*modpow(kji[i],k,mod)%mod*kji[k] % mod);
				dp[I + 1][t] %= mod;
			}
		}
	}
	cout << dp[b - a + 1][n] << endl;
/*	rep(i, b - a + 2) {
		rep(j, n + 1) {
			cout << dp[i][j] << ' ';
		}cout << endl;
	}*/
}

Measured memory_bytes: 8064
#include <stdio.h>

int main(void){

  int n,a,b,c,x;
  int i;
  int y[100];

  for(;;){
    scanf("%d %d %d %d %d",&n,&a,&b,&c,&x);
    if(n==0&&a==0&&b==0&&c==0&&x==0)break;

    int rand = x,hit = 0;

    for(i=0;i<n;i++)scanf("%d",&y[i]);

    int j=0;

    for(i=0;i<=10000;i++){
      if(y[j]==rand){
	hit++;
	j++;
      }
      if(hit==n){
	hit = -1;
	break;
      }
      rand = (a*rand+b)%c;
    }
    
    if(hit==-1)printf("%d\n",i);
    else printf("-1\n");    
  } 
  

  return 0;
}

Measured memory_bytes: 612
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    N = NI()
    Ps = [NLI() for _ in range(N)]
    Px = [x+y for x, y in Ps]
    Py = [x-y for x, y in Ps]
    print(max(max(Px) - min(Px), max(Py) - min(Py)))


if __name__ == "__main__":
    main()

Measured memory_bytes: 61636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;


int main(void){
    Cin(int, m, k);
    int n = (1 << m);
    
    if(m == 0){
        if(k == 0){
            Cout("0 0");
        }
        else{
            Cout(-1);
        }
    }
    else if(m == 1){
        if(k == 0){
            Cout("0 0 1 1");
        }
        else{
            Cout(-1);
        }
    }
    else if(k < n){
        For(i, n) if(i != k) cout << i << " ";
        cout << k << " ";
        for(int i = n-1; i >= 0; i --) if(i != k) cout << i << " ";
        cout << k << " ";
    }
    else{
        Cout(-1);
    }
}



Measured memory_bytes: 1792
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N, M = LI()

if N >= 2:
    nn = combinations_count(N , 2)
else:
    nn = 0

if M >= 2:
    mm = combinations_count(M , 2)
else:
    mm = 0

print(nn + mm)

Measured memory_bytes: 38256
// B - Box and Ball

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int x[100000];
int y[100000];
int b[100000];
bool p[100000];

int main() {
	int N, M;
	cin >> N >> M;

	for (int i=0; i<M; i++) {
		cin >> x[i] >> y[i];
		x[i]--;
		y[i]--;
	}

	for (int i=0; i<N; i++) {
		b[i] = 1;
	}

	p[0] = true;

	for (int i=0; i<M; i++) {
		b[x[i]]--;
		b[y[i]]++;

		if (p[x[i]]) {
			p[y[i]] = true;
			if (b[x[i]] == 0) p[x[i]] = false;
		}
	}

	int ans = 0;
	for (int i=0; i<N; i++) {
		if (p[i]) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4828
N = int(input())
Hlist = list(map(int,input().split()))

n = 0
A = 0

for i in range(N-1):
    if Hlist[i] >= Hlist[i+1]:
        n += 1
    else:
        A = max(A, n)
        n = 0
A = max(A, n)

print(A)

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

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long x, y;
    cin >> x >> y;
    long long res = 0;
    long long mul = 1;
    while (x * mul <= y) {
        res++;
        mul *= 2;
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[])
{
	int H, W;
	int a = 1;
	int tmp = 0;

	while (1)
	{
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0)
		{
			break;
		}
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				if (i % 2 == 0 && j % 2 == 0)
				{
					printf("#");
				}
				else if (i % 2 == 1 && j % 2 == 0)
				{
					printf(".");
				}
				else if (i % 2 == 0 && j % 2 == 1)
				{
					printf(".");
				}
				else if (i % 2 == 1 && j % 2 == 1)
				{
					printf("#");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}



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

int main()
{
	int n;
	cin >> n;
	std::vector<int> l(n + 1), r(n + 1);
	for (int i = 1; i <= n; ++i)
	{
		cin >> l[i] >> r[i];
	}
	int counter = 0;
	for (int i = 1; i <= n; ++i)
	{
		counter += r[i] - l[i] + 1;
	}
	cout << counter << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main() {
	int n, m, k;
	queue<int> card;
	cin >> n >> m;
	for (int i = 1; i <= n * 2; ++i) {
		card.push(i);
	}

	while (m--) {
		cin >> k;
		if (k > 0) {
			while (k--) {
				card.push(card.front());
				card.pop();
			}
		}
		else {
			queue<int> temp[2];
			for (int i = 0; i < 2; ++i) {
				for (int j = 0; j < n; ++j) {
					temp[i].push(card.front());
					card.pop();
				}
			}
			for (int i = 0; i < n; ++i) {
				for (int j = 0; j < 2; ++j) {
					card.push(temp[j].front());
					temp[j].pop();
				}
			}
		}
	}
	for (int i = 0; i < n * 2; ++i) {
		cout << card.front() << endl;
		card.pop();
	}

	return 0;
}

Measured memory_bytes: 3108
#!/usr/bin/env python
N, M = map(int, input().split())
C = [[int(i) for i in input().split()] for i in range(N)]
ans = 0
for i in [-1, 1]:
    for j in [-1, 1]:
        for k in [-1, 1]:
            s = []
            for x, y, z in C:
                s.append(i*x+j*y+k*z)
            s.sort(reverse=True)
            ans = max(ans, sum(s[:M]))
print(ans)

Measured memory_bytes: 3292
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_B

#include <iostream>
#include <iomanip>

#include <vector>
#include <string>
#include <iterator>
#include <algorithm>
#include <queue>

typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

using namespace std;

// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template<class T> void output(std::vector<T> & A) {
    const int n = A.size();
    for (int i = 0; i < n - 1; ++i) {
        std::cout << A[i] << " ";
    }
    std::cout << A[n - 1] << std::endl;
}

const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;
vector<vector<int>> M;
vector<int> colour, d;
int tt = 0;
queue<int> que;

void bfs(int u) {
    que.push(u);
    colour[u] = GRAY;

    while (!que.empty()) {
        const int v = que.front(); que.pop();
        for (int s : M[v]) {
            if (colour[s] == WHITE) {
                que.push(s);
                d[s] = d[v] + 1;
                colour[s] = GRAY;
            }
        }
        colour[v] = BLACK;
    }
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout << std::fixed << std::setprecision(15);

    // populate M
    int n; cin >> n;
    M = vector<vector<int>>(n);
    colour = vector<int>(n, 0);
    d = vector<int>(n, -1);

    rep(i, n) {
        int from; cin >> from; --from;
        int m; cin >> m;
        rep(j, m) {
            int to; cin >> to; --to;
            M[from].push_back(to);
            // M[to].push_back(from);
        }
    }

    // bfs
    d[0] = 0;
    bfs(0);

    rep(i, n) {
        cout << (i + 1) << " " << d[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3176
using System;
    using System.Text;
    using System.Linq;
    using System.Collections;
    using System.Collections.Generic;
    using static System.Console;
    using static System.Math;
     
    namespace NotFounds
    {
        public class Program
        {
            public static void Main(string[] args)
            {
                var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
                Console.SetOut(sw);
                new Program().Solve(new ConsoleInput(Console.In, ' '));
                Console.Out.Flush();
            }
     
            public void Solve(ConsoleInput cin)
            {
                checked
                {
                    if (string.Join("", cin.Read.ToCharArray().OrderBy(x => x)) == "abc")
            	WriteLine("Yes");
	        else
		WriteLine("No");
                }
            }
        }
     
        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); }}
            public int ReadInt { get { return int.Parse(Read); }}
            public long ReadLong { get { return long.Parse(Read); }}
            public double ReadDouble { get { return double.Parse(Read); }}
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
            public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; }}
            public void ReadIntArrays(long N, out int[] A, out int[] B, out int[] C) { A = new int[N]; B = new int[N]; C = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; C[i] = ReadInt; }}
            public void ReadLongArrays(long N, out long[] A, out long[] B) { A = new long[N]; B = new long[N]; for (long i = 0; i < N; ++i) { A[i] = ReadLong; B[i] = ReadLong; }}
        }
    }

Measured memory_bytes: 13396
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            int iA = int.Parse(sS[1]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = iN / iA;
            if (iN % iA != 0) { iOut += 1; }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int h[10];
	for (int i = 0; i < 10; i++)
		cin >> h[i];
	sort(h, h+10, greater<int>());
	for (int i = 0; i < 3; i++)
		cout << h[i] << endl;
	return 0;
}

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

int n, a[100009], p[100009], q[100009], cnts;

int solve(vector<int>x) {
	if (x.size() == 0) return 0;
	int R = 0, S = 0;
	for (int i = 0; i < x.size(); i++) {
		if (x[i] == 2) S = 1;
		else {
			S++; if (S == 2) { R++; S = 0; }
		}
	}
	if (S >= 1) R++;
	return R;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i]; int s = a[i], t = 1;
		while (s > 1) { p[i]++; s /= 2; }
		while (t < a[i]) { q[i]++; t *= 2; }
	}
	for (int i = 1; i <= 30; i++) {
		vector<int>P;
		for (int j = 0; j <= n; j++) {
			if (j == n || q[j] < i) {
				cnts += solve(P); P.clear(); continue;
			}
			if (p[j] < i && q[j] >= i) P.push_back(1);
			else P.push_back(2);
		}
	}
	cout << cnts << endl;
	return 0;
}

Measured memory_bytes: 2376
#include<iostream>
#include<stdio.h>
#include<vector>
#include<ctype.h>
#include<string>
#include<cmath>
#include<string.h>
#include<sstream>
#include<limits.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;

//最大公約数
int gcd(int a,int b){
    return b ? gcd(b,a%b):a;
}

//最小公倍数
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}

//素数判定
bool isPrime(int x){
    if(x<2)return 0;
    else if(x==2)return 1;
    if(x%2==0)return 0;
    for(int i=3;i*i<=x;i+=2){
        if(x%i==0)return 0;
    }
    return 1;
}

//桁ごとの足し算
int digsum(int n){
    int res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}

//約数列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i=1;i*i<=n;++i){
        if(n%i==0){
            ret.push_back(i);
            if(i*i !=n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//累乗の計算とあまり,0で累乗そのまま出力
long long modpow(long long a,long long n,long long mod){
    if(mod==0)mod=__LONG_LONG_MAX__;
    long long res=1;
    while(n>0){
        if(n & 1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

// //指定文字の文字数カウント
// int stringcount(string s,char c){
//     return count(s.cbegin(),s.cend(),c);
// }

int N,K;
vi fruits;

int main(){
    cin>>N>>K;
    fruits.resize(N);
    for(int i=0;i<N;++i){
        cin>>fruits[i];
    }
    for(int i=0;i<N;++i){
        for(int j=N-1;j>i;--j){
            if(fruits[j]<fruits[j-1]){
                int buf = fruits[j];
                fruits[j]=fruits[j-1];
                fruits[j-1]=buf;
            }
        }
    }
    int ans=0;
    for(int i=0;i<K;++i){
        ans+=fruits[i];
    }
    cout<<ans<<endl;
    return 0;
}

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

#define abs (x)(x>0?x:-x)


int main()
{
	int N, D;

	scanf("%d%d", &N, &D);

	printf("%d", (int)((double)(N / (D * 2.0 + 1.0))+0.999999));

}

Measured memory_bytes: 128
MOD = 10 ** 9 + 7
l = input()
n = len(l)
dp1 = [0] * (n + 1)
dp2 = [0] * (n + 1)
dp2[0] = 1
for i in range(n):
    if l[i] == '0':
        dp2[i + 1] += dp2[i]
    else:
        dp1[i + 1] += dp2[i]
        dp2[i + 1] += dp2[i] * 2
    dp1[i + 1] += dp1[i] * 3
    dp1[i + 1] %= MOD
    dp2[i + 1] %= MOD
print((dp1[n] + dp2[n]) % MOD)


Measured memory_bytes: 11128
#include <cstdio>
#include <unordered_map>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <cmath>

using namespace std;

typedef long long LL;

int w, h;
LL p[100005], q[100005];
LL preQ[100005];

int main() {
  LL ans = 0;
  scanf("%d%d", &w, &h);
  for (int i = 0; i < w; i += 1) {
    scanf("%lld", &p[i]);
  }
  for (int i = 0; i < h; i += 1) {
    scanf("%lld", &q[i]);
    ans += q[i];
  }
  sort(q, q + h);
  preQ[0] = q[0];
  for (int i = 1; i < h; i += 1) {
    preQ[i] = preQ[i - 1] + q[i];
  }
  for (int i = 0; i < w; i += 1) {
    int x = lower_bound(q, q + h, p[i]) - q;
    if (x > 0) ans += preQ[x - 1];
    ans += 1LL * (h - x + 1) * p[i];
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 2560
import math

def A():
    a, b = [int(x) for x in input().split()]
    print(math.ceil((a + b)/2))

def B():
    a = ''.join(sorted(list(input()), key=lambda x:ord(x)))
    b = ''.join(sorted(list(input()), key=lambda x:-ord(x)))
    if a < b:
        print('Yes')
    else:
        print('No')

B()


Measured memory_bytes: 3060
N, K = map(int, input().split())

L = [0] * K
R = [0] * K
for i in range(0, K):
    L[i], R[i] = map(int, input().split())

moves = [0] * N
moves[0] = 1

rui_wa = [0] * N
rui_wa[0] = 1

for i in range(1, N):
    for j in range(0, K):
        l = max(i - L[j], 0)
        r = max(i - R[j], 0)
        if i - L[j] < 0:
            continue

        moves[i] += (rui_wa[l] - rui_wa[r - 1]) % 998244353

    rui_wa[i] = (moves[i] + rui_wa[i - 1])  % 998244353



print(moves[N - 1] % 998244353)


Measured memory_bytes: 26824
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
    ll n;
    while (cin >> n) {
        if (n == 0) {
            break;
        } else {
            double mean = 0;
            vector <double> v(n);
            rep(i, n) {
                cin >> v.at(i);
                mean += v.at(i);
            }
            mean /= (double)n;
            ll res = 0;
            rep(i, n) {
                if (v.at(i) <= mean) res++;
            }
            cout << res << endl;
        }
    }
}


Measured memory_bytes: 3312
#include <iostream>
#include<string>
#include <cstdio>
#include <math.h>
using namespace std;
int main(void){
    int n;
  	int x;
    scanf("%d", &n);
  	
  	for(int i = 1; i <= 50000; i++){
    	x = i * 1.08;
    	if(x == n) {
    		printf("%d",i);
    		break;
    	}
    
    	if(i == 50000){
    		printf(":(");
    	}
    }
  	
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

long long int N,M;
int C[100005];
long long int L[200005], R[200005], D[200005];

long long int dis[100005];

vector<pair<long long int,long long int> > Adj[100005];

bool flag = 1;

void visit(long long int k, long long int d) {

	//cout << "k= " << k << " d= "<< d <<endl;
	if (C[k] == 0) {  //最初に訪れる
		dis[k] = d; C[k] = 1;

		for (int h = 0; h<int(Adj[k].size()); h++) {
			long long int K = Adj[k][h].first;
			long long int distance = Adj[k][h].second;// cout << "distance= " << distance << endl;
			visit(K, d + distance);
		}
	
	}
	else { //以前に訪れたことがある
		if (d != dis[k]) { flag = 0;   return; }// 不合理
	}

	//cout << "通過" << endl;
}


int main(void) {

	cin >> N>>M;
	long long int tmp;
	for (int i = 1; i <= M; i++) {
		cin >> tmp;
		L[i] = tmp;
		cin >> tmp;
		R[i] = tmp;
		cin >> tmp;
		D[i] = tmp;
	}

	for (int m = 1; m <= M; m++) {
		Adj[L[m]].push_back(pair<long long int, long long int >(R[m], D[m]));
		Adj[R[m]].push_back(pair<long long int, long long int >(L[m], -D[m]));
	}

	for (int i = 1; i <= N; i++) {
		if (C[i] == 0) {
			visit(i, 0);
		}
	}

	for (int i = 1; i <= N; i++) {
	//	cout << "dis[" << i << "]= " << dis[i] << endl;
	}

	for (int i = 1; i <= N; i++) {
		//cout << "Adj[" << i << "].size()= " << Adj[i].size() << endl;
	}

	if (flag == 0) { cout << "No" << endl; }
	else { cout << "Yes" << endl; }

	//system("pause");
	return 0;
};

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

const long long MOD = 1000000007;

int main() {
  long long N, K;
  cin >> N >> K;

  long long res = 0;
  for (long long i = K; i <= N + 1; i++) {
    long long minv = i * (i - 1) / 2;
    long long maxv = (N * 2 - i + 1) * i / 2;
    long long num = maxv - minv + 1;
    res = (res + num) % MOD;
  }

  cout << res << endl;
}

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

int main() {
  int N;
  long K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0, a; cin >> a; i++) A.at(i) = --a;
  int now = 0;
  while (K) {
    if (K % 2) now = A.at(now);
    vector<int> tmp(N);
    for (int i = 0; i < N; i++) tmp.at(i) = A.at(A.at(i));
    A = tmp;
    K /= 2;
  }
  cout << now + 1 << endl;
}

Measured memory_bytes: 4840
def main():
    D = int(input())
    c = list(map(int,input().split()))
    s = []
    for d in range(D):
        s.append(list(map(int,input().split())))
    
    last = [0 for i in range(26)]
    
    for d in range(D):
        tmp_score = [0 for i in range(26)]
        for I in range(26):
            tmp_last = last
            v = s[d][I]
            tmp_last[I] = d+1
            for i in range(26):
                v -= c[i]*(d+1-tmp_last[i])
            tmp_score[I] = v
        ans_i = tmp_score.index(max(tmp_score))
        print(ans_i+1)
        tmp_last[ans_i] = d+1
    
if __name__ == '__main__':
    main()

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

using namespace std;

int main(){
  string s, t;
  
  cin >> s;
  
  if ( s.length() == 2 ){
    cout << s << endl;
  }else {
    cout << s.at( 2 ) << s.at( 1 ) << s.at( 0 ) << endl;
  }
  //cout << ans << endl;

  
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        Boolean[] s = new Boolean[n];
        Arrays.fill(s, false);
        for (int i = 0; i < k; i++) {
            int d = Integer.parseInt(sc.next());
            for (int j = 0; j < d; j++) {
                int a = Integer.parseInt(sc.next()) - 1;
                s[a] = true;
            }
        }
        int c = 0;
        for (int i = 0; i < n; i++) {
            if (!s[i]) {
                c++;
            }
        }
        System.out.println(c);
    }
}

Measured memory_bytes: 41524
sum=0
dic={}
n=int(input())
lis=input()
lis=lis.split(' ')
def con(a,b):
    if b in dic:
        dic[b]=dic[b]+dic[a]
    else:
        dic[b]=dic[a]
    del dic[a]
for i in lis:
    sum=sum+int(i)
    if int(i) in dic:
        dic[int(i)]=dic[int(i)]+1
    else:
        dic[int(i)]=1
#print(dic)
#print(sum)
q=int(input())
for i in range(0,q):
    que=input()
    que=que.split()
    que[0]=int(que[0])
    que[1]=int(que[1])
    if que[0] in dic:
        if que[0]>que[1]:
            sum=sum-(que[0]-que[1])*dic[que[0]]
            con(que[0],que[1])
        else:
            sum=sum+(que[1]-que[0])*dic[que[0]]
            con(que[0],que[1])
    print(sum)
        


Measured memory_bytes: 23640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

void solve(long long A, long long B){
    cout << A*B << endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3688
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a <= 8 && b <= 8)
		cout << "Yay!" << "\n";
	else
		cout << ":(" << "\n";
}

Measured memory_bytes: 3560
n,l = map(int, input().split())

score = [l+i-1 for i in range(1,n+1)]

total = sum(score)


ans = 9999999999
for i in range(n):
  temp = score[i]
  score[i] = 0
  culTotal = sum(score)  
  score[i] = temp
  diff = abs(total-culTotal)
  if ans > diff:
    ans = diff
    result = culTotal
  
print(result)


Measured memory_bytes: 3060
<?php
// 文字列S,T S->T 操作回数の最小値
// Sの１文字を選んで別の文字に書き換える
$s = str_split(trim(fgets(STDIN)));
$t = str_split(trim(fgets(STDIN)));
$counter = 0;
for ($i = 0; $i < count($s); $i++) {
    if ($s[$i] != $t[$i]) {
        $counter++;
    }
}
echo $counter;

Measured memory_bytes: 41280
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))


fact = [1] * (N + 1)
for n in range(1, N + 1):
    fact[n] = fact[n - 1] * n

def BIT_update(tree, x):
    while x <= N:
        tree[x] += 1
        x += x & (-x)

def BIT_sum(tree, x):
    s = 0
    while x:
        s += tree[x]
        x -= x & (-x)
    return s


tree = [0] * (N + 1)
ans1 = 0
for i, x in enumerate(P):
    rank = x - BIT_sum(tree, x)
    ans1 += fact[N - i - 1] * (rank - 1)
    BIT_update(tree, x)

tree = [0] * (N + 1)
ans2 = 0
for i, x in enumerate(Q):
    rank = x - BIT_sum(tree, x)
    ans2 += fact[N - i - 1] * (rank - 1)
    BIT_update(tree, x)
print(abs(ans1-ans2))


Measured memory_bytes: 3064
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): pass
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n, m = LI()
G = [[] for _ in range(n)]
for _ in range(m):
    a, b = LI()
    G[a-1]+=[b-1]



dp = [-1] * n

def f(x):
    if dp[x] != -1:
        return dp[x]
    ret = 0
    for y in G[x]:
        ret = max(f(y) + 1, ret)
    dp[x] = ret
    return ret

for i in range(n):
    f(i)

print(max(dp))


Measured memory_bytes: 128784
import java.util.Scanner;

class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        int P = sc.nextInt();

        if (P <= C) {
            if (P * A >= B) {
                System.out.println(B);
            } else {
                System.out.println(P * A);
            }
        } else {
            if (P * A >= B + (P - C) * D) {
                System.out.println(B + (P - C) * D);
            } else {
                System.out.println(A * P);
            }
        }
    }

}



Measured memory_bytes: 26236
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	/*int n, r;
	cin >> n >> r;
	int i;
	if (n >= 10)i = r;
	else i = r + 100 * (10 - n);
	cout << i;*/


	/*int n, k;
	cin >> n >> k;
	int ans = 0;
	while (n > 0) {
		n /= k;
		ans++;
	}
	cout << ans;*/


	int n;
	cin >> n;
	vector<int>x(n);
	rep(i, n)cin >> x[i];

	int ans = 1e9;
	for (int p = 1; p <= 100; p++) {
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += pow(x[i] - p, 2);
		}
		ans = min(ans, sum);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
main(){
	double p[8];
	while(~scanf("%lf %lf %lf %lf %lf %lf %lf %lf"
		//,p,p+8,&p[2],&p[3],&p[4],&p[5],&p[6],&p[7])){
		//,p,p+8,p+16,p+24,p+32,p+40,p+48,p+56)){
		,p,p+1,p+2,p+3,p+4,p+5,p+6,p+7)){
		//printf("%d - %d = %d\n",&p[1],&p[0],&p[1]-&p[0]);
		printf(!(p[0]> p[6] ||p[0] >p[7] || p[2]<p[4] ||p[3] <p[5])?"YES\n":"NO\n");
	}
	return 0;
}

Measured memory_bytes: 616
import math
n = int(input())
pi = math.pi
def distance(p1, p2):
  print(math.sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2))
  return math.sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2)

def koch(p1, p2):
  p3 = [0, 0]
  p4 = [0, 0]
  p5 = [0, 0]
  p3[0] = round((p1[0]*2 + p2[0]) / 3, 8)
  p3[1] = round((p1[1]*2 + p2[1]) / 3, 8)
  p4[0] = round((p1[0] + p2[0]*2) / 3, 8)
  p4[1] = round((p1[1] + p2[1]*2) / 3, 8)
  p5[0] = round((p4[0]-p3[0])*math.cos(pi/3)-(p4[1]-p3[1])*math.sin(pi/3)+p3[0], 8)
  p5[1] = round((p4[0]-p3[0])*math.sin(pi/3)+(p4[1]-p3[1])*math.cos(pi/3)+p3[1], 8)
  return p3, p4, p5

dots = [[0,0], [100,0]]
def loop(p1, p2, i):
  if i == n:
    return 

  p3, p4, p5= koch(p1, p2)
  dots.append(p3)
  dots.append(p4)
  dots.append(p5)
  loop(p1, p3, i+1)
  print(*p3) 
  loop(p3, p5, i+1)
  print(*p5)
  loop(p5, p4, i+1)
  print(*p4)
  loop(p4, p2, i+1)
  
print(0, 0)
loop([0,0], [100, 0], 0)
print(100, 0)






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

int main() {
  int n,ta=0,tb=0;
  cin >> n;
  int vec[n];
  for(int i=0;i<n;i++)
    cin >> vec[i];
  int max=vec[0],line[n];
  for(int t=0;t<n;t++){
    //maxを見つける
    for(int i=0;i<n;i++){
      if(max<vec[i])
        max=vec[i];
    }
    line[t]=max;
    //maxを取り除く
    for(int i=0;i<n;i++){
      if(max==vec[i]){
        vec[i]=0;
        break;
      }
    }
    max=0;
  }
  for(int i=0;i<n;i+=2)
    ta+=line[i];
  for(int i=1;i<n;i+=2)
    tb+=line[i];
  cout << ta-tb << endl;
}

   

Measured memory_bytes: 3552
n = int(input())
L = list(map(int, input().split()))

ans = 0
for i in range(n):
    for j in range(i,n):
        for k in range(j,n):
            if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                if L[i] < L[j] + L[k] and L[j] < L[k] + L[i] and L[k] < L[i] + L[j]:
                    ans += 1

print(ans)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 1000005


int main() {
    int kk[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int k;
    cin>>k;

    cout<<kk[k-1]<<"\n";

}


Measured memory_bytes: 256
// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort(all(x), greater<>())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
#define INF 1e9;
#define LINF 1e18;
template<class T>bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
// clang-format on

void solve(long long A, long long B, long long C, long long D) {
  ANS(max(min(B, D) - max(A, C), 0LL));
}

// clang-format off
int main() {
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  long long C;
  scanf("%lld",&C);
  long long D;
  scanf("%lld",&D);
  solve(A, B, C, D);
  return 0;
}


Measured memory_bytes: 256
casen=0
if casen==0:
    a=[]
    c=[]
    n=int(input())
    for i in range(n):
        ai,bi=map(int,input().split())
        a.append([ai,bi])
    for i in range(n):
        ci,di=map(int,input().split())
        c.append([ci,di])
elif casen==1:
    n=3
    a=[[2,0],[3,1],[1,3]]
    c=[[4,2],[0,4],[5,5]]
elif casen==2:
    n=3
    a=[[0,0],[1,1],[5,2]]
    c=[[2,3],[3,4],[4,5]]
elif casen==3:
    n=2
    a=[[2,2],[3,3]]
    c=[[0,0],[1,1]]
elif casen==4:
    n=5
    a=[[0,0],[7,3],[2,2],[4,8],[1,6]]
    c=[[8,5],[6,9],[5,4],[9,1],[3,7]]
elif casen==5:
    n=5
    a=[[0,0],[1,1],[5,5],[6,6],[7,7]]
    c=[[2,2],[3,3],[4,4],[8,8],[9,9]]

c.sort()
a.sort(key=lambda x:x[1])
#a.reverse()

icnt=0
ic2=0
for ic in range(len(c)):
    for ia in range(len(a)-1,-1,-1):
        if a[ia][0]<c[ic][0] and a[ia][1]<c[ic][1]:
            icnt=icnt+1
            del a[ia]
            break
        else:
            continue
        break

print(icnt)               

Measured memory_bytes: 3192
N,K = map(int,input().split())

box = [0] * (10**5)

for _ in range(N):
    a,b = map(int,input().split())
    box[a-1] += b

count = 0
for i in range(10**5):
    count += box[i]
    if count >= K:
        print(i+1)
        break


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

int main()
{
    int n;
    scanf("%d",&n);
    vector <int> a(n) ,frq(n);
    for(int&i : a)
        scanf("%d",&i) ,frq[i-1]++;

    sort(frq.begin() ,frq.end());
    vector <int> cfrq = frq;
    for(int i=1; i<n; i++)
        cfrq[i] += cfrq[i-1];

    vector <int> ans(n);
    for(int i=1; i<=n; i++){
        int j = upper_bound(frq.begin() ,frq.end() ,i)-frq.begin()-1;
        ans[cfrq[j]/i + n-j-2] = i;
    }

    for(int i=n-2; ~i; i--)
        ans[i] = max(ans[i] ,ans[i+1]);
    for(int i : ans)
        printf("%d\n",i);
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

int n;

int main()
{
  while((cin >> n) && n){
    int res = 0;
    int pw = 5;
    while(n >= pw){
      res += n / pw;
      pw *= 5;
    }
    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 1160