akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <limits>

constexpr int INF = std::numeric_limits<int>::max() / 3;

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};
};

template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;

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

    Graph<> graph(n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        std::cin >> u >> v;
        --u, --v;
        graph[u].emplace_back(u, v);
    }

    std::vector<int> ans;

    for (int s = 0; s < n; ++s) {
        std::vector<int> dist(n, INF), prev(n, -1);
        std::queue<int> que;

        for (auto e : graph[s]) {
            int u = e.dst;
            dist[u] = 1;
            que.push(u);
        }

        while (!que.empty()) {
            int v = que.front();
            que.pop();

            for (auto e : graph[v]) {
                int u = e.dst;
                if (dist[u] < INF) continue;

                dist[u] = dist[v] + 1;
                prev[u] = v;
                que.push(u);
            }
        }

        if (dist[s] < INF &&
            (ans.empty() || dist[s] < ans.size())) {
            ans.clear();
            int v = s;
            do {
                ans.push_back(v);
                v = prev[v];
            } while (v != -1);
        }
    }

    if (ans.empty()) {
        std::cout << -1 << std::endl;
    } else {
        std::cout << ans.size() << std::endl;
        for (auto v : ans) {
            std::cout << v + 1 << std::endl;
        }
    }
    return 0;
}


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

int a, b, c = 0;


int main() {
	cin >> a >> b >> c;
	if (a == b) {
		if (b == c) {
			cout << "Yes\n";
		}
		else {
			cout << "No\n";
		}
	}

	else {
		cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int n, k;
multiset<int> p;

int main()
{
  ll ans=0;
  int inp;

  cin >> n >> k;
  for (int i=0; i<n; i++) {
    cin >> inp;
    p.insert(inp);
  }
  for (auto it=p.begin(); k>0; it++) {
    ans += *it;
    k--;
  }

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


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


int main(){
  int K, X;
  cin >> K >> X;
  for(int ii=X-K+1; ii<X+K; ii++){
    if(ii != X-K+1) cout << " ";
    cout << ii;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
use std::process;
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}
fn main() {
    let (a,b) = get!(i32,i32);
    let mut ans = 1;

    if b == 1 {
        println!("0");
        process::exit(0);
    }


    loop {
        if 1+a*ans-ans >= b {
            break;
        }
        ans += 1;
    }
    
    println!("{}" , ans);
}


Measured memory_bytes: 4352
<?php
// $n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));

$n = (int)$input[0];
$m = (int)$input[1];

$ms = [];
for ($i=0; $i < $m; $i++) { 
	$input = (int)trim(fgets(STDIN));
	$ms[$input] = true;
}

if ($n === 1) {
	if (isset($ms[1])) {
		echo 0;
	}else{
		echo 1;
	}
	exit();
}

$dp = [];
$dp[0] = 1;
if (isset($ms[1])) {
	$dp[1] = 0;
}else{
	$dp[1] = 1;
}

for ($i=2; $i <= $n; $i++) { 
	if (isset($ms[$i])) {
		$dp[$i] = 0;
	}else{
		$dp[$i] = ($dp[$i-2] + $dp[$i-1]) % 1000000007;
	}
}

echo $dp[$n];

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

using namespace std;

#define _int64 long long

_int64 a[60];

int main()
{
  _int64 i,j,n,tmp,ans,b1;
  scanf("%lld",&n);
  for (i=0;i<n;i++)
    scanf("%lld",&a[i]);
  ans=0;
  b1=1;
  while (b1==1)
  {
    b1=0;
    for (i=0;i<n;i++)
      if (a[i]>=n)
      {
        b1=1;
        tmp=a[i]/n;
        a[i]%=n;
        ans+=tmp;
        for (j=0;j<n;j++)
          if (i!=j) a[j]+=tmp;
      }
  }
  printf("%lld\n",ans);
  return 0;
}

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


using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;


ll pow_mod(ll n, ll k, ll m) {
	ll r = 1;
	for (; k > 0; k >>= 1) {
		if (k & 1)r = (r*n) % m;
		n = (n*n) % m;
	}
	return r;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

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

int main() {

	int n;
	cin >> n;

	vector<int> v(n), w(n);
	REP(i, n)cin >> v[i];
	
	vector<ll> a(1000005, 0);

	w = v;

	REP(i, n) {
		for (int j = 2; j*j <= w[i]+10; j++) {
			ll cnt = 0;
			while (v[i] % j == 0) {
				v[i] /= j;
				cnt++;
			}
			a[j] = max(a[j], cnt);
		}
		a[v[i]] = max(a[v[i]], 1LL);
	}

	ll b = 1;

	FOR(i, 2, 1000005) {
		if (a[i] == 0)continue;
		ll c = pow_mod(i, a[i], mod);
		b *= c;
		b %= mod;
	}
	
	ll ans = 0;

	REP(i, n) {
		ans += b * modinv(w[i], mod);
		ans %= mod;

	}

	cout << ans << endl;


}

Measured memory_bytes: 8192
from math import sqrt, sin, cos, acos, atan2
c1x,c1y,r1 = map(int,input().split())
c2x,c2y,r2 = map(int,input().split())
c1 = [c1x, c1y]
c2 = [c2x, c2y]
def dot(a, b):
    return sum([i * j for i,j in zip(a, b)])
def add(a,b):
    return [a[0] + b[0],a[1] + b[1]]
def sub(a, b):
    return [a[0] - b[0],a[1] - b[1]]
def multi(k, a):
    return [k*a[0],k*a[1]]
def cross(a, b):
    return  a[0] * b[1] - a[1] * b[0]
def norm(a):
    return sqrt(a[0] ** 2 + a[1] ** 2)    
def proj(p, l):
    base = sub(l.p2, l.p1)
    hypo = sub(p, l.p1)
    t = dot(hypo,base) / norm(base)
    return add(l.p1, multi(t/norm(base), base))
def polar(a,r):
    return [cos(r) * a, sin(r) * a]

d = norm(sub(c2,c1))
a = acos((r1**2 + d **2 - r2**2)/(2 * r1 * d))
c2c1 = sub(c2,c1)
t = atan2(c2c1[1],c2c1[0])
ans1 = add(c1, polar(r1, t+a))
ans2 = add(c1, polar(r1, t-a))

ans = sorted([ans1] + [ans2], key=lambda x: (x[0],x[1]))
print(' '.join([str(round(i, 9)) for o in ans for i in o]))

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

int main() {
	int N, X, T;
	int i = 0;
	cin >> N >> X >> T;

	if (N <= X) {
		cout << T << endl;
	}
	else {
		if ((N % X) == 0) {
			cout << (N / X) * T << endl;
		}
		else {
			while ((N - X) > 0) {
				N = N - X;
				i++;
			}

			i++;
			cout << T * i << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 3476
#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  std::string s; std::cin >> s;
  size_t n = s.length();
  std::vector<std::string> ngt;
  for (size_t i = 0; i < n; i++) {
    for (size_t j = 1; j <= std::min((size_t)5, n - i); j++) {
      ngt.push_back(s.substr(i, j));
    }
  }
  std::sort(ngt.begin(), ngt.end());
  ngt.resize(std::unique(ngt.begin(), ngt.end()) - ngt.begin());
  size_t k; std::cin >> k;
  assert(k <= ngt.size());
  std::cout << ngt.at(k - 1) << std::endl;
  return 0;
}

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

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

ll MOD = 1000000007;

struct UnionFindTree{
	int par[22],r[22];
	void init(int n = 22){
		for(int i = 0 ; i < n ; i ++){
			par[i] = i;
			r[i] = 0;
		}
	}
	int find(int x){
		if(par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	bool same(int x,int y){
		return find(x) == find(y);
	}
	void unit(int x,int y){
		if(same(x,y))return;
		x = find(x);
		y = find(y);
		if(r[x] < r[y]){
			par[x] = y;
		}
		else {
			par[y] = x;
			if(r[x] == r[y]){
				r[x] ++;
			}
		}
	}
}uf;

int main(){
	int n,m;
	int a[200],b[200];
	cin >> n >> m;
	for(int i = 0 ; i < m ; i ++){
		cin >> a[i] >> b[i];
	}
	
	static int r[1<<19] = {};
	for(int i = 0 ; i < (1<<(n-1)) ; i ++){
		uf.init();
		for(int j = 0 ; j < n-1 ; j ++){
			if((i>>j)&1)uf.unit(a[j],b[j]);
		}
		for(int j = n-1 ; j < m ; j ++){
			if(uf.same(a[j],b[j]))r[i] ++;
		}
	}
	static int d[1<<19] = {};
	for(int i = 0 ; i < (1<<(n-1)) ; i ++){
		int t = i;
		while(t > 0){
			d[i] += t&1;
			t >>= 1;
		}
	}
	
	/*for(int i = 0 ; i < 8 ; i ++){
		cout << r[i] << " " << d[i] << endl;
	}*/
	
	static P dp[2][1<<19];
	int t=0,t_=1;
	for(int i = 0 ; i < (1<<(n-1)) ; i ++){
		dp[t][i] = P(0,0);
	}
	dp[0][0] = P(1,0);
	for(int i = 0 ; i < m ; i ++){
		for(int x = 0 ; x < (1<<(n-1)) ; ++x){
			dp[t_][x] = P(0,0);
		}
		for(int x = 0 ; x < (1<<(n-1)) ; ++x){
			if(dp[t][x] == P(0,0))continue;
			if(r[x]+d[x]-i > 0){
				dp[t_][x].first += dp[t][x].first*(r[x]+d[x]-i);
				dp[t_][x].second += dp[t][x].second*(r[x]+d[x]-i);
			}
			int j = ((1<<(n-1))-1)^x;
			ll s = dp[t][x].second+(i+1)*dp[t][x].first;
			//for(int j = 0 ; j < n-1 ; ++j)
			while(j != 0){
				int jj = j&-j;
				j -= jj;
				//if(x&(1<<j))continue;
				dp[t_][x+jj].first += dp[t][x].first;
				dp[t_][x+jj].second += s;
			}
		}
		for(int x = 0 ; x < (1<<(n-1)) ; ++x){
			if(dp[t_][x] != P(0,0)){
				if(dp[t_][x].first >= MOD){
					dp[t_][x].first %= MOD;
				}
				if(dp[t_][x].second >= MOD){
					dp[t_][x].second %= MOD;
				}
			}
		}
		swap(t,t_);
		/*cout << i << ":" << endl;
		for(int j = 0 ; j < 8 ; j ++){
			cout << dp[t][j].first << " " << dp[t][j].second << endl;
		}
		cout << "======================" << endl;*/
	}
	cout << dp[t][(1<<(n-1))-1].second << endl;
}



Measured memory_bytes: 20864
N,A,B,C,D = map(int,input().split())
S = ['#']+list(input())
CanReach = True
CanChange = False
for i in range(A,C):
    if S[i] == '#' and S[i+1] == '#':
        CanReach = False
for i in range(B,D):
    if S[i] == '#' and S[i+1] == '#':
        CanReach = False
if C < D:
    CanChange = True
else:
    for i in range(B,D+1):
        if S[i-1] == '.' and S[i] == '.' and S[i+1] == '.':
            CanChange = True
if CanReach and CanChange:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 75112
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] l = new int[n];
    int[] r = new int[n];
    int sum = 0;

    for (int i = 0; i < n; i++) {
      l[i] = sc.nextInt();
      r[i] = sc.nextInt();
    }

    for (int i = 0; i < n; i++) {
      sum += r[i]-l[i]+1;
    }

    System.out.println(sum);

  }

}


Measured memory_bytes: 25520
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    static readonly int[] dy = { -1, 1, 0, 0 };
    static readonly int[] dx = { 0, 0, -1, 1 };

    static void Main(string[] args)
    {
        while (true)
        {
            var input = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int W = input[0], H = input[1];
            if (W == 0 && H == 0) break;
            int N = int.Parse(Console.ReadLine());
            int[][] rect = Enumerable.Range(0, N).Select(i => Array.ConvertAll(Console.ReadLine().Split(), int.Parse)).ToArray();
            var hashX = new HashSet<int>();
            var hashY = new HashSet<int>();
            hashX.Add(0); hashX.Add(W);
            hashY.Add(0); hashY.Add(H);

            Action<int, int, HashSet<int>> Add = (pos, max, hash) =>
            {
                if (pos - 1 >= 0) hash.Add(pos - 1);
                hash.Add(pos);
                if (pos + 1 < max) hash.Add(pos + 1);
            };

            foreach (int[] a in rect)
            {
                Add(a[0], W, hashX); Add(a[2], W, hashX);
                Add(a[1], H, hashY); Add(a[3], H, hashY);
            }
            var xs = hashX.OrderBy(x => x).ToList();
            var ys = hashY.OrderBy(y => y).ToList();
            W = xs.Count - 1;
            H = ys.Count - 1;
            bool[][] board = Enumerable.Range(0, H).Select(i => new bool[W]).ToArray();
            foreach (int[] a in rect)
            {
                int x1 = xs.BinarySearch(a[0]), x2 = xs.BinarySearch(a[2]);
                int y1 = ys.BinarySearch(a[1]), y2 = ys.BinarySearch(a[3]);
                for (int y = y1; y < y2; y++)
                    for (int x = x1; x < x2; x++)
                        board[y][x] = true;
            }
            int ans = 0;
            for (int sy = 0; sy < H; sy++)
                for (int sx = 0; sx < W; sx++)
                    if (!board[sy][sx])
                    {
                        ans++;
                        board[sy][sx] = true;
                        Queue<int> que = new Queue<int>();
                        que.Enqueue(sy); que.Enqueue(sx);

                        while (que.Count > 0)
                        {
                            int y = que.Dequeue(), x = que.Dequeue();
                            for (int d = 0; d < 4; d++)
                            {
                                int ny = y + dy[d], nx = x + dx[d];
                                if (ny >= 0 && ny < H && nx >= 0 && nx < W && !board[ny][nx])
                                {
                                    board[ny][nx] = true;
                                    que.Enqueue(ny); que.Enqueue(nx);
                                }
                            }
                        }
                    }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 12772
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
w = []
tmp = 0
for i in A:
    if i == tmp:
        w[-1] += 1
    else:
        w.append(1)
        tmp = i
ans = 0
for i in w:
    ans += i%2
print(ans)

Measured memory_bytes: 8012
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')
def Z(f):
    if f:
        print('Yay!')
    else:
        print(':(')
def ispow(n):
    if int(n**.5)**2==n:
        return True
    return False

s = input()
for i in range(1, 6):
    if s == 'hi' * i:
        y(1)
        exit()
y(0)


Measured memory_bytes: 5072
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n, m;
vector<llint> G[100005];
llint dist[100005], rec[100005];

void bfs(vector<llint> G[], int S, llint dist[])
{
	queue<int> Q;
	Q.push(S);
	
	for(int i = 1; i <= n; i++) dist[i] = inf;
	dist[S] = 0;
	
	while(Q.size()){
		int v = Q.front();
		Q.pop();
		for(int i = 0; i < G[v].size(); i++){
			if(dist[G[v][i]] < inf/2) continue;
			Q.push(G[v][i]);
			dist[G[v][i]] = dist[v] + 1;
			rec[G[v][i]] = v;
		}
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	llint u, v;
	for(int i = 1;  i<= m; i++){
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	
	bfs(G, 1, dist);
	
	cout << "Yes" << endl;
	for(int i = 2; i <= n; i++) cout << rec[i] << endl;
	
	return 0;
}

Measured memory_bytes: 13680
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
	ll r,d,x;
	cin>>r>>d>>x;
	rep(i,10){
		x=r*x-d;
		cout<<x<<endl;
	}
    return 0;
}





Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0122

"""
import sys
from sys import stdin
from collections import namedtuple, deque
input = stdin.readline


def bfs(pyon, sprinklers):
    # ??´?????????????§????????????´????????§?¨??????????
    # ??? ?§?????????????(0, 0)??¨??????????????¢?????\???????????????
    dy = [-2, -2, -2, -1,  0,  1, -1, 0, 1,  2, 2, 2]
    dx = [-1,  0,  1, -2, -2, -2,  2, 2, 2, -1, 0, 1]

    # ??????????????°???(S)
    sx = pyon.x                 #  ??????????????°????????§?¨?
    sy = pyon.y
    num_sprinkler = len(sprinklers)
    jump = 0                    #  ?????£?????????????????°

    Q = deque()
    Q.append((sx, sy, jump))    #  ????????????????????????????????????????????°?????????????????§????????¨????????????????????????????????£?????????????¨???¶????????????
    while Q:
        cx, cy, jump = Q.popleft()        #  ?????¨??°?????§?¨?
        if jump >= num_sprinkler:         #  ???????????????????????????????????????????????????????????§?????????????????¨?????§?????????????????¶?????????????????????????????????????????????????????????OK???????
            return 'OK'
        for i in range(len(dx)):
            nx = cx + dx[i]
            ny = cy + dy[i]
            #  ?§?????????§?????????????????¨?????§????????°?????????????????¢?´¢????¶??????????????????\????????\????????????
            if is_safe(sprinklers, jump, nx, ny):
                Q.append((nx, ny, jump + 1))
    return 'NA'


def is_safe(sprinklers, jump, nx, ny):
    # ?????£????????????????????¬???????????°?????§?????????????????????????°´????±??????????????¢??????????
    if not 0 <= nx <= 9:
        return False
    if not 0 <= ny <= 9:
        return False
    sp_x = sprinklers[jump].x
    sp_y = sprinklers[jump].y
    if not sp_x - 1 <= nx <= sp_x + 1:
        return False
    if not sp_y - 1 <= ny <= sp_y + 1:
        return False
    return True


def can_survive(pyon, sprinklers):
    return bfs(pyon, sprinklers)


pos = namedtuple('pos', ['x', 'y'])
def main(args):
    while True:
        px, py = map(int, input().split()) #  ??´????????????????????????
        if px == 0 and py == 0:
            break
        pyon = pos(px, py)
        n = int(input())        #  ??????????????????????????°
        temp = [int(x) for x in input().split(' ')]
        sprinklers = []         #  ??????????????????????????§?¨?
        for i in range(n):
            sprinklers.append(pos(temp[i*2], temp[i*2+1]))

        result = can_survive(pyon, sprinklers)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 8172
#include<bits/stdc++.h>
using namespace std;
int C[1000000];
int main ()
{
    int n,d;
    cin >> n;
    int ans[n+10];
    pair<int,int> a[n+10];
    for(int i=0;i<n;i++){
            cin >> a[i].first;
            C[a[i].first]++;
            a[i].second=i;
    }
    sort(a,a+n);
    int mx = a[n-1].first;
    if(C[mx]>1)
    {
        for(int i=0;i<n;i++){
            cout<<mx<<"\n";
        }
        return 0;
    }
    int mx2 = a[n-2].first;
    for(int i=0;i<n;i++){
        if(a[i].first!=mx)
        ans[a[i].second]=mx;
        if(a[i].first==mx)
        ans[a[i].second]=mx2;
    }
    for(int i=0;i<n;i++){
            cout<<ans[i]<<"\n";
        }
    return 0;
}



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

int main(){
    int n,m,cnt,tmp,loop;
    while(cin >> n >> m,m && n){
        cnt = 0;
        tmp = n;
        loop = 0;
        bool ju[n+1];
        memset(ju,true,sizeof(ju));
        while(1){
            do{
                (tmp == n)? tmp = 1 : tmp++;
            }while(!ju[tmp]);
            cnt++;
            if(loop == n-1) break;
            if(cnt == m) {
                cnt = 0;
                loop++;
                ju[tmp] = false;
            }
        }
        for(int i=1;i<n+1;i++){
            if(ju[i]){
                cout << i << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 1168
import java.util.Arrays;
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    final Scanner scanner = new Scanner(System.in);
    final int n = scanner.nextInt();
    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = scanner.nextInt();
    }
    Arrays.sort(a);
    final int m = a[n - 1];
    int ans = -1;
    for (int i = 0; i < n - 1; i++) {
      int d = Math.min(a[i], m - a[i]);
      if (d > ans) ans = a[i];
    }
    System.out.println(m + " " + ans);
  }
}


Measured memory_bytes: 52472
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n,a[200010],v=1,nw,fac=1;
char c[200010];
int main(){
	scanf("%d%s",&n,c+1),n<<=1;
	for(int i=1;i<=(n>>1);++i)fac=1ll*fac*i%mod;
	for(int i=1;i<=n;++i)a[i]=c[i]=='B';
	nw=0;
	for(int i=1;i<=n;++i){
		if((((nw+1)^a[i])&1)==0)++nw;
		else if(nw)v=1ll*v*nw%mod,--nw;
		else return puts("0"),0;
	}
	if(nw)return puts("0"),0;
	printf("%lld",1ll*v*fac%mod);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, a, b, c, x);
	int ans = 0;
	REP(i, a + 1) {
		REP(j, b + 1) {
			REP(k, c + 1) {
				if (500 * i + 100 * j + 50 * k == x) {
					debug(i);
					debug(j);
					debug(k);
					ans++;
				}
			}
		}
	}
  OUT(ans)BR;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>		
typedef long long ll;
#define pb push_back
#define mod 1000000007ll
const ll maxn = 9e18;
using namespace std;
const ll maxsize = 100000009;

 
void solve() {
	ll n, b, r,t , rem;
	cin >> n >> b >> r;	
	t = n / (r + b);
	rem = n % (r + b);	
	ll ans = t * b;
	ans += min(rem, b);		
	cout << ans << endl;
	return;
}


	

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(35);
	solve();
	return 0;
}






Measured memory_bytes: 3592
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(A,B);
    cout << max(0,A-2*B) << nn;
    return 0;
}

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

using namespace std;

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

const double PI=3.14159265358979323846;

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

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

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

bool s[1000000001];

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

    int N;
    cin >> N;
    int A;
    bool ans = true;
    rep (i, N)
    {
        cin >> A;
        if (s[A])
        {
            ans = false;
        }
        else
        {
            s[A] = true;
        }
        if (!ans) break;
    }

    cout << (ans ? "YES\n" : "NO\n");
    return 0;
}



Measured memory_bytes: 975360
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int s[101];

int main(void) {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        int sum = 0;
        int ma = 0, mi = INF;
        for (int i = 0; i < n; i++) {
            cin >> s[i];
            ma = max(ma, s[i]);
            mi = min(mi, s[i]);
            sum += s[i];
        }
        sum -= (ma + mi);
        cout << sum / (n-2) << endl;
    }
    return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define PI (acos(-1))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

#define MAXN 1123456
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;

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

    int h, w;
    cin >> h >> w;

    int n;
    cin >> n;

    int k = max(h,w);
    cout << (n+k-1) / k << endl;;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int n, k, a[100000];

int gcd(int b, int c) {
	if (b < c) return gcd(c, b);
	if (c == 0) return b;
	return gcd(c, b % c);
}

int main(int argc, char **argv) {
	cin >> n >> k;
	REP(i, n) cin >> a[i];
	sort(a, a + n);
	int g = a[0];
	REP(i, n) g = gcd(g, a[i]);
	cout << (k <= a[n - 1] && k % g == 0 ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<string> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    bool ng = true;
    int co = n;
    vector<int> s(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (c[i][j] == '#') {
                ng = false;
                s[j]++;
                if (s[j] == n) {
                    co--;
                }
            }
        }
    }
    if (ng) {
        cout << -1 << endl;
        return 0;
    }
    int ans = INF;
    for (int i = 0; i < n; i++) {
        int t = co;
        if (s[i] == 0) {
            t++;
        }
        for (int j = 0; j < n; j++) {
            if (c[i][j] == '.') {
                t++;
            }
        }
        chmin(ans, t);
    }
    cout << ans << endl;
}

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

int main(){
    int n,q,t;
    cin >> n >> q;
    string name;
    queue<pair<string,int> >Q;
    pair<string, int> hoge;
    int ans = 0;
    int time;
    for(int i = 0; i < n; i++){
        cin >> name >> t;
        Q.push(make_pair(name,t));
    }
    while(!Q.empty()){
        hoge = Q.front();
        Q.pop();
        if(hoge.second <= q){
            ans += hoge.second;
            cout << hoge.first << " " << ans << endl;
        }
        else{
            ans += q;
            hoge.second -= q;
            Q.push(hoge);
        }

    }

}


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

using namespace std;

vector <vector <long long> > a,b,c;
int n,m,l;
int main(){
    cin>>n>>m>>l;
    for(int i=0;i<n;i++){
        vector<long long> t;
        for(int j=0;j<m;j++){
            int  A;
            cin>>A;
            t.push_back(A);
        }
        a.push_back(t);
    }
    for(int i=0;i<m;i++){
        vector<long long> t;
        for(int j=0;j<l;j++){
            int A;
            cin>>A;
            t.push_back(A);
        }
        b.push_back(t);
    }
    for(int i=0;i<n;i++){
        vector<long long>t;
        for(int j=0;j<l;j++){
            long long s=0;
            for(int k=0;k<m;k++){
                s+=a[i][k]*b[k][j];
            }
            t.push_back(s);
        }
        c.push_back(t);
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            cout<<c[i][j];
            if(j!=l-1) cout<<" ";
            else cout<<endl;
        }
    }
}

Measured memory_bytes: 1480
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
using u8t = std::uint64_t;
using i8t = std::int64_t;
#define F(I,N) for(i8t I=0,I##_N=N;I<I##_N;I++)
#define FR(I,N) for(i8t I=N;I--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;
int main() {
  R(N)R(M)RV(A,M);
  i8t sum=0;
  F(I,M)sum+=A[I];
  P(std::max<i8t>(N-sum,-1))
  return 0;
}


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

typedef long long ll;
typedef pair<int,int> PII;
#define CINSPEED std::ios::sync_with_stdio(false),std::cin.tie(0),std::cout.tie(0)
#define fi first
#define se second
#define pb push_back

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


const int N = 100010,M = 1000010;


void solved()
{
    int h,a;
    cin >> h >> a;
    if(h % a == 0)cout << h / a;
    else cout <<(h / a + 1);
}

int main()
{
    CINSPEED;

    solved();
#ifdef LOCAL
    system("pause");
#endif
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,t,i,j=0,min=99999;
    scanf("%d %d",&n,&t);

    int cost[n],time[n],cost2[n],time2[n];

    for(i=0;i<n;i++)
    {
        scanf("%d %d",&cost[i],&time[i]);
    }

      for(i=0;i<n;i++)
    {
        cost2[i]=0;
    }

    for(i=0;i<n;i++)
    {
        if(time[i]<=t)
        {
            cost2[j]=cost[i];
            time2[j]=time[i];
            j++;
        }
    }

    for(i=0;i<j;i++)
    {
        if(cost2[i]<=min)min=cost2[i];
    }

    if(min==99999)printf("TLE");
    else
    printf("%d",min);




}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll N,K;
vector<pair<ll,ll>> vec;

void solve() {
	cin >> N >> K;

	if (N - 1 > N*(N - 1) / 2 - K) {
		cout << -1;
		return;
	}

	vector<vector<int>> vec(N, vector<int>(N, 1));
	vector<int> con(N, N - 1);
	rep(i, N) {
		vec[i][i] = 0;
	}

	rep(i, K) {
		bool chk = false;
		rep(j, N) {
			if (con[j] == 1) continue;
			rep(k, N) {
				if (con[k] == 1) continue;
				if (vec[j][k] == 0) continue;

				vec[j][k] = 0;
				vec[k][j] = 0;
				con[j]--;
				con[k]--;
				chk = true;
				break;
			}
			if (chk == true) break;
		}
	}

	ll sum = 0;
	vector<pair<int, int>> ans;
	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			if (vec[i][j] == 1) {
				sum++;
				ans.emplace_back(make_pair(i, j));
			}
		}
	}

	cout << sum << endl;
	rep(i, ans.size()) {
		cout << ans[i].first+1 << " " << ans[i].second+1 << endl;
	}

}

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


Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <limits>
#include <memory>
#include <queue>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define all(a) (a).begin(), (a).end()
#define sz(a) static_cast<int>((a).size())
#define fillchar(a, x) memset(a, x, sizeof(a))
#define rep(i, a, b) for(int i=int(a); i<=int(b); ++i)
#define irep(i, a, b) for(int i=int(a); i>=int(b); --i)
#define replr(i, a, b) rep(i, a, (b)-1)
#define reprl(i, a, b) irep(i, (b)-1, a)
#define repn(i, n) rep(i, 0, (n)-1)
#define irepn(i, n) irep(i, (n)-1, 0)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<string> VS;
template<class T, class S> ostream& operator<<(ostream& os, const pair<T, S>& v) { return os<<"("<<v.first<<", "<<v.second<<")"; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { os<<"["; repn(i, sz(v)) { if(i) os<<", "; os<<v[i]; } return os<<"]"; }
template<class T> bool setmax(T &_a, T _b) { if(_b>_a) { _a=_b; return true; } return false; }
template<class T> bool setmin(T &_a, T _b) { if(_b<_a) { _a=_b; return true; } return false; }
template<class T> T gcd(T _a, T _b) { return _b==0?_a:gcd(_b,_a%_b); }

const int N=550;

char g[N][N], a[N][N];
int n, m;

int main() {
    scanf("%d%d", &n,&m);
    rep(i, 1, n) scanf("%s", g[i]+1);

    fillchar(a, '.');
    rep(i, 1, n) rep(j, 1, m) a[i][j]=(i%2==0?'a':'b');
    rep(i, 1, n) a[i][1]='a', a[i][m]='b';
    for(char ch='a'; ch<='b'; ++ch) {
        rep(i, 1, n) {
            rep(j, 1, m) if(g[i][j]=='#' || a[i][j]==ch) printf("#"); else printf(".");
            printf("\n");
        }
        printf("\n");
    }



    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,cnt=0,i,j;
    cin >> a >> b >> c >> d;
    while(1)
    {
        if(cnt%2==0)
        {
            cnt++;
            c=c-b;
            if(c<=0)
            {
                break;
            }
        }
        else
        {
            cnt++;
            a=a-d;
            if(a<=0)
            {
                break;
            }
        }
    }
    if(cnt%2==0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    int c = min(a, b);

    int t[c + 1];
    for (int i = 0; i < c + 1; ++i) {
        t[i] = 0;
    }
    int j = 1, i = 1;
    while (j != c + 1) {
        if ((!(a % j)) && (!(b % j))) {
            t[i] = j;

            i++;
        }
        j++;
    }
    vector<int> v;
    for (int i = 0; i< c+1; ++i) {
        if(t[i])
            v.push_back(t[i]);
    }
    cout << v[v.size()-k];

}



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

int main(){
  int X,A,B;
  cin>>X>>A>>B;
  if(A-B>=0){
    cout<<"delicious"<<endl;
  }else if(B-A<=X){
    cout<<"safe"<<endl;
  }else{
    cout<<"dangerous"<<endl;
  }
}


Measured memory_bytes: 256
from itertools import product

MOD = 10**9 + 7

L, R = map(int, input().split())

binR = bin(R+1)[2:]
maxD = len(binR)
binL = bin(L-1)[2:].zfill(maxD)

dp = [[[[0]*(2) for k in range(2)] for j in range(2)] for i in range(maxD+1)]
dp[0][0][0][0] = 1
for d, (Ld, Rd) in enumerate(zip(binL, binR)):
    Ld, Rd = int(Ld), int(Rd)
    for isLleX, isYleR, isNum in product(range(2), repeat=3):
        for x, y in [(0,0), (0,1), (1,1)]:
            if not isNum and (x, y) == (0, 1): continue
            if not isLleX and x < Ld: continue
            if not isYleR and y > Rd: continue
            isLleX2 = isLleX or x > Ld
            isYleR2 = isYleR or y < Rd
            isNum2 = isNum or y == 1
            dp[d+1][isLleX2][isYleR2][isNum2] += dp[d][isLleX][isYleR][isNum]
            dp[d+1][isLleX2][isYleR2][isNum2] %= MOD

print(dp[-1][1][1][1])


Measured memory_bytes: 3064
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define X real()
#define Y imag()
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]
const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b);
  }
}

//外積
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}

//内積
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

//線 (線分)
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

//多角形
typedef vector<P> G;

G convex_hull(G &ps) {
  int n = ps.size(), k = 0;
  sort(ps.begin(), ps.end());
  G ch(2*n);
  for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
    while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) == -1) --k;
  for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]) // upper-hull
    while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) == -1) --k;
  ch.resize(k-1);
  return ch;
}

int main() {
  int N; cin >>N;
  G g(N);
  REP(i, N){
    int x, y; cin >>x >>y;
    g[i] = P(x, y);
  }
  G ans = convex_hull(g);
  cout <<ans.size() <<endl;
  REP(i, ans.size()) cout <<ans[i].X <<" " <<ans[i].Y <<endl;
  return 0;
}

Measured memory_bytes: 5756
def main():
    _ = input()
    D = sorted([int(x) for x in input().split()])
    _ = input()
    T = sorted([int(x) for x in input().split()])

    current = 0
    for elem in T:
        while D[current] < elem:
            current += 1

        if D[current] > elem:
            print("NO")
            return

        current += 1

    print("YES")



if __name__ == "__main__":
    main()

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

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

    int n;
    string s, t;
    cin >> n >> s >> t;

    string news;
    rep(i, 0, n) {
        news.push_back(s[i]);
        news.push_back(t[i]);
    }
    cout << news << endl;

    return 0;
}

Measured memory_bytes: 256
N, M = list(map(int, input().split()))
G_min, G_max = map(list, zip(*[list(map(int, input().split())) for i in range(M)]))
G_min.append(1)
G_max.append(N)
G_min = max(G_min)
G_max = min(G_max)

if G_max >= G_min:
  print(G_max-G_min+1)
else:
  print(0)

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

int main() {
  string s;cin>>s;
  string ans="";
  for(int i=0; i<s.size(); i++){
    if(s[i]=='0')ans+='0';
    if(s[i]=='1')ans+='1';
    if(s[i]=='B'&&ans!="")ans=ans.substr(0,ans.size()-1);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 764
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	s := getRunes()
	n := len(s)

	ans := 0
	for bit := 0; bit < (1 << uint(n-1)); bit++ {
		cursor := 0
		for i := 1; i <= n; i++ {
			if (bit&(1<<uint(i-1))) > 0 || i == n {
				ans += atoi(s[cursor:i])
				cursor = i
			}
		}
	}

	fmt.Fprintln(wr, ans)
}

func atoi(rs []rune) int {
	i, _ := strconv.Atoi(string(rs))
	return i
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 640
#include<iostream>
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned int ui;
#define infin ll(pow(10,9)+7)
using namespace std;
int main()
{
    ll n,ans1=1,ans2=1,ans3=1;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        ans1=(ans1*10)%infin;
        ans2=(ans2*9)%infin;
        ans3=(ans3*8)%infin;
    }
    ll ans=(ans1-2*ans2+ans3+2*infin)%infin;
    cout<<ans<<endl;
}


Measured memory_bytes: 3604