akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		boolean bre = false;
		int last = h[n - 1];
		for (int i = n - 2; i >= 0; i--) {
			if (h[i] - last > 1) {
				bre = true;
				break;
			} else if (h[i] - last == 1) {
				last = h[i] - 1;
			} else {
				last = h[i];
			}
		}
		if (bre) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 53304
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <queue>
#define N 505

using namespace std;

int n;
int a[N * N], rem[N];

struct node {
	int pos, val;
}q[N];
inline bool cmp_node(node lhs, node rhs) { return lhs.pos < rhs.pos; }

queue<int> que;

int main() {
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		rem[i] = i - 1;
		cin >> q[i].pos, a[q[i].pos] = i;
		q[i].val = i;
	}
	
	sort(q + 1, q + 1 + n, cmp_node);
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j < q[i].val; ++j)
			que.push(q[i].val);
	
	for(int i = 1; i <= n * n; ++i) {
		if(a[i]) {
			if(rem[a[i]]) {
				puts("No");
				return 0;
			} else {
				for(int j = 1; j <= n - a[i]; ++j)
					que.push(a[i]);
			}
		} else {
			if(!que.empty()) {
				a[i] = que.front();
				--rem[a[i]];
				que.pop();
			} else {
				puts("No");
				return 0;
			}
		}
	}
	
	puts("Yes");
	for(int i = 1; i <= n * n; ++i)
		printf("%d%c", a[i], i == n * n ? '\n' : ' ');
	return 0;
}

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

int main(){
		int N;
		cin >> N;
		int h[N];
		int dp[N];
		for(int i = 0; i < N; i++){
			cin >> h[i];
			dp[i] = 2147483647;
	  }
	  dp[0] = 0;
	  dp[1] = max(h[1] - h[0], h[0] - h[1]);
	  for(int i = 2; i < N; i++){
				int m1 = max(h[i] - h[i-1], h[i-1] - h[i]);
				int m2 = max(h[i] - h[i-2], h[i-2] - h[i]);
				dp[i] = min(m1 + dp[i-1],m2 + dp[i-2]);
		}
		cout << dp[N-1] << endl; 
		return 0;
}


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

int main(){
  ll l,r;
  cin >> l >> r;

  if(r-l>3000){
    cout << 0 << endl;
    return 0;
  }


  ll ans = 2019;
  for(ll i = l; i < r; i++){
    for(ll j = l+1; j <= r; j++){
      ll di = i%2019;
      ll dj = j%2019;
      ll res = (di*dj)%2019;
      ans = min(ans, res);
    }
  }
  cout << ans << endl;  
}


Measured memory_bytes: 3588
#include <iostream>
using namespace std;
int main()
{
  int p[5], k;
  cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> k;
  if ((p[4]-p[0])>k) {
    cout << ":(" << endl;
  } else {
    cout << "Yay!" << endl;
  }
  return 0;
}


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

struct cell{
    int level;
    char word;
    struct cell *mother;
    struct cell *child[30];
    int count;
};

struct cell *add(char inp[], struct cell *now);
int calc(struct cell *now);

int main(void) {
    int n, i;
    char inp[30];
    struct cell node;
    struct cell *now;
    scanf("%d",&n);
    while(n) {
        scanf("%s",inp);
        node.level = 1;
        node.word = inp[0];
        node.mother = NULL;
        node.count = 0;
        now = &node;
        for(i = 1; i < n; i++) {
            scanf("%s",inp);
            now = add(inp, now);
        }
        printf("%d\n",calc(&node));
        scanf("%d",&n);
    }
    return 0;
}

struct cell *add(char inp[], struct cell *now) {
    int len;
    struct cell *new_one;
    new_one = (struct cell *)malloc(sizeof(struct cell));
    len = strlen(inp);
    while(now->level+1 != len) {
        now = now->mother;
    }
    new_one->level = now->level+1;
    new_one->word = inp[len-1];
    new_one->mother = now;
    now->child[now->count] = new_one;
    now->count++;
    return new_one;
}

int calc(struct cell *now) {
    int i, ans = 0;
    if(now->word == '+') {
        for(i = 0; i < now->count; i++) {
            ans += calc(now->child[i]);
        }
    } else if(now->word == '*') {
        ans = 1;
        for(i = 0; i < now->count; i++) {
            ans *= calc(now->child[i]);
        }
    } else {
        return (now->word - '0' );
    }
    return ans;
}

Measured memory_bytes: 988
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,k;
  cin>>n>>k;
  vector<char> s(n);
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  int g=0;
  if(s[0]=='L') g+=1;
  if(s[n-1]=='R') g+=1;
  int h=0;
  for(int i=0;i<n-1;i++){
    if(s[i]=='R' && s[i+1]=='L'){
      h+=2;
    }
    
  }
  int y=0;
  int x=0;
  if(s[0]=='R' && s[1]=='L'){
    y=1;
  }
  if(s[n-2]=='L' && s[n-1]=='R'){
    x=1;
  }
  if(h/2>=k){
    h-=2*k;
  }
  else if(g==1 && k-h/2==1){
    h=0;
    g=1;
  }
  else if(g==2 && k-h/2==1){
    h=0;
    g-=1;
  }
  else if(g==1 && k-h/2>1){
    h=0;
    g=1;
  }
  else if(g==2 && k-h/2>1){
    h=0;
    g=1;
  }
  else{
    h=1;
  }
  cout<<n-g-h<<endl;
}
    
    


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define int long long
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
int getSegTreeSize(int len) {
    if (len == 0) return 0;
    int ret, cnt = 0, memo = 1;
    while (memo < len) {
        memo *= 2;
        cnt++;
    }
    ret = 1 << (cnt + 1);
    return ret;
}
class RAQ {
  private:
    int size, length;
    std::vector<int> node;
    RAQ() {}
    int find(int return_index, int index, int left, int right) {
        if (index == size + return_index - 1) return node[index];
        if ((left + right) / 2 < return_index) return find(return_index, index * 2 + 1, (left + right) / 2 + 1, right) + node[index];
        return find(return_index, index * 2, left, (left + right) / 2) + node[index];
    }
    void update(int left, int right, int element, int index, int i_left, int i_right) {
        if (left <= i_left && i_right <= right) {
            node[index] += element;
            return;
        }
        int middle = (i_left + i_right) / 2;
        if (middle >= left) update(left, right, element, index * 2, i_left, middle);
        if (middle < right) update(left, right, element, index * 2 + 1, middle + 1, i_right);
    }

  public:
    RAQ(int size) {
        this->size = getSegTreeSize(size) / 2;
        this->length = getSegTreeSize(size);
        node.resize(this->length);
        fill(node.begin(), node.end(), 0);
    }
    void update(int left, int right, int element) {
        update(left, right, element, 1, 1, size);
    }
    int find(int index) {
        return find(index, 1, 1, size);
    }
};
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9 + 7;
    int n, d, a;
    cin >> n >> d >> a;
    RAQ tree(n);
    vector<P> monster(n);
    rep(i, n) {
        cin >> monster[i];
    }
    sort(monster.begin(), monster.end());
    vector<int> point_monster(n);
    rep(i, n) {
        tree.update(i + 1, i + 1, monster[i].second);
        point_monster[i]=monster[i].first;
    }
    sort(point_monster.begin(),point_monster.end());
    int left=1,right=n,ans=0;
    while(left<=right){
        int findleft=tree.find(left);
        if(findleft>0){
            ans+=(findleft-1)/a+1;
            tree.update(left,upper_bound(point_monster.begin(),point_monster.end(),point_monster[left-1]+d*2)-point_monster.begin(),((findleft-1)/a+1)*a*-1);
        }
        left++;
        int findright=tree.find(right);
        if(findright>0){
            ans+=(findright-1)/a+1;
            tree.update(lower_bound(point_monster.begin(),point_monster.end(),point_monster[right-1]-d*2)-point_monster.begin()+1,right,((findright-1)/a+1)*a*-1);
        }
        right--;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, c[1010];
int Q, box[1010];
//---------------------------------------------------------------------------------------------------
int solve() {
    cin >> N;
    rep(i, 0, N) cin >> c[i];
    cin >> Q;
    rep(q, 0, Q) {
        int t, x, d; cin >> t >> x >> d;
        x--;

        if (t == 1) {
            box[x] += d;
            if (c[x] < box[x]) return x + 1;
        } else {
            box[x] -= d;
            if (box[x] < 0) return x + 1;
        }
    }
    return 0;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cout << solve() << endl;
}


Measured memory_bytes: 3232
#include <iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<algorithm>
#include<math.h>
using namespace std;

int main()
{
int n;cin>>n;
cout<<pow(n,3);
       return 0;
}


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

using namespace std;


void solve() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int cnt1 = 0;
    while (A > 0) {
        A -= D;
        cnt1++;
    }

    int cnt2 = 0;
    while (C > 0) {
        C -= B;
        cnt2++;
    }

    if (cnt1 < cnt2) cout << "No" << endl;
    else cout << "Yes" << endl;

}


int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

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

int main() {
  int N;
  cin >> N;
  if (N < 1200) cout << "ABC" << endl;
  else if (N < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
  
}


Measured memory_bytes: 256
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var s string
	fmt.Fscan(r, &s)

	ans := isPalindrome(s)
	if !isPalindrome(s[:(len(s)-1)/2]) {
		ans = false
	}

	if ans {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

func isPalindrome(s string) bool {
	t := reverseString(s)
	return s == t
}

func reverseString(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}


Measured memory_bytes: 640
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.Char

main :: IO()
main  = do
    [x1,y1,x2,y2] <- map read . words <$> getLine
    print . sqrt $(x2-x1) ** 2 + (y2-y1)**2 


Measured memory_bytes: 4056
from collections import defaultdict
N = int(input())
if N == 1:
    print(1)
    exit()
X, Y = [], []
for _ in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
d = defaultdict(int)
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        p = X[i] - X[j]
        q = Y[i] - Y[j]
        d[(p, q)] += 1
print(N - max(d.values()))

Measured memory_bytes: 3828
//============================================================================
// Name        : c.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;
int main() {
	int n;cin>>n;
	int m;cin>>m;
	vector<ll> dp(n,0),a(m);
	dp[0]=1;
	ll def=pow(10,9)+7;
	for(auto& x:a){
		cin>>x;
	}
	if(n==1){
		cout<<1<<endl;
		return 0;
	}
	if(m==0){
		m=1;
		a.push_back(0);
	}
	int mi=0;
	while(a[mi]<1){

		if(mi==m-1)break;
		mi++;
	}
	if(a[mi]!=1){
		dp[1]=1;
	}
	for(int i=2;i<n;i++){
		while(a[mi]<i){
			if(mi==m-1)break;
			mi++;
		}
		if(a[mi]!=i){
			dp[i]=dp[i-1]+dp[i-2];
			dp[i]%=def;
		}
	}
	cout<<(dp[n-1]+dp[n-2])%def<<endl;
	return 0;
}


Measured memory_bytes: 1792
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double EPS = 1e-10;
const int MOD = 1000000007;


int main(void) {
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];

  vector<ll> v(N);
  v[N - 1] = A[N - 1];
  for (int i = N - 2; i > 0; --i) {
    v[i] = (A[i] + v[i + 1]) % MOD;
  }

  ll ans = 0;
  ll num;
  rep(i, N - 1) {
    num = A[i] * v[i + 1] % MOD;
    ans = (ans + num) % MOD;
  }

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

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

int main(){
    int n,cnt=0;
    cin>>n;

    for (int i=1;i<n;i++){
        int a=n-i;
        for (int j=1;j*j<=a;j++){
            if(a%j==0){
                if (j*j==a)cnt++;
                else cnt+=2;
            }
        }
    }
    cout<<cnt<<endl;
}


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int a, b;
	cin >> a >> b;

	rep (i, 1, 4) {
		if (i == a || i == b) {
			continue;
		}	else {
			cout << i << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int yld(int qaq) {
	int k=qaq;
	if(qaq-k>=0.5) qaq=k+1;
	else qaq=k;
	return qaq;
}
int main() {
	cin>>n;
	for(int i=1;i<=50000;i++) 
		if(yld(i*1.08)==n) {
			cout<<i;
			return 0;	
		}
	cout<<":(";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<math.h>
#include <algorithm>



int main(void){
    int N=0;
    char S[102]={};
    int max=0;
    int first[26]={};
    int last[26]={};
    int count;
    int a='a';

    int i=0,j=0;

    scanf("%d",&N);
    scanf("%s",S); 
    
    

    for(i=0;i<=25;i++){
        for(j=0;j<=N-1;j++){
            if(S[j]==a+i){
                first[i]=j+1;
                break;
            }
        }

        for(j=N-1;j>=0;j--){
            if(S[j]==a+i){
                last[i]=j+1;
                break;
            }
        }
    }

    for(j=1;j<=N;j++){
        count=0;
        for(i=0;i<=25;i++){
            if(first[i]<=j && j<last[i]){count++;}
        }
        if(max<count){max=count;}
    }

    printf("%d",max);
    return 0;


}



Measured memory_bytes: 256
th, ta, ah, aa = map(int,input().split())
taeru_takahashi = 0
taeru_aoki = 0
if th%aa==0:
    taeru_takahashi = th//aa
else:
    taeru_takahashi = (th//aa)+1
if ah%ta ==0:
    taeru_aoki = ah//ta
else:
    taeru_aoki = (ah//ta)+1
if taeru_takahashi >= taeru_aoki:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9192
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int n, po[13], S[201000], Ans[13][550000];
vector<int>U[13][177147];
char p[201000];
int main(){
    int i, j;
    po[0]=1;
    for(i=0;i<12;i++)po[i+1]=po[i]*3;
    scanf("%d",&n);
    scanf("%s",p);
    for(i=0;p[i];i++){
        S[i+1]=S[i];
        if(p[i]=='S')S[i+1]++;
    }
    int m = i;
    for(i=0;i<3;i++){
        int cur = i;
        for(j=0;p[j];j++){
            if(cur==2 && p[j]=='R'){
                U[1][i].push_back(j);
            }
            if(p[j]=='S'){
                cur=(3-cur)%3;
            }
            else cur=(cur+1)%3;
        }
        Ans[1][i]=cur;
    }
    for(i=1;i<n;i++){
        for(j=0;j<po[i+1];j++){
            int a = j/po[i];
            int b = j%po[i];
            int pv = 0;
            for(auto &t : U[i][b]){
                int s=0;
                if(t)s += S[t];
                if(pv)s -= S[pv];
                if(s&1){
                    a=(3-a)%3;
                }
                a=(a+1)%3;
                if(a==0){
                    if(i+1<n) U[i+1][j].push_back(t);
                }
                pv=t+1;
            }
            int s=S[m];
            if(pv)s -= S[pv];
            if(s&1)a=(3-a)%3;
            Ans[i+1][j] = Ans[i][b] + po[i]*a;
        }
    }
    for(i=0;i<po[n];i++){
        printf("%d ",Ans[n][i]);
    }
}


Measured memory_bytes: 79088
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;

    
    ll n,a,b;
    cin>>n>>a>>b;
    vll G[300010];
    if(a+b>n+1||a*b<n){
        cout<<-1<<endl;
        return 0;
    }
    vll ans;
    ll s=n-a;
    rep(i,a){
        ll num=min(b-1,s)+1;
        s-=num-1;
        rep(j,num) ans.pb(n-num+1+j);
        n-=num;
    }
    reverse(all(ans));
    for(auto i:ans) cout<<i<<" ";
    cout<<endl;
    return 0;
}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

struct xyn{
  LL x, y, n;
  LL find = -2;
  xyn(LL x, LL y, LL n) : x(x), y(y), n(n) {}
};

//昇順ソート
int xcomp(xyn& a, xyn& b) {
	return a.x < b.x;
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

//昇順ソート
int ycomp(xyn& a, xyn& b) {
	return a.y < b.y;
}

#define YSORT(c) sort((c).begin(),(c).end(),ycomp)


//昇順ソート
int fcomp(xyn& a, xyn& b) {
	return a.find < b.find;
}

#define FSORT(c) sort((c).begin(),(c).end(),fcomp)

// size ver
class union_find {
	vector<int> par;
public:
	union_find(int n) : par(n, -1) {}
	int find(int a) {
		return par[a] < 0 ? a : par[a] = find(par[a]);
	}
	bool same(int a, int b) {
		return find(a) == find(b);
	}
	void unite(int a, int b) {
		a = find(a);
		b = find(b);
		if (a == b) return;
		if (par[a] < par[b]) {
			par[a] += par[b];
			par[b] = a;
		}
		else {
			par[b] += par[a];
			par[a] = b;
		}
	}
	int size(int a) {
		return -par[find(a)];
	}
};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  LL N;
  cin >> N;
  vector<xyn> xy;
  REP(i,N){
    LL x,y;
    cin >> x >> y;
    xy.push_back(xyn(x, y, i));
  }

  union_find uf(N);

  XSORT(xy);
  
  REP(i,xy.size()-1){
    if(xy[i].x==xy[i+1].x){
      uf.unite(xy[i].n, xy[i + 1].n);
    }
  }
  
  YSORT(xy);
  
  REP(i,xy.size()-1){
    if(xy[i].y==xy[i+1].y){
      uf.unite(xy[i].n, xy[i + 1].n);
    }
  }

  REP(i,xy.size()){
    xy[i].find = uf.find(xy[i].n);
  }

  FSORT(xy);
  
  LL idx = 0;
  LL sum = 0;
  while (idx < xy.size())
  {
    LL find = xy[idx].find;
    set<LL> xs;
    set<LL> ys;
    LL cnt = 0;
    while (idx < xy.size() && xy[idx].find == find)
    {
      xs.insert(xy[idx].x);
      ys.insert(xy[idx].y);
      cnt++;
      idx++;
    }
    sum += xs.size() * ys.size() - cnt;
  }
  cout << sum << endl;
}


Measured memory_bytes: 8812
h, w = [int(x) for x in input().split()]
S = ['+' * (w + 2)]



def func(i, j):
    cnt = S[i-1][j-1:j+2].count('#')
    cnt += S[i+1][j-1:j+2].count('#')
    cnt += S[i][j-1:j+2:2].count('#')
    
    return str(cnt)

for i in range(h):
    S += [['+']+list(input())+['+']]
S += ['+' * (w + 2)]

for i in range(1,h+1):
    for j in range(1,w+1):
        if S[i][j] == '.':
            S[i][j] = func(i,j)

for s in S[1:h+1]:
    print(''.join(s[1:w+1]))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
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++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    int r;
    cin >> r;
    cout << setprecision(12) << 2 * r * M_PI << endl;
    return 0;
}

Measured memory_bytes: 3788
from collections import defaultdict

n = int(input())
graph = defaultdict(list)
for _ in range(n):
    u, k, *edges = map(int, input().split())
    for i in range(0, len(edges), 2):
        graph[u].append((edges[i], edges[i+1]))

# print(graph)

s = 0
d = [float('inf')] * (n)
fixed = [False] * (n)
d[0] = 0

while True:
    u = None
    d_min = float('inf')
    for i in range(len(d)):
        if not fixed[i] and d[i] < d_min:
            d_min = d[i]
            u = i

    if u is None:
        break            
    fixed[u] = True
    # print('fixed:', u)

    for v, w in graph[u]:
        if not fixed[v]:
            d[v] = min(d[v], d[u]+w)
    # print(d)

# print(d)

for i in range(len(d)):
    print(i, d[i])


Measured memory_bytes: 6532
n = int(input())
red = []
white = []
s = input()

for i in range(n):
    if s[i] == "R":
        red.append(i)
    else:
        white.append(i)

roop_min_num = min(len(red), len(white))

res = 0
for i in range(roop_min_num):
    if white[i] < red[-i - 1]:
        res += 1
print(res)


Measured memory_bytes: 17336
#include <stdio.h>

int main(void) {
  int n, i, a[100];

  scanf("%d", &n);

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

  for (; n--; ) {
    printf("%d", a[n]);
    if (n > 0) {
      putchar(' ');
    }
  }

  putchar('\n');

  return 0;
}

Measured memory_bytes: 600
//package atcoder.dpContest;

import java.io.*;
import java.util.*;

/*
    Knapsack weight is changed from 10^5 to 10^9, so O(N * W) solution is not feasible anymore
    dp[i]: the min total weight of items with total value exactly i

    similar with coin change 2?
 */
public class Main {
    public static void main(String[] args) {
//        try {
//            FastScanner in = new FastScanner(new FileInputStream("src/input.in"));
//            PrintWriter out = new PrintWriter(new FileOutputStream("src/output.out"));
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(1, in, out);
//        }
//        catch (IOException e) {
//            e.printStackTrace();
//        }
    }

    private static void solve(int q, FastScanner in, PrintWriter out) {
        for(int qq = 0; qq < q; qq++) {
            int N = in.nextInt(), W = in.nextInt();
            int[] w = new int[N], v = new int[N];
            int valueSum = 0;
            for(int i = 0; i < N; i++) {
                w[i] = in.nextInt();
                v[i] = in.nextInt();
                valueSum += v[i];
            }

            long[] dp = new long[valueSum + 1];
            Arrays.fill(dp, (long)1e18);
            dp[0] = 0;

            for(int item = 0; item < N; item++) {
                for(int value_already = valueSum - v[item]; value_already >= 0; value_already--) {
                    dp[value_already + v[item]] = Math.min(dp[value_already + v[item]], dp[value_already] + w[item]);
                }
            }
            int ans = 0;
            for(int i = valueSum; i > 0; i--) {
                if(dp[i] <= W) {
                    ans = i;
                    break;
                }
            }
            out.println(ans);
        }
        out.close();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}




Measured memory_bytes: 22484
times = []
min_unit_place = 9
min_unit_index = None

for i in range(5):
  time_i = input()
  times.append(int(time_i))
  unit_place = int(time_i[-1])
  if unit_place > 0 and min_unit_place >= unit_place:
    min_unit_place = unit_place
    min_unit_index = i
  
answer = 0
for i, t in enumerate(times):
  if i == min_unit_index or t%10 == 0:
    answer += t
  else:
    answer = answer + t + (10-t%10)

print(answer)
    

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

int main() {
    int n, a;
    set<int> s;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        if(s.find(a)!=s.end()){
            cout << "NO" << endl;
            return 0;
        }
        s.insert(a);
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
// End of template code!
int main() 
{
    buff();
    int n;
    cin >> n;
    vector<int> v(n);
    for(int& x : v) cin >> x;
    int xola_mais = 0;
    int i = 0;
    while(i < n) {
        int add = (v[i] ^ v[i + 1]);
        xola_mais ^= add;
        i += 2;
    }
    for(int i = 0; i < n; ++i) {
        cout << (xola_mais ^ v[i]) << " ";
    }
    cout << '\n';
    return 0;
}



Measured memory_bytes: 3968
#include<iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include<string>
#include<utility>
#include<iterator>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(lli i=0;i<j;i++)
#define rep1(i,j) for(lli i=1;i<=j;i++)
#define rep0d(i,j) for(lli i=j-1;i>=0;i--)
#define MAX 1000000007
typedef struct tree Tree;

using namespace std;

bool cmpf(pair<lli, lli> left, pair<lli, lli> right) {
	return left.first < right.first;
}

lli check(vector<lli>& vec, lli n,lli cmp, lli num) {
	if (num > 26)return -1;
	if (vec[n] == cmp)return 1;
	else return check(vec, vec[n], cmp, num + 1);
}

int main() {
	lli n, k;
	cin >> n >> k;
	
	vector<lli> p_que(1,0),q_que(1,0),ans;
	rep0(i, n) {
		lli temp;
		cin >> temp;
		if (temp > 0)p_que.push_back(temp);
		else q_que.push_back(temp);
	}
	sort(rall(q_que));
	lli num=0;
	while(num<=k) {
		if (num < p_que.size() && k - num < q_que.size()) {
			ans.push_back(p_que[num] - q_que[k - num]+min(p_que[num] , -q_que[k - num]));
		}
		num++;
	}
	sort(all(ans));
	cout << ans[0];
}


Measured memory_bytes: 1784
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N, A, B = MAP()

print(min(A, B), max(A+B-N, 0))

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N = 2e5+50;
const int M = 1e6;
const ll oo = 1e18;
const int mod = 1e9+7;

ll seg[4*N],h[N],a[N],val;
int l,r;

void update(int n,int s,int e){
	if(s > r || e < l)return;
	if(s == e){
		seg[n] = val;
		return;
	}
	update(n*2,s,(s+e)/2);
	update(n*2+1,(s+e)/2+1,e);
	seg[n] = max(seg[n*2],seg[n*2+1]);
}

ll get(int n,int s,int e){
	if(s > r || e < l)return 0;
	if(s >= l && e <= r)return seg[n];
	return max(get(n*2,s,(s+e)/2) , get(n*2+1,(s+e)/2+1,e));
}

int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	for(int i=1;i<=n;i++)
		cin>>a[i];
	vector<pair<int,pair<int,int>>> v;
	for(int i=1;i<=n;i++)
		v.push_back({h[i],{a[i],i}});
	sort(v.begin(),v.end());
	for(auto cur : v){
		l = 1;
		r = cur.second.second;
		ll b = get(1,1,n);
		l = r = cur.second.second;
		val = b + cur.second.first;
		update(1,1,n);
	}
	cout << seg[1] << endl;
}

Measured memory_bytes: 11504
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long int
#define ff first
#define ss second
#define u128 __int128
#define pb push_back
 
#define N 200010
#define MOD 1000000007


int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	int a[n + 1][n + 1];
	for(int i = 1; i <= n; ++i)
	{
		for(int j = 0; j < n - 1; ++j)
			cin >> a[i][j];
	}

	int po[n + 1] = {};
	int ans = 0;
	while(1)
	{
		int f = 0;
		vector<bool> done(n + 1, 0);
		for(int i = 1; i <= n; ++i)
		{
			if(po[i] == n - 1)
				continue;
			int k = a[i][po[i]];
			if(a[k][po[k]] == i && done[i] == 0 && done[k] == 0)
			{
				f = 1;
				done[i] = done[k] = 1;
				po[i]++, po[k]++;
			}
		}

		if(f == 0)
			break;

		ans++;
	}
	for(int i = 1; i <= n; ++i)
	{
		if(po[i] != n - 1)
		{
			ans = -1; break;
		}
	}
	if(ans == 0)
		ans = -1;
	cout << ans;
	return 0;
}

Measured memory_bytes: 8064
import queue
H, W = map(int, input().split())
numw = 0
S = []
for i in range(H):
  ss = input()
  numw += ss.count(".")
  S.append(ss)
#print(numw)
D = [[-1]*W for i in range(H)]
q = queue.Queue()
q.put((0, 0, 0))
D[0][0] = 0
while not(q.empty()):
  i, j, d = q.get()
  if j > 0 and S[i][j-1] == "." and D[i][j-1] < 0:
    D[i][j-1] = d+1
    q.put((i, j-1, d+1))
  if i > 0 and S[i-1][j] == "." and D[i-1][j] < 0:
    D[i-1][j] = d+1
    q.put((i-1, j, d+1))
  if j+1 < W and S[i][j+1] == "." and D[i][j+1] < 0:
    D[i][j+1] = d+1
    q.put((i, j+1, d+1))
  if i+1 < H and S[i+1][j] == "." and D[i+1][j] < 0:
    D[i+1][j] = d+1
    q.put((i+1, j, d+1))
#print(D)
if D[H-1][W-1] < 0:
  print(-1)
  exit()
r = numw-D[H-1][W-1]-1
print(r)


Measured memory_bytes: 3952
N,X,M = map(int,input().split())

data = [X for i in range(M+1)]
val = set([X])

start = -1
period = -1
for i in range(1,M+1):
    data[i] = pow(data[i-1],2,M)
    if data[i] in val:
        for j in range(0,i):
            if data[j]==data[i]:
                start = j
                period = i-j
                break
        break
    else:
        val.add(data[i])

if N<=M:
    print(sum(data[:N]))
else:
    res = sum(data[:start])

    backet = sum(data[start:start+period])
    Q = (N - start) // period
    R = (N- start) % period

    res += backet*Q + sum(data[start:start+R])
    print(res)


Measured memory_bytes: 76340
def m(L,R):
 global c;c+=len(L)+len(R)
 T=[]
 for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
 return R+T[::-1]
def d(A):s=len(A)//2;return m(d(A[:s]),d(A[s:])) if len(A)>1 else A
c=0
input()
print(*d(list(map(int,input().split()))))
print(c)


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

int d[110][110] = {};
int n, m, inf = 1e9 + 7, a[1010], b[1010], c[1010], ans;
bool used[1010];

void warshall_floyd(int n)
{
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            for (int k = 0; k < n; k++)
            {
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }
}

int main()
{
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            d[i][j] = (i == j ? 0 : inf);
        }
    }
    for (int i = 0; i < m; i++)
    {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--, b[i]--, d[a[i]][b[i]] = c[i], d[b[i]][a[i]] = c[i];
    }
    warshall_floyd(n);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (i == j)
                continue;
            for (int k = 0; k < m; k++)
            {
                used[k] = used[k] || d[i][a[k]] + c[k] + d[b[k]][j] == d[i][j] || d[i][b[k]] + c[k] + d[a[k]][j] == d[i][j];
            }
        }
    }
    for (int i = 0; i < m; i++)
        ans += !used[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
int main(){
  int n, x[120], i, j, min1 = 1e9, sum = 0;
  scanf("%d",&n);
  for (i = 0; i < n; i++) scanf("%d",&x[i]);
  for (i = 0; i <= 100; i++) {
    for(j = 0; j < n; j++) sum += (x[j]- i)*(x[j] - i);
    if(sum<min1) min1 = sum;
    sum = 0;
  }
  printf("%d\n",min1);
  return 0;
}

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

ll two_pow(ll n){
  if (n==0) return 1;
  if (n==1) return 2;
  return two_pow(n/2) * two_pow(n/2) * two_pow(n%2);
}

ll count(string &s, ll head, ll tail){
  ll ans = stoll(s.substr(head, tail-head));
  for (ll i=head+1; i<tail; i++){
    ans += stoll(s.substr(head, i-head)) * two_pow(tail - i - 1);
    ans += count(s, i, tail);
  }
  return ans;
}

int main(){
  string s;
  cin >> s;
  cout << count(s, 0, s.size()) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>

using namespace std;

int simulation(int n_player, int interval)
{
  int player;
  int counter = 0;
  queue<int> que;

  for(int i = 1; i <= n_player; ++i)
    que.push(i);

  while(que.size() > 1){
    player = que.front();
    que.pop();

    if(++counter == interval){
      counter = 0;
    } else {
      que.push(player);
    }
  }

  return que.front();
}

int main()
{
  int n_player, interval;

  while(cin>>n_player>>interval){
    if(n_player == 0 && interval == 0) break;

    cout << simulation(n_player, interval) << endl;
  }

  return 0;
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n,a=0,t;
  cin>>n;
  unordered_map <string,long long> m;
  for(long long i=0;i<n;i++) {
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    m[s]++;
  }
  for(auto x:m) {
    t=x.second;
    a+=(t*(t-1))/2;
  }
  cout<<a;
  return 0;
}


Measured memory_bytes: 10660
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	string s; cin >> s;
	int cnt[3] = {};
	int len = s.length();
	rep(i, len) {
		cnt[s[i] - 'a']++;
	}
	if (abs(cnt[0] - cnt[1]) <= 1 && abs(cnt[0] - cnt[2]) <= 1 && abs(cnt[2] - cnt[1]) <= 1)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; ++i)
#define int long long
#ifdef DEBUG
#define dout cout
#else
std::stringstream dout;
#endif
using namespace std;
typedef pair<int, int> P;
struct edge {
  int to, cost;
};
// other libs
int gcd(int a, int b) {
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
int lcm(int a, int b) {
  return a * b / gcd(a, b);
}

class dijkstra {
private:
  int V;
  int d[100002];
  priority_queue<P, vector<P>, greater<>> que;

public:
  dijkstra(int v, int s, vector<edge> G[]) {
    V = v;
    update(s, G);
  }

  void update(int s, vector<edge> G[]) {
    fill(d, d + V + 1, 100000000000ll);
    d[s] = 0;
    que.push(make_pair(0, s));
    while (!que.empty()) {
      P p = que.top();
      que.pop();
      int v = p.second;
      if (d[v] < p.first)
        continue;
      rep(i, G[v].size()) {
        edge e = G[v][i];
        if (d[e.to] > d[v] + e.cost) {
          d[e.to] = d[v] + e.cost;
          que.push(make_pair(d[e.to], e.to));
        }
      }
    }
  }

  int find(int e) {
    return d[e];
  }
};
template<typename T>
class Union_Find {
private:
  vector<T> t, s;

public:
  Union_Find(T max_length) {
    rep(i, max_length + 1) {
      t.push_back(i);
      s.push_back(1);
    }
  }

  void Union(T x, T y) {
    if (same(x, y))
      return;
    T tx = Find(x), ty = Find(y);
    if (s[tx] < s[ty]) {
      s[ty] += s[tx];
      t[tx] = ty;
    }
    else if (s[tx] > s[ty]) {
      s[tx] += s[ty];
      t[ty] = tx;
    }
    else if (tx > ty) {
      t[tx] = ty;
      s[ty] += s[tx];
    }
    else {
      t[ty] = tx;
      s[tx] += s[ty];
    }
  }
  T Find(T n) {
    if (t[n] == n)
      return n;
    else
      return t[n] = Find(t[n]);
  }

  bool same(T x, T y) {
    return Find(x) == Find(y);
  }

  T get_Size(size_t a) {
    return s[a];
  }
};
bool ifPrime(int n) {
  if (n == 1)
    return false;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  return true;
}

set<int> prime_num_factor(int n){
  if(n<2)return set<int>();
  set<int> prime;
  prime.insert(2);
  for(int i=3;i<=n;i++){
    for(int it:prime){
      if(it*it>i){
        prime.insert(i);
        break;
      }
      if(i%it==0)break;
    }
  }
  return prime;
}
vector<int> makeDivisors(int n){
  vector<int> re;
  REP(i,1,sqrt(n)+1){
    if(n%i==0){
      re.push_back(i);
      if(i!=n/i)re.push_back(n/i);
    }
  }
  return re;
}
int modPow(int a,int n,int mod){
  int ret=1;
  while(n){
    if(n&1)ret=ret*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return ret;
}
signed main(signed argc, char* argv[]) {
  int a,b;
  cin>>a>>b;
  if(0<a&&a<10&&0<b&&b<10)cout<<a*b<<endl;
  else cout<<-1<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<par<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int a,b;
    cin>>a>>b;
    cout<<(a<=8&&b<=8?"Yay!":":(")<<endl;
}

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


int a[9][9];
bool f[9][9];


int main(){
	int n;
	cin>>n;
	while(n--){
		for(int i=0;i<9;i++){
			for(int j=0;j<9;j++){
				cin>>a[i][j];
				f[i][j]=false;
			}
		}
		int c[10];
		for(int i=0;i<9;i++){
			memset(c,0,sizeof(c));
			for(int j=0;j<9;j++){
				c[a[i][j]]++;
			}
			for(int j=0;j<9;j++){
				if(1<c[a[i][j]])f[i][j]=true;
			}
		}
		for(int j=0;j<9;j++){
			memset(c,0,sizeof(c));
			for(int i=0;i<9;i++){
				c[a[i][j]]++;
			}
			for(int i=0;i<9;i++){
				if(1<c[a[i][j]])f[i][j]=true;
			}
		}
		for(int y=0;y<9;y+=3)for(int x=0;x<9;x+=3){
			memset(c,0,sizeof(c));
			for(int i=0;i<3;i++)for(int j=0;j<3;j++){
				c[a[y+i][x+j]]++;
			}
			for(int i=0;i<3;i++)for(int j=0;j<3;j++){
				if(1<c[a[y+i][x+j]])f[y+i][x+j]=true;
			}
		}
		for(int i=0;i<9;i++){
			for(int j=0;j<9;j++){
				if(f[i][j])cout<<'*';
				else cout<<' ';
				cout<<a[i][j];
			}
			cout<<endl;
		}
		if(n)cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);
bitset<1000001> flag;
vector<int> v[1000001];

int main() {
	int N, x;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &x);
		v[x].pb(i);
	}
	for (int i = 1; i <= 1e6; i++) {
		if (!v[i].empty()) {
			if (v[i].size() > 1) {
				for (auto j : v[i]) flag[j] = 1;
			}
			for (int j = 2 * i; j <= 1e6; j += i) {
				for (auto k : v[j]) {
					flag[k] = 1;
				}
				while (!v[j].empty()) v[j].pop_back();
			}
			while (!v[i].empty()) v[i].pop_back();
		}
	}
	int ans = 0;
	for (int i = 0; i < N; i++) if (!flag[i]) ans++;
	printf("%d\n", ans);
}

Measured memory_bytes: 33476
#include<iostream>
using namespace std;
int main(void){
    int a{},b{},c{},n{};
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b>>c;
        if(((a*a)==((b*b)+(c*c)))||((b*b)==((a*a)+(c*c)))||((c*c)==((a*a)+(b*b))))
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

const int N = (int) 1e5;

ll ans;

int n;
int k;

int a[N];
int b[N];

int msb(int x) {
	int ans = 29;
	while (ans >= 0 && (x & (1 << ans)) == 0) {
		ans--;
	}
	return ans;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		if ((a[i] & ~k) == 0) {
			ans += b[i];
		}
	}
	for (int i = msb(k), mask = 0; i >= 0; i = msb(k)) {
		ll res = 0;
		int cur = mask | ((1 << i) - 1);
		for (int j = 0; j < n; j++) {
			if ((a[j] & ~cur) == 0) {
				res += b[j];									
			}
		}
		ans = max(ans, res);
		mask |= 1 << i;
		k -= 1 << i;
	}
	cout << ans;
}

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

#define int long long
#define double long double
#define pb push_back

typedef vector<int, int> vii;
typedef pair<int, int> pii;

const int inf = 2e18;

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
   
    double b,a;
    cin>>a >> b;
    double f= a*b;
    cout<<(int)f<<endl; 
}



Measured memory_bytes: 3752
using System;

namespace CA {
	class Program {
		static void Main(string[] args) {
			int i = int.Parse(Console.ReadLine());
			int[,,] r = new int[4,3,10];
			while(i-- != 0) {
				string[] s = Console.ReadLine().Split(' ');
				r[int.Parse(s[0]) - 1, int.Parse(s[1]) - 1, int.Parse(s[2]) - 1] += int.Parse(s[3]);
			}
			for(i = 0; i < 4; i++) {
				for(int j = 0; j < 3; j++) {
					for(int k = 0; k < 10; k++) {
						Console.Write(" " + r[i, j, k]);
					}
					Console.WriteLine();
				}
				if (i == 3)	break;
				Console.WriteLine("####################");
			}
		}
	}
}

Measured memory_bytes: 9140
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n,m;
    scanf("%d%d", &n, &m);

    vector<int> a(n+1);
    int i;
    for(i=0; i<m; i++) {
        int tmp;
        scanf("%d", &tmp);
        a[tmp]=1;
    }

    vector<ll> dp(n+1,0);
    dp[0]=1;
    dp[1]=(a[1]? 0: 1);
    for(i=2; i<=n; i++) {
        if(a[i]==0) dp[i]=(dp[i-2]+dp[i-1])%MOD;
    }
    printf("%d\n", dp[n]);

    return 0;
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
	int n,c;
	cin >> n >> c;
	int a,sum = 0;
	
	rep(i,0,c){
	    cin >> a;
	    sum += a;
	}
	
	
	if(sum % (n+1) != 0){
	    cout << sum/(n+1) +1 << endl;
	}
	else {
	    cout << sum/(n+1) << endl;
	}
	
	
	
	return 0;
}


Measured memory_bytes: 3108