akhauriyash/Code-Regression huggingface dataset:
var lines = [];
var B_counter, S, H, W
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    N = Number(lines[0].split(" ")[0]);
    X = Number(lines[0].split(" ")[1]);
    lines.shift();

    var M = lines.map(i => Number(i));
    M.sort((a, b) => a - b)
    for (var i = 0; i < N; i++) { X -= M[i]; }

    var ans = N;
    
    while (0 <= X) { X -= M[0]; ans++ }
    console.log(ans - 1)
});

Measured memory_bytes: 7756
N = int(input())
l = []
for i in range(N):
  s, p = input().split()
  l.append([s, int(p), i+1])

# 地名に関して辞書順に / 点数に関して降順に並べる
l = sorted(l, key=lambda x:(x[0], -x[1]))
for i in range(N):
  print(l[i][2])

Measured memory_bytes: 9024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main(){
	string s; cin>>s;
	vector<string> v;
	int k; cin >> k;
	rep(i,s.size()){
		rep(j,k){
			if (s.size() <= i+j) break;
			v.push_back(s.substr(i,j+1));
		}
	}
	set<string> ss(all(v));
	vector<string> vv(all(ss));
	cout << vv[k-1] << endl;
}


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

using namespace std;

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

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

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
  int a[10], b, c, n;
  bool judge;

  cin >> n;
  REP(i, n) {
    REP(j, 10) cin >> a[j];
    b = 0;
    c = 0;
    judge = true;
    REP(j, 10) {
      if(a[j] < b && a[j] < c) {
	judge = false;
	break;
      }
      else if(b < a[j] && c < a[j]) {
	if(b > c) b = a[j];
	else c = a[j];
      }
      else if(b < a[j] && c > a[j]) b = a[j];
      else if(b > a[j] && c < a[j]) c = a[j];
      else {
	if(b > c) b = a[j];
	else c = a[j];
      }
    }
    if(judge) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;
const int LOG = 22;
vector<int> G[100010];
int parent[25][100010];
int d[100010],n;
void dfs(int v, int p){
	for(int x:G[v]){
		if(x==p) continue;
		parent[0][x] = v;
		d[x] = d[v] + 1;
		dfs(x,v);
	}
}

void init(int v){
	d[v] = 0; parent[0][v] = -1;
	dfs(v,-1);
	for(int k=0;k+1<LOG;k++){
		for(int i=0;i<n;i++){
			if(parent[k][i]<0){
				parent[k+1][i] = -1;
			}else{
				parent[k+1][i] = parent[k][parent[k][i]];
			}
		}
	}
}

int lca(int u, int v){
	if(d[u]>d[v]) swap(u,v);
	for(int k = 0;k<LOG;k++){
		if((d[v] - d[u]) & (1<<k)){
			v = parent[k][v];
		}
	}
	if(u==v) return u;
	for(int k = LOG-1;k>=0;k--){
		if(parent[k][u]!=parent[k][v]){
			u = parent[k][u];
			v = parent[k][v];
		}
	}
	return parent[0][u];
}

int main(){
	int i,u,v;
	cin >> n >> u >> v;
	u--; v--;
	for(i=0;i<n - 1;i++){
		int x,y; cin >> x >> y;
		x--; y--;
		G[x].push_back(y); G[y].push_back(x);
	}
	init(v);
	int ans = 0;
	for(i=0;i<n;i++){
		int x = lca(u,i);
		if(d[x]>d[u] - d[x]){
			ans = max(ans,d[i] - 1);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 19712
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main(){
    ll x, ans;
    cin >> x;
    ll c = x/11;
    ans = c * 2;
    x -= 11*c;
    if(0 < x && x <= 6) ans++;
    else if(x != 0)ans += 2;
    cout << ans << endl;
}


Measured memory_bytes: 3608
class Point
  attr_reader :x, :y
  def initialize(position)
    @x = position[0]
    @y = position[1]
  end
end

class Line
  def initialize(point_one, point_two)
    @points = [point_one, point_two].sort{|one, two| one.x <=> two.x}
  end

  def y_of_intersection(x)
    x1 = @points[0].x
    x2 = @points[1].x
    y1 = @points[0].y
    y2 = @points[1].y
    return nil if x < x1 || x > x2
    return y1.to_f if x == x1
    return y2.to_f if x == x2
    additional_y = (y2 - y1).abs.to_f * (x - x1) / (x2 - x1)
    y1 > y2 ? y1 - additional_y : y1 + additional_y
  end

  def y_cut(low_x, high_x)
    y1 = y_of_intersection(low_x)
    y2 = y_of_intersection(high_x)
    return nil unless y1 && y2
    [y1, y2]
  end
end
while true
  point_number = gets.chomp.to_i
  break if point_number == 0
  points = []
  point_number.times do
    points.push(Point.new(gets.chomp.split(' ').map(&:to_i)))
  end
  points.push(points[0])
  lines = []
  points.each_cons(2) { |point_one, point_two|
    lines.push(Line.new(point_one, point_two))
  }
  max_x = points.max{|point_one, point_two| point_one.x <=> point_two.x }.x
  min_x = points.min{|point_one, point_two| point_one.x <=> point_two.x }.x
  area = 0
  (min_x..max_x).each_cons(2) do |xs|
    square_cuts = []
    crosses = lines.map { |line| line.y_cut(xs[0], xs[1])}
    sorted_crosses = crosses.compact.uniq.sort
    sorted_crosses.each_slice(2) do |two_lines|
      square_cuts.push([two_lines[0].min.floor, two_lines[1].max.ceil])
    end
    square_cuts.each.with_index do |cut, i|
      if i == 0
        area += (cut[1] - cut [0])
        next
      end
      former_end = square_cuts[i - 1][1]
      next if former_end >= cut[1]
      area += (cut[1] - [cut[0], former_end].max)
    end
  end
  puts area
end



Measured memory_bytes: 7932
n = int(input())
p = list(map(int,input().split()))

flg = 0
for i in range(0,len(p)):
    #print(i)
    if (p[i] != i + 1):
        flg += 1
       

if(flg > 2):
    print('NO')
else:
    print('YES')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
signed main() {
  ios::sync_with_stdio(false);
  int W, H; cin >> W >> H;
  vector<pair<int, char>> E;
  REP(i,W) {
    int cost; cin >> cost;
    E.emplace_back(cost, 'W');
  }
  REP(i,H) {
    int cost; cin >> cost;
    E.emplace_back(cost, 'H');
  }
  sort(E.begin(), E.end());
  int wc = 0, hc = 0;
  int ans = 0;
  for(pair<int, char> e : E) {
    if(e.second == 'W') {
      ans += e.first * (H + 1 - hc);
      wc++;
    }
    else {
      ans += e.first * (W + 1 - wc);
      hc++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4464
x, y = map(int, raw_input().split())
if x * y == 0 and x >= y:
    print x - y + 1
elif x * y == 0 and x < y:
    print y - x
elif x*y > 0 and x <= y:
    print y - x
elif x*y > 0 and x > y:
    print x - y + 2
else:
    print abs(abs(y) - abs(x)) + 1


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

int main() {
  ll N,x[100001],ans=0;
  cin>>N;
  int a[N];
  for(int i=0;i<N;i++) cin>>a[i];
  for(int i=0;i<100001;i++) x[i]=0;
  sort(a,a+N);
  for(int i=0;i<N;i++){
    x[a[i]]++;
  }
  for(int i=0;i<99999;i++) ans=max(ans,x[i]+x[i+1]+x[i+2]);
  cout<<ans<<endl;
}	


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

using namespace std;
using ll = long long;

int main() {

	ll a, b;
    cin>>a>>b;
	function<ll(ll, ll)> gcd = [&] (ll a, ll b) -> ll {
			if (b%a == 0) {
				return a;
			}
			
			return gcd(b%a, a);
	};

	if (a > b) {
		swap(a, b);
	}
	
	cout<<(a*b)/gcd(a, b)<<endl;

    return 0;
}


Measured memory_bytes: 256
## coding: UTF-8
s = input().split()
t = [int(p) for p in s]
#print(t)

'''
#print(max(t))
count = 0
for i in range(1, max(t)+1):
    if(t[0] < i and i <= t[1] and t[2] < i and i <= t[3]):
        count += 1
print(count)
'''

start = max(t[0], t[2])
goal = min(t[1], t[3])
time = max(0, goal - start)
#print(start)
#print(goal)
print(time)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    string s; cin >> s;
    int n = s.size();

    string s_nonx;

    rep(i, n){
        if(s[i] != 'x'){
            s_nonx.push_back(s[i]);
        }
    }

    int n_nonx = s_nonx.size();

    rep(i, n_nonx / 2 + 1){
        if(s_nonx[i] != s_nonx[n_nonx - 1 - i]){
            cout << -1 << endl;
            return 0;
        }
    }

    int n_search = 0;
    if(n_nonx % 2 == 0){
        n_search = n_nonx / 2;
    }
    else{
        n_search = n_nonx / 2 + 1;
    }

    int index = 0;
    int cnt_nonx = 0;
    int cnt_x = 0;
    vector<int> vec1;
    while(1){
        if(s[index] != 'x'){
            vec1.push_back(cnt_x);
            cnt_x = 0;
            cnt_nonx++;
        }
        else{
            cnt_x++;
        }

        if(cnt_nonx >= n_search){
            break;
        }
        index++;
    }

    index = n - 1;
    cnt_nonx = 0;
    cnt_x = 0;
    vector<int> vec2;
    while(1){
        if(s[index] != 'x'){
            vec2.push_back(cnt_x);
            cnt_x = 0;
            cnt_nonx++;
        }
        else{
            cnt_x++;
        }

        if(cnt_nonx >= n_search){
            break;
        }

        index--;
    }

    int ans = 0;
    rep(i, vec1.size()){
        ans += abs(vec1[i] - vec2[i]);
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const int INF = 1e9;
int par[100000]; //親
int rnk[100000]; //木の深さ

				 //n要素で初期化
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		rnk[i] = 0;
	}
}
//木のrootを求める
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

//xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (rnk[x] < rnk[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rnk[x] == rnk[y])rnk[x]++;
	}
}

//xとyが同じ集合に属するかどうか
bool same(int x, int y) {
	return find(x) == find(y);
}

int main() {
	cin.sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	int ans = 0;
	vector<int>a(M), b(M);
	rep(i, M) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}
	rep(i, M) {
		init(N);
		rep(j, M) {
			if (j == i)continue;
			unite(a[j], b[j]);
		}
		rep(j, N) {
			if (!same(0, j)) {
				ans++;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
	long long int a, b;
	cin >> a >> b;

	if (a == 0 || b == 0||(a<0&&0<b)) {
		cout << "Zero";
		return 0;
	}
	if (0 < a || a==b) {
		cout << "Positive";
		return 0;
	}
	
	if ((b - a) % 2 == 0) {
		cout << "Negative";
	}else{
		cout << "Positive";
    }

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<vector<int>> v1(n,vector<int>(3,0)),v2(n,vector<int>(3,0));
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      cin>>v1[i][j];
    }
  }
  for(int i=1;i<n;i++){
    v1[i][0]=max(v1[i-1][1],v1[i-1][2])+v1[i][0];
    v1[i][1]=max(v1[i-1][0],v1[i-1][2])+v1[i][1];
    v1[i][2]=max(v1[i-1][0],v1[i-1][1])+v1[i][2];
  }
  int maxi=INT_MIN;
  for(int i=0;i<3;i++){
    maxi=max(v1[n-1][i],maxi);
  }
  cout<<maxi;
}

Measured memory_bytes: 11136
n, k = map(int, input().split())
a = list(map(int, input().split()))

cs_a, cnt = [0] * n, 0
for i in range(n):
    cnt += a[i]
    cs_a[i] = cnt
dp = [[0] * (k + 1) for i in range(n + 1)]

for i in range(n + 1):
    for j in range(k + 1):
        if j == 0:
            dp[i][j] = 1
        elif (i == 0) or (j > cs_a[i - 1]):
            dp[i][j] = 0
        elif j == 1:
            dp[i][j] = dp[i - 1][j] + min(a[i - 1], 1)
        elif j - a[i - 1] - 1 < 0:
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1]
        else:
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - a[i - 1] - 1]
        dp[i][j] %= 10 ** 9 + 7

print(dp[n][k])


Measured memory_bytes: 120924
# 

l = list(input())
#print(l)
m = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
#print(m)

x = 0
for j in l:
    if j in m:
        x += 1

a = 0
for i in range(2,len(l)-1):
    if l[i] == 'C':
        a += 1
if a == 1 and l[0] == 'A' and x == 2:
    print('AC')
else:
    print('WA')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353
#define MEM_SIZE 101010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template <typename T>
void DEBUG(T e)
{
  if (DEBUG_OUT == false)
    return;
  std::cout << e << " ";
}
template <typename T>
void DEBUG(const std::vector<T> &v)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &e : v)
  {
    std::cout << e << " ";
  }
  std::cout << std::endl;
}
template <typename T>
void DEBUG(const std::vector<std::vector<T>> &vv)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &v : vv)
  {
    DEBUG(v);
  }
}
template <class T, class... Ts>
void DEBUG(T d, Ts... e)
{
  if (DEBUG_OUT == false)
    return;
  DEBUG(d);
  DEBUG(e...);
}
template <class T>
void corner(bool flg, T hoge)
{
  if (flg)
  {
    cout << hoge << endl;
    abort();
  }
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  //https://kimiyuki.net/writeup/algo/atcoder/agc_009_b/
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; i++)
  {
    int x;
    cin >> x;
    x--;
    g[x].push_back(i + 1);
  }
  vector<int> dp(n + 1, 0);

  function<void(int)> go = [&](int i) {
    if (g[i].empty())
      return;
    vector<int> acc;

    for (auto &&j : g[i])
    {
      go(j);
      acc.push_back(dp[j]);
    }
    sort(ALL(acc));
    reverse(ALL(acc));
    for (int i = 0; i < acc.size(); i++)
    {
      acc[i] += i + 1;
    }
    dp[i] = *max_element(ALL(acc));
  };
  go(0);
  cout << dp[0] << endl;

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 21772
#include<bits/stdc++.h>
using namespace std;
int n,T,a,b,Min=100000;

int main()
{
	cin>>n>>T;
	for(int i=1; i<=n; i++)
	{
		cin>>a>>b;
		if(b<=T) Min=min(Min, a);
	}
	if(Min == 100000)
		cout<<"TLE"<<endl;
	else
		cout<<Min<<endl;
	return 0;
}

Measured memory_bytes: 256
def searchstring(s) : 
  start = ord('a')
  end = ord('z')
  stringlist = [0] * 256
  for i in range(len(s)) : 
    stringlist[ord(s[i])] += 1
  for i in range(start, end + 1) : 
    if stringlist[i] == 0 : 
      return chr(i)
  return None



s = input()

print(searchstring(s))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define f(i,a,n) for(i=a;i<n;i++)
#define rf(i,a,n) for(i=a;i>=n;i--)
#define ll long long
#define pii pair<int,int>
#define pll pair<long long,long long>
#define vi vector<int>
#define vll vector<long long>
#define umii unordered_map<int,int>
#define umci unordered_map<char,int>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define all(v) begin(v),end(v)
#define mkp make_pair
#define setn1(a)  memset(a,-1,sizeof(a))
#define set0(a) memset(a,0,sizeof(a))
#define setl(b) memset(a,1000000001,sizeof(a))
#define M 1000000007
#define I 1000000000000000001
#define TakeInput freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);freopen("error.txt","w",stderr);


using namespace std;

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

int main()
{
	#ifndef ONLINE_JUDGE
	//TakeInput
	#endif
	fast;
	ll n,k,i,j;
	cin >> n >> k;
	ll a[n];
	f(i,0,n)
	{
		cin >> a[i];
	}
	sort(a,a+n);
	ll sum=0;
	f(i,0,n-k)
		sum += a[i];
	cout << sum;
	return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.Arrays;
public class Main
{
	public static void main(String args[])
	{
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int k = s.nextInt();
		int fruits[] = new int[n];
		for(int i=0;i<n;i++) fruits[i] = s.nextInt();
		solver(fruits,k);
	}
	private static void solver(int arr[],int k)
	{
		int min = 0;
		Arrays.sort(arr);
		for(int i=0;i<k;i++) min = min+arr[i];
		System.out.println(min); 
	}
}

Measured memory_bytes: 38880
#0<=i<r,0<=j<cで総和求めて引く
#chooseの+2でよい
mod = 10**9+7

def chs(a,b):
    a+=1;b+=1
    a+=b
    res = 1
    for i in range(a,a-b,-1):
        res *= i 
        res%=mod
    for i in range(1,b+1):
        res *= rev[i]
        #print(rev[i],pow(i,mod-2,mod))
        res %=mod 
    return res


r1,c1,r2,c2 = map(int, input().split( ))
r1 -=1;c1-=1
if c2>r2:
    r2,c2 = c2,r2
    r1,c1= c1,r1
rev = [pow(i,mod-2,mod) for i in range(c2+5)]###
ans = chs(r2,c2)-chs(r1,c2)-chs(r2,c1)+chs(r1,c1)
ans%=mod
#print(chs(r2,c2),chs(r1,c2),chs(r2,c1),chs(r1,c1))

print(ans)

Measured memory_bytes: 114160
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

ll N, A, B, C, D;

int main() {
    fastio();
    cin >> N >> A >> B >> C >> D;
    ll tmp, r = (N - 1) * C, l = (N - 1) * D;
    ll target = B - A + l;
    ll diff = l - r;
    REP(i, N-1) {
        tmp = i*(D+C);
        if(tmp <= target && target <= tmp + diff) {
            cout << "YES\n";
            return 0;
        }
    }
    cout << "NO\n";
	return 0;
}

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

int main() {
  string A;
  cin >> A;
  int c = 0;
  if (A[0] =='1') c++;
  if (A[1] =='1') c++;
  if (A[2] =='1') c++;
  cout << c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
/*太郎と花子がカードゲームをする。二人はそれぞれn枚のカードを持っており、nターンの勝負を行う。各ターンではそれぞれ１枚ずつカードを出す。カードにはアルファベットからなる動物の名前が書かれており、辞書順で大きいものがそのターンの勝者となる。勝者には３ポイント、引き分けの場合にはそれぞれ１ポイントが加算される。
太郎と花子の手持ちのカードの情報を読み込み、ゲーム終了後のそれぞれの得点を出力するプログラムを作成せよ。*/
using namespace std;

int main(){
	int taro = 0, hanako = 0;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		string tCard, hCard;
		cin >> tCard >> hCard;
		if(tCard.compare(hCard) > 0){
			taro += 3;
		}else if(tCard.compare(hCard) < 0){
			hanako += 3;
		}else{
			taro ++;
			hanako ++;
		}
	}
	cout << taro << ' ' << hanako << endl;
}



Measured memory_bytes: 3112
def dfs(i,sum1,sum2):
    global ans
    if i == 4 and sum1 != 7:
        return 0
    elif i == 4 and sum1 == 7:
        ans = sum2 + "=7"
        return 0
    else:
        dfs(i + 1,sum1 + int(s[i]),sum2 + "+" + s[i])
        dfs(i + 1, sum1 - int(s[i]), sum2 + "-" + s[i])

s = input()
ans = ""
dfs(1,int(s[0]),s[0])
print(ans)


Measured memory_bytes: 9132
#include<stdio.h>

int max(int a,int b){
  if(a>=b){
    return a;
  }else{
    return b;
  }
}

int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  int q=max(a+b,2*a-1);
  int p=max(q,2*b-1);
  printf("%d\n",p);
  return 0;
}

Measured memory_bytes: 1644
#include <iostream>
long long gcd(long long x,long long y)
{
    return x%y==0?y:gcd(y,x%y);
}
int main()
{
    int n,i;
    long long s,sum=1,x;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%lld",&x);
        s=gcd(sum,x);
        sum=sum/s*x;
    }
    printf("%lld\n",sum);
    return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
#define pqasc priority_queue<long long, vector<long long>, greater<long long>>

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ul = unsigned long;

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

class UnionFind{
private:
  vector<int> Parent; 
 public:
  UnionFind(int N){
    Parent = vector<int>(N, -1);
  }
  
  int root(int A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  int size(int A){
    return -Parent[root(A)]; 
  }
  
  bool connect(int A, int B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(int A, int B){
    return root(A) == root(B);
  }
};

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 int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n,m; cin>>n>>m;
  vi p(n);
  rep(i,n){
    cin>>p[i]; p[i]--;
  }
  
  auto uf=UnionFind(n);
  rep(i,m){
    int x,y; cin>>x>>y; x--,y--;
    uf.connect(x,y);
  }
  
  int ans=0;
  rep(i,n){
    if(uf.root(i)==uf.root(p[i])) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

unordered_map <string, ll> s;

int main() {
   

    ll n;
    cin >> n;
    ll ans = 0;
    ll low;
    for (ll i=0;i<n;i++){
        ll tmp;
        cin >> tmp;
        if(i==0){
            low = tmp;
        }
        if(low > tmp){
            low = tmp;
        }
        if(low >= tmp){
            ans++;
        }
    }
    cout << ans << endl;


}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=200000;

int n;
int v[2*MAXN];
pair<int,int> p[2*MAXN];
int cnt[MAXN];

ll solve() {
	int mx=v[0],mn=v[0],mxi=0,mni=0; FOR(i,1,2*n) { if(v[i]>mx) mx=v[i],mxi=i; if(v[i]<mn) mn=v[i],mni=i; }
	if(mn==mx) return 0;
	ll ret=LLONG_MAX;
	{
		int maxr=mx,minb=mn,minr=mx,maxb=mn;
		REP(i,n) { int b=min(v[2*i],v[2*i+1]),r=v[2*i]+v[2*i+1]-b; if(b>maxb) maxb=b; if(r<minr) minr=r; }
		ll cur=(ll)(maxr-minr)*(maxb-minb); if(cur<ret) ret=cur;
	}
	if(mxi!=(mni^1)) {
		int maxr=mx,minr=mn;
		REP(i,2*n) p[i]=MP(v[i],i/2); sort(p,p+2*n);
		memset(cnt,0,sizeof(cnt));
		int l=0,r=0,have=0;
		while(true) {
			if(have<n) {
				if(r>=2*n) break;
				if(cnt[p[r++].second]++==0) ++have;
			} else {
				int minb=p[l].first,maxb=p[r-1].first;
				ll cur=(ll)(maxr-minr)*(maxb-minb); if(cur<ret) ret=cur;
				if(--cnt[p[l++].second]==0) --have;
			}
		}
	}
	return ret;
}

void run() {
	scanf("%d",&n);
	REP(i,2*n) scanf("%d",&v[i]);
	printf("%lld\n",solve());
}

int main() {
	run();
	return 0;
}


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

using namespace std;

#define ll long long

const ll mod = (ll)1e9 + 7;

int** solve(int n) {
	int** ans = new int* [n + 1];
	for (int i = 0; i <= n; ++i) {
		ans[i] = new int[n + 1];
		for (int j = 0; j <= n; ++j)
			ans[i][j] = 0;
	}
	if (n == 2) {
		ans[1][2] = 1;
		return ans;
	}
	if (n == 3) {
		ans[1][2] = ans[1][3] = 1;
		ans[2][3] = 2;
		return ans;
	}
	if (n % 2 == 0) {
		int** tmp = solve(n / 2);
		for (int i = 1; i < n; ++i) {
			for (int j = i + 1; j <= n; ++j) {
				if (i % 2 != j % 2)
					ans[i][j] = 1;
				else if (i % 2 == 1) {
					ans[i][j] = tmp[(i + 1) / 2][(j + 1) / 2] + 1;
				}
				else {
					ans[i][j] = tmp[i / 2][j / 2] + 1;
				}
			}
		}
		return ans;
	}
	int** tmp1 = solve((n + 1) / 2); // 黒
	int** tmp2 = solve(n / 2); // 白
	for (int i = 1; i < n; ++i) {
		for (int j = i + 1; j <= n; ++j) {
			if (i % 2 != j % 2)
				ans[i][j] = 1;
			else if (i % 2 == 1) {
				ans[i][j] = tmp1[(i + 1) / 2][(j + 1) / 2] + 1;
			}
			else {
				ans[i][j] = tmp2[i / 2][j / 2] + 1;
			}
		}
	}
	return ans;
}

signed main() {
	int n; cin >> n;
	int** ans = solve(n);
	for (int i = 1; i < n; ++i) {
		for (int j = i + 1; j <= n; ++j)
			cout << ans[i][j] << " ";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1920
function main(input) {
    var nums = input.split('\n')[1].split(' ');

    var count = 0;
    while(nums.every((n) => (n % 2) === 0)) {
        count++;
        nums = nums.map((n) => n / 2);
    }
    
    console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll,ll>;
using vb = vector<bool>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define FORD(i,a,b) for (int i=int(b)-1; i>=(a); i--)

int main() {
	ll n;
	cin >> n;
	vl v(n);
	ll h = LLONG_MIN;
	ll hi = -1;
	FOR(i,0,n) {
		cin >> v[i];
		if (abs(v[i]) > h) {
			h = max(h, abs(v[i]));
			hi = i;
		}
	}
	if (h == 0) {
		cout << 0 << endl;
		return 0;
	}
	vector<pll> r;
	if (v[hi] > 0) {
		FOR(i, 1, n) {
			while (v[i] < v[i-1]) {
				v[i] += h;
				r.pb(mp(hi+1, i+1));
				if (v[i] > h) {
					h = v[i];
					hi = i;
				}
			}
		}
	} else {
		FORD(i, 0, n-1) {
			while (v[i] > v[i+1]) {
				v[i] -= h;
				r.pb(mp(hi+1, i+1));
				if (abs(v[i]) > h) {
					h = abs(v[i]);
					hi = i;
				}
			}
		}
	}
	cout << r.size() << endl;
	for (pll & p : r) {
		cout << p.first << " " << p.second << endl;
	}
}

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

int x,y,t;
int n,a,b,c;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) {
		cin>>c>>a>>b;
		int sum=abs(a-x)+abs(b-y),ti=c-t;
		if(sum>ti||(sum%2!=ti%2)) { cout<<"No"<<endl; return 0; }
		x=a,y=b,t=c;
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//戻る作業は必要ない。その飛び方を使うか使わないかが問題→時刻iまでではiまでの総和以下の数値分の移動は実現可能。

int main() {
  int X,ans;

  cin >> X ;

  for(int i=1;i<=X;i++){
    int s=i*(i+1)/2;
    if(X<=s){ans=i; break;}
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

char num[200000];

int main()
{
	scanf("%s", num);
	int len = strlen(num);
	int cnt1 = 0, cnt2 = 0;
	for (int i = 0; i < len; i++) {
		if (i % 2 != (num[i] - '0'))
			cnt1++;
		if ((i + 1) % 2 != (num[i] - '0'))
			cnt2++;
	}
	printf("%d", min(cnt1, cnt2));
	return 0;
}

Measured memory_bytes: 384
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::max;
use std::collections::HashMap;
fn main() {
    input!{
        x: String,
        y: String,
    }
    let mut m = HashMap::new();
    m.insert("A".to_string(), 0);
    m.insert("B".to_string(), 1);
    m.insert("C".to_string(), 2);
    m.insert("D".to_string(), 3);
    m.insert("E".to_string(), 4);
    m.insert("F".to_string(), 5);
    let x = m[&x.to_string()];
    let y = m[&y.to_string()];

    println!(
        "{}",
        if x < y {
            "<"
        } else if x > y {
            ">"
        } else {
            "="
        }
    );
}


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

#define ALL(x) x.begin(), x.end()

using namespace std;

typedef long long int lld;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(15);
    cout << fixed;

    int n;
    cin >> n;

    vector<pii> v(n);

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

    sort(ALL(v));

    for (int i = 0; i < n; i++) {
        cout << v[i].second << ' ';
    }
    cout << '\n';




    
    return 0;
}

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

s = [input() for i in range(n)]

c = [0, 0, 0, 0]

for i in range(n):
    if s[i] == 'AC':
        c[0] += 1
    elif s[i] == 'WA':
        c[1] += 1
    elif s[i] == 'TLE':
        c[2] += 1
    else:
        c[3] += 1


print('AC x ' + str(c[0]))
print('WA x ' + str(c[1]))
print('TLE x ' + str(c[2]))
print('RE x ' + str(c[3]))


Measured memory_bytes: 16328
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
using namespace std;
using ll = long long;
const int INF = 1e18L + 5;

void min_self(ll& a, ll b){
    a= min(a, b);
}

int main(){
    ll n,w;
    cin>>n>>w;
    vector<ll> weight(n), value(n);
    for(ll i = 0; i < n; i++){
        cin>>weight[i]>>value[i];
    }
    ll sum_value = 0;
    for(ll i = 0; i < n; i++){
        sum_value = sum_value + value[i];
    }
    vector<ll> dp(sum_value + 1, INF);
    dp[0]=0;
    for(ll item = 0; item < n; item++){
        for(ll value_already = sum_value - value[item]; value_already >= 0; value_already--){
            min_self(dp[value_already + value[item]], dp[value_already] + weight[item]);
        }
    }
        ll answer = 0;
        for(ll i = 0; i <= sum_value; i++){
            if(dp[i] <= w){
                answer = max(answer, i);
            }
        }
cout<<answer;

    return 0;
}



Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N, D = MI()

ans = 0
for _ in range(N):
    X, Y = MI()
    if X ** 2 + Y ** 2 <= D ** 2:
        ans += 1
print(ans)

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

typedef long long ll;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define REPM(i,n) for(ll i=(n-1); 0=<i; i--)
#define VI vector<int>
#define VL vector<ll>
#define VD vector<double>
#define VS vector<string>
#define V_SORT_U(x) sort(x.begin(), x.end());
#define V_SORT_D(x) sort(x.begin(), x.end(),greater<int>());
#define V_SUM(x) accumulate(x.begin(), x.end(), 0)
#define STR_TRANS_UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define STR_TRANS_LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);

int main(void){
    ll N;
    ll M;
    cin >> N >> M;

    VL A_i(M);

    REP(i,M)
    {
        cin >> A_i.at(i);
    }

    ll sum;
    sum = V_SUM(A_i);

    if(N >= sum)
    {
        cout << (N-sum) << endl;
    }
    else
    {
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3708
/*
#include<iostream>
#include<cmath>
using namespace std;

bool dic[1300000000] = {false};

int main() {
    int n, i, j, k;
    unsigned long long idx;
    char command[13];
    char element[13];
    char cur;
    cin >> n;
    for (i=0; i<n; i++) {
        cin >> command >> element;
        j = 0;
        while (element[j] != '\0') {
            j++;
        }
        j--;
        idx = 0;
        for (k=j; k>=0; k--) {
            if (element[j-k] == 'A') idx += 1 * int(pow(4.0, k));
            else if (element[j-k] == 'C') idx += 2 * int(pow(4.0, k));
            else if (element[j-k] == 'G') idx += 3 * int(pow(4.0, k));
            else idx += 4 * int(pow(4.0, k));
        }
        if (command[0] == 'i') {
            dic[idx] = true;
            // cout << idx << endl;
        }
        else {
            if (dic[idx]) cout << "yes\n";
            else cout << "no\n";
            // cout << idx << endl;
        }
    }
}
*/

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

// 文字から数値に変換
int getChar(char ch) {
    if (ch == 'A') return 1;
    else if (ch == 'C') return 2;
    else if (ch == 'G') return 3;
    else if (ch == 'T') return 4;
    else return 0;
}

// 文字列から数値へ変換してkeyを生成する
long long getKey(char str[]) {
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++) {
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key){return key % M;}
int h2(int key){return 1 + (key % (M - 1));}

int find(char str[]) {
    long long key, i, h;
    key = getKey(str);  // 文字列を数値に変換
    for (i = 0; ; i++) {
        h = (h1(key) + i*h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0) return 0;
    }
    return 0;
}

int insert(char str[]) {
    long long key, i, h;
    key = getKey(str);  // 文字列を数値に変換
    for (i = 0; ; i++) {
        h = (h1(key) + i*h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main() {
    int i, n, h;
    char str[L], com[9];
    for (i = 0; i < M; i++) H[i][0] = '\0';
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%s %s", com, str);   // より高速な入力scanfを使用
        if (com[0] == 'i') {
            insert(str);
        }
        else {
            if (find(str)) {
                printf("yes\n");
            }
            else {
                printf("no\n");
            }
        }
    }
    return 0;
}


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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int foo = b - a;
    int aa = foo * (foo - 1) / 2;
    int bb = foo * (foo + 1) / 2;
    assert(aa - a == bb - b);
    cout << aa - a << endl;
}


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

int solve(){
    int n;
    string s;
    cin>>n>>s;
    rep(i,n-1){
        if(s[i]=='x' && s[i+1]=='x'){
            return i+1;
        }
    }
    return n;
}

int main(void){
    cout<<solve()<<endl;
    return 0;
}



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

using namespace std;

int main(){
  int n;
  long long k;
  cin >> n >> k;
  
  vector<long long> a(n);
  vector<long long> f(n);
  
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n; i++) cin >> f[i];
  
  sort(a.begin(), a.end());
  sort(f.rbegin(), f.rend());
  
  long long t = 1e12;
  long long b = 0;
  long long c = (t + b) / 2;
  long long x = t;
  
  while(t - b > 0){
    long long s = 0;
    for(int i = 0; i < n; i++){
      s += max(a[i] - c / f[i], 0ll);
    }
    if(s <= k){
      x = c;
      t = c;
    }else{
      b = c + 1;
    }
    
    c = (t + b) / 2;
  }
  
  cout << x << endl;
  
  return 0;
}

Measured memory_bytes: 3328
# A - Sandglass2

# X 秒 図れる砂時計がある
# 上のパーツに X[g] 砂がある。　1秒に1[g]砂が落ちる。

# t 秒後に上のパーツに残っている砂は何[g]？

# X t を標準入力から得る
X, t = map(int, input().split())
# print(X, t)

# t <= X の時 X - t
# それ以外は、0 を代入
if t <= X:
    answer = X - t
else:
    answer = 0

# 結果を出力
print(answer)


Measured memory_bytes: 9144
H,W,M = map(int, input().split())

hs = [0] * H
ws = [0] * W
s = set()

for i in range(M):
  h,w = map(int, input().split())
  h -= 1
  w -= 1
  hs[h] += 1
  ws[w] += 1
  s.add((h,w))

mh = 0
mw = 0
for i in range(H):
  mh = max(mh, hs[i])
for j in range(W):
  mw = max(mw, ws[j])
  
l_s = list()
j_s = list()
for i in range(H):
  if mh == hs[i]:
    l_s.append(i)
for j in range(W):
  if mw == ws[j]:
    j_s.append(j)
    
ans = mh+mw
for i in l_s:
  for j in j_s:
    if (i,j) in s:
      continue
    print(ans)
    exit()
ans -= 1
print(ans)

Measured memory_bytes: 83332
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();

    if(N%K==0){
		System.out.println("0");	 
    }else{
		System.out.println("1");	    
	}
}
}


Measured memory_bytes: 22484
long n,a[3][1<<18],b,c,x,y,N[1<<18],M[1<<18],i,j;main(){scanf("%d",&n);for(i=0;i<3;++i)for(j=0;j++<n;scanf("%d",&a[i][j-1]),--a[i][j-1]){}for(i=0;i<n;++i){if(a[0][i]/3!=a[1][i]/3||a[1][i]/3!=a[2][i]/3||a[2][i]/3!=a[0][i]/3||a[1][i]%3!=1||(a[1][i]/3-i)%2){puts("No");return 0;}x=a[1][i]/3+1;while(x){if(i&1)c-=M[x];else b-=N[x];x-=x&-x;}if(i&1)c+=i/2;else b+=i/2;y=a[2][i]/3+1;while (y<1<<18){if(i&1)++M[y];else ++N[y];y+=y&-y;}if(a[0][i]%3){if(i&1)++b;else++c;}}puts((b&1)||(c&1)?"No":"Yes");}

Measured memory_bytes: 5604
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <functional>
#include <list>
#include <iomanip>
#include <cctype>
#include <math.h>
#include <utility>
#include <numeric>

#define REP(i,first,end) for(int i = first; i < end; i++)
#define rep(i,end) for(int i = 0; i < end; i++)

typedef long long ll;
#define mod =1000000007;

using namespace std;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a>>b>>c;
    
    cout << min(b/a,c) << endl;
}






Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;


typedef long long ll;

void insertionSort(vector<int>& nums, int n, int g, ll& cnt) {
  for (int i = g; i < n; ++i) {
    int v = nums[i];
    int j = i - g;
    while (j >= 0 && nums[j] > v) {
      nums[j + g] = nums[j];
      j -= g;
      ++cnt;
    }
    nums[j + g] = v;
  }
}

void solve(vector<int>& nums, int n) {
  vector<int> gaps;  
  for (int h = 1; h <= n;) {
    gaps.push_back(h);
    h = 3*h + 1;
  }
  reverse(gaps.begin(), gaps.end());

  ll cnt = 0;
  for (size_t i = 0; i < gaps.size(); ++i) {
    insertionSort(nums, n, gaps[i], cnt);
  }

  printf("%ld\n", gaps.size());
  for (size_t i = 0; i < gaps.size(); ++i) {
    if (i > 0) printf(" ");
    printf("%d", gaps[i]);
  }
  printf("\n");
  printf("%lld\n", cnt);
  for (size_t i = 0; i < nums.size(); ++i) {
    printf("%d\n", nums[i]);
  }
}

int main() {

  int n;
  scanf("%d", &n);

  vector<int> nums;
  for (int i = 0; i < n; ++i) {
    int num;
    scanf("%d", &num);
    nums.push_back(num);
  }

  solve(nums, n);
  return 0;
}



Measured memory_bytes: 6484
import sys
read = sys.stdin.readline
import time
import math
import itertools as it
def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
start_time = time.perf_counter()
# ------------------------------

N, D = inpl()
ans = 0
D = D**2
for i in range(N):
    X, Y = inpl()
    l = X**2 + Y**2
    if l <= D:
        ans+=1
print(ans)

# -----------------------------
end_time = time.perf_counter()
print('time:', end_time-start_time, file=sys.stderr)

Measured memory_bytes: 9212
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	cin >> s;
	int n;
	n = s.size();
	if (s[n - 1] == 's')
		cout << s << "es" << endl;
	else if (s[n - 1] != 's')
		cout << s << "s" << endl;
	return 0;
}

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

int main() {
  int N; 
  cin >> N;
  
  string S[N];
  map<string, int> Map;
  // 文字列を読み込み，何が何回か出たか辞書を作る
  for (int i = 0; i < N; i++){
    string S;
    cin >> S;
    
    Map[S]++;
  }

  
  // 辞書を一つずつ読み込んで，最大回数を調べる．
  int MAX = 0;
  for (auto s = Map.begin(); s != Map.end(); s++) {
    if (s->second > MAX) MAX = s->second;
  }
  
  // 辞書をもう一度一つずつ読み込んで，最大回数登場した単語を拾って vec を作る
  vector<string> vec;
  for (auto s = Map.begin(); s != Map.end(); s++) {
    if (s->second == MAX) vec.push_back(s->first);
  }
  
  // vecをsortする．
  sort(vec.begin(), vec.end());
  
  // vecを順番に出力する
  for (int i = 0; i < vec.size(); i++) {
    cout << vec.at(i) << endl;
  }
  
}

Measured memory_bytes: 28404
import java.util.Scanner;

public class Main {

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

	    int r=gi();
	    int g=gi();
	    int b=gi();



        //System.out.println(c);
        if (((r*100+g*10+b)%4) == 0) {
        	System.out.print("YES");
        }else{
            System.out.print("NO");
        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
}

Measured memory_bytes: 35432
N, M = map(int, input().split())
AB = [ list(map(int, input().split())) for i in range(N)]

AB.sort()
sum = 0

for ab in AB:
    if M <= ab[1]:
        sum += ab[0] * M
        print(sum)
        exit()
    else:
        sum += ab[0] * ab[1]
        M -= ab[1]


Measured memory_bytes: 27760
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int n;
double a[66];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    for(int i=1;i<n;i++) a[i] = (a[i]+a[i-1])/2;
    printf("%.20f\n",a[n-1]);
    return 0;
}


Measured memory_bytes: 384