akhauriyash/Code-Regression huggingface dataset:
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.stream.Stream;

class Main{
	private void solve(){
		int n=gInt(),y=gInt()/1000;
		for(int i=0;i*10<=y;++i) {
			for(int j=0;i*10+j*5<=y;++j) {
				int k=y-i*10-j*5;
				if(i+j+k==n) {
					System.out.println(i+" "+j+" "+k);
					return;
				}
			}
		}
		System.out.println("-1 -1 -1");
	}

	public static void main(String[] $){
		new Main().solve();
		System.out.flush();
	}


	static class System{
		private static final InputStream	in	=java.lang.System.in;
		private static final PrintWriter	out	=new PrintWriter(java.lang.System.out,false);
	}

	static Scanner s=new Scanner(System.in);


	static int gInt(){
		return s.nextInt();
	}

	static long gLong(){
		return s.nextLong();
	}

	static long gDouble(){
		return s.nextLong();
	}


	static Range rep(int i){
		return new Range(i);
	}

	static Range rep(int f,int t){
		return new Range(f,t);
	}

	static class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
		int from,to,c;
		Range(int from,int to){
			this.from=from;
			this.to=to;
			this.c=from;
		}
		Range(int n){
			this(0,n-1);
		}
		@Override
		public Iterator<Integer> iterator(){
			return this;
		}
		@Override
		public boolean hasNext(){
			return c<=to;
		}
		@Override
		public int nextInt(){
			return c++;
		}
	}


	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}

	static IntStream REPS(int l,int r){
		return IntStream.rangeClosed(l,r);
	}


	static IntStream ints(int n){
		return REPS(n).map(i->gInt());
	}

	static Stream<String> strs(int n){
		return REPS(n).mapToObj(i->s.next());
	}

}

Measured memory_bytes: 25044
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	string t = "keyence";
	if(s == t){
		cout << "YES" << endl;
		return 0;
	}
	int n = s.size();
	for(int i = 0; i < n; ++i){
		for(int j = i; j < n; ++j){
			string u = "";
			for(int k = 0; k < n; ++k){
				if(i <= k && k <= j) continue;
				else u.push_back(s[k]);
			}
			if(u == t){
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  int N;
  cin >> N;
  lint A,B,C,D;
  cin >> A >> B >> C >> D;
  lint dis=B-A;
  lint maxi=C*(N-1);
  lint scase[N];
  rep(i,N) scase[i]=maxi-2*C*i;
  lint rangeplus[N],rangeminus[N];
  rep(i,N){
    rangeplus[i]=(D-C)*(N-1-i);
    rangeminus[i]=(D-C)*i;
  }
  bool ans=false;
  rep(i,N){
    lint dis2=scase[i]-dis;
    if(dis2==0) ans=true;
    if(dis2>0) if(rangeminus[i]>=dis2) ans=true;
    if(dis2<0) if(rangeplus[i]>=-dis2) ans=true;
  }
  if(ans) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define lb(x) ((x)&(-(x)))
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define push_back pb
#define N 100010
using namespace std;
typedef long long ll;
int n,f[55][3][3];
char s1[55],s2[55];
inline void upd(int&a,int b){a+=b;a>=dalao?a-=dalao:0;}
int main(){
	cin>>n;
	scanf("%s%s",s1+1,s2+1);
	if(s1[1]^s2[1]){for(int i=0;i<3;i++)for(int j=0;j<3;j++)if(i^j)f[2][i][j]=1;}
	else for(int i=0;i<3;i++)f[1][i][i]=1;
	for(int i=2+(s1[1]!=s2[1]);i<=n;i++){
		if(s1[i]!=s2[i]){
			for(int j=0;j<3;j++)for(int k=0;k<3;k++)if(j^k)
				for(int x=0;x<3;x++)for(int y=0;y<3;y++)if(x!=j&&y!=k)upd(f[i][j][k],f[i-1][x][y]);
			mcpy(f[i+1],f[i]),i++;
		}else{
			for(int j=0;j<3;j++)for(int x=0;x<3;x++)for(int y=0;y<3;y++)
				if(x!=j&&y!=j)upd(f[i][j][j],f[i-1][x][y]);
		}
	}
	int ans=0;
	for(int i=0;i<3;i++)for(int j=0;j<3;j++)upd(ans,f[n][i][j]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,i=0,f;
	scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
	if(((a+b*5+c*10+d*50+e*100+f*500)/1000)>=1) i=1;
	printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 1032
#include <stdio.h>

int mco[101][101];
int p[100];

void matrixChainOrder(int);

int main(){
  int n;
  int d;
  int i;

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

  matrixChainOrder(n);

  printf("%d\n",mco[1][n]);

  return 0;
}

void matrixChainOrder(int n){
  int i,j,q,l,k;

  for(i=1;i<=n;i++) mco[i][i] = 0;

  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j= i+l-1;
      mco[i][j]= 2147483647;
      for(k=i;k<j;k++){
	q= mco[i][k] + mco[k+1][j] + p[i-1] * p[k] * p[j];
	if(mco[i][j] > q) mco[i][j] = q;
      }
    }
  }
}

Measured memory_bytes: 636
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------

signed main() {
	int x = read();
	cout << x * x * x << endl;
}


Measured memory_bytes: 3136
#include <stdio.h>
#include <vector>

using namespace std;

struct Node{
	Node(){
		brother = parent = -1;
		height = depth = num_of_children = 0;
	}
	int parent,brother,depth,num_of_children,height;
	vector<int> children;
};

void calcDepth(Node nodes[],int root_id){
	for(int i = 0;i < nodes[root_id].num_of_children;i++){
		nodes[nodes[root_id].children[i]].depth = nodes[root_id].depth+1;
		calcDepth(nodes,nodes[root_id].children[i]);
	}
}

void calcHeight(Node nodes[],int height,int parent){
	nodes[parent].height = max(nodes[parent].height,height+1);
	if(nodes[parent].parent != -1) calcHeight(nodes,height+1,nodes[parent].parent);
}

int main(){
	int n,id,left_id,right_id,root_id;
	scanf("%d",&n);
	Node nodes[n];

	for(int i = 0; i < n; i++){
		scanf("%d %d %d",&id,&left_id,&right_id);
		if(left_id != -1){
			nodes[id].children.push_back(left_id);
			nodes[id].num_of_children++;
			nodes[left_id].parent = id;
		}
		if(right_id != -1){
			nodes[id].children.push_back(right_id);
			nodes[id].num_of_children++;
			nodes[right_id].parent = id;
		}
		if(left_id != -1 && right_id != -1){
			nodes[left_id].brother = right_id;
			nodes[right_id].brother = left_id;
		}
	}

	for(root_id = 0; root_id < n; root_id++){
		if(nodes[root_id].parent == -1) break;
	}

	if(n > 1){
		calcDepth(nodes,root_id);

		for(int i = 0; i < n; i++){
			if(nodes[i].num_of_children == 0) calcHeight(nodes,0,nodes[i].parent);
		}
	}

	for(int i = 0; i < n; i++){
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,"
				,i,nodes[i].parent,nodes[i].brother,nodes[i].num_of_children,nodes[i].depth,nodes[i].height);
		if(nodes[i].parent == -1){
			printf(" root\n");
		}else if(nodes[i].num_of_children == 0){
			printf(" leaf\n");
		}else{
			printf(" internal node\n");
		}

	}
}


Measured memory_bytes: 2752
#define FASTIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//#define BZ
//#define PBDS
//#define POINT

#ifndef BZ
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("no-stack-protector")
#pragma GCC target ("tune=native")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize ("conserve-stack")
//#pragma GCC optimize ("no-stack-limit")
#endif

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using str = string;
using pll = pair<ll, ll>;

#ifdef POINT
using point = complex<ll>;
#define x real
#define y imag
#endif

#ifdef PBDS
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//using namespace __gnu_pbds::detail;
template <class T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#endif

#define INF 0x7fffffffffffffffLL
#define BASE 1000000007LL // 3 * 10**9 + 19 // 998244353 - rev == pow(n + m, BASE - 2)
#define MAX(type) std::numeric_limits<type>::max()
#define MIN(type) std::numeric_limits<type>::min()

#define LOG(v) cout << #v << " " << v << "\n";

#define pb push_back
#define eb emplace_back
//#define all(c) c.begin(), c.end()
//#define rall(c) c.rbegin(), c.rend()
#define F first
#define S second
#define forEach(c) for (auto &it : c)
#define loop while (true)
#define mp make_pair
#define mt make_tuple

template<class T>
void chMax(T &a, T b) {
	if (a < b) a = b;
}

template<class T>
void chMin(T &a, T b) {
	if (b < a) a = b;
}

inline ll divUp(ll a, ll b) {
	return (a + b - 1)/b;
}

void solve() {
	ll a;
	cin >> a;
	cout << a * a << "\n";
}

//#define LOCAL

int main() {
	FASTIO
#ifdef LOCAL
	auto start = std::chrono::system_clock::now();
#endif
	solve();
#ifdef LOCAL
	auto end = std::chrono::system_clock::now();
	std::chrono::duration<ld> elapsed_seconds = end - start;
	cerr << "\ntime: " << elapsed_seconds.count() << " s\n";
#endif
	return 0;
}


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

def is_this(word, a, b):
    if trans(word, a, b) == "this":
        return True
    return False

def is_that(word, a, b):
    if trans(word, a, b) == "that":
        return True
    return False

def trans(word, a, b):
    tra = ''
    for i in range(len(word)):
        tra += chr(97+(a*dic[word[i]]+b)%26)
    return tra

dic = {}
for i in range(26):
    dic[chr(97+i)] = i
n = int(raw_input())
for i in range(n):
    text = map(str, raw_input().split())
    j = 0
    flag = True
    while flag:
        if len(text[j]) == 4:
            tmp = text[j]
            for alfa in range(100):
                if alfa % 2 == 0 or alfa % 13 == 0:
                    continue
                for beta in range(26):
                    if is_this(tmp, alfa, beta) or is_that(tmp, alfa, beta):
                        flag = False
                        break
                if not flag:
                    break
        j += 1
    ans = []
    for t in text:
        ans.append(trans(t, alfa, beta))
    print " ".join(map(str, ans))

Measured memory_bytes: 6276
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    NI = lambda : int(sys.stdin.readline())

    N = NI()

    d = [2] * (N+1)
    d[1] = 1
    for i in range(2,int(math.sqrt(N))+1):
        d[i*i] += 1
        j = i + 1
        while i * j <= N:
            d[i*j] += 2
            j += 1

    ans = 0
    for i in range(1,N+1):
        ans += i * d[i]

    print(ans)


if __name__ == '__main__':
    main()

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

digit_N = len(str(N))

def make_753(a,N_limit,n=None):
    if n==None:
        n = len(str(max(a)))
    tmp = 10 ** n
    return [tmp*3 + i for i in a if tmp*3+i <= N_limit] + \
            [tmp*5 + i for i in a if tmp*5+i <= N_limit] + \
            [tmp*7 + i for i in a if tmp*7+i <= N_limit]

list_753 = [[3,5,7] for _ in range(digit_N)]
for i in range(1,digit_N):
    list_753[i] = make_753(list_753[i-1],N,i)

def check_753(num):
    check_3 = 0
    check_5 = 0
    check_7 = 0
    num = str(num)
    for c in num:
        if check_3 == 0 and c == "3":
            check_3 = 1
        elif check_5 == 0 and c == "5":
            check_5 = 1
        elif check_7 == 0 and c == "7":
            check_7 = 1
    return check_3 * check_5 * check_7

out = 0
for tmp in list_753[2:]:
    for num in tmp:
        out += check_753(num)
print(out)

Measured memory_bytes: 4456
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (y % 2 == 0 && y >= 2 * x && y <= 4 * x) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

// calculate |gcd|.
// if  ether num is 0, return 0
long long GCD(long long left, long long right) {
  if(left == 0 || right == 0) return 0;
  if(left < 0) left *= -1;
  if(right < 0) right *= -1;
  if(left < right) swap(left, right);
  long long nextnum, ansgcd = -1;
  while(ansgcd == -1) {
    nextnum = left % right;
    if(nextnum == 0) ansgcd = right;
    left = right;
    right = nextnum;
  }
  return ansgcd;
}

long long LCM(long long left, long long right) {
  return left / GCD(left, right) * right;
}

long long n;
vector<long long> a;

bool solve();

int main() {
  cin >> n;
  a.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  if(solve())
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

bool solve() {
  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());
  return a.size() == n;
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<int> strength(3 * n);
	for (int i = 0; i < 3 * n; ++i) {
		cin >> strength[i];
	}

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

	long long max_strength = 0;
	for (int i = 1; i <= 2 * n; i += 2) {
		max_strength += strength[3 * n - i - 1];
	}

	cout << max_strength << "\n";

	return 0;

}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,p;
    cin>>s>>p;
   int k=0;
   stack<char>j;
   for(int i=0;i<s.size();i++)
   {
       j.push(s[i]);
   }
   for(int i=0;i<s.size();i++)
   {
       if(j.top()==p[i])
       {
           j.pop();
           k++;
       }
   }
   if(k==p.size())
   {
       cout<<"YES"<<endl;
   }
   else
   {
        cout<<"NO"<<endl;
   }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int s, w;
    cin >> s >> w;

    cout << (s > w ? "safe\n" : "unsafe\n");

    return 0;
}



Measured memory_bytes: 3640
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    a,b,k=map(int,input().split())
    for i in range(k):
        if i%2==0:
            a=a//2*2
            b+=a//2
            a=a//2
        else:
            b=b//2*2
            a+=b//2
            b=b//2           
    print(a,b)

if __name__=='__main__':
    main()

Measured memory_bytes: 3060
def main():
    import sys
    input = sys.stdin.readline
    from collections import deque

    class Dinic:
        def __init__(self, N):
            self.N = N
            self.G = [[] for i in range(N)]

        def add_edge(self, fr, to, cap):
            forward = [to, cap, None]
            forward[2] = backward = [fr, 0, forward]
            self.G[fr].append(forward)
            self.G[to].append(backward)

        def add_multi_edge(self, v1, v2, cap1, cap2):
            edge1 = [v2, cap1, None]
            edge1[2] = edge2 = [v1, cap2, edge1]
            self.G[v1].append(edge1)
            self.G[v2].append(edge2)

        def bfs(self, s, t):
            self.level = level = [None] * self.N
            deq = deque([s])
            level[s] = 0
            G = self.G
            while deq:
                v = deq.popleft()
                lv = level[v] + 1
                for w, cap, _ in G[v]:
                    if cap and level[w] is None:
                        level[w] = lv
                        deq.append(w)
            return level[t] is not None

        def dfs(self, v, t, f):
            if v == t:
                return f
            level = self.level
            for e in self.it[v]:
                w, cap, rev = e
                if cap and level[v] < level[w]:
                    d = self.dfs(w, t, min(f, cap))
                    if d:
                        e[1] -= d
                        rev[1] += d
                        return d
            return 0

        def flow(self, s, t):
            flow = 0
            INF = 10 ** 9 + 7
            G = self.G
            while self.bfs(s, t):
                *self.it, = map(iter, self.G)
                f = INF
                while f:
                    f = self.dfs(s, t, INF)
                    flow += f
            return flow

    H, W = map(int, input().split())
    grid = []
    for _ in range(H):
        line = input().rstrip('\n')
        grid.append(line)

    dinic = Dinic(H+W+5)
    for h in range(H):
        for w in range(W):
            if grid[h][w] == 'o':
                dinic.add_edge(h+1, H+w+1, 1)
                dinic.add_edge(H+w+1, h+1, 1)
            elif grid[h][w] == 'S':
                dinic.add_edge(H+W+1, h+1, 10**5)
                dinic.add_edge(H+W+1, H+w+1, 10**5)
            elif grid[h][w] == 'T':
                dinic.add_edge(h+1, H+W+2, 10**5)
                dinic.add_edge(H+w+1, H+W+2, 10**5)

    ans = dinic.flow(H+W+1, H+W+2)
    if ans > 400:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 48220
#include <iostream>
#include <vector>
#include <map>

using namespace std;
typedef long long LL;

void searchG(LL pos, LL dist, vector<vector<LL> >& edge, vector<LL>& p, LL visited, LL& best){
    if(visited == (1<<p.size())-1){
        best = min<LL>(best, dist);
        return;
    }
    for(LL i = 0; i < p.size(); ++i){
        if((1<<i) & visited) continue;
        searchG(p[i], dist + edge[pos][p[i]], edge, p, visited|(1<<i), best);
    }
}

int main(){
    int n, m, r;
    cin >> n >> m >> r;
    vector<LL> p(r);
    for(int i = 0; i < r; ++i){
        cin >> p[i];
        p[i] -= 1;
    }
    vector<vector<LL> > edge(n, vector<LL>(n, 1000000000LL));
    for(int i = 0; i < m; ++i){
        LL a, b, c;
        cin >> a >> b >> c;
        edge[a-1][b-1] = c;
        edge[b-1][a-1] = c;
    }
    for(int k = 0; k < n; ++k){
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < n; ++j){
                edge[i][j] = min(edge[i][j], edge[i][k] + edge[k][j]);
            }
        }
    }
    LL best = 1000000000LL;
    for(int i = 0; i < p.size(); ++i){
        searchG(p[i], 0, edge, p, (1<<i), best);
    }
    cout << best << endl;
    
    return 0;
}

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

class MainClass
{
    static void Main()
    {
        var nab = ReadLine().Split().Select(int.Parse).ToArray();
        int n = nab[0];
        int a = nab[1];
        int b = nab[2];
        string S = ReadLine();

        int total= 0;
        int ab = 0;
        for (int i = 0; i < n; i++)
        {
            if (S[i] == 'a')
            {
                if (total < a + b)
                {
                    WriteLine("Yes");
                    total++;
                }
                else
                {
                    WriteLine("No");
                }
            }
            else if (S[i] == 'b')
            {
                if (total < a + b && ab < b)
                {
                    WriteLine("Yes");
                    total++;
                    ab++;
                }
                else
                {
                    WriteLine("No");
                }
            }
            else
            {
                WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 28476
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int[] x = new int[n];
		int sum = 0;
		for(int i=0; i<n; i++){
			x[i] = sc.nextInt();
			sum += x[i];
		}
		long[][][] dp = new long[n+1][n+1][sum+1];
		dp[0][0][0] = 1L;
		for(int i=1; i<n+1; i++){
			for(int k=0; k<n+1; k++){
				for(int s=0; s<sum+1; s++){
					if(s>=x[i-1] && k>=1){
						dp[i][k][s] = dp[i-1][k][s] + dp[i-1][k-1][s-x[i-1]];
					}
					else{
						dp[i][k][s] = dp[i-1][k][s];
					}
				}
			}
		}
		long ans = 0L;
		for(int k=1; k<n+1; k++){
			if(k*a<=sum)ans += dp[n][k][k*a];
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 86704
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        ll n, q;
        cin >> n >> q;
        vector<ll> a(n), x(q);
        rep(i, n) cin >> a[i];
        rep(i, q) cin >> x[i];

        // solve
        rep(i, q) {
            ll right = 0;
            ll sum = 0;
            ll res = 0;
            for (ll left = 0; left < n; ++left) {
                while (right < n && sum + a[right] <= x[i]) {
                    /* 実際に right を 1 進める */
                    sum += a[right];
                    ++right;
                }

                /* break した状態で right は条件を満たす最大なので、何かする */
                res += (right - left);

                /* left をインクリメントする準備 */
                if (right == left) ++right;
                else sum -= a[left];
            }
            cout << res << endl;
        }


#ifdef MY_DEBUG
    }
#endif
    return 0;
}


Measured memory_bytes: 3544
N = gets.chomp.to_i % 10
if N == 2 || N == 4 || N == 5 || N == 7 || N == 9
  puts "hon"
else
  if N == 0 || N == 1 || N == 6 || N == 8
    puts "pon"
  else
    puts "bon"
  end
end


Measured memory_bytes: 14280
#include <cstdio>

int main(){
	char num[1001];
	while(1){
		int sum=0, i=0;
	
		scanf("%s", num);
		if(num[0]=='0') break;
	
		while(num[i]!='\0'){
			//printf("%d\n", sum);
			sum += num[i]-'0';
			++i;
		}
		
		printf("%d\n", sum);
	}
	
	return 0;
}

Measured memory_bytes: 964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    string s[3];
    cin>>s[0]>>s[1]>>s[2];
    int i=0;
    int n[3]; n[0]=0; n[1]=0; n[2]=0;
    while(true){
        if(n[i]==s[i].size()){
            char ans='A'+i;
            cout<<ans<<endl;
            return 0;
        }
        char t=s[i][n[i]];
        n[i]++;
        if(t=='a'){
            i=0;
        }else if(t=='b'){
            i=1;
        }else{
            i=2;
        }
    }

}


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int n, q;
vector<vector<int>>graph;

void dfs(int v, int p, vector<ll>&res){
    if(p!=-1)res[v] += res[p];
    for(auto j:graph[v]){
        if(j == p)continue;
        dfs(j, v, res);
    }
}

int main() {
    cin >> n >> q;
    graph.assign(n, vector<int>());
    rep(i, 0, n-1){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    vector<ll>val(n, 0);
    rep(i, 0, q){
        int p, x;
        cin >> p >> x;
        p--;
        val[p] += x;
    }
    dfs(0, -1, val);
    rep(i, 0, n)cout << val[i] << " ";
    cout << endl;
    return 0;
}

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

int main() {
  ll n,m;
  cin >> n >> m;
  ll d[n+2],ans=1<<30;
  d[0]=0;
  d[n+1]=1<<30;
  for(int i=0,x; i<n; i++) {
    cin >> x;
    d[i+1]=x+d[i];
  }
  for(int i=0; i<n; i++) {
    ll x=lower_bound(d,d+n+1,d[i]+m)-d;
    if(x<=n) ans=min(ans,x-i);
  }
  if(ans==1<<30) ans=0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3884
#pragma GCC optimize(2)
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue<int, vector<int>, greater<int> > q;从小到大
#include <map>
#include <set> //multiset set<int,greater<int>>大到小
#include <vector>// vector<int>().swap(v);清空释放内存
#include <stack>
#include <cmath>
#include <utility>
#include <sstream>
#include <string>//__builtin_popcount(ans);//获取某个数二进制位1的个数
#define mod 1000000007
#define mod9 998244353
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
typedef long double ld;
const db eps=1e-7;
//const db pi=acos(-1);
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
#define rep(i,be,en) for (int i=be;i<=en;i++)
using namespace std;
const int N=1e6+7;

int T,n,m,fl=0;
int a[N];
ll sum=0,ans=0;
string s;
int main(){
    scanf("%d",&n);
    cin>>s;
    if(s.size()<=n){
        cout<<s;
    }else{
        cout<<s.substr(0,n)<<"...";
    }
}

Measured memory_bytes: 3172
import itertools
import collections
N,M = map(int, input().split())
A = [list(list(input().split())) for i in range(M)]
AList = list(itertools.chain.from_iterable(A))
cnt = collections.Counter(AList)
INF = 10**9+7
dp = [INF]*(N+1)
MOD = 10**9+7

def solve(val1, val2):
    if val1 == 0 and val2 == 0:
        print(0)
        exit()
    else:
        return val1 + val2

for i in range(N+1):
    if i == 0:
        dp[0] = 1
    elif i == 1:
        if cnt['1'] == 0:
            dp[1] = 1
        else:
            dp[1] = 0
    else:
        if cnt[str(i)] == 1:
            dp[i] = 0
        else:
            dp[i] = solve(dp[i-2], dp[i-1])
print(dp[N] % MOD)


Measured memory_bytes: 460404
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define N_MAX 200000
#define INF 1145141919
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;

int i, j;

int n, m;
int k, s;

int h, w;

char str[N_MAX];

void solve(){
	return;
}

int main (void) {
	int result;
	scanf("%d%d", &k, &s);
	for (i = 0; i <= k; i++) {
		if (i > s) break;
		if (s - i > k * 2) continue;
		if (s - i > k) {
			result += 2 * k + i -s +1;
		} else {
			result += s - i + 1;
		}
	}
	printf("%d\n", result);
	return 0;
}




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

int main() {
  // 変数設定
  int m; // 入力値
  int PRAVE_LAST_DATE_TIME = 24; // 12月30日の時間合計
  int LAST_DATE_TIME = 24; // 12月31日の時間数
  int result; // 出力結果
  
  // 入力
  cin >> m;
  
  // 計算処理
  result = PRAVE_LAST_DATE_TIME - m + LAST_DATE_TIME;
  
  // 出力
  cout << result << endl;
}

Measured memory_bytes: 256
s = input()
chars = []
a = None
a_count = 0
b = None
b_count = 0
fifty_fifty = True
for i in range(4):  
  if len(chars) == 0:
    chars.append(s[i])
    a = s[i]
    a_count += 1
  else:
    if s[i] not in chars:
      chars.append(s[i])
      b = s[i]
    if len(chars) > 2:
      fifty_fifty = False
    if s[i] == a:
      a_count += 1
    elif s[i] == b:
      b_count += 1
  
if fifty_fifty and a_count == b_count == 2:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  ll X;
  cin >> X;
  ll C = 100;
  int i = 0;
  while(true) {
    if(C >= X) {
      fin(i);
      return 0;
    }
    C = C + C / 100;
    i ++;
  }
  
  
}

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

int main() {
    int n,d;
    cin >> n >> d;

    int ans = 0;
    rep(i,n) {
        ll x,y;
        cin >> x >> y;

        if (sqrt(x*x+y*y) <= d) {
            ans++;
        }
    }

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

Measured memory_bytes: 3644
using System;

namespace Question2
{
    class Program
    {
        public const int ARRAY_AB = 2;

        static void Main(string[] args)
        {
            int[] ab = { 0, 0 };
            string[] readStr;

            readStr = Console.ReadLine().Split(' ');
            for (int i = 0; i < ARRAY_AB; i++)
            {
                ab[i] = int.Parse(readStr[i]);
            }

            if((ab[0]*ab[1] % 2) == 0)
            {
                Console.WriteLine("Even");
            }
            else
            {
                Console.WriteLine("Odd");
            }
        }
    }
}


Measured memory_bytes: 11092
int printf();
int scanf();
void *malloc ();

int main ()
{
    int n;
    int x;
    int *ans;
    int i;
    int j;
    scanf("%d %d", &n, &x);
    if (x == 1 || x == n * 2 - 1) {
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    if (n == 2) {
        printf("1\n2\n3\n");
        return 0;
    }
    ans = malloc(n * 2 * 4);
    if (x == 2) {
        *(ans + n - 3) = x + 1;
        *(ans + n - 2) = x - 1;
        *(ans + n - 1) = x;
        *(ans + n) = x + 2;
        i = 0;
        j = 1;
        while (i < n * 2 - 1) {
            if (j == x - 1)
                j = x + 3;
            if (i == n - 3)
                i = n + 1;

            *(ans + i) = j;
            i = i + 1;
            j = j + 1;
        }
    }
    else {
        *(ans + n - 3) = x - 1;
        *(ans + n - 2) = x + 1;
        *(ans + n - 1) = x;
        *(ans + n) = x - 2;
        i = 0;
        j = 1;
        while (i < n * 2 - 1) {
            if (j == x - 2)
                j = x + 2;
            if (i == n - 3)
                i = n + 1;

            *(ans + i) = j;
            i = i + 1;
            j = j + 1;
        }
    }
    i = 0;
    while (i < n * 2 - 1) {
        printf("%d\n", *(ans + i));
        i = i + 1;
    }
    return 0;
}


Measured memory_bytes: 2304
#include<stdio.h>
 
int main(void){
 
  int i;
  char moji;
  scanf("%c", &moji);
  
  if((moji>= 'a') && (moji<='z')){
    printf("a\n");
  }
  else if((moji>= 'A') && (moji<='Z')){
    printf("A\n");
  }

 
  return 0;
}

Measured memory_bytes: 1544
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long

const int mod=1e9+7;

int n,m,ans,now;

int main()
{
	scanf("%d%d",&n,&m);
	if(abs(n-m)>1)
	{
		puts("0");return 0; 
	}
	if(n>m) swap(n,m);now=ans=1;
	for(int i=1;i<=n;i++) ans=(ll)ans*i%mod;now=ans;
	for(int i=n+1;i<=m;i++) now=(ll)now*i%mod;ans=(ll)ans*now%mod;
	if(n==m) ans=(ll)ans*2%mod;
	printf("%d\n",ans);
}

Measured memory_bytes: 256
<?php
 
fscanf(STDIN, "%d", $n);
$task = [];
for($i=0;$i<$n;$i++){
    fscanf(STDIN, "%d %d", $a, $b);
    @$task[$b] = (int)($task[$b] + $a);
}
ksort($task);
$now = 0;
foreach ($task as $limit => $time){
    $now += $time;
    if($now > $limit){
        echo "No";
        exit;
    }
 
}
echo "Yes";

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int X;

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

  std::cin >> X;
  
  for(int i=0;i<=X;++i){
      if(100 * i <= X && X <= 100 * i + 5 * i){
          std::cout << 1 << std::endl;
          return 0;
      }
  }

  std::cout << 0 << std::endl;
}


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

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "YES" : "NO")

typedef pair <int, int> ii;
typedef pair <ii, int> iii;

const int siz = 2e5 + 10;
const int SIZ = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e12;
const string file = "2";



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

//    freopen ((file + ".inp").c_str(), "r", stdin);
//    freopen ((file + ".out").c_str(), "w", stdout);

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << max(max(a * c, b * c), max(a * d, b * d)) << "\n";

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


Measured memory_bytes: 3660
#include<stdio.h>
int n,k;
long long mem[55][2555];
main()
{
    int i,x,y,val;
    long long ans;
    scanf("%d%d",&n,&k);
    mem[0][0] = 1;
    for(i=0;i<n;i++)
    {
        scanf("%d",&val);
        for(x=n;x>=0;x--)
        {
            for(y=0;y<=2500;y++)
            {
                if(mem[x][y]) mem[x+1][y+val] += mem[x][y];
            }
        }
    }
    ans = 0;
    for(i=1;i<=n;i++) ans += mem[i][k*i];
    printf("%lld",ans);
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    int cnt=0;
    bool t=false;
    bool t2=true;
    for(int i=2;i<s.size()-1;i++){
        if(s[i]=='C'){
            t=true;
            cnt++;
        }
    }
    for(int i=0;i<s.size();i++){
        if(s[i]=='A' || s[i]=='C')
            continue;
        if(isupper(s[i]))
            t2=false;
    }
    if(s[0]=='A' && t && t2 && cnt==1){
        cout<<"AC";
    }else
    cout<<"WA";

    return 0;
}


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

int main()
{
	int a, b, i, x;
	float at, bt;
	scanf("%d %d", &a, &b);
	for (i = 0; i < 1100; i++) {
		at = floor(i * 1.08 - i);
		bt = floor(i * 1.1 - i);
		if (at == a && bt == b) {
			printf("%d", i);
			return 0;
		}
	}
	printf("-1");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  int n,q;
  cin>>n>>q;
  string s;
  cin>>s;

  vector<pair<char,char>> que;
  rep(i,q){
    string x,y;
    cin>>x>>y;
    que.push_back({x[0], y[0]});
  }
  
  auto sim = [&](int p){
    rep(i,q){
      if(s[p] == que[i].first){
        if(que[i].second == 'R') p++;
        else p--;
      }
      if(p<0) return -1;
      if(p>=n) return 1;
    }
    return 0;
  };

  int ans = n;

  // left
  {
    int l=-1, r=n;
    while(r-l>1){
      int m = (l+r)/2;
      if(sim(m) >= 0) r = m;
      else l = m;
    }
    ans -= r;
  }

  // right
  {
    int l=-1, r=n;
    while(r-l>1){
      int m = (l+r)/2;
      if(sim(m) <= 0) l = m;
      else r = m;
    }
    ans -= n-r;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String s  = sc.next();

		if(s.charAt(s.length() - 1) != 's') {
			System.out.println(s + "s");
		}else {
			System.out.println(s + "es");
		}



		sc.close();

	}

}


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

tasks = []
for _ in range(n):
	a, b = list(map(int, input().split()))
	c = b - 1
	tasks.append([a, b, c])

tasks.sort(key=lambda x: x[2])

now = 0
for task in tasks:
	now += task[0]
	if now > task[1]:
		print("No")
		break 
else:
	print("Yes")


Measured memory_bytes: 45284
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        string s;
        cin >> n >> s;
        if(n == 0)
            return 0;

        while(--n >= 0){
            ostringstream oss;
            int i = 0;
            while(i < s.size()){
                int j = i+1;
                while(j < s.size() && s[i] == s[j])
                    ++ j;
                oss << (j-i) << s[i];
                i = j;
            }
            s = oss.str();
        }

        cout << s << endl;
    }
}

Measured memory_bytes: 0
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	long long int n,t,time = 0,flag;
	long long int a[200005];
	scanf("%lld %lld",&n,&t);
	for(int i = 0; i < n ; i++)
	{
			scanf("%lld",&a[i]);
	}
	time = a[n-1] - a[0] + t; 
	for(int i = 0 ; i < n-1 ;i++)
	{
		if(a[i+1] - a[i] > t) time-=a[i+1]-a[i]-t;
	}
	printf("%lld",time);
	return 0;
} 


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        int C = NextInt();
        int[][] D = Enumerable.Range(0, C).Select(v => LineInt()).ToArray();
        int[][] c = Enumerable.Range(0, N).Select(v => LineInt()).ToArray();

        //それぞれを何色にするか決める
        int[,] data = new int[3, C];
        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++)
                data[((i + 1) + (j + 1)) % 3, c[i][j] - 1]++;

        //for (int k = 0; k < C; k++)
        //    for (int s = 0; s < C; s++)
        //        for (int u = 0; u < C; u++)
        //            D[s][u] = Math.Min(D[s][u], D[s][k] + D[k][u]);

        int ans = INF;
        for (int c0 = 0; c0 < C; c0++)
            for (int c1 = 0; c1 < C; c1++)
            {
                if (c0 == c1) continue;
                for (int c2 = 0; c2 < C; c2++)
                {
                    if (c0 == c2 || c1 == c2) continue;
                    int score = 0;
                    for (int i = 0; i < C; i++)
                    {
                        score += D[i][c0] * data[0, i];
                        score += D[i][c1] * data[1, i];
                        score += D[i][c2] * data[2, i];
                    }
                    ans = Math.Min(ans, score);
                }
            }
        Console.WriteLine(ans);

    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 18376
#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-7;
const int inf=1e8;
int main(){
	ll a,b;
	cin>>a>>b;
	ll out=0;
	if(a==0||b==0){
		if(a>b)out=1+abs(a-b);
		else out=abs(a-b);
	}else if(a*b<0){
		out=1+abs(abs(a)-abs(b));
	}else{
		if(a>b)out=2+abs(a-b);
		else out=abs(a-b);
	}
	cout<<out<<endl;
}










Measured memory_bytes: 764
using System;
//using System.Collections.Generic;
//using System.Collections;
//using System.Linq;

namespace solution
{
  class Class1
  {
    static void Main()
    {
      int n = int.Parse(Console.ReadLine());
      int count = 0;

      for (int i = 0; i < n; i++)
      {
        int x = int.Parse(Console.ReadLine());

        if (PrimeCheck(x) == true) count++;

      }
      Console.WriteLine(count);
    }

    static bool PrimeCheck(int x)
    {
      if (x == 2) return true;
      if (x % 2 == 0) return false;
      for (int i = 3; i <= Math.Sqrt(x); i += 2)
      {
        if (x % i == 0) return false;
      }
      return true;
    }
  }
}








Measured memory_bytes: 9100