akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
	#define int ll
	cin.tie(0);
	ios::sync_with_stdio(false);
	// ここに処理を記述

	string S;
	cin >> S;

	if(S[2] == S[3] && S[4] == S[5]){
		cout << "Yes" << "\n";
	}
	else{
		cout << "No" << "\n";
	}

	return 0;
}

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

signed main(){
	int n;
	while(cin >> n,n){
		int w[310];
		for(int i = 0;i < n;i++) cin >> w[i];
		int dp[310][310] = {};
		for(int i = 2;i <= n;i++){
			for(int j = 0;j < n - i + 1;j++){
				if(dp[j + 1][j + i - 1] == i - 2 && abs(w[j] - w[j + i - 1]) <= 1){
					dp[j][j + i] = i;
				}
				for(int k = j + 1;k < j + i;k++){
					dp[j][j + i] = max(dp[j][j + i],dp[j][k] + dp[k][j + i]);
				}
			}
		}
		cout << dp[0][n] << endl;
	}
}


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n, m, id;
	cin >> n >> m >> id;
	vector<string> a(n);
	for (auto &i : a) cin >> i;

	vector<vector<int>> ans(n, vector<int>(m));
	for (int j = 0; j < m; ++j)
	{
		bool f = false;
		for (int i = 0; i < n; ++i)
			if (a[i][j] == '#')
			{
				f = true;
				ans[i][j] = id;
				for (int k = i-1; k >= 0; --k)
				{
					if (a[k][j] == '#' || ans[k][j]) break;
					ans[k][j] = id;
				}
				for (int k = i+1; k < n; ++k)
				{
					if (a[k][j] == '#' || ans[k][j]) break;
					ans[k][j] = id;
				}
				--id;
			}
		if (!f && j > 0)
			for (int i = 0; i < n; ++i)
				ans[i][j] = ans[i][j-1];
	}

	for (int j = 0; j < m; ++j)
		if (ans[0][j])
		{
			for (int k = 0; k < j; ++k)
				for (int i = 0; i < n; ++i)
					ans[i][k] = ans[i][j];
			break;
		}

	for (auto &i : ans)
		for (auto &j : i)
			cout << j << " \n"[&j==&i.back()];

	return 0;
}


Measured memory_bytes: 1280
//Abraao Caiana de Freitas - UFCG

#include <bits/stdc++.h>
#define mod 1000000007
#define maxx 100010
using namespace std;
long long dp[200][maxx],arr[200];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
	cin>>n>>m;
	for(int i = 1; i <= n; i++){cin>>arr[i];dp[i][0]=1;}
	for(int i = 0; i <= m; i++)dp[1][i]=(i<=arr[1]?1:0);
	for(int i = 2; i <= n; i ++){
		for(int j = 1; j <= m; j++){
			long long extra=0;
			if(j>arr[i])extra=dp[i-1][j-arr[i]-1];
			dp[i][j]=((mod+dp[i-1][j]+dp[i][j-1])-extra)%mod;
		}
	}
	cout<<dp[n][m]<<"\n";
	return 0;
}

Measured memory_bytes: 81772
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double x1 = scanner.nextDouble();
        double x2 = scanner.nextDouble();
        double y1 = scanner.nextDouble();
        double y2 = scanner.nextDouble();
 
        System.out.println(Math.sqrt(Math.pow(y1 - x1, 2)
                + Math.pow(y2 - x2, 2)));
    }
}


Measured memory_bytes: 28128
#include<stdio.h>

int main(){
    int n, q;
    long int sum=0, count[1<<20]={0}, p;
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%ld", &p);
        count[p]++;
        sum = sum + p;
    }
    scanf("%d", &q);
    int b[1<<20], c[1<<20];
    for(int i=0; i<q; i++){
        scanf("%d%d", &b[i], &c[i]);
        sum = sum + (c[i]-b[i])*count[b[i]];
        printf("%ld\n", sum);
        count[c[i]] = count[c[i]] + count[b[i]];
        count[b[i]] = 0;
    }
}





Measured memory_bytes: 10680
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 1000 + 47;
const int MOD = 1000 * 1000 * 1000 + 7;

string A[MAX];
struct Matrix
{
	LL T[2][2];
	Matrix()
	{
		FOR(i, 0, 2) FOR(j, 0, 2) T[i][j] = 0;
	}

	void one()
	{
		T[0][0] = T[1][1] = 1;
	}

	void operator *=(Matrix a)
	{
		LL R[2][2] = {0};
		FOR(i, 0, 2)
		{
			FOR(j, 0, 2)
			{
				FOR(k, 0, 2)
				{
					R[i][j] = (R[i][j] + T[i][k] * a.T[k][j]) % MOD;
				}
			}
		}

		FOR(i, 0, 2)
		{
			FOR(j, 0, 2) T[i][j] = R[i][j];
		}
	}

	void print()
	{
		FOR(i, 0, 2)
		{
			FOR(j, 0, 2) cout << T[i][j] << " ";
			cout << endl;
		}
	}
};

void bp(Matrix& A, LL k)
{
	Matrix R;
	R.one();

	while (k)
	{
		if (k & 1)
		{
			R *= A;
		}

		k >>= 1;
		A *= A;
	}

	FOR(i, 0, 2)
	{
		FOR(j, 0, 2) A.T[i][j] = R.T[i][j];
	}
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n, m;
	LL k;
	cin >> n >> m >> k;

	FOR(i, 0, n) cin >> A[i];
	LL cnt = 0;
	bool ver = false;
	bool hor = false;
	FOR(i, 0, n)
	{
		if (A[i][0] == A[i][m - 1] && A[i][0] == '#') hor = true;
	}

	FOR(j, 0, m)
	{
		if (A[0][j] == A[n - 1][j] && A[0][j] == '#') ver = true;
	}
	
	FOR(i, 0, n)
	{
		FOR(j, 0, m) cnt += A[i][j] == '#';
	}

	if (ver && hor)
	{
		cout << 1 << endl;
		return 0;
	}

	if (!ver && !hor)
	{
		Matrix res;
		res.T[0][0] = cnt;
		bp(res, k - 1);
		cout << res.T[0][0] << endl;
		return 0;
	}

	LL w = 0;
	LL b = 0;

	if (hor)
	{
		FOR(i,0,n)
		{
			FOR(j, 1, m)
			{
				if (A[i][j] == A[i][j - 1] && A[i][j] == '#') w++;
			}

			if (A[i][0] == A[i][m - 1] && A[i][0] == '#') b++;
		}
	}
	else
	{
		FOR(j, 0, m)
		{
			FOR(i, 1, n)
			{
				if (A[i - 1][j] == A[i][j] && A[i][j] == '#') w++;
			}

			if (A[0][j] == A[n - 1][j] && A[0][j] == '#') b++;
		}
	}

	Matrix res;
	res.T[0][0] = b;
	res.T[0][1] = w;
	res.T[1][0] = 0;
	res.T[1][1] = cnt;
	//res.print();

	bp(res, k - 1);
	w = res.T[0][1];
	b = res.T[1][1];
	cout << (b - w + MOD) % MOD << endl;
}

Measured memory_bytes: 1920
n,k,s=map(int,input().split())


if s==10**9:
    a=[10**9 for i in range(k)]+[1 for i in range(n-k)]

else:
    a=[s for i in range(k)]+[s+1 for i in range(n-k)]

for i in range(n-1):
    print(a[i],end=" ")
print(a[n-1])

Measured memory_bytes: 7968
import java.util.*;
import java.io.*;

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args) throws IOException{
		NScanner sc = new NScanner(System.in);
		int r = sc.nextInt();
		int c = sc.nextInt();
		int sum = 0;
		int[] sumCol = new int[c];
		Arrays.fill(sumCol, 0);
		for(int i = 0; i < r; ++i){
			int sumRow = 0;
			for(int j = 0; j < c; ++j){
				int a = sc.nextInt();
				sumRow += a; sum += a;
				sumCol[j] += a;
				System.out.printf("%d ", a);
			}
			System.out.println(sumRow);
		}
		for(int j = 0; j < c; ++j)
			System.out.printf("%d ", sumCol[j]);
		System.out.println(sum);
		
	}

}

class NScanner{

	private BufferedReader br;
	private StringTokenizer tok;

	public NScanner(InputStream is) throws IOException{
		br = new BufferedReader(new InputStreamReader(is));
		getLine();
	}

	private void getLine() throws IOException{
		while(tok == null || !hasNext()){
			tok = new StringTokenizer(br.readLine());
		}
	}

	private boolean hasNext(){
		return tok.hasMoreTokens();
	}

	public String next() throws IOException{
		if(hasNext()){
			return tok.nextToken();
		}else{
			getLine();
			return tok.nextToken();
		}
	}

	public int nextInt() throws IOException{
		if(hasNext()){
			return Integer.parseInt(tok.nextToken());
		}else{
			getLine();
			return Integer.parseInt(tok.nextToken());
		}
	}

	public long nextLong() throws IOException{
		if(hasNext()){
			return Long.parseLong(tok.nextToken());
		}else{
			getLine();
			return Long.parseLong(tok.nextToken());
		}
	}

	public double nextDouble() throws IOException{
		if(hasNext()){
			return Double.parseDouble(tok.nextToken());
		}else{
			getLine();
			return Double.parseDouble(tok.nextToken());
		}
	}
}


Measured memory_bytes: 41056
import numpy as np

N, K = map(int, input().split())
A = list(map(int, input().split()))
M = 10**9 + 7

def prod(X):
    ans = 1
    for x in X:
        ans = ans * x % M
    return ans

def solve():
    # Case 1: N == K
    if N == K:
        return prod(A)

    # Case 2: ans is negative
    if all(a < 0 for a in A) and K % 2 == 1:
        return prod(sorted(A)[-K:])

    # Case 3: ans is positive
    posA = np.int64(sorted([a for a in A if a >= 0]))
    negA = np.int64(sorted([a for a in A if a < 0]))

    ans = 1
    if K % 2 == 1: # Keep the largest positive
        ans = ans * posA[-1] % M
        posA = posA[:-1]
    
    # Construct largest value by pairing items
    if len(posA) % 2 == 1: # Discard the one with smallest absolute value
        posA = posA[1:]
    if len(negA) % 2 == 1: # Discard the one with smallest absolute value
        negA = negA[:-1]
    pos_pairs = posA[0::2] * posA[1::2]
    neg_pairs = negA[0::2] * negA[1::2]
    pairs = np.concatenate([pos_pairs, neg_pairs], axis=0).tolist()
    pairs = sorted(pairs, reverse=True)[:K//2]
    ans = ans * prod(pairs) % M

    return ans

print(solve())
        


Measured memory_bytes: 50052
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
    int h,w;
    cin >> h >> w;
    char s[50][50];
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            cin >> s[i][j];
        }
    }

    bool flag = true;
    int d[2] = {-1,1};
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            if (s[i][j] == '#')
            {
                bool ch = false;
                // for(int dx = 0; dx < 4; dx++)
                // {
                //     for(int dy = 0; dy < 4; dy++)
                //     {
                //         if (0 <= i+dy && i+dy < h && 0 <= j+dx && j+dx < w && s[i+dy][j+dx] == '#')
                //         {
                //             ch = true;
                //         }
                //     }
                // }

                for(int dx = 0; dx < 2; dx++)
                {
                    if (0 <= j+d[dx] && j+d[dx] < w && s[i][j+d[dx]] == '#')
                    {
                        ch = true;
                    }
                }
                for(int dy = 0; dy < 2; dy++)
                {
                    if (0 <= i+d[dy] && i+d[dy] < h && s[i+d[dy]][j] == '#')
                    {
                        ch = true;
                    }
                }

                if(!ch)
                {
                    flag = false;
                    break;
                }
            }
        }
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main() {
  char a[100][101],b[102][102];
  int H,W;
  cin >> H>>W;
  for(int i = 0;i<H;i++)
   cin >> a[i];
  for (int i= 0;i<H+2;i++){
    for(int j= 0;j<W+2;j++){
      b[i][j]='#';
    }
  }
for(int i= 0;i<H;i++){
 for(int j = 0;j<W;j++){
   b[i+1][j+1]=a[i][j];
 }
}
for(int i = 0;i<H+2;i++){
  for(int j = 0;j<W+2;j++)
    cout <<b[i][j];
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000
int MOD=1000000007;
int modpow(int a,int x){
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}
int gyaku(int n){
    return modpow(n,MOD-2);
}
signed main() {
  int n;
  cin>>n;
  int a=0,b=0,c=0,d=0;
  rep(i,n){
    string s;
    cin>>s;
    if(s=="AC")a++;
    if(s=="WA")b++;
    if(s=="TLE")c++;
    if(s=="RE")d++;
  }
  cout<<"AC x "<<a<<endl<<"WA x "<<b<<endl<<"TLE x "<<c<<endl<<"RE x "<<d<<endl;
}


Measured memory_bytes: 3640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal, ROUND_CEILING
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

H, W, M = MAP()

h, w = ZIP(M)
cnt_h = Counter(h)
hm = max(cnt_h.values())
cnt_w = Counter(w)
wm = max(cnt_w.values())
hl = [k for k, v in cnt_h.items() if v == hm]
wl = [k for k, v in cnt_w.items() if v == wm]

s = set()
for h_, w_ in zip(h, w):
    s.add((h_, w_))

ans = hm + wm

for i in hl:
    for j in wl:
        if (i, j) not in s:
            break
    else:
        continue
    break
else:
    ans -= 1
print(ans)


Measured memory_bytes: 167360
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pradyumn Agrawal coderbond007
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            BigInteger bg1 = in.nextBigInteger();
            BigInteger bg2 = in.nextBigInteger();
            if (bg1.compareTo(bg2) > 0) {
                out.println("GREATER");
            } else if (bg1.compareTo(bg2) < 0) {
                out.println("LESS");
            } else {
                out.println("EQUAL");
            }
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int pnumChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public BigInteger nextBigInteger() {
            try {
                return new BigInteger(nextString());
            } catch (NumberFormatException e) {
                throw new InputMismatchException();
            }
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21460
w,h,n = map(int,input().split())
i = 0
x_1 =0
x_2 =w
y_1 =0
y_2 =h
for i in range(n):
    x,y,z = map(int,input().split())
    if z == 1 and x > x_1 :
        x_1 = x
    if z == 2 and x < x_2 :
        x_2 = x
    if z == 3 and y > y_1:
        y_1 = y
    if z == 4 and y < y_2:
        y_2 = y
if x_2 > x_1 and y_2 > y_1:
    print((x_2-x_1)*(y_2-y_1))
else:
    print(0)


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

vector<pair<long long,long long>> func(long long P){
    
    vector<pair<long long,long long>> res;
    for(long long i = 2; i*i <= P ;i++ ){
        if(P%i!=0)continue;
        int ans = 0;
        while(P%i==0){P/=i;ans++;}
        res.push_back(make_pair(ans,i));
    }
    if (P != 1) res.push_back(make_pair(1, P));
    return res;
}


int main(){

    long long N,P;
    cin >> N >> P;
    vector<pair<long long,long long>> res = func(P);
    long long ans = 1;
    for(auto u:res){
        for(long long i = 0; i < u.first/N;i++)ans *= u.second;
        
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return a1.size() - a2.size();
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

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

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

bool is_prime(int a) {
  int i = 2;
  while(i * i <= a) {
    if(a % i == 0) {
      return false;
    }
    i++;
  }
  return true;
}

int main() {
  std::cout << std::setprecision(9);
  int n;
  cin >> n;

  vector<string> s(n);
  for(int i=0; i<n; i++) {
    cin >> s[i];
  }
  sort(s.begin(), s.end());
  s.erase(unique(s.begin(), s.end()), s.end());
  
  cout << s.size() << endl;
}

Measured memory_bytes: 9580
#include <bits/stdc++.h>
#define INF 1.0e9
#define MOD 1.0e9+7
using namespace std;
typedef long long ll;

int N, K;

int main() {
    cin >> N >> K;
    if (K % 2 == 0) {
        ll cnt = N/K;
        ll a = 2*N/K;
        ll cnt2 = a - cnt;
        cout << (ll)pow(cnt, 3) + (ll)pow(cnt2, 3)<< endl;
    }
    else {
        ll cnt = N/K;
        cout << (ll)pow(cnt, 3) << endl;
    }
    return 0;
}

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

int main (){
  int a,b,A;
  cin >> a >> b;
  A = a*b;
  if ( A%2 == 1 ){
    cout <<"Odd" << endl;
  }
  else {
    cout <<"Even" << endl;
  }
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include <vector>
#include <cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
 const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/


signed main() {
    COMinit();
	ll n,k;
  	ci(n>>k)
    FOR(i,1,k+1){
      ll ans=1;
      ans*=combi(n-k+1,i);
      ans*=combi(k-1,i-1);
      ans%=1000000007;
   co(ans)
}
}


Measured memory_bytes: 12160
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=100000000000007;
const int MOD=1000000007;
signed main(){
  int n,k;cin>>n>>k;
  int del=0;int spe=0;int sum=0;
  vector<pair<int,int>> susi(n);
  rep(i,n){
    cin>>susi[i].second>>susi[i].first;
  }
  sort(ALL(susi));
  reverse(ALL(susi));
  vector<int> neta(n+2,0);
  vector<int> kaburi;
  rep(i,k){
    del+=susi[i].first;
    if(neta[susi[i].second]==0){
      neta[susi[i].second]++;
      spe++;
    }
    else{
      kaburi.push_back(susi[i].first);
    }
  }
  reverse(ALL(kaburi));
  kaburi.push_back(inf);
  susi.push_back(make_pair(0,0));
  int p=0;
  sum=del+spe*spe;
  int j=k;
  for(int i=spe+1;i<=k;i++){
    while(neta[susi[j].second]!=0){
      j++;
    }
    if(j>=n)break;
    if(kaburi[p]==inf)break;
    del-=kaburi[p];
    p++;
    del+=susi[j].first;
    neta[susi[j].second]++;
    spe++;
    sum=max(sum,del+i*i);
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 5880
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL){
    x=x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right!=NIL){
    x=x->right;
  }
  return x;
}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key){
    return u;
  }
  if(k<u->key){
    return treeSearch(u->left,k);
  }else{
    return treeSearch(u->right,k);
  }
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL){
    return treeMinimum(x->right);
  }
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  
  if(z->left==NIL || z->right==NIL){
    y=z;
  }else{
    y=treeSuccessor(z);
  }

  if(y->left!=NIL){
    x=y->left;
  }else{
    x=y->right;
  }

  if(x!=NIL){
    x->parent=y->parent;
  }

  if(y->parent==NIL){
    root=x;
  }else if(y==y->parent->left){
    y->parent->left=x;
  }else{
    y->parent->right=x;
  }
  if(y!=z){
    z->key=y->key;
  }
  free(y);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent=y;

  if(y==NIL){
    root=z;
  }else if(z->key<y->key){
    y->left=z;
  }else{
    y->right=z;
  }
}

void inorder(Node u){
  if(u==NIL){
    return;
  }
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL){
    return;
  }
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25236
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

const int N = 1e4 + 5;

ll get(ll x, ll y, ll MOD) {
  ll res = 1LL;
  while(y) {
    if(y & 1) res = (res * x) % MOD;
    y >>= 1LL;
    x = (x * x) % MOD;
  }
  return res;
}

int moves(ll x) {
  int ans = 0;
  while(x) {
    x = x % __builtin_popcountll(x);
    ans++;
  }
  return ans;
}

void solve() {
  int n; cin >> n;
  string s; cin >> s;
  int have = count(s.begin(), s.end(), '1');
  map <ll, ll> val;
  for(ll can : {have - 1, have, have + 1}) {
    if(can <= 0) continue;
    ll cur = 0ll;
    for(int i = 0; i < n; i++) {
      if(s[i] == '1') cur = (cur + get(2LL, n - i - 1LL, can)) % can;
    }
    val[can] = cur;
  }
  for(int i = 0; i < n; i++) {
    if(s[i] == '0') {
      ll cur = val[have + 1];
      cur = (cur + get(2LL, n - i - 1LL, have + 1)) % (have + 1);
      print(moves(cur) + 1);
    }
    else {
      if(val.count(have - 1) == 0) {
        print(0);
        continue;
      }
      ll cur = val[have - 1];
      cur = (cur - get(2LL, n - i - 1LL, have - 1)) % (have - 1);
      if(cur < 0) cur += (have - 1);
      print(moves(cur) + 1);
    }
  }
}

int main() {
  int t; t = 1;
  while(t--) solve();
}




Measured memory_bytes: 3756
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>

 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;

int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
 
//    auto start = chrono::steady_clock::now();
  
//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n);
        vector<tuple<int,int,int>> kyu;
        kyu.push_back(make_tuple(400,599,8));
        kyu.push_back(make_tuple(600,799,7));
        kyu.push_back(make_tuple(800,999,6));
        kyu.push_back(make_tuple(1000,1199,5));
        kyu.push_back(make_tuple(1200,1399,4));
        kyu.push_back(make_tuple(1400,1599,3));
        kyu.push_back(make_tuple(1600,1799,2));
        kyu.push_back(make_tuple(1800,1999,1));

        for(auto x : kyu) {
            if ((n>=get<0>(x)) && (n<=get<1>(x))) {
                cout << get<2>(x) << endl;
            }
        }

    }
 
//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;



int main() {
    
    // int n,k;
    // cin>>n>>k;
    // vi v(n);
    // rep(i,n)cin>>v[i];
    // Sort(v);
    // int ans=0;
    // rep(i,k)ans+=v[i];
    // fin(ans);
    char c;
    cin>>c;
    if(c>='A'&&c<='Z')fin("A");
    else fin("a");
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define INF 1000000000

using namespace std;

int n=0;
int arr[200001];
int pos[200001];

int main()
{
	cin >> n;
	for (int i=0; i<n; i++){
		cin >> arr[i];
	}
	int x = 1, mx=0;
	for (int i=0; i<n; i++)
	{
		if (arr[i]==x)
		{
			mx = max(mx, x);
			x++;
		}
	}
	if (mx==0)
		cout << -1;
	else
		cout << n-mx;
	return 0;
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  string s;
  cin >> s;
  vector<int> ch(0);
  int i;
  int n = s.size();
  rep(i,n)
  {
    if(s[i] == 'A')
    {
      ch.emplace_back(1);
    }
    else if(s[i] == 'B' && i < n-1)
    {
      if(s[i+1] == 'C')
      {
        ch.emplace_back(0);
        i++;
      }
      else
      {
        ch.emplace_back(-1);
      }
    }
    else
    {
      ch.emplace_back(-1);
    }
  }
  int m = ch.size();
  int las0 = m-1;
  ll ans = 0;
  for(i=m-1;i>=0;i--)
  {
    if(ch[i] == -1)
    {
      las0 = i-1;
    }
    else if(ch[i] == 1)
    {
      int add = las0-i;
      ans += add;
      las0--;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 1660
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;

#define pt pair<int, int>
#define x first
#define y second
#define int long long
#define what_is(x) cerr << #x << " is " << x << endl;

set<int> st;

bool check(int x)
{
	while (x)
	{
		if (st.count(x % 10))
			return 1;
		x /= 10;
	}

	return 0;
}

signed main()
{
	cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);

	int n, k, temp;
	cin >> n >> k;
	for (int i = 0; i < k; ++i)
	{
		cin >> temp;
		st.insert(temp);
	}

	while (check(n))
		++n;
	cout << n << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int n, k, count=0;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) { 
    cin >> a.at(i);
    if(a.at(i) >= k) {
      count++;
    }
  }
  cout << count;
}



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

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

  vector<int> a(N); 

  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  int i=a.at(0);
  int rev=1;
  while (i!= 2) {
      i=a.at(i-1);
      rev++;
      if (rev>N){
        rev=-1;
        break;
      }
      
  }
  cout << rev << endl;
}

Measured memory_bytes: 640
def myAnswer(X:int,Y:int) -> int:
   if(X*2 > Y): return 1
   ans = X
   total = 1
   while True:
      ans *= 2
      if(ans > Y):
         break
      else:
         total += 1
   return total


def modelAnswer():
   tmp=1
def main():
   X, Y = map(int,input().split())
   print(myAnswer(X,Y))
if __name__ == '__main__':
   main()

Measured memory_bytes: 3060
/***

    Muhammad Imdad-Ul-Haque Rakib(Attari)
    CSE'19
    Chittagong,Bangladesh

***/


#include<bits/stdc++.h>


/**Definitions**/


#define   ld             long double
#define   ll             long long
#define   boost_         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define   pb             push_back
#define   ppb            pop_back
#define   ull            unsigned long long
#define   over           return 0
#define   scan(i,n,a)    for(i=0;i<n;i++) cin>>a[i]
#define   MP             make_pair
#define   spc            " "

using namespace std;


/** Predefined Functions **/


int gcd(int x,int y){
    if(x==0) return y;
    else return gcd(y%x,x);
}
bool sortbysec(const pair<int,int>&a, const pair<int,int>&b){ return (a.second<b.second); }
bool sortbysecinrev(const pair<int,int>&a, const pair<int,int>&b){ return (a.second>b.second); }
bool sortbysize(string &s1,string &s2){ return s1.size() < s2.size(); }
bool sortinrev(const pair<int,int> &a, const pair<int,int> &b){ return (a.first > b.first); }


/** Main Function **/


int main(){

    boost_;
    ll n,k,x,y;
    cin>>n>>k>>x>>y;
    if(n<=k) cout<<n*x<<endl;
    else cout<<x*k+(n-k)*y<<endl;


    over;
}


Measured memory_bytes: 3624
// AOJ 0142: Nature of Prime Numbers
// 2017.8.16 bal4u@uu
// 2017.11.21

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX  10000
#define HALF 5000
int sqr[HALF+5];
int a[HALF+5];
int d[HALF+5];
char f[MAX+5];

char prime[MAX+5];
int tbl[24] = {
  3,  5,  7, 11, 13, 17, 19, 23, 29, 31,
 37, 41, 43, 47, 53, 59, 61, 67, 71, 73,
 79, 83, 89, 97 };
int sqp[24] = {
  9,25,49,121,169,289,361,529,841,961,
1369,1681,1849,2209,2809,3481,3721,4489,5041,
5329,6241,6889,7921,9409 };

int main()
{
	int n;
	int i, j, k, b, m;
	char buf[10];

	for (i = 0; i < 24; i++) {
		k = tbl[i];
		for (j = sqp[i]; j < MAX; j += k) prime[j] = 1;
	}
	for (sqr[1] = 1, j = 3, i = 2; i <= 5000; i++, j+=2) sqr[i] = sqr[i-1]+j; // sqr[i] = i^2

	while (fgets(buf, 10, stdin) && *buf != '0') {
		n = atoi(buf), k = n >> 1;
		// 4m+3????´???°
		if (!prime[n] && (n & 3) == 3) {
			sprintf(f, "%d", k-1);
			while(k--) puts(f);
			continue;
		}

		// ???????\???°????????????????????????????¨????
		memset(d, 0, sizeof(d));
		memset(f, 0, sizeof(f));
		for (m = 0, i = 1; i <= k; i++) {
			b = sqr[i] % n;
			if (!f[b]) f[b] = 1, a[m++] = b;
		}
		for (i = 0; i < m; i++) {
			for (j = 0; j < i; j++) {
				if (b = a[i] - a[j]) {
					if (b < 0) b += n;
					if (b > k) b = n - b;
					d[b]++;
				}
			}
		}
		for (i = 1; i <= k; i++) printf("%d\n", d[i]<<1);
	}
	return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef pair<int, int> pi;

int n;
const int maxn = 2e5 + 5;

int a[maxn], b[maxn];
int cnt[maxn];
map<int, int> ID;
int tot;

int fa[maxn], sz[maxn];
bool vis[maxn];

int Find(int x){
    return x == fa[x] ? x : fa[x] = Find(fa[x]);
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    int x = 0;
    tot = 0;
    for(int i = 1;i <= n;i++){
        cin >> a[i];
        x ^= a[i];
    }
    a[0] = x;
    x = 0;
    for(int i = 1;i <= n;i++){
        cin >> b[i];
        x ^= b[i];
    }
    b[0] = x;
    for(int i = 0;i <= n;i++){
        if(i > 0 and a[i] == b[i])
            continue;
        if(!ID.count(a[i])){
           ID[a[i]] = ++tot;
        }
        a[i] = ID[a[i]];
        if(!ID.count(b[i])){
            ID[b[i]] = ++tot;
        }
        b[i] = ID[b[i]];
        cnt[a[i]]++;
        cnt[b[i]]--;
    }
    for(int i = 1;i <= tot;i++){
        if(cnt[i] != 0){
            cout << -1 << endl;
            return 0;
        }
    }
    int e = 0;
    for(int i = 0;i <= n;i++){
        if(i > 0 and a[i] == b[i])
            continue;
        fa[a[i]] = a[i];
        fa[b[i]] = b[i];
    }
    for(int i = 1;i <= n;i++){
        if(a[i] != b[i]){
            e++;
            int fx = Find(a[i]);
            int fy = Find(b[i]);
            if(fx != fy){
                fa[fx] = fy;
            }
        }
    } 
    int c = 0;
    for(int i = 1;i <= tot;i++){
        int fx = Find(i);
        if(fx == i)
            c++;
    }
    cout << c + e - 1 << endl;
    return 0;
}


Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv){
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	int a,b; cin >> a >> b;
	int ans = 0;
	int hole = 1;
	while(hole<b){
		hole += a-1;
		ans++;
	}
	out(ans);

}




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

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

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;


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

    if(n%2!=0){
        cout<<"No"<<endl;
        return 0;
    }

    bool ans=true;
    rep(i,n/2){
        if(s[i]!=s[i+n/2]){
            ans=false;
            break;
        }
    }

    if(ans){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}



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

int main() {
   ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int h,w,a,b;
	cin>>h>>w>>a>>b;
	for(int i=0;i<b;i++){
		for(int j=0;j<a;j++){
			cout<<"1";
		}
		for(int j=a;j<w;j++){
			cout<<"0";
		}
		cout<<endl;
	}
	for(int i=b;i<h;i++){
		for(int j=0;j<a;j++){
			cout<<"0";
		}
		for(int j=a;j<w;j++){
			cout<<"1";
		}
		cout<<endl;
	}
}


Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
string s;
int main() {
  cin>>s;
  if (s[0] == s.back()) {
  	if (s.size()%2 > 0) {
    	cout<<"Second"<<endl;
    } else {
    	cout<<"First"<<endl;
    }
  } else {
  	if (s.size()%2 == 0) {
    	cout<<"Second"<<endl;
    } else {
    	cout<<"First"<<endl;
    }
  }
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define MOD 1000000007
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(v) (v).begin() , (v).end()
#define sumof(v) accumulate(all(v), 0LL, plus<ll>())
#define maxof(v) max_element(all(v))
#define minof(v) min_element(all(v))
#define inf INT_MAX

int main(){
    FASTIO
    ll H, W, m;
    cin>>H>>W>>m;
    set<pair<int, int>> s;
    vector<int> row(H+1, 0), col(W+1, 0);
    for(int i=0; i<m; ++i){
        int a, b; cin>>a>>b;
        s.insert({a, b});
        row[a]++; col[b]++;
    }
    auto rowX = max_element(row.begin(), row.end())-row.begin();
    auto colX = max_element(col.begin(), col.end())-col.begin();
    ll alpha = row[rowX], beta = col[colX];
    vector<int> t1, t2;
    for(int i=1; i<=H; ++i){
        if(row[i]==alpha) t1.push_back(i);
    }
    for(int i=1; i<=W; ++i){
        if(col[i]==beta) t2.push_back(i);
    }
    bool check = false;
    for(auto x: t1){
        int curr;
        for(auto y: t2){
            // cout<<"Here "<<x<<" "<<y<<endl;
            curr = (s.find({x, y})!=s.end())?-1:0;
            // cout<<"curr = "<<curr<<endl;
            if(curr==0) {check = true; break;}
        }
        if(check){
            // cout<<"I am here"<<endl;
            break;
        }
    }
    // cout<<"check = "<<check<<endl;
    // cout<<rowX<<" "<<colX<<endl;
    // cout<<row[rowX]<<" "<<col[colX]<<endl;
    int extra = 0;
    if(check==false) extra = -1;
    // int extra = (s.find({rowX, colX})!=s.end())?-1:0;
    cout<<row[rowX]+col[colX]+extra<<endl;
}



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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll K, A, B;
int main(){
  cin >> K >> A >> B;
  if (A + 2 >= B || K < A + 1){
    cout << K + 1 << endl;
    return 0;
  }

  ll ans = B; K -= A + 1;
  ans += (B - A) * (K / 2);
  if (K % 2 != 0) ans++;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void show(vector<int> a, int N) {
    rep(i, N - 1) cout<<a[i]<<" ";
    cout<<a[N - 1]<<endl;
}

void insertionSort(vector<int> a, int N) {
    rep(i, N) {
        int v = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > v) {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;

        show(a, N);
    }
}

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

    int N;
    cin>>N;
    vector<int> a(N);
    rep(i, N) cin>>a[i];

    insertionSort(a, N);
}



Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[114514];
signed main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	int ans=0;
	int sum=0;
	for(int i=0;i<n;i++){
		if(a[i]==0){
			ans+=sum/2;
			sum=0;
			}
		sum+=a[i];	
		}
		ans+=sum/2;
	cout<<ans<<endl;	
	}

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

int main(){
	int N,ans;
	cin >> N;
	int A[N],B[N],C[N];
	for(int i=0;i<N;i++) cin >> A[i];
	for(int i=0;i<N;i++) cin >> B[i];
	for(int i=0;i<N-1;i++) cin >> C[i];
	C[N-1] = 0;
	
	for(int i=0;i<N;i++){
		ans += B[i];
		if(A[i] - A[i-1] == 1) ans += C[A[i-1]-1];		
	}
	cout << ans << endl;
	}


Measured memory_bytes: 256