akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
using namespace std;
 
using   ll=long long;
using   ld=long double;
 
#define fast           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl           "\n"
#define int            long long 
#define pb             push_back
#define mp             make_pair
#define vll            vector<ll>
#define ff              first
#define ss              second
#define pll            pair<ll,ll>
#define ALL(v)         v.begin(),v.end()
#define ALLR(v)        v.rbegin(),v.rend()
#define pii            3.14159265358979323

#define m               1000000007

ll fff(ll n)
{
    ll ans=1;
    
    while(n--)
    {
        ans=(ans*2)%m;
    }
    
    return ans;
}

void solve()
{
    ll n;
    
    cin>>n;
    
    vector<ll> a(n+1);
    
    map<ll,ll> tt,pp;
    
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        
        ll cur=60;
        
        string s="";
        
        while(cur--)
        {
            if(a[i]%2)    s+='1';
            else          s+='0';
            
            a[i]/=2;
        }
        
        for(int j=0;j<60;j++)
        {
            if(s[j]=='0')    pp[j]++;
            else             tt[j]++;
        }
        
        //cout<<s<<endl;
    }
    
    ll ans=0;
    
    for(int i=0;i<60;i++)
    {
        ll r=fff(i);
        
        ll l=(tt[i]*pp[i])%m;

        ans=(ans+(l*r)%m)%m;
        
        ans%=m;
    }
    
    
    cout<<ans;
    
}
 
 
signed main()
{
 
    fast;
 
    ll t;
    
    t=1;
    
    //cin>>t;
    
    while(t--)
    {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 2560
import math

N = int(input())

anss = []
for n in range(1,math.ceil(N**0.5)+1):
	if N % n == 0:
		anss.append(max(len(str(n)),len(str(N//n))))

if len(anss) == 0:
	anss.append(1)
		
print(min(anss))

Measured memory_bytes: 3060
;; C - HonestOrUnkind2

(defun main ()
  (let* ((N (read))
         (testimonies
           (loop repeat N collect
             (let ((A (read)))
               (loop repeat A collect
                 (cons (read) (read))))))) ; (x_ij . y_ij)
    (print (solve N testimonies))
    (fresh-line)))

(defun solve (N testimonies)
  (let ((patterns (bit-patterns N)))
    (loop for pattern
           in (sort patterns #'> :key #'(lambda (p) (apply #'+ p)))
      when (satisfy pattern testimonies)
      return (apply #'+ pattern))))

(defun satisfy (pattern testimonies)
  (every #'(lambda (testimony)
             (every #'(lambda (xy)
                        (= (nth (1- (car xy)) pattern) (cdr xy)))
                    testimony))
    (honest-testimonies pattern testimonies)))

(defun honest-testimonies (pattern testimonies)
  (mapcar #'cdr
    (remove-if #'(lambda (pt) (= (car pt) 0))
      (mapcar #'cons pattern testimonies))))

(defun bit-patterns (n)
  (if (> n 0)
      (let ((tail (bit-patterns (1- n))))
        (append
          (mapcar #'(lambda (p) (cons 1 p)) tail)
          (mapcar #'(lambda (p) (cons 0 p)) tail)))
      (list nil)))

(main)


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

using namespace std;

int main()
{
	int w, h, x, y, r;
	int top, bot, rig, lef;

	cin >> w >> h >> x >> y >> r;

	top = y + r;
	bot = y - r;
	rig = x + r;
	lef = x - r;

	if (top > h || bot < 0 || rig > w || lef < 0)
	{
		printf("No\n");
	}
	else
	{
		printf("Yes\n");
	}

	return 0;
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/



int main() {
  ll i, j, k;
  
  double pi=3.1415926;
  
  ll r;
  cin >> r;
  
  printf("%.10f\n", r*2*pi);
  
  
  
}




Measured memory_bytes: 3764
S = list(map(int,list(input())))
# -*- coding: utf-8 -*-

p_num = 2**(len(S) - 1)
p = []
for i in range(p_num):
    temp_list = []
    temp = i
    for j in range(len(S) - 1):
        temp_list.append(temp % 2)
        temp //= 2

    p.append(temp_list)

g_sum = 0
for p_list in p:
    s_sum = S[0]
    add = 0
    for i in range(1,len(S)):
        if p_list[i-1] == 1:
            add += s_sum
            s_sum = S[i]
        else:
            s_sum = s_sum*10 + S[i]
    add += s_sum
    g_sum += add
    # print(p_list)
    # print(add)

print(g_sum)


Measured memory_bytes: 3064
#include<stdio.h>
int main(void) {
	int r, d, x[11],i;
	scanf("%d %d %d", &r, &d, &x[0]);
	for (i = 0; i < 10; i++) {
		x[i + 1] = r * x[i] - d;
		printf("%d\n", x[i + 1]);
	}
	return 0;
}

Measured memory_bytes: 128
def main():
    N = int(input())
    A = list(map(int, input().split()))
 
    if 0 in A:
        print(0)
        return
    
    ans = 1
 
    for i in A:
        ans *= i
      
        if ans > 10 ** 18:
            print(-1)
            return 
      
    print(ans)  

main()      

Measured memory_bytes: 21764
#!/usr/bin/env python3
import collections
import itertools as it
import math
import numpy as np

# A = input()
# A = int(input())
# A = map(int, input().split())
# A = list(map(int, input().split()))
# A = [int(input()) for i in range(N)]
#
# c = collections.Counter()

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

log_ = int(math.log(N, K))
print(log_+1)


print()

Measured memory_bytes: 21124
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>

using namespace std;
int ans[100][100] = {};
int now = 0, n;

int main() {
    int u, k, tmp;
    cin >> n;
    vector<int> dist(n, -1);
    queue<int> que;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> tmp;
            ans[u - 1][tmp - 1] = 1;
        }
    }
/*
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; ++j) {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
*/
    dist[0] = 0;
    que.push(0);
    while (!que.empty()) {
        int v = que.front();
        //cout << v;
        que.pop();

        for (int i = 0; i < n; ++i) {
            int nv = ans[v][i];
            if (dist[i] == -1 and nv != 0) {
                dist[i] = dist[v] + 1;
                que.push(i);
            }
        }
        //cout << endl;
    }
    for (int i = 0; i < n; ++i) {
        cout << i + 1 << " " << dist[i] << endl;
    }
    return 0;
}




Measured memory_bytes: 3128
#コピペコード
H, W = map(int, input().split())
a = [input() for _ in range(H)]
row = [False] * H
col = [False] * W
for i in range(H):
	for j in range(W):
		if a[i][j] == '#':
			row[i] = True
			col[j] = True
 
for i in range(H):
	if row[i]:
		for j in range(W):
			if col[j]:
				print(a[i][j], end = '')
		print()

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

using namespace std;

int main()
{
  string s;
  cin >> s;
  if (s == "abc" or s == "acb" or s == "bac" or s == "bca"
    or s == "cab" or s == "cba") {
      cout << "Yes\n";
    } else {
      cout << "No\n";
    }
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N,K;
	cin>>N>>K;
	vector<bool> vi(N);
	for (int i = 0; i < K; ++i){
		int d;
		cin>>d;
		for (int j = 0; j < d; ++j){
			int x;
			cin>>x;
			vi[x-1] = true;
		}
	}
	int res = 0;
	for (auto i : vi){
		if (!i) ++res;
	}
	cout<<res<<endl;
}


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

int main() {
  int a1,b1,a2,b2;
  cin>>a1>>b1>>a2>>b2;

  int x=a2-a1;
  int y=b2-b1;
  printf("%d %d %d %d\n",a2-y,b2+x,a1-y,b1+x);
}


Measured memory_bytes: 256
# -*- coding:utf-8 -*-
import sys
sys.setrecursionlimit(10 ** 5)
input = sys.stdin.readline
mod = 1000000007
inf = float("INF")
def I(): return int(input().rstrip())
def IR(n): return [I() for _ in range(n)]
def LI(): return list(map(int, input().rstrip().split()))
def LIR(n): return [LI() for _ in range(n)]
def LI_(): return list(map(lambda x: int(x) - 1, input().rstrip().split()))
def LIR_(n): return [LI_() for _ in range(n)]
def F(): return float(input().rstrip())
def FR(n): return [F() for _ in range(n)]
def LF(): return list(map(float, input().rstrip().split()))
def LFR(n): return [LI() for _ in range(n)]
def S(): return input().rstrip()
def SR(n): return [S() for _ in range(n)]
def LS(): return list(sys.stdin.readline().rstrip().split())
def LSR(n): return [LS() for _ in range(n)]
# ↑template↑
# ↓solution↑
a, b = LS()
ab = int(a + b)
if (ab ** 0.5).is_integer():
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9320
#include <iostream>
#include <algorithm>
#include <vector>
#include <limits>

using namespace std;

int count_point(const vector<long long> &x, const vector<long long> &y, long long x0, long long y0, long long x1, long long y1)
{
	int ans = 0;
	const int N = x.size();
	for (int i = 0; i < N; ++i) {
		if (x0 <= x[i] && x[i] <= x1 && y0 <= y[i] && y[i] <= y1) {
			++ans;
		}
	}
	return ans;
}

int main()
{
	int N, K;
	cin >> N >> K;
	vector<long long> x(N), y(N);
	for (int i = 0; i < N; ++i) {
		cin >> x[i] >> y[i];
	}

	vector<long long > x_org = x, y_org = y;

	long long ans = numeric_limits<long long>::max();

	sort(x.begin(), x.end());
	sort(y.begin(), y.end());

	for (int a = 0; a < N; a++) {
		for (int c = 0; c < N; c++) {
			for (int b = a + 1; b < N; b++) {
				for (int d = c + 1; d < N; d++) {
					if (count_point(x_org, y_org, x[a], y[c], x[b], y[d]) >= K) {
						ans = min(ans, (x[b] - x[a]) * (y[d] - y[c]));
					}
				}
			}
		}

	}
	cout << ans << endl;
}


Measured memory_bytes: 256
while True:
    s = int(input())
    if s == 0: break
    a = [0 for i in range(10)]
    for i in range(s):
        n = int(input())
        a[n]+= 1
    for i in range(10):
        if a[i]>0:
            print('*'*a[i])
        else:
            print('-')


Measured memory_bytes: 5628
//include
//------------------------------------------
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <limits>
using namespace std;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>(b);i--)
#define REP(i,n)  FOR(i,0,n)
#define INF 999999999.0

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
//-------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//typedef
//-------------------------------------------
typedef long long ll;
typedef pair<double, vector<int>> Pair;

int s[16];
int d[16];
int v[16];
Pair dp[16][1<<15];
int N;

Pair solve(int cnt, int idx, int used, int w) {
    Pair result(0, vector<int>());
    result.second.push_back(s[idx]);
    if (cnt == N) return result;
    if (dp[idx][used].first != INF) return dp[idx][used];
    result.first = INF;
    FOR(i, 1, N + 1) {
        if((used>>(i - 1))&1) {
            Pair tmp = solve(cnt + 1, i, used&~(1<<(i - 1)), w + v[i] * 20);
            tmp.first += abs(d[i] - d[idx]) / (2000.0 / (70 + w));
            if (result.first > tmp.first) {
                result = tmp;
            }
        }
    }
    result.second.insert(result.second.begin(), s[idx]);
    return dp[idx][used] = result;
}

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

    cin >> N;
    int init = (1<<15) - 1;
    FOR(i, 1, N + 1) cin >> s[i] >> d[i] >> v[i];
    FOR(i, 1, N + 1) {
        FOR(j, 1, 1<<15) {
            dp[i][j] = Pair(INF, vector<int>());
        }
    }
    Pair ans(INF, vector<int>());
    FOR(i, 1, N + 1) {
        Pair tmp = solve(1, i, init&~(1<<(i - 1)), v[i] * 20);
        if (ans.first > tmp.first) ans = tmp;
    }

    REP(i, N - 1) cout << ans.second[i] << " ";
    cout << ans.second[N - 1] << endl;

    return 0;
}

Measured memory_bytes: 30500
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
# define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ull i=a;i<b;i++)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define trace(s,a) cout<<s<<a,nl

ll gcd(ll a, ll b){
	if(a == b)
		return a;
	ll max = (a>b)? a: b;
	ll min = max^a^b;
	if(min == 0){
		return max;
	}
	else
		return gcd(max%min, min); 
}

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

ll mul(ll a, ll b, ll d){
	ll x;
	ll y;
	if(a%d == 0){
		x = a;
	}else{
		x = a + d - a%d;
		if(x > b)
			return 0;
	}
	y = b - b%d;
	return (y - x)/d + 1;

}

int main(){
	
 	ll a, b, c, d;
 	cin>>a>>b>>c>>d;
 	cout<<(b-a+1) - mul(a, b, c) - mul(a,b,d) + mul(a, b, lcm(c, d))<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
    vector<int>ch(1001001,0);
    int n;cin >>n;
    V a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
        ch[a[i]]++;
    }
    bool flg=true;
    for (int i = 2; i <1001001; ++i) {
        ll cnt=0;
        for (int j =i; j <1001001 ;j+=i) {
            if(ch[j])cnt+=ch[j];
        }
        if(cnt>=2)flg=false;
    }
    if(flg)puts("pairwise coprime");
    else {
        int g=0;
        for (int i = 0; i < n; ++i) {
            g=__gcd(g,a[i]);
        }
        if(g==1) {
            puts("setwise coprime");
        }
        else {
            puts("not coprime");
        }
    }
}


Measured memory_bytes: 11112
#include <iostream>
#include <string>
#include <algorithm>

int dp[1001][1001];

int lcs(std::string X, std::string Y){
	int m,n,i,j;
	m = X.length();
	n = Y.length();
	for(i=0;i<std::max(m,n)+1;i++){
			dp[i][0] = 0;
			dp[0][j] = 0;
	}
	
	for (i=0;i<m;i++){
		for(j=0;j<n;j++){
			if(X[i] == Y[j]){
				dp[i+1][j+1] = dp[i][j] +1;
			}
			else{
				dp[i+1][j+1] = std::max(dp[i][j+1], dp[i+1][j]);
			}
		}
	}
	return dp[m][n];
}
int main(void){
	int i,q,n,m;
	std::string str1, str2;
	std::cin >> q;
	for (i=0;i<q;i++){
		std::cin >> str1;
		std::cin >> str2;
		std::cout << lcs(str1, str2) << std::endl;
	}
	return 0;
}

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

#define FOR(i, a, b)  for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << "\n"
#define _ << " _ " <<
#define ll long long

using namespace std;

bool pitaj(ll x) {
  cout << "? " << x << "\n";
  char t;
  cin >> t;
  return (t == 'Y');
}

int main() {
  ios_base::sync_with_stdio(false);

  bool A = pitaj(1000000000);
  if (A) {
    ll x = 1;
    while (!pitaj(2 * x)) {x *= 10;}
    cout << "! " << x << "\n";
  } else {
    ll x = 1;
    while (pitaj(x)) {
      x *= 10;
    }
    x /= 10;
    ll lo = x, hi = x * 10 - 1;
    while (lo < hi) {
      ll mi = lo + (hi - lo) / 2;
      bool b = pitaj(10 * mi);
      if (b) {
        hi = mi;
      } else {
        lo = mi + 1;
      }
    }
    cout << "! " << lo << "\n";
  }

  return 0;
}


Measured memory_bytes: 596
package main

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

func main() {
	var sc = bufio.NewScanner(os.Stdin)
	maxSize := 300000 * 2
	buf := make([]byte, maxSize)
	sc.Buffer(buf, maxSize)
	sc.Scan()
	s := scanLineStr(sc)

	count := 0
	for i := range s {
		if s[i] == 'E' {
			count++
		}
	}

	result := count
	for i := range s {
		if s[i] == 'E' {
			count--
		}
		if i > 0 && s[i-1] == 'W' {
			count++
		}
		result = min(result, count)
	}
	fmt.Println(result)
}

func scanLineStr(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanLineInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int[] dist = new int[n + 10];
		int[] spot = new int[n + 10];
		long sumDist = 0;
		for(int i = 1; i <= n; i ++) {
			spot[i] = sc.nextInt();
			dist[i] = Math.abs(spot[i] - spot[i - 1]);
			sumDist += dist[i];
		}
		dist[n + 1] = Math.abs(spot[n]);
		sumDist += dist[n + 1];
		
		for(int i = 1; i <=n; i++) {
			int newDist = Math.abs(spot[i - 1] - spot[i + 1]);
			long ans = sumDist - dist[i] - dist[i + 1] + newDist;
			out.println(ans);
		}

		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}


Measured memory_bytes: 32620
H, N = map(int, input().split() )

A = []
B = []
for i in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)

# N -> dp[N - A_i] + B_i

dp = [0 for i in range(H+1)]

for i in range(H+1):
  temp = 10 ** 8 + 1
  for j in range(N): # Use each Magic j
    if i - A[j] > 0:
      temp = min(temp, dp[ i - A[j] ] + B[j] )
    else:
      temp = min(temp, B[j] )
  dp[i] = temp
               
print(dp[H])


Measured memory_bytes: 44524
# AtCoder
N = int(input())
sm = 0
for i in range(1, N+1):
    if i % 3 == 0 and i % 5 == 0:
        continue
    elif i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    else:
        sm += i
print(sm)


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

public class Main {
    static final Scanner sc    = new Scanner(System.in);
    static final int     MOD   = (int) 1E9 + 7;
    static final long    INF_L = (long) 4E18;
    static final int     INF   = Integer.MAX_VALUE;
    
    public static void main(String[] args) {
        int H = nint();
        int N = nint();
        long[] A = nlongs(N);
        long sum = Arrays.stream(A).sum();
        System.out.println(H <= sum ? "Yes": "No");
    }
    
    static int gcd(int m, int n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
    
    static long lcm(int m, int n) {
        return (long) m * n / gcd(m, n);
    }
    
    @Deprecated
    static int nint() {
        return sc.nextInt();
    }

    @Deprecated
    static int[] nints(int N) {
        return nints(N, 0, 0);
    }

    @Deprecated
    private static int[] nints(int N, int padL, int padR) {
        int[] a = new int[padL + N + padR];
        for (int i = 0; i < N; i++)
            a[padL + i] = nint();
        return a;
    }

    static long nlong() {
        return sc.nextLong();
    }

    static long[] nlongs(int N) {
        return nlongs(N, 0, 0);
    }

    static long[] nlongs(int N, int padL, int padR) {
        long[] a = new long[padL + N + padR];
        for (int i = 0; i < N; i++)
            a[padL + i] = nlong();
        return a;
    }

    static double ndouble() {
        return sc.nextDouble();
    }

    static double[] ndoubles(int N) {
        return ndoubles(N, 0, 0);
    }

    static double[] ndoubles(int N, int padL, int padR) {
        double[] d = new double[N + padL + padR];
        for (int i = 0; i < N; i++) {
            d[padL + i] = ndouble();
        }
        return d;
    }

    static String nstr() {
        return sc.next();
    }

    static char[] nchars() {
        return sc.next().toCharArray();
    }

    static char[] nchars(int padL, int padR) {
        char[] temp = sc.next().toCharArray();
        char[] ret = new char[temp.length + padL + padR];
        System.arraycopy(temp, 0, ret, padL, temp.length);
        return ret;
    }

    static char[][] nchars2(int H, int W) {
        return nchars2(H, W, 0, 0);
    }

    static char[][] nchars2(int H, int W, int padLU, int padRD) {
        char[][] a2 = new char[H + padLU + padRD][W + padLU + padRD];
        for (int i = 0; i < H; i++)
            System.arraycopy(nchars(), 0, a2[padLU + i], padLU, W);
        return a2;
    }

    static long min(long... ls) {
        return Arrays.stream(ls).min().getAsLong();
    }

    static long max(long... ls) {
        return Arrays.stream(ls).max().getAsLong();
    }

    static long abs(long a) {
        return Math.abs(a);
    }
}


Measured memory_bytes: 50080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if ((100 * a + 10 * b + c) % 4 == 0) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = $stdin.gets.to_i
A = []
B = []
0.upto(N - 1) do |i|
  A[i], B[i] = $stdin.gets.split.map {|j| j.to_i }
end
A.sort!
B.sort!
case N % 2
when 1
  ca = A[(N + 1) / 2 - 1]
  cb = B[(N + 1) / 2 - 1]
when 0
  ca = A[N / 2 - 1] + A[(N / 2)]
  cb = B[N / 2 - 1] + B[(N / 2)]
end
r = cb - ca + 1
if r < 0
  r = 0
end
puts r


Measured memory_bytes: 20004
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	s := next()
	c := 0
	for _, r := range s {
		switch r {
		case '+': c++
		case '-': c--
		}
	}

	fmt.Println(c)
}


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

signed main(){
    int N;
    cin >> N;
    vector<int> A;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        A.push_back(a);
    }
    
    bool next_is_cheaper[N+1];
    next_is_cheaper[N-1] = true;
    next_is_cheaper[N] = true;
    for(int i=N-2; i>=0; i--){
        if(A[i] > A[i+1]){
            next_is_cheaper[i] = true;
        }
        else if(A[i] < A[i+1]){
            next_is_cheaper[i] = false;
        }
        else{
            next_is_cheaper[i] = next_is_cheaper[i+1];
        }
    }

    
    
    int money = 1000, kabu = 0;
    for(int i=0; i<N; i++){
        if(!next_is_cheaper[i]){
            // 買い
            kabu += money / A[i];
            money = money % A[i];
        }
        else{
            // 売り
            money += kabu * A[i];
            kabu = 0;
        }
    }
    cout << money << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>

using namespace std;

#define ll long long
#define endl '\n'
#define mod 1000000007
#define mx 2000005
#define pb push_back
#define fr(a,b) for(int i = a; i < b;i++)

bool p[mx + 1];
ll fact[mx];
vector<int> prime;

void seieve(){
	for (int i = 2; i * i <= mx; i++){
		if (!p[i])
			for (int j = i * i; j <= mx; j += i)
				p[j] = 1;
	}
	for (int i = 2; i <= mx; i++)
		if (!p[i])
			prime.pb(i);
}

bool isprime(ll n){
	if (n <= 1)
		return false;
	for (ll i = 2; i * i <= n; i++)
		if (n % i == 0)
			return false;
	return true;
}

void factorial(){
	fact[0] = 1;
	for (int i = 1; i < mx; i++){
		fact[i] = fact[i - 1] * i;
		fact[i] %= mod;
	}
}

ll modInverse(ll a){
	ll m0 = mod;
	ll y = 0, x = 1;
	if (m0 == 1)
		return 0;

	while (a > 1){
		ll q = a / m0;
		int t = m0;
		m0 = a % m0, a = t;
		t = y;
		y = x - q * y;
		x = t;
	}
	if (x < 0)
		x += mod;
	return x;
}

ll power(ll x, ll y, ll p){
	ll res = 1;
	x = x % p;
	if (x == 0)
		return 0;
	while (y > 0){
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

ll nCr(int n, int r){
	return ((fact[n] * modInverse(fact[n - r])) % mod * modInverse(fact[r])) % mod;
}

void solve(){
	string s;
	cin>>s;
	if(s == "ABC")cout<<"ARC";
	else cout<<"ABC";
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
	while (t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3020
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define MAX_n 1000000000
typedef long long int ll;

int main(){

    int n;
    cin >> n;
    vector<ll> a(n);
    ll h,w;

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

    sort(a.begin(),a.end(),greater<ll>());
    int tmp = 0;
    int h_sum = 0;
    int w_sum = 0;
    bool flag = true;
    
    for(int i = 0;i < n-1;i++){

        if(a[i] == a[i+1]){

            for(int j = i+2;j<n;j++){
                if(a[j] == a[j+1]){
                    h = a[i];
                    w = a[j];
                    cout << h*w << endl;
                    return 0;
                }
            }
        }
    }
    cout << '0' << endl;


    


    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            String S = in.nextLine();
            int w = Integer.parseInt(in.nextLine());

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < S.length(); i += w) {
                sb.append(S.charAt(i));
            }

            System.out.println(sb.toString());
        }
    }
}


Measured memory_bytes: 23636
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


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

    ans = 0
    for i in range(0, len(L), 2):
        ans += L[i]
    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using _TYPE = int;
typedef tree< _TYPE, null_type, less< _TYPE >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int n, w;
const int MAXW = (int) 1e5 + 2, MAXN = 102;
ll memo[MAXN][MAXW];
int v[MAXN];
int wei[MAXN];

ll dp(int index, int remw) {
	if(remw < 0)
		return (ll) -1e12;
	if(index == n)
		return 0;
	ll &rt = memo[index][remw];
	if(rt != -1)
		return rt;
	rt = dp(index + 1, remw);
	rt = max(rt, dp(index + 1, remw - wei[index]) + v[index]);
	return rt;
}

int main() {
    IO;
    cin >> n >> w;
    for(int i = 0; i < n; i++)
    	cin >> wei[i] >> v[i];
    memset(memo, -1, sizeof memo);
    cout << dp(0, w);
    return 0;
}


Measured memory_bytes: 83312
import math

a, b, h, m = map(int, input().split())

# 時針・・・一時間で30度、一分で0.5度
angle_a = (30*h+m/2) * math.pi /180
# 秒針・・・一分間で6度
angle_b = m/30 * math.pi

coordinate_a = [a * math.cos(angle_a), a * math.sin(angle_a)]
coordinate_b = [b * math.cos(angle_b), b * math.sin(angle_b)]

diff_a_b = [abs(coordinate_a[0]-coordinate_b[0]),
            abs(coordinate_a[1]-coordinate_b[1])]

square = [diff_a_b[0]**2,diff_a_b[1]**2]
print(math.sqrt(abs(square[0]+square[1])))

Measured memory_bytes: 9380
#include<iostream>
using namespace std ;
int main( void )
{
	short w ,h ;
	cin >> h >> w ;
	short ans[ h ][ w ] = { 0 } ;
	char c[ h + 1 ][ w + 1 ] ;
	for( short i = 0 ; i < h ; i++ )
	{
		for( short j = 0 ; j < w ; j++ )
		{
			cin >> c[ i ][ j ] ;
		}
		short k = 0 ;
		for( ; k < w && c[ i ][ k ] == '.' ; k++ )
		{
			ans[ i ][ k ]-- ;
		}
		short p ;
		for( short j = k ; j < w ; j++ )
		{
			if( c[ i ][ j ] == 'c' )
			{
				p = j ;
				ans[ i ][ j ] = 0 ;
			}
			else
			{
				ans[ i ][ j ] = j - p ;
			}
		}
	}
	for( short i = 0 ; i < h ; i++ )
	{
		for( short j = 0 ; j < w ; j++ )
		{
			if( j < w - 1 )
			{
				cout << ans[ i ][ j ] << " " ;
			}
			else
			{
				cout << ans[ i ][ j ] << endl ;
			}
		}
	}
	return 0 ;
}

Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;

int a[200001];
int bucket[200001] = {0};

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

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

  return 0;
}

Measured memory_bytes: 4712
package main

import (
	"fmt"
	"sort"
)

func main() {
	var (
		n, s1, s2 int
	)

	fmt.Scan(&n)
	a := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	//sort.Ints(a)
	sort.Sort(sort.Reverse(sort.IntSlice(a)))

	for i := 0; i < n; i++ {
		if i % 2 == 0 {
			s1 += a[i]
		} else {
			s2 += a[i]
		}
	}

	fmt.Println(s1 - s2)
	//fmt.Println(a)
}

Measured memory_bytes: 512
import math

s = int(input())
if s == 10**18:
    print("0 0 0 1000000000 1000000000 0")
else:
    x2 = 10**9
    y2 = 1

    x3 = 10 ** 9 - s % 10**9
    y3 = s // 10**9 + 1

    print("0 0 1000000000 1 "+str(x3)+" "+str(y3))

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h> 
using namespace std;

typedef long long ll;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0) 
#define rep(pp,nn) for (int ii = pp; ii < nn; ++ii)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define endl "\n"

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

string int_to_string(int x) {
    stringstream ss;
	ss << x;
	string ni = ss.str();
	return ni;
}
int string_to_int(string x) {
	int n;
	stringstream s(x);
	s >> n;
	return n;
}

int64_t power_mod(ll a, ll b, ll mo) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = (ans % mo * a % mo) % mo;
		}
		a = (a % mo * a % mo) % mo;
		b /= 2;
	}
	return ans;
}
int64_t POW(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = ans * a;
		}
		a = a * a;
		b /= 2;
	}
	return ans;
}

void INVERSE(vector<int64_t> &fact, vector<int64_t> &mul, int64_t nn, int64_t mo) {
	vector<int64_t> inv(nn + 1);
    fact[0] = 1;
	for (int64_t i = 1; i <= nn; ++i) {
		fact[i] = (fact[i - 1] * i) % mo;
	}
	inv[0] = 1;
    inv[1] = 1;
	for (ll i = 2; i <= nn; ++i) {
		inv[i] = (mo - (mo / i) * inv[mo % i] % mo) % mo; 
	}
	mul[0] = 1;
	for (int i = 1; i <= nn; ++i) {
		mul[i] = (mul[i - 1] * inv[i]) % mo;
	}
}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

vector<int64_t> fact(2001);
vector<int64_t> inv(2001);
int mod = 1e9 + 7;

int64_t C(int64_t n, int64_t k) {
	if (k > n) {
		return 0;
	}
	return (fact[n] % mod * inv[k] % mod * inv[n - k] % mod) % mod;
}

int main() {
	IOS;
	int n, k;
	cin >> n >> k;
	int z = 2000;
	INVERSE(fact, inv, z, mod);
	int64_t R = n - k;
	int64_t B = k;
	for (int i = 1; i <= k; ++i) {
		 cout << (C(R + 1, i) % mod * C(B - 1, i - 1) % mod) % mod << endl;
	}
}




Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define N 1000005
typedef long long ll;
const ll LLINF=1ll<<60;
//const int mx=1e5+7;
//int n;
//bool visited[mx];
//vector<int> a(mx),b(mx);
//vector<int> g(mx);
// int deg[mx];
//vector<int> adj[mx];
//int sz[mx], par[mx];
//vector<int> ans;
//---dfs--
//vector<ll> val(mx,0);
// int sz=0;
// void dfs(int s, int p){
// 	par[s]=p;
// 	sz[s]=1;
// 	int maxx=0;
// 	for(int x: adj[s]){
// 		if(x!=p){
// 			dfs(x,s);
// 			sz[s]+=sz[x];
// 			maxx=max(maxx,sz[x]);
// 		}
// 	}
// 	maxx=max(maxx,n-sz[s]);
// 	//cout<<"mx "<<s<<" "<<maxx<<"\n";
// 	if(maxx<mn) mn=maxx, c1=s, c2=0;
// 	else if(maxx==mn) c2=s;
// 	//cout<<"mn "<<mn<<"\n";
// }
//---dfs---

//---primes---
// const int N = 1e7 + 10;

// bool prime[N];
 
// int spf[N];
 
// void calc(){
// 	for(int i = 2; i<1e4; i++){
// 		if(prime[i])
// 			continue;
// 		spf[i] = i;
// 		for(int j = i * i; j < N; j += i){
// 			prime[j] = 1;
// 			spf[j] = i;
// 		}
// 	}
// 	for(int i = 2; i < N; i++)
// 		if(!spf[i])
// 			spf[i] = i;
// }

// vector<pair<int,int>> getp(int x){
// 	int curr=x;
// 	vector<pair<int,int>> ans;
// 	while(curr>1){
// 		int a=spf[curr];
// 		int count=0;
// 		while(curr%a==0){ curr/=a; count++;}
// 		ans.push_back(make_pair(a,count));
// 	}
// 	return ans;
// }

// bool ispr(int n) {
// 	if(n==1) return false;
//     for (int i=2;i*i<=n;++i){
//         if(n%i==0){
//             return false;
//         }
//     }
//     return true;
// }
//---primes---

//---segment_tree---
// int upd(int t,int val,int l,int r,int y, int z){
// 	if(y<l||y>r) return tr[val];
// 	if(l==r) return tr[val]=z;
// 	int s=(l+r)/2;
// 	upd(t^1,2*val+1,l,s,y,z);
// 	upd(t^1,2*val+2,s+1,r,y,z);
// 	if(t) tr[val]=tr[2*val+1]|tr[2*val+2];
// 	else tr[val]=tr[2*val+1]^tr[2*val+2];
// 	return tr[val];
// }
//int query(){}
//---segment_tree---

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

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int T=1;
	//cin>>T;
	while(T--){
		ll a,b,c,d;
		cin>>a>>b>>c>>d;
		ll ans=-LLINF;
		ans=max({ans,a*c,a*d,b*c,b*d});
		cout<<ans<<"\n";
	}
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <limits>
#include <iomanip>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	ll result = a * c;
	if (a * d > result)
	{
		result = a * d;
	}

	if (b * c > result)
	{
		result = b * c;
	}

	if (b * d > result)
	{
		result = b * d;
	}

	cout << result << endl;
	return 0;
}

Measured memory_bytes: 3140
import sys
sys.setrecursionlimit(500*500)
N, M = map(int,input().split())
Q = [list(map(int,input().split())) for _ in range(M)]
C = [[] for _ in range(N+1)]
count = 0
for q in Q:
    X = q[0]
    Y = q[1]
    C[X].append(Y)
    C[Y].append(X)

flag = [-1]*(N+1)
flag[1] = 0
def dfs(s):
    global count
    for c in C[s]:
        flag[s] = 0
        if flag[c] == -1:
            flag[c] = 0
            count += 1
            dfs(c)

for i in range(1,N+1):
    dfs(i)
print(N-count)


Measured memory_bytes: 123648
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var words = ReadLine().Split(' ');
            bool flag = false;
            string a = words[0];
            string b = words[1];
            string c = words[2];
            if (a[a.Length - 1] == b[0] && b[b.Length - 1] == c[0]) flag = true;
            WriteLine(flag ? "YES" : "NO");
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}



Measured memory_bytes: 11092
import sys
a, b, c = map(int, input().split())

x = a % b

result = 'NO'

if x == 0 and c != 0:
  print(result)
  sys.exit()

past = []
for i in range(1, 100):
  s = (x * i) % b
  if s == c:
    result = 'YES'
    break
  try:
    past.index(s)
    break
  except:
    pass
  past.append(s)

print(result)

Measured memory_bytes: 3064
N=int(input())
A=list(input())
B=list(input())
C=list(input())
count=0
for i in range(len(A)):
    if A[i]!=B[i] or A[i]!=C[i] or B[i]!=C[i]:
        judege=[A[i],B[i],C[i]]
        judege=[judege.count(A[i]),judege.count(B[i]),judege.count(C[i]),]
        #print(max(judege))
        if max(judege)==1:
            count+=2
        elif max(judege)==2:
            count+=1
                
        
    
print(count)



Measured memory_bytes: 3064
# N分木におけるxの親は、0-indexedのときに、(x - 1) // N
# 一度0-indexedに戻すため、最初に-1したうえで、(x - 1) // Nを繰り返す
# 初めて一致した点が(0-indexedにおける)答えなので、+1して答え

import sys
readline = sys.stdin.readline

N,Q = map(int,readline().split())

for i in range(Q):
  v,w = map(int,readline().split())
  if N == 1:
    print(min(v,w))
    continue
  v -= 1
  w -= 1
  while v != w:
    if v > w:
      v = (v - 1) // N
    else:
      w = (w - 1) // N
  print(v + 1)


Measured memory_bytes: 9328
#include<iostream>
#include<string>
#include<algorithm>
#include <utility>
using namespace std;

string dec(string str,char c){
	if(c=='J'){
		int e=str.size()-1;
		str=str[e]+str;
		str.pop_back();
	}
	else if(c=='C'){
		str=str+str[0];
		str.erase(str.begin());
	}
	else if(c=='E'){
		int t=0;
		while(2*t<(str.size()-1)){
			swap(str[t],str[(str.size()+1)/2+t]);
			t++;
		}
	}
	else if(c=='A'){
		reverse(str.begin(),str.end());
	}
	else if(c=='P'){	
		for(int i=0;i<str.size();i++){
			if(str[i]>='0' && str[i]<='9')str[i]=((str[i]-'0')+9)%10+'0';
		}
	}
	else if(c=='M'){
		for(int i=0;i<str.size();i++){
			if(str[i]>='0' && str[i]<='9')str[i]=((str[i]-'0')+1)%10+'0';
		}
	}
	return str;
}

int main(){
	int n;
	cin>>n;
	while(n--){
		string ord,mes;
		cin>>ord>>mes;
		reverse(ord.begin(),ord.end());
		for(int i=0;i<ord.size();i++){
			mes=dec(mes,ord[i]);
		}
		cout<<mes<<endl;
	}
}

Measured memory_bytes: 3072
import math
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()-1
    name = [n%26]
    n = n // 26 -1
    while n >= 0:
        name.append(n%26)
        n  = n // 26 -1
    name.reverse()
    for na in name:
        print(chr(ord('z')-25+na), end='')
    print()

if __name__ == '__main__':
    main()

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

using namespace std;

typedef long long ll;

#define p(x) cout << x << endl
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int a, b;
    cin >> a >> b;

    int tas = a + b;
    int hiku = a - b;
    int kakeru = a * b;

    if(tas > hiku) {
        if(kakeru > tas) {
            p(kakeru);
        } else {
            p(tas);
        }
    } else {
        if(kakeru > hiku) {
            p(kakeru);
        } else {
            p(hiku);
        }
    }

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
d = {}
for _ in range(M):
    p, s = input().split()
    a = d.get(p, [0, 0])
    if s == "AC" and a[0] == 0:
        a[0] = 1
    elif s == "WA" and a[0] == 0:
        a[1] += 1

    d[p] = a

ac = 0
wa = 0
for x in d.values():
    if x[0] == 1:
        ac += x[0]
        wa += x[1]

print("{0} {1}".format(ac, wa))


Measured memory_bytes: 25308
#include <iostream>
using namespace std;
int main(void){
    int N,K,P;
    cin>>N;
    for(int i=0; i<N; i++){
        cin>>K>>P;
        if(K%P){
            cout<<K%P<<endl;
            }else if (K%P==0){
             cout<<P<<endl;   
            }
        }
}


Measured memory_bytes: 3100
#include<cstdio>
#include<cstring>

int main(){
    char n[201],s[101],p[101];
    scanf("%s %s",n,p);
    strcpy(s,n);
    strcat(n,s);
    if(strstr(n,p)==NULL){
        printf("No\n");
    }
    else{printf("Yes\n");}
    return 0;
}


Measured memory_bytes: 2752
#include <cstdio>
#include <cmath>

using namespace std;
long long N, S;
double n;

long long function(long long b, long long n) {
  if (n < b) {
    return n;
  } else {
    return function(b, n/b) + n % b;
  }
}

long long solve() {
  if (N < S) {
    return -1;
  }
  if (N == S) {
    return N+1;
  }
  for (long long i = 2; i < n+1; i++) {
    if (function(i, N) == S) {
      return i;
    }
  }
  for (long long p = (long long)(n+1); p >= 1; p--) {
    if ((N-S)/p == 0) {
      continue;
    }
    if (N % p == S % p && function((N-S)/p + 1, N) == S) {
      return (N-S)/p+1;
    }
  }
  return -1;
}

int main() {
  scanf("%lld", &N);
  scanf("%lld", &S);
  double N_double = N*1.0;
  n = sqrt(N_double);
  long long ans = solve();
  printf("%lld", ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

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

using namespace std;
using ll = long long int;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


int main()
{
	string s,t;
	cin >> s >> t;
	cout << t << s << endl;
	

	return 0;
}

Measured memory_bytes: 256
'use strict'
let Main = (input) => {
  let v = input.split('\n')
  let v1 = v[0], v2 = v[1], v3 = v[2], target = v[3]
  let store = []
  let cnt = 0
  for(let i=v1; i >= 0; i--){
    for(let j=v2; j >= 0; j--){
	  for(let k=v3; k >= 0; k--){

        if(target == sumUp(i, j, k)){
          let ijk = concat(i, j, k)
          if(store.indexOf(ijk) !== ijk){
            store.push()
            cnt++
          }
        }
      }
    }
  }
  
  console.log(cnt)
}

let sumUp = (a,b,c) => 500*a + 100*b + 50*c
let concat = (a,b,c) => a + '_' + b + '_' + c

Main(require("fs").readFileSync("/dev/stdin","utf8"))


Measured memory_bytes: 8012
#include<iostream>
#include<cstdio>
using namespace std;
int a[50] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;

int main() {
	scanf("%d", &k);
	printf("%d\n", a[k]);
	return 0;
}

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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//最終奥義 #define int long long
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; }
void put_double(double obj){printf("%.12f\n",obj);};
//lambda: [](int x, int y){return x<y;}

signed main(void){
    int n;cin>>n;
    string s;cin>>s;
    int ans=0;
    rep(t,1000){
       string num=to_string(t);
       while(num.size()<3)num=string("0").append(num);
       int c=0;
       rep(i,n){
           if(num[c]==s[i]) c++;
           if(c==3) break;
       }
       if(c==3) ans++;
    }
    cout << ans << endl;

    return 0;
}


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

#define PI 3.14159265358979
using namespace std;

int main(void)
{
	int a,b;
	char c;
	double x,y,r;
	x=y=0;
	r=0;
	while(cin>>a>>c>>b){
		if(a==0&&b==0){
			break;
		}
		x+=cos(r)*a;
		y+=sin(r)*a;
		r+=b*PI/180.0;
	}
	cout<<(int)y<<endl<<(int)x<<endl;
}

Measured memory_bytes: 1164