akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
      
      
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] b = new int[n];
		int[] p = new int[m];
		for(int i = 0; i < n; i++) {
			b[i] = sc.nextInt();
		}
		for(int i = 0; i < m; i++) {
			p[i] = sc.nextInt();
		}
		int zeroCount = 0;
		int oneCount  = 0;
		for(int i = 0; i < n; i++) {
			if(b[i] == 1) {
				oneCount++;
			}
			else {
				zeroCount++;
			}
		}
		int ACount = 0;
		int BCount = 0;
		for(int i = 0; i < m; i++) {
			if(i % 2 == 0) {
				ACount += p[i];
			}
			else {
				BCount += p[i];
			}
		}
		int min = Integer.MAX_VALUE;
		
		if(ACount == zeroCount && BCount == oneCount) {
			//StartZero
			int count = 0;
			int[] check = new int[n];
			int id = 0;
			for(int i = 0; i < m; i++) {
				for(int j = 0; j < p[i]; j++) {
					check[id++] = i % 2;
				}
			}
			int[] tmp = Arrays.copyOf(b, b.length);
			for(int i = 0; i < n; i++) {
				if(check[i] != tmp[i]) {
					int target = 0;
					for(int j = i+1; j < n; j++) {
						if(tmp[j] == check[i]) {
							target = j;
							break;
						}
					}
					for(int j = target; j > i; j--) {
						swap(tmp,j,j-1);
						count++;
					}
				}
			}
			min = Math.min(count, min);
		}
		if(ACount == oneCount && BCount == zeroCount) {
			//StartOne
			int count = 0;
			int[] check = new int[n];
			int id = 0;
			for(int i = 0; i < m; i++) {
				for(int j = 0; j < p[i]; j++) {
					check[id++] = (i+1) % 2;
				}
			}
			int[] tmp = Arrays.copyOf(b, b.length);
			for(int i = 0; i < n; i++) {
				if(check[i] != tmp[i]) {
					int target = 0;
					for(int j = i+1; j < n; j++) {
						if(tmp[j] == check[i]) {
							target = j;
							break;
						}
					}
					for(int j = target; j > i; j--) {
						swap(tmp,j,j-1);
						count++;
					}
				}
			}
			min = Math.min(count, min);
		}
		System.out.println(min);
		
		
		
	}
	static void swap(int[] a, int b, int c) {
		int tmp = a[b];
		a[b] = a[c];
		a[c] = tmp;
	}
 }

Measured memory_bytes: 26420
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int left = 0, right = N;
    for (int i = 0; i < M; i++) {
      int l = scanner.nextInt();
      int r = scanner.nextInt();
      if (l > right || r < left) {
        System.out.println(0);
        return;
      }
      if (l > left) left = l;
      if (r < right) right = r;
    }
    System.out.println(right - left + 1);
  }
}


Measured memory_bytes: 63608
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

long long P = 998244353;

class C {
public:
  int n;
  vector<long long> fac, inv, facInv;
  long long power(long long e, long long x) {
    if (x == 0)
      return 1;
    if (x == 1)
      return e;
    if (x % 2 == 0)
      return power((e * e) % P, x / 2);
    return (e * power(e, x - 1)) % P;
  }
  C(int n_) {
    n = n_;
    fac.resize(n + 1);
    inv.resize(n + 1);
    facInv.resize(n + 1);
    fac[1] = 1;
    for (int i = 2; i <= n; i++)
      fac[i] = (i * fac[i - 1]) % P;
    inv[1] = 1;
    for (int i = 2; i <= n; i++)
      inv[i] = power(i, P - 2);
    facInv[1] = 1;
    for (int i = 2; i <= n; i++)
      facInv[i] = (inv[i] * facInv[i - 1]) % P;
  }
  long long comb(int N, int K) {
    if (N == 0 || K == 0 || K == N)
      return 1;
    if (N < K || K < 0 || N < 0)
      return 0;
    return ((fac[N] * facInv[K]) % P * facInv[N - K]) % P;
  }
};

int main() {
  long long n, a, b, k;
  cin >> n >> a >> b >> k;
  C comb(1000000);
  long long ans = 0;
  for (int i = 0; i <= n; i++) {
    long long rest = k - a * i;
    if (rest % b == 0 && rest / b <= n) {
      long long as = i;
      long long bs = rest / b;
      ans = (ans + (comb.comb(n, as) * comb.comb(n, bs)) % P) % P;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 23680
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<cstring>
#include<set>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstdlib>
#define reep(n1,n2,n3) for(int n1=n3;n1<n2;n1++)
#define rep(n1,n2) reep(n1,n2,0)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define INF 1e9
using namespace std;
typedef long long int lint;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int,int> > vp;
typedef pair<int,int> pi;
typedef pair<int,pair<int,int> > pii;
typedef vector<string> vs;
const double PI  = acos(-1.0);
bool mx[500][500];
bool ret[500];
int main(){
    int n,m;
    while(cin>>n>>m,n){
        rep(i,n)
            rep(j,n)mx[i][j]=false;
        rep(i,n)ret[i]=false;
        mx[0][0]=true;
        ret[0]=true;
        rep(i,m){
            int a,b;
            cin>>a>>b;
            mx[--a][--b]=true;
            mx[b][a]=true;
        }
        rep(i,n){
            if(mx[0][i]){
                rep(j,n){
                    if(mx[i][j])ret[j]=true;
                }
            }
        }
        int s=0;
        rep(i,n)if(ret[i])s++;
        cout<<s-1<<endl;
    }
}

Measured memory_bytes: 1404
#include <iostream>
#include <vector>
#include <utility>
#include <limits>
using namespace std;

int merge(vector<pair<char, long>>& A, long left, long mid, long right)
{
    long n1 = mid - left;
    long n2 = right - mid;
    vector<pair<char, long>> L;
    vector<pair<char, long>> R;
    for (long i = 0; i < n1; ++i) {
        L.push_back(A[left + i]);
    }
    for (long i = 0; i < n2; ++i) {
        R.push_back(A[mid + i]);
    }
    L.push_back(make_pair('!', numeric_limits<long>::max())); // sentinel
    R.push_back(make_pair('!', numeric_limits<long>::max())); // sentinel
    long i = 0;
    long j = 0;
    for (long k = left; k < right; ++k) {
        if (L[i].second <= R[j].second) {
            A[k] = L[i];
            ++i;
        } else {
            A[k] = R[j];
            ++j;
        }
    }
    return right - left;
}

// Aの区間 [left, right) をソートする
int mergeSort(vector<pair<char, long>>& A, long left, long right)
{
    if (right - left <= 1) {
        // right - left <= 0 にすると無限再帰になるため、
        // 空になる前(1要素)を限界とすること。
        return 0;
    }
    long mid = (left + right) / 2;
    int cmp1 = mergeSort(A, left, mid);
    int cmp2 = mergeSort(A, mid, right);
    int cmp3 = merge(A, left, mid, right);
    return cmp1 + cmp2 + cmp3;
}

// Aの範囲[p, r]をpartition分割
long partition(vector<pair<char, long>>& A, long p, long r)
{
    long i = p - 1;
    for (long j = p; j <= r - 1; ++j) {
        if (A[j].second <= A[r].second) {
            swap(A[i + 1], A[j]);
            ++i;
        }
    }
    swap(A[i + 1], A[r]);
    return i + 1;
}

void quicksort(vector<pair<char, long>>& A, long p, long r)
{
    if (p >= r) {
        return;
    }
    long q = partition(A, p, r);
    quicksort(A, p, q - 1);
    quicksort(A, q + 1, r);
}

int main()
{
    long n;
    cin >> n;
    vector<pair<char, long>> A;
    vector<pair<char, long>> B;
    for (long i = 0; i < n; ++i) {
        char suit;
        int number;
        cin >> suit >> number;
        A.push_back(make_pair(suit, number));
        B.push_back(make_pair(suit, number));
    }
    quicksort(A, 0, n - 1);
    mergeSort(B, 0, n);
    bool stable = true;
    for (long i = 0; i < n; ++i) {
        if (A[i].first != B[i].first) {
            stable = false;
        }
    }
    if (stable) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
    for (auto a : A) {
        cout << a.first << " " << a.second << endl;
    }
}


Measured memory_bytes: 8584
#include <stdio.h>

int main(){
  int i=0;
  int N;
  int v, j,b;
  int A[1000];
  
  while(1){
    scanf("%d",&N);
    if(N<101 && N>0){
      break;
    }
    printf("Error\n");
  }

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

  for(i=1; i<N; i++){
    for(b=0; b<N-1; b++){
      printf("%d ",A[b]);
    }
    printf("%d\n",A[N-1]);
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1]=v;
  }
  
  for(i=0; i<N-1; i++){
    printf("%d ",A[i]);
    }
  printf("%d\n",A[N-1]);
  
  return 0;
}



Measured memory_bytes: 2140
#include <stdio.h>

int main (){
    int W,H,x,y,r;
    scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
    if (x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H)   printf("Yes\n");
    else    printf("No\n");
    return 0;
}



Measured memory_bytes: 2624
x = int(input())

if x < 600:
    print(8)
elif x < 800:
    print(7)
elif x < 1000:
    print(6)
elif x < 1200:
    print(5)
elif x < 1400:
    print(4)
elif x < 1600:
    print(3)
elif x < 1800:
    print(2)
else:
    print(1)

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

public class Main{
  public static void main(String[] args)throws Exception{
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] S = sc.nextLine().split(" ");
    Map<Long, Long> map = new HashMap<>();
    long[] val = new long[N];
    for(int i = 0; i < N; i++){
      val[i] = Long.parseLong(S[i]);
    }
    for(int i = 0; i < N; i++){
      if(map.containsKey(val[i])){
        map.put(val[i], map.get(val[i])+1);
      }else{
        map.put(val[i],1l);
      }
    }
    
    long ans = 0;
    for(Map.Entry<Long, Long> en : map.entrySet()){
      long b = en.getValue();
      ans += (b*(b-1))/2;
    }
    
    for(int i = 0; i < N; i++){
      long a = map.get(val[i]);
      long b = ((a*(a-1))-((a-1)*(a-2)))/2;
      System.out.println(ans-b);
    }
  }
}

Measured memory_bytes: 82580
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define N 2*10e5
#define precise cout<<fixed<<setprecision(10)
#pragma GCC optimize("O0")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#define rep(i,a,b) for(int i=a;i<b;i++)
#define min3(a,b,c) min(a,min(b,c))
#define nl cout<<"\n";
#define all(v) v.begin(),v.end()
#define F first
#define S second
typedef long long ll;
typedef vector<long long> vl;
typedef vector<pair<long,long>> vp;
void get(ll arr[],ll n){for(ll i=0;i<n;i++) cin>>arr[i];}
ll gcd(ll a,ll b);
ll binpow(ll a,ll b);
void solve()
{
	ll a;
	rep(i,0,5)
	{
		cin>>a;
		if(a==0)
		{
			cout<<i+1;break;
		}
	}
}
int main()
{
 	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
	 	solve();
	}
	//cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}
ll binpow(ll a, ll b) {
   ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}


Measured memory_bytes: 3628
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-05-03 21:13:01
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF 1000000000

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

    pair<long, long> ans;
    for (long a = -1000; a < 1000; a++) {
        for (long b = -1000; b < a; b++) {
            long c = pow(a, 5);
            long d = pow(b, 5);

            if (c-d == x) {
                ans.first = a;
                ans.second = b;
            }
        }
    }

    cout << ans.first << " " << ans.second << endl;

    return 0;
}


Measured memory_bytes: 4120
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-5;
const int inf=1e8;
int main(){
	char c;
	cin>>c;
	if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o')cout<<"vowel"<<endl;
	else cout<<"consonant"<<endl;
}













Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO 自動生成されたメソッド・スタブ
		Scanner ok =new Scanner(System.in);
		int n = ok.nextInt();
		int sum=0;

		for(int i=0;i<n;i++) {

			int k = ok.nextInt();
			int r = ok.nextInt();
			sum=sum-k+r+1;
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 25320
#include<bits/stdc++.h>
using namespace std;
int n;
int t[1001][1001];

int main(){
  scanf("%d",&n);
  while(n--){
    int ax,ay,bx,by;
    scanf("%d %d %d %d",&ax,&ay,&bx,&by);
    t[ax][ay]++;
    t[ax][by]--;
    t[bx][ay]--;
    t[bx][by]++;
  }

  int ans=0;
  for(int i=0;i<1001;i++){
    for(int j=0;j<1001;j++){
      if(i)t[i][j]+=t[i-1][j];
      if(j)t[i][j]+=t[i][j-1];
      if(i&&j)t[i][j]-=t[i-1][j-1];
      ans=max(ans,t[i][j]);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 7108
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
	cin >> s;
	if (s[5] == '0'){
		if (s[6] == '1' || s[6] == '2' || s[6] == '3' || s[6] == '4'){
			cout << "Heisei" << endl;
		}
		else cout << "TBD" << endl;
	}
	else cout << "TBD" << endl;
}

Measured memory_bytes: 3528
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;

int main(){
    string s,t;
    cin>>s>>t;
    int n=s.size();
    map<char,char> a,b;
    REP(i,n){
        if(a.find(s[i])!=a.end()){
            if(a[s[i]]!=t[i]){
                cout<<"No"<<endl;
                return 0;
            }
        }
        if(b.find(t[i])!=b.end()){
            if(b[t[i]]!=s[i]){
                cout<<"No"<<endl;
                return 0;
            }
        }
        a[s[i]]=t[i];
        b[t[i]]=s[i];
    }
    cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  string S;
  cin>>S;
  if(S[0]==S[1]&&S[1]==S[2]) {
cout<<"No"<<endl;
  }
  else {
    cout<<"Yes"<<endl;
  }
}

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

struct Computer{
  int time,saki,source;
};

int main(){
  Computer computer[20001];
  int data[20001];
 

  while(1){
    int n,m; cin >> n >> m;
    if( n == 0 && m == 0 ) break;
    
    for( int i = 0; i < 20001; i++ ) data[i] = 0;
    data[1] = 1;
    
    for( int i = 1; i <= m; i++ )
      cin >> computer[i].time >> computer[i].source >> computer[i].saki;

    for( int i = 1; i <= m; i++ ){
      for( int j = 1; j < m; j++ ){
	if( computer[j].time > computer[j+1].time ) swap(computer[j],computer[j+1]);
      }
    }
    
    // for( int i = 1; i <= m; i++ ) cout << "i " << i  << " "  << computer[i].time << " " << endl;
    
    for( int i = 1; i <= m; i++ ){
      if( data[ computer[i].source ] == 0 && data[ computer[i].saki ] == 1 ) continue;
      data[ computer[i].saki ] = data[ computer[i].source ];
    }

    int cnt = 0;

    //  for( int i = 1; i <= n; i++ ) cout << data[i] << " ";
    //cout << endl;
    
    for( int i = 1; i <= n; i++ ){
      if( data[i] == 1 ) cnt++;
    }

     cout << cnt << endl;

  }
  return 0;
}

Measured memory_bytes: 1472
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define mod 1000000007
#define inf 1e18+9
#define fr first
#define sc second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pll pair<ll,ll>
#define vll vector<ll>
#define umap unordered_map<ll,ll>
#define lpq priority_queue<ll,vector<ll>,greater<ll>>
ll globe=0;
ll powe(ll n,ll r){if(!r)return 1;else if(r%2==0)return powe(n*n,r/2);else return n*powe(n*n,(r-1)/2);}

int32_t main(){
 
	ios::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    
	ll t=1;
	//cin>>t;
	while(t--){
	    ll n;
	    cin>>n;
	    ll x=n/500;
	    n=n%500;
	    ll y=n/5;
	    ll ans=(x*1000)+(y*5);
	    cout<<ans<<endl;
	}
 
	return 0;
 
}
//BitMasking->setBit: n|(1<<i); unsetBit: n&!(1<<i); checkBit: n&(1<<i);
//ll idx=upper_bound(v.begin(),v.end(),val)-v.begin();
//v.erase(unique(v.begin(),v.end()),v.end());
//ll cnt=count(v.begin(),v.end(),val);
//bool f=find(v.begin(),v.end(),val);

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = []
A.append(LIST())
A.append(list(range(N)))

A = list(zip(*A))
A.sort()
A = list(zip(*A))
A[1] = [a+1 for a in A[1]]

print(*A[1])


Measured memory_bytes: 25668
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    int l = 0, r = N-1;
    
    string ss, es;
    cout << 0 << endl;
    cin >> ss;
    cout << N-1 << endl;
    cin >> es;
    if(ss == "Vacant" || es == "Vacant"){
        return 0;
    }

    string ms;
    while(1){
        int mid = (l+r+1)/2;
        cout << mid << endl;
        cin >> ms;

        if(ms == "Vacant"){
            return 0;
        }
        if(mid%2==l%2){
            if(ss==ms) l=mid, ss=ms;
            else r =mid, es =ms;
        }else{
            if(ss!=ms) l=mid, ss=ms;
            else r =mid, es =ms;
        }
    }
}

Measured memory_bytes: 852
// https://atcoder.jp/contests/abc126/tasks/abc126_e

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

//------------------------------------------------------------------------------
const int V_MAX = 1e5;

vector<int> G[V_MAX];
bool used[V_MAX];

void add_edge(int u, int v) {
  G[u].push_back(v);
  G[v].push_back(u);
}

void dfs(int p, int v) {
  used[v] = true;
  for (int u : G[v]) {
    if (u == p) continue;
    if (used[u]) continue;
    dfs(v, u);
  }
}

//------------------------------------------------------------------------------
const int N_MAX = 1e5;
const int M_MAX = 1e5;
const int Z_I_MAX = 100;

int N, M;
// int X[M_MAX];
// int Y[M_MAX];
// int Z[M_MAX];

void solve() {
  int ans = 0;
  REP(v, N) {
    if (used[v]) continue;
    ++ans;
    dfs(-1, v);
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d", &N, &M);
  REP(i, M) {
    int X, Y, Z;
    scanf("%d%d%d", &X, &Y, &Z);
    add_edge(X - 1, Y - 1);
  }
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 10496
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
string board[60];
int main(){
    int X, Y;
    cin >> X >> Y;
    int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
    int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
    for(int i = 0; i < X; i++)
        cin >> board[i];
    for(int i = 0; i < X; i++){
        for(int j = 0; j < Y; j++){
            if(board[i][j] == '.'){
                int cnt = 0;
                for(int k = 0; k < 8; k++){
                    int x = i + dx[k];
                    int y = j + dy[k];
                    if(x >= 0 && x < X && y >= 0 && y < Y && board[x][y] == '#')
                        cnt++;
                }
                board[i][j] = '0' + cnt;//cntの文字化
            }
        }
    }
    for(int i = 0; i < X; i++)
        cout << board[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"YES":"NO");
}
int main() {
  int n,x,t;cin>>n>>x>>t;
  int ans=(n+x-1)/x*t;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3656
n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []
for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for ni in range(n):
    print(" ".join([str(s) for s in C[ni]]))

Measured memory_bytes: 8788
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, e) for(int i = (int)(s); i < (int)(e); ++i)
#define rep(i, n) REP(i, 0, n)

int main() {
  string s;
  cin >> s;
  if((s[0] == s.back()) ^ ((int)s.size()%2 == 0)) cout << "Second";
  else cout << "First" << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n-1); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define scout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	int n,k,q; cin >> n >> k >> q;
	vint point(n+1,0);
	int no=k-q;
	rep(i,q) {
		int a; cin >> a;
		point[a]++;
	}
	for(int i=1;i<=n;i++) {
		if(point[i]+no>0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 3744
"use strict";
function main(input) {
  const inputs = input.split("\n").filter(x => x !== "");
  const N = inputs[0];

  function make(level) {
    if (level === 1) {
      return ["3", "5", "7"];
    }

    let preLevel = make(level - 1);
    return [].concat(
      preLevel.map(num => `3${num}`),
      preLevel.map(num => `5${num}`),
      preLevel.map(num => `7${num}`)
    );
  }

  let wholeArray = [];
  for (let i = 1; i <= 9; i++) {
    wholeArray = wholeArray.concat(make(i));
  }

  wholeArray = wholeArray
    .filter(
      item => item.includes("3") && item.includes("5") && item.includes("7")
    )
    .map(item => Number(item))
    .sort((a, b) => a - b);

  wholeArray.push(Number.MAX_VALUE);
  console.log(wholeArray.findIndex(element => element > N));
}

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


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

using namespace std;

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

	int n, m;
	cin >> n >> m;

	vector<int> a;
	a.resize(n);

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

	vector<int> delta;
	delta.resize(2 * m + 1);

	long long sum = 0;

	for(int i = 0; i < n - 1; ++i) {
		if(a[i] < a[i + 1]) {
			sum += a[i + 1] - a[i];
		} else {
			sum += a[i + 1] + m - a[i];
		}
	}

	vector<long long> add;
	add.resize(2 * m);

	for(int i = 0; i < n - 1; ++i) {
		int x = a[i] - 1;
		int y = a[i + 1] - 1;
		
		if(x < y) {
			++delta[x];
			--delta[y];
			add[y] += y - x;
		} else {
			++delta[x];
			--delta[y + m];
			add[y + m] += y + m - x;
		}
	}

	long long tot = 0;
	long long d = 0;

	vector<long long> ans;
	ans.assign(m, sum);

	for(int i = 0; i < 2 * m; ++i) {
		tot += d;
		ans[i % m] -= tot - d;
		tot -= add[i];
		d += delta[i];
	}

	cout << *min_element(ans.begin(), ans.end()) << '\n';

	return 0;
}


Measured memory_bytes: 3840
#include<stdio.h>
int main(void){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  while(1){
    c-=b;
    if(c<=0){
      printf("Yes\n");
      return 0;
    }
    a-=d;
    if(a<=0){
      printf("No\n");
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<iomanip>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>

i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;



//メモリ置き場


//inputします
void input() {
	
}

//ライブラリ置き場
i64 cup(i64 xxx38, i64 yyy38) {//切り上げ
	return (xxx38 + yyy38 - 1) / yyy38;
}
//main
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
	input();
	vector<int> dat(5);
	int sum = 0;
	int m = 10;
	ff(i, 0, 5) {
		cin >> dat[i];
		sum += cup(dat[i],10)*10;
		int r = (dat[i] - 1) % 10;
		r %= 10;
		r++;
		m = min(m, r);
	}

	cout << sum+m-10<< endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  cout<<n-k+1<<endl;
}


Measured memory_bytes: 892
import std;

BigInt calc(long[] a) {
    if (a.any!(e => e == 0)) return BigInt(0);

    BigInt x = 1;
    long m = 10L ^^ 18;
    foreach (e; a) {
        x *= e;
        if (x > m) return BigInt(-1);
    }
    return x;
}

void main() {
    int n; scan(n);
    auto a = reads!long;
    writeln(calc(a));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;


Measured memory_bytes: 8100
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )

using namespace std;

const int N = 2e5 + 5;

int n, m1, m2, x, y, u1[N], u2[N], cnt;

vector < vector <int> > g1, g2;

void dfs1 (int v)
{
    u1[v] = cnt;
    for (int i = 0; i < g1[v].size(); i++)
    {
        int to = g1[v][i];
        if ( !u1[to] )
            dfs1(to);
    }
}
void dfs2 (int v)
{
    u2[v] = cnt;
    for (int i = 0; i < g2[v].size(); i++)
    {
        int to = g2[v][i];
        if ( !u2[to] )
            dfs2(to);
    }
}
map <pair <int, int> , int > mp;

main ()
{
    cin >> n >> m1 >> m2;

    g1.resize(n + 1);
    g2.resize(n + 1);

    for (int i = 1; i <= m1; i++)
    {
        scanf("%d%d", &x, &y);
        g1[x].pb(y);
        g1[y].pb(x);
    }
    for (int i = 1; i <= m2; i++)
    {
        scanf("%d%d", &x, &y);
        g2[x].pb(y);
        g2[y].pb(x);
    }
    for (int i = 1; i <= n; i++)
    {
        if (!u1[i])
        {
            cnt++;
            dfs1( i );
        }
    }
    cnt = 0;
    for (int i = 1; i <= n; i++)
    {
        if (!u2[i])
        {
            cnt++;
            dfs2( i );
        }
        mp[ mk(u1[i], u2[i]) ]++;
    }
    for (int i = 1; i <= n; i++)
    {
        printf("%d ", mp[ mk( u1[i], u2[i] ) ]);
    }

}


Measured memory_bytes: 27776
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

int main()
{
	int32_t A, B, C;
	cin >> A >> B >> C;

	cout << (C >= A && C <= B ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
using namespace std;

int jousu(int, int);
int jousu(int x, int y) {
	int z = 1;
	for (int i = 0; i < y; i++) {
		z *= x;
	}
	return z;
}
int kurai(int x, int y) {
	int z = (x%jousu(10,y)) / jousu(10, y-1);
	return z;
}
int keta(int x) {
	int z = x;
	int w = 0;
	while (z != 0) {
		z /= 10;
		w++;
	}
	return w;
}


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

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

int main()
{
    int n, w;
    std::cin >> n >> w;

    std::vector<std::pair<long, long>> goods(n);

    for (int i = 0; i < n; i++) {
        std::cin >> goods[i].first >> goods[i].second;
    }

    std::vector<std::vector<long>> dp(n + 1, std::vector<long>(w + 1));

    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= w; j++) {
            if (j - goods[i].first >= 0) {
                dp[i + 1][j] = std::max(dp[i + 1][j], dp[i][j - goods[i].first] + goods[i].second);
            }
            dp[i + 1][j] = std::max(dp[i + 1][j], dp[i][j]);
        }
    }

    std::cout << dp[n][w] << std::endl;
}


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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
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;
}

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) (x).erase(unique(all(x)), (x).end())
#define int long long

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    int w, a, b;
    cin >> w >> a >> b;
    cout << (((min(a, b) + w) < max(a, b)) ? (max(a, b) - (min(a, b) + w)) : (0)) << endl;
    return 0;
}

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> b(n+1);
	b[0] = 0 ;
	rep(i,n){
		if(s[i] == '#'){
			b[i+1] = b[i] + 1;
		} else {
			b[i+1] = b[i];
		}
	}
	int ans = 10010010 ;
	for(int i = 1 ; i <= n ; i++){
		int black = b[i-1] ;
		int white = (n-i) - (b[n]-b[i]);
		chmin(ans,black+white);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

llong f(llong n, llong x){
	if(n==-1) return 0;
	return n/x + 1;
}

int main(){	
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	llong a, b, x;
	cin >> a >> b >> x;
	llong res = f(b, x) - f(a-1, x);
	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    int ret = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            ret += A[i] * A[j];
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
  	ll a,b;cin>>a>>b;
  	cout << (a+2*b)/(2*b+1)  << ednl;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  int N,K;
  cin>>N>>K;

  double ans=0;
  for(int i=1;i<=N;i++){
    ll res=i;
    double p=1./N;
    while(res<K){
      res*=2;
      p/=2.;
    }
    ans+=p;
  }
  cout<<fixed<<setprecision(20)<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
#AGC5 A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

stack = []
x = input()
n = len(x)
for i in range(n):
    if x[i] == 'S':
        stack.append(x[i])
    else:
        if len(stack) == 0 or stack[-1] != 'S':
            stack.append(x[i])
        elif stack[-1] == 'S':
            stack.pop()
print(len(stack))


Measured memory_bytes: 51936
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  string s;
  cin>>s;
  for(int i=0;i<(int)s.size()-1;i++){
    if(s[i]==s[i+1]){
      cout<<i+1<<' '<<i+2<<endl;
      return 0;
    }
  }
  if((int)s.size()>=3){
    for(int i=0;i<(int)s.size()-2;i++){
      if(s[i]==s[i+2]){
        cout<<i+1<<' '<<i+3<<endl;
        return 0;
      }
    }
  }
  cout<<-1<<' '<<-1<<endl;
  return 0;
}


Measured memory_bytes: 3764
import sys
input = sys.stdin.readline

def numK(n, k):
    return k * (n - k + 1) + 1


I = input().split()
N = int(I[0])
K = int(I[1])

sum = 0
for i in range(K,N+2):
    sum += numK(N,i)

print(sum % (10 ** 9 +7))

Measured memory_bytes: 8944
#include <iostream>
using namespace std;
   
#define check cnt=0;for(j=0;j<6;j++)if(d[q][j]==d[r][j])cnt++;
#define m tmp=d[r][1];d[r][1]=d[r][3];d[r][3]=d[r][4];d[r][4]=d[r][2];d[r][2]=tmp;
#define y tmp=d[r][0];d[r][0]=d[r][3];d[r][3]=d[r][5];d[r][5]=d[r][2];d[r][2]=tmp;
   
bool same(int d[][6],int q,int r){
 int tmp,cnt,a=1,i,j,k;
 check if(cnt==6)a=0;
   
 while(a){
  for(i=0;i<5;i++){
   for(k=0;k<4;k++){
    check if(cnt==6)break;
    m
   }
   check if(cnt==6)break;
   tmp=d[r][0];
   d[r][0]=d[r][1];
   d[r][1]=d[r][5];
   d[r][5]=d[r][4];
   d[r][4]=tmp;
  }
  if(cnt==6)break;
  y
  for(k=0;k<4;k++){
   check if(cnt==6)break;
   m
  }
  if(cnt==6)break;
  y y
  for(k=0;k<4;k++){
   check if(cnt==6)break;
   m
  }
  a=0;
 }
   
 if(cnt==6)return true;
 return false;
}
 
int main(){
 int n,judge=0;
 cin >> n;
 int d[n][6];
   
 for(int i=0;i<n;i++)for(int j=0;j<6;j++)cin >> d[i][j] ;
   
 for(int q=0;q<n-1;q++)for(int r=q+1;r<n;r++)if(same(d,q,r))judge++;
 
 if(judge>0)cout << "No" << endl ;
 else cout << "Yes" << endl ;
   
 return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;

int main() {
  ll N,K;cin>>N>>K;

  if (K==0) {
    OUT(N*N);
    return 0;
  }

  // bに入りうる値でループ
  ll ans = 0;
  FOR(b,K+1,N+1) {
    // 余りがK以上になる個数
    // 境界線を見つけて、そこまで足していく
    // ....ooo....ooo....oo|o
    // あまりの島が全部入っている個数
    int gap = b-K;
    int island_cnt = N/b;
    ans += gap*island_cnt;

    // 最後の島が境界線に分断されている場合
    ll mod = N%b;
    if (mod>=K) ans += mod-K+1;
  }
  OUT(ans);

  return 0;
}


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

int main() {
    string S;
    int Q;
    cin >> S >> Q;

    int rev = 0;
    for (int i = 0; i < Q; i++) {
        int T;
        scanf("%d", &T);
        if (T == 1) {
            rev++;
        } else {
            int F;
            string C;
            scanf("%d", &F);
            cin >> C;
            if (F == 1) {
                if (rev % 2 == 0) {
                    S.insert(0, C);
                } else {
                    S += C;
                }
            } else {
                if (rev % 2 == 0) {
                    S += C;
                } else {
                    S.insert(0, C);
                }
            }
        }
    }

    if (rev % 2 == 1) {
        reverse(S.begin(), S.end());
    }

    cout << S << endl;

    return 0;
}

Measured memory_bytes: 900
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

   private static final String INPUT_FILE_PATH = "";

   static void solve(InputReader in, PrintWriter out) {
      int n = in.nextInt();
      int[] a = new int[n];
      TreeMap<Integer, Integer> tm = new TreeMap();
      HashSet<Integer> seen = new HashSet();
      for (int i = 0; i < n; i++) {
         a[i] = in.nextInt();
         tm.put(a[i], 1 + tm.getOrDefault(a[i], 0));
      }
      int ans = 0;
      for (Map.Entry<Integer, Integer> entry : tm.entrySet()) {
         int x = entry.getKey();
         int count = entry.getValue();
         if (count == 1) {
            boolean hasDivisor = false;
            for (int i = 1; i * i <= x; i++) {
               if (x % i > 0) continue;
               if (seen.contains(i) || seen.contains(x / i)) {
                  hasDivisor = true;
                  break;
               }
            }
            if (!hasDivisor) ans++;
         }
         seen.add(x);
      }
      out.println(ans);
   }

   private static class InputReader {
      private BufferedReader br;
      private StringTokenizer st;

      public InputReader(InputStream inputStream) {
         this.br = new BufferedReader(new InputStreamReader(inputStream), 32768);
         this.st = null;
      }

      public String nextToken() {
         while (st == null || !st.hasMoreTokens()) {
            try {
               st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
               throw new RuntimeException(e);
            }
         }
         return st.nextToken();
      }

      public int nextInt() {
         return Integer.parseInt(nextToken());
      }

      public long nextLong() {
         return Long.parseLong(nextToken());
      }

      public double nextDouble() {
         return Double.parseDouble(nextToken());
      }
   }

   public static void main(String[] args) throws Exception {
      InputStream inputStream = INPUT_FILE_PATH.isEmpty()
         ? System.in
         : new FileInputStream(new File(INPUT_FILE_PATH));
      OutputStream outputStream = System.out;

      InputReader inputReader = new InputReader(inputStream);
      PrintWriter printWriter = new PrintWriter(outputStream);

      solve(inputReader, printWriter);

      printWriter.close();
   }

}


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

int cnt[10];
char s[10];

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a < b) swap(a, b);
    if (a < c) swap(a, c);
    int t = a - b + a - c;
    if (t & 1) printf("%d\n", t/2 + 2);
    else printf("%d\n", t/2);
    return 0;
}


Measured memory_bytes: 256