akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;
using ll = long long;
using tiii = tuple<ll, ll, ll>;

int main(){
	ios_base::sync_with_stdio(false);
	ll n, k;
	cin >> n >> k;
	if(2 * k > n + 1){
		cout << -1 << endl;
		return 0;
	}
	vector<ll> a(n), b(n);
	for(int i = 0; i < n; ++i){
		a[i] = k + i;
		b[i] = k + n + n - i - 1;
	}
	if(n % 2 == 1){
		const ll x = n / 2;
		for(ll i = 0; i < x / 2; ++i){ swap(a[i], a[x - 1 - i]); }
		const ll y = n - x;
		for(ll i = 0; i < y / 2; ++i){ swap(a[x + i], a[x + y - 1 - i]); }
	}else{
		const ll x = n / 2 - 1;
		for(ll i = 0; i < x / 2; ++i){ swap(a[i], a[x - 1 - i]); }
		const ll y = n / 2;
		for(ll i = 0; i < y / 2; ++i){ swap(a[x + i], a[x + y - 1 - i]); }
	}
	vector<tiii> solution(n);
	for(int i = 0; i < n; ++i){ solution[i] = tiii(a[i] + b[i], a[i], b[i]); }
	sort(solution.begin(), solution.end());
	for(int i = 0; i < n; ++i){
		cout << get<1>(solution[i]) << " " << get<2>(solution[i]) << " " << k + n + n + i << "\n";
	}
	return 0;
}



Measured memory_bytes: 6144
n, q = map(int, input().split())

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # 要素xが属するグループの根を返す
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    # 要素xが属するグループと要素yが属するグループとを併合する
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    # 要素xが属するグループのサイズ（要素数）を返す
    def size(self, x):
        return -self.parents[self.find(x)]

    # 要素x, yが同じグループに属するかどうかを返す
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    # 各要素の親要素の番号を格納するリスト
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    # グループの数を返す
    def group_count(self):
        return len(self.roots())

    # {ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


G = UnionFind(n)

for _ in range(q):
    com, x, y = map(int, input().split())

    if com == 0:
        G.union(x, y)
    else:
        print(int(G.same(x, y)))


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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll>   pairl;
typedef vector<ll>     vl;
typedef vector<ll>     vll;
typedef vector<vector<ll> > vvl;
const   int            infi = numeric_limits<int>::max();
const   ll             infl = numeric_limits<ll>::max();
const   double         eps = 0;
const   int            ms  = 0;


vector<vi> E;
vi vis;
vector<pair<int, int> > ed;
unordered_map<string, int> um;
int ei = 0;
void f(int i, int c){
    if(vis[i] == 1)return ;
    vis[i] = 1;
    int cc = 1;
    for(int j = 0; j < E[i].size(); j++){
        int to = E[i][j];
        if(vis[to] == 1)continue;
        if(cc == c)cc++;
        string s0 = to_string(i) + " " + to_string(to);
        string s1 = to_string(to) + " " + to_string(i);

        um[s0] = cc;
        um[s1] = cc;
        int a = ed[ei].first;
        int b = ed[ei].second;
        
        //debug(i)debug(E[i][j])debug(cc)
        f(E[i][j], cc);
        cc++;
    }
    return ;
}

int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    
    int N;
    cin >> N;
    
    E = vvi(N+1, vi(0));
    vis = vi(N+1, -1);
    int k = 0;
    rep(i, N-1){
        int a, b;
        cin >> a >> b;
        E[a].pb(b);
        E[b].pb(a);
        ed.pb({a, b});
    }

    rep(i, N){
        k = max(k, (int)E[i].size());
    }

    cout << k << endl;
    
    f(1, 0);
    rep(i, N-1){

        cout <<um[to_string(ed[i].first) + " " + to_string(ed[i].second)] <<endl;
    }

    return 0;
}

Measured memory_bytes: 31388
import sys
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

h, w, a, b = MAP()
l = 0
for i in range(h-b):
    for j in range(a):
        print(0, end= "")
    for j in range(w-a-1):
        print(1, end="")
    print(1)
for i in range(b):
    for j in range(a):
        print(1, end="")
    for j in range(w-a-1):
        print(0, end="")
    print(0)

    

Measured memory_bytes: 121048
n = int(input())
a = [int(input()) for i in range(n)]
a.sort()

p = [0]*n
m = [0]*n

for i in range(n-1):
    if i%2:
        m[i] += 1
        p[i+1] += 1
    else:
        p[i] += 1
        m[i+1] += 1
p.sort(reverse=True)
m.sort(reverse=True)
ans = 0
for i in range(n):
    if m[i] <= 0:
        break
    ans -= m[i]*a[i]
for i in range(n):
    if p[i] <= 0:
        break
    ans += p[i]*a[-1-i]
ans2 = 0
for i in range(n):
    if p[i] <= 0:
        break
    ans2 -= p[i]*a[i]
for i in range(n):
    if m[i] <= 0:
        break
    ans2 += m[i]*a[-1-i]

print(max(ans,ans2))


Measured memory_bytes: 14684
#include <iostream>
#include <algorithm>
#include <string>

#define MAX 1000001
#define SIZE 2000

typedef long long ll;

using namespace std;

int m, n;
int table[SIZE][SIZE]={{0,0}};
int dp[SIZE][SIZE];
bool prime[MAX]; 
pair<int, int>coord[MAX];//座標
pair<int, int> ans;// <素数の数, 出口の番号>


void dfs(int count, int y, int x){
	int num = table[y][x];
	if(num <= 0 || m < num) return;
	if(count < dp[y][x] || (count == dp[y][x] && prime[num] == false && dp[y][x] !=0)) return;
	dp[y][x] = count;

	if(prime[num] == true){
		count++;
		dp[y][x] = count;
		if(ans.first < count || (ans.first == count && ans.second < num)){
			ans.first = count;
			ans.second = num;
		}
	}

	for(int dx=-1; dx<=1; dx++){
		dfs(count, y+1, x+dx);
	}
}


int main(void){
	fill(prime, prime+MAX, true);
	prime[0] = prime[1] = false;
	for(int i=2; i<MAX; i++){
		if(prime[i]){
			for(int j=i+i; j<MAX; j+=i){
				prime[j] = false;
			}
		}
	}

	int d=0, x=1000, y=1000;
	int dx[4]={0, 1, 0, -1};
	int dy[4]={1, 0, -1, 0};
	for(int i=1; i<MAX; i++){
		table[y][x] = i;
		coord[i] = make_pair(y, x);
		if(table[y+dy[(d+1)%4]][x+dx[(d+1)%4]] == 0) d++;
		x += dx[d%4];
		y += dy[d%4];
	}

	while(1){
		cin >> m >> n;
		if(!m && !n) break;

		int y = coord[n].first;
		int x = coord[n].second;
		fill(dp[0], dp[2000], 0);
		ans = make_pair(0, 0);
		dfs(0, y, x);
		cout << ans.first << " " << ans.second << endl;
	}

	return 0;
}


Measured memory_bytes: 35332
#include <string>
#include <stack>
#include <stdlib.h>
#include <iostream>
#include <queue>
#include <utility>
using namespace std;

/*
#if 0
S.push(word)はできません。#include<stdlib.h>を使って、c = atoi(word.c_str())S.push(c)；を使うにはできます、しかし#include <stdilb.h>はVSしかないできます、ほかのコンパイルで使えません。
S.push(c);
#endif
int a, b,c;

int main()
{
	string word;
	stack <int> S;
	while (cin >> word)
	{
		if (word == "+")
		{

			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a + b);
		}
		else if (word == "-")
		{
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(b - a);
		}
		else if (word == "*")
		{
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a * b);
		}
		else
		{
			c = atoi(word.c_str());
			S.push(c);
		}
	}
	cout << S.top() << endl;
	return 0;
}*/
#define MAX_SIZE 100000
pair<string, int> process1, process2;
queue<pair<string, int> > Q;
int main()
{
	int j = 0,sum=0;
	int n,t,flag=0;
	cin >> n>>t;
	for(int i=0;i<n;i++)
	{
		cin >> process1.first >> process1.second;
		Q.push(process1);
	}
	while (!Q.empty()) {
		 process2 = Q.front(); Q.pop();
		if (process2.second > t) {
			process2.second -= t;
			sum += t;
			Q.push(process2);
		}
		else {
			sum += process2.second;
			cout << process2.first << " " << sum<< endl;
		}
	}
	return 0;
}


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

using namespace std;

//#define debug

#ifdef debug
#define mode cout << "--- debug mode ---" << endl
#define dump(i) cout << "[*] " #i ": " << i << " (line: " << __LINE__ << ")" << endl
#else
#define mode
#define dump(i)
#endif

int main() {
  mode;

  unsigned long long int x, y;

  cin >> x >> y;

  unsigned long long int i = 0;
  while (x <= y) {
    y >>= 1;
    ++i;
  }

  cout << i << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val H, W, K = sc.nextInt
  sc.nextLine
  val c = Array.fill(H)(sc.nextLine.toCharArray)

  val a = c.map(_.count(_ == '#')).sum
  var z = 0
  if (a >= K) {
    for (i <- 0 to H) {
      val x = (0 until H).combinations(i).toSeq
      x.foreach(f => {
        for (j <- 0 to W) {
          val y = (0 until W).combinations(j).toSeq
          y.foreach(g => {
            val k = (f.isEmpty, g.isEmpty) match {
              case (true, true) =>
                val k = c.map(_.count(_ == '#')).sum
                k
              case (true, false) =>
                val c1 = c.transpose.zipWithIndex.filterNot(h => g.contains(h._2)).map(_._1)
                val k = c1.map(_.count(_ == '#')).sum
                k
              case (false, true) =>
                val c1 = c.zipWithIndex.filterNot(h => f.contains(h._2)).map(_._1)
                val k = c1.map(_.count(_ == '#')).sum
                k
              case (false, false) =>
                val c1 = c.zipWithIndex.filterNot(h => f.contains(h._2)).map(_._1)
                val c2 = c1.transpose.zipWithIndex.filterNot(h => g.contains(h._2)).map(_._1)
                val k = c2.map(_.count(_ == '#')).sum
                k
            }
            if (k == K) z += 1
          })
        }
      })
    }
  }

  println(z)
}


Measured memory_bytes: 58812
#include <bits/stdc++.h>
using namespace std;
//vector<vector<int>> a(5, vector<int>(5, 0)) 5*5-0
int main(){
    int a;
    cin >> a;
    int b;
    b = a % 1000;
    if(b == 0){
        b = 1000;
    }

    cout << 1000 - b << endl;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Bulletin Board
            var lines = ReadLines(3);
            int n = lines[0];
            int h = lines[1];
            int w = lines[2];
            int count = 0;

            for(int y = 0; y < n; y++)
            {
                for(int x = 0; x < n; x++)
                {
                    if (y + h <= n && x + w <= n)
                    {
                        count++;
                    }
                }
            }

            Console.WriteLine(count);
        }

        static List<int> ReadLines(int count = 0)
        {
            //[summary]コンソールの値を読み込む
            var list = new List<int>();

            //読み込む行数が未指定のときは、1行目の値を"count"とみなす
            if (count == 0)
            {
                string s = Console.ReadLine().TrimEnd();
                count = int.Parse(s);
            }

            for (int i = 0; i < count; i++)
            {
                string s = Console.ReadLine().TrimEnd();
                list.Add(int.Parse(s));
            }

            return list;
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<30)
#define LLINF (1LL<<60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

const int MAX_N=200005;

vector<int> a,ans;
vector<int> to[MAX_N];
int dp[MAX_N];

void dfs(int v,int p=-1){
    int i=lower_bound(dp,dp+MAX_N,a[v])-dp;
    int old=dp[i];
    dp[i]=a[v];
    ans[v]=i;
    if(p!=-1)ans[v]=max(ans[v],ans[p]);
    for(int u:to[v]){
        if(u==p)continue;
        dfs(u,v);
    }
    dp[i]=old;
}

int main(){
    int n;
    cin>>n;
    a=ans=vector<int>(n);
    rep(i,n) cin>>a[i];
    rep(i,n-1){
        int u,v;
        cin>>u>>v;
        --u;--v;
        to[v].pb(u);
        to[u].pb(v);
    }
    rep(i,MAX_N)dp[i]=1001001001;
    dp[0]=-1001001001;
    dfs(0);
    rep(i,n)cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 30772
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
const int N = 1e5+1;
int n,a[N],tot,tmp,mn=0x7fffffff;

//bool can(int ans)
//{
//	if()
//}

int main()
{
	cin>>n;
	for(int i=1;i<=n;++i)cin>>a[i];
	sort(a+1,a+n+1);
	if(a[1]==0){cout<<"No";return 0;}
	if(a[n]-a[1]>=2){cout<<"No";return 0;}
	if(a[n]==a[1]&&a[1]*2>n)
	{
		if(a[n]==n-1){cout<<"Yes";return 0;}
		cout<<"No";return 0;
		
	}
	if(a[n]==a[1]){cout<<"Yes";return 0;}
	for(int i=1;i<=n;++i)tot+=a[i];
	mn=a[1];
	for(int i=1;i<=n;++i)if(a[i]==mn)tmp++;
	int n1=a[n]-tmp;
	if(2*n1>n-tmp||n1<=0){cout<<"No";return 0;}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 long long n,count;
  cin>>n;
  count=1;
  vector<string>vec(n);
  for(long long i=0;i<n;i++){
    cin>>vec.at(i);
  }
 sort(vec.begin(),vec.end());
  string a=vec.at(0);
  for(long long j=1;j<n;j++){
    string b=vec.at(j);
    if(a!=b){
      count++;
      a=b;
    }
  }
  cout<<count<<endl; 
}

Measured memory_bytes: 9600
W, H, x, y = map(int, input().split())
 
if x == 0 or x == W or y == 0 or y == H:
    print("{:.10f}".format(W*H/2), 0)
else:
    if x == W/2 and y == H/2:
        print("{:.10f}".format(W*H/2), 1)
    else:
        print("{:.10f}".format(W*H/2), 0)

Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
using namespace std;
typedef long long LL;

int main(void) {
	LL i, j, k;
	string a, b;
	cin >> a >> b;
	for (i = 0; i < b.size(); i++) {
		cout << a[i] << b[i];
	}
	if (a.size() - b.size() > 0) {
		cout << a[a.size() - 1];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


n = inp()
n -= 1

res = n * (n+1) // 2
print(res)


Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int n = sc.nextInt();
    List<Integer> listPlus = new ArrayList<>();
    List<Integer> listMinus = new ArrayList<>();

    for (int i = 0; i < n; i++) {
      int pi = sc.nextInt();
      int xpi = pi - x;
      if (xpi >= 0) {
        listPlus.add(xpi);
      } else {
        listMinus.add(xpi);
      }
    }
    int plusX = 0;
    for (int i = 0; i < 101; i++) {
      boolean check1 = true;
      for (Integer plus : listPlus) {
        if (i == plus) {
          check1 = false;
        }
      }
      if (check1) {
        plusX = i;
        break;
      }
    }
    int minusX = -101;
    for (int i = -1; i > -101; i--) {
      boolean check1 = true;
      for (Integer minus : listMinus) {
        if (i == minus) {
          check1 = false;
        }
      }
      if (check1) {
        minusX = i;
        break;
      }
    }
    int abs = Math.abs(minusX);
    if (plusX == abs) {
      System.out.println(x + minusX);
    } else if (plusX > abs) {
      System.out.println(x + minusX);
    } else {
      System.out.println(x + plusX);
    }
  }
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll H, W;
    cin >> H >> W;
    vector<string> s(H);
    REP(i, H)
    {
        cin >> s[i];
    }

    ll dp[H][W];
    REP(i, H)
    {
        REP(j, W)
        {
            dp[i][j] = LONG_MAX;;
        }
    }

    dp[0][0] = s[0][0] == '.' ? 0 : 1;
    REP(i, H)
    {
        REP(j, W)
        {
            if (i - 1 >= 0)
            {
                if (s[i - 1][j] == '.' && s[i][j] == '#')
                {
                    dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
                }
                else
                {
                    dp[i][j] = min(dp[i][j], dp[i - 1][j]);
                }
            }
            if (j - 1 >= 0)
            {
                if (s[i][j - 1] == '.' && s[i][j] == '#')
                {
                    dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
                }
                else
                {
                    dp[i][j] = min(dp[i][j], dp[i][j - 1]);
                }
            }
        }
    }

    cout << dp[H - 1][W - 1] << endl;
}


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

int main(){
     int N;
     while(cin>>N,N){
	  int maxp=-1,minp=1000000;
	  for(int i=0;i<N;i++){
	       int sum=0;
	       for(int j=0;j<5;j++){
		    int temp;
		    cin>>temp;
		    sum+=temp;
	       }
	       maxp=max(maxp,sum);
	       minp=min(minp,sum);
	  }
	  cout<<maxp<<" "<<minp<<endl;
     }
     return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=600005,maxe=maxn<<1,TT=924844033;
int n,L,len,sz[maxn],rev[maxn];
int e,lnk[maxn],nxt[maxe],son[maxe];
long long fct[maxn],ifct[maxn],G[2][maxn],a[maxn],b[maxn],c[maxn];
inline char nc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read(){
	int ret=0;bool f=0;char ch=nc();
	while(ch>'9'||ch<'0') f^=ch=='-',ch=nc();
	while(ch<='9'&&ch>='0') ret=ret*10+ch-'0',ch=nc();
	return f?-ret:ret;
}
inline void add_e(int x,int y){son[++e]=y;nxt[e]=lnk[x];lnk[x]=e;}
void DFS(int x,int fa){
	sz[x]=1;
	for (int i=lnk[x];i;i=nxt[i]) if(son[i]^fa)
	DFS(son[i],x),sz[x]+=sz[son[i]],a[sz[son[i]]]--;
	if(~fa) a[n-sz[x]]--;a[n]++;
}
inline long long pw(long long x,long long y){
	long long ret=1,w=x%TT;
	while(1){
		if(y&1) ret=ret*w%TT;
		if(!(y>>=1)) return ret;
		w=w*w%TT;
	}
}
inline void rsv(long long*A){for (int i=0;i<n-i;i++) swap(A[i],A[n-i]);}
inline void NTT(long long*A,bool flg){
	for (int i=0;i<len;i++) if(i<rev[i]) swap(A[i],A[rev[i]]);
	for (int i=1;(i<<1)<=len;i<<=1)
	for (int j=0;j<len;j+=(i<<1))
	for (int k=0;k<i;k++){
		long long x=A[j|k],y=A[i|j|k]*G[flg][i|k]%TT;
		A[i|j|k]=x<y?x-y+TT:x-y;A[j|k]=x+y>=TT?x+y-TT:x+y;
	}
	if(flg){
		int inv=pw(len,TT-2);
		for (int i=0;i<len;i++) A[i]=A[i]*inv%TT;
	}
}
int main(){
	n=read();
	for (int i=fct[0]=1;i<=n;i++) fct[i]=fct[i-1]*i%TT;
	ifct[n]=pw(fct[n],TT-2);
	for (int i=n;i;i--) ifct[i-1]=ifct[i]*i%TT;
	for (L=0,len=1;len<=(n<<1);L++,len<<=1);
	for (int i=1;i<len;i++) rev[i]=rev[i>>1]>>1|(i&1)*(len>>1);
	G[0][0]=5,G[1][0]=pw(5,TT-2);
	for (int T=0;T<2;T++)
	for (int i=1;i<len;i<<=1){
		G[T][i]=1;long long now=pw(G[T][0],(TT-1>>1)/i);
		for (int j=1;j<i;j++) G[T][i|j]=G[T][i|j-1]*now%TT;
	}
	for (int i=1,x,y;i<n;i++)
	x=read(),y=read(),add_e(x,y),add_e(y,x);
	DFS(1,-1);
	for (int i=1;i<=n;i++) a[i]=(a[i]+TT)*fct[i]%TT;
	for (int i=0;i<n;i++) b[i]=ifct[i];
	rsv(a);NTT(a,0),NTT(b,0);
	for (int i=0;i<len;i++) c[i]=a[i]*b[i]%TT;
	NTT(c,1);rsv(c);
	for (int i=1;i<=n;i++) printf("%lld\n",c[i]*ifct[i]%TT);
	return 0;
}

Measured memory_bytes: 55168
#include<stdio.h>
int main(void){
	int i,j,h,w;
	for(;;){
		scanf("%d %d",&h,&w);
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				printf("#");
			}
			printf("\n");
		}
		if(h==0&&w==0){
			break;
		}
	else printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
<?php
$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));
$c = trim(fgets(STDIN));
$x = trim(fgets(STDIN));

$count = 0;
for ($i = 0; $i <= $a; $i++) {
  for ($j = 0; $j <= $b; $j++) {
    for ($k = 0; $k <= $c; $k++) {
      $result = 0;
      $result += $i * 500;
      $result += $j * 100;
      $result += $k * 50;
      if ($result == $x) {
        $count++;
      }
    }
  }
}

echo $count;

Measured memory_bytes: 4728
a = int(input())
b = list(map(int, input().split()))
c = {}
for i in b:
    if 1 <= i <= 399:
        c[0] = 1
    elif 400 <= i <= 799:
        c[1] = 1
    elif 800 <= i <= 1199:
        c[2] = 1
    elif 1200 <= i <= 1599:
        c[3] = 1
    elif 1600 <= i <= 1999:
        c[4] = 1
    elif 2000 <= i <= 2399:
        c[5] = 1
    elif 2400 <= i <= 2799:
        c[6] = 1
    elif 2800 <= i <= 3199:
        c[7] = 1
    else:
        if 8 not in c:
            c[8] = 1
        else:
            c[8] += 1
count = 0
se = 0
for k, v in c.items():
    if k == 8:
        se = v
    else:
        count += 1
if se == 0:
    print("{} {}".format(count, count))
else:
    if count == 0:
        print("{} {}".format(1, se))
    else:
        print("{} {}".format(count, count + se))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;

int main() {
    int x,y;cin >> x >> y;
    ll ans = 0; int a[x];
    for(int i = 0;i < x;i++){
        cin >> a[i];
    }
    for(int i = 1;i < x;i++){
        ans+=min(y,a[i]-a[i-1]);
    }
    cout << ans+y;
}



Measured memory_bytes: 1024
n,q=map(int,raw_input().split())
exist=[False]*(n+2)
exist[1]=True
cup=range(n+2)
now=1
exist[cup[now-1]]=True
exist[cup[now+1]]=True
for i in xrange(q):
    a,b=map(int,raw_input().split())
    if now==a:now=b
    elif now==b:now=a
    tmp=cup[a]
    cup[a]=cup[b]
    cup[b]=tmp
    exist[cup[now-1]]=True
    exist[cup[now+1]]=True
ans=0
for i in xrange(1,n+1):
    if exist[i]:ans+=1
print ans


Measured memory_bytes: 6660
import java.util.*;

public class Main{
	public static void main(String[] args){
	    Scanner scanner = new Scanner(System.in);
	    int[] array = new int[4];
	    int ans=-1;
	    for(int i=0;i<4;i++){   
		array[i]=scanner.nextInt();
	    }
	    if(array[0]<=array[2]){
		if(array[1]<=array[3])ans=array[1]-array[2];
		if(array[3]<=array[1])ans=array[3]-array[2];
	    }
	    if(array[2]<array[0]){
		if(array[1]<=array[3])ans=array[1]-array[0];
		if(array[3]<=array[1])ans=array[3]-array[0];
	    }
	    if(ans<0)ans = 0;
		System.out.println(ans);
	}
}

Measured memory_bytes: 20820
package main

import (
	"bufio"
	"fmt"
	"os"
)

type point struct {
	h, w int
}

var sc = bufio.NewScanner(os.Stdin)

const inf = 1 << 60

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func rs() string {
	sc.Scan()
	return sc.Text()
}

func smaller(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	sc.Split(bufio.ScanWords)
	H, W := ri(), ri()

	directions := []point{point{h: 1, w: 0}, point{h: -1, w: 0}, point{h: 0, w: 1}, point{h: 0, w: -1}}

	que := make([]point, 0, H*W)

	dp := make([][]int, H) // board
	for i := 0; i < H; i++ {
		a := rs()
		row := make([]int, W)
		for j, aa := range a {
			if aa == '#' {
				row[j] = 0
				que = append(que, point{h: i, w: j})
			} else {
				row[j] = inf
			}
		}
		dp[i] = row
	}

	var curr point
	for len(que) != 0 {
		curr, que = que[0], que[1:]

		for _, d := range directions {
			expl := point{h: curr.h + d.h, w: curr.w + d.w}

			if expl.h < 0 || expl.w < 0 || expl.h >= H || expl.w >= W {
				continue
			}

			if dp[curr.h][curr.w]+1 < dp[expl.h][expl.w] {
				dp[expl.h][expl.w] = dp[curr.h][curr.w] + 1
				que = append(que, point{h: expl.h, w: expl.w})
			}
		}
	}

	maxCost := 0
	for _, row := range dp {
		for _, cost := range row {
			if cost > maxCost {
				maxCost = cost
			}
		}
	}
	fmt.Println(maxCost)
}


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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    if (s[0] == s[2])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  int si;
  priority_queue<int> slime, s;
  while (cin >> si) s.emplace(si);
  slime.emplace(s.top());
  s.pop();
  REP(i, n) {
    vector<int> nx;
    vector<int> horyu;
    REP(j, 1 << i) {
      int now = slime.top(); slime.pop();
      while (!s.empty() && s.top() >= now) {
        horyu.emplace_back(s.top());
        s.pop();
      }
      if (s.empty()) {
        cout << "No\n";
        return 0;
      }
      nx.emplace_back(now);
      nx.emplace_back(s.top());
      s.pop();
    }
    for (int e : nx) slime.emplace(e);
    for (int e : horyu) s.emplace(e);
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 4620
import sys
sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 998244353
input = lambda:sys.stdin.readline().rstrip()

class SegmentTree(object):
    def __init__(self, A, dot, unit):
        n = 1 << (len(A) - 1).bit_length()
        tree = [unit] * (2 * n)
        for i, v in enumerate(A):
            tree[i + n] = v
        for i in range(n - 1, 0, -1):
            tree[i] = dot(tree[i << 1], tree[i << 1 | 1])
        self._n = n
        self._tree = tree
        self._dot = dot
        self._unit = unit

    def __getitem__(self, i):
        return self._tree[i + self._n]

    def update(self, i, v):
        i += self._n
        self._tree[i] = v
        while i != 1:
            i >>= 1
            self._tree[i] = self._dot(self._tree[i << 1], self._tree[i << 1 | 1])

    def add(self, i, v):
        self.update(i, self[i] + v)

    def sum(self, l, r):
        l += self._n
        r += self._n
        l_val = r_val = self._unit
        while l < r:
            if l & 1:
                l_val = self._dot(l_val, self._tree[l])
                l += 1
            if r & 1:
                r -= 1
                r_val = self._dot(self._tree[r], r_val)
            l >>= 1
            r >>= 1
        return self._dot(l_val, r_val)

from bisect import bisect_left
def resolve():
    n = int(input())
    XD = [tuple(map(int, input().split())) for _ in range(n)]
    XD.sort()
    X = [xd[0] for xd in XD]

    tree = SegmentTree([-INF] * n, max, -INF)
    for i in range(n - 1, -1, -1):
        x, d = XD[i]
        j = bisect_left(X, x + d)
        tree.update(i, max(j, tree.sum(i + 1, j)))

    dp = [0] * (n + 1)
    dp[n] = 1
    for i in range(n - 1, -1, -1):
        dp[i] += dp[i + 1]
        dp[i] += dp[tree[i]]
        dp[i] %= MOD
        
    print(dp[0])
resolve()

Measured memory_bytes: 99388
#include <stdio.h>
#define N 100
#define WHITE 0;
#define GRAY 1;
#define BRACK 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs_visit(int u){
  int v;
  color[u] = GRAY;
  d[u] = ++tt;
  for( v = 0; v < n; v++ ){
    if ( M[u][v] == 0 ) { continue; }
    if ( color[v] == 0 ){
      dfs_visit(v);
    }
  }
  color[u] = BRACK;
  f[u] = ++tt;
  
}

void dfs() {
  int u;
  for ( u = 0; u < n; u++ ) color[u] = WHITE;
  tt = 0;
  
  for ( u = 0; u < n; u++) {
    if (color[u] == 0 ) { dfs_visit(u); }
  }
  for ( u = 0; u < n; u++ ) {
    printf("%d %d %d\n", u + 1, d[u], f[u]);
  }
}

int main() {
  int u, v, k, i, j;
  
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    for ( j = 0; j < n; j++ ) M[i][j] = 0;
  }
  
  for ( i = 0; i < n; i++ ) {
    scanf("%d %d", &u, &k );
    u--;
    for ( j = 0; j < k; j++ ) {
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }
    
    dfs();
    
    return 0;
}

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

int main()
{
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;

    if ((x >= r && x <= W - r) && (y >= r && y <= H - r))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3112
#include <iostream>
#include <vector>
using namespace std;
#define A

#ifdef A

int main(void)
{
	int n;
	cin >> n;
	vector<int> arr(n);
	for (auto &a : arr)
	{
		cin >> a;
	}
	for (int i = n - 1; i >= 0; i--)
	{
		cout <<arr[i] ;
		if (i != 0)
			cout << " ";
	}
	cout << endl;
	return 0;
}
#endif // A

Measured memory_bytes: 3004
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 100, S = 20000;

int tt[N], vv[N], oo[S], pp[S], qq[S];

int main() {
	int n; cin >> n;
	int s = 0;
	for (int i = 0; i < n; i++) {
		int t; cin >> t;
		s += tt[i] = t;
	}
	for (int i = 0; i < n; i++) {
		int v; cin >> v;
		vv[i] = v;
	}
	for (int h = 0; h < s; h++) {
		oo[h] = s;
		pp[h] = h;
		qq[h] = s - 1 - h;
	}
	for (int l = 0, i = 0; i < n; i++) {
		int t = tt[i], v = vv[i];
		int r = l + t;
		for (int h = l; h < r; h++)
			oo[h] = min(oo[h], v);
		for (int h = r; h < s; h++)
			pp[h] = min(pp[h], v + h - r);
		for (int h = 0; h < l; h++)
			qq[h] = min(qq[h], v + l - 1 - h);
		l = r;
	}
	double ans = 0;
	for (int h = 0; h < s; h++) {
		int o = oo[h], p = pp[h], q = qq[h];
		if (o <= p && o <= q)
			ans += o;
		else
			ans += p == q ? p + 0.25 : min(p, q) + 0.5;
	}
	printf("%f\n", ans);
	return 0;
}


Measured memory_bytes: 3900
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define pb push_back
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 main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N;
  	cin >> N;
    int A[N];
    ll sum = 0;
    REP(i,N){
        cin >> A[i];
        sum += A[i];
    }
    cout << sum - N << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n,sum,ave,max,min;
  int num;
  int i;

  scanf("%d",&n);

  while(n != 0){
    sum = 0;
    ave = 0;
    min = 1001;
    max = -1;
    for(i=0;i<n;i++){
      scanf("%d",&num);
      sum += num;
      if(max <= num){
        max = num;
      }
      if(min >= num){
        min = num;
      }
    }

    sum = sum - max - min;

    ave = sum / (n - 2);

    printf("%d\n",ave);

    scanf("%d",&n);
  }

  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int a[n],b[n];
    r(i,n)cin>>a[i];
    r(o,114514){
      map<int,int>s;
      r(i,n)b[i]=a[i],s[a[i]]++;
      r(i,n)a[i]=s[a[i]];
      int c=0;
      r(i,n)if(b[i]!=a[i])c++;
      if(!c){
        cout<<o<<endl;
        r(i,n){
          if(i)cout<<' ';
          cout<<a[i];
        }
        cout<<endl;
        goto L;
      }
    }L:;
  }
}

Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
using namespace std;
#define ll long long
const long long mod = 1e9 + 7;

int main() {
	ll n, k;
	ll d[100010];
	cin >> n;
	for (int i = 0; i < n; i++)cin >> d[i];
	sort(d, d + n);
	k = n / 2;
	cout << abs(d[k - 1] - d[k]) << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
    int n,s[3],i,j,jugde,a,b,c;
    char d[100];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d",&s[0],&s[1],&s[2]);
        if(s[0]<s[1]){
            j=s[1];
            s[1]=s[0];
            s[0]=j;
        }
        if(s[0]<s[2]){
            j=s[2];
            s[2]=s[0];
            s[0]=j;
        }
        a=s[0]*s[0];
        b=s[1]*s[1];
        c=s[2]*s[2];
        
        if(a==(b+c))
            printf("YES\n");
        else
            printf("NO\n");
    }
}

Measured memory_bytes: 1700
#include <iostream>

using namespace std;

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

  if (n <= a) {
    cout << "Yes" << endl;
  } else {
    if (n < 500) {
      cout << "No" << endl;
    } else {
      if (n % 500 <= a) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public  class Main
{
public static void main(String args[])
{
  Scanner sc=new Scanner(System.in);
  String h[]=sc.nextLine().split(" ");
  String hh[]=sc.nextLine().split(" ");
  int s=0;

  int a=Integer.parseInt(h[0]);
  for(int i=0;i<hh.length;i++)
  {s+=Integer.parseInt(hh[i]);
    if(s>a){break;}
  }
  System.out.println(s>a?-1:(a-s));
}}

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

using P = pair<int, int>;

vector<P> next(int y, int x) {return {{y-1, x-1}, {y-1, x}, {y-1, x+1}, {y, x-1}, {y, x+1}, {y+1, x-1}, {y+1, x}, {y+1, x+1}};}

int main() {
  int H, W;
  cin >> H >> W;

  auto valid = [&](auto y, auto x) {return 0 <= y && y < H && 0 <= x && x < W;};

  vector<vector<int>> toughness(H, vector<int>(W)), blank(H, vector<int>(W));

  for(auto i = 0; i < H; ++i) for(auto j = 0; j < W; ++j) {
    char c;
    cin >> c;
    toughness[i][j] = (c == '.') ? 0 : (c - '0');
  }

  queue<P> cur, nex;
  for(auto i = 0; i < H; ++i) for(auto j = 0; j < W; ++j) if(toughness[i][j] <= blank[i][j]) cur.emplace(i, j);
  for(auto step = 0; ; ++step) {
    if(cur.empty()) {cout << step - 1 << endl; break;}
    while(!cur.empty()) {
      int y, x;
      tie(y, x) = cur.front();
      cur.pop();
      for(auto p: next(y, x)) if(valid(p.first, p.second)) if(++blank[p.first][p.second] == toughness[p.first][p.second]) nex.emplace(p);
    }
    swap(cur, nex);
  }
}

Measured memory_bytes: 10888
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> pl;

ll gcd(ll a,ll b){
  if(a<b)swap(a,b);
  ll c=a%b;
  while(c!=0){
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}

vector<ll> soinsu(ll n){
  vector<ll> a;
  for(ll i=2;i*i<=n;i++){
    if(n%i)continue;
    a.push_back(i);
    while(n%i==0){
      n/=i;
    }
  }
  if(n!=1)a.push_back(n);
  return a;
}



int main(){
  ll a,b;
  cin>>a>>b;

  ll c=gcd(a,b);
  auto f=soinsu(c);

  cout<<f.size()+1<<endl;

}


Measured memory_bytes: 256
/*
Dont BLUNDER
*/
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


 */
#define d long double
#define int long long
#define pii pair<int,int>
#define pb push_back
#define endl '\n'
#define pi acos(-1)

#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod1 = 998244353;
int const mod = 1000000007;
#define l first
#define r second
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// * Using PBDS *
/*typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
               os; */



int modexp(int x, int n) {
	if (n == 0) {
		return 1;
	}
	else if (n & 1) {
		return (modexp((x * x) % mod, n / 2) % mod * x % mod) % mod;
	}
	else {
		return (modexp((x * x) % mod, n / 2) % mod);
	}
}

int modinv(int n)
{
	return modexp(n, mod - 2);
}

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

int n, k;
int arr[200001];
bool con(int x)
{
	//cout << x << " ";
	int s = 0;
	for (int i = 0; i < n; i++) {
		int v = arr[i];
		if (v % x != 0)
			s += v / x;
		else
			s += max(0ll, (v / x) - 1 );
	}
	//cout << s << endl;


	if (s <= k)
		return true;
	return false;

}




signed main()
{
	haha
#ifndef ONLINE_JUDGE

	freopen("inp.txt", "r", stdin);

	freopen("out.txt", "w", stdout);
#endif
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	int l = 1;
	int r = 1e10;
	while (l + 1 < r) {
		int m = (l + r) / 2;
		//cout << m << endl;
		if (con(m)) {
			r = m;
		} else
			l = m + 1;
	}
	if (con(l))
		cout << l;
	else
		cout << r;



}

Measured memory_bytes: 5148
package main

import (
	"fmt"
)

const mod = 1000000007

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	var ans int
	if n == m {
		p := permutation(n)
		ans = 2 * p * p
	} else if abs(n-m) == 1 {
		p := permutation(min(n, m))
		ans = p * p % mod * max(n, m)
	} else {
		ans = 0
	}
	fmt.Println(ans % mod)
}

func permutation(n int) int {
	v := 1
	for i := 0; i < n; i++ {
		v *= n - i
		v %= mod
	}
	return v
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 1768
unittest
{
	assert( [ "2 4" ].solve == 5 );
	assert( [ "123 456" ].solve == 435 );
	assert( [ "123456789012 123456789012" ].solve == 123456789012 );
	
	assert( [ "0 1000000000000" ].solve == 1000000000000 );		// 追加ケース
	assert( [ "2 1000000000000" ].solve == 1000000000001 );		// 追加ケース
}



import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto a = 0L;
	auto b = 0L;
	input.front.formattedRead!"%s %s"( a, b );
	b++;
	
	auto aa = 0L;
	for( auto x = 1L; x <= a; x <<= 1 )
	{
		auto y = x << 1;		// ビットパターンの周期
		auto r = a % y;
		auto c = ( a / y * x );			// 1周期でビットが立つ回数
		if( x <= r ) c += r - x;		// 最終週でビットが立つ回数
		if( c % 2 ) aa |= x;
	}
	
	auto bb = 0L;
	for( auto x = 1L; x <= b; x <<= 1 )
	{
		auto y = x << 1;		// ビットパターンの周期
		auto r = b % y;
		auto c = ( b / y * x );			// 1周期でビットが立つ回数
		if( x <= r ) c += r - x;		// 最終週でビットが立つ回数
		if( c % 2 ) bb |= x;
	}
	
	return aa ^ bb;
}


Measured memory_bytes: 2932
N = int(input())
a = list(map(int, input().split()))
 
COLOR = 8
cnt, ov = [0] * COLOR, 0
for r in a:
    if r < 3200:
        cnt[r // 400] = 1
    else:
        ov += 1

used = 0
for c in cnt:
    if c > 0:
        used += 1

unused = N - used

print(max(1, used), used + min(unused, ov))


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

class Vec;
Vec operator/(const Vec& v, const double& divisor);
Vec operator*(const double& scale, const Vec& v);

class Vec {
  using F = double;
  vector<F> container;

 public:
  Vec(size_t size) : container(size) {}
  Vec(initializer_list<F> elements)
      : container(elements.begin(), elements.end()) {}
  size_t dim() const { return container.size(); }
  F& operator[](const size_t size) { return container.at(size); }
  const F& operator[](const size_t size) const { return container.at(size); }
  Vec operator+(const Vec& other) const {
    Vec ret(*this);
    for (size_t i = 0; i < dim(); i++) ret[i] += other[i];
    return ret;
  }
  Vec operator-(const Vec& other) const { return (*this) + (-other); }
  Vec operator-() const { return -1.0 * (*this); }
  F inner(const Vec& other) const {
    F acc = 0;
    for (size_t i = 0; i < dim(); i++) {
      acc += (*this)[i] * other[i];
    }
    return acc;
  }
  F norm() const { return sqrt(inner(*this)); }
  Vec unit() const { return (*this) / this->norm(); }
  F ccw(const Vec& other) const {
    return (*this)[0] * other[1] - other[0] * (*this)[1];
  }
};
Vec operator/(const Vec& v, const double& divisor) { return 1.0 / divisor * v; }
Vec operator*(const double& scale, const Vec& v) {
  Vec ret(v);
  for (size_t i = 0; i < ret.dim(); i++) ret[i] *= scale;
  return ret;
}

class Line {
  Vec m_grad;
  double m_bias;

 public:
  Line(const Vec& grad, double bias) : m_grad(grad), m_bias(bias) {}
  static Line fromPoints(const Vec& p0, const Vec& p1) {
    Vec d = p0 - p1;
    Vec g({-d[1], d[0]});
    return Line(g, g.inner(p0));
  }
  const Vec& grad() const { return m_grad; }
  double bias() const { return m_bias; }
  double dist(const Vec& p) const {
    return abs(m_grad.inner(p) - m_bias) / m_grad.norm();
  }
  Vec projection(const Vec& p) const {
    const Vec g = m_grad.unit();
    const Vec h({-g[1], g[0]});
    return m_bias / m_grad.norm() * g + h.inner(p) * h;
  }
};

int main() {
  double x0, y0, x1, y1;
  cin >> x0 >> y0 >> x1 >> y1;

  const Line line = Line::fromPoints(Vec{x0, y0}, Vec{x1, y1});

  int q;
  cin >> q;
  rep(i, q) {
    double x, y;
    cin >> x >> y;

    const Vec v = line.projection(Vec({x, y}));
    cout << fixed << setprecision(10) << v[0] << " " << v[1] << "\n";
  }
  cout.flush();
  return 0;
}



Measured memory_bytes: 3288
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DUMP(x) cout << #x << " = " << (x) << endl
using ll = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

int main() {
  ll x, y; cin >> x >> y;
  vector<ll> ans;
  while (x <= y) {
    ans.push_back(x);
    x += x;
  }
  cout << ans.size() << endl;
  return 0;
}

Measured memory_bytes: 256
#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;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc145/tasks/abc145_b>
 問題文============================================================
 B - Echo
 =================================================================
 解説=============================================================
 
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    string S; cin >> S;
    return S.substr(0,S.length()/2) == S.substr(S.length()/2)?"Yes":"No";
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long dp[1001][1001];
int main()
{
    long long n,m,i,j;
    char ch[1001][1001];
    cin>>n>>m;
    for (i=1;i<=n;i++)
        for (j=1;j<=m;j++) cin>>ch[i][j];
    dp[1][1]=1;
    for (i=1;i<=n;i++)
        for (j=1;j<=m;j++)
    {
        if (ch[i][j]=='.') dp[i][j]+=dp[i-1][j]+dp[i][j-1],dp[i][j]%=mod;
    }
    cout<<dp[n][m]<<endl;
}


Measured memory_bytes: 12424
#!/usr/bin/python3

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

lenbin = len(bin(max(max(a), k))) - 2
bitcnt = [0] * lenbin

for i in range(lenbin):
    for ai in a:
        if ai & (1 << i):
            bitcnt[i] += 1

x = 0
for i in range(lenbin - 1, -1, -1):
    if bitcnt[i] <= n // 2 and x + (1 << i) <= k:
        x += (1 << i)

ans = 0
for ai in a:
    ans += (x ^ ai)

print(ans)

Measured memory_bytes: 14620
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);


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

Measured memory_bytes: 256
h_1, m_1, h_2, m_2, k = map(int, input().split())

if m_2 >= m_1:
    min = m_2 - m_1
else:
    min = 60 + m_2 - m_1
    h_2 -= 1

hour = h_2 - h_1

print(hour*60 + min - k)


Measured memory_bytes: 9156