akhauriyash/Code-Regression huggingface dataset:
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;

long long gcd(long long x, long long y){
			if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }

int main(){
int N;
cin >> N;
vector<long long> a(N);
for(int i = 0; i< N;i++)cin >> a[i];
long long ans = 0;
for(int i = 0;i<N;i++){
	while(a[i]%2==0){
		ans++;
		a[i]/=2;
	}
	}

cout << ans <<endl;
}



Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
#define mp make_pair
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
    ll n;
    cin >> n;
    vl a(n);
    ll z=0;
    rep(i,n){
        cin >> a[i];
        z=z^(ll)a[i];
    }
    rep(i,n){
        ll k=z^a[i];
        cout << k;
        if(i!=n-1){
            cout << " ";
        }
    }
}

Measured memory_bytes: 4836
N,M,K = [int(x) for x in input().split()]
flag = False
for y in range(N+1):
    if(N-2*y==0):
        continue
    x = (K-M*y)/(N-2*y)
    if(int(x)==x and 0<=x<=M):
        flag = True
        break

if(flag):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#define ALL(obj) (obj).begin(), (obj).end()

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
typedef long long ll;
const ll INF = 1e18;

ll N;

int main() {
    // ios_base::sync_with_stdio(false);
	// cin.tie(0);
    
    cin >> N;

    vector<pair<ll, ll> > v(N);
    for(ll i=0; i<N; i++){
        ll a, b;
        cin >> a >> b;
        v[i] = {a + b, a - b};
    }

    sort(ALL(v));

    ll count = 0;
    ll max = -INF;

    for(auto pair: v) {
        if(pair.second >= max) {
            count++;
            max = pair.first;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
const ll m = 1e9 + 7;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n; cin >> n;
    vector <ll> v(n);
    for(ll &x: v) cin >> x;
    vector <ll> sum(n);
    ll s = 0;
    for(int i = n - 2; i >= 0; i--){
        s+=v[i+1];
        s%=m;
        sum[i]=s;
    }
    ll ans  = 0;
    for(int i = 0; i < n- 1; i++){
        ans+=(v[i]*sum[i])%m;
        ans%=m;
    }
    cout << ans << "\n";
}


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

#define pb push_back
#define sp " "
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define tra(a,b) for (auto a:b) 
#define fo(a,b,c) for (unsigned long long a=b;a<=c;a++) 
#define ms(a,b) memset(a,b,sizeof(a)) 
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())
#define bit(i,j) (i&(1<<j))
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair<int,ii> iii;

const int N=2e5+5,mod=998244353;
ll a,b;

int main()
{
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	cin>>a>>b;
	a%=b;
	ll r=a;
	r=min(r,b-a);
	cout<<r;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N; i64 A[101010];
i64 D[101010];

i64 hoge()
{
	int top = 0, end = N - 2;
	int a = 1;
	i64 ret = 0;
	while (top <= end) {
		if (a % 2 == 0) {
			ret += a * D[top++];
		} else {
			ret += a * D[end--];
		}
		++a;
	}
	return ret;
}
int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%lld", A + i);

	sort(A, A + N);

	for (int i = 0; i < N - 1; ++i) D[i] = A[i + 1] - A[i];

	i64 ret = 0;
	int a = 1;
	int top = 0, end = N - 2;
	for (;;) {
		if (end - top == 0) {
			ret += D[top] * (N - 1);
			break;
		} else if (end - top == 1) {
			ret += (D[end] + D[top]) * (N - 2);
			ret += max(D[end], D[top]);
			break;
		} else {
			ret += (D[end] + D[top]) * a * 2;
			++a;
			--end;
			++top;
		}
	}
	printf("%lld\n", ret);

	return 0;
}


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

int main() {
    int N,H,m=0,c=0;
    cin >> N >> H;
    vector<int> a(N),b(N);

    rep(i,N)
        cin >> a.at(i) >> b.at(i);
    sort(b.begin(), b.end(), greater<int>());
    
    rep(i,N)
        m = max(m, a.at(i));
    
    rep(i,N)
        if(b.at(i) >= m) {
            c++;
            H -= b.at(i);

            if(H <= 0) {
                cout << c << endl;
                return 0;
            }
        }
    
    if(H%m)
        c++;
    cout << c + H/m << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string.h>
using namespace std;
int n,a[100000];
int branchserch(int key){
    int left=0;
    int right=n;
    int mid;
    while(left<right){
        mid=(left+right)/2;
        if(a[mid]==key)return 1;
        if(key<a[mid])right=mid;
        else if(key>a[mid])left=mid+1;
    }
    return 0;
}
int main(){
    int count=0,q,k;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    cin>>q;
    for(int j=0;j<q;j++){
        cin>>k;
        if(branchserch(k)){
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}




Measured memory_bytes: 3376
N = int(input())
ans = [0 for _ in range(N+1)]

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            tmp = x*x + y*y + z*z + x*y + y*z + z*x
            if tmp <= N:
                ans[tmp] += 1

for i in range(N):
    print(ans[i+1])

Measured memory_bytes: 9184
#include <stdio.h>

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

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

public class Main {

	public static void main(String[] count) {

		Scanner scan = new Scanner(System.in);

		int n = Integer.parseInt(scan.next());

		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(scan.next());
		}
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			b[i] = Integer.parseInt(scan.next());
		}
		int[] c = new int[n];
		for (int i = 0; i < n; i++) {
			c[i] = Integer.parseInt(scan.next());
		}

		scan.close();

		// start
		Arrays.sort(a);
		Arrays.sort(b);
		Arrays.sort(c);

		long ans = 0;
		for (int i = 0; i < n; i++) {
			ans += (binarySearchA(a, b[i]) + 1) * (n - binarySearchC(c, b[i]));
		}

		System.out.println(ans);

	}

	private static long binarySearchA(int[] array, int key) {
		int ok = -1;
		int ng = array.length;

		while (ng - ok > 1) {
			int mid = (ok + ng) / 2;
			if (array[mid] < key) {
				ok = mid;
			} else {
				ng = mid;
			}
		}

		return ok;

	}

	private static long binarySearchC(int[] array, int key) {
		int ng = -1;
		int ok = array.length;

		while (ok - ng > 1) {
			int mid = (ok + ng) / 2;
			if (array[mid] > key) {
				ok = mid;
			} else {
				ng = mid;
			}
		}

		return ok;
	}

}


Measured memory_bytes: 63420
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
		if(s == "RRR") cout << 3 << endl;
		else if(s == "SSS") cout << 0 << endl;
		else if(s == "RRS" || s == "SRR") cout << 2 << endl;
		else cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(){
  int n,x;
  scanf("%d%d\n",&n,&x);
  int l[n];
  for(int i = 0; i < n; ++i) scanf("%d",&l[i]);
  int dis = 0;
  int answer = 0;
  for(int i = 0; i < n + 1; ++i){
    if(dis <= x) answer++;
    else break;
    dis += l[i];
  }
  printf("%d",answer);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#define REP(i,m,n) for(int i = (int) (m);i < (int) (n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

int x[5], y[5];
int X, Y;


int main() {

	rep(i, 4) {
		cin >> x[i];
		X += x[i];
	}
	rep(i, 4) {
		cin >> y[i];
		Y += y[i];
	}
	if (X >= Y) cout << X << endl;
	else cout << Y << endl;






	return 0;
}



Measured memory_bytes: 3092
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){

    ll N;
    cin >> N;
    ll ans = 100;
    vector<ll>X(N), Y(N);
    for(ll i = 0; i < N; i++){
        cin >> X[i] >> Y[i];
    }
    for(ll i = 0; i < N; i++){
        for(ll j = 0; j < N; j++){
            ll p = X[j] - X[i];
            ll q = Y[j] - Y[i];
            ll cnt = 0;
            vector<ll>flg(N, 0);
            for(ll k = 0; k < N; k++){
                if(flg[k])continue;
                queue<ll>Q;
                cnt++;
                flg[k] = 1;
                Q.push(k);
                while(!Q.empty()){
                    ll idx = Q.front();
                    Q.pop();
                    for(ll l = 0; l < N; l++){
                        if(flg[l])continue;
                        if(X[idx] + p == X[l] && Y[idx] + q == Y[l]){
                            flg[l] = 1;
                            Q.push(l);
                        }
                        if(X[idx] - p == X[l] && Y[idx] - q == Y[l]){
                            flg[l] = 1;
                            Q.push(l);
                        }
                        
                    }
                }
            }
            ans = min(ans, cnt);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
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();
if(a + b + c > 21){
 System.out.print("bust");
} else {
   System.out.print("win");
}
          }
}

Measured memory_bytes: 22608
r,g,b,n = map(int,input().split())

   

if r != 1 or g != 1:
 ans = 0
 for i in range(n//r +1):
    for j in range(n//g +1):
        if (n - i*r - j*g) < 0 :
            pass
        elif (n - i*r - j*g) % b == 0:
            ans += 1
 print(ans)

else:
    tmp = n // b
    ans =  0
    for i in range(tmp+1):
        ans += n - i + 1
    print(ans)  

Measured memory_bytes: 3064
#include<stdio.h>

main(){

  int i, j, n, q, count = 0, S[10000], T[500];

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

  scanf("%d", &q);
  for(i = 0;i < q;i++){
    scanf("%d", &T[i]);
    for(j = 0;j < n;j++){
      if(T[i] == S[j]){
	count++;
	break;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
}c(200005);

int main() {
	int N,K;
	cin >> N >> K;
	vector<int> A(N);
	for (int n = 0;n < N;++n) {
		cin >> A[n];
	}
	sort(A.begin(),A.end());
	mint ans = 0;
	for (int n = 0; n < N - K + 1; ++n) {
		ans += (mint)c(N - 1 - n,K - 1) *(A[ N - 1 - n] - A[0 + n]);
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 6696
N = int(input())
S = input()

L=["A", "B", "C", "D", "E", "F", "G", "H", "I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
A="ABCDEFGHIJKLMNOPQRSTUVWXYZ"

num=0
ans=""
for i in S:
    num=A.find(i) + N
    if num>25:
        num=num-26
    ans=ans+L[num]
print (ans)

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline

INF = float('inf')


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

    counter = 0
    while True:
        for i in range(len(A)):
            if A[i] % 2 == 0:
                A[i] /= 2
            else:
                print(counter)
                return
        counter += 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
D = gets.to_i
c = gets.split.map(&:to_i)
s = []
D.times do
  s << gets.split.map(&:to_i)
end

t = []
D.times do
  t << gets.to_i
end
ld = Array.new(26,0)
v = 0
(1..D).each do |day|
  sel = t[day-1] -1
  v += s[day-1][sel]
  ld[sel] = day
  26.times do |j|
    next if j == sel
    
    v -= c[j] * (day - ld[j])
  end
  puts v
end

Measured memory_bytes: 14264
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    """
    https://qiita.com/drken/items/4a7869c5e304883f539b#3-3-dfs-%E3%81%AE%E5%86%8D%E5%B8%B0%E9%96%A2%E6%95%B0%E3%82%92%E7%94%A8%E3%81%84%E3%81%9F%E5%AE%9F%E8%A3%85
    cf. https://atcoder.jp/contests/abc138/submissions/13273052
    """

    from collections import deque

    N= int(input())
    M=N-1  # 頂点数，辺数
    # グラフ入力受取 (ここでは無向グラフを想定)
    G = [[] for _ in range(N)]
    for i in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        G[a].append((b, i))
        G[b].append((a, i))

    seen = [False]*N
    res = [0]*M


    def dfs(G, v, pc):
        color = 1
        if color == pc:
            color += 1
        seen[v] = True
        stack = deque([(v,-1)])
        while stack:
            v,pc = stack.pop()
            color=1
            for next_v, edge_ind in G[v]:
                if seen[next_v]:
                    continue
                if color == pc:
                    color += 1
                res[edge_ind] = color
                seen[next_v] = True
                stack.append((next_v,color))
                color+=1

            

    # 頂点 0 をスタートとした探索
    dfs(G, 0, -1)
    print(max(res))
    for i in res:
        print(i)



resolve()

Measured memory_bytes: 68384
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
        String[] line = new String[num];
        String[][] s = new String[num][10];
        for(int i=0; i<num; i++){
          line[i] = sc.next();
          s[i] = line[i].split("");
        }
        int count = 0;
        int aNum = 0;
        int bNum = 0;
        int baNum= 0;
        int check = 0;
        for(int i=0; i<num; i++){
          for(int j=0; j<line[i].length()-1; j++){
            if(s[i][j].equals("A") && s[i][j+1].equals("B")) count++;
            if(j == 0 && s[i][j].equals("B")) {
              bNum++;
              check = 1;
            }
            if(j == line[i].length()-2 && s[i][j+1].equals("A")) {
              if(check == 1){
                baNum++;
                aNum++;
              }
              else aNum++;
            }
          }
          check = 0;
        }
        int plus = (aNum <= bNum) ? aNum : bNum;
        //if(aNum == num && bNum == num) plus--;
        if(baNum > 0 && baNum == aNum && baNum == bNum) plus -= 1;
		System.out.println(count+plus);
        //System.out.println(aNum);
        //System.out.println(bNum);
	}
}

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

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((a - 1) / d + 1 >= (c - 1) / b + 1)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}


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

int main() {
	vector<string> v;
	for(int i = 0; i < 8; i++) {
		string s;
		cin >> s;
		v.push_back(s);
	}

	for(int i = 1; i <= 3; i++) {
		cout << i * 90 << endl;
		for(int j = 0; j < 8; j++) {
			for(int k = 0; k < 8; k++) {
				char c;
				switch(i) {
					case 1: c = v[7 - k][j]; break;
					case 2: c = v[7 - j][7 - k]; break;
					case 3: c = v[k][7 - j]; break;
				}
				cout << c;
			}
			cout << endl;
		}
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using llint = long long;
using vint = vector<int>;

int main () {
    int a, b, c; cin >> a >> b >> c;
    if (a * c < b) cout << c << endl;
    else cout << b / a << endl;
}

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

int main() {
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	int common=min(X, Y);
	int S=common*min(A+B, 2*C);
	X -= common; Y -= common;
	S += X*min(A, 2*C) + Y*min(B, 2*C);
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 256
MOD = 10**9+7

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

asum = sum(a) % MOD
asq  = sum(x*x %MOD for x in a) %MOD

ans = (asum*asum - asq) %MOD * pow(2,MOD-2,MOD) %MOD
print(ans)

Measured memory_bytes: 31440
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string a;
    int x=0;
    cin>>a;
    if(a[0]=='1')x++;
    if(a[1]=='1')x++;
    if(a[2]=='1')x++;
    cout << x << endl;
}

Measured memory_bytes: 256
'use strict'
function Main(input) {
  const week = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'];
  const days = [7, 6, 5, 4, 3, 2, 1];
  let today = input.split("\n")[0];
  // console.log({ today });

  let num = week.indexOf(today);
  console.log(days[num]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(0);
    
    ll n , x;
    cin >> n >> x;
    
    ll d1=0;
    ll cnt =1;
    while(n--){
        ll ln;
        cin >> ln;
        ll dn;
        dn = d1 + ln;
         if (dn<=x)
        {
            d1 = dn;
            cnt++;
            // cout << dn << endl;
        }
        else
            d1 = dn;

    }
    cout << cnt << endl;
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define vec vector
const int INF=0x3f3f3f3f;
#define N int(5e5+5)

ll gcd(ll a,ll b){
	if(a<b)swap(a,b);
	while(a%b){
		ll t=a%b;
		a=b;
		b=t;
	}
	return b;
}
int main(){
	ios::sync_with_stdio(false);
	ll a,b;
	while(cin>>a>>b){
		ll g=gcd(a,b);
		ll lcm=g*(a/g)*(b/g);
		cout<<g<<' '<<lcm<<endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int K,X;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>K>>X;
	for(i=X-K+1;i<=X+K-1;i++) cout<<i<<" ";
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split()) 

ab = [list(map(int,input().split()))for _ in range(n)]
cd = [list(map(int,input().split()))for _ in range(m)] 

for a, b in ab:
  distance = [abs(a-c) + abs(b-d) for c,d in cd]
  print(distance.index(min(distance))+1)

Measured memory_bytes: 9188
// Date: 2020-08-28

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define D(x) cout << #x << " = " << x << endl;
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int a[2][N];
int pre[N], suf[N];

int main() {
    int n;
    scanf("%d", &n);
    rep(i, 0, 1) rep(j, 1, n) scanf("%d", &a[i][j]);
    rep(j, 1, n) pre[j] = pre[j-1] + a[0][j];
    per(j, n, 1) suf[j] = suf[j+1] + a[1][j];
    int ans = 0;
    rep(j, 1, n) {
        int tmp = pre[j] + suf[j];
        chkmax(ans, tmp);
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int[] arr = new int[N];
		int output = 0;
		for(int i = 0;i<N;i++)arr[i]=sc.nextInt();
		int temp = 0;
		if(0<=X)output++;
		for(int i = 0;i<N;i++) {
			temp+=arr[i];
			if(temp<=X)output++;
		}
		System.out.println(output);

	}

}


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

int main() {
  #define int long long
  int x;
  cin >> x;
  int a = 100;
  int count = 0;
  for (int i = 0; i < 10000; i++) {
    a = a + a / 100;
    count++;
    if (a >= x) {
      break;
    }
    
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()

int32_t main(){
	int l=0,r,u,d=0,n;
	cin>>r>>u>>n;
	int x,y,a;
	for(int i=1;i<=n;i++){
		cin>>x>>y>>a;
		switch(a){
			case 1:
				l = max(l,x);
				break;
			case 2:
				r = min(r,x);
				break;
			case 3:
				d = max(d,y);
				break;
			case 4:
				u = min(u,y);
				break;
		}
	}
	//cout<<l<<" "<<r<<" "<<d<<" "<<u<<"\n";
	cout<<max(0LL,u-d)*max(0LL,r-l);
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        int h, w;

        while (true)
        {
            string[] num = Console.ReadLine().Split(' ');
            h = int.Parse(num[0]);
            w = int.Parse(num[1]);

            if (h == 0 && w == 0)
            {
                break;
            }

            for (int i = 1; i <= h; i++)
            {
                for (int j = 1; j <= w; j++)
                {
                    if (j % 2 == 1 && i % 2 == 1)
                    {
                        Console.Write("#");
                    }
                    else if (j % 2 == 0 && i % 2 == 0)
                    {
                        Console.Write("#");
                    }
                    else
                    {
                        Console.Write(".");
                    }
                }
                Console.WriteLine("");
            }
            Console.WriteLine("");
        }
    }
}


Measured memory_bytes: 8912
#include <bits/stdc++.h>
#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)

typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;



int main() {

  ll s;
  cin >> s;
  ll sum = 0;
  REP1(i,s){
    REP1(j,s){
      REP1(k,s){
        ll a = gcd(i,j);
        ll b = gcd(a,k);
        sum += b;
      }
    }
  }

  
  cout << sum << endl;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<vector>
#include<algorithm>
#define N 100002
using namespace std;

int s[N],cur[N],f[N],l[N],r[N],c[N];
vector<int>g[N];
int main(){
	int n;scanf("%d",&n);
	for(int i=1,u,v;i<n;i++){
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for(int i=1;i<=n;i++)l[i]=-2e9,r[i]=2e9;
	int k;scanf("%d",&k);
	for(int i=1,x,y;i<=k;i++)
		scanf("%d%d",&x,&y),l[x]=r[x]=y;
	for(s[s[0]=1]=1;s[0];){
		int u=s[s[0]],v;
		if(cur[u]==g[u].size()){
			s[0]--;cur[u]=0;
			for(int i=0;i<g[u].size();i++)if((v=g[u][i])^f[u]){
				if(l[u]!=-2e9&&l[v]!=-2e9&&(l[u]^l[v]-1)&1)goto ed;
				if(r[u]!=2e9&&r[v]!=2e9&&(r[u]^r[v]+1)&1)goto ed;
				l[u]=max(l[u],l[v]-1);
				r[u]=min(r[u],r[v]+1);
			}
			if(l[u]>r[u])goto ed;
		}
		else if((v=g[u][cur[u]++])^f[u])s[++s[0]]=v,f[v]=u;
	}
	c[1]=r[1];
	for(s[s[0]=1]=1;s[0];){
		int u=s[s[0]--],v;
		for(int i=0;i<g[u].size();i++)if((v=g[u][i])^f[u])
			c[v]=c[u]+1>r[v]?c[u]-1:c[u]+1,s[++s[0]]=v;
	}
	printf("Yes\n");
	for(int i=1;i<=n;i++)printf("%d\n",c[i]);
	return 0;
	ed:printf("No");
}

Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << "\n"
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(b<a)a=b
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
constexpr int dx[] = {1, 0, -1,  0};
constexpr int dy[] = {0, 1,  0, -1};
constexpr char dir[4] = {'r', 'u', 'l', 'd'};
#define N 4
#define N2 16
#define LIMIT 100
int MDT[N2][N2];
struct Puzzle {
	int f[N2];
	int space, MD;
};
Puzzle state;
int limit;
vi path(LIMIT, 0);
int getAllMD(Puzzle pz) {
	int sum = 0;
	rep(i, 0, N2) {
		if(pz.f[i] == N2) continue;
		sum += MDT[i][pz.f[i] - 1];
	}
	return sum;
}
bool isSolved() {
	rep(i, 0, N2) if(state.f[i] != i + 1) return false;
	return true;
}
bool dfs(int depth, int prev) {
	if(state.MD == 0) return true;
	if(depth + state.MD > limit) return false;
	int sx = state.space / N;
	int sy = state.space % N;
	Puzzle tmp;
	int tx, ty;
	rep(r, 0, 4) {
		tx = sx + dx[r];
		ty = sy + dy[r];
		if(tx < 0 || tx >= N || ty < 0 || ty >= N) continue;
		if(max(prev, r) - min(prev, r) == 2) continue;
		tmp = state;
		state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
		state.MD += MDT[sx * N + sy][state.f[tx * N + ty] - 1];
		swap(state.f[tx * N + ty], state.f[sx * N + sy]);
		state.space = tx * N + ty;
		if(dfs(depth + 1, r)) { path[depth] = r; return true; }
		state = tmp;
	}
	return false;
}
string iterative_deepening(Puzzle in) {
	in.MD = getAllMD(in);
	string ans = "";
	for(limit = in.MD; limit <= LIMIT; ++limit) {
		state = in;
		if(dfs(0, -100)) {
			ans = "";
			rep(i, 0, limit) ans += dir[path[i]];
			return ans;
		}
	}
	return "unsolvable";
}
int main() {
	rep(i, 0, N2) {
		rep(j, 0, N2) {
			MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
		}
	}
	Puzzle in;
	rep(i, 0, N2) {
		cin >> in.f[i];
		if(in.f[i] == 0) {
			in.f[i] = N2;
			in.space = i;
		}
	}
	P(len(iterative_deepening(in)));
	return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#define rep(i,a,b) for(int i=(a); i<(b); i++)

using namespace std;

int w,h;
char m[22][22];
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int dfs(int y , int x){
  int rtn = 0;
  if(y < 0 || h <= y || x < 0 || w <= x || m[y][x] =='#')
    return rtn;
  m[y][x] = '#';
  rtn++;
  rep(i,0,4){
    rtn += dfs(y + dy[i] , x + dx[i]);
  }
  return rtn;
}

int main(){
  while(cin >> w >> h , w + h){
    int sx,sy;
    rep(i,0,h){
      rep(j,0,w){
        cin >> m[i][j];
        if(m[i][j] == '@'){
          sx = j;
          sy = i;
        }
      }
    }
    cout << dfs(sy , sx) << endl;
  }
  return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        1000005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}   

signed main()
{
    showoff;
    int n,ans = 0;
    string s;
    cin >> n >> s;
    s = '#'+s;
    vector<int>sr(n+5),sg(n+5),sb(n+5);
    RFOR(i,n,0){
        if(s[i] == 'R')sr[i] = 1;
        else if(s[i] == 'G')sg[i] = 1;
        else sb[i] = 1;
        sg[i] += sg[i+1];
        sr[i] += sr[i+1];
        sb[i] += sb[i+1];
    }
    FOR(i,1,n+1){
        FOR(j,i+1,n+1){
            if(s[i] == s[j])continue;
            set<int>st;
            st.insert(s[i]-'A'),st.insert(s[j]-'A');
            if(st.find('R'-'A') == st.end()){
                ans += sr[j+1];
                if(2*j-i <= n && s[2*j-i] == 'R')ans--;
            }
            if(st.find('G'-'A') == st.end()){
                ans += sg[j+1];
                if(2*j-i <= n && s[2*j-i] == 'G')ans--;
            }
            if(st.find('B'-'A') == st.end()){
                ans += sb[j+1];
                if(2*j-i <= n && s[2*j-i] == 'B')ans--;
            }
        }
    }
    cout << ans;
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ... 

Measured memory_bytes: 3696
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void) {
	int array[3];
	for (int i = 0; i < 3; i++)
		scanf("%d", &array[i]);
	for (int i = 2; i > 0; i--) {
		for (int j = 0; j < i; j++) {
			if (array[j] > array[j + 1]){
				int tmp = array[j];
				array[j] = array[j + 1];
				array[j + 1] = tmp;
			}
		}
	}
	cout << array[0] << " " << array[1] << " " << array[2] << endl;
	return 0;
}




Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(ll i=m;i<(int)(n);i++)
typedef long long ll;
typedef pair<ll,ll> pint;
 
 
int main(){
    ll n,k;cin>>n>>k;
    ll ans=0;
    ll MOD=1000000007;
    ll a;
    ll b;
    REP(i,k,n+2){
        b=((i-1)*i/2);
        a = n*i-b;
        ans+=a-b+1;
        //cout<<a<<" "<<b<<endl;
        //cout<<ans<<endl;
    }
    cout<<ans%MOD<<endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main()
{
    long long x, y;
    long long ans = 0;

    cin >> x >> y;

    if(x <= y)
    {
        if(x*y >= 0)
        {
            ans = abs(abs(x) - abs(y));
        }
        else
        {
            if(abs(x) < abs(y))
            {
                ans = 1 + y + x;
            }
            else
            {
                ans = 1 + abs(abs(x) - abs(y));
            }
        }
    }
    else
    {
        if(abs(x) < abs(y))
        {
            if(x < 0)
            {
                ans = 1 + abs(abs(y) - abs(x)) + 1;
            }
            else
            {
                ans = 1 + abs(abs(y) - abs(x));
            }
        }
        else
        {
            if(y <= 0)
            {
                ans = 1 + abs(abs(x) - abs(y));
            }
            else
            {
                ans = 1 + abs(abs(x) - abs(y)) + 1;
            }
        }
    }

    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 in=new Scanner(System.in);
		int M=50000000;
		while(in.hasNext())
		{
			int n=in.nextInt(), m=in.nextInt(),K=in.nextInt();
			double minmax=0;
			int cost[][]=new int[n+1][n+1];
			for(int i=0;i<=n;i++)
				Arrays.fill(cost[i], M);
			for(int i=0;i<=n;i++)
				cost[i][i]=0;
			String cap[]=new String[m];
			for(int i=0;i<m;i++)
			{
				int a=in.nextInt(),b=in.nextInt(),l=in.nextInt();
				cap[i]=a+" "+b+" "+l;
				cost[a][b]=l;
				cost[b][a]=l;
			}
			int fmo=in.nextInt();
			int startmo=fmo;
			if(K>1)
				for(int i=1;i<K;i++)
				{
					int nexmo=in.nextInt();
					cost[fmo][nexmo]=0;
					cost[nexmo][fmo]=0;
					fmo=nexmo;
				}
			int leng[]=new int[n+1];// minimum distance
			int v[] = new int[n+1];// decision flag

			int p=0;
			int start =startmo;
			for(int k=1;k<=n;k++)
			{
				leng[k]=M;
				v[k]=0;
			}
			leng[start]=0;
			for(int j=1;j<=n;j++)
			{
				int min=M;//最小の節点を探す
				for(int k=1;k<=n;k++)
				{
					if(v[k]==0&&leng[k]<min)
					{
						p=k;
						min=leng[k];
					}
				}
				v[p]=1;//確定フラグ
				for(int k=1;k<=n;k++) //pを経由してkに至長さがそれまでの最短経路より小さければ更新
					leng[k]=Math.min(leng[p]+cost[p][k], leng[k]);
			}
			for(int i=0;i<m;i++)
			{
				String ss[]=cap[i].split(" ");
				int a=Integer.valueOf(ss[0]);
				int b=Integer.valueOf(ss[1]);
				int cos=Integer.valueOf(ss[2]);
				double d=(leng[a]+leng[b]+cos)/2.0;
				minmax=Math.max(minmax, d);
			}
			System.out.println(Math.round(minmax));
		}
	}
}

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

int main()
{
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int ans;
  int X, Y;
  X = K - A;
  Y = X - B;
  if (X < 0)
  {
    ans = K;
  }
  else if (X <= B)
  {
    ans = A;
  }
  else if (Y <= C)
  {
    ans = A - Y;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define vll vector< ll >
//#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<int,int>
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//#define int unsigned long long
//#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long  
#define int long long
using namespace std;
//using ll = unsigned long long;
ll md=MD;
//ll M=1073741824;
ll M=1e9+7;
//ll exp(ll a,ll b){ll r=1;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(int a,int b){if(a<b)return a; return b;}
ll Max(int a,int b){if(a>b)return a; return b;}
ll powM(ll a,ll b){if(a==1) return 1;ll ans=1;while(b>0){if(b&1)ans=(ans*a)%M;a=(a*a)%M;b=b>>1;}return ans;}
ll power(ll a,ll b){if(a==1) return 1;ll ans=1;while(b>0){if(b&1)ans=(ans*a);a=(a*a);b=b>>1;}return ans;}
const int INF=1000000000000000000;

//always try to hack ur soln before submitting (penalty-50 wrong submission 50 min sochle isse aacha)
// Abe n*m ke grid main y ke coordinates m se akm hone chahiye na ke n se 

int32_t main()
{
	IOS;
	int t;
//	cin>>t;
	t=1;
	while(t--)
	{
		int n;
		cin>>n;
		int ac=0,re=0,tle=0,wa=0;
		for(int i=0;i<n;++i)
		{
			string s;
			cin>>s;
			if(s=="AC")++ac;
			else if(s=="RE")++re;
			else if(s=="TLE")++tle;
			else if(s=="WA")++wa;
		}
		cout<<"AC x "<<ac<<"\n"<<"WA x "<<wa<<"\n"<<"TLE x "<<tle<<"\nRE x "<<re<<"\n";
	}
}


Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
using namespace std;

const int maxn = 2e5 + 10;

int n, k, l, par1[maxn], par2[maxn];

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

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

void unite(int x, int y, int* par) {
	x = find(x, par);
	y = find(y, par);
	if (x != y) {
		par[x] = y;
	}
}

int main() {
	cin >> n >> k >> l;
	init();
	for (int i = 0, x, y; i < k; i++) {
		cin >> x >> y;
		unite(x, y, par1);
	}
	for (int i = 0, x, y; i < l; i++) {
		cin >> x >> y;
		unite(x, y, par2);
	}
	map<pair<int, int>, int>mp;
	for (int i = 1; i <= n; i++) {
		find(i, par1); find(i, par2);
	}
	for (int i = 1; i <= n; i++) {
		mp[{par1[i], par2[i]}]++;
	}
	for (int i = 1; i <= n; i++) {
		cout << mp[{par1[i], par2[i]}] << ' ';
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 13568
import std.stdio;

int[4] l, r;

void main(){
	double a, b;
	l[] = r[] = 0;
	while (readf("%s %s\n", &a, &b)) {
		set(l, a);
		set(r, b);
	}
	foreach (i; 0..4) writeln(l[i], " ", r[i]);
}

void set(int[] list, double a){
	if (a < 0.2) list[3]++;
	else if (a < 0.6) list[2]++;
	else if (a < 1.1) list[1]++;
	else list[0]++;
}

Measured memory_bytes: 1020
N, L, T = map(int, input().split())


ants = []
collision = 0
for _ in range(N):
    X, W = map(int, input().split())
    if W == 1:
        collision += (X+T) // L
        x1 = (X+T) % L
    else:
        collision += (X-T) // L
        x1 = (X - T) % L
    ants.append(x1)

collision %= N
ants.sort()
ants = ants[collision:] + ants[:collision]
for ant in ants:
    print(ant)

Measured memory_bytes: 8608
import sys

sys.setrecursionlimit(10**6) #再帰の回数制限を増やす
input = sys.stdin.readline


def add_num(i, total, parent=-1):
    """隣接リストを取り出して深さ優先探索
    自分より上層の total のカウント数と部分木の頂点としてのカウント数を足す"""
    for p in adj[i]:
        if p != parent:
            ans_lst[p] = total + tmp[p]
            add_num(p, total + tmp[p], i)
    return
    
    
N, Q = [int(i) for i in input().split()]

adj = [[] for _ in range(N)] # 隣接リスト
tmp = [0] * N # 部分木の根としてのカウント数 
ans_lst = [0] * N # 答えのリスト

# 隣接リストの作成
for _ in range(N - 1):
    a, b = [int(i) - 1 for i in input().split()]
    adj[a].append(b)
    adj[b].append(a)

# ｔｍｐリストの作成
for _ in range(Q):
    p, x = [int(i) for i in input().split()]
    tmp[p-1] += x

ans_lst[0] = tmp[0]
total = tmp[0]
add_num(0, total)

print(*ans_lst, sep=' ')


Measured memory_bytes: 280760
#include <stdio.h>
 int main(){
     int  s[200000][5];
     int n,i,j;
     int HP;
     int max;//切る攻撃の最大ダメージ
     int katana;
     int exdamage=0;//MAXダメージを超える投げダメージの和
     int exkatana=0;//投げる刀の数
     int result=0;
     int exmax;
     int memo;
     int k,l;
     int s2[100001];
     scanf("%d",&n);
     scanf("%d",&HP);
     
     for(i=0;i<n;i++)
     {
     	for(j=0;j<=1;j++)
     	{
     		scanf("%d",&s[i][j]);
     	}
     }
     
   for(i=0;i<n;i++)
   {
   	if(s[i][0]>max){
   		max=s[i][0];
   		}
   }
   for(i=0;i<n;i++){
   	
   	if(s[i][1]>=max){
   	exdamage=exdamage+s[i][1];
   	exkatana++;
    }	
   	
   	}
   
   	if(exdamage<=HP)
   	{
   	
   for(i=0;i<10000000000;i++){
    if(exdamage>=HP)
    {
    	result=result+exkatana;
    	printf("%d",result);
    	break;
    }
   	HP=HP-max;
   	result++;
   	if(HP<=0)
   	{
   		printf("%d",result);
   		break;
   	}
   	
   	}
   	
   	}else{
   	
   		exmax=0;
   		for(j=0;j<100010;j++){
   			l=1;
   		for(i=0;i<n;i++){
   			
   		if(s[i][1]>exmax){
   			l=1;
   			exmax=s[i][1];
   			s2[0]=i;
   		}else if(s[i][1]==exmax)
   		{
   		   s2[l]=i;
   		    l++;
   		}
   		
   }
   for(i=0;i<l;i++)
   {
   	HP=HP-exmax;
   	result++;
   	s[s2[i]][1]=0;
   	if(HP<=0)
   	{
   		printf("%d",result);
   		break;
   	}
   }
   exmax=0;
   if(HP<=0)
   {
   	break;
   }
   }
   }
   return 0;
 	}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372036854775807ll;

void solve()
  {
   int n;
   cin>>n;
   vector<int> adj(n+1,0);
   loop(i,2,n+1)
     {
      int x;
      cin>>x;
      adj[x]++;
      //adj[x].pb(i);
     }
   loop(i,1,n+1)
     cout<<adj[i]<<END;

  } 
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 

     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

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

int a[5];

int main(){
	rep(i,5) cin >> a[i];
	sort(a, a+5, greater<int>());
	rep(i,5){
		cout << a[i];
		if(i == 4) break;
		cout << " ";
	}
	cout << endl;
}

Measured memory_bytes: 1172
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	char b;
	in >> b;

	char ans;
	if (b == 'A') ans = 'T';
	if (b == 'T') ans = 'A';
	if (b == 'G') ans = 'C';
	if (b == 'C') ans = 'G';

	out << ans << std::endl;
}


Measured memory_bytes: 256
def examA():
    A, B, C = LI()
    S = A+B+C
    cur = 0
    for i in range(32):
        if A%2==1 or B%2==1 or C%2==1:
            break
        A = (S-A)//2
        B = (S-B)//2
        C = (S-C)//2
        cur +=1
    if cur==32:
        ans = -1
    else:
        ans = cur
    print(ans)
    return

def examB():
    N, M = LI()
    cur = [0]*N
    for i in range(M):
        a, b = LI()
        cur[a-1] +=1
        cur[b-1] +=1
    ans = "YES"
    for j in cur:
        if j%2==1:
            ans = "NO"
            break
    print(ans)
    return


def clear_maze(h,w,s,maze):
#    debug_print(maze)
    distance = [[inf]*w for _ in range(h)]
    def bfs():
        queue = deque()
        queue.append(s)
        distance[s[0]][s[1]] = 0
        while len(queue):
            y, x = queue.popleft()
            for i in range(4):
                nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]
                if (0<= nx <w and 0<= ny <h and maze[ny][nx] != '#'):
                    if distance[ny][nx]<=distance[y][x]+1:
                        continue
                    queue.append((ny, nx))
                    distance[ny][nx] = distance[y][x] + 1
        return distance
    return bfs()
def examC():
    H, W, K = LI()
    A = [SI() for _ in range(H)]
    sx = W-1; sy = H-1
    for i in range(H):
        for j in range(W):
            if A[i][j]=="S":
                sy = i; sx = j
                break
        if sy!=H-1 or sx!=W-1:
            break
    D = clear_maze(H,W,[sy,sx],A)
#    for v in D:
#        print(v)
    ans = inf
    for i in range(H):
        for j in range(W):
            if D[i][j]>K:
                continue
            cur = min((i+K-1)//K,(j+K-1)//K,(H+K-i-2)//K,(W+K-j-2)//K)
            ans = min(ans,cur+1)
    print(ans)
    return

def examD():
    def dfs(v, edges, n, visited, matched):
        for u in edges[v]:
            if u in visited:
                continue
            visited.add(u)
            if matched[u] == -1 or dfs(matched[u], edges, n, visited, matched):
                matched[u] = v
                return True
        return False
    N = I()
    V = [set()for _ in range(N)]
    for _ in range(N-1):
        a, b = LI()
        a -= 1; b -= 1
        V[a].add(b)
        V[b].add(a)
    cnt = 0
    matched = [-1] * N
    for s in range(N):
        cnt += dfs(s, V, N, set(), matched)
    #print(cnt)
    if cnt<N:
        print("First")
    else:
        print("Second")
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = 10**18

if __name__ == '__main__':
    examD()


Measured memory_bytes: 38056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
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()
{
    int N, X, Y;
    cin >> N >> X >> Y;
    --X, --Y;
    vector<int> res(N, 0);
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            int d = min({abs(i - j), abs(i - X) + abs(j - Y) + 1,
                         abs(i - Y) + abs(j - X) + 1});
            res[d]++;
        }
    }

    for (int d = 1; d < N; ++d) cout << res[d] << endl;

    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
using namespace std;
#define MAX 21

int main(){
  int n;

  while(cin >> n,n){
    int field[MAX][MAX]={{0}},a,b;
    while(n--){
      cin >> a >> b;
      field[a][b] = 1;
    }
    cin >> n;
    int x = 10 ,y = 10 , c = field[x][y],dis;  field[x][y] = 0;
    char order;
    const int dx[] = {-1,0,1,0} ,dy[] = {0,-1,0,1};
    int nx,ny;

    while(n--){
      cin >> order >> dis;
      for(int i = 0 ; i < dis ; i++){
	switch(order){
	case 'N':
	  nx = x + dx[3];
	  ny = y + dy[3];
	  y++;
	  break;
	case 'S':
	  nx = x + dx[1];
	  ny = y + dy[1];
	  y--;
	  break;
	case 'W':
	  nx = x + dx[0];
	  ny = y + dy[0];
	  x--;
	  break;
	case 'E':
	  nx = x + dx[2];
	  ny = y + dy[2];
	  x++;
	  break;
	}
	field[nx][ny] = 0;
      }
    }
    int cnt = 0;    
    for(int i = 0 ; i < 20 ; i++){
      for(int j = 0 ; j < 20 ; j++){
	if(field[i][j]) cnt++;
      }
    }
    if(cnt) cout << "No" << endl;
    else cout << "Yes" << endl;
  }

  return 0;
}
    

Measured memory_bytes: 1152