akhauriyash/Code-Regression huggingface dataset:
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(a,p);
    cout << (a*3+p)/2 << nn;
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int N = 0;
  long long int ans = 0;
  cin >> N;
  for(long long int n = 1; n < N + 1; n++){
    if( n % 3 != 0 && n % 5 != 0){
      ans += n;
    }
  }
  cout << ans;
}

Measured memory_bytes: 3648
import sys

l = []
for i in sys.stdin:
    l.append(i.split())

for i in range(0,len(l)):
    if l[i][0] == '0' or l[i][1] == '0':
        continue
    for j in range(0,int(l[i][0])):
        if j == 0 or j == int(l[i][0])-1:
            print("#" * int(l[i][1]))
        else:
            print("#",end='')
            print("." * (int(l[i][1])-2),end='')
            print("#")
    print()


Measured memory_bytes: 5636
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K, L, PQ, RS):
    ans = 0
    gr = defaultdict(list)
    for p, q in PQ:
        gr[p].append(q)
        gr[q].append(p)

    gt = defaultdict(list)
    for r, s in RS:
        gt[r].append(s)
        gt[s].append(r)

    ccr = {}
    unused = set(gr.keys())
    while unused:
        q = [unused.pop()]
        con = set([])
        while q:
            v = q.pop()
            con.add(v)
            for u in gr[v]:
                if u in unused:
                    q.append(u)
                    unused.remove(u)
        for v in con:
            ccr[v] = con

    cct = {}
    unused = set(gt.keys())
    while unused:
        q = [unused.pop()]
        con = set([])
        while q:
            v = q.pop()
            con.add(v)
            for u in gt[v]:
                if u in unused:
                    q.append(u)
                    unused.remove(u)
        for v in con:
            cct[v] = con

    cache = {}

    def cc(t, r):
        k = (id(t), id(r))
        if k not in cache:
            cache[k] = len(t & r)
        return cache[k]

    ans = []
    for i in range(1, N+1):
        if i in cct and i in ccr:
            a = cc(cct[i], ccr[i])
        else:
            a = 1
        ans.append(a)
    return " ".join(map(str, ans))


def main():
    N, K, L = read_int_n()
    PQ = [read_int_n() for _ in range(K)]
    RS = [read_int_n() for _ in range(L)]

    print(slv(N, K, L, PQ, RS))


if __name__ == '__main__':
    main()


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

int main() {
  char c;
  cin >> c;

    switch(c) {
      case 'a' :
      case 'e' :
      case 'i' :
      case 'o' :
      case 'u' :
      cout << "vowel";
        break ;
      default :
      cout << "consonant";
    }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, int>;

int main() {
    int n, W;
    cin >> n >> W;
    vector<ll> w(n), v(n);
    rep(i, n)cin >> w[i] >> v[i];
    vector<vector<ll>> c(4);
    c[0].push_back(v[0]);
    for(int i = 1; i < n; i++)c[w[i]-w[0]].push_back(v[i]);
    rep(i, 4)sort(c[i].begin(), c[i].end(), greater<ll>());

    ll ans = 0;
    rep(i, c[0].size()+1)rep(j, c[1].size()+1)rep(k, c[2].size()+1)rep(l, c[3].size()+1){
        ll weight = i*w[0]+j*(w[0]+1)+k*(w[0]+2)+l*(w[0]+3);
        if(weight > W)continue;
        ll sum = 0;
        for(int ii = 0; ii < i; ii++)sum += c[0][ii];
        for(int jj = 0; jj < j; jj++)sum += c[1][jj];
        for(int kk = 0; kk < k; kk++)sum += c[2][kk];
        for(int kk = 0; kk < l; kk++)sum += c[3][kk];
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

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

int main(){
    ipi(N);
    vector<int> H(N);
    rep(i,N)cin >>H[i];

    int ans=0,a=0;
    rep(i,N-1){
        if(H[i]>=H[i+1]){
            a++;
        }
        else a = 0;
        if(ans < a)ans = a;
    }
    cout << ans;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int k[10000000];
int main(){
  string s;
  int n,ans=1;
  cin>>s;
  if(s=="Sunny") cout<<"Cloudy\n";
  if(s=="Cloudy") cout<<"Rainy\n";
  if(s=="Rainy") cout<<"Sunny\n";
  return(0);
}


Measured memory_bytes: 256
from collections import defaultdict
n,k=map(int,input().split())
d=defaultdict(int)
for _ in range(n):
  a,b=map(int,input().split())
  d[a]+=b
s=sorted(d.items(), key=lambda x:x[0])
l=0
for i,v in s:
  l+=v
  if l>=k:
    print(i)
    break
  

Measured memory_bytes: 15324
#include<stdio.h>

int main(){
  int flag[100001]={},c[100001]={};
  int i,j;
  int n,l,r,cnt=0;
  flag[0]=flag[1]=1;
  for(i=0;i<=100000;i++){
    if(flag[i]==0){
      for(j=2*i;j<=100000;j+=i) flag[j]=1;
    }
  }  
  for(i=3;i<=100000;i+=2) if(flag[i]==0&&flag[(i+1)/2]==0) c[i]++;
  for(i=3;i<=100000;i++) c[i]+=c[i-1];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&l,&r);
    printf("%d\n",c[r]-c[l-1]);
  }
}

Measured memory_bytes: 1280
#include <iostream> 
#include <string> 
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <map> 
#include <queue> 
#include <set> 
#include <stack>  
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 

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

int main(){
    int n;
    cin >> n;
    cout <<  double (n - n / 2) / n << endl;
}


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

int main() {

  int a;
  cin >> a;
  double sum = 0;
  
  rep(i,a) {
    double x;
    cin >> x;
    sum += 1/x;
  }
  
  cout << 1/sum << endl;  

}


Measured memory_bytes: 256
n = int(input())
num_list = [int(i) for i in input().split()]
 
answer = "Yes"
 
for i in range(n-1):
  if num_list[i] - num_list[i+1] >= 2:
    answer = "No"
    break
  elif num_list[i] - num_list[i+1] >= 1:
    num_list[i+1] += 1
    
print(answer)

Measured memory_bytes: 14224
import math

menu = [int(input()) for i in range(5)]
last_menu_index = min([[i, x % 10 ] for i, x in enumerate(menu) if x % 10 != 0 ]+[[123,123]], key=lambda x: x[1])[0]
print(sum([math.ceil(x / 10) * 10 if last_menu_index != i else menu[last_menu_index] for i, x in enumerate(menu)]))


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
	int n;
	cin >> n;
	cout << n * 800 - n / 15 * 200 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 405;
const int mod = 1e9+7;

inline int mul(int a, int b){
	return a*1ll*b%mod;
}
inline int add(int a ,int b){
	a += b;
	if(a >= mod) a -= mod;
	return a;
}
int power(int x , int y){
	int res = 1;
	while(y){
		if(y&1)
			res = mul(res , x);
		x = mul(x , x);
		y >>= 1;
	}
	return res;
}
int A[N] , B[N];

int dp[N][N]; //number of ways to divide j candies to first i students

int main(){
	fio; cout<<fixed<<setprecision(25);	
	int n , c; cin >> n >> c;

	for(int i = 1;i <= n ; ++i){
		cin >> A[i];
	}
	for(int i =1 ;i <= n ; ++i){
		cin >> B[i];
	}
	dp[0][0] = 1;
	for(int i =1 ;i <= n; ++i){
		for(int j = 0;j <= c ; ++j){
			//number of candies to curr student;
			int curr = 0;
			for(int k = A[i] ; k <= B[i] ; ++k)
				curr = add(curr , power(k , j));

			for(int k = j; k <= c ; ++k){
				dp[i][k] = add(dp[i][k] , mul(dp[i-1][k-j] , curr));
			}
		}
	}
	cout << dp[n][c] << endl;

	return 0;
}


Measured memory_bytes: 896
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n, q = MAP()
s = STR()
arr = [1 if s[i] + s[i + 1] == 'AC' else 0 for i in range(n - 1)]
arr2 = [[0, False] for _ in range(n - 1)]
arr2[0] = [arr[0], True if arr[0] == 1 else False]
for i in range(1, n - 1):
    arr2[i][0] = arr2[i - 1][0] + arr[i]
    arr2[i][1] = True if arr[i] == 1 else False
for _ in range(q):
    l, r = MAP()
    print(arr2[r - 2][0] - arr2[l - 1][0] + arr2[l - 1][1])


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

using namespace std;

int main(void) {
	long long H, W;
	cin >> H >> W;
	if(H == 1 || W == 1) {
		cout << "1\n";
		return 0;
	}
	long long ans;
	long long a = H % 2;
	long long b = W % 2;
	if (a == 0 || b == 0) {
		ans = H * W / 2;
	} else {
		ans = (H * W + 1) / 2;
	}
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 256
while True:
    h,w = tuple([int(x) for x in raw_input().split(" ")])
    if h==0 and w==0: break
 
    for ih in range(h):
        if ih==0 or ih==h-1 or w <= 2: print "#" * w
        else: print "#" + "." * (w-2) + "#"
 
    print ""

Measured memory_bytes: 6268
import sys

N,K=map(int, sys.stdin.readline().split())
A=map(int, sys.stdin.readline().split())
A.sort()

mod=10**9+7
fact, inv_fact = [1], [1]
fact_tmp = 1
for i in range(1, N+1):
    fact_tmp *= i
    fact_tmp %= mod
    fact.append(fact_tmp)
    inv_fact.append(pow(fact_tmp, mod-2, mod))
 
 
def ncr(n,r):
	if n < 0 or r < 0 or n < r:	return 0
	else:	return (fact[n] * inv_fact[r] * inv_fact[n-r]) %mod

NCR=[]
for i in range(N-1):
    NCR.append(ncr(i,K-2))

RUISEKI_NCR=[0]
for x in NCR:
    RUISEKI_NCR.append(RUISEKI_NCR[-1]+x)

total_max=0
for a,x in zip(A,RUISEKI_NCR):
    total_max+=a*x


total_min=0
for a,x in zip(A,RUISEKI_NCR[::-1]):
    total_min+=a*x

print (total_max-total_min)%mod


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

using namespace std;

int main(void){
	int a,b,c;
	long ans;
	cin >> a;
	cin >> b;
	if(a > 8 || b > 8){
		cout << ":(" << endl;
	}else{
		cout << "Yay!" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
/*16D8103005J 相良和希 ayachi0117 C++*/
#include<iostream>
#include<string>
#include<queue>
int main(){
	
	int n,q,a;
	std::cin>>n;
	std::cin>>q;
	std::string na;
	int tim,now=0;
	
	std::queue<std::string> name;
	std::queue<int> time;
	
	for(int i=0;i<n;i++){
		std::cin>>na;
		std::cin>>tim;
		name.push(na);
		time.push(tim);
	}
	
	while(name.empty()==0){
		
		if(time.front()<=q){
			now+=time.front();
			std::cout<<name.front()<<" "<<now<<"\n";
			name.pop();
			time.pop();
		}else{
			now+=q;
			name.push(name.front());
			a=time.front()-q;
			time.push(a);
			name.pop();
			time.pop();
		}
	}
	return 0;
}


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

int main(){
    string a,b,c;
    cin >> a >> b;
    c = a + b;
    int res;
    res = stoi(c);
    bool flag = false;
    for(int i=1;i<=1000;i++){
        if(res == i*i){
            flag = true;
            break;
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.math.*

fun main(args: Array<String>) {
    val (x, a, b) = readInputLine().split(" ").map { it.toInt() }
    
    println(if (Math.abs(x - a) < Math.abs(x - b)) "A" else "B")
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 35952
S = input()
T = input()

lens = len(S)
S = S
dic1,dic2 = {},{}

ch = 0
for i in range(lens):
    dic1[S[i]] = ''
    dic2[T[i]] = ''

for i in range(lens):
    if dic1[S[i]] == '' or dic1[S[i]] == T[i]:
        dic1[S[i]] = T[i]
    else:
        ch = 1
    if dic2[T[i]] == '' or dic2[T[i]] == S[i]:
        dic2[T[i]] = S[i]
    else:
        ch = 1

for k1 in dic1.keys():
#    print(k1, '->', dic2[dic1[k1]])
    if dic2[dic1[k1]] != k1:
        ch = 1

if ch == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX =510000;
int main(){
  string S;
  cin >>S;
  if(S[1]=='B'){cout<<"ARC";}
  else{cout<<"ABC";}
}

Measured memory_bytes: 3628
#!/usr/bin/env python3

MOD = 10**9
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

S = list(input())

R = []

for s in reversed(S):
    R.append(s)

ans = True

N = len(S)
h = N//2
ni = (N-1)//2
h2 = ni//2
S2 = S[0:ni]

san = (N+3)//2 - 1
h3 = san//2
S3 = S[san:]

if S[0:h] != R[0:h]:
    print('No')
    exit()


R2 = []
for s in reversed(S2):
    R2.append(s)


if S2 != R2:
    print('No')
    exit()

R3 = []
for s in reversed(S3):
    R3.append(s)


if S3 != R3:
    print('No')
    exit()

print('Yes')


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

ll knapsack(vector<vector<ll> >&dp, ll weight[], ll value[], ll i, ll w){
	if(i<0){
		return 0;
	}
	if(w==0){
		return 0;
	}
	if(dp[i][w]!=-1){
		return dp[i][w];
	}

	ll op1 = knapsack(dp,weight,value, i-1, w);
	ll op2 = 0;
	
	if(weight[i]<=w){
		op2 = knapsack(dp,weight,value, i-1, w-weight[i]) + value[i];
	}

	dp[i][w] = max(op1,op2);
	return dp[i][w];
}

int main(){
	ll n,w;
	cin>>n>>w;
	ll weight[n], value[n];

	for(int i=0;i<n;i++){
		cin>>weight[i]>>value[i];
	}

	vector<vector<ll> >dp(n,vector<ll>(w+1,-1));

	cout<<knapsack(dp, weight, value, n-1, w)<<"\n";
}

Measured memory_bytes: 79360
#include<stdio.h>
long gcd2(long a, long b){
	long t;
	if(a<b){
		t = a;
		a = b;
		b = t;
	}
	t = a % b;
	while(t!=0){
		a = b;
		b = t;
		t = a % b;
	}
	return b;
}
long n, x;
int main(void){
  scanf("%ld%ld", &n, &x);
  printf("%ld\n", (n-gcd2(n,x))*3);
}


Measured memory_bytes: 128
import collections

N, K, Q = map(int, input().split())

lst = [input() for i in range(Q)]

c = dict(collections.Counter(lst))
for i in range(N):
  if (str(i+1) not in c):
    if (K - Q <= 0):
      print('No')
    else:
      print('Yes')
  else:
    if (K + c[str(i+1)] - Q <= 0):
      print('No')
    else:
      print('Yes')

Measured memory_bytes: 70616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, m;
	cin >> n >> m;
	if(m == n){
		print("Yes")
	}
	else{
		print("No")
	}
	return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

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

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD = 1000000007
INF = float("inf")

sys.setrecursionlimit(1000000)

def main():
    H, W, M = LI()
    hw = LIR(M)

    s = set(h + w * (10 ** 6) for h, w in hw)

    ch = Counter(i for i, _ in hw)
    cw = Counter(j for _, j in hw)
    _, maxcy = ch.most_common(1)[0]
    _, maxcx = cw.most_common(1)[0]

    ans = maxcy + maxcx - 1

    lh = [k for k, v in ch.items() if v == maxcy]
    lw = [k for k, v in cw.items() if v == maxcx]

    for h in lh:
        for w in lw:
            if not h + w * (10 ** 6) in s:
                print(ans + 1)
                return
    print(ans)




if __name__ == '__main__':
    main()

Measured memory_bytes: 217704
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 55;

int n, m;
vector <int> g[MAXN];
int p[MAXN];
int tin[MAXN], tout[MAXN];
int tm;
long long q[MAXN];
map < pair<int, int>, int> edges;
int eNum;
long long ans;

void dfs(int v, int par = -1) {
  p[v] = par;
  tm++;
  tin[v] = tm;
  for (int to : g[v]) {
    if (to != par) {
      edges[{min(v, to), max(v, to)}] = eNum;
      eNum++; 
      dfs(to, v);
    }
  }
  tm++;
  tout[v] = tm;
}

bool isPar(int a, int b) {
  return tin[a] <= tin[b] && tout[a] >= tout[b];
}

int getBit(long long x, int pos) {
  return (x & (1ll << pos)) > 0 ? 1 : 0;
}

int main() { 

  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int from, to;
    scanf("%d %d", &from, &to);
    from--; to--;
    g[from].push_back(to);
    g[to].push_back(from);
  }

  dfs(0);

  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--; b--;
    while (!isPar(a, b)) {
      int edge = edges[{min(p[a], a), max(p[a], a)}];
      q[i] |= (1ll << edge);
      a = p[a];
    }
    while (b != a) {
      int edge = edges[{min(p[b], b), max(p[b], b)}];
      q[i] |= (1ll << edge);
      b = p[b];
    }
  }

  for (int mask = 0; mask < (1 << m); mask++) {
    long long total = 0;
    for (int i = 0; i < m; i++) {
      if (getBit(mask, i) == 1) {
        total |= q[i];
      }
    }
    long long cnt = __builtin_popcountll(total);
    long long cur = 1ll << (n - 1 - cnt);
    if (__builtin_popcount(mask) % 2 == 0) {
      ans += cur;
    } else {
      ans -= cur;
    }
  }

  // cout << (1ll << (n - 1)) - ans << endl;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
using namespace std;
int mod(int n)
{
	if(n>=0) return n;
	return -1*n;
}
int mini(int a, int b)
{
    if(a<b) return a;
    return b;
}
int cost3(int n, int h[], int k)
{
	int a[n],i;
	for(i=0;i<n;i++)
		a[i] = INT_MAX;
	if(n==1)
		return 0;
	if(n==2)
		return mod(h[0]-h[1]);
	a[n-1]=0;
	a[n-2]=mod(h[n-1]-h[n-2]);
	for(i=n-3;i>=0;i--)
		for(int j = i+1;j<min(n,i+k+1);j++)
			a[i] = mini(a[i],mod(h[i]-h[j])+a[j]);
	return a[0];
}

int main()
{
	int n,k;
	cin >> n >> k;
	int i,h[n];
	for(i=0;i<n;i++)
		cin >> h[i];
	cout << cost3(n,h,k);
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
#define pb push_back
#define __V vector
#define all(x) x.begin(), x.end()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}
template<typename X, typename Y>
istream& operator>>(istream& in, pair<X, Y> &a) {
	in >> a.first >> a.second;
	return in;
}
template<typename T>
void getv(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv(vector<T>& v, int n, Ns ... ns) {
	v.resize(n);
	for (auto& i : v)
		getv(i, ns...);
}
template<typename T>
void getv1(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv1(vector<T>& v, int n, Ns ... ns) {
	v.resize(n + 1);
	for (int i = 1; i <= n; i++)
		getv(v[i], ns...);
}
#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
inline void getch(char &x) {
	while (x = getchar_unlocked(), x < 33) {
		;
	}
}
inline void getstr(string &str) {
	str.clear();
	char cur;
	while (cur = getchar_unlocked(), cur < 33) {
		;
	}
	while (cur > 32) {
		str += cur;
		cur = getchar_unlocked();
	}
}
template<typename T> inline bool sc(T &num) {
	bool neg = 0;
	int c;
	num = 0;
	while (c = getchar_unlocked(), c < 33) {
		if (c == EOF)
			return false;
	}
	if (c == '-') {
		neg = 1;
		c = getchar_unlocked();
	}
	for (; c > 47; c = getchar_unlocked())
		num = num * 10 + c - 48;
	if (neg)
		num *= -1;
	return true;
}
typedef unsigned long long ull;
typedef long long ll;
typedef float ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
using AntonTsypko = void;
using arsijo = AntonTsypko;
using god = arsijo;
uniform_real_distribution<double> double_dist(0, 1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
	doin();
	ll n;
	cin >> n;
	cout << 3*n*n;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 1010;

int k,a,b;

int32_t main() {
	FAST
	cin >> k >> a >> b;
	for (int i =a;i<=b;i++) {
		if (i%k == 0) {
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
	
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
using namespace std;

int main() {
	IOS;
	int sh;
	cin >> sh; 
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); ++i) {
		int x = (s[i] - 'A' + sh) % 26; 
		cout << (char)(x + 'A');
	}
    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}

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

int a[100010];
map<int, int> cnt;
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) cin >> a[i];

  REP(i, n) cnt[a[i]]++;

  int res = 0;
  for(auto i: cnt) {
    if(i.second < i.first) res += i.second;
    else if(i.second > i.first) res += i.second - i.first;
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 7040
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        int num = int.Parse(ReadLine());
        string[] list = ReadLine().Split(' ');
        int[] lisi = new int[num+10];
        lisi[0] = 3;
        long ans = 1;
        for(int i=1;i<=num;i++){
            int k = int.Parse(list[i-1])+1;
            lisi[k]++;
            ans*= lisi[k-1]-lisi[k]+1;
            ans%= 1000000007;
        }
        WriteLine(ans);
    }
}


Measured memory_bytes: 18784
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    int n;cin>>n;
    vector<int> v[n];
    rep(i,0,n)rep(j,0,26)v[i].push_back(0);
    map<vector<int>,int> mp;
    ll ans=0;
    rep(i,0,n){
        string s;cin>>s;
        rep(j,0,10)v[i][s[j]-'a']++;
        ans+=mp[v[i]];
        mp[v[i]]++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 37248
#include<iostream>
#include<cstdio>
#include<cmath>
#define Point Vector
using namespace std;
class Vector
{
public:
	double x;
	double y;
	Vector(double x=0,double y=0):x(x),y(y){}
	Vector operator +(Vector &p)
	{
		return Vector(x + p.x, y + p.y);
	}
	Vector operator -(Vector &p)
	{
		return Vector(x - p.x, y - p.y);
	}
	Vector operator *(double k)
	{
		return Vector(k*x,k*y);
	}
	double abs(Vector &p)
	{
		return sqrt(p.x*p.x + p.y*p.y);
	}
	double dot(Vector &p1, Vector &p2)
	{
		return p1.x*p2.x + p1.y*p2.y;
	}
	Point projection(Point p1, Point p2)
	{
		Vector p1p(x - p1.x, y - p1.y);
		Vector p1p2(p2.x - p1.x, p2.y - p1.y);
		double pj = dot(p1p, p1p2) / abs(p1p2);
		Vector p1x = p1p2 * (pj / abs(p1p2));
		Point x = p1x + p1;
		return x;
	}
};
int main()
{
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	Point p1(x1, y1);
	Point p2(x2, y2);
	int q;
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		double x, y;
		cin >> x >> y;
		Point p(x, y);
		Point res = p.projection(p1, p2);
		printf("%.10f %.10f\n", res.x, res.y);
	}
}


Measured memory_bytes: 3256
s = input()
t = input()
n, m = len(s), len(t)

for i in range(n - m, -1, -1):
    match = True
    for j in range(m):
        if s[i + j] != '?' and s[i + j] != t[j]:
            match = False
            break
    if match:
        print(s[:i].replace('?', 'a') + t + s[i + m:].replace('?', 'a'))
        exit()
print("UNRESTORABLE")


Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    string s; cin >> s;
    int w = 0, e = 0;
    for(int i=0; i<n; ++i){
        if(s[i]=='W'){w++;}
    }
    e = n-w;
    int nw = 0, ne = e;
    int mi = INT32_MAX; int c;
    for(int i=0; i<n; ++i){
        if(s[i]=='W' && i>0){nw++;}
        if(s[i]=='E' && i>0){ne--;}
        int pen = nw + ne; 
        if(mi>pen){mi = pen; c=i;}
    }
    int res = 0; //cout << "c:" << c << endl;
    for(int i=0; i<n; ++i){
        if(s[i]=='W' && i<c){res++;}
        if(s[i]=='E' && i>c){res++;}
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

typedef struct edge
{
    int to,weight;
    edge(int t,int w)
    {
        to=t;weight=w;
    }
}edge;

const int N=1e4+10;
vector<edge> G[N];

void add(int s,int t,int w)
{
    G[s].push_back(edge(t,w));
    G[t].push_back(edge(s,w));
}

int height[N];

void getHeight(int v,int p)
{
    height[v]=0;
    for(int i=0;i<G[v].size();i++)
    {
        edge e=G[v][i];
        if(p!=e.to)
        {
            getHeight(e.to,v);
            height[v]=max(height[v],height[e.to]+e.weight);
        }
    }
}

int ans[N];
void solve(int v,int height_p,int p)
{
    vector<pair<int,int> > res;
    res.push_back(make_pair(0,-1));
    for(int i=0;i<G[v].size();i++)
    {
        edge e=G[v][i];
        if(p==e.to)
        {
            res.push_back(make_pair(height_p+e.weight,e.to));
        }else
        {
            res.push_back(make_pair(height[e.to]+e.weight,e.to));
        }
    }
    sort(res.rbegin(),res.rend());
    ans[v]=res[0].first;
    for(int i=0;i<G[v].size();i++)
    {
        edge e=G[v][i];
        if(p!=e.to)
        {
            int tmp=(e.to==res[0].second?res[1].first:res[0].first);
            solve(e.to,tmp,v);
        }
    }
}

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

    for(int i=1;i<n;i++)
    {
        int s,t,w;
        cin>>s>>t>>w;
        add(s,t,w);
    }

    getHeight(0,-1);
    solve(0,0,-1);

    for(int i=0;i<n;i++)
    {
        cout<<ans[i]<<endl;
    }

    return 0;
}



Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch CountBalls | diff CountBalls.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address CountBalls.cpp && ./a.out

/*
 
 3/8/2020
 
 20:33-
 
 */

LL N,A,B;

void solve() {
  LL x=N/(A+B);

  LL res=x*A+min(A,N%(A+B));
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>A>>B;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
a=input()
b=["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"]
c=["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"]
t=0
for i in range(26):
    if a==b[i]:
        t+=1
if t==1:
    print("A")
else:
    print("a")

Measured memory_bytes: 61752
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 4001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,K;
    cin >> n >> K;
    vector<LP> v(n);
    rep(i,n) cin >> v[i].first >> v[i].second;
    sort(all(v));
    ll ans = linf;
    rep(i,n) rep(j,n) {
        if(i >= j) continue;
        if(j-i+1 < K) continue;
//        cout << i << " " << j << endl;
        vector<ll> y;
        rep2(k,i,j+1) y.pb(v[k].second);
        sort(all(y));
//        for(int ni : y) cout << ni << endl;
        ll mn = linf;
        rep(k,j-i+1-K+1) {
            chmin(mn,y[k+K-1]-y[k]);
        }
//        cout << mn << endl;
        chmin(ans,mn*(v[j].first-v[i].first));
    }
//    rep(i,n) cout << v[i].first << " " << v[i].second << endl;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int d;
  cin >> d;
  if (d == 25) {
    cout << "Christmas" << endl;
  } else if (d == 24) {
    cout << "Christmas Eve" << endl;
  } else if (d == 23) {
    cout << "Christmas Eve Eve" << endl;
  } else {
    cout << "Christmas Eve Eve Eve" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

d = defaultdict(int)
N = int(input())

for n in range(1, N + 1):
    n = str(n)

    a = n[0]
    b = n[-1]

    d[(a, b)] += 1


s = 0
for i in range(10):
    for j in range(10):

        s += d[(str(j), str(i))] * d[(str(i), str(j))]

print(s)


Measured memory_bytes: 3316
class Tree:
    nodes = []
    def __init__(self, root = None):
        None
    def insert(self, label, children = []):
        if children != []:
            for i in children:
                self.nodes[label].children.append(self.nodes[i])
                self.nodes[i].parent = self.nodes[label]
                self.nodes[i].type_ = "internal node"
    def depth(self, node):
        if node.children == []:
            node.type_ = "leaf"
        else:
            for i in node.children:
                i.depth = node.depth + 1
                self.depth(i)

class Node:
    def __init__(self, label, children = []):
        self.label = label
        self.type_ = "root"
        self.depth = 0
        self.parent = -1
        self.children = [] # self.children = childrenにするとハマる

tree = Tree()
n = int(input())
for i in range(n):
    tree.nodes.append(Node(i))
for i in range(n):
    children = []
    label, num, *children = map(int, input().split())
    tree.insert(label, children)
for i in tree.nodes:
    if i.parent == -1:
        tree.depth(i)
        None
if n == 1:
    tree.nodes[0].type_ = "root"
for i in tree.nodes:
    print("node {0:}: parent = {1:}, depth = {2:}, {3:}, ".\
            format(i.label, i.parent if i.parent == -1 else i.parent.label,\
            i.depth, i.type_), end = "")
    print([i.label for i in i.children])


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

typedef pair<int, int> P;

int main() {
    for(int N, M; cin >> N >> M, N || M; ) {
        vector<P> data;
        int s = 0;
        for(int i = 0; i < N; i++) {
            int d, p;
            cin >> d >> p;
            data.push_back(P(p, d));
            s += p * d;
        }
        sort(data.rbegin(), data.rend());
        for(int i = 0; i < N; i++) {
            s -= min(data[i].second, M) * data[i].first;
            M -= min(data[i].second, M);
        }
        cout << s << endl;
    }
}

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

int main() {
  int64_t a,b,c;
  cin>>a>>b;
  if (a==1&&b==1) c=1;
  else if(a==1||b==1) c=a*b-2;
  else c=(a-2)*(b-2);
  cout << c << endl;
}


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

x = [0 for i in range(n-1)]
y = [0 for i in range(n-1)]
num = sum(lst)
x[0] = lst[0]
y[0] = num-lst[0]

for i in range(1,n-1):
    x[i] = x[i-1]+lst[i]
    y[i] = num-x[i]
# print(x)
# print(y)

ans = float("INF")
for i in range(n-1):
    ans = min(ans, abs(x[i]-y[i]))

print(ans)


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, n;
  cin >> x >> n;
  set<int> st;
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p;
    st.insert(p);
  }
  int ans = -1000;
  for (int i = -200; i <= 200; i++) {
    if (!st.count(i)) {
      if (abs(x - i) < abs(x - ans)) {
        ans = i;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3664
s=int(input())
mod=10**9+7
dp=[0]*(s+1)
dp[s]=1
for i in range(s,2,-1):
  for j in range(3,s+1):
    if i-j<0:break
    dp[i-j]+=dp[i]
    dp[i-j]%=mod
print(dp[0])

Measured memory_bytes: 66120
#include<cstdio>

int main(){
    int n;
    scanf("%d",&n);
    int a[n],b[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&a[i]);
    }
    for(int i = n - 1; i > 0; i--){
        printf("%d ",a[i]);
    }
    printf("%d\n",a[0]);
    return 0;
}


Measured memory_bytes: 2692
import math
s = int(input())
x1 = y1 = 0
x2 = y3 = math.ceil(s**0.5)
x3 = y2 = 0
diff = x2*y3 - s
for i in range(int(diff**0.5), 0, -1):
    if diff % i == 0:
        x3 = i
        y2 = diff // i
print(x1,y1,x2,y2,x3,y3)


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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

using psi = pair<string, int>;
using psii = pair<psi, int>;

inline void Main() {
  // code
  string s;
  int a,b;
  bool x = false,y = false;
  cin>>s;

  a = (s[0] - '0') * 10 + (s[1] - '0');
  b = (s[2] - '0') * 10 + (s[3] - '0');

  if(0 <= a && a < 100 && 0 < b && b < 13) {
    x = true;
  }

  swap(a, b);

  if(0 <= a && a < 100 && 0 < b && b < 13) {
    y = true;
  }

  if(x && y) {
    cout << "AMBIGUOUS" << endl;
  } else if(x) {
    cout << "YYMM" << endl;
  } else if(y) {
    cout << "MMYY" << endl;
  } else {
    cout << "NA" << endl;
  }
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  cout<<x2-y2+y1<<" "<<x2-x1+y2<<" "<<x1-y2+y1<<" "<<y1+x2-x1<<endl;
  return 0;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


int main() {

    double w,h,x,y;
    cin>>w>>h>>x>>y;

    cout<<fixed<<setprecision(10)<<w*h/2<<" ";

    if(x+x==w&&y+y==h){
        cout<<1<<endl;
        return 0;
    }
    cout<<0<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int A, B;
	cin >> A >> B;
	if (A >= 13)
	{
		cout << B << endl;
	}else if (A >= 6 && A <= 12)
	{
		cout << B / 2 << endl;
	}else{
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define nl cout<<'\n';
#define int long long
#define ff first
#define ss second
#define _lmax 1e14
#define pb push_back
void print(int a)                  {              cout<<a<<'\t'<<'\n';}
void print(int a,int b)                {          cout<<a<<'\t'<<b<<'\t'<<'\n';}
void print(int a,int b,int  c)             {      cout<<a<<'\t'<<b<<'\t'<<c<<'\n';}
void print(int a,int  b,int  c,int  d)         {   cout<<a<<'\t'<<b<<'\t'<<c<<'\t'<<d<<'\n';}
void print(int a,int  b,int  c,int  d,int  e)      { cout<<a<<'\t'<<b<<'\t'<<c<<'\t'<<d<<'\t'<<e<<'\n';}
void print(vector<int> &a)  {for(auto i:a)  cout<<i<<" ";   nl;}
void print(string s){cout<<s;nl;}

void MAIN()
{
    int n;  cin>>n;
    int a[n][3] , dp[n+1][3] = {};

    for(int i=0 ; i<n ; i++)
        cin>>a[i][0]>>a[i][1]>>a[i][2];

    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];

    for(int i=1; i<n; i++)
    {
        dp[i][0] = max(dp[i-1][1] , dp[i-1][2]) + a[i][0];
        dp[i][1] = max(dp[i-1][0] , dp[i-1][2]) + a[i][1];
        dp[i][2] = max(dp[i-1][1] , dp[i-1][0]) + a[i][2];
    }
    int ans = max({dp[n-1][0] , dp[n-1][1] , dp[n-1][2]});
    print(ans);

}
int32_t main()
{
//      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
//     int t;  cin>>t; while(t--)
//     ios_base::sync_with_stdio(0) , cin.tie(0);  int t; cin>>t; while(t--)
    MAIN();
    return 0;
}
/*

9 2
6 19 3 4 4 2 6 7 8
2 5 11 18 30 43 62 83 121






*/


















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



int main(){ 

    Int N;
    cin >> N;

    vector<Int> A(N);
    rep(i,N) cin >> A[i];

    set<Int> s;
    map<Int,Int> f;

    rep(i,N) {
        s.insert(A[i]);
        f[A[i]]++;
    }

    Int Sum = 0;

    set<Int>::iterator ite;;
    for (ite = s.begin(); ite != s.end(); ite++) {
        Sum += f[*ite] * (f[*ite] - 1) / 2;
    }

    rep(i,N) {
        Int ans;
        ans = Sum - (f[A[i]] * (f[A[i]] - 1) / 2) + (f[A[i]]-1) * (f[A[i]] - 2) / 2;
        cout << ans << endl;
    }


    
}


Measured memory_bytes: 17024