akhauriyash/Code-Regression huggingface dataset:
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import bisect
import sys
input = sys.stdin.readline

setrecursionlimit(1000000)

dp = defaultdict(lambda x:-1)

def main():
	a,b = map(int,input().split())
	if(a-b*2 > 0):
		print(a-b*2)
	else:
		print(0)
	

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


Measured memory_bytes: 65004
#include<bits/stdc++.h>
#define INF "{"
#define M 500
#define N 40
using namespace std;
typedef pair<int,string> P;
typedef pair<string,int> P1;

int n,m,s,g;
vector<P> G[N];
string d[N][M];

void init(){
  for(int i=0;i<N;i++)
    for(int j=0;j<M;j++) d[i][j]=INF;
  for(int i=0;i<N;i++) G[i].clear();
}

string dijkstra(){
  priority_queue<P1,vector<P1>,greater<P1> > q;
  
  for(int i=0;i<G[s].size();i++){
    int nx=G[s][i].first;
    string ncost=G[s][i].second;
    q.push(P1(ncost,nx));
  }
  
  while(!q.empty()){
    P1 t=q.top(); q.pop();
    string cost=t.first;
    int x=t.second;
    
    if(cost.size()>=M-1)continue;
    
    if(d[x][cost.size()]<=cost)continue;
    
    d[x][cost.size()]=cost;
    
    if(x==g){
      if(cost.size()>=245)break;
      return cost;
    }
    
    for(int i=0;i<G[x].size();i++){
      int nx=G[x][i].first;
      string ncost=cost+G[x][i].second;
      q.push(P1(ncost,nx));
    }
    
  }
  
  return "NO";
}

int main(){
  
  while(1){

    cin>>n>>m>>s>>g;
    if(!n&&!m&&!s&&!g)break;
    
    init();
    
    int a,b;
    string s;
    for(int i=0;i<m;i++){
      cin>>a>>b>>s;
      G[a].push_back(P(b,s));
    }
    
    cout<<dijkstra()<<endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 43900
{-# LANGUAGE BangPatterns #-}

import qualified Data.ByteString.Char8 as C
import Data.Vector.Unboxed (foldl1', generate, prescanl', prescanr', replicate, reverse, zipWith4)
import Prelude hiding (replicate, reverse)


main = print =<< sol <$> readLn <*> (C.length <$> C.getLine)

sol k n = foldl1' (.+.) $ zipWith4 (\a b c d -> a .*. b .*. c .*. d) c1 c2 p1 p2
  where
  c1 = prescanl' (.*.) (fac (n-1)) $ generate (k+1) (n+)
  c2 = prescanr' (.*.) (inv $ fac (n-1) .*. fac k) $ generate (k+1) id
  p1 = prescanl' (.*.) 1 $ replicate (k+1) 25
  p2 = reverse . prescanl' (.*.) 1 $ replicate (k+1) 26

(.*.) = ((`mod` p) .) . (*)
(.+.) = ((`mod` p) .) . (+)

p = 10^9+7 :: Int

inv 1 = 1
inv !a = pwr a (p-2)

pwr !a !n
  | n == 0    = 1
  | odd n     = a .*. r
  | otherwise = r
  where
  q = pwr a (n `div` 2)
  r = q .*. q

fac 0 = 1
fac !n = n .*. fac (n-1)

Measured memory_bytes: 54448
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) erase(x.begin(), x.begin+n)
// #define int long long
#define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;

signed main(void) {
  	int N, D;
  	cin >> N >> D;
  	int ans = int(N/(2*D+1));
  	if (N%(2*D+1) > 0) {
  		ans += 1;
  	}
  	cout << ans << endl;
 	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ld float
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define vvi vector<vi >
#define str string
#define vs vector<str>
#define vb vector<bool>
#define slli set<lli>
#define mii map<int, int>
#define mlli map<int, lli>
#define msi map<str, int>
#define mp make_pair
#define pii pair<int, int>
#define pll pair<lli, lli>
#define vpii vector<pii >
#define vpll vector<pll >
#define pb push_back
#define loop(i, s, l, j) for(int i = s; i < l; i += j)
#define rloop(i, s, l, j) for(int i = s; i >= l; i -= j)
#define rep(i, n) loop(i,0,n,1)
#define rrep(i, n) rloop(i,n-1,0,1) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ft first
#define sd second
#define all(a) a.begin(),a.end()
#define rev(a) reverse(all(a))
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define mod 998244353
#define inf 2000000000
#define limit 200005
#define minval -100000000000000000
#define maxval 1000000000000000
int dx4[4] = {0, -1, 0, 1};
int dy4[4] = {1, 0, -1, 0};
int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Power(int base,int exp){int ans=1;  while(exp > 0){if(exp&1)ans=(1LL*ans*base)%mod; exp=exp>>1; base=(1LL*base*base)%mod;}  return ans;}

lli BIT[200005] = {};
void update(int x, int val)
{
    while(x < limit)
        BIT[x] = (BIT[x] + val)%mod, x += (x&(-x));
}
lli query(int x)
{
    lli ans = 0;
    while(x > 0)
        ans = (ans + BIT[x])%mod, x -= (x&(-x));
    return ans;
}

void solve(int test_case)
{
    int n, k;
    cin >> n >> k;

    vi l(k), r(k);
    rep(i,k)
        cin >> l[i] >> r[i];

    lli ans = 1;
    update(1,1);
    loop(i,2,n+1,1)
    {
        ans = 0;
        rep(j,k)
        {
            int i2 = i - l[j];
            int i1 = i - r[j];

            if(i1 < 0 && i2 < 0)
                continue;
            else if(i1 < 0)
            {
                if(i2 == 0)
                    continue;
                else
                    ans = (ans + query(i2))%mod;
            }
            else if(i2 < 0)
                continue;
            else
            {
                if(i1 == 0 && i2 == 0)
                    continue;
                else if(i1 == 0)
                    ans = (ans + query(i2))%mod;
                else
                    ans = (ans + (mod + query(i2) - query(i1-1))%mod)%mod;
            }
        }
        update(i, ans);
    }    
    cout << ans << '\n';
}

int main()
{
   /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
   */
    fastio();
    int q = 1;
    //cin >> q;
    rep(i,q)
        solve(i+1);
}


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

int cost[100001];


int mod(int a , int b)
{
	return (a>b)? a-b : b-a;
}

int min(int a , int b)
{
	return (a>b)? b : a ;
}

int min_cost(int a[] , int n)
{
	if(n==2)
	return cost[n] = mod(a[n-1] , a[n-2]);
	
	if(n == 3)
	return cost[n] = min( mod(a[n-1] , a[n-2]) + mod(a[n-3] , a[n-2])   ,    mod(a[n-1],a[n-3]) );
	
	if(cost[n] != -1)
	return cost[n];
	
	else
	return cost[n] = min(  mod(a[n-1] , a[n-2])+min_cost(a , n-1)  , mod(a[n-1],a[n-3])+min_cost(a , n-2) );
	
	
	
}

int main()
{
	memset(cost, -1, sizeof(cost));
    int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	
	cout<<min_cost(a , n)<<endl;
	
}

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

using namespace std;
#define ll long long
#define dbug printf("I am here\n");
const int maxn = 2e5+100;

const ll inf = 1e18;

int main()
{
    ll sum = 0;
    ll mins = 0;
    int n; cin >> n;
    ll mx = 1e12;
    for(int i = 1; i<=n; i++){
        ll p; cin >> p;
        if(p < 0)mins++;
        if(p < 0)p = p*(-1);
        mx = min(mx , p);
        sum += p;
    }
    if(mins & 1)sum -= 2*mx;
    cout << sum << endl;
    return 0;

}



Measured memory_bytes: 256
class UnionFind():
    def run(self, N, M, p, x):
        '''Union find(ランクなし)'''
        # 初期化。index0はとりあえず0で埋める
        self.part = []
        for i in range(N+1):
            self.part.append(i) 
        # 経路をまとめる
        for i in range(M):
            self.union(x[i][0], x[i][1])
        cnt = 0
        for i in range(1, N+1):
            if self.root(i) == self.root(p[i-1]):
                cnt += 1
        return cnt

    def root(self, x):
        if self.part[x] == x:
            return x
        else:
            # 経路圧縮
            self.part[x] = self.root(self.part[x])
            return self.part[x]
    
    def union(self, x, y):
        x_root = self.root(self.part[x])
        y_root = self.root(self.part[y])
        if x_root == y_root:
            pass
        else:
            self.part[x_root] = y_root


def main():
    N, M = map(int, input().split())
    p = list(map(int, input().split()))
    x = []
    for i in range(M):
        x.append(list(map(int, input().split())))
    obj = UnionFind()
    print(obj.run(N, M, p, x))


if __name__ == '__main__':
    main()


Measured memory_bytes: 35336
import java.util.Scanner;

public class Main{
	
	static boolean is_same(int[][] dic,int n){
		int count;
		for(int i=1;i<n;i++){
			count=0;
			for(int j=0;j<6;j++){
				if(dic[0][j]==dic[i][j]){
					count++;
				}
			}
			if(count==6){
				return false;
			}
		}
		return true;
	}

	static void exchange(int[][] dic,int n){
		for(int i=0;i<n;i++){
			int tmp;
			if(dic[0][1]==dic[i][5]){
				tmp=dic[i][1];
				dic[i][1]=dic[i][5];
				dic[i][5]=dic[i][4];
				dic[i][4]=dic[i][0];
				dic[i][0]=tmp;
			}
			if(dic[0][1]==dic[i][3]){
				tmp=dic[i][1];
				dic[i][1]=dic[i][3];
				dic[i][3]=dic[i][4];
				dic[i][4]=dic[i][2];
				dic[i][2]=tmp;
			}
			if(dic[0][1]==dic[i][0]){
				tmp=dic[i][1];
				dic[i][1]=dic[i][0];
				dic[i][0]=dic[i][4];
				dic[i][4]=dic[i][5];
				dic[i][5]=tmp;
			}
			if(dic[0][1]==dic[i][2]){
				tmp=dic[i][1];
				dic[i][1]=dic[i][2];
				dic[i][2]=dic[i][4];
				dic[i][4]=dic[i][3];
				dic[i][3]=tmp;
			}
			if(dic[0][1]==dic[i][4]){
				tmp=dic[i][1];
				dic[i][1]=dic[i][4];
				dic[i][4]=tmp;
				tmp=dic[i][3];
				dic[i][3]=dic[i][2];
				dic[i][2]=tmp;
			}

			if(dic[i][2]==dic[0][5]||dic[i][5]==dic[0][5]||dic[i][3]==dic[0][5]||dic[i][0]==dic[0][5]){
				if(dic[i][5]==dic[0][5]){
				}else if(dic[i][3]==dic[0][5]){
					tmp=dic[i][3];
					dic[i][3]=dic[i][0];
					dic[i][0]=dic[i][2];
					dic[i][2]=dic[i][5];
					dic[i][5]=tmp;
				}else if(dic[i][0]==dic[0][5]){
					tmp=dic[i][0];
					dic[i][0]=dic[i][5];
					dic[i][5]=tmp;
					tmp=dic[i][3];
					dic[i][3]=dic[i][2];
					dic[i][2]=tmp;
				}else{
					tmp=dic[i][2];
					dic[i][2]=dic[i][0];
					dic[i][0]=dic[i][3];
					dic[i][3]=dic[i][5];
					dic[i][5]=tmp;
				}
			}else{
			}
		}
	}

	static void judge(int[] dic1,int[] dic2){
		for(int i=0;i<6;i++){
			if(dic1[i]!=dic2[i]){
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();//サイコロ数。

		int[][] dic=new int[n][6];

		for(int i=0;i<n;i++){
			for(int j=0;j<6;j++){
				dic[i][j]=scan.nextInt();
			}
		}

		exchange(dic,n);
		if(is_same(dic,n)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}


		scan.close();
	}
}

Measured memory_bytes: 20904
/* created   : 2019-08-29 10:24:58
 * accepted  : 2019-08-29 10:27:15
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#ifndef LOCAL
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  double ans = (a[0] + a[1]) / 2.0;
  for (int i = 2; i < n; i++) {
    ans = (ans + a[i]) / 2.0;
  }
  cout << ans << '\n';
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  cout << fixed << setprecision(20);
  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

template <typename T>
std::vector<int> sort_indexes(const std::vector<T> &v) {
  std::vector<int> idx(v.size());
  std::iota(idx.begin(), idx.end(), 0);
  std::sort(idx.begin(), idx.end(), [&v](int i1, int i2) {return v[i1] < v[i2];});
  return idx;
}


signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	
	auto idx = sort_indexes(a);
	for(auto i:idx) {
		std::cout << i+1 << ' ';
	}
	std::cout << ENDL;
	return 0;
}


Measured memory_bytes: 2432
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int bit = 0;
        for (int i = 0; i < N; i++) {
            bit |= sc.nextInt();
        }
        System.out.println(Integer.numberOfTrailingZeros(bit));
    }
}


Measured memory_bytes: 36204
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int, int> P;
int main(){
    int D;
    cin >> D;
    vector<int> dec(26);
    for(int i = 0; i < 26; i++) cin >> dec[i];
    vector<vector<int>> s(D, vector<int> (26)); 
    for(int i = 0; i < D; i++){
        for(int j = 0; j < 26; j++) cin >> s[i][j];
    }
    vector<int> last(26, 0);
    long long ans = 0;
    vector<int> day;
    for(int i = 0; i < D; i++){
        int m = -1e9;
        int ind = 0;
        for(int j = 0; j < 26; j++){
            int temp = s[i][j];
            for(int k = 0; k < 26; k++){
                if(j == k) continue;
                temp -= dec[k] * (i + 1 - last[k]);
            }
            if(m < temp){
                m = temp;
                ind = j;
            }
        }
        last[ind] = i + 1;
        ans += m;
        day.push_back(ind + 1);
    }
    for(int i = 0; i < D; i++) cout << day[i] << endl;
}

Measured memory_bytes: 3664
def revS(x):
    if x == '0':
        return '1'
    return '0'

S = list(input().rstrip())

count = 0
for i in range(1, len(S)):
    if S[i] == S[i - 1]:
        S[i] = revS(S[i])
        count += 1

print(count)


Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

// graph template
template<typename T>
class Edge{
    public:
        int src, to; T cost;

        Edge(int to, T cost): src(-1), to(to), cost(cost){}
        Edge(int src, int to, T cost): src(src), to(to), cost(cost){}
};
template<typename T>
using Edges = vector<Edge<T>>;
template<typename T>
using AdjacencyList = vector<Edges<T>>;
template<typename T>
using Matrix = vector<vector<T>>;

template<typename T>
vector<bool> bipartite_matching(AdjacencyList<T> &g){
    int V = (int)g.size();
    vector<bool> color(V), used(V, false);
    
    stack<int> s;
    color[0] = false;
    s.push(0);
    while(not s.empty()){
        int v = s.top(); s.pop();
        used[v] = true;

        for(auto e: g[v]){
            if(used[e.to]){
                if((e.cost & 1) == (color[v] ^ color[e.to])) continue;
                else return vector<bool>();
            }else{
                color[e.to] = (e.cost & 1) ^ color[v];
                s.push(e.to);
            }
        }
    }

    return color;
}

int main(void){
    int N;
    cin >> N;
    AdjacencyList<int> g(N);
    for(int i = 0; i < N-1; i++){
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        g[u].push_back(Edge<int>(v, w));
        g[v].push_back(Edge<int>(u, w));
    }

    vector<bool> vec = bipartite_matching(g);
    if(not vec.empty()){
        for(int i = 0; i < N; i++){
            cout << vec[i] << '\n';
        }
    }

    return 0;
}

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

int main(){
  int array[110]={};
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>array[i];
  }
  for(int i=n-1;i>=1;i--){
    cout<<array[i]<<" ";
  }
  if(n != 0){
    cout<<array[0]<<endl;
  }
  return 0;
}

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

int main(){
	string abc;
  int a=0,b=0,c=0;
  
  cin>>abc;
  
    if(abc.find("a")!=-1&&abc.find("b")!=-1&&abc.find("c")!=-1){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }


}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

struct UFTree(T)
{
    struct Node
    {
        T parent;
        T rank = 1;
    }

    ///
    T min_size, max_size;

    ///
    this(T n)
    {
        nodes.length = n;
        sizes.length = n;
        foreach (i, ref node; nodes) {
            node = Node(i.to!T);
            sizes[i] = 1;
        }

        min_sizes.length = n + 1;
        min_sizes[1] = n;
        min_size = 1;
        max_size = 1;
    }

    ///
    bool unite(T a, T b)
    {
        a = root(a);
        b = root(b);

        if (a == b) return false;

        auto a_size = sizes[a];
        auto b_size = sizes[b];
        --min_sizes[a_size];
        --min_sizes[b_size];
        ++min_sizes[a_size + b_size];
        foreach (nxt_size; min(a_size, b_size)..min_sizes.length) if (min_sizes[nxt_size] != 0) {
            min_size = nxt_size.to!T;
            break;
        }
        max_size = max(max_size, a_size + b_size);

        if (nodes[a].rank < nodes[b].rank) {
            sizes[a] += sizes[b];
            nodes[b].parent = a;
        } else {
            sizes[b] += sizes[a];
            nodes[a].parent = b;
            if (nodes[a].rank == nodes[b].rank) ++nodes[b].rank;
        }

        return true;
    }

    ///
    bool is_same(T a, T b)
    {
        return root(a) == root(b);
    }

    ///
    T size(T i)
    {
        return sizes[root(i)];
    }

private:
    Node[] nodes;
    T[] sizes;
    T[] min_sizes;

    T root(T i)
    {
        if (nodes[i].parent == i) return i;

        return nodes[i].parent = root(nodes[i].parent);
    }
}

///
UFTree!T uftree(T)(T n)
{
    return UFTree!T(n);
}

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];
    auto uft = uftree(N);
    foreach (_; 0..M) {
        auto ab = readln.split.to!(int[]);
        uft.unite(ab[0]-1, ab[1]-1);
    }
    int r;
    foreach (i; 0..N) r = max(r, uft.size(i));
    writeln(r);
}

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

const int M = 1e5 + 5;
int n, k, q, da[M];

int main () {
	cin >> n >> k >> q;
	for (int i = 0; i < q; i++) {
		int x;
		cin >> x;
		da[x]++;
	}
	for (int i = 1; i <= n; i++) {
		da[i] = k-(q-da[i]);
		if (da[i] <= 0) puts("No");
		else puts("Yes");
	}

}	


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define ll long long
#define P pair<int, int>

using namespace std;
int mod = 1000000007;

int N;
int main() {
  cin >> N;
  vector<int> x(N);
  int y[20][100005];
  rep(i, N) {
    cin >> x.at(i);
  }
  int L;
  cin >> L;

  int pos = 1;
  rep(i, N) {
    while(pos < N && x.at(pos) <= x.at(i)+L) {
      pos++;
    }
    y[0][i+1] = pos;
  }

  for(int i=0; i<18; i++) {
    for(int j=1; j<=N; j++) {
      y[i+1][j] = y[i][y[i][j]];
    }
  }

  int Q;
  cin >> Q;

  while(Q > 0) {
    Q--;
    int ans = 0;
    int a, b;
    cin >> a >> b;
    if (a > b) {
      int tmp = b;
      b = a;
      a = tmp;
    }

    int now = a;
    while (now < b) {
      int base = 1;
      int i=0;

      while (y[i][now] < b) {
        i++;
        base *= 2;
      }
      if (i >= 1) {
        now = y[i-1][now];
        ans += base/2;
      } else {
        now = b;
        ans += base;
      }
    }

    cout << ans << endl;
  }
}


Measured memory_bytes: 8960
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int(i)=0;i<n;i++)

long long gcd(long long a, long long b) {
    return a % b ? gcd(b,a % b) : b;
}

long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b;
}

int main() {
    int n;
    cin >> n;
    vector<long long> v;
    long long c;
    REP(i,n) {
        cin >> c;
        v.push_back(c);
    }
    
    sort(v.begin(), v.end(), greater<long long>());
    long long ans = 1;
    REP(i,n) {
        ans = lcm(ans, v[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def mod_div(x, y, mod=10 ** 9 + 7):
    return x * pow(y, mod - 2, mod) % mod


def solve():
    N, K = map(int, rl().split())
    A = list(map(int, rl().split()))
    MOD = 10 ** 9 + 7
    
    if K == N:
        ans = 1
        for ai in A:
            ans *= ai
            ans %= MOD
        print(ans)
        return

    A.sort(key=lambda num: abs(num), reverse=True)
    if all(ai < 0 for ai in A) and K % 2 == 1:
        ans = 1
        for ai in A[-K:]:
            ans *= ai
            ans %= MOD
        print(ans)
        return
    
    ans = 1
    INF = 10 ** 10
    min_pos, min_neg = INF, INF
    cnt_neg = 0
    for ai in A[:K]:
        if ai < 0:
            min_neg = ai
            cnt_neg += 1
        else:
            min_pos = ai
        ans *= ai
        ans %= MOD
    
    if cnt_neg % 2 == 0:
        print(ans)
    else:
        n_pos, n_neg = INF, INF
        for ai in A[K:]:
            if n_pos != INF and n_neg != INF:
                break
            if ai < 0 and n_neg == INF:
                n_neg = ai
            elif 0 <= ai and n_pos == INF:
                n_pos = ai
        if min_pos != INF and min_neg != INF and n_pos != INF and n_neg != INF:
            if abs(min_pos * n_pos) <= abs(min_neg * n_neg):
                ans = mod_div(ans, min_pos) * n_neg % MOD
            else:
                ans = mod_div(ans, min_neg) * n_pos % MOD
        elif min_neg != INF and n_pos != INF:
            ans = mod_div(ans, min_neg) * n_pos % MOD
        else:
            ans = mod_div(ans, min_pos) * n_neg % MOD
        print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 106228
# coding:utf-8

import sys
from collections import Counter


input = sys.stdin.readline


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


# Counterを使ったD - Candy Distributionの解法
def solve(N, M, A):
    # 累積和(mod M)を求める
    S = [0]
    for i in range(N):
        S.append((S[-1] + A[i]) % M)
    del S[0]

    # 各要素の個数を数える
    C = Counter(S)

    ans = 0
    for num in C:
        if C[num] <= 1:
            continue
        # C[num]個から2つ選ぶ組み合わせ
        ans += C[num] * (C[num] - 1) // 2

    # 1箱で条件を満たす(Si = 0, l=r)場合を加算
    return ans + C[0]


N, M = inpl()
A = inpl()
print(solve(N, M, A))


Measured memory_bytes: 17284
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define msg(x) debug() << x
#define int long long
const int xx = 2e5;
const int MOD = 1e9 + 7;
signed main(){
  ios::sync_with_stdio(false);cin.tie(0);

  int N , L;
  vector<int>v;
  cin >> N >> L;
  for(int i=1;i<=N;i++){
    v.push_back(L+i-1);
  }
  int sum = 0;
  for(int i : v) sum += i;
  // dg1(v);
  // dg1(sum);
  int ans = 100000000;
  int x;
  for(int i : v){
    int rem = sum - i;
    int diff = abs(sum - rem);

    if(diff < ans){
      ans = diff;
      x = rem;
    }
  }
  cout << x << '\n';
  
}

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

mod=pow(10,9)+7

def pow_method(r,N):
    ans=1
    for i in range(N):
        ans=ans*r%mod
    return ans

calc=pow_method(9,N)+pow_method(9,N)-pow_method(8,N)
ans=pow_method(10,N)-calc
ans=ans%mod
ans=(ans+mod)%mod

print(ans)

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

int main(){
  int n;cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v.at(i);
  int sum = 0;
  rep(i,n){
    sum+=v.at(i);
  }
  int ans = 0,d;
  d = sum;
  if (sum%10 != 0){
    cout << sum << endl;
    return 0;
  }
  else{
    rep(i,n){
      sum-=v.at(i);
      if (sum%10 != 0){
        ans = max(ans,sum);
      }
      sum = d;
    }
  }
  cout << ans << endl;
}

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

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

#define random_shuffle(...) shuffle(__VA_ARGS__, rng)
#define rand() rng()

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

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

	int n = nxt(), m = nxt();
	string s, t;
	cin >> s >> t;
	int g = __gcd(n, m);
	for (int i = 0; i < g; ++i) {
		if (s[i * (n / g)] != t[i * (m / g)]) {
			cout << "-1\n";
			return 0;
		}
	}
	cout << 1ll * n * m / g << "\n";

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << endl
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rrep(i,n) for(int i=(n); (i)>=0; --(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
#define max(v) *max_element(v.begin(), v.end())
#define min(v) *min_element(v.begin(), v.end())
#define lb(v,x) v[lower_bound(v.begin(), v.end(), x) - v.begin()]
#define ub(v,x) v[upper_bound(v.begin(), v.end(), x) - v.begin()]
template<class T> inline bool print(T& x){ cout << x << endl; return true; }
template<class T> inline bool print_(T& x){ cout << x << " "; return true; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
const int INF = 1e9;
const ll llINF = 1LL<<60;
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main(){
    int n; cin >> n;
    vector<int> a(n); rep(i,n) cin >> a[i], a[i] -= (i+1);
    ll ans=0, med;
    sort(all(a));
    if(n%2) med = a[n/2];
    else med = (a[n/2-1] + a[n/2])/2;
    rep(i,n) ans += abs(a[i]-med);
    
    cout << ans;
    
    return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long, long> > vllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  int arr[5] = { 0 };
  string s;
  fi(0, n) {
    cin >> s;
    switch(s[0]) {
      case 'M':
        arr[0]++;
        break;
      case 'A':
        arr[1]++;
        break;
      case 'R':
        arr[2]++;
        break;
      case 'C':
        arr[3]++;
        break;
      case 'H':
        arr[4]++;
        break;
    }
  }
  // fi(0, 5) {
  //   cout << arr[i] << endl;
  // }
  fi(0, 1 << 5) {
    if(__builtin_popcount(i) != 3)
      continue;
    ll cnt = 1;
    fj(0, 5) {
      if((i >> j) & 1) {
        cnt *= arr[j];
      }
    }
    ans += cnt;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.awt.geom.Point2D;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
//Loopで使う文字列の長さは固定！
//intで大丈夫？オーバーフローしない？
//Loop回数は本当に10⁹以内になってる？Loopは回る？？
public class Main {
    public static void main(String[]$){
        Scanner sc = new Scanner(in);
        int H=sc.nextInt();
        int W=sc.nextInt();
        int[][] a=new int[H][W];
        for (int i = 0; i < H; i++) {
            String s=sc.next();
            for (int j = 0; j < W; j++) {
                if(s.charAt(j)=='#')a[i][j]=1;
            }
        }
        int[] t=new int[W];
        for (int i = 0; i < H; i++) {
            int c=0;
            for (int j = 0; j < W; j++) {
                t[j]+=a[i][j];
                c+=a[i][j];
            }
            if(c==0){
                for (int j = 0; j < W; j++) {
                    a[i][j]=2;
                }
            }
        }
        for (int i = 0; i < W; i++) {
            if(t[i]==0){
                for (int j = 0; j < H; j++) {
                    a[j][i]=2;
                }
            }
        }
        for (int i = 0; i <H; i++) {
            int c=0;
            for (int j = 0; j < W; j++) {
                if(a[i][j]==0)out.print(".");
                if(a[i][j]==1)out.print("#");
                c+=a[i][j];
            }
            if(c!=2*W)out.println();
        }
    }
    static long power(long x,int n){
        long mod=1000000007;
        long ans=1;
        while (n>0) {
            if((n&1)==1){
                ans=(ans*x)%mod;
            }
            x=(x*x)%mod;
            n>>=1;
        }
        return ans;
    }
    //最大公約数
    static int gcd (int a, int b) {
        int temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }
//※最小公倍数はa*b/gcd(a,b)である
}


Measured memory_bytes: 23764
using System;
using System.Collections.Generic;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ND = ReadInts();
            var ans = 0;
            for (int i = 0; i < ND[0]; i++)
            {
                var XY = ReadLongs();
                var distance = Sqrt((XY[0] * XY[0]) +( XY[1] * XY[1]));
                if (distance <= ND[1]) ans++;
            }
            WriteLine(ans);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	ll ans = 0;
	if( n == 2 )
	{
		cout << 1 << '\n';
		return 0;
	}
	for (ll i = 2; i * i <= n - 1; i++)
	{
		if( (n-1) % i == 0 )
		{
			ans ++;
			if( i * i != n - 1 ) ans ++; 
		}
	}
	ans ++;
	for (ll i = 2; i * i <= n; i++)
	{
		if( n % i == 0 )
		{
			ll t = n;
			while( t % i == 0 ) t /= i;
			if( t % i == 1 ) ans ++;
			if( i * i != n )
			{
				ll z = n / i;
				t = n;
				while( t % z == 0 ) t /= z;
				if( t % z == 1 ) ans ++;
			}
		}
	}
	ans ++;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lli=int64_t;
int main()
{
    long long  n;
    lli cost=INT64_MAX;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    for(int i=-100;i<=100;i++)
    {
        lli cc=0;
        for(int j=0;j<n;j++)
        {
            cc=cc+(arr[j]-i)*(arr[j]-i);
        }
        cost=min(cost,cc);

    }
    cout<<cost<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	long int a, b; cin >> a >> b;
	long int n = b-a;
	long int x = -(n+a+b)/2;
	for(int i=1;i<=n;i++){
		x += i;
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

N = int(input())
count = defaultdict(int)
for n in range(1, N+1):
    i = n
    while i >= 10:
        i //= 10
    j = n % 10
    if i != 0 and j != 0:
        count[(i, j)] += 1
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += count[(i, j)] * count[(j, i)]
print(ans)


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define se set<ll>
#define vec vector<ll>
#define inf 10000000000000000
bool mark[100005];
vec adj[100005];
ll counter;
vec cnt;
vector<string> forsubs;
ll ans=0;
ll n;

	

int main()
{    
 

	#ifdef APNA_IO
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 

ll h,w;
string s;
cin>>h>>w;
char mat1[h+1][w+1];
ll mat2[h+1][w+1];
ll mat3[h+1][w+1];

for(ll i=1;i<=h;i++)
{	
	cin>>s;
	for(ll j=0;j<w;j++)
			{
				mat1[i][j+1]=s[j];

			}
}

for(ll i=0;i<=h;i++)
{
	for(ll j=0;j<=w;j++)
	{
		mat2[i][j]=0;
		mat3[i][j]=0;
	}
}

for(ll i=1;i<=h;i++)
{
	for(ll j=1;j<w;j++)
	{
		if(mat1[i][j]=='#')
			mat2[i][j]=0;
		else
		{
			if(mat1[i][j+1]=='.')
				mat2[i][j]=mat2[i][j-1]+1;
			else
				mat2[i][j]=mat2[i][j-1];
		}
	}
	
	if(mat1[i][w]=='.')
		mat2[i][w]=mat2[i][w-1];
	else
		mat2[i][w]=0;
}

for(ll i=1;i<=w;i++)
{
	for(ll j=1;j<h;j++)
	{
		if(mat1[j][i]=='#')
			mat3[j][i]=0;
		else
		{
			if(mat1[j+1][i]=='.')
				mat3[j][i]=mat3[j-1][i]+1;
			else
				mat3[j][i]=mat3[j-1][i];
		}
	}
	
	if(mat1[h][i]=='.')
		mat3[h][i]=mat3[h-1][i];
	else
		mat3[h][i]=0;
}

for(ll i=h;i>=1;i--)
{
	for(ll j=w-1;j>=1;j--)
	{
		if(mat2[i][j]==0)
			continue;
		else
			mat2[i][j]=max(mat2[i][j+1],mat2[i][j]);
	}
}

for(ll i=w;i>=1;i--)
{
	for(ll j=h-1;j>=1;j--)
	{
		if(mat3[j][i]==0)
			continue;
		else
			mat3[j][i]=max(mat3[j+1][i],mat3[j][i]);
	}
}

for(ll i=1;i<=h;i++)
{
	for(ll j=1;j<=w;j++)
	{
		ans=max(mat2[i][j]+mat3[i][j],ans);
	}
}


cout<<ans+1<<endl;

}	





Measured memory_bytes: 69120
class Binary_Indexed_Tree:

    def __init__(self,n):
        self.size=n
        self.graph=[0]*(n+1)

    def partially_sum(self,i):
        res=0
        while i>0:
            res+=self.graph[i]
            i-=i&-i
        return res

    def add_element(self,i,x):
        while self.size>=i:
            self.graph[i]+=x
            i+=i&-i

n,q=map(int,input().split())
tree=Binary_Indexed_Tree(n)
for _ in range(q):
    c,x,y=map(int,input().split())
    if c==0:
        tree.add_element(x,y)
    else:
        print(tree.partially_sum(y)-tree.partially_sum(x-1))


Measured memory_bytes: 7924
#include <bits/stdc++.h>
using namespace std;
 
 
int main(){
  int N;
  string S;
  cin >> N >> S;
  if(N%2==1){
    cout << "No" << endl;
    return 0;
  }
  if(S.substr(0, N/2)!=S.substr(N/2, N/2)){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in); 
    int N = sc.nextInt();
    if (N % 1000 == 0) {
      System.out.println(0);
    } else {  
      System.out.println(((N / 1000) + 1)* 1000 - N);
    }
  }
}



Measured memory_bytes: 35692
#![allow(bare_trait_objects)]
#![allow(unused_imports)]
#![allow(dead_code)]

use std::fmt::Debug;
use std::io::BufRead;
use std::io::Stdin;
use std::io::StdinLock;
use std::str::FromStr;

pub struct Scanner<'a> {
    // stdin: Stdin,
    buf_read: Box<BufRead + 'a>,
    tokens: Vec<String>,
}

impl<'a> Scanner<'a> {
    pub fn new(buf_read: StdinLock<'a>) -> Self {
        Scanner {
            buf_read: Box::new(buf_read),
            tokens: Vec::new(),
        }
    }

    // pub fn from_stdin() -> Self {
    //     let stdin = Box::leak(Box::new(std::io::stdin()));
    //     Self {
    //         buf_read: Box::new(stdin.lock()),
    //         tokens: Vec::new(),
    //     }
    // }

    pub fn next(&mut self) -> String {
        while self.tokens.is_empty() {
            let mut s = String::new();
            if self.buf_read.read_line(&mut s).is_err() {
                panic!()
            }
            self.tokens = s
                .split_whitespace()
                .filter(|s| !s.is_empty())
                .rev()
                .map(str::to_string)
                .collect();
        }
        self.tokens.pop().unwrap()
    }

    pub fn next_g<T: FromStr>(&mut self) -> T
    where
        T::Err: Debug,
    {
        self.next().parse().unwrap()
    }

    pub fn next_vec_g<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        T::Err: Debug,
    {
        (0..n).map(|_| self.next_g()).collect()
    }

    pub fn usize(&mut self) -> usize {
        self.next_g()
    }

    pub fn i64(&mut self) -> i64 {
        self.next_g()
    }

    pub fn vec_i64(&mut self, n: usize) -> Vec<i64> {
        self.next_vec_g(n)
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut sc = Scanner::new(stdin.lock());

    let a = sc.i64();
    let b = sc.i64();
    let c = sc.i64();

    let l = 4 * a * b;
    let r = c - a - b;

    if r > 0 && l < r * r {
        println!("{}", "Yes")
    } else {
        println!("{}", "No")
    }
}


Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	string S;

	cin >> S;

	int ans[] = {0, 0};


	for(int i = 0; i < 2; i++){
		for(int j = 0 ; j<S.size(); j++){
			int x = S[j] - '0';
			if(x == ((i+j) % 2)){
				ans[i]++;
			}
		}
	}

	cout << min(ans[0], ans[1]) << endl;

	return 0;
}


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

//vector <long long> v;

//stack <long long> s[1000000], wym;

//queue <long long> s;

long long int  x[1000000], y, z;
char s1[1000000], s2[1000000];

int main()
{
    long long int a, b, c, d, k, l, i, j, q, t, p, n, m=131072, w, r;

    t=1;
    //scanf("%lld", &t);
    for(q=0; q<t; q++)
    {
        scanf("%lld%lld%lld%lld", &a, &b, &c, &k);

        w=0;
        while(b<=a)
        {
            w++;
            b*=2;
        }
        while(c<=b)
        {
            w++;
            c*=2;
        }
        if(k>=w)printf("Yes\n");
        else printf("No\n");
    }
    return(0);
}


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

vector<int> dignum(int X){
    if(X == 0) return {0};
    vector<int> res;
    while(X){
        res.push_back(X%10);
        X /= 10;
    }
    reverse(res.begin(), res.end());
    return res;
}

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> S(M), C(M);
    for(int i=0; i<M; i++){
        cin >> S[i] >> C[i];
        S[i]--;
    }

    for(int x=0; x<1000; x++){
        auto v = dignum(x);
        if(v.size() != N) continue;
        bool ok = true;
        for(int i=0; i<M; i++) if(v[S[i]] != C[i]) ok = false;
        if(ok){
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($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:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(t: [chars]);
    let s: Vec<_> = vec!["AC", "WA", "TLE", "RE"]
        .into_iter().map(|x| x.to_owned().chars().collect::<Vec<_>>())
        .collect();
    let mut ans = vec![0; 4];
    for t in t {
        let idx = s.iter().position(|x| x == &t).unwrap();
        ans[idx] += 1;
    }
    for i in 0..4 {
        for c in &s[i] {
            puts!("{}", c);
        }
        puts!(" x {}\n", ans[i]);
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 6368
n = int(input())
candy = [list(map(int,input().split())) for c in range(2)]
ans = sum(candy[0])+candy[1][-1]
for i in range(n):
  num = sum(candy[1][i:]) + sum(candy[0][:i+1])
  if num > ans:
    ans = num
print(ans)

    

Measured memory_bytes: 8984
#include<bits/stdc++.h>
#define M 1000005
#define P 1000000007
#define LL long long
using namespace std;
int A[M],sum[M],n;
bool check(){
	if(A[1]>1)A[1]--;
	for(int i=2;i<=n;i++){
		if(A[i]>A[i-1])A[i]--;
		if(A[i]<A[i-1])return false;
	}
	return true;
}
int main(){  
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",&A[i]);
	}
	puts(check()?"Yes":"No");
	return 0;
}

Measured memory_bytes: 4352
from functools import lru_cache

@lru_cache
def comb(n, k):
    if k == 0:
        return 1
    elif n == k:
        return 1
    else:
        return comb(n-1, k) + comb(n-1, k-1)

N, A, B = map(int, input().split())
vs = sorted(map(int, input().split()), reverse = True)

print(sum(vs[:A]) / A)
v_replaceable = vs[A]

n = vs.count(v_replaceable)
a = A - vs.index(v_replaceable)
b = min(n, B - vs.index(v_replaceable))

if vs[0] == v_replaceable:
    #n個からa~b個を選ぶ選び方が答え。
    print(sum(comb(n, t) for t in range(a, b+1)))
else:
    #n個からa個を選ぶ選び方が答え。
    print(comb(n, a))

Measured memory_bytes: 9528
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int a, e, k;
  cin >> a >> e >> e >> e >> e >> k;
  cout << (((e-a) > k)?":(":"Yay!") << endl;
  return 0;
}


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

using ll=long long;
#define int ll

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

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	int H=read(),W=read();
	char a[H+2][W+2];
	REP(i,H+2){
		REP(j,W+2){
			a[i][j]='#';
		}
	}
	
	FOR(i,1,H+1){
		FOR(j,1,W+1){
			cin >> a[i][j];
		}
	}
	
	REP(i,H+2){
		REP(j,W+2){
			cout << a[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 256