akhauriyash/Code-Regression huggingface dataset:
def erato(n)
  numbers = (0..n).to_a
  numbers[0], numbers[1] = nil
  m = []
  for d in numbers
    next unless(d)
    break if (Math::sqrt(n) < d)
    (2*d..n).step(d){|e| numbers[e] = nil}
  end
  numbers.delete(nil)
  s = numbers.length
  return s
end
while line = gets
  p erato(line.to_i)
end

Measured memory_bytes: 33036
#include <math.h>
#include <assert.h>

#include <queue>
#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

template <typename T>
void in(T& x) {
    std::cin >> x;
}

template <typename T>
void out(const T H) {
    std::cout << (H);
}

template <typename T1, typename... T2>
void out(const T1 H, const T2... T) {
    std::cout << (H) << " "; out(T...);
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& v) {
    return os << v.first << " " << v.second;
}

template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
    int n = (int) v.size();
    for (int i = 0; i < n - 1; ++i) os << v[i] << ' ';
    return os << v[n - 1];
}

template <typename T>
void eout(const char *s, const T H) {
    std::cerr << s << "=" << H << "\n";
}

template <typename T1, typename... T2>
void eout(const char *s, const T1 H, const T2... T) {
    while (*s != ',') std::cerr << *s++;
    std::cerr << "=" << H << " | "; eout(++s, T...);
}

#define nl                std::cout << "\n"
#define err(args...)      eout(#args, args)

#define inn(x)            int x; in(x)
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define per(i, n)         for (int i = (n) - 1; i > -1; --i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)

#define sz(v)             ((int) v.size())
#define all(v)            (v).begin(), (v).end()
#define lla(v)            (v).rbegin(), (v).rend()

#define no                std::cout << "NO\n"
#define yes               std::cout << "YES\n"

const int INF           = 2147483647;
const long long int LNF = 9223372036854775807LL;

using ll  = long long int;
using vi  = std::vector<int>;
using vb  = std::vector<bool>;
using ii  = std::pair<int, int>;
using iii = std::pair< ii, int>;
using vii = std::vector<ii>;

const int N  = 505050;
const int MD = 1000*1000*1000 + 7;

int solve();
int main() {
    std::ios_base::sync_with_stdio(0); std::cin.tie(0);
    //std::cout.tie(0);

    //inn(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}

int solve() {
    inn(n); inn(m);
    vi job[m + 1];
    rep(i, n) {
        inn(x); inn(y);
        if (x <= m) job[m - x].push_back(y);
    }

    std::priority_queue<int> q;
    ll ans = 0;
    for (int i = m; i > -1; --i) {
        for (int j: job[i]) q.push(j);
        if (!q.empty()) ans += q.top(), q.pop();
    }
    out(ans);
    return 0;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long a[n];
  vector<long long> b;
  long long count = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a,a+n);
  for (int i = 0; i < n-1; i++) {
    if (a[i] == a[i+1]) {
      b.push_back(a[i]);
      i++;
      count++;
    }
  }
  if (b.size() > 1) cout << b[count-1] * b[count-2] << '\n';
  else cout << 0 << '\n';
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
inline void solve() {
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	if (a + b - 1 <= n && 1ll * n <= 1ll * a * b) {
		vector <long long> v;
		int A = 0;
		int B = b;
		while ((int)v.size() + a< n) {
			if (B == b) {
				a--;
			}
			v.push_back(1ll * A * b + 1ll * B);
			B--;
			if (B == 0) {
				B = b;
				A++;
			}
		}
		A++;
		if (B != b) {
			A++;
		}
		while ((int)v.size() < n) {
			v.push_back(1ll * A * b);
			A++;
		}
		vector <long long> v2;
		v2 = v;
		sort(v2.begin(), v2.end());
		for (int i = 0; i < (int)v.size(); i++) {
			int pos = (int)(lower_bound(v2.begin(), v2.end(), v[i]) - v2.begin());
			v[i] = pos + 1;
		}
		for (auto i: v) {
			printf("%lld ", i);
		}
		printf("\n");
	} else {
		printf("-1\n");
	}
}
int main() {
		solve();
}


Measured memory_bytes: 8684
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <complex>
#include <set>
#include <cmath>
using namespace std;

int A[10],B[10];

int main(){
	int W,H;
	while( cin >> W >> H && W ){
		for(int i = 0 ; i < W ; i++) cin >> A[i];
		for(int i = 0 ; i < H ; i++) cin >> B[i];
		sort(A,A+W);
		sort(B,B+H);
		int X[100]={},Y[100]={};
		int sum = 0;
		for(int i = 0 ; i < W ; i++) X[A[i]]++;
		for(int i = 0 ; i < H ; i++) Y[B[i]]++;
		int ans = 0;
		for(int i = 0 ; i < 100 ; i++){
			int doub = min(X[i],Y[i]);
			ans += i*(X[i] + Y[i] - doub);
		}
		cout << ans << endl;	
	}
}

Measured memory_bytes: 1180
<?php
fscanf(STDIN, "%d %d", $r, $c);
$format = join(' ', array_map(function ($f) { return '%d'; }, range(1, $c)));

$matrix = array();
$sum_cols = array_fill(0, $c, 0);

for ($i = 0; $i < $r; $i++) {
    $cols = fscanf(STDIN, $format);

    $sum = array_sum($cols);
    $cols[] = $sum;

    $matrix[] = $cols;

    for ($j = 0; $j < $c; $j++) {
        $sum_cols[$j] += $cols[$j];
    }
}

$sum = array_sum($sum_cols);
$sum_cols[] = $sum;

$matrix[] = $sum_cols;

for ($i = 0; $i < count($matrix); $i++) {
    echo join(' ', $matrix[$i])."\n";
}

Measured memory_bytes: 8124
import java.io.*;
import java.util.*;

public class Main {
    static InputReader in;
    static PrintWriter out;

    public static void main(String[] args) {
        in = new InputReader(); //use it for input
        out = new PrintWriter(System.out); //use it for output
        solve();
        out.close();
    }

    static void solve() {
        int n = in.nextInt();

        int f[] = new int[4];

        for(int i = 0; i < n; i++) {
            int x = in.nextInt();
            f[x]++;
        }

        double dp[][][] = new double[n + 1][n + 1][n + 1];

        for(int c3 = 0; c3 <= n; c3++) { //3
            for(int c2 = 0; c2 <= n; c2++) { //2
                for(int c1 = 0; c1 <= n; c1++) { //1
                    if(c1 + c2 + c3 > n)
                        continue;

                    if(c1 + c2 + c3 == 0)
                        continue;

                    dp[c1][c2][c3] = n;

                    if(c1 > 0)
                        dp[c1][c2][c3] += 1.0 * c1 * dp[c1 - 1][c2][c3];

                    if(c2 > 0)
                        dp[c1][c2][c3] += 1.0 * c2 * dp[c1 + 1][c2 - 1][c3];

                    if(c3 > 0)
                        dp[c1][c2][c3] += 1.0 * c3 * dp[c1][c2 + 1][c3 - 1];

                    dp[c1][c2][c3] /= 1.0 * (c1 + c2 + c3);
                }
            }
        }

        out.println(dp[f[1]][f[2]][f[3]]);
    }
}

class InputReader {
    BufferedReader rd;
    StringTokenizer tk;

    InputReader() {
        rd = new BufferedReader(new InputStreamReader(System.in), 32768);
    }

    public String readLine() {
        try {
            return rd.readLine();
        } catch (IOException e) {
            throw new RuntimeException();
        }
    }

    public String read() {
        while (tk == null || !tk.hasMoreTokens()) {
            tk = new StringTokenizer(readLine());
        }

        return tk.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(read());
    }

    public long nextLong() {
        return Long.parseLong(read());
    }

    public double nextDouble() {
        return Double.parseDouble(read());
    }
}

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

using namespace std;

int main() {

    long long h, n;
    cin >> h >> n;

    long long cn = 0;

    while (n--) {
        long long x;
        cin >> x;
        cn += x;
    }

    if (cn < h) {
        cout << "No";
    } else {
        cout << "Yes";
    }





    return 0;
}


Measured memory_bytes: 256
program sample
	implicit none
    integer :: x,a,b,c,d
    
    read(*,*) x,a,b
    
    c=abs(x-a)
    d=abs(x-b)
    
    if (c>d) then
    	write(*,*) 'B'
    else
    	write(*,*) 'A'
    end if
    
    stop
end program sample

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int  a,b;
	cin>>a>>b;
	if(a!=b){
		a++;
	}
	cout<<(a+b)/2<<endl;
	return 0;
}


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

W = [0]
E = [0]

for i in range(N): 
  s = S[i]
  if s == "W":
    W.append(W[-1] + 1)
    E.append(E[-1])
  else:
    W.append(W[-1])
    E.append(E[-1] + 1)


ans = float("inf")
for i in range(N):
  ans = min(ans, W[i] + (E[-1] - E[i+1]))
print(ans)

Measured memory_bytes: 17644
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    if N == 1:
        return 0
    max_divisor = math.sqrt(N)
    divisor = 2
    counter = 0
    while divisor <= max_divisor:
        temp_divisor = divisor
        while N%temp_divisor == 0:
            N //= temp_divisor
            temp_divisor *= divisor
            counter += 1
        while N%divisor == 0:
            N //= divisor
        divisor += 1
    if N != 1:
        counter += 1
    return counter


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 67648
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
int main(){
    
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   int e=d+c-a,f=c-(d-b);
   cout<<f<<" "<<e<<" ";
   int g=f-(c-a),h=e-(d-b);
   cout<<g<<" "<<h<<endl;
   
    
}

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

typedef long long ll;

int factorial(int x) {
	int res = 1;
	for (int i = 1; i <= x; ++i) {
		res *= i;
	}
	return res;
}

struct Point {
	int x, y;
};

double dist(Point a, Point b) {
	return sqrt(((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y))*1.0);	
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int facs = factorial(n-1), fac = facs*n;
	vector<Point> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i].x >> a[i].y;
	}
	double total = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i+1; j < n; ++j) {
			total += (dist(a[i], a[j])*2*facs);
		}
	}
	cout << fixed << setprecision(9) <<  1.0*total/fac << endl;
	return 0;
}

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S="",C="";
  cin>>S;
  for(int i=0;i<S.size();i++){
    if(S[i]=='0')C+='0';
    else if(S[i]=='1')C+='1';
    else if(S[i]=='B'&&C.size()>0)C.erase(C.size()-1);
  }
  cout<<C;
  cout<<endl;
}

Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())
# print(N)
# print(M)

hq = []
A = list(map(int, input().split()))
for x in A:
    heapq.heappush(hq, -x)
    
# print(hq)

for i in range(M):
    x = heapq.heappop(hq)
    x = int(x / 2)
    # print(x)
    heapq.heappush(hq, x)

# print(hq)
ans = 0
for x in hq:
    ans += -x
print(ans)

Measured memory_bytes: 14180
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(int i = a; i < n; ++i)
#define pb push_back
#define mp make_pair
//#define f first
//#define sex second

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <set>
#include <ostream>
#include <queue>
#include <functional>
#include <sstream>
#include <map>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
#pragma comment(linker, "/STACK:228228000")
const ll mod = 998244353;
			///166374062
			///998244372

ll n, res;
vector<ll> a;

int main()
{
	/*

	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	*/

	
	cin >> n;
	
	forn(i, 0, n)
	{
		a.pb(0);
		cin >> a.back();
		a.back() -= i + 1;
	}
	sort(a.begin(), a.end());

	forn(i, 0, n)
	{
		res += abs(a[i] - a[a.size()/2]);
	}

	cout << res;
	return 0;
}


Measured memory_bytes: 2420
S = input()
N = len(S)
def is_palindrome(s):
    return s == ''.join(list(reversed(s)))

ans = 'Yes' if is_palindrome(S) and is_palindrome(S[:(N-1)//2]) and is_palindrome(S[(N+1)//2:]) else 'No'
print(ans)

Measured memory_bytes: 9128
#include<iostream>
#include<algorithm>
using namespace std;
int p[200000];

int main() {

	//B
	string s;
	cin >> s;
	int i;
	for (i = 0; i < s.size(); i++) {
		s[i] = 'x';
	}
	cout << s << endl;
	return 0;

	//C
	/*int n;
	cin >> n;
	int i;
	for (i = 0; i < n; i++) {
		cin >> p[i];
	}
	sort(p, p + n);
	for (i = 0; i < n-1; i++) {
		if (p[i] == p[i + 1]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;*/
	//D
	/*int n, k;
	cin >> n >> k;
	int i;
	for (i = 0; i < n; i++) {
		cin >> p[i];
	}
	int max = 0;
	int sum = 0;
	for (i = 0; i < k; i++) {
		sum = sum + p[i];
	}
	max = sum;
	for (i = k; i < n; i++) {
		sum = sum + p[i] - p[i - k];
		if (sum > max)max = sum;
	}
	//cout << max + k << endl;
	double f = (double)(((double)max +(double) k) / 2);
	printf("%.10f\n", f);
	//cout << (max + k) / 2 << endl;
	return 0;
	*/
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
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; }

ll gcd (ll a, ll b){ return b == 0? a : gcd(b, a % b); }

void solve(long long K){
    ll ans = 0;
    for(ll a = 1; a <= K; a ++){
        for(ll b = 1; b <= K; b ++){
            ll tmp = gcd(a, b);
            for(ll c = 1; c <= K; c++){
                ans += gcd(tmp, c);
            }
        }
    }
    cout<<ans<<endl;
}

int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 3252
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long ll;

int main(){
  ll N; cin >> N;
  vector<ll> a(3*N,0);
  for(ll i = 0; i < 3*N; i++){
    cin >> a[i];}
  sort(a.begin(),a.end());
   ll sum = 0;
  for(ll i = N; i <= 3*N - 2; i+= 2){
    sum += a[i];}
   cout << sum << endl; return 0;}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a[1000][10],b[1000010],c[1000010];
int main()
{
	int n,r;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<10;j++)
		{
			scanf("%d",&r);
			if(r==1)
			{
				b[i]+=(1<<(10-j-1));
			}
//			scanf("%d",&b[i][j]);
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<11;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	int ans=INT_MIN,ind=-1;
	for(int i=1;i<(1<<10);i++)
	{
		for(int k=0;k<n;k++)
		{
			int w=b[k]&i;
			c[k]=0;
			for(int j=0;j<10;j++)
			{
			//	if(i==837)
			//		printf("cx%d %d %d\n",w,(1<<j),w&(1<<j));
				if((w&(1<<j))>0)
				{
					c[k]++;
				}
			}
		}
		int u=0;
		for(int k=0;k<n;k++)
		{
			u+=a[k][c[k]];
		}
		ans=max(ans,u);
	}
	printf("%d\n",ans);
}

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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, M; cin >> N >> M;
    vi a(N), b(N); REP(i, N) cin >> a[i] >> b[i];
    vi c(M), d(M); REP(i, M) cin >> c[i] >> d[i];

    REP(i, N)
    {
        int dist = INF;
        int m;
        REP(j, M)
        {
            if(chmin(dist, abs(a[i]-c[j]) + abs(b[i]-d[j]))) m = j;
        }
        cout << m+1 << endl;
    }
}

Measured memory_bytes: 3628
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define fi first
#define se second
//#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N=1e3+5;
inline int qi(){
    int f=0,fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
inline ll ql(){
	ll f=0;int fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
int ans[MAX_N][MAX_N];
char g[MAX_N][MAX_N];
bool vis[MAX_N][MAX_N];
int mov[4][2]={0,1,0,-1,1,0,-1,0};
vector<P> rec;
int h,w;
void solve(int x,int y)
{
	queue<P> q; q.push(P(x,y));
	while(!q.empty())
	{
		P now=q.front(); q.pop();
		repi(i,0,3){
			int tx=now.fi+mov[i][0],ty=now.se+mov[i][1];
			if(tx<1||tx>h||ty<1||ty>w||g[tx][ty]=='#'||ans[tx][ty]!=-1) continue;
			ans[tx][ty]=ans[now.fi][now.se],q.push(P(tx,ty));
		}	
	}
}
int main()
{
	h=qi(),w=qi(); memset(ans,-1,sizeof(ans)); ms(vis);
	int ch=qi(),cw=qi(),dh=qi(),dw=qi();
	repi(i,1,h) ss(g[i]+1);
	queue<P> q;
	ans[ch][cw]=0,solve(ch,cw),q.push(P(ch,cw));
	while(!q.empty())
	{
		rec.clear();
		P now=q.front(); q.pop();
		queue<P> q2; q2.push(now),rec.pb(now),vis[now.fi][now.se]=true;
		while(!q2.empty())
		{
			P now2=q2.front(); q2.pop();
			repi(i,0,3){
				int tx=now2.fi+mov[i][0],ty=now2.se+mov[i][1];
				if(tx<1||tx>h||ty<1||ty>w||g[tx][ty]=='#'||vis[tx][ty]) continue;
				q2.push(P(tx,ty)),rec.pb(P(tx,ty)),vis[tx][ty]=true;
			}
		}
		for(auto x:rec){
			repi(i,-2,2)repi(j,-2,2){
				int tx=x.fi+i,ty=x.se+j;
				if(tx<1||tx>h||ty<1||ty>w||g[tx][ty]=='#'||ans[tx][ty]!=-1) continue;
				ans[tx][ty]=ans[x.fi][x.se]+1,solve(tx,ty),q.push(P(tx,ty));
			}
		}
	}
	printf("%d\n",ans[dh][dw]);
	return 0;
}

Measured memory_bytes: 9692
using System;
using System.Linq;
using System.Collections.Generic;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
  
     string[] str=Console.ReadLine().Split(' ');
     int A=int.Parse(str[0]);
     int B=int.Parse(str[1]);
     int C=int.Parse(str[2]);
      Console.WriteLine(C/A*B);
          
          
      
     }
    
  }

}


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

int main(){
  
  int N; cin >> N;
  vector<int> W(N);
  
  int sum = 0;
  for(int i = 0; i< N; i++){
    cin >> W[i];
    sum += W[i];
  }
  
  int sum1 = 0;
  vector<int> dif(N);
  
  for(int i = 0; i < N; i++){
    sum1 += W[i];
    dif[i] = abs(sum - 2*sum1);
  }
  
  int min = *min_element(dif.begin(),dif.end());
  
  cout << min << endl;
 

  return 0;  
  
}

Measured memory_bytes: 256
n, d, a = map(int, input().split())
xh = []
for _ in range(n):
    x, h = map(int, input().split())
    xh.append((x, h))

xh.sort(key=lambda x:x[0])

def bisect(x):
    ok = n
    ng = -1
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if xh[mid][0]>x:
            ok = mid
        else:
            ng = mid
    return ok

out = [0]*(n+1)
ans = 0
accu = 0
for ind, (x, h) in enumerate(xh):
    accu -= out[ind]
    h -= accu
    if h<=0:
        continue
    ans += (h+a-1)//a
    accu += ((h+a-1)//a)*a
    out[bisect(x+2*d)] += ((h+a-1)//a)*a
print(ans)

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

counter = 0

N_temp = N
while N_temp//5 != 0:
	N_temp = N_temp//5
	counter += 1

if N%2 == 1:
	print(0)
else:
	ans = 0
	for k in range(1,counter+1):
		ans += (N//(5**k))//2
	print(ans)


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m; cin >> n >> m;
  int l0 = 1, r0 = n;
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    l0 = max(l, l0);
    r0 = min(r0, r);
  } 
  cout << max(0, r0 - l0 + 1) << '\n';
  return 0;
}

Measured memory_bytes: 256
//#pragma warning disable

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Text;

public class Test
{
    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();

        var chars = new[] { 'x', 'o' };

        var table_o = new[]{
            0,  // 000
            1,  // 011
            1,  // 101
            0,  // 110
            };
        var table_x = new[]{
            1,  // 001
            0,  // 010
            0,  // 100
            1,  // 111
            };

        char[] str = new char[N];

        for (int j = 0; j < 4; j++)
        {
            int n0 = j % 2;
            int n1 = j / 2;

            bool flag = false;

            for (int i = 0; i < N; i++)
            {
                int m = s[i] == 'o' ? 0 : 1;
                int n2 = n0 ^ n1 ^ m;
                
                str[(i + 1) % N] = n2 == 0 ? 'S' : 'W';

                n0 = n1;
                n1 = n2;
            }
            
            if (n0 == j % 2 && n1 == j / 2) {
                Console.WriteLine(new string(str));
                return;
            }
        }

        Console.WriteLine("-1");
    }
}

Measured memory_bytes: 12000
import java.util.*;
import java.math.BigDecimal;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		BigDecimal A = new BigDecimal(sc.next());
		BigDecimal B = new BigDecimal(sc.next());
		System.out.println(A.multiply(B).setScale(0, BigDecimal.ROUND_DOWN));
	}

}

Measured memory_bytes: 35988
#include <stdio.h>
int main()
{
	int a, b, c, d;
	while(scanf("%d %d %d %d", &a, &b, &c, &d)!=EOF)
	{
		int t;
		if(a>c)
		{
			t=a;
			a=c;
			c=t;
		}
		if(b>d)
		{
			t=b;
			b=d;
			d=t;
		}
		if((b-c)<0) b=c;
		
		printf("%d\n", b-c);
	}
	return 0;
}

Measured memory_bytes: 128
n = int(input())
info = [list(map(int, input().split())) for i in range(n)]
profits = [list(map(int, input().split())) for i in range(n)]
ans = -float("inf")

for i in range(1, 2 ** 10):
    tmp = 0
    for j in range(n):
        count = 0
        for k in range(10):
            if ((i >> k) & 1) == 1 and info[j][k] == 1:
                count += 1

        tmp += profits[j][count]
    
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 3064
#if __has_include("../library/Basic/Debug.hpp")

#include "../library/Basic/Debug.hpp"

#else

/* ----- Header Files ----- */
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>
#include <cstdint>


/* ----- Type Alias ----- */
using Int = long long int;
using Real = long double;
using String = std::string;
template <class... Ts>
using Tuple = std::tuple<Ts...>;

template <class T>
using Vector = std::vector<T>;
template <class T>
using Queue = std::queue<T>;
template <class T>
using Stack = std::stack<T>;
template <class T>
using Deque = std::deque<T>;

template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T>
using Set = std::set<T>;
template <class T, class U>
using Map = std::map<T, U>;

template <class T, class... Us>
using Func = std::function<T(Us...)>;

template <class T>
T genv(T v) { return v; }

template <class T, class... Ts>
auto genv(size_t l, Ts... ts) {
    return Vector<decltype(genv<T>(ts...))>(l, Vector<T>(ts...));
}

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

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = Int>
using Edges = Vector<Edge<Cost>>;
template <class Cost = Int>
using Graph = Vector<Vector<Edge<Cost>>>;

#endif

/* ----- Misc ----- */
void fastio() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

struct Fout {
    Int precision;
    Fout(Int precision) : precision(precision) {}
};
std::ostream& operator<<(std::ostream& os, const Fout& fio) {
    os << std::fixed << std::setprecision(fio.precision);
    return os;
}


/* ----- Constants ----- */
constexpr Int INF = std::numeric_limits<Int>::max() / 3;
// constexpr Int MOD = 1000000007;
// constexpr Real PI = acos(-1);
// constexpr Real EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));

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

    Vector<Int> dp(c + 1, -INF);
    dp[0] = 0;
    for (Int i = 0; i < n; ++i) {
        Int s, p;
        std::cin >> s >> p;
        for (Int w = c; w - s >= 0; --w) {
            dp[w] = std::max(dp[w], dp[w - s] + p);
        }
    }

    for (Int k = 1; k <= m; ++k) {
        Int max = 0;
        for (Int w = 0; w * k <= c; ++w) {
            max = std::max(max, dp[w]);
        }
        std::cout << max * k << std::endl;
    }
    return 0;
}



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

using namespace std;

int main()
{
    int a, b;
    while (1)
    {
        cin >> a >> b;
        if (a == 0 && b == 0)
            break;
        if (b < a)
        {
            cout << b << " " << a << endl;
        }else{
            cout << a << " " << b << endl;
        }
    }
    return 0;
}


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

using namespace std;

int main()
{
    int N,M,x;
    cin >> N;
    int s[N],l[N],p[N];
    for(int i = 0 ; i < N ; i++){
        cin >> s[i] >> l[i] >> p[i];
    }
    int dp[500] = {0};
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < 500 ; j++){
            for(int k = s[i] ; k <= l[i] ; k++){
                if(j + k >= 500) continue;
                dp[j+k] = max(dp[j+k],dp[j]+p[i]);
            }   
        }
    }
    cin >> M;
    vector<int> res(M);
    bool check = 0;
    for(int i = 0 ; i < M ; i++){
        cin >> x;
        res[i] = dp[x];
        if(res[i] == 0) check = 1;
    }
    if(check){
        cout << -1 << endl;
    }else{
        for(auto v : res){
            cout << v << endl;
        }
    }   
    return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;

bool is_prime[10000001];
vector<int> prime;

void sieve(){
	fill(is_prime,is_prime+10000001,true);
	is_prime[0]=is_prime[1]=false;
	for(int i=2; i<=10000000; ++i){
		if(is_prime[i]){
			prime.push_back(i);
			for(int j=2; i*j<=10000000; ++j){
				is_prime[i*j]=false;
			}
		}
	}
}

int main(){
	sieve();
	int N;
	while(cin >> N&&N){
		long long int ans=0;
		for(int i=0; i<=N/2; ++i){
			if(is_prime[i]&&binary_search(prime.begin(),prime.end(),N-i)){
				//cout << i << endl;
				++ans;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 16932
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    if (N % 2 == 0) {
        cout << 0.5 << endl;
    } else {
        cout << (double)((N + 1) / 2) / (double)N << endl;
    }
    return 0;
}


Measured memory_bytes: 256
s = list(input())
mods = [0]*(len(s))
countRemainder = [0] * 2019
cnt = 0


m = 1
mod = 0
for i in range(len(s)):
    mod += int(s[len(s) - i - 1]) * m

    mod %= 2019
    m *= 10
    m %= 2019

    countRemainder[mod] += 1

countRemainder[0] += 1

for i in range(2019):
    cnt += int(countRemainder[i] * (countRemainder[i] - 1) / 2)

print(cnt)



Measured memory_bytes: 11832
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265359
using namespace std;

int main()
{
  int r;

  cin >> r;

  cout << 2*PI*r << endl;
  return 0;
}


Measured memory_bytes: 3692
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
typedef long long ll;
std::pair<int, int> ans[105];
int main()
{
	// freopen("ARC102-D.in", "r", stdin);
	int len;
	scanf("%d", &len);
	int n = 19, m = n * 2 - 2, cur = 0;
	if (len & (1 << n))
	{
		ans[m++] = {n - 1, len - (1 << n)};
		ans[m++] = {n - 1, len - (1 << n) + (1 << n - 1)};
		len -= 1 << n;
	}
	for (int i = 0; i < n; i++)
	{
		if (len & (1 << i))
		{
			ans[m++] = {i, cur};
			cur += 1 << i;
		}
	}
	printf("%d %d\n", n + 1, m);
	for (int i = 1; i < n; i++)
	{
		printf("%d %d 0\n", i, i + 1);
		printf("%d %d %d\n", i, i + 1, 1 << i - 1);
	}
	for (int i = n * 2 - 2; i < m; i++)
		printf("%d %d %d\n", ans[i].first + 1, n + 1, ans[i].second);
	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp.chars

if n < 4
  puts "0"
  exit
end

dp = Array.new(n) { Array.new(3, 0) }
c = ["R", "G", "B"]
t = [0, 0, 0]
t[c.index(s[-1])] += 1
dp[n - 1] = t
(n - 2).downto(0) do |i|
  t = Marshal.load(Marshal.dump(dp[i + 1]))
  t[c.index(s[i])] += 1
  dp[i] = t
end

res = 0
0.step(s.size - 2) do |i|
  (i + 1).step(s.size - 1) do |j|
    if s[i] != s[j] && j + 1 < s.size
      kc = 3 - c.index(s[i]) - c.index(s[j])
      res += dp[j + 1][kc]
      res -= 1 if j + (j - i) < s.size && s[j + (j - i)] == c[kc]
    end
  end
end

puts res

Measured memory_bytes: 14972
local function split(text, delimiter)
    if text.find(text, delimiter) == nil then
      return { text }
    end
  
    local splited_texts = {}
    local last_position
  
    for splited_text, position in text:gmatch("(.-)"..delimiter.."()") do
      table.insert(splited_texts, splited_text)
      last_position = position
    end
    table.insert(splited_texts, string.sub(text, last_position))
    return splited_texts
end

local str = io.read()
local str_list = split(str, " ")
local str1 = str_list[1]
local str2 = str_list[2]

local count = 0
for i = str1, str2 do
    if(tonumber(i) == tonumber(string.reverse(i))) then
        count = count + 1
    end
end
print(count)

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=1e5+100;

LL gi() {
	LL w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

LL w[N],d[N];
int main()
{
	int n=gi(),k=gi(),i;LL l,r,mid,sum;
	for (i=1;i<=n;i++) w[i]=gi(),d[i]=gi();
	l=1,r=2e18;
	while (l!=r) {
		mid=(l+r)>>1;
		sum=0;
		for (i=1;i<=n;i++)
			if (w[i]<=mid&&(sum+=(mid-w[i])/d[i]+1)>=k) break;
		if (sum<k) l=mid+1;
		else r=mid;
	}
	cout<<l<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define lli long long int
#define ld long double
#define pb push_back
#define is insert
#define iamspid ios_base::sync_with_stdio(false); cin.tie(NULL);
int main()
{
    iamspid
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    lli n, w;
    cin>>n>>w;
    lli wi[n], vi[n];
    for(lli i=0;i<n;i++) cin>>wi[i]>>vi[i];
    vector<vector<lli>>dp(n+1, vector<lli> (w+1));
    for(lli i=0;i<=w;i++) dp[0][i]=0;
    for(lli i=1;i<=n;i++)
    {
        for(lli j=0;j<=w;j++)
        {
            if(wi[i-1]<=j) dp[i][j]=max(dp[i-1][j], vi[i-1]+dp[i-1][j-wi[i-1]]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w]<<endl;
    return 0;
}


Measured memory_bytes: 83032
using System;
using System.Linq;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input1 = Console.ReadLine();
            var input2 = Console.ReadLine().Split(' ');
            var input3 = Console.ReadLine();

            var n = int.Parse(input1);
            var t = int.Parse(input2[0]);
            var a = int.Parse(input2[1]);
            var hs = input3.Split(' ')
                           .Select(s => int.Parse(s))
                           .ToArray();
            var pos = 0;
            var diff = long.MaxValue;

            for (var i = 0; i < n; i++)
            {
                var d = (t * 1000 - hs[i] * 6) - a * 1000;
                
                if (d < 0)
                {
                    d = -d;
                }

                if (d < diff)
                {
                    diff = (int)d;
                    pos = i + 1;
                }
            }

            Console.WriteLine(pos);
        }
    }
}

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

int main(){
 int n;
 int cnt=0;
 cin>>n;
 string s[n];
 for(int i=0; i<n;i++){
   cin>>s[i];
   cnt +=1;
   if(s[i]=="Y"){
     cout<<"Four"<<endl;
     break;
   }
 }
  if (cnt ==n)cout<<"Three"<<endl;
}

Measured memory_bytes: 256
//
// エラトステネスの篩
//
// cf.
//   高校数学の美しい物語: エラトスネテスの篩
//     https://mathtrain.jp/eratosthenes
//
// verified
//   AOJ 0009 素数
//     http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009&lang=jp
//

/*
 
    n 以下の素数をすべて列挙する
 
*/


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


vector<bool> isprime;
vector<int> Era(int n) {
    isprime.resize(n, true);
    vector<int> res;
    isprime[0] = false; isprime[1] = false;
    for (int i = 2; i < n; ++i) isprime[i] = true;
    for (int i = 2; i < n; ++i) {
        if (isprime[i]) {
            res.push_back(i);
            for (int j = i*2; j < n; j += i) isprime[j] = false;
        }
    }
    return res;
}


int main() {
    vector<int> primes = Era(1000000);
    int n;
    while (cin >> n) {
        int num = upper_bound(primes.begin(), primes.end(), n) - primes.begin(); // n 以下が何個か
        cout << num << endl;
    }
}



Measured memory_bytes: 3396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;



public class Main{
	public static void main(String[] args){

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		int num;
		double Dxy;
		String str;
		String[] vectorA, vectorB;

		try{

			num=Integer.parseInt(reader.readLine());
			str=reader.readLine();
			vectorA=str.split(" ");
			str=reader.readLine();
			vectorB=str.split(" ");
			int[] diff=new int[num];


			for(int i=0;i<num;i++){
				diff[i]=Integer.parseInt(vectorA[i])-Integer.parseInt(vectorB[i]);
				if(diff[i]<0)diff[i]=diff[i]*-1;
			}

			Dxy=0;
			for(int i=0;i<num;i++){
				Dxy+=diff[i];
			}System.out.printf("%.8f\n", Dxy);//p=1;

			Dxy=0;
			for(int i=0;i<num;i++){
				Dxy+=(double)diff[i]*diff[i];
			}System.out.printf("%.8f\n", Math.sqrt(Dxy));//p=2;

			Dxy=0;
			for(int i=0;i<num;i++){
				Dxy+=(double)diff[i]*diff[i]*diff[i];
			}System.out.printf("%.8f\n", Math.cbrt(Dxy));//p=3;

			Dxy=0;
			for(int i=0;i<num;i++){
				if(Dxy<diff[i])Dxy=diff[i];
			}System.out.printf("%.8f\n", Dxy);//p=???


		}catch(IOException e){
			System.out.print(e);
		}
	}

}

Measured memory_bytes: 24680
import sys

n = int(input())
b = list(map(int, input().rstrip().split(' ')))

ans = list()

for ii in reversed(range(n)):
    for jj in reversed(range(ii+1)):
        if b[jj] == jj + 1:
            ans.append(b.pop(jj))
            # print(ans)
            break

if len(b) != 0:
    print(-1)
    sys.exit()

for ii in reversed(range(n)):
    print(ans[ii])


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
    int N, M;
    int low = 0, high = 100000;

    cin >> N >> M;

    for(int i = 0; i < M; i++){
        int L, R;
        cin >> L >> R;
        low = max(low, L);
        high = min(high, R);
    }

    int ans = high - low + 1;

    if(ans > 0) {
        cout << ans << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

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

#define M 1046527

string H[M];

int getChar(char s) {
    switch (s) {
        case 'A':
            return 1;
        case 'C':
            return 2;
        case 'G':
            return 3;
        case 'T':
            return 4;
        default:
            return 0;
    }
}

ll getKey(string s) {
    ll sum = 0, p = 1;
    rep(i, s.length()) {
        sum += p * s[i];
        p *= 5;
    }
    return sum;
}

void insert(string str) {
    ll key = getKey(str);
    for (ll i = 0;; i++) {
        ll h = (key % M + i * (1 + key % (M - 1))) % M;
        if (H[h] == str)
            break;
        else if (H[h].length() == 0) {
            H[h] = str;
            break;
        }
    }
}

string find(string str) {
    ll key = getKey(str);
    for (ll i = 0;; i++) {
        ll h = (key % M + i * (1 + key % (M - 1))) % M;
        if (H[h] == str)
            return "yes";
        else if (H[h].length() == 0) {
            return "no";
        }
    }
    return "no";
}

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

    rep(i, n) {
        string order, str;
        cin >> order >> str;

        if (order == "insert")
            insert(str);
        else
            cout << find(str) << endl;
    }

    return 0;
}



Measured memory_bytes: 27452
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int i=0;
  int c=0;
  cin>>n;
  int p[200000];
  
  for(i=0;i<n;i++){
    cin>>p[i];
  }
  
  int t=0;
  int max=2000000;
  for(i=0;i<n;i++){
    if(p[i]<max){
      c++;
      max=p[i];
    }
  }
  cout<<c<<endl;
    
}

Measured memory_bytes: 1024
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int X, t;
  cin >> X >> t;

  cout << max(0, X - t) << endl;
}


Measured memory_bytes: 256
<?php
/**
 * ABC123
 * A - Five Antennas
 */

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

for ($i = 0; $i < 5; $i++) {
    fscanf(STDIN, "%d", $d[$i]);
}
fscanf(STDIN, "%d", $k);

if ($d[4] - $d[0] > $k) {
    echo ':(', PHP_EOL;
    exit;
}
echo 'Yay!', PHP_EOL;


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

using namespace std;

int main()
{
 	int h,w;
 	cin>>h>>w;
 	string a[h];
 	for(int i=0; i<h; i++)cin>>a[i];
 	for(int i=0; i<h+2; i++)
 	{
 		if(i==0 or i==h+1)
 		{
 			for(int l=0; l<w+2; l++)cout<<"#";
		 }
		 else 
		 {
		 	for(int l=0; l<3; l++)
		 	{
		 		if(l==0 or l==2)cout<<"#";
		 		else cout<<a[i-1];
			 }
		 }
		 cout<<endl;
	 }
	 return 0;
}


Measured memory_bytes: 256
a = [input() for i in range(2)]

key1 = a[0]
key2 = a[1]
key2_front = a[1][:-1]
key2_back = a[1][-1]

if (key1 == key2_front):
    if len(key1) == len(key2_front):
        if len(key2_back) == 1:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 9136
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  int a,b,c,ans=0;
  cin >> a >> b >> c;
  if(a==b&&b==c&&a%2==0&&b%2==0&&c%2==0) {
    cout << -1 << endl;
  }
  else {
    while(a%2==0&&b%2==0&&c%2==0) {
      int aa=b/2+c/2,bb=a/2+c/2,cc=a/2+b/2;
      a=aa,b=bb,c=cc;
      ans++;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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 pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N, A, B;
	string S;
	cin >> N >> A >> B >> S;
	int a = 0, b = 0, c = 0;
	int sum = 0;
	rep(i, S.size()) {
		if (S[i] == 'a') {
			if (sum < A + B) {
				cout << "Yes" << endl;
				sum++;
			}
			else cout << "No" << endl;
			a++;
		}
		else if (S[i] == 'b') {
			if (sum < A + B && b < B) {
				cout << "Yes" << endl;
				sum++;
			}
			else cout << "No" << endl;
			b++;
		}
		else {
			cout << "No" << endl;
			c++;
		}
	}
}

Measured memory_bytes: 896
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
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 (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール

// 処理内容
int main() {
    
    ll q;
    cin >> q;
    vector<ll> l(q), r(q);
    REP(i, q) cin >> l[i] >> r[i];

    vector<bool> is_prime(100001, false);
    vector<ll> primes;
    primes.push_back(2);
    for (ll i = 3; i <= 100000; i += 2) {
        ll j = i;
        bool ispr = true;
        for (ll f = 3; f * f <= i; f += 2) {
            if (j % f == 0) {
                ispr = false;
                break;
            }
        }
        if (ispr) primes.push_back(i);
    }
    for (ll prime : primes) is_prime[prime] = true;

    vector<ll> imos(100002, 0);
    REP(i, 100001) {
        imos[i+1] = imos[i] + (is_prime[i] && is_prime[(i+1)/2]);
    }
    
    REP(i, q) {
        cout << imos[r[i]+1] - imos[l[i]] << endl;
    }
    
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n,k;
  cin >> n >> k;
  vector<int> count(n);
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    //count the "a-1" th number in the "count" array
    count.at(a-1)++;
  }
  sort(count.begin(),count.end());
  int ans = 0;
  for(int i = 0; i < n - k; i++){
    ans += count.at(i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
def main():
    s = input()
    K = int(input())
    lst = sorted(set(s))
    ans = []

    def dfs(c):
        if len(ans) < K:
            ans.append(c)
            for li in lst:
                if c + li in s:
                    return dfs(c + li)
        return

    for li in lst:
        dfs(li)
    print(ans[K - 1])
    return


main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    double ans=0;
    for(int i=1;i<=n;++i){
        int tmp=i;
        int flag=0;
        for(int j=0;j<20;++j){
            if(tmp>=k){
                flag=j;
                break;
            }
            tmp*=2;
        }
        ans+=1.0/(1.0*pow(2,flag));
    }
    ans=ans/(1.0*n);
    printf("%.10f",ans);
    return 0;
}



Measured memory_bytes: 256
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
using namespace std;
long long inf=100000000000007;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
typedef pair<int,int>  P;
string alph("abcdefghijklmnopqrstuvwxyz");
struct edge{int to,cost;};
vector<edge> G[22];
vector<int> O[10];
char fi[1005][1005];
P sg[10];
int d[1005][1005];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
pair<int,double> s[1005];
int c=0;
int n,k;

signed main(){
    int h,w;cin>>h>>w;
    int gr[10][10];
    rep(i,10)rep(j,10)cin>>gr[i][j];
    int di[205][205];
    rep(i,h)rep(j,w)cin>>di[i][j];
    rep(k,10)rep(i,10)rep(j,10)gr[i][j]=min(gr[i][j],gr[i][k]+gr[k][j]);
    int ans=0;
    rep(i,h)rep(j,w){
        if(di[i][j]==-1)continue;
        else ans+=gr[di[i][j]][1];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640