akhauriyash/Code-Regression huggingface dataset:
from functools import lru_cache
n=int(input())
k=int(input())
@lru_cache(None)
def F(x,y):  #xという数字に対して0出ない数字がyこのモノの個数
    if x<10:
        if y==1:
            return x
        elif y==0:
            return 1
        else:
            return 0
    else:
        res=0
        q,r=divmod(x,10)
        res+=F(q,y)  #最後の桁が0
        if y>=1:
            res+=r*F(q,y-1) #最後の桁が1-r
            res+=(9-r)*F(q-1,y-1) #最後がr+1,,,9
        return res
print(F(n,k))

Measured memory_bytes: 3940
#include <bits/stdc++.h>
#define ld long double
#define int long long
using namespace std;
const int N = 2e5 + 50;
const int mod = 1e9 + 7;
const int inf = 1e17;
int dx[] = {0, 1, -1, 0, -1, 1, 1, -1};
int dy[] = {1, 0, 0, -1, -1, 1, -1, 1};
int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
 	int n;
 	cin >> n;
 	double ans = 0.0;
 	while(n--){
 		double x;
 		string y;
 		cin >> x >> y;
 		if(y == "JPY"){
 			ans += x;
 		}else{
 			ans += (380000.0 * x);
 		}
 	}
 	cout << showpoint << fixed << setprecision(10) << ans;
}

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

int main() {
  int N;
  cin >> N;
  vector<int>A(N);
  vector<int>B(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    B.at(A.at(i) - 1) = i + 1;
  }
  for (int i = 0; i < N; i++) {
    cout << B.at(i) << ' ';
  }
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <functional>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
using namespace std;
const char sentinel = 'z' + 1;
int main() {
    while (true) {
        int n; cin >> n;
        if (n == 0) break;
        vector<string> s(n);
        repeat (i,n) {
            cin >> s[i];
            s[i] += sentinel;
        }
        array<array<bool, 27>, 27> lt = {};
        repeat (i,26) lt[26][i] = true;
        repeat (j,n) repeat (i,j) {
            auto it = mismatch(s[i].begin(), s[i].end(), s[j].begin(), s[j].end());
            auto p = it.first;
            auto q = it.second;
            if (p == s[i].end()) {
                assert (q == s[j].end());
            } else {
                lt[*p - 'a'][*q - 'a'] = true;
            }
        }
        bool has_cycle = false;
        array<bool, 27> used = {};
        function<void (int)> dfs = [&](int i) {
            if (used[i]) {
                has_cycle = true;
                return;
            }
            used[i] = true;
            repeat (j, 27) if (lt[i][j]) {
                dfs(j);
                if (has_cycle) break;
            }
            used[i] = false;
        };
        repeat (i, 27) {
            dfs(i);
            if (has_cycle) break;
        }
        cout << (has_cycle ? "no" : "yes") << endl;
    }
    return 0;
}

Measured memory_bytes: 3216
/**
*    author:  yuya1234
*    created: 25.07.2020 21:28:22
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SORT(x) sort(x.begin(),x.end())
#define SORTD(x) sort(x.rbegin(),x.rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SZ(x) ll(x.size())

#define MEMSET(v, h) memset((v), h, sizeof(v))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

  int n;
  cin>>n;

  int a[n];
  REP(i,n)cin>>a[i];

  vector<int> v;
  int tmp,idx=0;
  bool buy=true;
  tmp=a[0];
  v.emplace_back(0);
  FOR(i,1,n-1)
  {
    //cout<<tmp<<" "<<a[i]<<endl;
    if(buy)
    {
      if(tmp<a[i])
      {
        v.emplace_back(i);
        tmp=a[i];
        idx++;
        buy=false;
      }
      else if(tmp>=a[i])
      {
        v[idx]=i;
        tmp=a[i];
      }
    }
    else
    {
      if(tmp>a[i])
      {
        v.emplace_back(i);
        tmp=a[i];
        idx++;
        buy=true;
      }
      else if(tmp<=a[i])
      {
        v[idx]=i;
        tmp=a[i];
      }
    }
  }

  if(SZ(v)==1)
  {
    cout<<1000<<endl;
    return 0;
  }

  ll sum=1000;
  int kaisu=SZ(v);
  if(kaisu%2==1)kaisu--;
  for(int i=0;i<kaisu;i+=2)
  {
    ll sel=sum/a[v[i]];
    sum=(sum%a[v[i]])+(sel*a[v[i+1]]);
  }

  cout<<sum<<endl;

  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a < b){
        cout << "a < b" << endl;
    } else if (a > b){
        cout << "a > b" << endl;
    } else if (a == b){
        cout << "a == b" << endl;
    }
    return 0;

}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 998244353;
ll n, m, k;
ll Pow(ll a, ll b) {
	ll res = 1ll;
	while (b) {
		if (b & 1)res = res * a%mod;
		a = a * a%mod;
		b >>= 1;
	}
	return res;
}
ll fac[N], inv[N];
void init() {
	fac[0] = 1;
	for (ll i = 1; i < N; i++) {
		fac[i] = fac[i - 1] * i %mod;
	}
	inv[N - 1] = Pow(fac[N - 1], mod - 2);
	for (ll i = N - 2; i >= 0; i--) {
		inv[i] = inv[i + 1] * (i + 1) % mod;
	}
}
ll ans;
ll C(ll n, ll k) {
	return fac[n] * inv[k] % mod*inv[n - k] % mod;
}
int main() {
	init();
	scanf("%lld%lld%lld", &n, &m, &k);
	for (ll i = 0; i <= k; i++) {
		ll p = n - i;
		ans = (ans + C(n - 1, p - 1)*Pow(m - 1, n - i - 1) % mod*m%mod) % mod;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 6944
#include <iostream>
#include <vector>
#include <queue>

#define INF 1010101010

using namespace std;

vector<vector<int>> v(100000);
vector<int> ans(100000);
vector<int> depth(100000, INF);

int main()
{
	int n, m;
	cin >> n >> m;
	
	int a, b;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		v[a - 1].emplace_back(b - 1);
		v[b - 1].emplace_back(a - 1);
	}

	queue<pair<int, pair<int, int>>> q;
	q.push(make_pair(0, make_pair(0, 0)));

	while (!q.empty()) {
		if (depth[q.front().first] != INF) {
			q.pop();
			continue;
		}

		depth[q.front().first] = q.front().second.second;
		ans[q.front().first] = q.front().second.first;

		for (auto & i : v[q.front().first]) {
			if (i == q.front().second.first) {
				continue;
			}

			q.push(make_pair(i, make_pair(q.front().first, q.front().second.second + 1)));
		}
		q.pop();
	}

	for (int i = 0; i < n; i++) {
		if (ans[i] == INF) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	for (int i = 1; i < n; i++) {
		cout << ans[i] + 1 << endl;
	}

	return 0;
}

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

int main(){
  string s;
  cin>>s;
  ll ans=0;
  int cnt_A=0;
  rep(i,s.size()){
    if(s[i]=='A') cnt_A++;
    else if(i!=s.size()-1 && s[i]=='B' && s[i+1]=='C'){
      ans+=cnt_A;
      i++;
    }
    else cnt_A=0;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
const int MAX_N = 100000;
main(){
    int cnt[4] = {};
    rep(i,0,3){
        int a,b;
        cin >> a >> b;
        cnt[a-1]++;
        cnt[b-1]++;
    }
    rep(i,0,4){
        if(cnt[i] >= 3){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,i;
    char z;
    for(i=0;;i++){
        scanf("%d %c %d",&a,&z,&b);
        if(z=='+'){
            printf("%d\n",a+b);
        }else if(z=='-'){
            printf("%d\n",a-b);
        }else if(z=='*'){
            printf("%d\n",a*b);
        }else if(z=='/'){
            printf("%d\n",a/b);
        }else if(z=='?'){
            break;
        }
        }
    return 0;
}



Measured memory_bytes: 2096
import java.util.Scanner;
 
class Main{
	public static void main(String[]args){
        	Scanner sc = new Scanner(System.in);
        	int x = sc.nextInt();
        	int y = sc.nextInt();
        	int table[][] = new int[x+1][y+1];
         
        	for(int i = 0; i < x; i++){
            		for(int j = 0; j < y; j++){
                		table[i][j] = sc.nextInt();
                		table[i][y]+=table[i][j];
                		table[x][j]+=table[i][j];
               			table[x][y]+=table[i][j];
            		}
        	}
     
        	for(int i = 0; i < x+1; i++){
            		for(int j = 0; j < y+1; j++){
                		System.out.print(table[i][j]);
                		if(j != y){
					System.out.print(" ");
				}
            		}
            	System.out.println();
        	}
    	}
}

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

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> L;
    rep(i,0,n){
        int tmp;
        cin >> tmp;
        L.push_back(tmp);
    }
    int memo=1;
    int ans =0;
    sort(all(L));
    rep(i,0,n){
        rep(j,i+1,n){
            rep(k,j+1,n){
                if(L[i]+L[j]>L[k]){
                    ans++;
                }else{
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void){

    char b;   cin >> b;
    if(b == 'A')
	cout << 'T' << endl;
    else if(b == 'T')
	cout << 'A' << endl;
    else if(b == 'G')
	cout << 'C' << endl;
    else if(b == 'C')
	cout << 'G' << endl;


    return 0;
}


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

using namespace std;

int main() {
	int k, s;
	cin >> k >> s;
	int cnt = 0,z;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			z = s - (x + y);	//仮定する
			if (s - (x + y) <= k && z>=0) {
				cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int N;
long long int K;
long long int A[2050];

long long int MOD = 1000000007;

int main(void) {

	cin >> N >> K;

	for (int i = 0; i <= N - 1; i++) {
		cin >> A[i];
	}

	long long int ans = 0;

	for (int i = 0; i <= N - 1; i++) {
		for (int j = i + 1; j <= N - 1; j++) {
			if (A[i] > A[j]) { ans++; }
		}
	}

	ans = (ans*K) % MOD;

	long long int tmp = (K*(K - 1)) / 2;
	tmp %= MOD;
	//cout << "tmp= " << tmp << endl;
	for (int i = 0; i <= N - 1; i++) {
		for (int j = i + 1; j <= N - 1; j++) {
			if (A[i] != A[j]) {
				ans += tmp;
				ans %= MOD;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
h,w = map(int, input().split())
ch,cw = map(int, input().split())
ch,cw = ch-1, cw-1
dh,dw = map(int, input().split())
dh,dw = dh-1,dw-1
s = [list(map(lambda x: x==".", input())) for i in range(h)]

inf = 2**32-1
count = [[inf]*w for i in range(h)]

from collections import deque
que = deque()
que.append((ch,cw,0))

dxdy = [(-1,0),(0,1),(1,0),(0,-1)]
dxdy1 = [(-1,-1),(-1,-2),(-2,-1),(-2,-2)]
dxdy2 = [(-1,1),(-1,2),(-2,1),(-2,2)]
dxdy3 = [(1,1),(1,2),(2,1),(2,2)]
dxdy4 = [(1,-1),(1,-2),(2,-1),(2,-2)]
while que:
    x,y,c = que.popleft()
    if count[x][y] <= c:
        continue
    count[x][y] = c
    state = [False]*4
    for i, (dx,dy) in enumerate(dxdy):
        nx, ny = x+dx, y+dy
        if not (0<=nx<h and 0<=ny<w):
            continue
        if s[nx][ny]:
            que.appendleft((nx,ny,c))
        else:
            state[i] = True
            nx,ny = nx+dx, ny+dy
            if 0<=nx<h and 0<=ny<w and s[nx][ny] and count[nx][ny] > c+1:
                que.append((nx,ny,c+1))

    if state[-1] and state[0]:
        for dx,dy in dxdy1:
            nx, ny = x+dx, y+dy
            if 0<=nx<h and 0<=ny<w and s[nx][ny] and count[nx][ny] > c+1:
                que.append((nx,ny,c+1))

    if state[0] and state[1]:
        for dx,dy in dxdy2:
            nx, ny = x+dx, y+dy
            if 0<=nx<h and 0<=ny<w and s[nx][ny] and count[nx][ny] > c+1:
                que.append((nx,ny,c+1))
    if state[1] and state[2]:
        for dx,dy in dxdy3:
            nx, ny = x+dx, y+dy
            if 0<=nx<h and 0<=ny<w and s[nx][ny] and count[nx][ny] > c+1:
                que.append((nx,ny,c+1))
    if state[2] and state[3]:
        for dx,dy in dxdy4:
            nx, ny = x+dx, y+dy
            if 0<=nx<h and 0<=ny<w and s[nx][ny] and count[nx][ny] > c+1:
                que.append((nx,ny,c+1))

ans = count[dh][dw]
if ans == inf:
    ans = -1
print(ans)



Measured memory_bytes: 114592
import sys
from collections import deque

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

class UnionFind():
	def __init__(self, n):
		self.n=n
		self.parents = [-1]*n
	def find(self, x):
		if self.parents[x] < 0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]
	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)
		if x==y:
			return
		if self.parents[x] > self.parents[y]:
			x, y = y, x
		self.parents[x] += self.parents[y]
		self.parents[y] = x
	def size(self, x):
		return -self.parents[self.find(x)]
	def same(self, x, y):
		return self.find(x) == self.find(y)
	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]
	def roots(self):
		return [i for i, x in enumerate(self.parents) if x < 0]
	def group_count(self):
		return len(self.roots())
	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()}
	def __str__(self):
		return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
	N,M,K = MI()
	frend = [[] for _ in range(N)]
	block = [[] for _ in range(N)]
	uf = UnionFind(N)
	for _ in range(M):
		A,B = map(int1, sys.stdin.readline().split())
		uf.union(A,B)
		frend[A].append(B)
		frend[B].append(A)

	for _ in range(K):
		C,D = map(int1, sys.stdin.readline().split())
		if uf.same(C,D):
			block[C].append(D)
			block[D].append(C)

	ans_v = []
	for i in range(N):
		ans = uf.size(i)-len(frend[i])-len(block[i])
		ans_v.append(ans-1)
	printH(ans_v)

main()

Measured memory_bytes: 51740
n = int(input())
z = [0 for _ in range(26)]
mn = [51 for _ in range(26)]
for _ in range(n):
    s = input()
    st = set(s)
    cnt = [0 for _ in range(26)]
    for i in range(len(s)):
        pos = ord(s[i]) - 97
        cnt[pos] += 1
    for ch in st:
        p = ord(ch) - 97
        z[p] += 1
    
    for k in range(len(mn)):
        if cnt[k] != 0 and cnt[k] < mn[k]:
            mn[k] = cnt[k]
            
ans = ""
for i in range(26):
    if z[i] == n:
        if mn[i] != 51:
            ans += chr(i+97)*mn[i]
            
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
int a[N];
void solve(){
    int n, x;
    cin >> n >> x;   
    ll sum = 0;
    ll cnt = 0; 
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
    }
    for(int i = 2; i <= n; ++i) {
        int cur = a[i] + a[i - 1];
        if(cur <= x) 
            continue;
        cur -= x;
        sum += cur;
        int dt = min(a[i], cur);
        a[i] -= dt;
    }
    cout << sum << "\n";
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 3996
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0; i < (n); i++)

const int LOOP = 100000000;

typedef pair<int, int> PI;

void next(vector<int>& p, int& cur, int& cur_x2) {
  cur = cur + p[cur];
  cur_x2 = cur_x2 + p[cur_x2];
  cur_x2 = cur_x2 + p[cur_x2];
}

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> p2(n);
  vector<bool> detected(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < n; i++) {
    if (detected[i] || p[i] == 0) {
      if(!detected[i]) {
        p2[i] = i;
        detected[i] = true;
      }
      continue;
    }
    int cur = i;
    int cur_x2 = i + p[i];
    bool has_loop = false;
    while(p[cur] != 0 && !detected[cur]) {
      if (cur == cur_x2) {
        has_loop = true;
        break;
      }
      next(p, cur, cur_x2);
    }
    int dest = detected[cur] ? p2[cur] : has_loop ? LOOP : cur;
 //   cout << dest << "deぬる" << endl;
    cur = i;
    cur_x2 = i + p[i];
    while(!detected[cur]) {
      int prev = cur;
      next(p, cur, cur_x2);
      detected[prev] = true;
      p2[prev] = dest;
    }
  }
  for (int i = 0; i < n; i++) {
//    cout<<" " << p2[i] << " "<< endl;
  }
  p = p2;
  vector<int> dists(n, -1);
  queue<int> que;
  que.push(0);
  dists[0] = 0;
  while (!que.empty()) {
    int s = que.front();
    que.pop();
    int dist = dists[s];

    for (int i = 1; i <= 6; i++) {
      if (p[s+i] != LOOP && dists[p[s+i]] == -1) {
        dists[p[s+i]] = dist+1;
        que.push(p[s+i]);
        if (p[s+i]+1 >= n) {
 //         rep(j,n) cout << dists[j]<< " ";
          cout << dist+1 << endl;
          return 0;
        }
      }
    }
  }
  
  
  return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<pair<int,int>> v;
  rep(i,n) {
    int x,y;
    cin>>x>>y;
    if(x != 0 || y != 0) v.pb({x,y});
  }

  sort(all(v), [](auto &l, auto &r){
    auto m = [](pair<int,int> &p){
      using PID = pair<int, double>;
      if(p.first == 0){
        if(p.second > 0) return PID{0, p.second};
        else return PID{2, p.second};
      }
      else if (p.first > 0) return PID{1, -(double)p.second/p.first};
      else return PID{3, -(double)p.second/p.first};
    };
    return m(l) < m(r);
  });

  int m = v.size();
  rep(i,m) v.pb(v[i]);

  double ans =  0;
  rep(i,m) {
    long dx  = 0, dy = 0;
    rep(j, m) {
      dx += v[i+j].first;
      dy += v[i+j].second;
      ans = max(ans, sqrt(dx*dx + dy*dy));
    }
  }

  printf("%.10f\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>			//cout,endl,cin
#include <string>			//string,to_string,stoi
#include <vector>			//vector
#include <algorithm>		//min,max,swap,sort,reverse,lower_bound,upper_bound
#include <utility>			//pair,make_pair
#include <tuple>			//tuple,make_tuple
#include <cstdint>			//int64_t,int*_t
#include <cstdio>			//printf
#include <map>				//map
#include <queue>			//queue,priority_queue
#include <set>				//set
#include <stack>			//stack
#include <deque>			//deque
#include <unordered_map>	//unordered_map
#include <unordered_set>	//unordered_set
#include <bitset>			//bitset
#include <cctype>			//isupper,islower,isdigit,toupper,tolower
#include <math.h>
#include <cstdio>
#include <cstring>
#include <iomanip>

using namespace std;

int main(void) {
    string s;
    string t;
    int len;
    int i;
    int j = 0;

    cin >> s >> t;
    len = s.size();

    for (i = 0; i <= len-1; i++) {
        if (s.at(i) != t.at(i)) {
            j++;
        }
    }

    if (j == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }


   // cout << s << t << endl;


}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  string S;
  cin>>S;
  int N=S.size();
  vector<int> A(N+1,0),B(N+1,0);
  for(int i=0;i<N;i++){
    if(S[i]=='<')
      A[i+1]=A[i]+1;
    else
      A[i+1]=0;
  }
  for(int i=N;i>0;i--){
    if(S[i-1]=='>')
      B[i-1]=B[i]+1;
    else
      B[i-1]=0;
  }
  int ans=0;
  for(int i=0;i<=N;i++)
    ans+=max(A[i],B[i]);
  cout<<ans<<endl;
}

Measured memory_bytes: 11668
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[200001],b[200001];
  long long ans=0;
  set<int> s;
  cin>>n;
  for(int i=1;i<=n;i++)cin>>a[i],b[a[i]]=i;
  s.insert(0);
  s.insert(n+1);
  for(int i=1;i<=n;i++){
    set<int>::iterator it=s.lower_bound(b[i]);
    long long right = (*it) -b[i];
    it--;
    long long left = b[i] - (*it);
    ans+=right*left*i;
    s.insert(b[i]);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int s;
	cin >> s;
	vector<int> f(1000000);
	f[0] = s;
	int ans = 1;
	for (int i = 1;; i++) {
		if (f[i - 1] % 2 == 0) f[i] = f[i - 1] / 2;
		else f[i] = 3 * f[i - 1] + 1;
		ans++;
		for (int j = 0; j < i; ++j) {
			if (f[j] == f[i]) {
				cout << ans << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <boost/format.hpp>
#include <algorithm>
using namespace std;

int KetaCount(int Num){
    string tmp = (boost::format("%1%") % Num).str();
    return (int)(tmp.length());
}

int main(void){
    int N;
    int GetKeta;
    int cnt = 0;
    cin >> N;

    for(int i=1; i<=N; i++){
        GetKeta = KetaCount(i);
        if(GetKeta%2 == 1) cnt++;
    }
    cout << cnt <<endl;
    return 0;
}

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

using namespace std;

int main() {
    int money = 100000;
    int n;
    cin >> n;
    for (int i=0; i<n; ++i) {
        money = money + ceil(money * 0.05 / 1000) * 1000;
    }
    cout << money << endl;
    return 0;
}

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

#define Online 1
// #define multitest 1
// #define Debug 1
typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;
void ControlIO();
void TimerStart();
void TimerStop();
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

void solve()
{
	int n, k;
	cin >> n >> k;
	vector<int> V;
	for (int i = 0; i < n; ++i)
	{
		int x;
		cin >> x;
		V.pb(x);
	}
	ll answer = 0;
	priority_queue<int, vector<int>, greater<int>> Q;
	for (int leftcnt = 0; leftcnt <= n; ++leftcnt)
	{
		if (leftcnt)
			Q.push(V[leftcnt - 1]);
		if (Q.size() > k)
			break;
		auto q1 = Q;
		for (int right = 0; right <= n; right++)
		{
			if (right)
				Q.push(V[n - right]);
			if (Q.size() > k)
				break;
			if (Q.size() > n)
				break;
			db(leftcnt, right, Q.size());
			int Remove = k - Q.size();
			while (Remove >= 0)
			{
				int r = Remove;
				Remove--;
				auto q2 = Q;
				ll sum = 0;
				while (Q.size())
				{
					if (r)
					{
						if (Q.top() < 0)
							r--;
						else
							sum += Q.top();
					}
					else
						sum += Q.top();
					Q.pop();
				}
				if (sum > answer)
					db(leftcnt, right, Remove + 1, q2.size());
				answer = max(answer, sum);
				Q = q2;
			}
		}
		Q = q1;
	}
	cout << answer;
}

int main()
{
	ControlIO();
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	TimerStart();
	while (t--)
		solve();
	TimerStop();
	return 0;
}

void ControlIO()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifndef Online
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();

void TimerStart()
{
#ifndef Online
	TimeStart = chrono::steady_clock::now();
#endif
}

void TimerStop()
{
#ifndef Online
	TimeEnd = chrono::steady_clock::now();
	auto ElapsedTime = TimeEnd - TimeStart;
	cout << "\n\nTime elapsed: " << chrono::duration<double>(ElapsedTime).count() << " seconds.\n";
#endif
}

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

int main()
{
  int h,w;
  cin >> h >> w;
  char a[h][w];
  int b[h][w];
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      cin >> a[i][j];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int d=0;
      for(int k=j;k>=0;k--){
        if(a[i][k]=='c'){
          b[i][j]=j-k;
          d++;
          break;
        }
      }
      if(d==0) b[i][j]=-1;

    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w-1;j++)
      cout << b[i][j] << " ";
    cout << b[i][w-1] << endl;
  }
  return 0;
}



Measured memory_bytes: 3152
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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









int main(){
    ll n;
    cin >> n;
    vector<ll> x(n), y(n);
    REP(i, n){
        cin >> x[i];
    }
    ll ans = 0;
    REP(i, n){
        cin >> y[i];
        ans += max(x[i] - y[i], 0LL);
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<string.h>
#include<stdlib.h>
using namespace std;

int main()
{
	int i=0,j,count=0;
	string W,s;
	char temp[10];
	getline(cin,W);
	while(getline(cin,s))
	{
		i=0;
		if(s == "END_OF_TEXT") {
			cout<<count<<endl;
			return 0;
		}
		while(i<s.size())
		{
			j=0;
			while ((s[i]>='a'&&s[i]<='z') || (s[i]>='A'&&s[i]<='Z' ) )
			{
				temp[j] = s[i];
				i++,j++;
			}
			temp[j] ='\0';
			if(W.size() != strlen(temp)){
				i++;
				continue;
			}
			else
			{
				for(j=0;j<W.size();j++)
				{
					if((temp[j] != W[j]) && (abs(temp[j] - W[j]) != 32))
						break;
				}
				if(j==W.size()) count++;
				i++;
			}		
		}
	}
	return 0; 
}



Measured memory_bytes: 3184
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <regex>
#include <complex>

using ll = long long;
using ull = unsigned long long;
using ld = long double;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;
    // cerr.rdbuf(nullptr);

    int n;
    cin >> n;
    vec<int> A(n);
    for (auto& e : A)
        cin >> e;

    auto ans = 1.0 / accumulate(A.cbegin(), A.cend(), 0.0, [](double init, double x) {return init + 1.0 / x; });

    cout << fixed << ans << endl;

    return 0;
}

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

using namespace std;

int main(){
    string s;
    cin>>s;
    int cnt = 0,ans = 0;
    for(char x:s){
        if(x=='R'){
            cnt++;
            ans = max(ans,cnt);
        }else{
            cnt = 0;
        }
    }
    cout<<ans;
}


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

#define int long long

signed main() {
    int N;
    cin >> N;
    int a[N];
    for (int i = 0; i < N; i ++) {
        cin >> a[i];
    }
    int i = 0;
    int round = 0;
    while(round < N) {
        i = a[i] - 1;
        round ++;
        if (i == 1) {
            cout << round << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
int a[1001];
void solve()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	double ans = a[0];
	for (int i = 1; i < n; i++)
	{
		ans = (ans + a[i]) / 2;
	}
	cout << fixed << setprecision(15) << ans << endl;
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		int i1 =scan.nextInt();
		int i5 =scan.nextInt();
		int i10 =scan.nextInt();
		int i50 =scan.nextInt();
		int i100 =scan.nextInt();
		int i500 =scan.nextInt();
		if(i1 + i5*5 + i10*10 + i50*50 + i100*100 + i500*500 >=1000){
			System.out.println(1);
		}else{
			System.out.println(0);
		}
	}
}

Measured memory_bytes: 17168
#include <bits/stdc++.h>
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
using namespace std;

int main(){
    int n, k, d, a;
    set<int> S;
    cin >> n >> k;
    REP(int,i,1,n+1) S.insert(i);

    REP(int,i,0,k){
        cin >> d;
        REP(int,j,0,d){
            cin >> a;
            S.erase(a);
        }
    }
    cout << S.size() << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main () {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> data(H, vector<char>(W));
  vector<vector<pair<int,int>>> sub(H, vector<pair<int, int>> (W));
  vector<int> cont;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> data.at(i).at(j);
    }
  }
  int count = 0, co = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(data.at(i).at(j) == '#'){
        sub.at(i).at(j).first = -1;
        if(co != 0){
          cont.push_back(co);
          co = 0;
          count++;
        }
      } else {
        co++;
        sub.at(i).at(j).first = count;
      }
    }
    if(co != 0){
      cont.push_back(co);
      co = 0;
      count++;
    }
  }
  
  for(int i = 0; i < W; i++){
    for(int j = 0; j < H; j++){
      if(data.at(j).at(i) == '#'){
        sub.at(j).at(i).second = -1;
        if(co != 0){
          cont.push_back(co);
          co = 0;
          count++;
        }
      } else {
        co++;
        sub.at(j).at(i).second = count;
      }
    }
    if(co != 0){
      cont.push_back(co);
      co = 0;
      count++;
    }
  }
  
  int ans = -1;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(sub.at(i).at(j).first != -1){
        ans = max(ans, cont.at(sub.at(i).at(j).first) + cont.at(sub.at(i).at(j).second) - 1);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 45676
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
vector<int> A(1e6);
int N, K;

bool isOK(ll len) {
    ll cnt = 0;
    rep(i, N) {
        if (A[i] == len) continue;
        cnt += A[i] / len;
    }
    if (K >= cnt) return true;
    return false;
}
int main()
{
    
    cin >> N >> K;
    rep(i, N) cin >> A[i];

    ll left = 0, right = 1e18;

    while (right - left > 1) {
        ll mid = left + (right - left) / 2;
        if (isOK(mid)) right = mid;
        else left = mid;
    }

    cout << right << endl;
    return 0;
}

Measured memory_bytes: 7064
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N;
    int k;
    vector<int> ans[1000];
    cin >> N;
    bool find = false;
    for(int i = 1; i*(i-1)/2 <= N; i++){
        if(i*(i-1)/2 == N){
            find = true;
            k = i;
            break;
        }
    }
    if(find){
        int cnt = 1;
        for(int i = 0; i < k; i++){
            for(int j = i+1; j < k; j++){
                ans[i].push_back(cnt);
                ans[j].push_back(cnt);
                cnt++;
            }
        }
        //output
        cout << "Yes" << endl;
        cout << k << endl;
        for(int i = 0; i < k; i++){
            cout << k-1 << ' ';
            for(int j = 0; j < k-1; j++){
                cout << ans[i][j];
                if(j != k-1) cout << ' ';
            }
            cout << endl;
        }
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 2304
// https://abc042.contest.atcoder.jp/tasks/abc042_a
#include <iostream>

using namespace std;

int main() {
	int a = 0, b = 0, x;
	for (int i = 0; i < 3; i++) {
		cin >> x;
		if (x == 5) a++;
		else if (x == 7) b++;
	}
	if (a == 2 && b == 1) cout << "YES\n";
	else cout << "NO\n";
}


Measured memory_bytes: 256
n = int(input())
a = sorted([int(input()) for i in range(n)])
b = list(a[::-1])



def f(A):
    l = r = A.pop(0)

    ans = 0

    for i in range(len(A)//2):
        if i % 2 == 0:
            ans += abs(l - A[-1]); l = A.pop(-1);
            ans += abs(r - A[-1]); r = A.pop(-1);
        else:
            ans += abs(l - A[0]); l = A.pop(0);
            ans += abs(r - A[0]); r = A.pop(0);
    if (A):
        ans += abs(l - A[0])

    return ans


print(max(f(a), f(b)))

Measured memory_bytes: 8632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        long K = Long.parseLong(sc.next());
        long gosencho = 5000000000000000l;

        long cur = 0;
        for (int i = 0; i < s.length(); i++) {
            long n = s.charAt(i) - 48;
            cur += Math.pow(n, gosencho);
            if (cur >= K) {
                System.out.println(n);
                return;
            }
        }
    }
}


Measured memory_bytes: 22996
#include <stdio.h>
#include <stdlib.h>
#define num 1000000
#define true 1
#define false 0

void pollock();
int min(int f1,int f2);
int *dp_ki;
int *dp;
int N;

int main(){
  dp_ki = (int *)malloc(num * sizeof(int));
  dp = (int *)malloc(num * sizeof(int));
  for(int i=0;i<num;i++){
    dp[i]=i;
    dp_ki[i]=i;
  }
  pollock();

  while(scanf("%d",&N),N){
    printf("%d %d\n",dp[N],dp_ki[N] );
  }

  free(dp_ki);
  free(dp);
  exit(0);
}

int min(int f1,int f2){
  if(f1>f2){
    return f2;
  }else{
    return f1;
  }
}

void pollock(){
  for(int n=3,p=4;p<num;n++){
    for(int i=0;i+p<num;i++){
      dp[i+p] = min(dp[i+p],dp[i]+1);
      // dp[i+p] = dp[i] + 1;
    }
    if(p%2){
      for(int i=0;i+p<num;i++){
        dp_ki[i+p] = min(dp_ki[i+p],dp_ki[i]+1);
        // dp_ki[i+p] = dp_ki[i] + 1;
      }
    }
    p= n*(n+1)*(n+2)/6;
  }
}



Measured memory_bytes: 8964
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ignore ignore
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define bitcount(x)  __builtin_popcount(x)
#define bitcountll(x)  __builtin_popcountll(x)
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define YES printf("YES\n")
#define NO printf("NO\n")
#define yes printf("Yes\n")
#define no printf("No\n")
#define lin printf("\n")
// Iterator
#define rep(i,n) for(i=0;i<n;++i)
#define rrep(i,n) for(i=n-1;i>=0;--i)
#define lp(i,a,b) for(i=a;i<b;++i)
#define rlp(i,a,b) for(i=a;i>=b;--i)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// function
#define sz(x) x.size()
#define inrange(i,a,b) (i>=a && i<=b)
#define FLUSH fflush(stdout)
#define precision(x) cout << setprecision(x) << fixed
#define remax(a,b) a=max(a,b)
#define remin(a,b) a=min(a,b)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
// Constant
const double PI = acos(-1);
const double eps = (1e-9);
const ll INF = 2e15;
const int M = (1e9)+7;
const ll N = (2e5)+1;  // check the limit, man
int main()
{
    int n,i,a,b,r;
    in(n);
    vii vp(n);
    rep(i,n)
    {
        in2(a,b);
        vp[i]={a-b,a+b};
    }
    sort(all(vp));
    int ans=0;
    r=-M;
    rep(i,n)
    {
        tie(a,b)=vp[i];
        if(a>=r)
            ans++,r=b;
        else
            remin(r,b);
    }
    out(ans);
}






Measured memory_bytes: 1024
n, q = gets.split.map(&:to_i)

hash = Hash.new{|h,k| h[k] = []}
arr = []
n.times{|i|
  arr[i] = i
  hash[i] << i
}

q.times{
  com, x, y = gets.split.map(&:to_i)
  case com
  when 0
    ax = arr[x]
    ay = arr[y]
    next if ax == ay
    ax, ay = ay, ax if ax > ay
    hash[ay].each{|i|
      arr[i] = ax
      hash[ax] << i
    }
  when 1
    if arr[x] == arr[y] then
      puts "1"
    else
      puts "0"
    end
  end
}

Measured memory_bytes: 9656
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o set
const ll INF = 1e18;
vector<int> G[200100];
vector<ll> ans(200200);
void dfs(int pre,int s){
    for(int u:G[s]){
        if(u==pre) continue;
        ans[u]+=ans[s];
        dfs(s,u);
    }
}
signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n,q; cin >> n >> q;
    rep(i,n-1){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].pb(b); G[b].pb(a);
    }
    rep(i,q){
        int p,x; cin >> p >> x;
        p--;
        ans[p]+=x;
    }
    dfs(-1,0);
    rep(i,n) cout << ans[i] << " ";
}


Measured memory_bytes: 25072
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = S()
if N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 74644
#![allow(dead_code, unused_variables, unused_macros, unused_imports)]

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $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") }; }

// vの中でx以上となる最初のインデックスを返す
fn bsearch<T>(v: &Vec<T>, x: T) -> Option<usize>
where
    T: Copy + PartialOrd,
{
    let is_ok = |i, key| v[i] >= key;
    let mut ng = -1;
    let mut ok = v.len() as i32;
    while (ok - ng).abs() > 1 {
        let mid = (ok + ng) / 2;
        if is_ok(mid as usize, x) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    if ok == -1 {
        None
    } else {
        Some(ok as usize)
    }
}

fn main() {
    input! {
        n: usize,
        q: usize,
        s: String,
        lr: [(usize1, usize1); q],
    }

    let mut v = Vec::new();
    for i in 0..n - 1 {
        if &s[i..i + 2] == "AC" {
            v.push(i);
        }
    }

    for &(l, r) in lr.iter() {
        match (bsearch(&v, l), bsearch(&v, r)) {
            (Some(l), Some(r)) => println!("{}", r - l),
            _ => println!("0"),
        }
    }
}


Measured memory_bytes: 6908
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int k, t;
vector<int> a;

void mainmain(){
    cin >> k >> t;
    for (int i = 0;i < t; i++){
        int m;
        cin >> m;
        a.push_back(m);
    }
    sort(a.begin(),a.end(),greater<int>());
    int ans = a[0]-1;
    for(int i = 0; i< t;i++){
        if (i == 0)continue;
        ans -= a[i];
        if (ans <= 0) {
            ans = 0;
            break;
        }
    }
    cout << ans <<endl;

}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define int long long
const int mod = 1e9 + 7;
void test_case(){
	int n; cin>>n;
	int a[n], sum = 0;
	for(int i=0;i<n;i++) {
		cin>>a[i];
		sum += a[i];
		sum %= mod;
	}
	int ans = 0;
	for(int i=0;i<n;i++){
		sum -= a[i];
		sum = (sum + mod) % mod;
		int t = sum * a[i];
		t%=mod;
		ans += t;
		ans %= mod;
	}
	cout<<ans<<endl;
	
	
}
		
 
signed main(){
	IOS;
	int t=1, i=1; 
	//cin>>t;
	while(t--){
		//cout<<"Case #"<<i<<": ";
		test_case();
		i++;
	}
}


Measured memory_bytes: 5176
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=tf-8
#

"""
"""

from collections import defaultdict
import bisect

import sys
input = sys.stdin.readline

def solve(d,t,s):
    if (d+s-1)//s <= t:
        print('Yes')
    else:
        print('No')

            

def main():
    d,t,s = map(int,input().split())
    solve(d,t,s)


if __name__ == "__main__":
    main()

Measured memory_bytes: 65044
n, k, s = io.read("*n", "*n", "*n")
if n - k < s then
  t = {}
  for i = 1, k do
    t[i] = s
  end
  for i = k + 1, n do
    t[i] = 1
  end
  print(table.concat(t, " "))
else
  t = {}
  for i = 1, k do
    t[i] = s
  end
  for i = k + 1, n do
    t[i] = s + 1
  end
  print(table.concat(t, " "))
end


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

int main() {
  int N, X;
  cin >> N >>X;
  int m[110];
  int sum1 = 0;

  for(int i = 0; i < N; i++) {
    cin >> m[i];
    sum1 += m[i];
  }

  sort(m, m + N);
  int ans = N;
  X = X - sum1;
  

  for(int i = 0; i < N; ++i) {
    if(X < 0) break;
    int d = X / m[i];
    ans += d;
    X = X % m[i];
  
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
using System;

class program
{
    static void Main()
    {
        for(int i = 1; i < 10; i++)
        {
            for (int j=1; j< 10;j++)
            {
                int multip = i * j;
                Console.WriteLine("{0}x{1}={2}", i, j, multip);
            }
        }
    }
}

Measured memory_bytes: 9080