akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		int[] h = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = Integer.parseInt(sa[i]);
		}
		int[] a = new int[m];
		int[] b = new int[m];
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			a[i] = Integer.parseInt(sa[0]) - 1;
			b[i] = Integer.parseInt(sa[1]) - 1;
		}
		br.close();

		Set<Integer> set = new HashSet<>();
		for (int i = 0; i < m; i++) {
			if (h[a[i]] > h[b[i]]) {
				set.add(b[i]);
			}
			if (h[a[i]] < h[b[i]]) {
				set.add(a[i]);
			}
			if (h[a[i]] == h[b[i]]) {
				set.add(a[i]);
				set.add(b[i]);
			}
		}
		System.out.println(n - set.size());
	}
}


Measured memory_bytes: 56628
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <iterator>
#include <algorithm>
#include <map>
#include <string.h>
#include <vector>
#include <cmath>
#include <deque>
#include <iomanip>

using namespace std;
#define range(a) a.begin(), a.end()
#define rep(i, c) for(int i = 0; i < (int)c; i++)
typedef long long ll;

const string YES = "Yes";
const string NO = "No";

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

  int x, a; cin >> x >> a;
  if(x < a) cout << 0 << endl;
  else cout << 10 << endl;


  return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	for(;;){
    	int n;
	    cin>>n;
	    if(n==0)break;
	    char a[100];
	    for(int i=0;i<100;i++){
	    	cin>>a[i];
     	}	
	    int b[10]={};//それぞれの持ち札
    	int c=0;//場
    	for(int i=0,d=0;i<100;i++,d++){
			if(d==n){
				d=0;
			}	
    		if(a[i]=='M'){
    			b[d]+=1;
    		}
	    	if(a[i]=='S'){
	    		c+=b[d]+1;
	    		b[d]=0;
	    	}
	    	if(a[i]=='L'){
	    		b[d]+=c+1;
	    		c=0;
    		}
    	}
    	sort(b,b+n);
    	for(int i=0;i<n;i++){
    		cout<<b[i]<<" ";
    	}
    	cout<<c<<endl;
    }
    return 0;
}    		



Measured memory_bytes: 3128
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    """
    辺(a,b)を結べるかどうかは、(a,b)の距離が奇数長かどうかと等しい
    なぜなら、(a,b)が奇数長なら(a,b)の間の3-stepを1-stepで出来るような辺を張れるのでいずれ3-stepになる。
    
    1.二部グラフでないなら、奇数サイクルが1つ以上存在する
        ―奇数サイクルがあるなら、サイクル上のvを通るようなpath(s,t)が存在し、それが偶数長でも余計に奇数サイクルを通ることで奇数長のパスを見つける事ができる
    2.二部グラフならグループ1とグループ2の任意の点を結ぶパスは奇数長になり、同グループのパスは偶数長になる
    """
    N,M=MI()
    edge = [[]for _ in range(N)]
    for _ in range(M):
        a,b = MI_()
        edge[a].append(b)
        edge[b].append(a)
    
    group = [-1]*N
    group[0] = 0

    def is_bipartite():
        stack = [0]
        while stack:
            v = stack.pop()
            for to in edge[v]:
                if group[to]!=-1 and group[to]==group[v]:
                    return False
                if group[to]==-1:
                    stack.append(to)
                    group[to] = group[v]^1
        return True

    bipartite = is_bipartite()
    if bipartite:
        g1 = group.count(0)
        g2 = N-g1
        ans = g1*g2
    else:
        ans = N*(N-1)//2
    ans -= M
    print(ans)

                
if __name__ == '__main__':
    main()

Measured memory_bytes: 84584
while True:
    l = input().split()
    a = int(l[0])
    op = l[1]
    b = int(l[2])

    if op =='+':
        c = a+b
        print(c)
    elif op =='-':
        d = a-b
        print(d)
    elif op =='*':
        e = a*b
        print(e)
    elif op =='/':
        f =a/b
        print(int(f))
    else:
        break


Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 5000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,t; cin>>a>>b>>t;
    cout<<b*(t/a)<<endl;
}

Measured memory_bytes: 764
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<long long,long long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
 
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

//long long A,B;
bool ok(long long key,long long index){
    if(index > key) return true;
    else if(index <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    string S;cin >> S;
    for(int i = 0;i<5;i++){
        cout << S.at(i);
    }
    cout << " ";
    for(int i = 6;i<13;i++){
        cout << S.at(i);
    }
    
    cout << " ";
    for(int i = 14;i<19;i++) cout << S.at(i);

    cout << endl;

    // PLEASE GIVE ME THE "ACCEPTED" !
}


Measured memory_bytes: 256
N, A, B, C, D = map(int, input().split())
MOD = 10 ** 9 + 7

fac = [1] * (N + 1)
for i in range(2, N + 1):
    fac[i] = fac[i - 1] * i % MOD

finv = [1] * (N + 1)
finv[-1] = pow(fac[-1], MOD - 2, MOD)
for i in reversed(range(1, N + 1)):
    finv[i - 1] = finv[i] * i % MOD

dp = [[0] * (N + 1) for _ in range(B + 1)]
dp[A - 1][0] = 1

for i in range(A, B + 1):
    for j in range(N + 1):
        dp[i][j] = dp[i - 1][j]
        for k in range(C, min(D, j // i) + 1):
            t = (fac[N - j + i * k] * finv[N - j] \
                      * pow(finv[i], k, MOD) * finv[k]) % MOD
            dp[i][j] += dp[i - 1][j - i * k] * t
            dp[i][j] %= MOD

print(dp[B][N])


Measured memory_bytes: 99164
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    int max_count = 0;
    int max_num = 1;
    for (int i=1; i <= N; i++) {
        int num = i;
        int count = 0;
        while (true) {
            if (num % 2 != 0) {
                break;
            }

            count += 1;
            num = num / 2;
        }

        if (count > max_count) {
            max_count = count;
            max_num = i;
        }
    }

    cout << max_num << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
	$n = trim(fgets(STDIN));
	$m = trim(fgets(STDIN));
	$m = explode(" ", $m);

	printf("%d ", min($m));
	printf("%d ", max($m));

	$sum = 0;
	foreach ($m as $val) {
		$sum += $val;
	}
	printf("%d\n", $sum);

Measured memory_bytes: 8420
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n,k;
    while (cin>>n>>k, n+k) {
        bool flag=true;
        vi v(k,0);
        rep(i,k)cin>>v[i];
        rep(i,n){
            rep(j,k){
                int temp; cin>>temp;
                v[j]-=temp; if(v[j]<0)flag=false;
            }
        }
        if(flag)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 2968
import java.util.*;
import java.util.stream.IntStream;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    IntStream.range(0,s.length())
    .filter(i -> i%2 == 0)
    .forEach(
      i -> System.out.print(s.charAt(i))
    );
    System.out.println();
  }
}


Measured memory_bytes: 31684
#include <iostream>
using namespace std;
int main(void){
    int x, y;
    cin >> x >> y;
    string ans = "No";
    for (int i = 0; i <= x; i++) {
        if (i*2 + (x-i)*4 == y) {
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

vi par,sz,vis,dis;
vector<vi> graph;
vector<vector<pair<li,li>>> wgraph;

void init(li n)
{
    par.resize(n);
    sz.resize(n);
    wgraph.resize(n);
    dis.resize(n);
    vis.resize(n);
    graph.resize(n);

    f(i,0,n-1)
    {
        par[i]=i;
        sz[i]=1;
        dis[i]=1e18;
    }
}

li root(li a)
{
    while(a!=par[a])
    {
        par[a]=par[par[a]];
        a=par[a];
    }

    return a;
}

void unio(li a,li b)
{
    li r_a=root(a);
    li r_b=root(b);

    if(par[r_a]!=r_b)
    { 
        if(sz[r_a]<sz[r_b])
        {
            par[r_a]=par[r_b];
            sz[r_b]+=sz[r_a];
            sz[r_a]=0;
        }
        else
        {
            par[r_b]=par[r_a];
            sz[r_a]+=sz[r_b];
            sz[r_b]=0;
        }
    }
}

int main()
{    
   

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li n;

    cin>>n;

    li mx=INT_MIN;

    map<string,li> m;

    f(i,0,n-1)
    {
        string s;

        cin>>s;

        m[s]++;

        mx=max(mx,m[s]);
    }

    set<string> ans;

    for(auto it:m)
    {
        if(it.S==mx)
        {
            ans.insert(it.F);
        }
    }

    for(string i:ans)
        cout<<i<<endl;

    return 0;
}

Measured memory_bytes: 33280
n = int(input())
a = [[int(input()),0] for _ in range(n)]
b = [[int(input()),1] for _ in range(n)]
mod = 10**9 + 7
ab = sorted(a+b)
ans = 1
now = [0,0]
for x,y in ab:
    if now[1-y] > 0:
        ans *= now[1-y]
        ans %= mod
        now[1-y] -= 1
    else:
        now[y] += 1

print(ans)

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

enum eRoll {
	W,S,N,E
};

class Dice {
private:
	int _dice[6];
public:
	void roll(eRoll er) {
		int _diceinfo[6];
		for (int i = 0; i < 6; ++i) {
			_diceinfo[i] = _dice[i];
		}
		switch (er) {
		case W:
			_dice[0] = _diceinfo[2];
			_dice[1] = _diceinfo[1];
			_dice[2] = _diceinfo[5];
			_dice[3] = _diceinfo[0];
			_dice[4] = _diceinfo[4];
			_dice[5] = _diceinfo[3];
			break;
		case S:
			_dice[0] = _diceinfo[4];
			_dice[1] = _diceinfo[0];
			_dice[2] = _diceinfo[2];
			_dice[3] = _diceinfo[3];
			_dice[4] = _diceinfo[5];
			_dice[5] = _diceinfo[1];
			break;
		case N:
			_dice[0] = _diceinfo[1];
			_dice[1] = _diceinfo[5];
			_dice[2] = _diceinfo[2];
			_dice[3] = _diceinfo[3];
			_dice[4] = _diceinfo[0];
			_dice[5] = _diceinfo[4];
			break;
		case E:
			_dice[0] = _diceinfo[3];
			_dice[1] = _diceinfo[1];
			_dice[2] = _diceinfo[0];
			_dice[3] = _diceinfo[5];
			_dice[4] = _diceinfo[4];
			_dice[5] = _diceinfo[2];
			break;
		}
	}
	int getTopNum() { return _dice[0]; }
	int getRSideNum() { return _dice[2]; }
	int getForwardNum() { return _dice[1]; }
	int getNum(int index) { return _dice[index]; }

	void setNum() {
		for (int i = 0; i < 6; ++i) 
			cin >> _dice[i];
	}
};

bool numCheck(Dice dice1, Dice dice2) {
	bool equal = false;
	int work[6] = {-1,-1,-1,-1,-1,-1};
	int counter = 0;
	for (int i = 0; i < 6; ++i) {
		for (int k = 0; k < 6; ++k) {
			for (int j = 0; j < 6; ++j) {
				if (k == work[j])
					continue;
			}
			if (dice1.getNum(i) == dice2.getNum(k)) {
				equal = true;

				work[counter] = k;
				++counter;
				break;
			}
		}
		if (!equal)
			return false;
	}

	return true;
}

bool IsEqual(Dice dice1, Dice dice2) {
	bool work = true;
	for (int i = 0; i < 6; ++i) {
		if (dice1.getNum(i) != dice2.getNum(i)) {
			work = false;
			break;
		}
	}
	if (work) return true;
	dice1.roll(W);
	dice1.roll(W);
	for (int i = 0; i < 6; ++i) {
		if (dice1.getNum(i) != dice2.getNum(i)) {
			dice1.roll(W);
			dice1.roll(W);
			return false;
		}
	}
	return true;
}

int main() {
	int n;

	cin >> n;

	Dice *dice = new Dice[n];

	for (int i = 0; i < n; ++i) {
		dice[i].setNum();
	}

	for (int ix = 0; ix < n - 1; ++ix) {
		for (int ixx = ix+1; ixx < n; ++ixx) {
			if (!numCheck(dice[ix], dice[ixx])) {
				continue;
			}

			for (int i = 0; i < 3; ++i) {
				for (int k = 0; k < 4; ++k) {
					if (IsEqual(dice[ix], dice[ixx])) {
						cout << "No" << endl;
						//while (true) {}
						return 0;
					}
					dice[ixx].roll(N);
				}
				if (i == 0)dice[ixx].roll(W);
				if (i == 1) {
					dice[ixx].roll(N);
					dice[ixx].roll(W);
				}
			}
		}
	}
	delete[] dice;

	cout << "Yes" << endl;
	//while(true){}
	return 0;
}



Measured memory_bytes: 3100
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    n = I()
    d = set()
    for i in range(n):
        s = S()
        d.add(s)
    print(len(list(d)))


main()



Measured memory_bytes: 33320
void main() {
    int[] s = readln.chomp.split("/").to!(int[]);
    writeln(s[1] <= 4 ? "Heisei" : "TBD");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

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

int main(){
	
	double Ax,Ay,Bx,By,Cx,Cy;
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&Ax,&Ay,&Bx,&By,&Cx,&Cy)!=EOF){
		double dAx = (Ax-Bx)/hypot(Ax-Bx,Ay-By);
		double dAy = (Ay-By)/hypot(Ax-Bx,Ay-By);
		double t = dAy*(Ax-Cx)-dAx*(Ay-Cy);
		double Dx = Cx+t*2*dAy;
		double Dy = Cy-t*2*dAx;
		printf("%.6f %.6f\n",Dx,Dy);
	}
	
	return 0;
}


Measured memory_bytes: 3116
<?php
	$n = (string)fgets(STDIN);

	$mae = intval(substr($n,0,2));
	$usiro = intval(substr($n,2,2));

	if (1 <= $mae && $mae <= 12) {
		if (1 <= $usiro && $usiro <= 12) {
			echo "AMBIGUOUS";
		} else {
			echo "MMYY";
		}
	} else {
		if (1 <= $usiro && $usiro <= 12) {
			echo "YYMM";
		} else {
			echo "NA";
		}
	}
?>





Measured memory_bytes: 4728
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int nax = 1e5+5;
int a[10];

signed main(){
	int a1,b,c;
	cin>>a1>>b>>c;
	a[a1]++;
	a[b]++;
	a[c]++;
	for(int i=1; i<10; i++){
		if(a[i]==2){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	
	return 0;
}


Measured memory_bytes: 256
s = input()
ans = 0
gcount = 0

for i in range(len(s)):
  if s[i] == 'g':
    if gcount > 0:
      ans += 1
      gcount -= 1
    else:
      gcount += 1
    
  else:
    if gcount > 0:
      gcount -= 1
    else:
      ans -= 1
      gcount += 1
print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  int i,j,k,l;
  vector<string> vec(H);
  for ( i=0; i<H; i++) cin >> vec.at(i);
  for ( j=0; j<W+2; j++ ) cout << "#";
  cout << endl;
  for ( k=0; k<H; k++ ) {
    cout << "#" << vec.at(k) << "#" << endl;
  }
  for ( i=0; i<W+2; i++ ) cout << "#";
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
    int64_t K;
    cin >> K;

    int m = K%50;
    int64_t a = K/50 + 49;

    cout << 50 << endl;
    for(int i=0; i<m; i++) {
        cout << a-m+51 << " ";
    }
    for(int i=m; i<50; i++) {
        cout << a-m << " ";
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())


def ask(i):
    print(i, flush=True)
    resp = input()
    if resp == 'Vacant':
        exit()
    return resp


def test(l, r, l_resp, r_resp):
    if l % 2 == r % 2:
        return l_resp == r_resp
    else:
        return l_resp != r_resp


resp = ask(0)

l = 0
r = N
l_resp = resp
r_resp = resp

for _ in range(19):
    m = (l+r)//2
    m_resp = ask(m)
    if test(l, m, l_resp, m_resp):
        l, l_resp = m, m_resp
    else:
        r, r_resp = m, m_resp


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

int main () {
  int a, b;
  cin >> a >> b;
  
  int x = 1;
  while (b/x != 0) {
    x *= 10;
  }
  int c = a*x+b;
  int d = sqrt(c);
  if (d*d == c) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#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[i];
    sort(a.begin(), a.end());
    long long ans = 0;
    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j < n; ++j)
        {
            int l = upper_bound(a.begin(), a.end(), a[j] - a[i]) - a.begin();
            int r = lower_bound(a.begin(), a.end(), a[j] + a[i]) - a.begin() - 1;
            ans += max(0, r - l + 1 - (l <= i && i <= r) - (l <= j && j <= r));
        }
    cout << ans / 3;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)
int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> dp(n);
    for (int i=0;i<n;i++) cin >> v[i];
    dp[0]=0;
    dp[1]=abs(v[1]-v[0]);
    for (int i=2;i < n;i++){
      dp[i]=min(dp[i-2]+abs(v[i]-v[i-2]),dp[i-1]+abs(v[i]-v[i-1]));
    }
    cout << dp[n-1] << endl;
    
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define in long long
using namespace std;
in ans=0;
int main()
{
    string s;
	cin >>s;
	for(in i=0;i<(1<<s.size()-1);i++)
	{
		in l=-1;
		in r=0;
		for(in j=0;j+1<s.size();j++)
		{
			if(((i>>j)&1)!=0)
			{
				in c=0;
				for(in k=l+1;k<j+1;k++)
				c=c*10+s[k]-'0';
				r+=c;
				l=j;
			}
		}
		in c=0;
		for(in k=l+1;k<s.size();k++)
		c=c*10+s[k]-'0';
		r+=c;
		ans+=r;
	}
	cout <<ans<<endl;
	return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
	ll s; cin >> s;
	const ll _1e9 = 1000000000;
	cout << 0 << " " << 0 << " " << _1e9 << " " << (s % _1e9 == 0 ? 0 : _1e9 - s % _1e9) << " " << 1 << " " << (s + _1e9 -1) / _1e9 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N),B(N);
    for(int i=0;i<N;i++) {
        cin >> A[i];
        B[i]=A[i];
    }
    sort(B.rbegin(),B.rend());
    for(int i=0;i<N;i++){
        if(A[i]==B[0]){
            cout << B[1] << endl;
        }
        else {
            cout << B[0] << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 4736
// Problem : Rabbo Loves Jumping
// Contest : CodeChef - ketek[i] QuickMatch 25
// URL : https://www.codechef.com/KQKM2020/problems/HRJMP
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

/*/ Author:Amar1503/*/
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define fio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ull unsigned long long
#define ll long long
#define inf 1e9
#define mninf INT_MIN
#define Mod 1000000007
#define endl "\n"
#define cp(x) cout<<(x)<<" "
#define cl(x) cout<<(x)<<endl
#define ct(x,y) cout<<(x)<<" "<<(y)<<endl;
#define nl   cout<<endl
//const double PI=3.1415926535897932384626433832;
//looping
#define For(i,a,b) for(int i=a;i<b;i++)
#define test(t)  int (t); cin>>(t); while((t)--)
#define array(a,n) int (n); cin>>(n); int a[n]; for(int i=0;i<(n);i++) cin>>a[i];
#define trace(x) clog<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) clog<<#x<<": "<<x<<"     "<<#y<<" "<<y<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define printv(v)  for(int i=0;i<(v).size();i++) cout<<v[i]<<" "
//containers
#define F first
#define S second
#define pb emplace_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define itr(it, a) for(auto it = (a).begin(); it != (a).end(); it++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ers(v)   sort(all(v)); (v).erase(unique(all(v)),(v).end())
#define printmatrix(a,n,m) for(int i=0;i<n;i++){ for(int j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
typedef vector<int> vi;
typedef vector< vector< int > > vvi;
typedef pair <int, int> pii;
typedef vector < pair <int, int> > vpii;
// cout<<"\nTime Elapsed : " << 1.0*clock() /CLOCKS_PER_SEC << " s\n";
int dx[8]={1,-1,0,0,1,1,-1,-1};
int dy[8]={0,0,1,-1,1,-1,1,-1};
//#define int long long
/*/----------------------------Code begins----------------------------------/*/
int32_t main(){
fio;
int n;
cin>>n;
vector<int> dp(3,0);
int a,b,c;
for(int i=0;i<n;i++){
	cin>>a>>b>>c;
	int x=a+max(dp[1],dp[2]);
	int y=b+max(dp[0],dp[2]);
	int z=c+max(dp[0],dp[1]);
	dp[0]=x;dp[1]=y;dp[2]=z;
}
//cout<<*max_element(dp,dp+3);
cout<<max3(dp[0],dp[1],dp[2]);
}








Measured memory_bytes: 384
#include <bits/stdc++.h>
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define mod         (ll)1000000007
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll inf = (ll)1e18;
ld pi = 3.141592653589;
using namespace std;

ll bpow(ll x, ll v) {	
	if (v == 0)
		return 1 % mod;
	if (v % 2 == 1)
		return (x * bpow(x, v - 1)) % mod;
	ll r = bpow(x, v / 2);
	return (r * r) % mod;	
}

ll lcm(ll a,ll b)
{
	ll ret=(a*b)/__gcd(a,b);
	return ret;
} 

ll solve(){ 
	sl s;
	lp(i,0,3){
		ll p; cin>>p;
		s.insert(p);
	}
	if(sz(s)==2) {cout<<"Yes";}
	else cout<<"No";

}
int main(){
    ios
    ll t=1; 
    //cin>>t;
    while(t--){
    	solve();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int main(){
    int x;
    cin>>x;
    if(x==1){cout<<0<<endl;}
    else{
        cout<<1<<endl;
    }
}

Measured memory_bytes: 3628
import collections
import sys
input=sys.stdin.readline

def divisors(n):
  ret=[]
  for i in range(2,int(n**0.5)+1):
    if n%i==0:
      ret.append(i)
      while n%i==0:
        n//=i
  if n!=1:
    ret.append(n)
  return ret

def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)

n=int(input())
arr=list(map(int,input().split()))
cnt=collections.defaultdict(int)
tmp=arr[0]
for val in arr:
  tmp=gcd(tmp,val)
if tmp==1:
  is_setwise=True
else:
  is_setwise=False
is_pairwise=True
for val in arr:
  divisor=divisors(val)
  for val2 in divisor:
    cnt[val2]+=1
    if cnt[val2]==2:
      is_pairwise=False
      break
  if is_pairwise==False:
    break
if is_pairwise==True:
  print('pairwise coprime')
elif is_setwise==True:
  print('setwise coprime')
else:
  print('not coprime')

Measured memory_bytes: 191224
def pff(m):
    pf = {}
    for i in range(2, int(m ** 0.5) + 1):
        while m % i == 0:
            pf[i] = pf.get(i, 0) + 1
            m //= i
    if m > 1: pf[m] = 1
    return pf

def examC(mod):
    N = I()
    ans = int(1)
    d = defaultdict(int)
    for i in range(2,N+1):
        m = pff(i)
#        print(m)
        for v in m:
            d[v] += m[v]
#    print(d)
    for i in d:
        ans = (ans*(d[i]+1))%mod
    print(ans)

import sys
import copy
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC(mod)


Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;

#define FOR(i,N) for(int i=0;i<N;i++)

int main(){
    long long K,X,T,X1,X2,ans=0,keep1,keep2;
    string N;
    cin >> N;
    FOR(i,N.length()){
        ans += long(N[i])-48;
        ans = ans % 9;
    }
    if(ans%9==0){
        cout <<"Yes";
    }else{
        cout << "No";
    }
}	

Measured memory_bytes: 3708
//Bokann ga bokka--nn!!
//JOI 2008yo-5
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
queue<P>que;
int n;
void shuffle(int x,int y)
{
	//1~x x+1~y y+1~n
	int rep=que.size();
	for(int i=0;i<rep;i++)
	{
		P p=que.front(); que.pop();
		int f=p.first,s=p.second;
		if(s<=x)
		{
			que.push(mp(n-x+f,n-x+s));
		}
		else if(f<=x && s<=y)
		{
			if(f==1 && s==y)
			{
				que.push(mp(n-y+1,n));
			}
			else
			{
				que.push(mp(n-x+f,n));
				que.push(mp(n-y+1,n-y+s-x));
			}
		}
		else if(f<=x)
		{
			if(f==1)
			{
				que.push(mp(n-y+1,n));
				que.push(mp(1,s-y));
			}
			else if(s==n)
			{
				que.push(mp(1,n-x));
				que.push(mp(n-x+f,n));
			}
			else
			{
				que.push(mp(1,s-y));
				que.push(mp(n-y+1,n-x));
				que.push(mp(n-x+f,n));
			}
		}
		else if(s<=y)
		{
			que.push(mp(n-y+f-x,n-y+s-x));
		}
		else if(f<=y)
		{
			if(f==x+1 && s==n)
			{
				que.push(mp(1,n-x));
			}
			else
			{
				que.push(mp(1,s-y));
				que.push(mp(n-y+f-x,n-x));
			}
		}
		else
		{
			que.push(mp(f-y,s-y));
		}
	}
}
int main(){
	while(1)
	{
		cin >> n;
		if(!n) return 0;
		int m;
		cin >> m;
		int pp,q,r;
		cin >> pp >> q >> r;
		if(r==1) { cout << q-pp+1 << endl; continue;}
		while(!que.empty()) que.pop();
		que.push(mp(1,r));
		for(int i=0;i<m;i++)
		{
			int x,y;
			cin >> x >> y;
			shuffle(x,y);
		}
		int ret=0;
		while(!que.empty())
		{
			P p=que.front(); que.pop();
			ret+=max(0,min(q,p.second)-max(pp,p.first)+1);
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 1264
implicit none
integer :: a,b
integer :: n,i,j,k,nstr
character(5) :: str
logical :: flg

read *,a,b

n = 0
do i = a, b
   write(str,'(i0)') i
   flg = .true.
   nstr = len_trim(str)
   k = nstr+1
   do j = 1, nstr/2
      k = k - 1
      if (str(j:j) .ne. str(k:k)) then
         flg = .false.
         exit
      endif
   enddo
   if (flg) then
      n = n + 1
   endif
enddo

write(6,'(i0)') n
stop
end

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

string s;

void solve(){
	cin >> s;
	int n = s.length();
	REP(i, 0, n) {
		REP(j, i, n) {
			string pref = s.substr(0, i);
			string suf = s.substr(j, n - j);
			//cout << pref + suf << endl;
			if (pref + suf == "keyence") {
				printf("YES\n");
				return;
			}
		}
	}
	printf("NO\n");
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799;

int n;
int w[100];
int ans = INF;
int sum[100];

int main(){
  cin >> n;
  rep(i, n){
    cin >> w[i];
  }
  sum[0] = w[0];
  for(int i = 1; i < n; i++) sum[i] = sum[i-1] + w[i];
  rep(i, n) ans = min(ans, abs(sum[n-1] - 2 * sum[i]));
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>

int main(){

	double x1, y1, x2, y2;
	std::cin >> x1 >> y1 >> x2 >> y2;

	printf("%.8f\n", std::sqrt(std::abs(x1 - x2)*std::abs(x1 - x2) + std::abs(y1 - y2)*std::abs(y1 - y2)));

	return 0;
}

Measured memory_bytes: 1236
from sys import stdin
from collections import deque
from math import factorial
mod = 10**9 + 7
a,b = [int(x) for x in stdin.readline().rstrip().split()]

if abs(a-b) >= 2:
    print(0)
    exit()

if a == b:
    print(2*(factorial(a)%mod)**2%mod)
else:
    mi = min(a,b)
    print(factorial(mi+1)%mod*(factorial(mi)%mod)%mod)

Measured memory_bytes: 4476
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
//#define DEBUG
//#define RANDOM
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<bool> v(n + 3, false);
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        if (a == b)
        {
            v[i] = true;
        }
    }
    bool yes = false;
    for (int i = 0; i < n; i++)
    {
        if (v[i] && v[i + 1] && v[i + 2])
        {
            yes = true;
        }
    }
    if (yes)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3652
package main

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

func solve() {
	n := getInt()
	ans := (n - 1) / 2
	fmt.Fprintln(wr, ans)
}

const (
	inf = 1 << 60
	mod = 1000000007
)

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

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

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

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

func getFloat() float64 {
	f, err := strconv.ParseFloat(getString(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


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

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var H = sc.nextLong();
        var a = new int[N];
        var b = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }

        long ans = 0;
        var amax = a.Max();
        var thr = b.Where(i => i > amax).Select(i => (long)i).OrderByDescending(l => l).ToArray();

        for (int i = 0; i < thr.Length; i++) {
            H -= thr[i];
            ans++;
            if (H <= 0) break;
        }

        if (H > 0) {
            if (H % amax != 0) {
                ans++;
            }
            ans += H / amax;
        }

        WriteLine(ans);
    }
}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 22992
read SELECTNUM BLUE RED

ANS_TMP=$(( $(($SELECTNUM / $(($BLUE + $RED)) )) * $BLUE))
REM=$(($SELECTNUM % $(($BLUE + $RED)) ))

if [ $REM -lt $BLUE ] ; then
  ANS=$(( $ANS_TMP + $REM ))
else
  ANS=$(( $ANS_TMP + $BLUE ))
fi

echo $ANS

exit 0

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

while 1:
  n,k = map(int,input().split())
  if n == k == 0:
    break
  a = []
  for i in range(n):
    a.append(int(input()))
    c = 0
  for i in range(k):
    c += a[i]
    b = c
  for i in range(k, n):
    c += a[i]
    c -= a[i - k]
    b = max(b,c)
  print(b)


Measured memory_bytes: 9616
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
//const int MOD=998244353;
const long long LINF = 1e18;
using namespace std;
#define int long long
//template
typedef pair<int, int> P;
std::vector<P> ans;//答え
int nowx = 0, nowy = 0;//現在のxとyの場所
void move(int x, int y) {
	nowx += x; nowy += y;
	ans.push_back(P(nowx, nowy));
}
//main
signed main() {
	int k, x, y; 
	cin >> k >> x >> y;
	if (k % 2 == 0 && ((x + y) & 1)){ cout << -1 << endl; return 0; }

	if (abs(x) + abs(y) == k) { cout << 1 << endl << x << " " << y << endl; return 0; }
	int X = abs(x), Y = abs(y);
	int cou = -1;

	for (int j = k * 2; cou < 0; j += k) {
		if ((j - (X + Y)) % 2 == 0) {
			cou = (j - (X + Y)) / 2;
		}
	}
	if (cou) {
		int a = cou / k;
		while (a--)move(-k, 0);
		cou %= k;
		if (nowx < 0)move(k - cou, -cou);
		else {
			
			if (X > Y)move(k - cou, -cou);
			else move(-cou, k - cou);
		}
	}
	while (nowx + k <= X)move(k, 0);
	while (nowy + k <= Y)move(0, k);
	if (nowx != X || nowy != Y)ans.push_back(P(X, Y));

	cout << ans.size() << endl;
	for (auto p : ans) {
		if (x < 0)cout << p.first*(-1);
		else cout << p.first;
		cout << " ";
		if (y < 0)cout << p.second*(-1);
		else cout << p.second;
		cout << endl;
	}
}


Measured memory_bytes: 5484
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k, n;
  cin >> k >> n;
  vector<int> vec(n);
  REP(i,n) cin >> vec[i];
  int maxi = vec[0];
  REP(j,n) {
    if(j == 0) continue;
    if(j == n-1) continue;
    if(maxi < vec[j+1] - vec[j]) maxi = vec[j+1]-vec[j];
  }
  int b;
  b = k - vec[n-1] + vec[0];
  if(b > maxi) maxi = b;
  cout << k - maxi << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;
int main() {
 int N,D;
 cin>>N>>D;
 int X[N][D];
 for(int i=0;i<N;i++){
     for(int j=0;j<D;j++){
         cin>>X[i][j];
     }
 } 
 int count=0;
 for(int i=0;i<N;i++){
    for(int k=i+1;k<N;k++){
      int sum=0;
     for(int j=0;j<D;j++){
      int T=X[i][j]-X[k][j];
      sum+=T*T;
     }
     int q=sqrt(sum);
     if(q*q==sum){count++;}
 }
 }
 cout<<count<<endl;
 return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define PB push_back
#define MP make_pair
#define S second
#define F first
//#define D cout<<"*\n";
#define fast ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define mod 1000000007 
const double pi = 3.14159265358979323846; 

int dp[100005][4];
int solve(int act[][3],int n,int pd)
{
	
	if(n==0)
	return 0;
	
	int &ans=dp[n][pd];
	if(ans!=-1)
	return ans;
	
	int mx=0;
	for(int i=0;i<3;i++)
	{
		if(i!=pd)
		{
			mx=max(mx,solve(act,n-1,i)+act[n-1][i]);
		}
	}
	ans=mx;
	return mx;
}

signed main()
{
    fast
    int t=1;
   // cin>>t;
    
    while(t--)
    {
      int n;
      cin>>n;
      memset(dp,-1,sizeof(dp));
      int act[n][3];
      
      for(int i=0;i<n;i++)
      {
      	cin>>act[i][0]>>act[i][1]>>act[i][2];
	  }
	  int r1=solve(act,n,0);
	  memset(dp,-1,sizeof(dp));
	  int r2=solve(act,n,1);
	  memset(dp,-1,sizeof(dp));
	  int r3=solve(act,n,2);
	  
	  cout<<max(r1,max(r2,r3));
    }
	return 0;
}

	

Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N , i ;
    cin>>N;
    vector < int > A(N);
    for(i=0;i<N;++i)cin>>A[i];
    sort(A.begin(),A.end());
    int to = *A.rbegin()/2;
    to = ceil(*A.rbegin()/2.);

    bool flag = 1;
    for(i=*A.rbegin();i>to;--i)
        if(upper_bound(A.begin(),A.end(),i) - lower_bound(A.begin(),A.end(),i)<2)
            flag = 0;

    if(*(A.rbegin()) % 2==0)
    {
        if(upper_bound(A.begin(),A.end(),i) - lower_bound(A.begin(),A.end(),i)!=1)
            flag =  0;
    }
    else
    {
        if(upper_bound(A.begin(),A.end(),i) - lower_bound(A.begin(),A.end(),i)!=2)
            flag =  0;
    }

    if(A[0] < to)
        flag = 0;

    puts(flag?"Possible":"Impossible");
    return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC080A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, a, b, x;
            var word = Console.ReadLine().Split(' ');
            n = int.Parse(word[0]);
            a = int.Parse(word[1]);
            b = int.Parse(word[2]);
            if (n * a <= b)
                x = n * a;
            else
              x = b;
            Console.WriteLine(x);
            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 13140
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T>
using Tree =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;  // check the limits, dummy

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

  vector<int> A(N + 1);
  F0R(i, N + 1) cin >> A[i];

  vector<int> B(N);
  F0R(i, N) { cin >> B.at(i); }

  ll ans = 0;

  F0R(i, N) {
    ll V = min(A[i], B[i]);
    A[i] -= V;
    B[i] -= V;
    ans += V;
    V = min(A[i + 1], B[i]);
    A[i + 1] -= V;
    B[i] -= V;
    ans += V;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
int main() {
	float N;
	N = 100020;
	int Q;
	cin >> Q;
	vector<float> s(N+20,1);
	s[1] = 0;
	s[0] = 0;
	for (int i = 2; i < N + 1; i++) {
		if (s[i] == 1) {
			for (int j = i + i; j < N + 1; j = j + i) {
				s[j] = 0;
			}
		}
	}
	
	vector<int> neko(N + 20, 0);
	for (int i = 1; i < N + 1; i = i + 2) {
		if (s[i] == 1) {
			if (s[(i + 1) / 2] == 1) {
				neko[i] = 1;
			}
		}
	}
	vector<int> ruiseki;
	ruiseki.push_back(0);
	for (int i = 0; i < N + 1; i++) {
		ruiseki.push_back(ruiseki[i] + neko[i]);
	}
	int cnt = 0;
	vector<pair<int, int>> saikou;
	for (int i = 0; i < Q; i++) {
		int a, b;
		cin >> a >> b;
		pair<int, int> key;
		key.first = a;
		key.second = b;
		saikou.push_back(key);
	}
	for (int i = 0; i < Q; i++) {
		pair<int, int> si;
		si = saikou[i];
		int a = si.first;
		int b = si.second;
		cnt = cnt + ruiseki[b + 1] - ruiseki[a];
		cout << cnt << endl;
		cnt = 0;
	}
}

Measured memory_bytes: 2676