akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter


import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(X, Y, Z, K, A, B, C):
    q = []

    for a in A:
        for b in B:
            if len(q) < K:
                heapq.heappush(q, a+b)
            else:
                heapq.heappushpop(q, a+b)

    qq = []
    for c in C:
        for d in q:
            if len(qq) < K:
                heapq.heappush(qq, d+c)
            else:
                heapq.heappushpop(qq, d+c)

    qq.sort(reverse=True)
    return qq

def main():
    X, Y, Z, K = read_int_n()
    A = read_int_n()
    B = read_int_n()
    C = read_int_n()
    print(*slv(X, Y, Z, K, A, B, C), sep='\n')


if __name__ == '__main__':
    main()


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

using pii = pair<int,int>;
using ll = long long;
#define f(i,a,b) for (int i = a; i < b; i++)
#define fr(i,a,b) for (int i = b-1; i >= a; i--)

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n; cin >> n;
	int a[n]; f(i,0,n) cin>>a[i];
	auto valid = [&](int k) {
		map<int,int> s;
		f(i,1,n) if (a[i]<=a[i-1]) {
			int j = a[i]-1;
			for (auto it = s.upper_bound(j); it != s.end(); it = s.erase(it));
			for (pii pp : s) if (pp.first > j) 
				s[pp.first] = 0;
			while (j >= 0) {
				if (++s[j] == k) s[j--] = 0;	
				else break;
			}
			if (j == -1) return 0;
		}
		return 1;
	};
	bool found = 1;
	f(i,1,n) if (a[i]<=a[i-1])
		found = 0;
	if (n==1 || found) cout << 1 << endl;
	else {
		int lo = 2, hi = n;
		while (lo<=hi) {
			int mid = (lo+hi)/2;
			if (valid(mid)) hi = mid-1;
			else lo = mid+1;
		}
		cout << lo << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
n = raw_input()
p = map(int, raw_input().split())
c =  0
for i in range(1, len(p)-1):
    if p[i] > p[i-1] and p[i] < p[i+1]:
        c += 1
    elif p[i] > p[i+1] and p[i] < p[i-1]:
        c += 1
print(c)

Measured memory_bytes: 2568
#include <iostream>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>

using namespace std;

using ll = long long;

vector<pair<pair<string,int>,int > > v;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	string s;
	int p;
	cin>>n;
	for(int i=0; i<n; ++i){
		cin>>s>>p;
		v.push_back({{s,-p},i+1});
	}
	sort(v.begin(),v.end());
	for(auto i:v){
		cout<<i.second<<'\n';
	}
	cout<<flush;
	return 0;
}


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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using vc2 = vector<vector<char>>;

int main(){
	int a, b, c, d;
	string s;
	cin >> s;
	a = static_cast<int>(s.at(0))-48;
	b = static_cast<int>(s.at(1))-48;
	c = static_cast<int>(s.at(2))-48;
	d = static_cast<int>(s.at(3))-48;
	vector<char> op(3);
	for(int bit = 0; bit < (1<<3); ++bit){
		int sum = a;
		if(bit& (1<<2)){
			sum += b;
			op.at(0) = '+';
		}else{
			sum -= b;
			op.at(0) = '-';
		}
		if(bit & (1<<1)){
			sum += c;
			op.at(1) = '+';
		}else{
			sum -= c;
			op.at(1) = '-';
		}
		if(bit & (1<<0)){
			sum += d;
			op.at(2) = '+';
		}else{
			sum-=d;
			op.at(2) = '-';
		}
		if(sum == 7){
			cout << a << op.at(0) << b << op.at(1) << c << op.at(2) << d << "=7" << endl;
			break;
		}
	}
}


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

#define pb push_back
#define ll long long int
#define mpi map<int, int>
#define vi vector<int>
#define si set<int>
#define pii pair<int, int>
#define vpi vector<pii>
#define vs vector<string>
#define pri priority_queue<int>
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define For(i, n) for (int i = 0; i < n; i++)
#define Ford(i, a, b) for (int i = a; i >= b; i--)
#define Rep(i, x, y) for (int i = x; i <= y; i++)
#define mem(a, b) memset(a, b, sizeof(a))
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

double tick()
{
    static clock_t oldt, newt = clock();
    double diff = 1.0 * (newt - oldt) / CLOCKS_PER_SEC;
    oldt = newt;
    return diff;
}
const double pi = 3.1415926535897932;

int main()
{
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double ang = abs(m / 2 + h * 30 - 6 * m);
    ang = pi * ang / 180;
    double res = sqrt(a * a + b * b - 2 * a * b * cos(ang));
    printf("%.15lf", res);
    cerr << "execution time is: " << tick() << "\n";
}


Measured memory_bytes: 4196
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std; 
int t[103];

// ansでキャッシュして、最後に時間を引いて、xを足すことによって置き換える
int main(){
	fastIO;         
	int n,m;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		cin>>t[i];
		ans+=t[i];
	}
	cin>>m;
	for(int i=0;i<m;i++){
		int p,x;	
		cin>>p>>x;
		cout<<ans-t[p]+x<<'\n';
	}
	return 0;
}

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

if 400 <= x <= 599:
  print(8)
elif 600 <= x <= 799:
  print(7)
elif 800 <= x <= 999:
  print(6)
elif 1000 <= x <= 1199:
  print(5)
elif 1200 <= x <= 1399:
  print(4)
elif 1400 <= x <= 1599:
  print(3)
elif 1600  <= x <= 1799:
  print(2)
else:
  print(1)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a = 0, b = 0;
    int n;
    cin >> n;
    while(n--) {
        string s, t;
        cin >> s >> t;
        if(s > t) a += 3;
        if(s < t) b += 3;
        if(s == t) a++, b++;
    }
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N, M;
int a[150], b[150], c[150];
ll dp[1<<15][15], s[1<<15];
int g[15][15];

int main() {
	cin >> N >> M;
	
	memset(g, -1, sizeof(g));
	REP(i, M) {
		scanf("%d %d %d", a + i, b + i, c + i);
		a[i]--; b[i]--;
		g[a[i]][b[i]] = c[i];
		g[b[i]][a[i]] = c[i];
	}
	
	REP(i, 1<<N) {
		ll sum = 0;
		REP(j, M) if (i >> a[j] & 1 && i >> b[j] & 1) sum += c[j];
		s[i] = sum;
	}
	
	memset(dp, -1, sizeof(dp));
	dp[1][0] = 0;
	
	REP(i, 1<<N) REP(j, N) if (dp[i][j] != -1) {
		REP(k, N) if (!(i >> k & 1) && g[j][k] != -1) chmax(dp[i | 1<<k][k], dp[i][j] + g[j][k]);
		
		int bit = ((1<<N)-1) ^ i;
		int now = bit;
		do {
			chmax(dp[i | now][j], dp[i][j] + s[now | 1<<j]);
			now = (now - 1) & bit;
		} while (now != bit);
		
	}
	
	ll ans = 0;
	REP(i, M) ans += c[i];
	ans = ans - dp[(1<<N)-1][N-1];
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>

#define fr(i,b,e) for(int i=(b); i<(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long ll;

const int mod= 1000000007;    

int chk(vector<int>& a){
    int n=a.size();
    fr(i,0,n){
        cout << a.at(i);
    }
    cout << endl;
}


int gcd(int a,int b){ //a>b
    int tmp=a%b;
    a=b;
    b=tmp;
    if(b!=0){
        return gcd(a,b);
    }else{
        return a;
    }
}

int mon_combination(int n, int a, int p){
    int m = min(a,n-a);
    int c = 0;
    ll up = 1;
    while(c != m){
        up = ((n-c)*up) % p;
        ++c;
    }

    ll down = 1;
    while(c != 0){
        down=(down*c)%p;
        --c;
    }
}

ll power(ll a,ll n){
    if(n==1){
        return a;
    }
    else if(n&1==1){
        --n;
        return power(a,n)*a;
    }else{
        n=n>>1;
        return power(a,n)*power(a,n);
    }
}

ll mod_power(ll a,ll n, ll p){
    if(n==1){
        return a%p;
    }
    else if(n&1==1){
        --n;
        return (mod_power(a,n,p)*a)%p;
    }else{
        n=n>>1;
        return (mod_power(a,n,p)*mod_power(a,n,p))%p;
    }
}

ll mod_inv_fermat(ll a,ll p){  // inv of a in mod p
    ll n=p-2;
    return mod_power(a,n,p);
}

ll egcd(ll a, ll p, ll &x, ll &y) {
    /*
        ax+pm=1を再帰的に解いてxをaの逆元として求める。
        入力としてa<pを仮定。
    */
    if (a == 0) {
        x = 0;
        y = 1;
        return p;
    }
    ll d = egcd(p%a, a, y, x); // 再帰的に解く
    // 再帰で求まったx,y,a,pを用いて、逆元を計算
    x -= p/a * y; //　今までの処理を呼び出している関数の引数を計算
    return d;
}

ll mod_inv(ll a,ll p){  // inv of a in mod p
    ll x,y;
    egcd(a,p,x,y);
    return (x%p+p)%p;
}

ll mod_combination(ll n, ll a, ll p){
    ll m = min(a,n-a);
    ll c = 0;
    ll up = 1;
    ll down = 1;
    while(c != m){
        up = ((n-c)*up) % p;
        ++c;
        down =(down*c) % p;
    }
    return (up*mod_inv(down,p))%p;
}


int main(void){
    ll a,b;
    ll n;
    cin >> n >> a>> b;
    ll all=(mod_power(2,n,mod)-1)%mod;

    all=(all-mod_combination(n,a,mod)+mod)%mod;
    all=(all-mod_combination(n,b,mod)+mod)%mod;
    cout << all << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();

		int ans = 1;
		double check = (b % a)/a;


		if(a != b) {
			ans = (int) ((b+a-3)/(a-1));

		}else {
		}
		System.out.println(ans);

	}

}


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

#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

using namespace std;
int main() 
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	long N;
	cin >> N;
	vector<long> ar;
	long input;
	while(N-- && cin >> input){
		ar.push_back(input);
	}
	map<long,long> m;
	for(vector<long>::iterator t=ar.begin(); t!=ar.end(); t++){
		m[*t]++;
	}
	long c = 0;
	for(auto v : m){
		if(v.second<v.first)
			c+=v.second;
		else
			c+=v.second-v.first;
	}
	cout << c << "\n";


}

Measured memory_bytes: 7028
N=int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))
D=[0]*N
for i in range(N):
    D[i]=V[i]-C[i]
D.sort(reverse=True)
ans=0
for i in range(N):
    if D[i]>0:
        ans+=D[i]
    else:
        break
print(ans)

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

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;

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

    long s[N];
    s[0] = p[0];
    for(int i=1; i<N; i++){
        s[i] = s[i-1] + p[i];
    }

    long m = s[K-1];
    for(int i=1; i<N-K+1; i++){
        if(m < s[K-1+i] - s[i-1]) m = s[K-1+i] - s[i-1];
    }

    //cout << (double)(m+K) / (double)2.0;
    printf("%.12lf\n", (double)(m+K) / (double)2.0);

    return 0;
}

Measured memory_bytes: 2560
def ispalindrome(str): return 1 if str == str[::-1] else 0

S = input()

length = len(S)

mini_length = length//2

if mini_length%2 != 0:
    left_center = mini_length//2
    right_center = mini_length + left_center + 1
    left_left = S[:left_center]
    left_right = S[left_center+1:mini_length]
    right_left = S[mini_length+1:right_center]
    right_right = S[right_center+1:length]
    left = S[:mini_length]
    right = S[mini_length+1:length]

    # if (left_left == left_right[::-1]) and (right_left == right_right[::-1]):
    #     print('Yes')
    # else:
    #     print('No')
    if (ispalindrome(left)==1) and (ispalindrome(right)==1) and(ispalindrome(S)==1):
        print('Yes')
    else:
        print('No')
else:
    left_center = mini_length//2
    right_center = mini_length + left_center + 1
    left_left = S[:left_center]
    left_right = S[left_center:mini_length]
    right_left = S[mini_length+1:right_center]
    right_right = S[right_center:length]
    left = S[:mini_length]
    right = S[mini_length+1:length]
    if (ispalindrome(left)==1) and (ispalindrome(right)==1) and (ispalindrome(S)==1):
        print('Yes')
    else:
        print('No')



Measured memory_bytes: 3064
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <cstring>
#include <fstream>

using namespace std;

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

	int a, b, c;

	cin >> a >> b >> c;

	if (a + b + c >= 22)
	{
		cout << "bust" << '\n';
	}
	else
	{
		cout << "win" << '\n';
	}

	return 0;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll

int grid[100][100] = {};
void solve() {
	int n;
	cin >> n;
	REP(i, n) {
		REP(q, n) {
			cin >> grid[i][q];
		}
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		for (int q = i + 1; q < n; ++q) {
			ans += min(grid[i][q], grid[q][i]);
		}
	}
	cout << ans << endl;
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3292
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
// #include <bits/extc++.h>
using namespace std;

#define debug(s) cout << #s << " = " << s << endl
#define all(v) (v).begin(), (v).end()
#define KeepUnique(v) (v).erase( unique(all(v)), v.end() )
#define MEMSET(a, val) memset(a, val, sizeof (a))
#define PB push_back
#define endl '\n'
typedef long long ll;

inline int myrand(int l, int r) {
	int ret = rand(); ret <<= 15; ret ^= rand();
	if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
	return ret;
}

template <typename F, typename S>
ostream& operator << (ostream& os, const pair< F, S>& p) {
	return os<<"(" <<p.first<<", "<<p.second<<")"; }

typedef pair<int, int> ii;

template<typename T> using min_pq =
	std::priority_queue<T, vector<T>, greater<T> >;

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

#define int long long
const int maxn = 100;

int n, a[maxn], p;
int dp[maxn][2];

int get(int i, int v) {
	if(i == n + 1) return v == p;
	int &ret = dp[i][v];
	if(ret != -1) return ret;
	ret = get(i + 1, v) + get(i + 1, (a[i] + v) % 2);
	return ret;
}

int32_t main () {
    // freopen("in", "r", stdin);
    cin >> n >> p;
    for(int i = 1; i <= n; i++)
    	cin >> a[i];
    memset(dp, -1, sizeof dp);
    cout << get(1, 0) << endl;
}

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

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 1000000007

int main(){


    ll n,m,ans = 0;
    cin >> n >> m;

    if(m >= n*2){
        ans+=n;
        m = m-n*2;
        ans+=m/4;
    }else{

        ans = m/2;
    }  

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){
  int n, d;  scanf("%d %d", &n, &d);
  int x[13][13];
  for(int i=1; i<=n; i++)
    for(int j=1; j<=d; j++)
      scanf("%d", &x[i][j]);
  int count = 0;
  for(int i=1; i<n; i++){
    for(int j=i+1; j<=n; j++){
      int dis = 0;
      for(int k=1; k<=d; k++)
	dis = dis + (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      if(dis == (int)sqrt(dis)*(int)sqrt(dis)){
	count++;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}


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

#define co(x) cout << x << endl ;

int main ()
{
    int botA , botB , amoA , sum = 0 , res = 0 ;

    cin >> botA >> amoA >> botB ;

    sum = amoA + botB ;

    res = sum - botA ;

    if (res <= 0 )
    {
        co (0)
    }
    else
    {
        co (res)
    }
    return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
#define F first
#define S second
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cout << fixed << setprecision(10);
  int n,x,t;
  cin >> n >> x >> t;
  cout << (n+x-1)/x*t << endl;
}


Measured memory_bytes: 3616
n, k = [int(x) for x in input().split()]
v_list = [int(x) for x in input().split()]

stop = min(n, k)

ans = 0
for a in range(stop + 1):
    a_list = v_list[:a]
    for b in range(stop + 1 - a):
        b_list = v_list[n-b:]
    
        temp_list = a_list + b_list
        temp_list.sort(reverse=True)

        for _ in range(k - a - b):
            if len(temp_list) == 0 or temp_list[-1] >= 0:
                break
            temp_list.pop()

        temp = sum(temp_list)
        if ans < temp:
            ans = temp
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  REP(i,1,10) {
    REP(j,1,10) {
      if(i*j==n) {
        pr("Yes");
        return;
      }
    }
  }
  pr("No");
}

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


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc162/tasks/abc162_b

def acc(n)
  n * (n + 1) / 2
end

N = gets.to_i
ans = acc(N) - 3 * acc(N / 3) - 5 * acc(N / 5) + 15 * acc(N / 15)
puts ans


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

#define pb push_back
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000

using namespace std;

typedef long long ll;   
typedef double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<int> vi;

int main(){
    int n, temp;
    cin>>n;
    vi cou(n, 0);

    for(int i=1;i<n;i++){
        cin>>temp;
        cou[temp - 1]++;
    }

    for(int i=0;i<n;i++) cout<<cou[i]<<endl;


    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}


Measured memory_bytes: 4096
#include <stack>
using namespace std;

struct Rectangle {
  int height;
  int pos;
};
 

#include <stdio.h>
#define SIZ 1400
int m[SIZ+1][SIZ+1];
int st[SIZ];
char z[9999999];
int get(){
	static int input_count=0;
	int r=0;
	for(;'0'<=z[input_count]&&z[input_count]<='9';)r=r*10+z[input_count++]-'0';
	input_count++;
	return r;
}
int main(){
	fread(z,1,sizeof(z),stdin);
	int i,j,k,y=get(),x=get(),r,ptr;
	for(j=0;j<y;j++)for(r=i=0;i<x;m[j][i]=r,i++){
		int t=get();
		r=t==0?r+1:0;
	}
	r=0;
/*
	for(i=0;i<x;i++)for(ptr=j=0;j<=y;j++){
		//printf("%d %d %d %d\n",i,j,ptr,m[j][i]);
		if(!ptr || st[ptr-1]<m[j][i])st[ptr++]=m[j][i];
		else{
			for(;ptr && st[ptr-1]>m[j][i];){
				int _y=(j-(ptr-1)),_x=st[--ptr];
				//printf("%d %d\n",_x,_y);
				if(r<_x*_y)r=_x*_y;
			}
			st[ptr++]=m[j][i];
		}
	}
*/
	Rectangle rect;
	for(int i=0;i<x;i++){
		stack<Rectangle> stk;
		int pop=0;
		for(int j=0;j<=y;j++){
			rect.height = m[j][i];
			rect.pos = j;
			if(stk.empty() || stk.top().height < rect.height){
				stk.push(rect);
			}else{
				//printf("[-] %d %d\n",i,j);
				for(;!stk.empty() && stk.top().height >= rect.height;){
					pop++;
					Rectangle pre = stk.top(); stk.pop();
					int area = pre.height * (j - pre.pos);
					r = max(r, area);
					//printf("%d %d\n",target,pre.pos);
					rect.pos = pre.pos;
				}
				stk.push(rect);
			}
			if(rect.height==0)pop=0;
		}
	}

	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 14312
#include<bits/stdc++.h>
using namespace std;
long long k,maX,ans,n,i;
long long a[10000000];
int main()
{
	cin>>i>>n;
	for(k=1;k<=n;k++)
	{
		cin>>a[k];
	}
	sort(a+1,a+1+n);
	for(k=2;k<=n;k++)
	{
		maX=max(a[k]-a[k-1],maX);
	}
	maX=max(maX,a[1]-a[n]+i);
	cout<<i-maX;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;

int main() {
	int x;
	bool tf = true;
	cin >> x;
	while (1) {
		tf = true;
		for (int j = 2; j <= x / 2; j++) {
			if (x % j == 0) {
				tf = false;
				break;
			}
		}
		if (tf) {
			break;
		}
		x++;
	}
	cout << x << endl;
	

	return 0;
}

Measured memory_bytes: 256
# Union Find
# http://www.prefield.com/algorithm/container/union_find.html
class UnionFind
  def initialize(n)
    @data = Array.new(n, -1)
  end

  def union_set(a, b)
    a = root(a)
    b = root(b)
    if a != b
      a, b = b, a if @data[b] < @data[a]
      @data[a] += @data[b]
      @data[b] = a
    end
    return a != b
  end

  def find_set(a, b)
    root(a) == root(b)
  end

  def size(a)
    return -@data[root(a)]
  end

  def root(a)
    return a if @data[a] < 0
    @data[a] = root(@data[a])
  end
end

n, m = gets.chomp.split.map(&:to_i)

uf = UnionFind.new(n)
m.times do
  a, b = gets.chomp.split.map(&:to_i)
  a -= 1
  b -= 1

  uf.union_set(a, b)
end

res = 0
n.times do |i|
  res = [res, uf.size(i)].max
end

puts res


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

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define pull pair<ull, ull>
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int s, w;
	cin >> s >> w;
	
	if(w >= s)cout << "unsafe";
	else cout << "safe";
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, l;
    cin >> n >> l;
    // lからl+n-1まで
    int ans = 0;
    int mn = 1001001001;
    for (int i = l; i <= l+n-1; ++i) {
        ans += i;
        if (abs(mn) > abs(i)) mn = i;
    }
    ans -= mn;
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define BS bitset
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue<LL>
#define PQS priority_queue<LL, vector<LL>, greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define MP make_pair
#define TS to_string
#define TU to_ullong
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000000000001
#define NUM 200010

void yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
template<typename T>bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  LL N,M,T,i,j,a=0;
  VL x(100005),y(100005),kf(50005),kn(50005);
  BS<100005> ans;
  VE<BS<50005>> f(50005);
  cin>>N>>M>>T;
  rep(i,M)cin>>x[i]>>y[i];
  if(T==1){
    FOR(i,1,N+1)f[i][i]=1;
    rep(i,M)f[x[i]]=f[y[i]]=f[x[i]]|f[y[i]];
    FOR(i,1,N+1){
      if(f[i].count()!=N)continue;
      f[i].reset();
      f[i][i]=1;
      for(j=M-1;j>=0;j--){
        if(f[i].test(x[j]))f[i][y[j]]=1,ans[j]=1;
        else if(f[i].test(y[j]))f[i][x[j]]=1,ans[j]=0;
        else ans[j]=0;
      }
      if(f[i].count()==N)a=1;
      if(a==1){
        rep(i,M)cout<<(ans.test(i)?'^':'v');
        return 0;
      }
    }
    cout<<-1<<endl;
  }else{
    FOR(i,1,N+1)kf[i]=i,kn[i]=1;
    for(i=M-1;i>=0;i--){
      if(kn[kf[x[i]]]>kn[kf[y[i]]]){
        ans[i]=0;
        kn[kf[x[i]]]--,kn[kf[y[i]]]++;
        kf[x[i]]=kf[y[i]];
      }else{
        ans[i]=1;
        kn[kf[x[i]]]++,kn[kf[y[i]]]--;
        kf[y[i]]=kf[x[i]];
      }
    }
    FOR(i,1,N+1)if(kn[i]>0)a++;
    if(a>1)rep(i,M)cout<<(ans.test(i)?'^':'v');
    else printf("-1");
  }

	return 0;
}


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

int tax(int X, int i) {
  return i * (100 + X) / 100;
}

int main() {
  int X;
  int Y;
  int S;

  while (true)
    {
      cin >> X >> Y >> S;
      if (X == 0 && Y == 0 && S == 0) break;
      int maximum = 0;
      for (int i = 1; i < S; ++i) 
	for (int j = 1; j < S; ++j)
	  if (tax(X, i) + tax(X, j) == S) 
	    maximum = max(maximum, tax(Y, i)+tax(Y,j));

  cout << maximum << endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
typedef long long ll;
using namespace std;

int main()
{
	string O, E;
	cin >> O >> E;
	int n = min(O.size(), E.size());
	for (int i = 0; i < n; i++)
	{
		cout << O[i] << E[i];
	}
	if (n < O.size()) cout << O[n];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n;
  ll x;
  cin>>n>>x;
  vecll a(n);
  for(auto&& e:a) cin>>e;
  ll sum = 0;
  for(auto&& e:a) sum += e;
  ll ans = sum;
  vecll mn = a;
  for(auto&& i:irange(0,n)) {
    vecll nx = a;
    for(auto&& j:irange(0,n)) {
      int old = (j + n - 1) % n;
      nx[j] = min(a[j], mn[old]);
    }
    ll sum = 0;
    for(auto&& e:nx) sum += e;
    ans = min(ans, sum + (i+1) * x);
    swap(mn, nx);
  }
  cout<<ans<<endl;
  return 0;
}


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

#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))

typedef long long ll;
const int inf = 2e9;
using namespace std;
ll MOD = 1000000007;
typedef pair<int,int> ii;
typedef struct {int a,b,c;}iii;
typedef vector<int> vi;


void mosA(vector<int> a){
	for(int i=0; i<a.size(); i++) printf("%d ",a[i]);
	printf("\n");
}
void mosP(vector<ii> a){
	for(int i=0; i<a.size(); i++) printf("%d %d\n",a[i].first,a[i].second);
	printf("\n");
}
ll min_especial(ll a, ll b){
  if(a!=-1 && b!=-1) return min(a,b);
  else return max(a,b);
}

bool ord(ll a, ll b){
	return b<a;
}

int k,q,n,m,t,a,b,u,f,l,x,z,y;
ll A[3][1005];
map<ll,bool> M;



int main(){
	scanf("%d%d%d%d",&x,&y,&z,&k);
	FOR(i,x) scanf("%lld",&A[0][i]);
	FOR(i,y) scanf("%lld",&A[1][i]);
	FOR(i,z) scanf("%lld",&A[2][i]);
	sort(A[0],A[0]+x,ord);
	sort(A[1],A[1]+y,ord);
	sort(A[2],A[2]+z,ord);

	ll p1 = 0,p2 = 0, p3 = 0, cual=-1;

	//FOR(i,x) printf("%lld\n",A[0][i]);


	priority_queue<pair<ll,ll>> Q;
	Q.push({A[0][p1]+A[1][p2]+A[2][p3],p1+p2*1000+p3*1000000});

	while(k--){



		pair<ll,ll> m = Q.top();
		ll pos = m.second;

		printf("%lld\n",m.first);
		Q.pop();

		M[pos] = 1;

		p1 = pos%1000;
		p2 = (pos/1000)%1000;
		p3 = pos/1000000;

		//cout<<p1<<" "<<p2<<" "<<p3<<endl;

		if(p1+1<x && !M[p1+1+p2*1000+p3*1000000]){
			Q.push({A[0][p1+1]+A[1][p2]+A[2][p3],p1+1+p2*1000+p3*1000000});
			M[p1+1+p2*1000+p3*1000000] = 1;
		}
		if(p2+1<y && !M[p1+(p2+1)*1000+p3*1000000]){
			Q.push({A[0][p1]+A[1][p2+1]+A[2][p3],p1+(p2+1)*1000+p3*1000000});
			M[p1+(p2+1)*1000+p3*1000000] = 1;
		}
		if(p3+1<z && !M[p1+p2*1000+(p3+1)*1000000]){
			Q.push({A[0][p1]+A[1][p2]+A[2][p3+1],p1+p2*1000+(p3+1)*1000000});
			M[p1+p2*1000+(p3+1)*1000000] = 1;
		}

	}

	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const long double PI = (acos(-1));
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)

ll mpow(ll a, ll n){
    ll res = 1;
    while (n > 0){
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

int main(){
    int x; sc(x);
    bool check = false;
    vector<ll> v1, v2;
    ll now = 0, tmp, a, b, tmp1, tmp2;
    while(1){
        tmp = mpow(now, 5);
        if (now == 120) break;
        v1.push_back(tmp);
        v2.push_back(now);
        now++;
    }
    rep(i, 0, v1.size()){
        a = v1[i];
        tmp1 = a + x;
        tmp2 = x - a;
        auto it1 = lower_bound(v1.begin(), v1.end(), tmp1);
        auto it2 = lower_bound(v1.begin(), v1.end(), tmp2);
        if (*it1 - a == x){
            cout << v2[it1-v1.begin()] << " " << v2[i] << endl;
            break;
        }
        if (*it2 + a == x){
            cout << v2[it2-v1.begin()] << " " << -v2[i] << endl;
            break;
        }
    }
    return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> X(N), S(N);
  for (int i = 0; i != N; ++i) {
    cin >> X[i];
    S[i] = X[i];
  }
  sort(begin(S), end(S));
  auto m1 = S[N/2-1];
  auto m2 = S[N/2];
  for (auto &x: X) {
    if (x >= m2) cout << m1 << endl;
    else cout << m2 << endl;
  }
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

int main() {
  int p, q, r;
  cin >> p >> q >> r;

  cout << min({p + q, q + r, r + p}) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef vector<int> V;
typedef pair<int,int> P;
typedef vector<vector<int>> Graph;

int main() {
    int n,q;
    map<int,int> a;
    cin >> n;
    ll ans=0,tmp=0;
    rep(i,n){
        int A;
        cin >> A;
        a[A]++;
        ans += A;
    }
    cin >> q;
    rep(i,q){
        int b,c;
        cin >> b >> c;
        ans += a[b]*c - a[b]*b;
        a[c] = a[c] + a[b];
        a[b] = 0;
        cout << ans << endl;
    }
}

Measured memory_bytes: 8052
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  string S;
  sc.scan(S);

  int min = abs(753 - to!int(S[0 .. 3]));

  foreach (i; 1 .. S.length - 2) {
    if (min > abs(753 - to!int(S[i .. i + 3])))
      min = abs(753 - to!int(S[i .. i + 3]));
  }

  writeln(min);
}


Measured memory_bytes: 256
#import <Foundation/Foundation.h>
#import <stdarg.h>

@interface StdIO : NSObject
+(NSMutableString*)stringFromStdIn; // 標準入力から NSString を得る
+(void)printf:(NSString*)format, ...; // 標準出力へ出力
@end

@implementation StdIO
+(NSMutableString*)stringFromStdIn
{
    NSFileHandle *handle = [NSFileHandle fileHandleWithStandardInput];
    NSMutableString *result = [NSMutableString string];
    NSData *data = [handle availableData];
    while ([data length] > 0) {
        [result appendString:[[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]];
        data = [handle availableData];
    }
    NSUInteger length = [result length];
    if (length >= 1 && [result characterAtIndex:length-1] == '\n') { // 入力末尾に改行文字があれば削除
        [result deleteCharactersInRange:NSMakeRange(length-1,1)];
    }
    return result;
}
+(void)printf:(NSString*)format, ...
{
    va_list arguments;
    va_start(arguments, format);
    NSString *string = [[[NSString alloc] initWithFormat:format arguments:arguments] autorelease];
    NSFileHandle *fileHandle = [NSFileHandle fileHandleWithStandardOutput];
    [fileHandle writeData:[string dataUsingEncoding:NSUTF8StringEncoding]];
    va_end(arguments);
}
@end

@interface NSArray (Extension)
-(NSArray*)integerValues;
@end

@implementation NSArray (Extension)
-(NSArray*)integerValues
{
    NSMutableArray *result = [NSMutableArray array];
    for (id obj in self) {
        [result addObject:@([obj integerValue])];
    }
    return result;
}
@end

  
int main() {
    @autoreleasepool {
        NSArray *numbers = [[[StdIO stringFromStdIn] componentsSeparatedByString:@" "] integerValues];
        NSInteger N = [[numbers objectAtIndex:0] integerValue];
        NSInteger Y = [[numbers objectAtIndex:1] integerValue] / 1000;
        
        NSInteger x = 0;
        while (x <= MIN(N,Y/10)) {
            NSInteger y = Y-N-9*x;
            NSInteger z = 5*N-Y+5*x;
            if (y>=0 && z>=0 && y%4==0 && z%4==0) {
                [StdIO printf:@"%ld %ld %ld", x, y/4, z/4];
                return 0;
            }
            x++;
        }
        [StdIO printf:@"-1 -1 -1"];
    }
    return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        char[] S = Console.ReadLine().ToCharArray();

        string[] three = new string[N - 2];
        for (int i = 0; i < N - 2; i++)
            for (int j = 0; j < 3; j++)
                three[i] += S[i + j];

        int O = three.Where(o => o == "ABC").Count();

        Console.WriteLine(O);
    }
}


Measured memory_bytes: 11348
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+7; 
int main()
{
	int n;
	cin>>n;
	long long sum=0;
	long long count=0;
	long long a[N];
	long long  minn=1e15; 
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	count+=a[1]; 
	for(int i=2;i<=n;i++)
	{
		minn=min(minn,abs(sum-count*2));
		count+=a[i];
	}
	cout<<minn<<endl;
	return 0;
} 

Measured memory_bytes: 1792
#include<bits/stdc++.h>
const long int p=1e9+7;

using namespace std;

void swap(int *x,int *y)
{
    int temp=*x;
    *x=*y;
    *y=temp;
}

void fun()
{
   int x,y,z;
   cin>>x>>y>>z;

   swap(x,y);
   swap(x,z);

   cout<<x<<" "<<y<<" "<<z;

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

    fun();
    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;
 
#define pi pair<int,int>
#define pl pair<lld,lld>
 
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())
 
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
 
int main() {
    string S;
    cin >> S;
    if(S.size() == 9){
        if(S == "AKIHABARA"){
            cout << "YES" << endl;
            exit(0);
        }
    } else if(S.size() == 8){
        if(S == "KIHABARA" || S == "AKIHBARA" || S == "AKIHABRA" || S == "AKIHABAR"){
            cout << "YES" << endl;
            exit(0);
        }
    } else if(S.size() == 7){
        if(S == "KIHBARA" || S == "KIHABRA" || S == "KIHABAR" || S == "AKIHBRA" || S == "AKIHBAR" || S == "AKIHABR"){
            cout << "YES" << endl;
            exit(0);
        }
    } else if(S.size() == 6){
        if(S == "AKIHBR" || S == "KIHABR" || S == "KIHBAR" || S == "KIHBRA"){
            cout << "YES" << endl;
            exit(0);
        }
    } else if(S.size() == 5){
        if(S == "KIHBR"){
            cout << "YES" << endl;
            exit(0);
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<queue>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<set>
#include<stack>
#include<queue>
#include<map>
#include<iostream>
using namespace std;
char s[1100],t[1100];
int  main()
{
	scanf("%s",s+1);
	int n=strlen(s+1),i;
	for(i=1;i<=n;i++){
		if(s[i]!=s[n+1-i])
		break;
	}
	if(i<=n){
		printf("No\n");
		return 0;
	}
	for(i=1;i<=n/2;i++){
		if(s[i]!=s[n/2+1-i])
		break;
	}
	if(i<=n/2)
	{
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int n, q;
vector<int> edge[300004];
long long x[300004];

void dfs(int here, int parent){
	x[here] += x[parent];
	for(int there : edge[here])
		if(there != parent)
			dfs(there, here);
}
 
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin>>n>>q;
	for(int i = 0;i<n-1;i++){
		int a, b;
		cin>>a>>b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	memset(x, 0, sizeof(x));
	for(int i = 0;i<q;i++){
		int p, a;
		cin>>p>>a;
		x[p] += a;
	}
	dfs(1, 0);
	for(int i = 1;i<=n;i++)	cout<<x[i]<<' ';
	return 0;
}

Measured memory_bytes: 27392
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
	// your code goes here
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	
	ll n;
	cin>>n;
	ll x = 0;
	ll temp[n];
	
	for(ll i=0;i<n;i++){
	    cin>>temp[i];
	    x = x^temp[i];
	}
	
	for(ll i=0;i<n;i++){
	    cout<<(temp[i]^x)<<" ";
	}
	cout<<"\n";
	
	return 0;
}

Measured memory_bytes: 5100
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
#include <bitset>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int gcd(int a, int b) {
    if(a % b == 0) {
        return b;
    }
    else {
        return(gcd(b, a % b));
    }
}


int main() {
    int h, w, k;
    int ans = 0, ab = 0;
    cin >> h >> w >> k;
    vector<vector<char>> c(h, vector<char> (w));
    rep(i, h) {
        rep(j, w) {
            cin >> c.at(i).at(j);
            if (c.at(i).at(j) == '#') ab++;
        }
    }
    for (int i = 0; i < (1 << h); i++) {
        bitset<6> hb(i);
        for (int j = 0; j < (1 << w); j++) {
            int sum = 0;
            bitset<6> wb(j);
            for (int l = 0; l < h; l++) {
                for (int m = 0; m < w; m++) {
                    if (hb.test(l) | wb.test(m)) {
                        if (c.at(l).at(m) == '#') sum++;
                    }
                }
            }
            if (ab - sum == k) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
# -*- coding: utf-8 -*-

a, b = map(str, input().split())

if a == 'H' and b == 'H':
    print('H')
elif a == 'D' and b == 'H':
    print('D')
elif a == 'H' and b == 'D':
    print('D')
else:
    print('H')

Measured memory_bytes: 8944
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef vector<xy_t> polygon;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 29;
const double EPS = 1e-10;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
#define repD(i, n) for(int i = n; i >= 0; i--)

bool fail[1000];
int nxt[1000];

bool check(string s, int n){
	if(n % 3 == 0 && n % 5 == 0) return s == "FizzBuzz";
	if(n % 3 == 0) return s == "Fizz";
	if(n % 5 == 0) return s == "Buzz";
	int num = 0;
	int sz = s.size();
	rep(i, sz){
		if(!isdigit(s[i])) return false;
		num = num * 10 + s[i] - '0';
		if(num > n) return false;
	}
	return num == n;
}

int main(){
	int m, n;
	int rest;
	string s;
	while(cin >> m >> n && (m || n)){
		getline(cin, s);
		memset(fail, false, sizeof(fail));
		rep(i, m){
			nxt[i] = (i+1)%m;
		}
		int pos = m-1;
		rest = m;
		rep(i, n){
			getline(cin, s);
			
			if(rest == 1 ) continue;
			if(!check(s, i+1)){
				int tmp = nxt[pos];
				nxt[pos] = nxt[tmp];
				fail[tmp] = true;
				rest--;
			}else{
				pos = nxt[pos];
			}
		}
		
		vector<int> res;
		rep(i, m) if(!fail[i]) res.push_back(i+1);
		rep(i, (int)res.size()){
			if(i != 0) cout << " ";
			cout << res[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
def main(X, Y, D):
    length = X**2 + Y**2
    if length <= D**2:
        return 1
    else:
        return 0

if __name__ == '__main__':
    N, D = map(int, input().split())
    ans = 0
    for _ in range(N):
        X, Y = map(int, input().split())
        ans += main(X, Y, D)
    print(ans)



Measured memory_bytes: 9140