akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":"\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template<class T>bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template<class T>bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

int sum[105][105][105];
signed main() {
    int n,K;
    cin>>n>>K;
    vector<vector<int>> p(n);
    map<int,int> idx_x,idx_y,idx_z;
    map<int,int> xdi_x,xdi_y,xdi_z;
    REP(i,n) {
        int x1,y1,z1,x2,y2,z2;
        cin>>x1>>y1>>z1>>x2>>y2>>z2;
        p[i]={x1,y1,z1,x2,y2,z2};
        idx_x[x1]=idx_x[x2]=idx_y[y1]=idx_y[y2]=idx_z[z1]=idx_z[z2]=0;
    }
    int cnt=0;
    FORE(x,idx_x) x.second=cnt++, xdi_x[x.second]=x.first;
    cnt=0;
    FORE(y,idx_y) y.second=cnt++, xdi_y[y.second]=y.first;
    cnt=0;
    FORE(z,idx_z) z.second=cnt++, xdi_z[z.second]=z.first;

    REP(i,n) {
        int x1=idx_x[p[i][0]];
        int y1=idx_y[p[i][1]];
        int z1=idx_z[p[i][2]];
        int x2=idx_x[p[i][3]];
        int y2=idx_y[p[i][4]];
        int z2=idx_z[p[i][5]];
        REPF(x,x1,x2) {
            REPF(y,y1,y2) {
                REPF(z,z1,z2) {
                    sum[x][y][z]++;
                }
            }
        }
    }

    int ans=0;
    REP(i,104) {
        REP(j,104) {
            REP(k,104) {
                if(sum[i][j][k]>=K) {
                    ans+=(xdi_x[i+1]-xdi_x[i])*(xdi_y[j+1]-xdi_y[j])*(xdi_z[k+1]-xdi_z[k]);
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int count=0;
  int N;
  cin>>N;
  for(int i=1;i<N+1;i++){
    if((int(log10(i))+1)%2){
      count++;
    }
  }
  cout<<count;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#define inf 0x7fffffff
using namespace std;
typedef long long ll;
const int MAXN=1e5+10;
const int MAX=1e5+10;
const double eps=1e-6;



int main(){
    #ifdef ONLINE_JUDGE
    #else
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    #endif
 	
    string s;
    int juge=0;
    cin>>s;
    for(int i=0;i<s.size();i++){
    	if(s[i]=='A'){
    		if(i+1<s.size()&&s[i+1]=='C')
    			juge=1;
    	}
    }
    if(juge)
    	cout<<"Yes"<<endl;
    else
    	cout<<"No"<<endl;

    return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int w,a,b,s;
int xa1,xa2,ya1,ya2;
int main(){
	scanf("%d%d%d",&w,&a,&b);
	xa1 = a;
	xa2 = a+w;
	ya1 = b;
	ya2 = b+w;
	if((xa1>=ya1&&xa1<=ya2) || (xa2>=ya1&&xa2<=ya2)){
		printf("0");
		return 0;
	}
	s = min(abs(xa1-ya2),abs(xa2-ya1));
	printf("%d",s);
}

Measured memory_bytes: 256
function main(input) {
  	'use strict'
	let arr = input.split(" ");
  	let H = arr[0]
    const A = arr[1]
	let flg = true;
  	let indx = 0;
    while (flg){
      H -= A
      indx ++;
      if(H <= 0){
      	flg = false;
      }
    }
    console.log(indx)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
N, M = map(int, input().split())
L = [0]*(N*2)
for i in range(M):
    a, l = map(int, input().split())
    for ll in range(a, a+l):
        L[ll] = 1

for i in range(N, 2*N):
    L[i-N] = max(L[i-N], L[i])

#print(L)
left = 0
i = 0
while L[i]==1:
    left += 1
    i += 1
    if i==N:
        print(N, 1)
        exit()

A = []
s = 0
#p = 0
for i in range(i, N):
    li = L[i]
    if li==0:
        if s!=0:
            A.append(s)
        s = 0
    else:
        s += 1

#print(A, left, s)
if s+left != 0:
    A.append(s+left)
A.sort(reverse=True)

v = A[0]
n = 0
for a in A:
    if a==v:
        n+=1
    else:
        print(v, n)
        n = 1
        v = a
print(v, n)



Measured memory_bytes: 5612
import math
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
A=[]
B=[]
a=0
b=0
for i in range(1,n+1):
  A.append(i)
  B.append(i)
for i in range(n):
  a=a+A.index(p[i])*math.factorial(n-i-1)
  A.remove(p[i])
for i in range(n):
  b=b+B.index(q[i])*math.factorial(n-i-1)
  B.remove(q[i])
print(abs(a-b))

Measured memory_bytes: 3064
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  int N; std::cin >> N;
  std::vector<int> d(N);
  for (int i = 0; i < N; ++i) std::cin >> d[i];

  int sum = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      sum += d[i]*d[j];
    }
  }
  std::cout << sum << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;

#define INF 999999999

int in[200001], ma[200001], mi[200001];

int main(){
	int n;
	cin >> n;
	
	for(int i=0; i<n; i++) cin >> in[i];
	mi[0] = in[0];
	for(int j=1; j<n; j++) mi[j] = min(mi[j-1], in[j]);
	ma[n-1] = in[n-1];
	for(int k=n-2; k>=0; k--) ma[k] = max(ma[k+1], in[k]);
	int ans=-1000000000;
	for(int x=1; x<n;x++) if(ans < ma[x] - mi[x-1]) ans = ma[x] - mi[x-1];
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3504
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		int a = Integer.parseInt(input[0]);
		int b = Integer.parseInt(input[1]);
		int c = Integer.parseInt(input[2]);
		
		if(c>=a && c<=b)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}





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

using namespace std;

#define reps(i, n, m) for (int i = (int) (n); i < (int) (m); i++)
#define rep(i, n) reps(i, 0, (n))
#define all(v) (v).begin(), (v).end()

const int inf = 1e9 + 3e8;
int main() {
    int n, W; cin >> n >> W;
    vector<int> w(n), v(n);
    rep(i, n) cin >> v[i] >> w[i];
    vector<int> dp(n*100+1, inf);
    dp[0] = 0;
    int res = 0;
    rep(i, n) {
        for (int j = dp.size() - 1; j >= v[i]; j--) {
            dp[j] = min(dp[j], dp[j-v[i]] + w[i]);
            if (dp[j] <= W) res = max(res, j);
        }
    }
    cout << res << endl;
}


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

ll mod=10007;

ll i,j,k,l;
int main(){
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;//a:red  b:green  c:no_color
    //x:aのうち食べる個数　y:bのうち食べる個数
    priority_queue<ll> r;
    vector<ll> p(a),q(b);
    vector<ll> number;

    ll rnum;
    for(i=0;i<a;i++){cin>>p[i];}//p,q
    for(i=0;i<b;i++){cin>>q[i];}
    for(i=0;i<c;i++){cin>>rnum;r.push(rnum);}

    sort(p.begin(),p.end(),greater<ll>());//p,q sort
    sort(q.begin(),q.end(),greater<ll>());
    
    //とりあえず大きいものからnumberに入れる
    for(i=0;i<x;i++){
        number.push_back(p[i]);
    }
    for(i=0;i<y;i++){
        number.push_back(q[i]);
    }

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

    i=0;
    ll ins;//無色のもののうちnumberより大きいものが有れば無色を採用
    while(r.top()>number[i] && r.size()!=0){
        number[i]=r.top();
        r.pop();
        i++;
    }

    ll ans=0;
    for(i=0;i<number.size();i++){
        ans+=number[i];
    }

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

Measured memory_bytes: 4724
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct Road {
    int a, b;
    int dist;

    bool operator < (const Road &other) const {
        return dist < other.dist;
    }
};

int getroot(int i, vector<int> &roots) {
    if(roots[i] == i) return i;
    return roots[i] = getroot(roots[i], roots);
}

void unite(int i, int j, vector<int> &roots) {
    roots[getroot(i, roots)] = getroot(j, roots);
}

int main() {
    while(true) {
        int N, M;
        cin >> N;
        if(!N) break;
        cin >> M;

        vector<Road> roads(M);
        char comma;
        for(int i = 0; i < M; ++i) 
            cin >> roads[i].a >> comma >> roads[i].b >> comma >> roads[i].dist;
        sort(roads.begin(), roads.end());

        int ans = 0;
        vector<int> roots(N);
        for(int i = 0; i < N; ++i) roots[i] = i;
        for(int i = 0; i < M; ++i) {
            const Road &r = roads[i];
            if(getroot(r.a, roots) == getroot(r.b, roots)) continue;
            unite(r.a, r.b, roots);
            ans += r.dist/100 - 1;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
using namespace std;
#define R 1000000007	
int main() {
	int N, M;
	long long int ans;
	long long int a = 1;
	long long int b = 1;
	scanf("%d%d",&N,&M);
	bool nTurn = true;
	int curN = N;
	int curM = M;
	for (int i = 0; i < (N + M); i++) {
		if (nTurn) {
			if (curN == 0) {
				a = 0;
				break;
			}
			a *= (curN);
			a %= R;
			curN--;
			nTurn = !nTurn;
		}
		else {
			if (curM == 0) {
				a = 0;
				break;
			}
			a *= (curM);
			a %= R;
			curM--;
			nTurn = ~nTurn;
		}
	}
	nTurn = false;
	curN = N;
	curM = M;
	for (int i = 0; i < (N + M); i++) {
		if (nTurn) {
			if (curN == 0) {
				b = 0;
				break;
			}
			b *= (curN);
			b %= R;
			curN--;
			nTurn = !nTurn;
		}
		else {
			if (curM == 0) {
				b = 0;
				break;
			}
			b *= (curM);
			b %= R;
			curM--;
			nTurn = ~nTurn;
		}
	}
	printf("%d", (a+b)%R);
	return 0;
}

Measured memory_bytes: 128
import math

S=input()
T=input()
ans=0
#print("ans="+str(ans))

for i in range(len(S)-len(T)+1):
    tmp=0
    for j in range(len(T)):
        #print("i="+str(i)+"\tj="+str(j)+"\tT[j]="+T[j]+"\tS[i+j]"+S[i+j])
        if T[j]==S[i+j]:
            tmp+=1
    if ans<tmp:
        ans=tmp
print(len(T)-ans)

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

using namespace std;

int main(){
  int a;
  string inStr,tmpStr;
  cin >> a;
  cin >> inStr;
  //入力文字列の半分をコピー
  a=a/2;
  tmpStr=inStr.substr(0,a);
  //繰り返す
  tmpStr+=tmpStr;
  //
  if(inStr==tmpStr){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define ll long long

ll n, m, d;
int main(){
    scanf("%lld%lld%lld",&n, &m, &d);
    double P = d==0?(double)1/n:(double)(2 * (n - d))/(n*n);
    //printf("%lf ", P);
    double ans = 0;
    for (ll i = 0;(1<<i)<=(m-1);i++){
        if((m-1)&(1<<i)){
            ans += P;
        }
        //printf("%lld ",i);
        P *= 2;
    }
    printf("%3.8lf", ans);
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

typedef long long ll;

const int mod = 1e9 + 7;
const int N = 2100;
ll dp[N];

int main()
{
    ll n;
    cin>>n;
    for(int i=3; i<=n; i++)
    {
    	dp[i] = 1;
    	for(int j=3; i-j>=3; j++)
    	{
    		dp[i] = (dp[i] + dp[i-j]) % mod;
		}
	}
    	
    		
    cout<<dp[n];
	return 0;
}

Measured memory_bytes: 3600
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include<numeric>

using namespace std;

int main() {
     int N,K;
    double a,ans=0;
    cin>>N>>K;
    for(int i=1;i<N+1;i++){
        a=1.0/N;
        if(i>=K)ans=ans+(double)1/N;
        else{
            for(int k=1;k*i<K;k=k*2){
                a=a/2;
            }
            ans=ans+a;
        }

    }
    cout<<setprecision(11)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define rep(i,n)for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int h,w;
	while(cin >> h >> w)
	{
		if(h == 0 && w == 0) break;

		rep(i,h)
		{
			rep(j,w)
			{
				if(i%2 == 0)
				{
					if(j%2 == 0)
					{
						cout << "#";
					}
					else
					{
						cout << ".";
					}
				}
				else
				{
					if(j%2 == 0)
					{
						cout << ".";
					}
					else
					{
						cout << "#";
					}
				}
			}
			cout << endl;
		}
		cout  << endl;
	}
	return 0;
}

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

using namespace std;

void solve(int X, int Y, int n, int m, vector<int> N, vector<int> M){
    int flag1=0;
    int flag2=0;
    for(int Z=X+1; Z<Y+1; Z++){
        flag1=0;
        for(int i=0; i<N.size(); i++){
            if(N[i]>=Z){
                flag1++;
                break;
            }
        }
        for(int i=0; i<M.size(); i++){
            if(Z>M[i]){
                flag1++;
                break;
            }
        }
        if(flag1==0) {
            cout << "No War" << endl;
            flag2++;
            break;
        }
    }
    if(flag2==0)cout<<"War"<<endl;
}

int main(){
    int tmp;
    int n, m, X, Y;
    vector<int> N, M;

    cin>>n>>m>>X>>Y;
    for(int i=0; i<n; i++){
        cin>>tmp;
        N.push_back(tmp);
    }

    for(int i=0; i<m; i++){
        cin>>tmp;
        M.push_back(tmp);
    }

    solve(X, Y, n, m, N, M);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}


//#########################################



int main() {
 int a=D();
 cout<<(48)-(a);




}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static long bignum = 1000000000+7;

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[m];
		int[] b =new int[m];


		ArrayList<Integer>[] pointers = new ArrayList[n+1];
		for(int i =0;i<n+1;i++) {
			pointers[i]=new ArrayList<Integer>();
		}

		for(int i =0;i<m;i++) {
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
			pointers[a[i]].add(b[i]);
			pointers[b[i]].add(a[i]);
		}


		int[] times = new int[n+1];
		int[] path = new int[n+1];

		for(int i =0;i<n+1;i++) {
			times[i]=100000;
			path[i]=0;
		}
		times[1]=0;
		path[1]=1;

		ArrayList<Integer> subject = new ArrayList<Integer>();
		subject.add(1);

		while(subject.size()>0) {
			ArrayList<Integer> ns = new ArrayList<Integer>();
			for(int i=0;i<subject.size();i++) {
				for(int j=0;j<pointers[subject.get(i)].size();j++) {
					int g = pointers[subject.get(i)].get(j);
					if(times[g]>1+times[subject.get(i)]) {
						times[g]=1+times[subject.get(i)];
						path[g]=subject.get(i);
						ns.add(g);
					}
				}
			}
			subject = ns;
		}


		System.out.println("Yes");
		for(int i=2;i<n+1;i++) {

			System.out.println(path[i]);
		}

	}


	static long divn(int target, int times) {//10_9+7のあまり累乗版
		int sqtimes = (int)Math.sqrt(times);
		long ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		long holder = ans;
		ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans*holder)%(1000000000+7);
		}
		for(int i=0;i<times - sqtimes*sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		return ans;
	}

	static long div(long a) {//10_9+7のあまり
		if(a<0)a+=1000000000+7;
		return a%(1000000000+7);
	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 78032
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		int[]a = new int[7];
		a[0] = 1;
		for(int i = 1; i < 7; i++) {
			a[i] = a[i - 1] * 2;
		}
		for(int i = 0; i < 7; i++) {
			if(N == a[i]) {
				System.out.println(N);
				System.exit(0);
			}else if(N < a[i]) {
				System.out.println(a[i - 1]);
				System.exit(0);
			}
		}
		System.out.println(a[6]);
	}
}

Measured memory_bytes: 23124
N,D,A = map(int,input().split())
X = []
for _ in range(N):
    x,h = map(int,input().split())
    X.append([x,h])
X.sort()
if X[-1][0] - X[0][0] < 2 * D:
    ans = 0 
    max = 0
    for i in range(N):
        if X[i][1] > max:
            max = X[i][1]
    if max % A == 0:
        ans = max // A
    else:
        ans = max // A + 1
else:
    ans = 0
    for i in range(N):
        h = int(X[i][1])
        if h != 0:
            x = int(X[i][0])
            if h % A == 0:
                count = h // A
            else:
                count = h // A + 1
            ans += count
            dmg = A * count
    #print(ans,dmg)
            for j in range(i+1,N):
                x2 = int(X[j][0])
                h2 = int(X[j][1])
                if  x + (2 * D) < x2:
                    break
                else:
                    X[j][1] = max(0,h2-dmg)
                    #print(X[j])
print(ans)

Measured memory_bytes: 76504
sx,sy,tx,ty=map(int,input().split())
x=tx-sx
y=ty-sy
print("U"*y+"R"*x+"D"*y+"L"*(x+1)+"U"*(y+1)+"R"*(x+1)+"DR"+"D"*(y+1)+"L"*(x+1)+"U")

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>

using namespace std;

class RSQuery
{
public:
  int solve();
  void updateST( vector<int> &st, int ix );
  int getSum( vector<int> &st, int x, int y , int ix, int l, int r );
};

void RSQuery::updateST( vector<int> &st, int ix )
{
  if ( ix == 0 ) return;
  int p = (ix - 1) / 2;
  
  while ( true )
    {
      st[p] = st[2 * p + 1] + st[2 * p + 2];
      if ( p == 0 ) break;
      p = (p - 1) / 2;
    }

  return;
}

int RSQuery::getSum( vector<int> &st, int x, int y , int ix, int l, int r )
{
  if ( r <= x || y <= l ) return 0;
  if ( x <= l && r <= y )
    return st[ix];
  else
    return getSum( st, x, y, 2 * ix + 1, l, (l + r) / 2 ) + getSum(st, x, y, 2 * ix + 2, (l + r) / 2, r );
  return 0;
}

int RSQuery::solve()
{

  int n, q, mn;

  cin >> n >> q;

  for ( mn = 1; mn < n; mn *= 2 );

  vector<int> st( 2 * mn , 0 );

  for ( auto i = 0; i < q; ++i )
    {
      int com, x, y;
      cin >> com >> x >> y;
      if ( com == 0 )
        {
          st[ mn - 2 + x ] += y;
          updateST( st, mn - 2 + x );
        }
      else
        cout << getSum( st, x - 1, y, 0, 0, mn ) << endl;
    }

  return 0;
}

int main()
{
  RSQuery rsq;

  rsq.solve();

  return 0;
}

Measured memory_bytes: 2056
//標準入力をするときに記述する必要がある
process.stdin.resume();
process.stdin.setEncoding("utf8");

let line_input; //標準入力代入用に宣言
let lines = []; //複数行入力用
let reader = require("readline").createInterface({
    input: process.stdin,
    output: process.stdout
});

//入力, 文字列で受け渡される
reader.on("line", (line) => {
    //line_input = parseInt(line) //単行入力
    let column = line.split(" ");
    let int_column = [];
    for (let i = 0; i < 2; i++){
        int_column.push(parseInt(column[i]))
    }
    lines.push(int_column)
});

//出力
reader.on("close", () => {
    let count = 0;
    for (let i=1; i < lines.length; i++){
        if (Math.pow(lines[i][0], 2) + Math.pow(lines[i][1], 2) <= Math.pow(lines[0][1], 2)){
            count += 1;
        }
    }
    console.log(count)
})

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

int main()
{
  int N, M; cin >> N >> M;
  vector<int> A(M);
  rep(i,M) cin >> A[i];
  
  int sum = 0;
  rep(i,M) sum += A[i];
  if(sum <= N) cout << N-sum << endl;
  else cout << "-1" << endl;
}


Measured memory_bytes: 3652
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 100005;

int n, i, res[N], l, r, ind;
char t[10];

int main() {
scanf("%d", &n);
for (i=0;i<n;i++) res[i] = -1;
printf("0\n");
fflush(stdout);
scanf("%s", t);
if (t[0] == 'V') {
	return 0;
}
res[0] = res[n] = (t[0] == 'M');
l = 0;
r = n;
while (true) {
	ind = (l + r) / 2;
	printf("%d\n", ind);
	fflush(stdout);
	scanf("%s", t);
	if (t[0] == 'V') {
		return 0;
	}
	res[ind] = (t[0] == 'M');
	if ((ind - l) % 2 == 0 && res[ind] != res[l]) r = ind;
	else if ((ind - l) % 2 == 1 && res[ind] == res[l]) r = ind;
	else l = ind;	
}
return 0;
}



Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define debug(x) cout << #x << " = " << x << endl
#define print(x) cout << x << endl;
const ll MOD = 1000000007;

vector<vector<char>> maze;
vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};

struct node
{
    int x, y;
    node(int _x, int _y)
    {
        x = _x;
        y = _y;
    }
};

int H, W;

int bfs(queue<node> q, vector<vector<int>> shortest_move, int max_count)
{
    while (!q.empty())
    {
        node now = q.front();
        q.pop();

        // Update max count
        if (shortest_move[now.x][now.y] > max_count)
        {
            max_count = shortest_move[now.x][now.y];
        }

        // Next nodes
        for (int i : {0, 1, 2, 3})
        {
            int x = now.x + dx[i];
            int y = now.y + dy[i];

            bool cond1 = 0 <= x && x < H;
            bool cond2 = 0 <= y && y < W;

            if (cond1 && cond2 && maze[x][y] == '.' && shortest_move[x][y] == -1)
            {
                shortest_move[x][y] = shortest_move[now.x][now.y] + 1;
                q.push(node(x, y));
            }
        }
    }

    return max_count;
}

int main()
{
    cin >> H >> W;

    // init
    rep(i, H)
    {
        maze.push_back({});
        rep(j, W)
        {
            char temp;
            cin >> temp;
            maze[i].push_back(temp);
        }
    }

    int ans = -1;
    rep(i, H)
    {
        rep(j, W)
        {
            node start = node(i, j);
            if (maze[start.x][start.y] == '.')
            {

                // init maze
                queue<node> q;
                q.push(start);
                vector<vector<int>> shortest_move(H, vector<int>(W, -1));
                shortest_move[start.x][start.y] = 0;

                // get shortest move to all node
                int max_count = bfs(q, shortest_move, 0);

                // upate
                if (max_count > ans)
                {
                    ans = max_count;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef long int li;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    ll ans=0;
    ll a[5];
    for(int i=0;i<5;i++)cin >> a[i];
    ll x=0;
     for(int i=0;i<5;i++){
        x=max((a[i]%10),x);
    }
    for(int i=0;i<5;i++){
        if((a[i]%10)!=0)x=min((a[i]%10),x);
    }
    for(int i=0;i<5;i++){
        if(a[i]%10!=0)a[i]=(10-(a[i]%10))+a[i];
    }
    for(int i=0;i<5;i++){
        ans+=a[i];
    }
	if(x==0)cout << ans << endl;
      else cout << ans-10+x << endl;
    return 0;
}



Measured memory_bytes: 256
S = input()

ACGT = "ACGT"

i = 0

result = 0

while i < len(S):
    while i < len(S) and S[i] not in ACGT:
        i += 1
    st = i
    while i < len(S) and S[i] in ACGT:
        i += 1
    result = max(result, i - st)

print(result)



Measured memory_bytes: 2940
import sys
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def main():
    N = int(input())
    A = inpl()
    Api = [a + i + 1 for i, a in enumerate(A)]
    Ami = [i + 1 - a for i, a in enumerate(A)]
    Api.sort()
    Ami.sort()
    # print(Api)
    # print(Ami)
    ans = 0
    for a in Api:
        ans += bisect_right(Ami, a) - bisect_left(Ami, a)
    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 33256
def gcd(x,y):
	while y:
		x,y = y,x % y
	return x


a,b,c,d = map(int,input().split())
ans = 0

cd = c * d // gcd(c,d)

if a%c == 0:
	start_c = a
else:
	start_c = a + c - a % c
if a%d == 0:
	start_d = a
else:
	start_d = a + d - a % d
if a%cd == 0:
	start_cd = a
else:
	start_cd = a + cd - a % cd

end_c = b - b % c
end_d = b - b % d
end_cd = b - b % cd

if b >= c:
	ans += (end_c - start_c) // c + 1
if b >= d:
	ans += (end_d - start_d) // d + 1
if b >= cd:
	ans -= (end_cd - start_cd) // cd + 1

print(b-a+1-ans)


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

const int N=2e6+5;
int n,GCD;
int a[N];
bool jay;
bool f[N];

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

int main(){
	scanf("%d",&n);
	for (register int i=1; i<=n; ++i) scanf("%d",&a[i]);
	
	jay=true;
	for (register int i=1; i<=n; ++i)
	{
		int x=a[i];
		for (register int j=2; j*j<=x; ++j)
		if (x%j==0)
		{
			if (f[j]) {jay=false; break;}
			while (x%j==0) x/=j;
			f[j]=true;
		}
		if (x>1) 
		{
			if (f[x]) jay=false;
			f[x]=true;
		}
		if (!jay) break;
	}
	if (jay) {puts("pairwise coprime"); return 0;}
	
	GCD=a[1];
	for (register int i=2; i<=n; ++i)
	{
		GCD=gcd(GCD,a[i]);	
	}
	if (GCD==1) {puts("setwise coprime"); return 0;}
	puts("not coprime");
return 0;	
}

Measured memory_bytes: 7528
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<numeric>

using namespace std;

int main(){ 
    int x, n, m;
    vector<int> vec;
    cin >> x;

    n = x / 500;
    m = (x % 500) / 5;
    cout << 1000 * n + m * 5 << endl;
}


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


int main(){
    int N;
    cin >> N;
    bool flag = false;
    for(int i=0;i<=N/4;++i){
        for(int j=0;j<=N/4;++j){
            if(4*i+7*j==N) flag = true;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define endl "\n" 
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  vector<double> a(n);
  double sum = 0;
  for(int i=0; i < n; ++i) {
    cin >> a[i];
    sum += a[i];
  }
  double ninki = sum/(4*m);
  sort(a.rbegin(), a.rend());
  int cnt = 0;
  for(int i=0; i < n; ++i) {
    if(a[i] >= ninki) {
      cnt++;
      if(cnt == m) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;


  return 0;
}


Measured memory_bytes: 256
A,B = map(int,input().split())

cnt = 0
for i in range(A,B+1):
  s = str(i)
  half = len(s) // 2
  add = len(s) % 2
  #print(s,-1, s[0:half],-1, s[half+add:][::-1])
  if s[0:half] == s[half+add:][::-1]:
    cnt += 1
    
print(cnt)

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

int main()
{
    ll n;
    cin>>n;
    vector<ll>v;
    for(int i = 0 ; i < n ; i++)
    {
        ll temp;
        cin>>temp;
        v.push_back(temp);
    }
    ll x = v[0]^v[1];
    for(int i = 2 ; i < n ; i++)
        x = x ^ v[i];
    for(int i = 0 ; i < n ; i++)
        cout<<(x ^ v[i])<<" ";
    return 0;
}

Measured memory_bytes: 5248
#include <map>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define met(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
typedef long long ll;

int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
}

Measured memory_bytes: 256
n = int(input())
a_list = list(map(int,input().split()))
f_denied = 0

for i in range(n):
    if a_list[i] % 2 == 0:
        # 偶数
        if a_list[i] % 3 != 0 and a_list[i] % 5 != 0:
            f_denied = f_denied + 1

if f_denied != 0:
    print("DENIED")
else:
    print("APPROVED")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cmath>
#include <cassert>
using namespace std;

int main(){
    long long L, R;
    cin >> L >> R;
    long long ans = 2019;
    for(long long i=L; i<=min(L+2019, R); i++){
        for(long long j=i+1; j<=min(L+2019, R); j++){
            ans = min(ans, (i*j)%2019);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

string decode(string s, char m) {
	switch(m) {
		case 'J':
			return s[$-1] ~ s[0..$-1];
		case 'C':
			return s[1..$] ~ s[0];
		case 'E':
			return s[($+1)/2..$] ~ s[$/2..($+1)/2] ~ s[0..$/2];
		case 'A':
			return s.dup.reverse.to!string;
		case 'P':
			return s.map!(to!char).map!((char a) {
				if(a == '0') {
					return '9';
				} else if(!digits.find(a).empty) {
					return cast(char)(a-1);
				} else {
					return a;
				}
			}).array;
		case 'M':
			return s.map!(to!char).map!((char a) {
				if(a == '9') {
					return '0';
				} else if(!digits.find(a).empty) {
					return cast(char)(a+1);
				} else {
					return a;
				}
			}).array;
		default:
			return s;
	}
}

void main(){
	auto n = readInt();
	for(int i; i < n; ++i) {
		auto o = readln().chomp();
		auto l = readln().chomp();
		foreach(m; o.dup.reverse){
			l = decode(l, m);
		}
		writeln(l);
	}
}

Measured memory_bytes: 2484
n = int(input())

cells = list(map(int, input().split()))


for i in range(n-1, 0, -1):
  if cells[i] >= cells[i-1]:
    continue
  else:
    cells[i-1] -= 1
    if cells[i] < cells[i-1]:
      print('No')
      break
else:
  print('Yes')



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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

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

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	string S;
	cin>>S;
	int N=S.size();
	int cnt=0;
	rep(i,N){
		int b=S[i]-'0';
		if(i%2==b)cnt++;
	}
	cout<<min(cnt,N-cnt)<<endl;
	return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var tempreture = input[0];
        var average = input[1];
        var heights = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        var min = double.MaxValue;
        var point = 0;
        for (int i = 0; i < n; i++)
        {
            var buf = Conpare(Ave(tempreture, heights[i]), average);
            if (min > buf)
            {
                min = buf;
                point = i + 1;
            }
        }

        Console.WriteLine(point);
    }

    static double Ave(int temp, int height)
    {
        return temp - height * 0.006;
    }

    static double Conpare(double a, double b)
    {
        return Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    }
}

Measured memory_bytes: 13340
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<20)
#define LLINF (1LL<<60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

const int MAX_N=200005;

vector<int> a,ans;
vector<int> to[MAX_N];
int dp[MAX_N];

void dfs(int v,int p=-1){
    int i=lower_bound(dp,dp+MAX_N,a[v])-dp;
    int old=dp[i];
    dp[i]=a[v];
    ans[v]=i;
    if(p!=-1)ans[v]=max(ans[v],ans[p]);
    for(int u:to[v]){
        if(u==p)continue;
        dfs(u,v);
    }
    dp[i]=old;
}

int main(){
    int n;
    cin>>n;
    a=ans=vector<int>(n);
    rep(i,n) cin>>a[i];
    rep(i,n-1){
        int u,v;
        cin>>u>>v;
        --u;--v;
        to[v].pb(u);
        to[u].pb(v);
    }
    rep(i,MAX_N)dp[i]=1001001001;
    dp[0]=-1001001001;
    dfs(0);
    rep(i,n)cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 30808
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<vector>
#include<ctime>
#define ll long long
#define pr(x) cerr<<#x<<"="<<x<<endl
using namespace std;
struct node
{
	int l,r;
}b[5100000];
bool cmp(node x,node y)
{
	if (x.r==y.r) return x.l<y.l;
	return x.r<y.r;
}
int n,i,cnt,a[510000],nowl,nowr,tot,now,dp[510000];
char ch[510000];
int main()
{
	scanf("%d",&n);
	scanf("%s",ch);
	for (i=1;i<=n;i++) a[i]=ch[i-1]-'0';
	i=2;
	a[0]=a[n+1]=-1;
	while (i<n)
	{
		if (a[i-1]==1&&a[i]==0&&a[i+1]==1)
		{
			now=i;
			i=i+1;
			while (a[i]==1) 
			{
				b[++cnt].l=now-1;
				b[cnt].r=i;
				i++;
			}
		}
		else i++;
	}
	i=n-1;
	while (i>1)
	{
		if (a[i+1]==1&&a[i]==0&&a[i-1]==1)
		{
			now=i;
			i=i-1;
			while (a[i]==1) 
			{
				b[++cnt].r=now+1;
				b[cnt].l=i;
				i--;
			}
		}
		else i--;
	}
	sort(b+1,b+1+cnt,cmp);
	//for (i=1;i<=cnt;i++) printf("%d %d\n",b[i].l,b[i].r);
	//cout<<endl;
	for (i=1;i<=cnt;i++)
	{
		if (nowl!=b[i].l||nowr!=b[i].r) 
		{
			b[++tot]=b[i];
			nowl=b[i].l;
			nowr=b[i].r;
		}
	}
	//for (i=1;i<=tot;i++) printf("%d %d\n",b[i].l,b[i].r);
	now=1;
	for (i=1;i<=n;i++)
	{
		dp[i]=max(dp[i],dp[i-1]);
		while (b[now].r==i)
		{
			dp[i]=max(dp[i],dp[b[now].l-1]+b[now].r-b[now].l-1);
			now++;
		}
	}
	//for (i=1;i<=n;i++) printf("dp[%d]=%d\n",i,dp[i]);
	printf("%d\n",dp[n]);
	return 0;
}

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

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

    int ans = N;
    
    // N を次のように二つに分けて全探索
    // 6^p (p > 0) (と 1 )で割る数を i ,
    // 9^p (p > 0) (と 1 )で割る数を N - i とし、
    // その和が最小になる i を求める 
    for(int i = 0; i <= N; i++ )
    {
        int cc = 0;
        int tmp  = i;
        while( tmp > 0 ){
            cc += tmp % 6; // 例えば最初は 6 で割る回数に相当する
            tmp /= 6;
        }
        tmp = N - i;
        while( tmp > 0 ){
            cc += tmp % 9;
            tmp /= 9;
        }
        ans = min( ans, cc );
    } 

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, W, *wv = map(int, read().split())

    w0 = wv[0]
    weight = [[] for _ in range(4)]
    for w, v in zip(*[iter(wv)] * 2):
        weight[w - w0].append(v)

    for i in range(4):
        weight[i].sort(reverse=True)

    csum = [[0] for _ in range(4)]
    for i in range(4):
        csum[i].extend(accumulate(weight[i]))

    def dfs(w, v, idx):
        if idx == 4:
            return v

        ans = 0
        for i in range(len(csum[idx])):
            if w + (w0 + idx) * i > W:
                break
            ans = max(ans, dfs(w + (w0 + idx) * i, v + csum[idx][i], idx + 1))

        return ans

    print(dfs(0, 0, 0))

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 74032
import java.util.*;

public class Main {
    public static void main(String[] args) {
        int N;
        int M;
        int[] waCnt=null;
        boolean[] acFlg = null;

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            M = sc.nextInt();
            waCnt = new int[N];
            acFlg = new boolean[N];

            for (int i = 0; i < M; i++) {
                int num = sc.nextInt();
                String rcwa = sc.next();
                if(acFlg[num-1]){
                    continue;
                }
                if(rcwa.equals("AC")){
                    acFlg[num-1] = true;
                }else{
                    waCnt[num-1]++;
                }
            }
        }
        int acResult = 0;
        int pena = 0;
        for (boolean b : acFlg){
            if(b){
                acResult++;
            }
        }
        for (int i = 0; i < N; i++) {
            if(!acFlg[i]){
                continue;
            }
            pena += waCnt[i];
        }
        System.out.println(acResult+" "+pena);
    }
}


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

int main() {
	int MPlayer;
	int PScore[200][3];
	int AScore[200];
	int SFlag[200][3];
	int i,j,k;

	cin >> MPlayer;

	for (i = 0; i < MPlayer; i++) {
		cin >> PScore[i][0] >> PScore[i][1] >> PScore[i][2];
		AScore[i] = 0;
		SFlag[i][0] = 0;
		SFlag[i][1] = 0;
		SFlag[i][2] = 0;
	}

	for (i = 0; i < 3; i++) {
		for (j = 0; j < MPlayer; j++) {
			for (k = 0; k < MPlayer; k++) {
				if (j != k) {
					if (PScore[j][i] == PScore[k][i]) {
						SFlag[j][i] = 1;
						break;
					}
				}
			}
		}
	}

	for (int k = 0; k < 3; k++) {
		for (j = 0; j < MPlayer; j++) {
			if (SFlag[j][k] == 0) {
				AScore[j] += PScore[j][k];
			}
		}
	}
	

	for (i = 0; i < MPlayer; i++) {
		cout << AScore[i] << endl;
	}
}


Measured memory_bytes: 3084
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	checkDivisor(a, b)
}

func checkDivisor(a, b int) {
	if b%a == 0 {
		fmt.Println(a + b)
	} else {
		fmt.Println(b - a)
	}
}


Measured memory_bytes: 512
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL tb[100010];

int main() {
	LL n, k; cin >> n >> k;

	for (int i = 0; i < n; i++) {
		LL a, b; cin >> a >> b;

		tb[a] += b;
	}

	LL cnt = 0;
	for (int i = 0; i < 100010; i++) {

		cnt += tb[i];

		if (cnt >= k) {
			cout << i << endl;
			return 0;
		}
	}

	
}

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

int main() {
  int N; cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
  }
  
  int ans=0;
  for(int i=1;i<N-1;i++){
   if(min(min(vec.at(i-1),vec.at(i)),vec.at(i+1))
      != vec.at(i)
     && max(max(vec.at(i-1),vec.at(i)),vec.at(i+1))
       != vec.at(i)){
     ans++;
   } 
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import deque
n=int(input())
a=list(map(int,input().split()))
b=deque()
for i in range(n):
    if (i+1)%2==1:
        b.append(a[i])
    else:
        b.appendleft(a[i])
if n%2==1:
    b.reverse()
print(*b)

Measured memory_bytes: 25412
N, K = map(int, input().split())
a = [int(x) for x in input().split()]
mod = 10**9+7
dp = [[0] * (K+1) for i in range(N+1)]
for i in range(K+1):
    dp[0][i] = 1
for i in range(1, N+1):
    for j in range(K+1):
        tmp = 0 if j-a[i-1]-1 < 0 else dp[i-1][j-a[i-1]-1]
        dp[i][j] += dp[i-1][j]-tmp
        dp[i][j] %= mod
    if i != N:
        for j in range(K):
            dp[i][j+1] = (dp[i][j+1]+dp[i][j])%mod
print(dp[N][K])


Measured memory_bytes: 119660
price = [*100..105]
dp = [[*100..105]]
n = gets.to_i
if price.include? n
  p 1
  exit
end
(1..1000).each do |k|
  dp[k] = []
  price.each do |p|
    dp[k-1].each do |d|
      if d+p == n
        p 1
        exit
      end
      dp[k] << d+p
    end
  end
  dp[k].uniq!
end
p 0


Measured memory_bytes: 38004
# AGC 027 A - Candy Distribution Again
n, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
count = 0
for i in range(n):
    if i == n-1:
        if x == a[i]:
            count += 1
        else:
            break
    elif x >= a[i]:
        x -= a[i]
        count += 1
    else:
        break
        
print(count)

Measured memory_bytes: 3064
<?php

fscanf(STDIN, "%d %d %d %d", $a, $b, $h, $m);

$angvelh = (360 * (pi() / 180)) / (12 * 60);
$angvelm = (360 * (pi() / 180)) / 60;

$angh = $angvelh * ($h * 60 + $m);
$angm = $angvelm * $m;

echo sqrt(pow($a, 2) + pow($b, 2) - 2 * $a * $b * cos(abs($angh - $angm)));


Measured memory_bytes: 16384
#include<cstdint>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<iterator>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>
#include<utility>
#include<initializer_list>


#define repi(i,start,end)for(int64_t (i)=(start);(i)<(end);++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x, v) for(auto& (x) : (v))
#define iterate(itr, v) for(auto (itr)=(v).begin();(itr)!=(v).end();++(itr))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vin(v) rep(i,(v).size()) cin >> (v)[i];
#define vpin(v) rep(i,(v).size()) cin >> (v)[i].first >> (v)[i].second

using namespace std;
using pint = tuple<int64_t, int64_t>;
using vint = vector<int64_t>;
using vvint = vector<vint>;
using vpint = vector<pint>;
using vstr = vector<string>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<"\n";}
template<class T>void println(T a){cout << a << "\n";}
template<class T>void put_line(T &v){iterate(itr,v){cout<<*itr<<((itr==--v.end())?"\n":" ");}}
// auto [x, y] = make_tuple(3, 4); => let (x, y) = (3, 4);

int main(void) {
    int s, w; cin >> s >> w;
    if(w >= s) {
        println("unsafe");
    } else {
        println("safe");
    }

    return 0;
}


Measured memory_bytes: 3620
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<algorithm>


using namespace std;
using ll=long long;
using vll=vector<ll>;


ll calc(vll a, ll b)
{
	ll ret=0;

	for(int i=0;i<(int)a.size();i++)
	{
		ret+=llabs(a[i]-(i+b));
	}
	return ret;
}


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vll a(n);
		vll t(n);

		for(int i=0;i<n;i++)
		{
			scanf("%lld", &a[i]);
			t[i]=a[i]-i;
		}
		sort(t.begin(), t.end());
		ll ans_n=calc(a, t[n/2]);
		ll ans_p=calc(a, t[n/2+1]);
		ll ans=min(ans_n, ans_p);
		printf("%lld\n", ans);
	}

	return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  ll n, k;
  cin >> n >> k;

  ll ans = 0;
  ll keta = 1;
  while (keta - 1 < n) {
    ans++;
    keta *= k;
  }

  cout << ans << endl;

  return 0;
}


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

int main()
{
  	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  	
  	const long long mod = 1e9 + 7;
 	long long s;
  	cin >> s;
  	
  	vector<long long> dp(s+1);
  	dp[0] = 1;
  	for(long long i = 3; i <= s; i++)
		for(long long j = i - 3; j >= 0; j--)
          	dp[i] = (dp[i] + dp[j]) % mod;
  
  	cout << dp[s];
}

Measured memory_bytes: 3616