akhauriyash/Code-Regression huggingface dataset:
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
struct Edge{
    int to;
    int cost;
};
int n, m;
vector<vector<Edge>> g;
bool f = true;
void dfs(int now, int pos, vector<int> &x, vector<int> &visited){
    if(x[now] == -1e9){
        x[now] = pos;
    } else {
        if(x[now] != pos){
            f = false;
            return;
        }
    }

    if(visited[now]) return;
    visited[now] = true;

    rep(i, g[now].size()){
        int next = g[now][i].to;
        int cost = g[now][i].cost;
        dfs(next, pos + cost, x, visited);
    }
}
int main(void){
    cin >> n >> m;
    g.resize(n);

    vector<int> x(n, -1e9);
    vector<int> visited(n, 0);

    rep(i, m){
        int l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        Edge tmp;
        tmp.cost = d;
        tmp.to = r;
        g[l].push_back(tmp);
        tmp.cost = -d;
        tmp.to = l;
        g[r].push_back(tmp);
    }

    rep(i, n){
        if(!visited[i]){
            dfs(i, 0, x, visited);
        }
    }

    if(f){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 12416
#include<iostream>
using namespace std;
int main(){

	int N;
	cin >> N;

	for(int i = 0; i < N; i++) {
		int x, y, b, p;
		cin >> x >> y >> b >> p;

		
		int futsu = x * b + y * p; 
		int oome = (x * 5 + y * 2 + x * max(b - 5, 0) + y * max(p - 2, 0)) * 8 / 10;


		if (b >= 5 && p >= 2) {
			cout << futsu * 8 / 10 << endl;
		} else if (oome < futsu) {
			cout << oome << endl;
		} else {
			cout << futsu << endl;
		}

	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

void bfs(std::vector<std::vector<char> > &map, std::pair<int, int> start) {
    int w = map.size();
    int h = map[0].size();
    int dy[4] = {0, 0, 1, -1};
    int dx[4] = {1, -1, 0, 0};
    std::queue<std::pair<int, int> > que; // coord
    int cost = 0;
    std::pair<int, int> coord = start;
    cost++;
    que.push(std::make_pair(coord.first, coord.second));
    map[coord.first][coord.second] = '#';

    while(! que.empty()) {
        coord = que.front(); 
        que.pop();
        for (int i = 0; i < 4; i++) {
            if (map[coord.first + dy[i]][coord.second + dx[i]] == '.') {
                cost++;
                que.push(std::make_pair(coord.first + dy[i], coord.second + dx[i]));
                map[coord.first + dy[i]][coord.second + dx[i]] = '#';
            }
        }
    }
    std::cout << cost << std::endl;
    return;
}

int main(void) {
    int w;
    int h;
    std::pair<int, int> start;

    while (1) {
        std::cin >> w >> h;
        if (w == 0 && h == 0) {
            break;
        }
        std::vector<std::vector<char> > map(h + 2, std::vector<char>(w + 2, '#'));
        for (int i = 1; i <= h; i++) {
            for (int j = 1; j <= w; j++) {
                std::cin >> map[i][j];
                if (map[i][j] == '@') {
                    start.first = i;
                    start.second = j;
                }
            }
        }
        bfs(map, start);
    }
    return 0;
}

Measured memory_bytes: 3032
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<set>
using namespace std;

const int M=1e5+10;
char a[M];

int main(){
    while(scanf("%s",a)!=EOF){
        getchar();
        int flag=0;
        for(int i=1;a[i];i++){
           if(a[i]==a[i-1]){
                printf("%d %d\n",i,i+1);
                 flag=1;
                break;
            }
            else
                if(a[i-1]==a[i+1]){
                    printf("%d %d\n",i,i+2);
                    flag=1;
                    break;
                }
        }
        if(!flag)
            printf("-1 -1\n");
    }
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<vector>
#include<stdlib.h>

#define SZ(v) ((int)v.size())
#define pb push_back
using namespace std;
typedef vector<int> VI;

const int N=200005;
VI li[N],id;
char s[N];
int n,m,L,ec,sum,mark[N];

void markit(){
	for(int i=0;i<<2<id.size();i++){
		for(int j:{0,1})for(int k:{0,1})mark[id[i<<2|j<<1|k]]=ec+k+1;
		ec+=2;
	}
}
void output(){
	puts("Yes");
	for(int i=0;i<L;i++){
		if(!mark[i])mark[i]=ec<0?-ec:++ec,ec=-ec;
		printf("%d ",mark[i]);
	}
	exit(0);
}

int main(){
	scanf("%d",&n);scanf("%s",s+1);s[0]='1';L=n<<1;
	for(int i=0,j;i<L;i++)if(s[i]=='0'&&s[(i+1)%L]=='1'){
		for(li[m].pb(i),j=(i+1)%L;s[j]=='1';j=(j+1)%L)li[m].pb(j);
		m++;
	}
	if(!m){
		if(~n&1){
			for(int i=0;i<L;i++)id.pb(i);
			markit();output();
		}else puts("No"),exit(0);
	}
	for(int i=0;i<m;i++)sum+=SZ(li[i])-2;
	if(sum&1)puts("No"),exit(0);
	if(sum&2){
		for(int i=0;i<m;i++)if(SZ(li[i])>2)li[m-1].swap(li[i]);
		for(int i=0;i<m-1;i++)if(SZ(li[i])>2){
			VI&a=li[i],&b=li[m-1];
			int la=SZ(a)-1,lb=SZ(b)-1,ea=a[la],eb=b[lb];
			mark[a[la-1]]=mark[b[lb-1]]=++ec;
			a.pop_back();b.pop_back();a.pop_back();b.pop_back();a.push_back(eb);b.push_back(ea);
			sum-=2;
			break;
		}
		if(sum&2)puts("No"),exit(0);
	}
	for(int i=0;i<m;i++){
		mark[li[i][0]]=ec+1+i;
		mark[li[i][SZ(li[i])-1]]=ec+1+(i+1)%m;
		for(int j=1;j<SZ(li[i])-1;j++)id.pb(li[i][j]);
	}
	ec+=m;markit();output();
	return 0;
}

Measured memory_bytes: 9084
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
#define PP 1000000007
using namespace std;

int main(){
ll N, Ans = 0;cin >> N;
priority_queue<ll> P;
priority_queue<ll> Q;

rep(i, 0, N){

  ll p;cin >> p;

  P.push(p);Q.push(p);

}

if(N%2 == 1){

  ll A = 0, B = 0;

  rep(i, 1, N + 1){

    if(i <= N/2){

      A += 2*P.top();P.pop();continue;

    }

    if(N/2 < i && i <= N/2 + 2){

      A -= P.top();P.pop();continue;

    }

    else{

      A -= 2*P.top();P.pop();continue;

    }

  }

  rep(i, 1, N + 1){

    if(i <= N/2 - 1){

      B += 2*Q.top();Q.pop();continue;

    }

    if(N/2 - 1 < i && i <= N/2 + 1){

      B += Q.top();Q.pop();continue;

    }

    else{

      B -= 2*Q.top();Q.pop();continue;

    }

  }

Ans = max(A, B);

}

if(N%2 == 0){

  rep(i, 1, N + 1){

    if(i <= N/2 - 1){

      Ans += 2*P.top();P.pop();continue;

    }

    if(N/2 == i ){

      Ans += P.top();P.pop();continue;

    }

    if(N/2 + 1 == i ){

      Ans -= P.top();P.pop();continue;

    }

    else{

      Ans -= 2*P.top();P.pop();continue;

    }

  }

}

cout << Ans;

}

Measured memory_bytes: 5108
// Author : Syed Mujtaba
// Seek knowledge from the Cradle to the Grave !!
// https://www.linkedin.com/in/syed-mujtaba-064a5016a 

#include <bits/stdc++.h>
using namespace std;
#define int     long long
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod ((int)(1e9 + 7))
int A[4000];
int dp[4000][4000];
signed main()
{
	fast_io
	int n;
	cin >> n;
	int sum = 0;
	for(int i = 1; i <= n; i++)
	{
		cin >> A[i];
		sum += A[i];
	}
	for(int l = n; l >= 1; l--)
	{
		for(int r = 1; r <= n; r++)
		{
			if(l <= r)
			{
				if(l == r)
					dp[l][r] = A[r];
				else if(r - l + 1 == 2)
				{
					dp[l][r] = max(A[l], A[r]);
				}
				else 
				{
					int a = 0, b = 0, c = 0, d = 0;
						a = dp[l + 2][r];
						b = dp[l + 1][r - 1];
						c = dp[l + 1][r - 1];
						d = dp[l][r - 2];
						dp[l][r] = max(A[l] + min(a, b), A[r] + min(c, d));
				}
			}
		}
	}
	cout << 2*dp[1][n] - sum<< endl;
}

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

using namespace std;

typedef long long ll;

int main() {
	
	string N;
	cin >> N;
	int total = 0;
	for (int i = 0; i < N.size(); i++) {
		total += N[i] - '0';
	}
	if (total % 9 == 0) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3724
# https://atcoder.jp/contests/abc160/tasks/abc160_d
N, X, Y = map(int, input().split())

visited = set()

# special case: first advance
for i in range(N - 1):
    visited.add((i, i + 1))
visited.add((X - 1, Y - 1))

print(len(visited))

next_items = visited.copy()
for _ in range(N - 2):
    candidates = []

    for point in next_items:
        x, y = point

        if (x - 1, y) not in visited and x - 1 >= 0:
            visited.add((x - 1, y))
            candidates.append((x - 1, y))

        if (x + 1, y) not in visited and x + 1 != y:
            visited.add((x + 1, y))
            candidates.append((x + 1, y))

        if (x, y - 1) not in visited and x != y - 1:
            visited.add((x, y - 1))
            candidates.append((x, y - 1))

        if (x, y + 1) not in visited and y + 1 < N:
            visited.add((x, y + 1))
            candidates.append((x, y + 1))

    print(len(candidates))
    next_items = candidates


Measured memory_bytes: 183412
#include <stdio.h>
int main(void)
{
    int a,b,c,tmp = 0;
    scanf("%d %d %d",&a,&b,&c);
    tmp = b;
    b = a;
    a = tmp;
    tmp = c;
    c = a;
    a = tmp;
    printf("%d %d %d",a,b,c);

    return 0;
}

Measured memory_bytes: 128
import itertools
N=int(input())
prime=[3,5,7,11,13,17,19]

comb = list(itertools.combinations(prime,3))

lst=[]
for i in range(len(comb)):
    temp=comb[i][0]*comb[i][1]*comb[i][2]
    if temp<=200:
        lst.append(temp)

lst.append(135)
lst.append(189)

ans = sum(N>=x for x in lst)
print(ans)

Measured memory_bytes: 3064
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(input())
    S1 = input()
    S2 = input()

    l = []
    res = 1
    while res < N:
        if S1[res - 1] == S1[res]:
            l.append(2)
            res += 2
        else:
            l.append(1)
            res += 1
    if res == N:
        l.append(1)

    n = len(l)
    if l[0] == 1:
        ans = 3
    else:
        ans = 6

    for i in range(1, n):
        if l[i] == 1 and l[i - 1] == 1:
            ans = ans * 2 % MOD
        elif l[i] == 2 and l[i - 1] == 1:
            ans = ans * 2 % MOD
        elif l[i] == 2 and l[i - 1] == 2:
            ans = ans * 3 % MOD

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9244
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

n = inp[0]
st = Hash.new(0)
n.times do
  st[gets.chomp.split("").sort.join] += 1
end
ans = 0
st.to_a
st.to_a.each do |a|
  d = a[1]-1
  ans += (d*(d+1)/2)
end
p ans

Measured memory_bytes: 25212
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
//#define int long long
#define D double
#define inf 123456789
#define mod 1000000007
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
#define rep(i , a , b) for(int i = (a) , i##Limit = (b) ; i <= i##Limit ; ++ i)
#define drep(i , b , a) for(int i = (a) , i##Limit = (b) ; i >= i##Limit ; -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define lb(x) (x)&(-(x))
#define ls k * 2
#define rs k * 2 + 1
#define maxn 2333
int n, m;
int main() {
	int a = read(), b = read(), c = read();
	if(a + b + c >= 22) puts("bust");
	else puts("win");
	return 0;
}


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

using namespace std;

char c[150];
char a[150],b[150];
string s[15];
typedef long long ll;
ll k;
ll ans[15];
int main()
{
    cin>>s[1];
    cin>>k;
    for(int i=2;i<10;i++){
        s[i]=s[i-1]+s[1];
    }
    for(int i=1;i<10;i++){
        int len=s[i].size();
        for(int j=0;j<len-1;j++){
            if(s[i][j]==s[i][j+1]){
                s[i][j+1]='#';
                ans[i]++;
            }
        }
    }
    if(k<10)cout<<ans[k];
    else {
        if(k%2==1){
            ll d=ans[9]-ans[7];
            cout<<(k-9)/2*d+ans[9]<<endl;
        }
        else {
            ll d=ans[8]-ans[6];
            cout<<(k-8)/2*d+ans[8]<<endl;
        }
    }
    /*int len=strlen(c);
    for(int i=0;i<=len;i++){
        a[i]=c[i];
        b[i]=c[i];
    }
    for(int i=0;i<len-1;i++){
        if(c[i]==c[i+1]){
            ans1++;
            c[i+1]='#';
        }
    }
    for(int i=1;i<len-1;i++){
        if(b[i]==b[i+1]){
            ans2++;
            b[i]='#';
        }
    }
    if(c[0]==c[len-1]){
        ans1+=k-1;
    }*/
    return 0;
}
/*

aaaaa
3

*/


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int a,b,c,d,e;
	cin >> a;
	b = a % 10;
	c=(a % 100) / 10;
	d = (a % 1000) / 100;

	e = a / 1000;

	if ((b == c &&c== d) ||( c ==d&& d == e)) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int n;
int a[250010];
int x[512];

vpi v;

void as( bool f ){
  if( not f ){
    puts( "No" );
    exit( 0 );
  }
}

int main(){

  n = in();

  REP( i , n*n ){
    a[i] = -1;
  }
  
  REP( i , n ){
    x[i] = in() - 1;
    v.pb( x[i] , i );
    as( a[x[i]] == -1 );
    a[x[i]] = i;
  }

  SORT( v );

  int it = 0;
  YYS( w , v ){
    REP( i , w.se ){
      while( a[it] != -1 ){
        it++;
      }
      as( it < w.fi );
      a[it] = w.se;
      it++;
    }
  }

  REVERSE( v );

  it = n*n-1;
  YYS( w , v ){
    REP( i , n-1-w.se ){
      while( a[it] != -1 ){
        it--;
      }
      as( it > w.fi );
      a[it] = w.se;
      it--;
    }
  }

  puts( "Yes" );
  REP( i , n*n ){
    if( i != 0 ){
      printf( " " );
    }
    printf( "%d" , a[i]+1 );
  }
  printf( "\n" );
    
  return 0;
}


Measured memory_bytes: 2176
n, k = map(int, input().split())
x = list(map(int, input().split()))

ans = float("inf")
for i in range(len(x)-(k-1)):
    xl = x[i]
    xr = x[i+k-1]
    candidate = min(abs(xl) + abs(xr-xl), abs(xr) + abs(xl-xr))
    ans = min(ans, candidate)

print(ans)



Measured memory_bytes: 14380
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<"!"<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin>>n;
  vi A(n);
  for(auto &a:A)cin>>a;

  ll le=-INF,ri=INF;
  for(int i=0;i<60;i++){
    ll num=le+ri;
    ll lemi=(num+le)/3;
    ll rimi=(num+ri)/3;
    ll lesum=0;
    ll risum=0;
    for(int j=0;j<n;j++){
      lesum+=abs(A[j]-(lemi+j+1));
      risum+=abs(A[j]-(rimi+j+1));
    }
    if(lesum<risum){
      ri=rimi;
    }else{
      le=lemi;
    }
  }

  ll ans=0;
  le=(le+ri)/2;
 
  for(int i=0;i<n;i++){
    ans+=abs(A[i]-(le+i+1));
  }
  cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std ;
int main(int argc, char** argv) {
	string str ;
	bool op = true ;
	cin >> str ;
	string arr[4] ;
	arr[0] = "eraser" ;
	arr[1] = "erase" ;
	arr[2] = "dreamer" ;
	arr[3] = "dream" ;
	for	( int i = 0 ; i < 4 ; i++ ) {
		op = true ;
		while ( op == true ) {
			op = false ;
			string::size_type find = str.find(arr[i]) ;
			if ( find != string::npos) {
				str.erase( find , arr[i].length() ) ;
				op = true ;
   			}
   		}
   	}
   	if ( str.length() == 0 ) {
   		cout << "YES" ;
	}
	else {
		cout << "NO" ;
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){

string s, t;
  cin >> s >> t;
int a[26] = {0};
int b[26] = {0};
bool ans = true;  
  
  for(int i = 0;i < s.size();i++) a[s.at(i) - '0' - 49]++;
  for(int i = 0;i < t.size();i++) b[t.at(i) - '0' - 49]++;
  sort(a, a + 26);
  sort(b, b + 26);
  
  for(int i = 0;i < 26;i++){
      if(a[i] != b[i]){
      ans = false;  
      break;
      }
  }
  
 if(ans == true) cout << "Yes" << endl;
  else cout << "No" << endl;

return 0;
  
}

Measured memory_bytes: 776
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<long long,long long> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

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

int main() {
    int N;cin >> N;
    //first:右端 second:左端
    vector<P> retu(N);
    for(int i = 0;i<N;i++){
        long long X,L;cin >> X >> L;
        retu.at(i).first = X-L;
        retu.at(i).second = X+L;
        swap(retu.at(i).first,retu.at(i).second);
    }
    sort(retu.begin(),retu.end());
    int ans = N;
    long long finish = retu.at(0).first;
    for(int i = 1;i<N;i++){
        if(retu.at(i).second < finish){
            ans--;
        }
        else{
            finish = retu.at(i).first;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()

using namespace std;

void execute()
{
	int H, W;
	char tmp;
	vector<int> h = {1, 1, 1, 0, 0, -1, -1, -1};
	vector<int> w = {1, 0, -1, 1, -1, 1, 0, -1};
	cin >> H >> W;

	vector<vector<int>> map(H + 2, vector<int>(W + 2, 0));

	for (int i = 1; i <= H; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			cin >> tmp;
			if (tmp == '#')
			{
				for (int k = 0; k < 8; k++)
				{
					if (map[i + h[k]][j + w[k]] != 9)
						map[i + h[k]][j + w[k]]++;
				}
				map[i][j] = 9;
			}
		}
	}

	for (int i = 1; i <= H; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			if (map[i][j] == 9)
				cout << "#";
			else
				cout << map[i][j];
		}
		cout << endl;
	}

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


H, W = LI()
h, w = LI()

print((H-h)*(W-w))


Measured memory_bytes: 7748
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[n],t=1;
	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]) t++;
	}
	cout << t;
}


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

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define forrn(i, a, b) for (int i = (a); i < (int)(b); i++)
#define PYMOD(A, M) ((((A) % (M)) + (M)) % (M))
using ll = long long;

using namespace std;

pair<vector<int>::const_iterator, vector<int>::const_iterator> maxes(const vector<int>& v) {
    auto mx = max_element(all(v));
    if (mx == v.begin())
        return mp(mx, max_element(v.begin() + 1, v.end()));
    else if (next(mx) == v.end())
        return mp(mx, max_element(v.begin(), v.end() - 1));
    else {
        auto it = max_element(v.begin(), mx);
        auto jt = max_element(mx + 1, v.end());
        return mp(mx, *it > *jt ? it : jt);
    }
}

vector<int> count(vector<int> v) {
    vector<int> ans(*max_element(all(v)) + 1);
    for (int u : v)
        ans[u]++;
    return ans;
}

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

    int n;
    cin >> n;

    if (n == 2) {
        cout << 0 << endl;
        return 0;
    }

    vector<int> a(n / 2);
    vector<int> b(n / 2);
    forn(i, n) {
        if (i % 2 == 0)
            cin >> a[i / 2];
        else
            cin >> b[i / 2];
    }

    auto ca = count(a);
    auto cb = count(b);
    auto p1 = maxes(ca);
    auto p2 = maxes(cb);

    if (p1.ff - ca.begin() == p2.ff - cb.begin()) {
        cout << min(n - *p1.ff - *p2.ss, n - *p1.ss - *p2.ff) << endl;
    } else {
        cout << n - *p1.ff - *p2.ff;
    }

    return 0;
}

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

int main(){
	int n;
	while (1){
		cin >> n;
		if (n == 0) break;
		int start, end,sum;
		int cnt = 0;
		for (int i = 1; i < n-1; i++){
			start = i;
			sum = i;
			for (int j = i + 1; j < n; j++){
				sum += j;
				if (sum >= n) break;
			}
			if (sum == n) cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import sys
S0=raw_input()
T=list(raw_input())

l=len(T)

if len(S0)<len(T):
	print "UNRESTORABLE"
	sys.exit()


ans=""
for i in range(len(S0)-l+1):
	S1=list(S0)
	#print S1
	for j in range(l):
		#print i+j,j,S1[i+j],T[j]
		if S1[i+j]!=T[j] and S1[i+j]!="?":
			#print "break"
			break
	else:
		#print "else"
		for j in range(l):
			S1[i+j]=T[j]
		S_tmp=(''.join(S1)).replace('?','a')
		#print ans
		#print S_tmp
		if ans=="":
			ans=S_tmp
		if S_tmp < ans:
			ans=S_tmp
			
	
if ans=="":
	print "UNRESTORABLE"
	sys.exit()
else:
	print ans



Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
int32_t main(){
    SPEED;
    int arr[3][3];
    for(int i = 0; i < 3; ++i){
        for(int j = 0; j < 3; ++j){
            cin >> arr[i][j];
        }
    }
    int n;
    cin >> n;
    while(n--){
        int x;
        cin >> x;
        int check = 0;
        for(int i = 0; i < 3; ++i){
            for(int j = 0; j < 3; ++j){
                if(arr[i][j] == x) {
                    arr[i][j] = 0;
                    check = 1;
                    break;
                }
            }
            if(check) break;
        }
    }
    for(int i = 0; i < 3; ++i){
        if(arr[i][0] == 0 && arr[i][1] == 0 && arr[i][2] == 0){
            cout << "Yes" << endl;
            return 0;
        }
        if(arr[0][i] == 0 && arr[1][i] == 0 && arr[2][i] == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(arr[0][0] == 0 && arr[1][1] == 0 && arr[2][2] == 0){
        cout << "Yes" << endl;
        return 0;
    }
    if(arr[2][0] == 0 && arr[1][1] == 0 && arr[0][2] == 0){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3572
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,N,A,B,ans=0;
  cin>>N>>A>>B;
  B+=A;
  print(N/B*A+min(A,N%B));
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    int A,B; cin >> A >> B;

    if(A%3 == 0 || B%3 == 0 || (A+B)%3 == 0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    
    return 0;

}

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

int f[2][185][185][185],g[2][185][185][185];
char a[185][185];
int h, w;
int main()
{
	scanf("%d%d",&h,&w);
	for(int i = 0;i < h;++i) {
		for(int j = 0;j < w;++j) {
			char x;
			scanf(" %c",&x);
			if(x == '#') {
				a[i][j] = 1;
			} else {
				a[i][j] = 0;
			}
		}
	}
	for(int i = 0;i < h;++i) {
		int last = w - 1;
		for(int j = w - 1;j >= 0;--j) {
			if(a[i][j] != a[i][last]) last = j;
			f[0][i][i][j] = last;
		}
	}
	for(int i = 0;i < h;++i) {
		for(int j = i + 1;j < h;++j) {
			for(int k = 0;k < w;++k) {
				if(a[j-1][k] == a[j][k]) {
					f[0][i][j][k] = std::min(f[0][i][j-1][k], f[0][j][j][k]);
				} else {
					f[0][i][j][k] = k-1;
				}
			}
		}
	}
	for(int i = 0;i < w;++i) {
		int last = h - 1;
		for(int j = h - 1;j >= 0;--j) {
			if(a[j][i] != a[last][i]) last = j;
			g[0][i][i][j] = last;
		}
	}
	for(int i = 0;i < w;++i) {
		for(int j = i + 1;j < w;++j) {
			for(int k = 0;k < h;++k) {
				if(a[k][j-1] == a[k][j]) {
					g[0][i][j][k] = std::min(g[0][i][j-1][k], g[0][j][j][k]);
				} else {
					g[0][i][j][k] = k-1;
				}
			}
		}
	}
	int rnd = 0;
	int cnt = 0;
	while(f[rnd][0][h-1][0] < w-1) {
		for(int i = 0;i < h;++i) {
			for(int j = i;j < h;++j) {
				for(int k = 0;k < w;++k) {
					int x = f[rnd][i][j][k];
					if(x < w - 1) x = f[rnd][i][j][x+1];
					f[rnd^1][i][j][k] = x;
				}
			}
		}
		for(int i = 0;i < w;++i) {
			for(int j = 0;j < w;++j) {
				for(int k = 0;k < h;++k) {
					int x = g[rnd][i][j][k];
					if(x < h - 1) x = g[rnd][i][j][x+1];
					g[rnd^1][i][j][k] = x;
				}
			}
		}
		for(int i = 0;i < h;++i) {
			for(int j = i;j < h;++j) {
				for(int k = 0;k < w;++k) {
					for(int x = f[rnd][i][j][k]+1;x <= f[rnd^1][i][j][k];++x) {
						g[rnd^1][k][x][i] = std::max(g[rnd^1][k][x][i],j);
					}
				}
			}
		}
		for(int i = 0;i < w;++i) {
			for(int j = i;j < w;++j) {
				for(int k = 0;k < h;++k) {
					for(int x = g[rnd][i][j][k]+1;x <= g[rnd^1][i][j][k];++x) {
						f[rnd^1][k][x][i] = std::max(f[rnd^1][k][x][i],j);
					}
				}
			}
		}
		rnd = rnd ^ 1;
		++cnt;
	}
	printf("%d\n", cnt);
}


Measured memory_bytes: 98560
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s1,s2;
  cin>>s1;
  cin>>s2;
  int k=0;
  for(int i=0;i<s1.size();i++){
    if(s1[i]!=s2[i]) k=k+1;
  }
  if(k>0) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3592
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

signed main() {
    int x;
    cin>>x;

    while(1){
        bool prime = true;
        for(int i=2;i<=x/2;i++){
            if( x % i == 0){
                prime = false;
                break;
            }
        }
        if(prime){
            cout<<x<<endl;
            return 0;
        }
        x++;
    }

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

Measured memory_bytes: 256
/*input
5
10 1
2 1
4 1
6 1
8 1
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;

bool func(const pair<ll, ll> &a, const pair<ll, ll> &b)
{
	return a.second < b.second;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    int ans = n;
    vector<pair<ll, ll>> a(n);
    for(int i = 0; i < n; i++)
    {
    	ll x, l; cin >> x >> l;
    	a[i] = make_pair(x - l, x + l);
    }
    sort(a.begin(), a.end(), func);
    pair<ll, ll> last = a[0];
    for(int i = 1; i < n; i++)
    {
    	if(a[i].first < last.second && a[i].second > last.first) ans--;
    	else last = a[i];
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 1792
// Author : Radhesh Sarma
   #include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #pragma comment(linker, "/stack:200000000")
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast")
  #pragma GCC optimize("unroll-loops")
    using namespace std;
  using namespace __gnu_pbds;
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define endl "\n"
    #define int long long
    #define all(v) v.begin(),v.end()
    #define rep(i,a,b) for(int i = a; i <=b; i++)
    #define rep2(i,a,b) for(int i = a; i>=b; i--)
    #define f first
    #define s second
    #define PB push_back
    #define MP make_pair
    #define db long double
    #define trace1(x)                cerr<<#x<<": "<<x<<endl
    #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
    #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
    #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
    #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
    #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
    #define cases int testcases;cin>>testcases; while(testcases--)
    #define INF 2000000000
    const double PI = acos(-1);
    const int N =  200005;

  int32_t main() 
  {
    IOS

     string s,t;
     cin >> s >> t;
     cout << t + s;     

    return 0;
  }

Measured memory_bytes: 256
while line = gets
  numbers = line.chomp.split('').map(&:to_i)

  loop do
    _numbers = []
    numbers.each_cons(2) do |a, b|
      _numbers << (a + b) % 10
    end
    numbers = _numbers.dup
    break if numbers.size == 1
  end

  puts numbers.first
end

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

#define PMAX 200000

using namespace std;

int main(){
	vector<int> prime;
	bool pr[PMAX]={0};
	pr[0] = true; pr[1] = true;
	for(int i=2; i<PMAX; i++){
		if(!pr[i]){
			prime.push_back(i);
			for(int j=2*i; j<PMAX; j+=i){
				pr[j] = true;
			}
		}
	}
	int N, P;
	while(cin >> N >> P, N != -1 && P != -1){
		vector<int> sum;
		int j;
		for(j=0; j<prime.size(); j++){
			if( prime[j] > N ){
				break;
			}
		}
		for(int i=0; i<P; i++){
			for(int k=0; k<=i; k++){
				sum.push_back( prime[j+i] + prime[j+k] );
			}
		}
		sort(sum.begin(), sum.end());
		cout << sum[P-1] << endl;
	}
	return 0;
}

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

int main(){
    long long a, b, c;
    cin >> a >> b >> c;
    long long d = c - (a + b);
    if(d < 0){
        cout << "No" << endl;
        return 0;
    }
    d = d * d;
    if(d - 4*a*b > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

void main()
{
    auto N = readln.chomp.to!int;
    long[] rs, cs;
    foreach (_; 0..N) {
        auto rc = readln.split.to!(long[]);
        rs ~= rc[0];
        cs ~= rc[1];
    }

    auto DP = new long[][](N, N);
    foreach (ref dp; DP) dp[] = long.max/3;
    foreach (i; 0..N-1) {
        DP[i][i] = 0;
        DP[i][i+1] = rs[i] * cs[i] * cs[i+1];
    }
    DP[N-1][N-1] = 0;
    foreach (jj; 2..N) {
        foreach (i; 0..N-2) {
            auto j = jj + i;
            if (j >= N) break;
            foreach (k; i..j) {
                DP[i][j] = min(DP[i][j], DP[i][k] + DP[k+1][j] + rs[i] * cs[k] * cs[j]);
            }
        }
    }
    writeln(DP[0][N-1]);
}


Measured memory_bytes: 2504
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define N 100000
#define INFTY 1000000001

typedef struct{
  char suit;
  int num;
}P;

void merge(P *,int,int,int);
void mergeSort(P *,int,int);
void quicksort(P *,int,int);
int partition(P *,int,int);

P L[N],R[N];

int main(){
  int n,i;
  int flag=1;
  P A[N],B[N];

  scanf("%d ",&n);

  for(i=0;i<n;i++){
    scanf("%c %d ",&A[i].suit,&A[i].num);
    B[i].suit=A[i].suit;
    B[i].num=A[i].num;
  }

  mergeSort(A,0,n);
  quicksort(B,0,n-1);

for(i=0;i<n;i++){
  if(A[i].suit!=B[i].suit){
    flag=0;
  }
}
if(flag==1){
  printf("Stable\n");
}
else{
  printf("Not stable\n");
}

  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].suit,B[i].num);
  }

  return 0;
}

void quicksort(P *B,int p,int r){
  int q;
   if (p < r){
     q = partition(B, p, r);

     quicksort(B, p, q-1);
     quicksort(B, q+1, r);
  }}

  int partition(P *B,int p,int r){
    int i,j;
    P x,temp;
     x = B[r];
     i = p-1;
    for (j=p;j<r;j++){
       if (B[j].num <= x.num){
         i = i+1;
         temp=B[i];
         B[i]=B[j];
         B[j]=temp;
       }

       /* A[i] と A[j] を交換*/
     }


     temp=B[i+1];
     B[i+1]=B[r];
     B[r]=temp;
     /*A[i+1] と A[r] を交換*/
     return i+1;
   }

   void merge(P *A,int left,int mid,int right){
     int n1,n2,i,j,k;
     n1=mid-left;
     n2=right-mid;

     for(i=0;i<n1;i++){
       L[i]=A[left+i];
     }
     for(i=0;i<n2;i++){
       R[i]=A[mid+i];
     }
     L[n1].num=INFTY;
     R[n2].num=INFTY;
     i=0;
     j=0;

     for(k=left;k<right;k++){
       if(L[i].num<=R[j].num){
         A[k]=L[i];
         i=i+1;
       }
       else{
         A[k]=R[j];
         j=j+1;
       }
     }
   }

   void mergeSort(P *A,int left,int right){
     int mid;
     if(left+1<right){
       mid=(left+right)/2;
       mergeSort(A,left,mid);
       mergeSort(A,mid,right);
       merge(A,left,mid,right);
     }
   }



Measured memory_bytes: 4144
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
  //stream
  friend ostream& operator<<(ostream& os, const mint a);
};
ostream& operator<<(ostream& os, const mint a){
  os << a.x;
  return os;
}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
int main(void) {
	int n,k; cin >> n >> k;
	mint ans = 0;
	combination comb(n+5);
	rep(i,min(k+1,n)) ans += comb(n,i)*comb(n-1,i);
	cout << ans << endl;
}




Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll n,m; cin >> n >> m;
  if(n % m == 0){
    cout << "0";
  }
  else{
    cout << "1";
  }
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>

int main(void)
{
	char s[10];
	int number = 0, dif[10] = {0}, lenth = 0, min = 0;
	
	scanf("%s", s);
	lenth = strlen(s);
	for ( int i = 0; i < lenth - 2; i++ ) {
		number = ( s[i] - '0' ) * 100 + ( s[i+1] - '0' ) * 10 +  ( s[i+2] - '0' );
		dif[i] = abs(number-753);
		if ( i == 0 ) min = dif[i];
		else if ( min >= dif[i] ) min = dif[i];
	}
	printf("%d", min);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <cstring>
using namespace  std;
int main()
{
	int N = 0, A = 0, B = 0;
	cin >> N >> A >> B;
	string str;
	cin >> str;
	int sum = A + B, overseas = 0, currentsum = 0;
	for(int i = 0; i < str.size(); i ++) {
		if(str[i] == 'a') {
			if(currentsum < sum) {
				cout << "Yes" << endl;
				currentsum ++;
			}
			else
				cout << "No" << endl;
		}
		else if(str[i] == 'b') {
			overseas ++;
			//cout << " over" << overseas << " " << currentsum << endl;
			if(currentsum < sum && overseas <= B) {
				cout << "Yes" << endl;
				currentsum ++;
			}
			else
				cout << "No" << endl;
		}
		else
			cout << "No" << endl;
	}
}


Measured memory_bytes: 896