akhauriyash/Code-Regression huggingface dataset:
{
  const lines = [];
  const reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
  });

  reader.on('line', function (line) {
    lines.push(line);
  });
  reader.on('close', function () {
    const input1 = (lines[0] as string).split(' ');
    const N: number = Number(input1[0]);
    const D: number = Number(input1[1]);
    let count = 0;
    for (let i = 1; i <= N; i++) {
      const input = (lines[i] as string).split(' ');
      const X: number = Number(input[0]);
      const Y: number = Number(input[1]);
      const distance2: number = X * X + Y * Y;
      if (distance2 <= D * D) count += 1;
    }
    console.log(count);
  });
}


Measured memory_bytes: 73012
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
	    int x = scan.nextInt();
	    scan.close();
	    int pow = 0;
		int ans = 1;
		for (int i = 1; i < x; i++) {
			for (int j = 2; j < x; j++) {
				pow = (int) Math.pow(i, j);
				if (pow <= x) {
					ans = Math.max(ans, pow);
				}
			}
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
typedef long long ll;

vector<pair<int, int>> a;
#define REP 100
double fxy(double t1, double t2){

    double len = 0;
    for(auto p: a){
        double x = (double)t1 - p.first;
        double y = (double)t2 - p.second;
        double tmp = (x * x) + (y * y);
        tmp = sqrt(tmp);
        len = max(len, tmp);
    }
    return len;
}

double g(double x){
    double u = 1000.0;
    double d = 0.0;
    rep(i, REP){
        double uud = (u*2 + d) / 3;
        double udd = (u + d*2) / 3;
        if (fxy(x, uud) < fxy(x, udd)){
            d = udd;
        } else {
            u = uud;
        }
        //cout << u << " " << d << endl;
    }
    return fxy(x, u);
}

int main()
{
    int n;
    cin >> n;
    rep(i, n){ 
        int t1, t2; 
        cin >> t1 >> t2; 
        a.push_back(make_pair(t1, t2));
    }

    double l = 0.0;
    double r = 1000.0;
    rep(i, REP){
        double llr = (l*2 + r)/3;
        double lrr = (l + r*2)/3;
        if (g(llr) < g(lrr)){
            r = lrr;
        } else {
            l = llr;
        }
        //cout << l << " " << r << endl;
    }
    double ans = g(r);
    printf("%4.10lf", ans);
}



Measured memory_bytes: 256
#include<stdio.h>
const int N = 105; 
int main()
{
	int n, a[N] = {0};
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	for(int i = n - 1; i >= 0; i--)
	{
		if(i)
		{
			printf("%d ", a[i]);
		}
		else
		{
			printf("%d\n", a[i]);
		}
	}
	return 0;
} 



Measured memory_bytes: 2684
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int a, b;
    cin >> a >> b;
    cout << max({a + b, a * b, a - b}) << endl;
}


Measured memory_bytes: 3616
p,q=(map(int,input().split()))
minimums=2018
if q-p>=2019:
    for i in range(p,p+2019):
        for j in range(p,p+2019):
            if i>=j:
                continue
            if i<j:
                div=(i*j)%2019
                if div<minimums:
                    minimums=div
                    
                else:
                    continue
if q-p<2019:
    for i in range(p,q+1):
        for j in range(p,q+1):
            if i>=j:
                continue
            if i<j:
                div=(i*j)%2019
                if div<minimums:
                    minimums=div
                    
                else:
                    continue
print(minimums)
            

Measured memory_bytes: 3064
import java.io.*; 
import java.math.*;
import java.util.*;
 
public class Main {
	static final long MOD = 998244353;
	//static final long MOD = 1000000007;
	static boolean[] visited;
    public static void main(String[] args) throws IOException {
        FastScanner sc = new FastScanner();
        int N = sc.nextInt();
        int K = sc.nextInt();
        int Q = sc.nextInt();
        int[] correct = new int[N];
        for (int i = 0; i < Q; i++) {
        	correct[sc.nextInt()-1] += 1;
        }
        for (int i = 0; i < N; i++) {
        	if (K > Q-correct[i]){
        		System.out.println("Yes");
        	} else {
        		System.out.println("No");
        	}
        }
    }
    
    public static int[] baseN(int N, int num) {
    	int[] ans = new int[N];
    	for (int i = N-1; i >= 0; i--) {
    		int pow = (int)Math.pow(N,i);
    		ans[i] = num/pow;
    		num -= ans[i]*pow;
    	}
    	return ans;
    }
    
    public static int[][] sort(int[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i< array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<int[]>() {
			  @Override
			  public int compare(int[] arr1, int[] arr2) {
				  //Descending order
				  return arr2[0]-arr1[0];
			  }
		});
		return array;
	}
    
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str; 
        }
    }
}

class Node {
	public HashSet<Node> children;
	public int n;
	
	public Node(int n) {
		this.n = n;
		children = new HashSet<Node>();
	}
	
	public void addChild(Node node) {
		children.add(node);
	}
	
	public void removeChild(Node node) {
		children.remove(node);
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		return n;
	}

	@Override
	public boolean equals(Object obj) {
		if (! (obj instanceof Node)) {
			return false;
		} else {
			Node node = (Node) obj;
			return (n == node.n);
		}
	}
	
	public String toString() {
		return (this.n+1)+"";
	}
}

Measured memory_bytes: 44132
function trans(c){
	if(c == "d")return "b"; 
	if(c == "b")return "d";
	if(c == "q")return "p";
	if(c == "p")return "q";
}

function Main(inputData) {
	init(inputData);
	
	var s = inS();

	for(var i = 0; i < s.length; i++){
		if(trans(s[i]) != s[s.length-i-1]){
			outln("No");
			return 0;
		} 
	}
	outln("Yes");
}


////////////////////////////////////////////////////////////////////////////////////
var input,inputCnt;

// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
	Main(document.getElementById("input").value);
}

function init(inputData){
    //配列inputに順番に代入
	input = inputData.replace( /\n/g , " " );
	input = input.split(" ");
	inputCnt = 0;
}
//output
const out = (output) => { console.log(output) }
const outln = (output) => { console.log(output+"\n") }

//input
const inS = () => {return input[inputCnt++]};
const inI = () => {return parseInt(inS(), 10)};
const inF = () => {return parseFloat(inS())};

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
// ABC087-B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
int main()
{
	int c500, c100, c50;
	cin >> c500 >> c100 >> c50;
	int X;
	cin >> X;
	int a = X / 50;
	int b = X / 100;
	int c = X/ 500;
	int counter = 0;
	for (int i = 0; i <= c500; i++)
	{
		for (int j = 0; j <= c100; j++)
		{
			for (int k = 0; k <= c50; k++)
			{
				if (k * 50 + j * 100 + i * 500 == X)
				{
					counter++;
					//cout << i << "," << j << "," << k;
				}
			}
		}
	}
	cout << counter;


}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include <stdio.h>

#define PASTA_NUM 3

int main(void){
	int N, K;
    int num[100][PASTA_NUM][PASTA_NUM] = {0};
    int pasta[100] = {0};
    int ans = 0;
	int i, j, k, l;
	
    scanf("%d %d", &N, &K);
    for(i = 0; i < K; i++){
        scanf("%d", &j);
        scanf("%d", &pasta[j - 1]);
    }

    if(pasta[0] != 0){
        num[0][0][pasta[0] - 1] = 1;
    }else{
        for(i = 0; i < PASTA_NUM; i++){
            num[0][0][i] = 1;
        }
    }

    if(pasta[1] != 0){
        for(i = 0; i < PASTA_NUM; i++){
            num[1][i][pasta[1] - 1] += num[0][0][i];
        }
    }else{
        for(i = 0; i < PASTA_NUM; i++){
            for(j = 0; j < PASTA_NUM; j++){
                num[1][i][j] += num[0][0][i];
            }
        }
    }

    for(k = 2; k < N; k++){
        if(pasta[k] != 0){
            for(i = 0; i < PASTA_NUM; i++){
                for(j = 0; j < PASTA_NUM; j++){
                    if(!(i == j && i == (pasta[k] - 1))){
                        num[k][i][pasta[k] - 1] += num[k - 1][j][i];
                        num[k][i][pasta[k] - 1] %= 10000;
                    }
                }
            }
        }else{
            for(i = 0; i < PASTA_NUM; i++){
                for(j = 0; j < PASTA_NUM; j++){
                    for(l = 0; l < PASTA_NUM; l++){
                        if(!(i == j && i == l)){
                            num[k][i][l] += num[k - 1][j][i];
                            num[k][i][l] %= 10000;
                        }
                    }
                }
            }
        }
    }

    for(i = 0; i < PASTA_NUM; i++){
        for(j = 0; j < PASTA_NUM; j++){
            ans += num[N - 1][i][j];
            ans %= 10000;
        }
    }

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 2052
a,b,c,d = map(int,input().split())
e,f,g,h = 0,0,0,0
if a == c:
    f = d
    e = c-(d-b)
    g = e
    h = b
else:
    f = d+(c-a)
    e = c -(d - b)
    g = e - (c-a)
    h = f - (d-b)
print(e,f,g,h)

Measured memory_bytes: 3064
// https://atcoder.jp/contests/abc170/tasks/abc170_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X, N;
    cin >> X >> N;
    unordered_set<int> st;
    REP(i, N) {
        int t;
        cin >> t;
        st.insert(t);
    }
    int minv = INT32_MAX, ans = 0;
    REP(i, 200) {
        if (st.count(i) == 0 && minv > abs(X - i)) {
            minv = min(minv, abs(X - i));
            ans = i;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3660
using System;
class ProgramB
    {
        static void Main(string[] args)
        {var line = Console.ReadLine();
var data = line.Split(' ');
var a1 = int.Parse(data[0]); //first integer
//var b1 = int.Parse(data[1]); //sec
     var s=Console.ReadLine();     
          //string a=Console.ReadLine();int a1=int.Parse(a); string b=Console.ReadLine();int b1=int.Parse(b);
         Console.WriteLine(((a1)<3200?"red": s));
           /* string input = Console.ReadLine();
            int n = int.Parse(input);
            string[] input_p = Console.ReadLine().Split(' ');
            int[] p = new int[n];
            for(int i = 0;i < n;i++)
                p[i] = int.Parse(input_p[i]);

            int count = 0;
            
            for(int i = 0;i < n;i++)
            {
                if(p[i] != i + 1)
                    count++;
            }

            if( count == 2 || count == 0)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");*/
        }
    }


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <iomanip>
#include <iterator>
#include <utility>

typedef long long ll;
typedef unsigned long long ull;

int main() {
	ull a, b, c, d, n, c_r, d_r;
	std::cin >> a >> b >> c >> d;
	c_r = c;
	d_r = d;
	if (c < d) {
		std::swap(c, d);
		std::swap(c_r, d_r);
	}
	for (int i = 0; i < c; ++i) {
		n = c % d;
		c = d;
		if (n == 0) {
			break;
		}
		d = n;
	}
	a -= 1;
	std::cout << (b - (b / c_r) - (b / d_r) + (b / (c_r * d_r / d))) - (a - (a / c_r) - (a / d_r) + (a / (c_r * d_r / d))) << std::endl;
}

Measured memory_bytes: 3184
#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 c=0;
    while(true){
        bool flag=false;
        for(int i=0;i<N;i++){
            if(A.at(i)%2!=0){
               flag=true; 
            }
        }
        if(flag) break;
        for(int i=0;i<N;i++){
            A.at(i)/=2;
        }
        c++;
    }
    cout << c << endl;
return 0;
}

Measured memory_bytes: 256
def col(n, m):
    X = [[] for _ in range(n)]
    for _ in range(m):
        a, b = map(int, input().split())
        X[a-1].append(b-1)
        X[b-1].append(a-1)
    C = [-1] * n
    c = 0
    for i in range(N):
        if C[i] >= 0: continue
        Q = [i]
        C[i] = c
        while Q:
            x = Q.pop()
            for y in X[x]:
                if C[y] == -1:
                    C[y] = C[x]
                    Q.append(y)
        c += 1
    return C

N, K, L = map(int, input().split())
A = col(N, K)
B = col(N, L)
D = {}
for a, b in zip(A, B):
    t = (a<<18) + b
    if t in D: D[t] += 1
    else: D[t] = 1

print(*[D[(a<<18)+b] for a, b in zip(A, B)])

Measured memory_bytes: 46528
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int N, Q;
string s;
char t[200000], d[200000];

bool check(int pos, bool left) {
    REP(i, Q) {
        if (s[pos] == t[i]) {
            if (d[i] == 'L') pos--;
            else pos++;
        }
        if (pos <= 0) return left;
        if (pos >= N + 1) return !left;
    }
    return false;
}

int binary_search(int ok, int ng, bool left) {
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (check(mid, left)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main() {
    cin >> N >> Q >> s;
    s = " " + s + " ";
    REP(i, Q) cin >> t[i] >> d[i];
    int left = binary_search(0, N + 1, true);
    int right = binary_search(N + 1, 0, false);
    cout << right - left - 1 << endl;
    return 0;
}

Measured memory_bytes: 984
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k,q;
    cin >> n >> k >>q;
    vector<int> a(n,k-q);
    rep(i,q){
        int m;
        cin >> m;
        a[m-1]+=1;
    }
    rep(i,n){
        if(a[i]<=0) cout << "No" << endl;
        else cout << "Yes" <<endl;
    }
    

    return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define f(i,n)  for(i=0;i<n;i++)
#define em emplace_back
#define mp make_pair

int main() {
    int s,w;
    cin>>s>>w;
    if(w>=s)    cout<<"unsafe";
    else    cout<<"safe";
	return 0;
}//1236895

Measured memory_bytes: 3624
n = int(input())
v = list(map(int, input().split()))
v = sorted(v)
while len(v) > 1:
  a = v.pop(0)
  b = v.pop(0)
  v.append((a+b)/2)
  v = sorted(v)
  if len(v) == 1:
    break

print(*v)

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std ;

const int N=1e5+100 ;

char s[N] ;
int a[N] ;
int n , k ;

inline bool check ( int l )
{
	int i , res=0 ;
	for ( i=1 ; i<=l ; i++ ) 
		if ( !a[i] && a[i]!=a[i-1] ) res++;
	if ( res<=k ) return 1 ;
	for ( i=l+1 ; i<=n ; i++ ) 
	{
		if ( a[i-1] && !a[i] ) res++;
		if ( !a[i-l] && a[i-l+1] ) res--;
		if ( res<=k ) return 1 ;
	}
	return 0 ;
}

int main ()
{
	int i ;
	scanf("%d%d %s ",&n,&k,s+1);
	for ( i=1 ; i<=n ; i++ ) a[i]=s[i]-'0';
	a[0]=-1;
	int l=1 , r=n ;
	while ( l<r )
	{
		int mid=(l+r+1)>>1;
		if ( check(mid) ) l=mid;
		else r=mid-1;
	} 
	printf("%d\n",l);
	return 0 ;
}

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

int main(){
  int N;
  string S;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> S;
    if (S == "Y"){
      cout << "Four" << endl;
      break;
    }
    else if (i == (N - 1)){
      cout << "Three" << endl;
    }
  }
}


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

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

void solve(){
    string s, t;
    cin >> s >> t;
    int ans = INF;
    int n = s.size(), m = t.size();
    for (int i = 0; i <= n - m; ++i){
        int tmp = 0;
        for (int j = 0; j < m; ++j){
            if (s[i+j] != t[j])tmp++;
        }
        ans = min(tmp, ans);
    }
    cout << ans << '\n';
}

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	ll i, j, n;
	int t = 1; //cin >> t;
	while(t--) solve();
	return 0;
}



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

int main() {
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    c*=2;
    if(a+b>=c){
        int d;
        if(x>=y){
            if(a>=c){
                cout<<c*x<<endl;
            }else{
                cout<<c*y+a*(x-y)<<endl;
            }
        }else{
            if(b>=c){
                cout<<c*y<<endl;
            }else{
                cout<<c*x+b*(y-x)<<endl;
            }
        }
    }else{
        cout<<a*x+b*y<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A == 5 && B == 5 && C == 7) {
    cout << "YES" << endl;
  }
  else if (A == 5 && B == 7 && C == 5) {
    cout << "YES" << endl;
  }
  else if (A == 7 && B == 5 && C == 5) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),n.end()
#define PI acos(-1)
using namespace std;
int main(){

  int n,m;
  while(cin>>n>>m,n){
    vector<int>a(m);
    vector<int>b(m,0);

    rep(i,m)a[i]=i;
    rep(i,n){
      rep(j,m){
	int tmp;
	cin>>tmp;
	b[j]+=tmp;
      }
    }
    //cout<<b[0]<<endl;;
    rep(i,m-1){
      rep(j,m-1){
	if(b[j]<b[j+1]){
	  swap(b[j],b[j+1]);
	  swap(a[j],a[j+1]);
	}
      }
    }
    rep(i,m){
      if(i==m-1)cout<<++a[i]<<endl;
      else cout<<++a[i]<<" ";
    }
  }
}

Measured memory_bytes: 1196
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
    static void solve(){//Here is the main function
      ArrayList<String> one = nextStrArray();
      String A = one.get(0);
      String B = one.get(1);
      if(A.equals("H")){
        myout(B);
      }else{
        myout((B.equals("H")) ? "D" : "H");
      }
	}
	//Method addition frame start


  
	//Method addition frame end
}


Measured memory_bytes: 33088
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define rep(i, s, n) for(int i = s; i < n; i++) 

int main() {
    int n, k;
    int r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;

    int ans = 0;
    rep(i, 0, n) {
        if(t[i] == 'r') {
            ans += p;
        }
        else if(t[i] == 's'){
            ans += r;
        }
        else if(t[i] == 'p') {
            ans += s;
        }
    }

    rep(i, 0, n-k) {
        if(t[i] == t[i+k]) {
            if(t[i] == 'r') {
                ans -= p;
                t[i+k] = 'z';
            }
            else if(t[i] == 's') {
                ans -= r;
                t[i+k] = 'x';
            }
            else if(t[i] == 'p') {
                ans -= s;
                t[i+k] = 'y';
            }
        }
    }

    cout << ans << endl;
}

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

const int maxn = 1e5 + 5;
vector<int> G[maxn];
int dist[maxn];
int indegree[maxn];
bool vis[maxn];

void dfs(int u) {
    vis[u] = true;

    for (int v: G[u]) {
        dist[v] = max(dist[v], dist[u] + 1);
        --indegree[v];
        if (indegree[v] == 0)
            dfs(v);
    }
}

int main() {
    int N, M;
    scanf("%d%d", &N, &M);

    for (int i = 0; i < M; ++i) {
        int a, b;
        scanf("%d%d", &a, &b);
        G[a].push_back(b);
        ++indegree[b];
    }

    for (int i = 1; i <= N; ++i) {
        if (!vis[i] and indegree[i] == 0)
            dfs(i);
    }

    int ans = 0;

    for (int i = 1; i <= N; ++i)
        ans = max(ans, dist[i]);

    printf("%d\n", ans);
}

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

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(ll i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<ll>());
  ll ans = 0;
  queue<ll> que;
  for(ll i=1;i<n;i++){
    if(i==1) ans += a[0];
    else if(i==2) ans += a[1];
    else if(i==3){
      ans += a[1];
      que.push(a[i]);
      que.push(a[i]);
    }
    else if(i==4){
      ans += a[2];
      que.push(a[i]);
      que.push(a[i]);
    }
    else if(i==5){
      ans += a[2];
      que.push(a[i]);
      que.push(a[i]);
    }
    else{
      ans += que.front();
      que.pop();
      que.push(a[i]);
      que.push(a[i]);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6420
#include <iostream>

using namespace std;

typedef long long ll;

int r, D;

void calc(ll x, int i) {
		if (i == 10) return;
		else {
				x = r * x - D;
				i++;
				cout << x << endl;
				calc(x, i);
		}
}

int main() {
		ll x;
		cin >> r >> D >> x;
		calc(x, 0);
		return 0;
}


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

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

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);

    if (a <= 5)
        printf("0\n");
    else if (6 <= a && a <= 12)
        printf("%d\n", b / 2);
    else
        printf("%d\n", b);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
int main() {
  int A, B, x, X = 0;
  std::string str;

  cin >> A >> B;

  for(int i = A; i <= B; i++){
     str = std::to_string(i);

     if(str.at(0) == str.at(4) && str.at(1) == str.at(3)){
       X++;
     }

  }

  cout << X << endl;

}


Measured memory_bytes: 256
var
 a,b:string;
 i,j,la,lb:longint;
 t:char;
begin
 readln(a);
 read(b);
 la:=length(a);
 lb:=length(b);
 for i:=1 to la-1 do
 for j:=i+1 to la do 
 if a[i]>a[j] then 
  begin
   t:=a[i];a[i]:=a[j];a[j]:=t;
  end;
 for i:=1 to lb-1 do
 for j:=i+1 to lb do 
 if b[i]<b[j] then 
  begin
   t:=b[i];b[i]:=b[j];b[j]:=t;
  end;
 if a<b then writeln('Yes')
 else writeln('No');
end.

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

int main()
{
    int n, q;
    cin>>n>>q;
    string s;
    cin>>s;
    vector<int> v(n+1);
    for(int i=1; i<n; ++i)
    {
        if(s[i-1]=='A' && s[i]=='C')
            v[i]=1;
    }
    for(int i=1; i<=n; ++i)
        v[i]+=v[i-1];
    while(q--)
    {
        int l,r;
        cin>>l>>r;
        cout<<v[r-1] - v[l-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3844
n, m= map(int, input().split())
H = list(map(int, input().split()))
mountains = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    if H[a-1] > H[b-1]:
        mountains[b-1] = 1
    elif H[a-1] < H[b-1]:
        mountains[a-1] = 1
    else:
        mountains[a-1] = 1
        mountains[b-1] = 1
print(mountains.count(0))

Measured memory_bytes: 84856
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int n,i,cnt,a[51];
	scanf("%d",&n);
	for(i=1;i<=n;i++)	scanf("%d",&a[i]);
	cnt=0;
	for(i=1;i<=n;i++)	{
		if(a[i]!=i)	cnt++;
	}
	if(cnt<=2)	printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A_list = list(map(int,input().split()))

# A_listのうち、奇数であるA_Nが偶数個ならばYES, 奇数個ならばNOである。
modsum = 0
for i in A_list:
    modsum += i % 2

if modsum % 2 == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 14108
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	t := make([][]int, 2)
	for i := 0; i < 2; i++ {
		ct := make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Scan(&ct[j])
		}
		t[i] = ct
	}

	p := make([]int, n)
	for i := 1; i <= n; i++ {
		p[i-1] = i
	}
	all := Permute(p)
	var (
		index1 int
		index2 int
	)
	sort.Strings(all)
	for i := range all {
		if all[i] == fmt.Sprint(t[0]) {
			index1 = i
		}
		if all[i] == fmt.Sprint(t[1]) {
			index2 = i
		}
	}
	fmt.Println(math.Abs(float64(index1) - float64(index2)))
}

func Permute(nums []int) []string {
	n := factorial(len(nums))
	ret := make([]string, 0, n)
	permute(nums, &ret)
	return ret
}

func permute(nums []int, ret *[]string) {
	*ret = append(*ret, fmt.Sprint(makeCopy(nums)))

	n := len(nums)
	p := make([]int, n+1)
	for i := 0; i < n+1; i++ {
		p[i] = i
	}
	for i := 1; i < n; {
		p[i]--
		j := 0
		if i%2 == 1 {
			j = p[i]
		}

		nums[i], nums[j] = nums[j], nums[i]
		*ret = append(*ret, fmt.Sprint(makeCopy(nums)))
		for i = 1; p[i] == 0; i++ {
			p[i] = i
		}
	}
}

func factorial(n int) int {
	ret := 1
	for i := 2; i <= n; i++ {
		ret *= i
	}
	return ret
}

func makeCopy(nums []int) []int {
	return append([]int{}, nums...)
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
ll n,m,q;
ll a[50],b[50],c[50],d[50];
ll x[10];
ll ans=0;
void dfs(ll i0,ll j0){
    x[i0]=j0;
    if(i0==n-1){
        ll tmp=0;
        rep(0,i,q)if(x[b[i]-1]-x[a[i]-1]==c[i])tmp+=d[i];
        ans=max(ans,tmp);
    }else if(i0<n){
        rep(j0,j,m)dfs(i0+1,j);
    }
}
int main(void){
    // Your code here!
    cin>>n>>m>>q;
    rep(0,i,q)cin>>a[i]>>b[i]>>c[i]>>d[i];
    rep(0,i,m)dfs(0,i);
    cout<<ans;
}

Measured memory_bytes: 3604
import sys

str_s = input()
k = input()

int_s = int(str_s)
k = int(k)

gosentyo = 5000000000000000
count = 0

# print(2 ** gosentyo)


for s in str_s:
    now_count = 1

    if int(s) == 1:
        count += 1
        if count >= k:
            print(s)
            sys.exit()
    else:
        for i in range(gosentyo):
            # print(count,now_count)
            if (now_count + count >= k):
                print(s)
                sys.exit()
            now_count *= int(s)
        else:
            count += now_count


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int a[505][505],c[250100][4],h,w,ans;
int main(){
    cin>>h>>w;
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            cin>>a[i][j];
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w-1;j++)
        {
            if(a[i][j]%2==1)
            {
                c[ans][0]=i;
                c[ans][1]=j;
                c[ans][2]=i;
                c[ans][3]=j+1;
                ans++;
                a[i][j+1]++;
            }
        }
    }
    for(int i=0;i<h-1;i++)
    {
        if(a[i][w-1]%2==1)
        {
            c[ans][0]=i;
            c[ans][1]=w-1;
            c[ans][2]=i+1;
            c[ans][3]=w-1;
            ans++;
            a[i+1][w-1]++;
        }
    }
    cout<<ans<<endl;
    for(int i=ans-1;i>=0;i--)
        cout<<c[i][0]+1<<" "<<c[i][1]+1<<" "<<c[i][2]+1<<" "<<c[i][3]+1<<endl;
    return 0;
}

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

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n+1), b(n);
	for(int i=0;i<n+1;i++)
		cin >> a[i];
	for(int i=0;i<n;i++)
		cin >> b[i];
	
	ll ans = 0;
	for(int i=0;i<n;i++)
	{
		if(b[i] > a[i])
		{
			ans += a[i];
			b[i] = b[i] - a[i];
			a[i] = 0;
		}else{
			ans += b[i];
			a[i] = a[i] - b[i];
			b[i] = 0;
		}

		if(b[i] > a[i+1])
		{
			ans += a[i+1];
			b[i] = b[i] - a[i+1];
			a[i+1] = 0;
		}else{
			ans += b[i];
			a[i+1] = a[i+1] - b[i];
			b[i] = 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define inf 1000000000000000001
#define mod 1000000007
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise fixed(cout);cout<<setprecision(16);
#define Set(N,p) N=((N)|((1LL)<<(p)))
#define Reset(N,p) N=((N)&(~((1LL)<<(p))))
#define Check(N,p) (!(((N)&((1LL)<<(p)))==(0)))
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define OUT(x) for(auto a:x) cout << a << " "; cout << endl;
#define OK cout << "@===================ok===================@" <<endl;
#define WTF cout <<"< "<<lo<<" | "<< hi <<" >" << endl;

using namespace std;
const int maxn=1e7+5;
int sod[maxn];

void prec(){
    for(int i=1;i<maxn;++i) {
        for(int j=i;j<maxn;j+=i) ++sod[j];
    }
}
int main()
{
    prec();
    //cout << sod[1] <<" "<<sod[2] <<" "<< sod[3] <<" "<< sod[4] <<"\n";
    int n;
    cin >> n;
    ll res=0;
    for(int k=1;k<=n;k++){
        res+=1LL*k*sod[k];
    }
    cout << res <<"\n";
}


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

int main(){
    string s;
    cin >> s;
    int l = s.length();
    if(l == 2){
        if(s[0] == s[1]) cout << "1" << " " << "2" << endl;
        else cout << "-1" << " " << "-1" << endl;
        return 0;
    }
    rep(i,l-2){
        if(s[i] == s[i+1] || s[i] == s[i+2] || s[i+1] == s[i+2]) {
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << "-1" << " " << "-1" << endl;
    return 0;
}


Measured memory_bytes: 512
n = int(input())
hn = list(map(int, input().split()))


count = 0
maxim = 0
before = hn[0]
for i in hn[1:]:
    if before >= i:
        count += 1
        if count > maxim:
            maxim = count
    else:
        count = 0
    before = i
print(maxim)

Measured memory_bytes: 14252
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

n = ni()
p = []

for _ in range(n):
    p.append(ni())

dp = [0]*(n+1)

for i in range(n):
    dp[p[i]] = dp[p[i]-1] + 1

print(n - max(dp))

Measured memory_bytes: 18984
#include<iostream>
using namespace std;
typedef long long ll;

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

int main(){
    int n, x;
    cin >> n >> x;
    int a[n];
    for(int i = 0; i < n; i++)  cin >> a[i];
    int z = abs(x-a[0]);
    for(int i = 1; i < n; i++)  z = gcd(z, abs(x-a[i]));
    cout << z << endl;
    return 0;
}


Measured memory_bytes: 640
//#pragma GCC optimize(2)
#include<set>
#include<map>
#include<stack>
#include<ctime>
#include<cstdio>    
#include<queue>    
#include<cmath>    
#include<vector>    
#include<cstring>   
#include<climits>    
#include<iostream>   
#include<algorithm>
using namespace std;
#define LL long long
LL read(){
    LL f=1,x=0;char c=getchar();
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
    while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();}
    return f*x;
}
#define MAXN 5000
#define INF 10000000000000000ll
LL a[MAXN+5],mn[MAXN+5];
int main(){
	LL n=read(),x=read(),ans=INF;
	for(int i=1;i<=n;i++)
		a[i]=a[i+n]=read(),mn[i]=INF;
	for(int t=0;t<=n;t++){
		LL tmp=t*x;
		for(int i=1;i<=n;i++)
			mn[i]=min(mn[i],a[i+t]),tmp+=mn[i];
		ans=min(ans,tmp);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MAXSIZE 10000000;

bool comp(const pair<int,int> a, const pair<int,int> b) {

    return a.second < b.second;
}

int Dx[6] = { 0, 0, 1, 1,-1,-1};
int Dy[6] = { 1,-1, 1, 0, 0,-1};

//priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
//priority_queue<long long int> PQ1;
int main(){

  string list;
  string ans = "No";
  vector<char> s;

  cin >>list;

  for(int i = 0;i<4;i++){
    s.push_back(list[i]);

  }

  sort(s.begin(),s.end());

  if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2]){
    ans = "Yes";
  }
  cout <<ans<<endl;
  return 0;
}

/*Syakutori
while(cin >>b && b)){
      ll t = 1;
      long long int ansS = 1,ansT=0;
      long long int sum = 0;

      for(ll s = 1;s < 50000000;s++){

        while(t <  50000000 && sum+Rsum[t] < b){
          sum += Rsum[t];
          t++;
        }
        if(b == sum+Rsum[t]){
          if(ansT - ansS < t-s){
            ansS = s;
            ansT = t;
          }
          cout <<ansS<<" "<<ansT-ansS + 1<<endl;
          break;
        }
        if(t == s)++t;
        else sum -= Rsum[s];
        }
    }

*/

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int x;
    scanf("%d",&x); 
    if(x%7==0)printf("thu\n");
    else if(x%7==1) printf("fri\n");
    else if(x%7==2) printf("sat\n");
    else if(x%7==3) printf("sun\n");
    else if(x%7==4) printf("mon\n");
    else if(x%7==5) printf("tue\n");
    else printf("wed\n");
    
   return 0;
}




Measured memory_bytes: 2112
package main

import "fmt"

func solve() {
	var N, A, B int
	fmt.Scan(&N, &A, &B)

	fmt.Println(min(N*A, B))

}

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

func main() {
	solve()
}


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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;


const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = INT_MAX / 2;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	string w;
	cin >> w;
	map<char, int> m;
	for (char c : w) {
		m[c]++;
	}
	string ans = [&] {
		for (auto &p : m) {
			if (p.second % 2) return "No";
		}
		return "Yes";
	}();
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int e,x=0,y=0,z=0,m=1000000;
    
    while(1){
        m=1000000;
        scanf("%d",&e);
        if(e==0)break;
        for(z=0;z<101;z++)
            for(y=0;y<1001;y++){
                x=e-z*z*z-y*y;
                if (x<0) continue;
                if(m>(x+y+z))
                    m=x+y+z;
            }
        printf("%d\n",m);
    }
    return 0;
}

Measured memory_bytes: 596
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		Console.WriteLine(X * Math.Min(K, N) + Y * Math.Max(0, N - K));
		
		
	}
	long N,K,X,Y;
	public Sol(){
		N = rl();
		K = rl();
		X = rl();
		Y = rl();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11092
N = int(input())
print(0,flush=True)
zero = input()
if zero == 'Vacant':
    exit()
l = 0
r = N-1
while True:
    if r-l <= 1:
        print(r,flush=True)
        if input() == 'Vacant':
            exit()
        print(l,flush=True)
        if input() == 'Vacant':
            exit()
    k = (r+l)//2
    print(k,flush=True)
    seat = input()
    if seat == 'Vacant':
        exit()
    else:
        if k%2:
            if seat == zero:
                r = k
            else:
                l = k
        else:
            if seat == zero:
                l = k
            else:
                r = k


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

using namespace std;
int N;
int S[4000];
int main()
{
  for(int i=0;i<5;i++){
    cin>>N;
    if(N==0){
      cout<<i+1;
      break;
    }
  }

  return 0;
}





Measured memory_bytes: 3592
#include<stdio.h>
int main(void)
{
	int i,j,a,b[101],X,S,flg,x;
	x=0;
	while(1){
		scanf("%d",&a);
		if(a==0) break;
		for(i=0;i<a+1;i++){
			scanf("%d",&b[i]);
		}
		for(i=0;i<a+1;i++){
			X=b[0];
			b[0]=b[i];
			b[i]=X;
			S=b[2]-b[1];
			flg=0;
			for(j=1;j<a;j++){
				if(b[j+1]-b[j]!=S){
				flg=1;
				}
				x=b[0];
			}
			if(flg==0) break;
		}
		printf("%d\n",x);
	}
	return 0;
}

Measured memory_bytes: 1028
#include<stdio.h>


int A[1000000], n;

int binarySearch(int key) {
	int left = 0;
	int right = n;
	int mid;

	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) {
			return  1;//keyを発見//
		}
		else if (key > A[mid]) {
			left = mid + 1;//後半を探索する//
		}
		else{
			right = mid;//前半を探索する//
		}
	}
	return 0;
}

int main() {
	int i, q, k, sum = 0;

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

	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &k);
		if (binarySearch(k) == 1) {
			sum++;
		}
	}
	printf("%d\n", sum);

	return 0;
}


Measured memory_bytes: 2980
#include<bits/stdc++.h>
using namespace std;
long long x,k,d;
int main(){
	cin>>x>>k>>d;
	if (x>0){
		if (x/d<=k)
			k-=x/d,x=x%d;
		else{
			while (k/100000000!=0){
				k-=100000000;
				x-=d*100000000;
			}
			while (k/1000!=0){
				k-=1000;
				x-=d*1000;
			}
			while (k!=0){
				k-=1;
				x-=d;
			}
		}
		if (k%2==0)
			cout<<x<<endl;
		else
			cout<<abs(x-d)<<endl;
	}
	else if (x<0){
		if ((-1*x)/d<=k)
			k-=(-1*x)/d,x=-1*((-1*x)%d);
		else{
			while (k/100000000!=0){
				k-=100000000;
				x+=d*100000000;
			}
			while (k/1000!=0){
				k-=1000;
				x+=d*1000;
			}
			while (k!=0){
				k-=1;
				x+=d;
			}
		}
		if (k%2==0)
			cout<<abs(x)<<endl;
		else
			cout<<abs(x+d)<<endl;
	}
	else{
		if (k%2==0)
			cout<<0<<endl;
		else
			cout<<abs(d)<<endl;
	}
	return 0;
}


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

void input(vector<int>& rvnLife)
{
  int nLiftSiz;
  cin >> nLiftSiz;
  rvnLife.resize(nLiftSiz);

  for (int& rnLife : rvnLife)
    cin >> rnLife;
}

int gcd(int nOne, int nOtr)
{
  if (nOtr == 0)
    return nOne;
  else
    return gcd(nOtr, nOne % nOtr);
}

int calcMinLife(const vector<int>& cnrvnLife)
{
  int nMinLife = cnrvnLife[0];

  for (int i = 1; i < cnrvnLife.size(); i++)
    nMinLife = gcd(nMinLife, cnrvnLife[i]);

  return nMinLife;
}
 
int main()
{
  vector<int> vnLife;

  input(vnLife);
  cout << calcMinLife(vnLife) << endl;

  return 0;
}

Measured memory_bytes: 3648
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int N, M;
  ci(N, M);
  int A = 0;
  rep(i, M){
    int x;
    ci(x);
    A += x;
  }
  N - A >= 0 ? co(N - A) : co(-1);
}

Measured memory_bytes: 3576