akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  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, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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];
  }
};

vector<pair<ll,int>> factorize(ll n) {
  vector<pair<ll,int>> res;
  for (ll i = 2; i*i <= n; ++i) {
    if (n % i) continue;
    res.emplace_back(i,0);
    while (n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n,1);
  return res;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll n,m;
  cin >> n >> m;
  vector<pair<ll,int> > res = factorize(m);
  int maxi = 0;
  for (auto p : res) chmax(maxi, p.second); //combのために乗数の最大値を求めておく
  combination comb(n+maxi-1);
  mint ans(1);
  for (auto p : res) {
    ans *= comb(n+p.second-1, p.second);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
S = []
for _ in range(N):
    S.append(int(input()))
mat = [0]*9
A = A1+A2+A3

for i in range(9):
  if A[i] in S:
    mat[i] = 1
res = 'No'
if sum(mat[0:9:3])==3 or sum(mat[1:9:3])==3 or sum(mat[2:9:3])==3 or sum(mat[0:3])==3 or sum(mat[3:6])==3 or sum(mat[6:9])==3 or sum(mat[0:9:4])==3 or sum(mat[2:7:2])==3:
  res = 'Yes'
print(res)




Measured memory_bytes: 38384
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    string s;
    cin >> s;
    if( s[0] == 'a') cout << "vowel" << endl;
    else if( s[0] == 'i') cout << "vowel" << endl;
    else if( s[0] == 'u') cout << "vowel" << endl;
    else if( s[0] == 'e') cout << "vowel" << endl;
    else if( s[0] == 'o') cout << "vowel" << endl;
    else cout << "consonant" << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

load = [a,b,c,d,e]

minl = min(load)

if (n%minl==0):
    print(n//minl-1+5)

if (n%minl!=0):
    print(n//minl+5)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> P;
//const ll big=998244353;
const ll big=1000000007LL;
const ll INF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int n;cin >> n;
    vec<ll> a(n),b(n);
    ll suma=0,sumb=0;
    rep(i,n){
        cin >> a[i];
        suma+=a[i];
    }
    rep(i,n){
        cin >> b[i];
        sumb+=b[i];
    }
    /*
    a[i]<b[i]{
        a[i]にfloor((b[i]-a[i])/2) 回2を足さないといけない　ラスト一回は(i,i)に操作すればいい
    }
    a[i]>b[i]{
        b[i]にa[i]-b[i]回1を足さないといけない
    }
    */
    ll cnt=0,cnt2=0;
    rep(i,n){
        if(a[i]<b[i])cnt+=(b[i]-a[i]+1)/2;
        else cnt2+=a[i]-b[i];
    }
    cout << (cnt>sumb-suma||cnt2>sumb-suma ? "No" : "Yes") << endl;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int 
#define pb push_back
#define mp make_pair
#define endl "\n"
#define mem(x) memset(x, -1, sizeof(x))
const int MOD = 1e9+7;

template <typename T>
void print(T AA[], int nn){for(int ii=0; ii<nn; ii+=1){cout<<AA[ii]<<" ";}cout<<endl;}
template <typename T> inline void print(T nn){ cout << nn << endl;}
/* ----------------------------------------------------------------------------------- */

const int N = 1005;
char A[N][N];
int n, m, cache[N][N];

int fn(int i, int j){
    if(i>=n || j>=m) return 0;
    if(A[i][j]=='#') return 0;
    if(i==n-1 && j==m-1) return 1;
    int &ans = cache[i][j];
    if(ans != -1) return ans;
    ans = fn(i+1, j) + fn(i, j+1);
    if(ans >= MOD) ans %= MOD;
    return ans;
}

int32_t main(){

    IOS

    mem(cache);
    cin >> n >> m;
    for(int i=0; i<n; i+=1){
        for(int j=0; j<m; j+=1){
            cin >> A[i][j];
        }
    }
    print(fn(0, 0));

    return 0;
}

Measured memory_bytes: 9216
N,M = map(int,(input().split()))
line = [[] for _ in range(N)]
for i in range(M):
    a,b = map(int,(input().split()))
    line[a-1].append(b-1)
    line[b-1].append(a-1)

# N!通りの順列
# lはタプルなのでlist()でリスト化して使うべし
import itertools
t = [i for i in range(N)]
l = list(itertools.permutations(t))
# 以下でリスト化
for i in range(len(l)):
    l[i] = list(l[i])

ans = 0
for i in range(len(l)):
    for j in range(N-1):
        if not l[i][j+1] in line[l[i][j]]:
            break
    else:
        if l[i][0] == 0:
            ans += 1

print(ans)

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;
using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline bool isprime(i32 n) { if (n < 2) return 0; for (i32 i = 2; i * i <= n; i++) if (n % i == 0) return 0; return 1; }
inline vi32 plist(i32 n) { vi32 f(n, 1); f[0] = f[1] = 0; repi(i, 2, n) for (int j = i * 2; j < n; j += i) f[j] = 0; return f; }
inline void ioinit() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); }
template<class T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<class T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<class T> inline bool amax(T &x, T y) { if (x >= y) return 0; x = y; return 1; }
template<class T> inline bool amin(T &x, T y) { if (x <= y) return 0; x = y; return 1; }
template<class T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<class T> vector<T> make_v(int n, T v) { return vector<T>(n, v); }
template<class... Ts> auto make_v(int n, Ts... ts) { return vector<decltype(make_v(ts...))>(n, make_v(ts...)); }

vector<int> edges[200010];
int dp[200010];
int dist[200010];
void dfs(int x, int p) {
  dist[x] = dist[p] + 1;
  for (auto e : edges[x]) {
    if (e == p) continue;
    dfs(e, x);
  }
}

int main() {
  ioinit();
  int n;
  cin >> n;
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  rep(i, 200010) dist[i] = -1;
  dfs(1, 0);
  int u;
  int mx = -1;
  reps(i, n) if (dist[i] > mx) {
    mx = dist[i], u = i;
  }
  rep(i, 200010) dist[i] = -1;
  dfs(u, 0);
  mx = -1;
  reps(i, n) if (dist[i] > mx) {
    mx = dist[i];
  }
  int cnt = mx + 1;
  dp[1] = 1;
  dp[2] = 0;
  repi(i, 3, n + 1) {
    if (dp[i - 1] == 1 && dp[i - 2] == 1) {
      dp[i] = 0;
    } else {
      dp[i] = 1;
    }
  }
  if (dp[cnt] == 1) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
  return 0;
}


Measured memory_bytes: 22144
import sys
input = sys.stdin.readline
from collections import deque
def main():
    N, Q = map( int, input().split())
    E = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map( int, input().split())
        a, b = a-1, b-1
        E[a].append(b)
        E[b].append(a)
    V = [0]*N
    for _ in range(Q):
        p, x = map( int, input().split())
        p -= 1
        V[p] += x
    q = deque([0])
    W = [0]*N
    W[0] = 1
    while q:
        v = q.popleft()
        c = V[v]
        for t in E[v]:
            if W[t] == 1:
                continue
            V[t] += c
            W[t] = 1
            q.append(t)
    print( " ".join( map( str, V)))
if __name__ == '__main__':
    main()


Measured memory_bytes: 121932
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v1(100001,0);
    vector<int> v2(100001.0);
    int temp;
    int i;
    for(i = 0;i <n;++i){
        cin >> temp;
        if(i % 2 == 0){
            ++v1.at(temp);
        }else{
            ++v2.at(temp);
        }
    }
    int ma1mode1 = 0,ma2mode1 = 0;
    int ma1mode2 = 0,ma2mode2 = 0;
    for(i = 1;i <= 100000;++i){
        if(v1.at(i) >= v1.at(ma1mode1)){
            ma2mode1 = ma1mode1;
            ma1mode1 = i;
        }else if(v1.at(i) > v1.at(ma2mode1)){
            ma2mode1 = i;
        }
    }
    for(i = 1;i <= 100000;++i){
        if(v2.at(i) >= v2.at(ma1mode2)){
            ma2mode2 = ma1mode2;
            ma1mode2 = i;
        }else if(v2.at(i) > v2.at(ma2mode2)){
            ma2mode2 = i;
        }
    }
    int ans;
    if(ma1mode1 != ma1mode2){
        ans =  n-v1.at(ma1mode1)-v2.at(ma1mode2);
    }else{
        if(v1.at(ma2mode1) > v2.at(ma2mode2)){
            ans = n - v1.at(ma2mode1) - v2.at(ma1mode2);
        }else{
            ans = n - v1.at(ma1mode1) - v2.at(ma2mode2);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<set>
#include<vector>
#define MAX 1000000
using namespace std;
int main(){
	multiset<int> box;
	int q,n,p;
	vector<int> pr,pri;
	for(int i=0;i<=MAX;i++)
	pr.push_back(1);
	pr[0]=pr[1]=0;
	q=0;
	for(int i=0;i<=MAX&&q<=100;i++){
		if(pr[i]){
			pri.push_back(i);
			if(i>=100000)
			q++;
			for(int j=i*2;j<=MAX;j+=i){
				pr[j]=0;
			}
		}
	}
	int now;
	while(cin>>n>>p,n!=-1){
		for(int i=0;i<pri.size();i++)
		if(n<pri[i]){
			now=i;
			break;
		}
		for(int i=now;i<now+p;i++)
		for(int j=i;j<now+p;j++)
		box.insert(pri[i]+pri[j]);
		now=1;
		multiset<int>::iterator ite=box.begin();
		while(now!=p){
			ite++;
			now++;
		}
		cout<<*ite<<endl;
		box.clear();
	}
	return 0;
}

Measured memory_bytes: 5000
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(int argc, char* argv[])
{
	int N,i;
	cin>>N;
	vector<int> A(N);
	for (i=1;i<N;i++){
		cin>>A[i];
	}
	map<int,int> myMap;
	map<int,int>::iterator mit;

	for (i=1;i<N;i++){
		mit=myMap.find(A[i]);
		if (mit==myMap.end()){
			myMap[A[i]]=1;
		}else{
			(*mit).second++;
		}
	}
	for (i=1;i<=N;i++){
		mit=myMap.find(i);
		if (mit==myMap.end()){
			cout<<0<<endl;
		}else{
			cout<<(*mit).second<<endl;
		}
	}
	return 0;
}

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

int main() {
    long long N, D; cin >> N >> D;
    long long X[N], Y[N];
    for (int i = 0; i < N; i++) cin >> X[i] >> Y[i];

    int ans = 0;
    for (int i = 0; i < N; i++) {
        long long d = X[i] * X[i] + Y[i] * Y[i];
        if (d <= D*D) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){
    int k, x;

    scanf("%d%d", &k, &x);

    for(int i = max(-1000000, x - k + 1); i <= min(1000000, x + k - 1); i++) printf("%d ", i);

    printf("\n");
    
    return 0;
}

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

# ITP1_7_D
# import numpy as np
# import io

n,m,l=map(int,input().split())
    
A=[list(map(int,input().split())) for _ in range(n)]
B=[list(map(int,input().split())) for _ in range(m)]


# 旧来の書き方だとこう
# for k in range(n):
#     list1=list()
#     for j in range(l):
#         sum=0
#         for i in range(m):
#             sum+=A[k][i]*B[i][j]
#         list1.append(str(sum))
#     print(" ".join(list1))


# これが、結果の(0,0)のセルに当たる。
# sum([A[0][k] * B[k][0] for k in range(m)])

# これが０行目のリストに当たる
# print( [ sum([A[0][k] * B[k][j] for k in range(m)]) for j in range(l) ] )

for i in range(n):
    t = [ str(sum([A[i][k] * B[k][j] for k in range(m)])) for j in range(l) ]
    print(" ".join(t))






Measured memory_bytes: 6300
def main():
    n = int(input())
    a = [int(input()) for i in range(n)]
    a_sorted = sorted(a)
    first, second = a_sorted[-1], a_sorted[-2]
    f_idx = a.index(first)

    for idx in range(n):
        if idx == f_idx:
            print(second)
        else:
            print(first)

main()


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

typedef long long int int64;
static const int64 mod1 = 1290382391, mod2 = 1350983507;
using hash = std::pair<int,int>;
hash x(139436098, 325878929);
hash y(1142067043, 890079571);
int64 exgcd(int64 a,int64 b,int64 &c,int64 &d)
{
	if(b == 0) {
		c = 1, d = 0;
		return a;
	}
	int64 k = exgcd(b,a%b,d,c);
	d -= c * (a / b);
	return k;
}
using hash = std::pair<int,int>;
hash operator +(const hash &a, const hash &b) {
	return hash(((int64)a.first+b.first)%mod1,((int64)a.second+b.second)%mod2);
}
hash operator *(const hash &a, const hash &b) {
	return hash((int64)a.first*b.first%mod1,(int64)a.second*b.second%mod2);
}
hash operator -(const hash &a, const hash &b) {
	int v1 = a.first-b.first, v2 = a.second-b.second;
	if(v1<0) v1+=mod1; if(v2<0) v2+=mod2;
	return hash(v1,v2);
}
hash inv(const hash &x) {
	int64 v1,v2,v3,v4;
	assert(exgcd(mod1,x.first,v1,v2) == 1);
	assert(exgcd(mod2,x.second,v3,v4) == 1);
	return hash(v2<0?v2+mod1:v2,v4<0?v4+mod2:v4);
}
hash operator /(const hash &a, const hash &b) {
	return a*inv(b);
}
using line = std::pair<hash,hash>;
// b(a(x))
line compose(const line &a,const line &b) {
	return line(a.first*b.first,b.first*a.second+b.second);
}
int n;
char s[250003];
line pre[250003],invpre[250003];
int main()
{
	scanf("%d %s",&n,s+1);
	pre[n+1] = invpre[n+1] = line(hash(1,1),hash(0,0));
	hash f(0,0);
	for(int i = n;i >= 1;--i) {
		line l, invl;
		switch(s[i]) {
		case '+': {
			l = line(hash(1,1),hash(1,1));
			invl = line(hash(1,1),hash(mod1-1,mod2-1));
			break;
		}
		case '-': {
			l = line(hash(1,1),hash(mod1-1,mod2-1));
			invl = line(hash(1,1),hash(1,1));
			break;
		}
		case '>': {
			l = line(x,hash(0,0));
			invl = line(y,hash(0,0));
			break;
		}
		case '<': {
			l = line(y,hash(0,0));
			invl = line(x,hash(0,0));
			break;
		}}
		pre[i] = compose(pre[i+1],l);
		invpre[i] = compose(invl,invpre[i+1]);
	}
	f = pre[1].second;
	std::map<hash,int> m;
	int64 ans = 0;
	for(int i = n+1;i >= 1;--i) {
		ans += m[f*invpre[i].first+invpre[i].second];
		++m[invpre[i].second];
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 39552
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector<int>   vi;
typedef vector<long long> vll;
typedef vector<pair<int,int> > vii;
#define ll long long
#define pb push_back
#define mp  make_pair
#define ff first
#define ss second
#define pq priority_queue
#define sf1(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
int inf = (1e9) + 7;


int main(){


	int a,b;
	cin >> a >> b;
	printf("%d\n",max(a-b,0));

}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


bool is_p(ll x){
	if(x<2)return false;
	FOR(i,2,sqrt(x)+1){
		if(x%i==0)return false;
	}
	return true;
}

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

	while(1){
		ll a,d,n;
		cin >> a >> d >> n;
		if(a==0&&d==0&&n==0)break;
		while(n){
			n -= is_p(a);
			a += d;
		}
		a -= d;
		cout << a << endl;
	}

}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 int N,D;
 int c = 0;
 cin >> N >> D;
 for(int i = 0; i < N;i++){
   double x,y;
   cin >> x >> y;
   if (sqrt(x*x + y*y) <= D) c++;
 }
 cout << c;

  
}

Measured memory_bytes: 3812
"use strict";

var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/),
    cid = 0;

function next() {
    return +cin[cid++];
} // number一個取得
function nextstr() {
    return cin[cid++];
} // 文字列一個取得
function nextbig() {
    return BigInt(cin[cid++]);
} // BigInteger一個取得
// 長さnの配列として取得。aは文字列フラグ
function nexts(n, a) {
    return a ? cin.slice(cid, cid += n) : cin.slice(cid, cid += n).map(a => +a);
}
// 長さnのBigInt配列として取得。
function nextsbig(n) {
    return cin.slice(cid, cid += n).map(a => BigInt(a));
}
// w個ずつを組にして長さhの配列。aは文字列フラグ。
function nextm(h, w, a) {
    var r = [],
        i = 0;
    if (a)
        for (; i < h; i++) r.push(cin.slice(cid, cid += w));
    else
        for (; i < h; i++) r.push(cin.slice(cid, cid += w).map(a => +a));
    return r;
}
// 多次元配列。v,a1,a2,a3 なら、3次元。[[値vで長さa3の配列]をa2個並べた配列]をa1個並べた配列。
function xArray(v) {
    var a = arguments,
        l = a.length,
        r = "Array(a[" + --l + "]).fill().map(x=>{return " + v + ";})";
    while (--l) r = "Array(a[" + l + "]).fill().map(x=>" + r + ")";
    return eval(r);
}


console.log(main().toString());

function main() {
    let n = next();
    let m = next();
    let ab = nexts(2*m)
    let ans = xArray(0,n+1)
    ab.forEach(l=> ans[l]++)
    ans.shift();
    return ans.join("\n")
}

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

using namespace std;

int main()
{

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n,k;
	cin >>n>>k;
	vector<int> v(n+1);
	vector<bool> dp(k+1);
	for (int i = 1; i <=n; ++i) cin >> v[i];
	for(int i = k;i>=0;i--) {
		for(int j = n;j>=1;j--) {
			if(dp[i+v[j]]==0&&i+v[j]<=k) {
				dp[i] = 1;
				break;
			}
		}
	}
	if(dp[0]==1) cout << "First" <<'\n';
	else cout <<"Second"<<'\n';
	return 0;
}

Measured memory_bytes: 3616
/*
AUTHOR: Aman Raj
LANG: C++
*/

using namespace std;

typedef   long long  int ll;
#include <bits/stdc++.h>


//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
#define fast  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
#define all(a) a.begin(),a.end()
//#define mod 998244353


#define mod   1000000007

#define inf 1e18
//#define mod 3
#define flush fflush(stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<ll, ll, hash< ll > > ht;

// find_by_order()  // order_of_key
typedef tree<
    ll,
    null_type,
    less<ll>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;






ll power1(ll a, ll b)//a raised to power b
   {  if(b<=0) return 1; if(b==1) return a;
       ll c=power1(a,b/2);
        c*=c;c%=mod;if(b%2==1) c*=a;c%=mod;
        return c;
   }
   ll mi(ll a,ll m)
   { ll c= power1(a,m-2);

     return c;
   }



 struct less_then_greater {
    template<typename T, typename U>
    bool operator()(T const& lhs, U const& rhs) const {
        if (lhs.first < rhs.first) return true;
        if (rhs.first < lhs.first) return false;
        return lhs.second > rhs.second;
    }
};

 /*std::priority_queue<std::pair<int, int>,
                    std::vector<std::pair<int, int>>,
                    less_then_greater
                    > pq;*/


  int main()
{  fast;
   ll a,b,c,d;cin>>a>>b>>c>>d;
     ll ans=b*d;
     ans=max(b*c,ans);
     ans=max(a*c,ans);
     ans=max(a*d,ans);
     cout<<ans<<endl;
   return 0;
}


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

using namespace std;

#define int long long
int const maxc = 100005;
int mod = 1e9 + 7;
int dp[105][maxc], dp1[105][maxc], pref[maxc], pref1[maxc];

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector < pair < int, int > > a;
    for (int i = maxc; i <= n; ++i) {
        int lef = i, righ = n + 1;
        while (righ - lef > 1) {
            int mid = (righ + lef) / 2;
            if (n / i == n / mid) lef = mid;
            else righ = mid;
        }
        a.push_back({i, lef});
        i = lef;
    }
    for (int i = 1; i < min(maxc, n + 1); ++i) dp[1][i] = 1;
    for (int j = 0; j < (int)a.size(); ++j) dp1[1][j] = a[j].second - a[j].first + 1;
    for (int i = 2; i <= k; ++i) {
        for (int j = 1; j < min(maxc, n + 1); ++j) pref[j] = pref[j - 1] + dp[i - 1][j];
        for (int j = 1; j <= (int)a.size(); ++j) pref1[j] = pref1[j - 1] + dp1[i - 1][j - 1];
        for (int j = 1; j < min(maxc, n + 1); ++j) {
            /*for (int lst = 1; lst * j <= n && lst < min(maxc, n + 1); ++lst) {
                dp[i][j] += dp[i - 1][lst];
            }*/
            int lst = min({n / j, n, maxc - 1});
            dp[i][j] += pref[lst];
            /*for (int lst = 0; lst < (int)a.size(); ++lst) {
                if (a[lst].first * i <= n && a[lst].first * i > n) {
                    cout << "WA";
                    exit(0);
                }
                if (a[lst].first * i <= n) dp[i][j] += dp1[i][lst];
            }*/
            int lef = -1, righ = (int)a.size();
            while (righ - lef > 1) {
                int mid = (righ + lef) / 2;
                if (a[mid].first * j <= n) lef = mid;
                else righ = mid;
            }
            dp[i][j] += pref1[lef + 1];
            dp[i][j] %= mod;
        }
        for (int j = 0; j < (int)a.size(); ++j) {
            /*for (int lst = 1; lst < min(maxc, n + 1); ++lst) {
                if (a[j].first * lst <= n && a[j].second * lst > n) {
                    cout << "WA";
                    exit(0);
                }
                if (a[j].first * lst <= n) dp1[i][j] += dp[i - 1][lst] * (a[j].second - a[j].first + 1);
            }*/
            dp1[i][j] += (a[j].second - a[j].first + 1) * (pref[n / a[j].first] % mod);
            dp1[i][j] %= mod;
        }
    }
    int ans = 0;
    for (int i = 0; i < maxc; ++i) ans += dp[k][i] + dp1[k][i];
    cout << ans % mod << '\n';
    return 0;
}



Measured memory_bytes: 159100
/* Simplicity and Goodness */

#include <bits/stdc++.h>
using namespace std;
#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define deb(x) cout << #x << " = " << x << ' ';
#define rep(i, a, b) for(int i=(int)(a); i<(int)(b); i++)
#define tc int tt; scn(tt); while(tt --)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 998244353;
const int N = 2e5+2;


int main()
{
    int a, b;
    cin >> a >> b;
    cout << a * b;
    return 0;
}

Measured memory_bytes: 3584
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,m = map(int,readline().split())
lr = list(map(int,read().split()))

imos = [0] * (m+2)
ans = [0] * (m+2)

it = iter(lr)
for l,r in zip(it,it):
    i = 1
    li = r+1
    while(li > i):
        ri = min(li, r//i + 1)
        li = (l-1)//i + 1
        if(ri > li):
            imos[li] += 1
            imos[ri] -= 1
        i+=1

    for i in range(1,li):
        if(r//i)-((l-1)//i)>0:
            ans[i] += 1

for i in range(1,m+1):
    imos[i] += imos[i-1]
    ans[i] += imos[i]

print('\n'.join(map(str,ans[1:m+1])))

Measured memory_bytes: 130700
#include<bits/stdc++.h>
using namespace std;
main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long i,j,k,l,m,n,o,p,q;
    while(cin>>m>>n>>o>>p)

    {
        if(abs(m-o)<=p)
            cout<<"Yes"<<endl;
        else  if(abs(m-n)<=p&&abs(n-o)<=p)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,h;cin >> n >> h;
	vector<int> a(n), b(n);
	rep(i,n) cin >> a.at(i) >> b.at(i);
	sort(a.rbegin(),a.rend());
	sort(b.rbegin(),b.rend());
	int ans = 0;
	rep(i,n){
		if(b.at(i) < a.at(0)) break;
		ans++;
		if(h - b.at(i) > 0) h -= b.at(i);
		else{
			h = 0;
			break;
		}
	}
	ans += (h + a.at(0) - 1) / a.at(0);
	cout << ans << endl;
}


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

int main(){
  char b;
  cin>>b;
  if(b=='A'){
    cout<<'T'<<endl;
  }
  else if(b=='T'){
    cout<<'A'<<endl;
  }
  else if(b=='C'){
    cout<<'G'<<endl;
  }
  else{
    cout<<'C'<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long n,t,k,kcase;
	long long a,b[2000005];
	long long m = 0;
	int flag = 1;
	k = 0;
	kcase = 0;
	cin >> n >> t;
	for (int i = 0; i < n; i++)
	{
		cin>>a>>b[i];
		if (m < a)
		{
			m = a;
			k = b[i];
		}
		else if(m == a)
		{
			if(k> b[i])
				k = b[i];
		}
	}
	sort(b, b + n);
	for (int i = n-1; i >=0; i--)
	{
		if (t - k <= 0)
		{
			cout<<kcase+1<<endl;
			return 0;
		}
		if (b[i] == k && flag)
		{
			flag = 0;
			continue;
		}
		if(b[i]>m)
		t = t - b[i];
		else
		{
			t = t - m;
		}
		kcase++;
		if (t <= 0)
		{
			cout<<kcase<<endl;
			return 0;
		}
		
	}
	t = t - k;
	kcase++;
	if (t <= 0)cout << kcase << endl;
	else
	{
		kcase += t / m; 
		t = t - (t / m)*m;
		if(t > 0) kcase++;
		cout<<kcase<<endl;
	}
	return 0;
}

Measured memory_bytes: 2816
import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val a = cin.nextLong()
    val b = cin.nextLong()

    var d_value: Long = 1
    var d: Int = 0

    var ans: Long = 0

    while (true) {
        if (d_value > b) {
            break
        }
        val a_extra: Long = a % (d_value*2)
        val b_extra: Long = b % (d_value*2)

        var one: Long = 0

        
        if (a_extra >= d_value) {
            one += d_value*2 - a_extra
        }
        if (b_extra >= d_value) {
            one += b_extra - d_value + 1
        }


        if (d != 0 && one % 2 == 1.toLong()) {
            ans += d_value
        }

        if (d == 0) {
            val less_a_odd = a/2
            val less_b_odd = b/2
            val b_plus = b%2

            if ((less_b_odd - less_a_odd + b_plus) % 2 == 1.toLong()) {
                ans += 1
            }
        }
        d_value *= 2
        d += 1
    }
    println(ans)
}

Measured memory_bytes: 31272
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll n, m; cin >> n >> m;
  Vll a(m); cin >> a;
  
  ll sum = 0;
  rep(i, m) sum += a[i];

  ll ans = ((sum > n) ? -1 : (n - sum));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
#include <boost/math/constants/constants.hpp>
using namespace std;
typedef long long ll;
long double e = boost::math::constants::e<long double>();
long double pi = boost::math::constants::pi<long double>();
// 条件を見落としていませんか？

int main () {
    ll H, W;
    cin >> H >> W;
    if (H == 1 || W == 1) {
        puts("1");
        return 0;
    }
    ll m = W/2, M = W-m;
    ll a = H/2, b = H-a;
    cout << m*a+M*b << endl;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
    input = Number(input);
    var memo = [];
    for (var i=1; i<=1000000; i++){
        if (memo[input] === 1) {
            console.log(i);
            break;
        }
        memo[input] = 1;
        if (input % 2 === 0) {
            input = input/2;
        }else {
            input = input * 3 + 1;
        }
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}

ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}

class Segment_Tree{
	private:
	int n;
	vl a,b;
	pll Query_func(int s,int t,int k,int l,int r){
		if(r<=s||t<=l) return {0,1};
		if(s<=l&&r<=t) return {a[k],b[k]};
		int m=(l+r)/2;
		pll p=Query_func(s,t,k*2+1,l,m),q=Query_func(s,t,k*2+2,m,r);
		ll B1=p.second,B2=q.second,L=lcm(B1,B2);
		return {(L/B1%mod*p.first+L/B2%mod*q.first)%mod,L};
	}
	public:
	Segment_Tree(int n_){
		n=1;
		while(n<n_) n*=2;
		a=vl(2*n-1);
		b=vl(2*n-1,1);
	}
	void Update(int k,ll A,ll B){
		k+=n-1;
		a[k]=A;
		b[k]=B;
		while(k>0){
			k=(k-1)/2;
			ll B1=b[2*k+1],B2=b[k*2+2];
			ll l=lcm(B1,B2);
			a[k]=(l/B1%mod*a[k*2+1]+l/B2%mod*a[k*2+2])%mod;
			b[k]=l;
		}
	}
	ll Query(int s,int t){
		return Query_func(s,t,0,0,n).first;
	}
};

int n,q;
vi p;

int main(){
	cin>>n>>q;
	p=vi(n);
	Segment_Tree st(n);
	for(int i=0;i<n;i++) cin>>p[i];
	vi used(n);
	for(int i=0;i<n;i++) if(!used[i]){
		ll I=i,sum=0,t=0;
		vi tmp;
		while(!used[I]){
			sum+=p[I];
			t++;
			used[I]=1;
			tmp.push_back(I);
			I=p[I]-1;
		}
		sum%=mod;
		int S=tmp.size();
		for(int j=0;j<S;j++) st.Update(tmp[j],sum,t);
	}
	for(int i=0;i<q;i++){
		int l,r;
		cin>>l>>r;
		cout<<st.Query(l-1,r)<<endl;
	}
}

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

int main() {
  int n, d;
  cin >> n >> d;
  int x[100][100] = {0};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++) {
      cin >> x[i][j];
    }
  }
  vector<int> a;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int tmp = 0;
      for (int k = 0; k < d; k++) {
        tmp += abs(x[i][k] - x[j][k])*abs(x[i][k] - x[j][k]);
      }
      a.push_back(tmp);
    }
  }
  int ans = 0;
  for (int i = 0; i < a.size(); i++) {
    for (int j = 0; j <= 1000; j++) {
      if (a[i] == j*j) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int N, ans = 0;
    scanf("%d",&N);

    while(1){
    if(N == ans){
        ans = N;
    }
    else if(N > ans){
        ans += 111;
    }

    if(ans >= N) break;
    }

    printf("%d",ans);

    return 0;
}

Measured memory_bytes: 128
import math

a, b, c, d = list(map(int, input().split()))

ac = (a-1) // c
ad = (a-1) // d
bc = b // c
bd = b // d
cd_lcm =  (c * d) // math.gcd(c, d)
acd_lcm = (a-1) // cd_lcm
bcd_lcm = b // cd_lcm

l = b - a + 1

print(l - (bc - ac) - (bd - ad) + (bcd_lcm - acd_lcm))


Measured memory_bytes: 9092
#include <bits/stdc++.h>
 
using namespace std;
const int N = 2e5 + 5;
typedef long long ll;
const ll inf=1e15;
#define pb push_back
const int INF=(0x3f3f3f3f);

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  
  string s1,s2;
  cin>>s1>>s2;
  cout<<s2<<s1<<'\n';
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n;
ll x,g;
 ll gcd(ll a,ll b)
{
	return !b?a:gcd(b,a%b);
}
 
 int main()
{
	scanf("%d%lld",&n,&x);
	for(int i=1;i<n;i++)
	{
		scanf("%lld",&g);
		x/=gcd(g,x);
		x*=g;
	}
	printf("%lld\n",x);
}

Measured memory_bytes: 256
# AtCoder Beginner Contest 145 D - Knight
import sys
from math import factorial

mod = 10 ** 9 + 7

X, Y = map(int, sys.stdin.readline().strip().split())

# 合計の移動回数は Total = X + Y / 3 
# 移動方法は A: (i + 1, j + 2)  B: (i + 2, j + 1) の2通り
# 移動回数は A: 2 * Total - X  B: X - Total 

# 到達不可能であるか判断する
if (X + Y) % 3 != 0:
    print(0)
    sys.exit()

if Y > 2 * X or Y < X * 0.5:
    print(0)
    sys.exit()


Total = (X + Y) // 3
A = Total * 2 - X
B = X - Total

# combination の計算
ans = 1
for i in range(1, Total + 1):
    ans *= i
    ans %= mod

ans = ans * pow(factorial(A), mod - 2, mod)
ans = ans * pow(factorial(B), mod - 2, mod)

print(ans % mod)



Measured memory_bytes: 152500
#if !defined(ONLINE_JUDGE)
    #include "prettyprint.hpp" 
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 1729
    #define cer(x) 13
#endif
const bool testcase=0;
typedef long long int ll;
#define INF LONG_MAX
#define MINF LONG_MIN 
#define MAXR 111111
const ll mod1 = 1000000007;
const ll mod2 = 998244353;



//loop 
#define loop(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define loope(i,L,R) for (int i = L; i <= R; i++)
#define rloop(i,L,R) for (int i = L; i > R; i--)
#define rloope(i,L,R) for (int i = L; i >= R; i--)
#define nl cout<<'\n'



//misc
#define sz(x) ((int)((x).size()))
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL) 
#define checkbit(n,b) ( (n >> b) & 1)
#define test int _T_=1;if(testcase){cin>>_T_;}while(_T_--)



//vector
#define lastEle(vec) vec[vec.size()-1]
#define all(ve) ve.begin(),ve.end()
#define rall(x) x.rbegin(),x.rend()
#define fi first
#define se second



template<typename T>inline T mmod(T a,T b,T mod){return ((a%mod)*(b%mod))%mod;}
template<typename T>inline T smod(T a,T b,T mod){return ((a%mod)+(b%mod))%mod;}
template<typename T>bool isPrime(T n){for(T i=2;i*i<=n;i++)if(n%i==0)return 0;return 1;}
template<typename TAIL>inline void inp(TAIL& T){cin>>T;}
template<typename HEAD,typename... TAIL>inline void inp(HEAD &H,TAIL&... T){cin>>H;inp(T...);}
template<typename T>inline bool in_range(T a,T l,T r){return (a>=l&&a<=r);}
template<typename T,typename U>inline istream& operator >>(istream& in,pair<T,U> &a){in>>a.fi>>a.se;return in;}
template<typename T>inline istream& operator >>(istream& in,vector<T> &a){for(auto &x : a)in>>x;return in;}

ll lcm(ll a,ll b){return (max(a,b)/__gcd(a,b))*min(a,b);} 

// MAIN
void solve();
int main(){
    std::chrono::time_point<std::chrono::high_resolution_clock> start, end;
    start = std::chrono::high_resolution_clock::now();
    fast;
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
        // for debug in error.txt
        freopen("error.txt", "w", stderr);
    #endif
    test {
        solve();
    }
    end = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
    cerr << "\nElapsed Time: " << elapsed_time << "ms\n";
    return 0;
}


// SOLVE 

void solve() {
    ll n;
    cin >> n;
    ll ans = INT_MIN, cnt = 0;
    for(int i = 0; i < n; i++) {
        ll a, b;
        cin >> a >> b;
        if(a == b) {
            cnt++;
        }else{
            ans = max(ans,cnt);
            cnt = 0;
        }
        ans = max(ans,cnt);
    }
    // cout << ans << '\n';
    if(ans >= 3){
        cout << "Yes";
    }else {
        cout << "No";
    }
}



Measured memory_bytes: 3552
#include<algorithm>
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
  int lot[33]; // くじ
  int w,n,a,b;
  for(int i=1;i<=30;i++)lot[i] = i;
  cin >> w >> n;

  for(int i=0;i<n;i++){
    scanf("%d,%d",&a,&b);
    swap(lot[a],lot[b]);
  }

  for(int i=1;i<=w;i++){
    cout << lot[i] << endl;
  }
}

Measured memory_bytes: 1240
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef long long LL;
LL n, k, res;
int main() {
	scanf("%lld%lld", &n, &k);
	if(k == 0)printf("%lld\n", n * n);
	else {
		for(LL b = k + 1; b <= n; b++) {
			res += (b - k) * (n / b) + max(n % b - k + 1LL, 0LL);
		}
		printf("%lld\n", res);
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
ll ans=0;
int a[]={3,5,7},n;
set<char> st;
int ret(string s) {
    int p = 0;
    for (auto i:s) {
        p = (p*10) + i-'0';
    }
    return p;
}
void solve(string s) {
    if (s.size()==9) return;
    s += '0';
    for (int i=0;i<3;i++) {
        s[-1+s.size()] = (char)(a[i]+'0');
        if (s.size()>2) {
            st.clear();
            for (auto i:s) {
                st.insert(i);
            }
            if (st.size()==3) {
                if (ret(s)<=n) ans++;
            }
        }
        solve(s);
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    solve("");
    cout<<ans;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;
    ll n,l,ans=0;
    scanf("%lld%lld",&n,&l);
    ll taste[n];
    rep(i,0,n){
        taste[i]=l+i;
    }
    ll sum=0,p,dif=INF,mark;
    rep(i,0,n){
        sum+=taste[i];
    }
    // printf("%lld ",sum);
    rep(i,0,n){
        p=sum;
        p-=taste[i];
        if(dif>ABS(p-sum)){
            mark=i;
            dif=ABS(p-sum);
        }
    }
    ans=sum-taste[mark];

    
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-

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

color = [0,0,0,0,0,0,0,0,0]

for i in range(n):
    if 1 <= a[i] <= 399:
        color[0] += 1
    elif 400 <= a[i] <= 799:
        color[1] += 1
    elif 800 <= a[i] <= 1199:
        color[2] += 1
    elif 1200 <= a[i] <= 1599:
        color[3] += 1
    elif 1600 <= a[i] <= 1999:
        color[4] += 1
    elif 2000 <= a[i] <= 2399:
        color[5] += 1
    elif 2400 <= a[i] <= 2799:
        color[6] += 1
    elif 2800 <= a[i] <= 3199:
        color[7] += 1
    elif 3200 <= a[i]:
        color[8] += 1


min_col = color[:]
min_cnt = 0
del min_col[-1]
for i in range(len(min_col)):
    if min_col[i] != 0:
        min_cnt += 1

max_cnt = min_cnt + color[8]
min_cnt = max(1,min_cnt)

print(min_cnt, max_cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define maxn 200005
#define LL long long
using namespace std;
LL a[maxn],k;
LL cut[maxn];
int n;
LL L=1,R=0;
 
bool check(LL t){
	LL cnt=0;
	for(int i=1;i<=n;i++){
		cut[i]=(a[i]/t)-1+(a[i]%t>0);
		cnt+=cut[i];
	}
	if(cnt<=k)return 1;
	else return 0;
}
 
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)R=max(R,a[i]);
	R++;
	while(L+1<R){
		LL mid=L+R>>1;
	//	cout<<L<<" "<<R<<" "<<mid<<endl;
		if(check(mid))R=mid;else L=mid;
	}
	if(check(L))cout<<L<<endl;
	else cout<<R<<endl;
}

Measured memory_bytes: 6680
//Robs Code
/***********HEADER***************/
#include<bits/stdc++.h>
/***********MACROS***************/
#define ll long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 10000007
#define mxval 1e9
#define grt [](auto x,auto y){return x>y;}
#define pii pair<ll,ll>
/*********VARIABLE****************/
using namespace std;
ll i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/***********MAIN******************/
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n>>m;
    vector<pii> v(n);
    fri(0,n-1) cin>>v[i]._1>>v[i]._2;
    sort(all(v));
    for(i=0;i<n;i++){
        if(m<1) break;
        t=min(v[i]._2,m);
        m-=t;
        tot[0]+=(v[i]._1*t);
    }
    cout<<tot[0];
	return 0;
}
//.........

Measured memory_bytes: 1792
// ABC 056
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const int inf=1000000007;

int main() {
  int x;cin >>x;
  int n = 0;
  while(2*x>n*(n+1)) ++n;
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 256
a, b = map(int, input().split())

if (a <= 0 and b >= 0) or (a >= 0 and b <= 0):
  print("Zero")
elif (a < 0 and b < 0):
  if (abs(a - b) + 1) % 2 == 0:
    print("Positive")
  else:
    print("Negative")
else:
  print("Positive")


Measured memory_bytes: 61832