akhauriyash/Code-Regression huggingface dataset:
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>

using namespace boost::multiprecision;
*/

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define debug(aa, a) fprintf(stderr, aa, a)

using ll =long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	string s = to_string(n);
	int p = 0;
	for (auto aa : s)p += aa - '0';
	printyn(n % p == 0);

	Please AC;
}


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

int main(){
  ll n;
  cin >> n;
  ll c = n;
  map<ll,ll> m;
  for(ll i = 2; i*i <= n; i++) {
    while(c % i == 0) {
      m[i]++;
      c /= i;
    }
  }
  if(c > 1) m[c]++;
  ll num[MAX] = {};
  for(int i = 1; i < MAX; i++) {
    num[i] += i + num[i-1];
  }
  ll ans = 0;
  for(auto x : m) {
    ll b = upper_bound(num,num+MAX,x.second) - num;
    b--;
    ans += b;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	int a,b,n,T,cas=0;
	cin>>n;
	int s=0;
	for(int i=0;i<n;++i) {
		cin>>a;
		while(a%2==0) {
			s++;
			a/=2;
		}
	}
	cout<<s<<endl;
	return 0;
}

//J

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  int n,i;
  cin>>n;
  for( i=1;i<=9;i++){
    if(n%i==0 && n/i <=9){
      cout<<"Yes";
      break;
    }
  }
  if(i==10)cout<<"No";
  return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main()
{
    int n, a[100+1], i, j, min, max;

    scanf( "%d", &n );
    for( i =  1; i < n+1; i++ )
    {
        scanf( "%d", &a[i] );
    }

    //最大と最小を見つけて差を出す
    min = a[1];
    max = a[1];
    for( j = 1; j < n+1; j++ )
    {
        if( a[j] > max ) max = a[j];
        else if( a[j] < min ) min = a[j];
    }
    printf("%d\n", max - min);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>

typedef long long LL;
typedef unsigned long long ULL;
//typedef pair<int,int> PII;
//typedef vector<int> VI;

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define FILL(A,value) memset(A,value,sizeof(A))
#define f first
#define s second

using namespace std;

int cnt(int n){
    int kol = 0;
    for(int i = 1;i * i <= n;i++){
        if (n % i == 0){
            if (n / i != i){
                kol += 2;
            }
            else{
                kol++;
            }
        }
    }
    return kol;
}

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

    int ans = 0;
    for(int i = 1;i <= n;i++){
        ans += cnt(i) == 8 && i % 2;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'
 
int solve(vi &a, int l, int r) {
    if (l + 1 == r) {
        if (a[l] == 1) return 1;
        else return 0;
    }
    int m = (l + r) / 2;
    int res = solve(a, l, m) + solve(a, m, r);

    vi a1, a2;
    int sum = 0;
    for (int i = m - 1; i >= l; i--) {
        sum += a[i];
        a1.push_back(sum);
    }
    sum = 0;
    for (int i = m; i < r; i++) {
        sum += a[i];
        a2.push_back(sum);
    }
    sort(all(a2));
    
    rep (i, a1.size()) {
        int x = a1[i];
        auto itr = lower_bound(all(a2), 1 - x);
        res += a2.end() - itr;
    }
    return res;
}


signed main() {
    fio();
    ll n;
    cin >> n;
    vl a(n);
    rep (i, n) cin >> a[i];

    int ok = inf, ng = 0;
    ll zen = n * (n + 1) / 2;
    while (ng + 1 < ok) {
        int mid = (ng + ok) / 2;
        vi b(n);
        rep (i, n) {
            if (a[i] <= mid) b[i] = 1;
            else b[i] = -1;
        }
        int res = solve(b, 0, n);
        if (res - (zen - res) >= 1) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}

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

int main()
{
    
    string sa,sb,sc;
    cin >> sa >> sb >> sc;
    int a = 1;
    int b = 0;
    int c = 0;
    int turn = 0;
    while(a <= sa.size() && b <= sb.size() && c <= sc.size()){
        if(turn == 0){
            switch(sa[a-1]){
                case 'a':
                    turn = 0;
                    a++;
                    break;
                case 'b':
                    turn = 1;
                    b++;
                    break;
                case 'c':
                    turn = 2;
                    c++;
                    break;
            }
        }
        else if(turn == 1){
            switch(sb[b-1]){
                case 'a':
                    turn = 0;
                    a++;
                    break;
                case 'b':
                    turn = 1;
                    b++;
                    break;
                case 'c':
                    turn = 2;
                    c++;
                    break;
            }
        }
        else{
            switch(sc[c-1]){
                case 'a':
                    turn = 0;
                    a++;
                    break;
                case 'b':
                    turn = 1;
                    b++;
                    break;
                case 'c':
                    turn = 2;
                    c++;
                    break;
            }
        }
    }

    if(a > sa.size()){
        cout << 'A' << endl;
    }
    else if(b > sb.size()){
        cout << 'B' << endl;
    }
    else{
        cout << 'C' << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int D;
    cin >> D;
    vector<int> c(26);
    REP (i, 26) {
        cin >> c[i];
    }
    vector<vector<int> > s(D, vector<int>((26)));
    REP (i, D) {
        REP (j, 26) {
            cin >> s[i][j];
        }
    }

    vector<int> t(D);
    REP(i,D) {
        cin >> t[i];
        t[i]--;
    }

    int M;
    cin >> M;
    vector<int> d(M), q(M);
    REP(k,M) {
        ans = 0;
        cin >> d[k] >> q[k];
        d[k]--;
        q[k]--;
        t[d[k]] = q[k];
        vector<int> last(26,0);

        REP(i,D) {
            last[t[i]] = i+1;
            ans += s[i][t[i]];
            REP(j,26) {
                ans -= c[j] * (i+1 - last[j]);
            }
        }
        cout << ans << endl;
    }



    


    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/intro-heuristics/intro_heuristics_c && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/intro-heuristics/intro_heuristics_c && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/intro-heuristics/intro_heuristics_c && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 4744
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F0(i,n) for (int i = 0; i < n; i++)
#define F1(i,n) for (int i = 1; i <= n; i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define SZ(x) ((int)x.size())
const double eps = 1e-10;
const int inf = 1000000009;
int i, j, k, m, n, l;
int ans;

ll solve(ll a, ll b) {
	if (a < b) return solve(b, a);
	ll x = a / b;
	if (a % b == 0) return (2 * x - 1) * b;
	ll ret = 2 * x * b;
	return ret + solve(b, a - x * b);
}

int main() {
	//freopen("x.in", "r", stdin);

	ll N, X;
	cin >> N >> X;

	cout << solve(N - X, X) + N << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
using namespace std;
int n,a[105];
int main(){
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	cout<<a[n-1]-a[0];
	return 0;
}

Measured memory_bytes: 256
n = int(input())
robot = []
for _ in range(n):
    x, l = map(int, input().split())
    robot.append([x - l, x + l])

# startが被らないendが小さいもの

ans = 0
robot.sort(key=lambda x: x[1])
last = - float('inf')
for start, end in robot:
    if start >= last:
        ans += 1
        last = end

print(ans)


Measured memory_bytes: 21336
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int h=sc.nextInt();
        int w=sc.nextInt();
        int a=sc.nextInt();
        int b=sc.nextInt();
        boolean[][] ans=new boolean[h][w];
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(b>i&&a>j||b<=i&&a<=j){
                    System.out.print(1);
                }else{
                    System.out.print(0);
                }
            }
            System.out.println();
        }
    }


}



Measured memory_bytes: 47020
fun main(args: Array<String>) {
    val n = readInputLine().toInt()
    
    // parent -> (child, distance)
    val edges = mutableMapOf<Int, MutableList<Pair<Int, Int>>>()
    val visited = BooleanArray(n)
    val distances = IntArray(n)
    
    for (i in 1..n - 1) {
        val (u, v, w) = readInputLine().split(" ").map { it.toInt() }
        val edge1 = edges.get(u) ?: mutableListOf<Pair<Int, Int>>()
        val edge2 = edges.get(v) ?: mutableListOf<Pair<Int, Int>>()
        
        edge1.add(Pair(v, w))
        edge2.add(Pair(u, w))
        
        edges.put(u, edge1)
        edges.put(v, edge2)
    }

    search(1, edges, visited, distances)

    for (d in distances) {
        if (d % 2 == 0) {
            println(0)
        } else {
            println(1)
        }
    }
}

fun readInputLine(): String {
    return readLine()!!
}

fun search(parent: Int, edges: MutableMap<Int, MutableList<Pair<Int, Int>>>, visited: BooleanArray, distances: IntArray) {
    visited[parent - 1] = true
    if (!edges.containsKey(parent)) {
        return
    }
    for (e in edges.get(parent)!!) {
        if (visited[e.first - 1]) {
            continue
        }
        visited[e.first - 1] = true
        distances[e.first - 1] = distances[parent - 1] + e.second
        search(e.first, edges, visited, distances)
    }
}


Measured memory_bytes: 123676
def func(n,x):
    if n%x!=0:
        return n+(x-n%x)
    else:
        return n
X=[]
n=int(input())
for i in range(n):
    t,a=map(int,input().split())
    X.append([t,a])

T=X[0][0]
A=X[0][1]

for i in range(1,n):
    if T<=X[i][0] and A<=X[i][1]:
        T=X[i][0]
        A=X[i][1]
    elif T>X[i][0] and A<=X[i][1]:
        T=func(T,X[i][0])
        A=T*X[i][1]//X[i][0]
    elif T<=X[i][0] and A>X[i][0]:
        A=func(A,X[i][1])
        T=A*X[i][0]//X[i][1]
    else:
        T=func(T,X[i][0])
        A=func(A,X[i][1])
        if T>A*X[i][0]//X[i][1]:
            A=T*X[i][1]//X[i][0]
        else:
            T=A*X[i][0]//X[i][1]
print(T+A)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(void)
{
	int N, K;
	cin >> N >> K;

	vector<int> A(N + 1, 0);
	int sum = 0;
	for (int loop = 0; loop < N; ++loop) {
		int x;
		cin >> x;
		A[x] += 1;
	}
/*
	sort(A.begin(), A.end());

	vector<int> kind(N + 1, 0);
	int count = 0;
	for (int loop = 1; loop < N + 1; ++loop) {
		count = 0;
		for (int loop1 = 0; loop1 < N + 1; ++loop1) {
			if (loop == A[loop1]) {
				++count;
				kind[loop] = count;
			}
		}
	}
*/	
/*
	cout << "要素種類" << endl;
	for (int loop1 = 1; loop1 < N + 1; ++loop1) {
      cout << loop1 << " : " <<A[loop1] << endl;
    }
*/
	//配列から0を削除
    A.erase(std::remove(A.begin(), A.end(), 0), A.end());

	sort(A.begin(), A.end());
/*
	cout << "要素種類2" << endl;
	for (int loop1 = 0; loop1 < A.size(); ++loop1) {
      cout << loop1 << " : " <<A[loop1] << endl;
    }
*/
 	if (A.size() <= K) {
		cout << 0 << endl;
	} else {
		int delcount = 0;
		for (int loop = 0; loop < A.size(); ++loop) {
			if (loop < (A.size() - K)) {
				delcount += A[loop];
			}
		}
		cout << delcount << endl;
	}

	return 0;
}


Measured memory_bytes: 3680
#C
from itertools import permutations
N=int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))
num=[i for i in range(1,N+1)]
L=permutations(num,N)
L=sorted(L)

for i in range(len(L)):
    if L[i]==P:
        a=i
    if L[i]==Q:
        b=i

print(abs(a-b))

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

int main(){
	int c[3];
	int a,b;
	while(cin>>a>>b,a!=0&&b!=0){
		for(int i=0;i<3;i++)c[i]=0;
		b-=a;
		while(1000<=b){b-=1000;c[2]++;}
		while(500<=b){b-=500;c[1]++;}
		while(0<b){b-=100;c[0]++;}
		
		for(int i=0;i<2;i++)cout<<c[i]<<" ";
		cout<<c[2]<<endl;
	}


}

Measured memory_bytes: 1160
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        ks: [isize; 2]
    }
    println!("{}", solve(ks[0], ks[1]));
}

fn solve(k:isize, s:isize) -> isize {
    let mut answer = 0;
    for x in 0..k+1 {
        for y in 0..k+1 {
            let z = s - x - y;
            if z >= 0 && z <= k {
                answer += 1;
            }
        }
    }
    answer
}

#[test]
fn solve_test() {
    assert_eq!(solve(2,2), 6);
    assert_eq!(solve(5,15), 1);
    assert_eq!(solve(2500, 7500), 1);
    assert_eq!(solve(2499, 7500), 0);
    assert_eq!(solve(2500, 2), 6);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	vector<pair<int, int>> v;
	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		
		bool f = true;
		for (int j = 0; j < v.size(); j++) {
			int m = v.at(j).first;
			if (m == n) {
				v.at(j).second++;
				f = false;
				break;
			}
		}

		if (f) {
			pair<int, int> p = { n,1 };
			v.push_back(p);
		}
	}

	int ans = 0;
	for (int i = 0; i < v.size(); i++) {
		int a, b;
		a = v.at(i).first;
		b = v.at(i).second;

		if (b > a) ans += b - a;
		else if (b < a) ans += b;
	}

	cout << ans << endl;
}

Measured memory_bytes: 4304
#define P(x) cout << #x" = " << x << endl
#define PP(x, y) cout << "("#x", "#y") = (" << x << ", " << y << ")" << endl
#define PPP(x, y, z) cout << "("#x", "#y", "#z") = (" << x << ", " << y << ", " << z << ")" << endl

#include <iostream>
#include <vector>
#include <map>
using namespace std;
int s;
map<int, int> mp;
int main(){
    cin >> s;
    int a = s;
    int i = 1;
    while(true) {
        if (mp.find(a) != mp.end()) {
            cout << i << endl;
            break;
        }
        mp[a] = i;
        a = a % 2 == 0 ? a / 2 : 3 * a + 1;
        i++;
    }
}

Measured memory_bytes: 888
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    n = kwargs["n"]
    res = [0 for i in range(n)]

    for x in range(1, 100):
        for y in range(1, 100):
            for z in range(1, 100):
                tmp = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
                if tmp <= n:
                    res[tmp - 1] += 1

    res = "\n".join([str(r) for r in res])
    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    kwargs["n"] = [int(i) for i in cin][0]

    cout = main(kwargs)
    print(cout)

Measured memory_bytes: 30980
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,w;
  while(cin>>n>>w,n){
    double sum=0;
    int a[50]={},p1=0,p2=0,v;
    for(int i=0;i<n;i++){
      cin>>v;
      int p=v/w;
      a[p]++;
      p1=max(p1,p);
      p2=max(p2,a[p]);
    }
    for(int i=0;i<=p1;i++)
      sum+=((double)a[i]/p2)*((double)(p1-i)/p1);
    cout<<sum+0.01<<endl;
  }
}

Measured memory_bytes: 3236
#include <iostream>

using namespace std;

int main() {
  int first_N, second_N,total_N;
  string answer_W;

  cin >> first_N >> second_N;
  total_N = first_N * second_N;
  if(total_N % 2 == 0){
    answer_W = "Even";
  }
  else{
    answer_W = "Odd";
  }
  cout << answer_W  << endl;
  return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
h = []
ans = 10**10
for i in range(N):
  tmp = int(input())
  h.append(tmp)
h = sorted(h)
for i in range(N-K+1):
  h2 = h[i]
  h3 = h[i+K-1]
  ans = min(h3 - h2,ans)
print(str(ans))

Measured memory_bytes: 14036
#include <stdio.h>

int N;
int A[32];
int B[32];
int C[32];

int main(void) {
	int i;
	int kugyu = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 1; i <= N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	for (i = 1; i <= N; i++) {
		if (scanf("%d", &B[i]) != 1) return 1;
	}
	for (i = 1; i <= N - 1; i++) {
		if (scanf("%d", &C[i]) != 1) return 1;
	}
	kugyu += B[A[1]];
	for (i = 2; i <= N; i++) {
		kugyu += B[A[i]];
		if (A[i] == A[i - 1] + 1) kugyu += C[A[i - 1]];
	}
	printf("%d\n", kugyu);
	return 0;
}


Measured memory_bytes: 128
use proconio::input;

#[proconio::fastout]
fn main() {
    input! {
        H: i128,
        W: usize,
        K: usize
    }
    if W == 1 {
        println!("1");
        return;
    }
    const MOD: i128 = 1_000_000_007;

    let mut positions = vec![0i128; W];
    positions[0] = 1;
    for _y in 0..H {
        let mut row = vec![0i128; W];
        for x in 0usize..(1 << (W - 1)) {
            // 同じ端点を共有してはならない
            if x & (x << 1) != 0 { continue; }

            // iビット目が立っているとき、i番目の橋が存在する
            // ここでi番目の橋とは、i番目の線から右に伸びるもの

            for i in 0..W {
                // i番目の橋があるなら
                if x & (1 << i) != 0 {
                    // 左から右へ
                    row[i + 1] += positions[i];
                    row[i + 1] %= MOD;
                    // 右から左へ
                    row[i] += positions[i + 1];
                    row[i] %= MOD;
                } else if i == 0 || x & (1 << (i - 1)) == 0 {
                    // そのまま下へ
                    row[i] += positions[i];
                    row[i] %= MOD;
                }
            }
        }
        positions = row;
    }
    println!("{}", positions[K - 1]);
}


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

#define ff first
#define ss second
#define all(abcc) (abcc).begin(), (abcc).end()
#define endl '\n'
#define left aba
#define right abc

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N=(int)(1e5)+2;

int n, k;

int h[N], dp[N];

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

    cin>>n>>k;
    for(int i=0; i<n; ++i) {
        cin>>h[i];
        dp[i]=INT_MAX;
    }

    dp[0]=0;
    for(int i=1; i<n; ++i) {
        for(int j=1; j<=k; ++j) {
            if(i-j<0) break;
            dp[i]=min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
        }
    }

    cout<<dp[n-1]<<endl;

    //cerr<<"Time: "<<(double)clock()/CLOCKS_PER_SEC<<"s"<<'\n';
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cat X;
	cin >> N >> X;
	vector<cat> A(N);
	for(int i = 0; i < N; i++) cin >> A[i];
	sort(begin(A), end(A));
	int ans = 0;
	for(int i = 0; i < N; i++) if(X >= A[i]) {
		X -= A[i];
		ans++;
	}
	if(ans == N && X != 0) ans--;
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 892
#include<stdio.h>
#include<stdlib.h>
int cmp(const void*a,const void*b){
	return *(int*)a-*(int*)b;
}
int main(int argc, char const *argv[]){
	int n,a[100],i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	qsort(a,n,sizeof(int),cmp);
	printf("%d\n",a[n-1]-a[0]);
	return 0;
}

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

macro_rules! tern {
    ($condition: expr, $_true: expr, $_false: expr) => {
        if $condition {
            $_true
        } else {
            $_false
        }
    };
}

fn main() {
    let N = get!(usize);
    let mut vs = get!(usize | );
    vs.sort();
    let mut mean = vs[0] as f64;
    for &v in vs.iter().skip(1) {
        mean = (mean + v as f64) as f64 / 2f64; 
    }
    println!("{}", mean);
}


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


int main()
{
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int ans = 0;
  if (n == 1)
  {
    puts("0");
    return 0;
  }
  rep(i, n)
    if (s[i] == 'R' && i != n - 1 && s[i+1] == 'R')
      ans++;
    else if (s[i] == 'L' && i != 0 && s[i-1] == 'L')
      ans++;
  ans += k * 2;
  cout << min(ans, n - 1) << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,K; cin>>N>>K;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  vii dp(N,vi(K+1)),cp(N,vi(K+2));
  REP(i,1,K+1){
    cp[0][i]=cp[0][i-1];
    if(A[0]>=i-1){
      dp[0][i-1]++;
      cp[0][i]+=dp[0][i-1];
    }
  }
  rep(i,1,N){
    REP(j,0,K){
      dp[i][j]=(cp[i-1][j+1]+MOD-cp[i-1][max(0ll,j-A[i])])%MOD;
      cp[i][j+1]=(cp[i][j]+dp[i][j])%MOD;
    }
  }
  cout<<dp[N-1][K]<<endl;
  }



Measured memory_bytes: 157552
N = list(input())
x = N[-1]
if x == '2' or x =='4' or x =='5' or x =='7' or x =='9':
    print('hon')
elif N[-1] == '0' or x =='1' or x =='6' or x =='8':
    print('pon')
elif N[-1] == '3':
    print('bon')

Measured memory_bytes: 61624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int dp[10][10];
    for(int i = 0; i < 10; i++)
        for(int j = 0; j < 10; j++)dp[i][j] = 0;                                 
    for(int i = 1; i <= n; i++)
    {
        int ld = i%10;//尾数
        int lg = log10(i);
        int fd = i/pow(10,lg);//首位
        dp[fd][ld]+=1;
    }
    long long ans = 0;
    for(int i = 1; i < 10; i++)
    {
        for(int j = 1; j < 10; j++)
        {
            ans+=(dp[i][j]*dp[j][i]);
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 384
import java.io.*;
import java.io.ObjectInputStream.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	//final static long MOD = 998244353;

	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solutionA(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solutionA(String[] args) throws Exception{
		int H = nextInt();
		int W = nextInt();

		int[][] c = new int[10][10];
		for(int i=0;i<10;i++) {
			c[i]=nextInts();
		}
		int[][] A = new int[H][];
		for(int i=0;i<H;i++) {
			A[i]=nextInts();
		}


		for(int k=0;k<10;k++) {
			for(int from=0;from<10;from++) {
				for(int to=0;to<10;to++) {
					c[from][to]=Math.min(c[from][to],c[from][k]+c[k][to]);
				}
			}
		}



		long ans = 0;
		for(int h=0;h<H;h++) {
			for(int w=0;w<W;w++) {
				if(A[h][w]!=-1) {
					ans+=c[A[h][w]][1];
				}
			}
		}
		pw.println(ans);
	}


	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}



Measured memory_bytes: 24404
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

int main() {
  ll N,A,B,C,D,E;
  cin >> N >> A >> B >> C >> D >> E;
  
  ll m = min({A,B,C,D,E});
  cout << (N+m-1)/m + 4 << endl;
}

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

DP = [[0] * 10 for _ in range(10)]
D = [0] * 10
L = [0] * 1000
for i in range(N):
  for j in range(10):
    for k in range(10):
      if DP[j][k] == 1:
        L[j * 100 + k * 10 + int(S[i])] = 1
  for j in range(10):
    if D[j] == 1:
      DP[j][int(S[i])] = 1
  D[int(S[i])] = 1

print(sum(L))

Measured memory_bytes: 73932
#include <bits/stdc++.h>
using namespace std;
int a[100009],b[100009];
int main() {
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        b[i]=1000000009;
    }
    b[1]=0;
    for(int i=2;i<=n;i++){
        for(int j=1;j<=k && i-j>0;j++){
            b[i]=min(b[i-j]+abs(a[i]-a[i-j]), b[i]);
        }
    }
    cout<<b[n]<<endl;
}


Measured memory_bytes: 1024
N, M = gets.split.map(&:to_i)

readlines.map.with_index(1){|l, i| [i, *l.split.map(&:to_i)]}.sort_by{|i, p, y| y}
  .group_by{|i, p, y| p}.values.flat_map{|a| a.map.with_index(1){|(i, p, y), j| [i, p, j]}}.sort
  .each{|i, p, j| printf "%06d%06d\n", p, j}

Measured memory_bytes: 41148
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll, ll> P;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N;
    cin >> N;
    vector<vector<pair<ll, ll>>> comment(N);
    Rep (i, N) {
        ll A;
        cin >> A;
        Rep (j, A) {
            ll x, y;
            cin >> x >> y;
            x--;
            comment[i].push_back(P{x, y});
        }
    }

    ll ans = 0;
    Rep (i, 1<<N) {
        bool check = true;
        Rep (j, N) {
            if (i & (1 << j)) {
                for (auto e : comment[j]) {
                    if ((i & (1 << e.first)) != (e.second << e.first)) {
                        check = false;
                    }
                }
            }
        }
        if (check) {
            ll tmp = 0;
            Rep (j, N) {
                if (i & 1 << j) tmp++;
            }
            chmax(ans, tmp);
        }
    }

    cout << ans << "\n";
}

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

int main(){
  int h, w;
  while(true){
    cin >> h >> w;
    if(h==0&&w==0){
      break;
    }
    rep(i, h){
      rep(j, w){
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
 

  return 0;
}


Measured memory_bytes: 3124
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
int main()
{
	int n=read(),k=read();
	ll ans=0;
	for (int b=k+1;b<=n;b++)
	{
		int t=(n+1)/b;
		ans+=t*(b-k)+max(n-t*b+1-k,0);
	}
	if (k==0) ans-=n;
	printf("%lld\n",ans);
	return 0;
}


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

int main(){
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
    
    long long n;
    cin >> n;
    long long res1 = n/500;
    long long res2 = (n-(500*res1)) / 5;
    cout << ((500*(res1*2))) + res2*5;
}

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

struct STUDENT {
    int x;
    int y;
};
struct CHECKPOINT {
    int x;
    int y;
};

int main() {
    int stunum, chenum;
    cin >> stunum >> chenum;
    vector<STUDENT> students;
    vector<CHECKPOINT> checkpoints;
    FOR(i, stunum) {
        int temp1, temp2;
        cin >> temp1 >> temp2;
        STUDENT s;
        s.x = temp1, s.y = temp2;
        students.push_back(s);
    }
    FOR(i, chenum) {
        int temp1, temp2;
        cin >> temp1 >> temp2;
        CHECKPOINT c;
        c.x = temp1, c.y = temp2;
        checkpoints.push_back(c);
    }

    vector<int> ans;
    FOR(i, stunum){
        int thisans = 0;
        int nearest = abs(students[i].x - checkpoints[0].x) + abs(students[i].y - checkpoints[0].y);
        for(int j = 1; j < chenum; j++) {
            if(nearest > abs(students[i].x - checkpoints[j].x) + abs(students[i].y - checkpoints[j].y)) {
                nearest = abs(students[i].x - checkpoints[j].x) + abs(students[i].y - checkpoints[j].y);
                thisans = j;
            }
        }
        ans.push_back(thisans);
    }
    FOR(i, stunum) cout << ans[i] + 1 << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k/*saidaiti*/,s/*goukei*/,c=0;
	cin>>k>>s;
	for(int i=0;i<=k;i++){
		for(int j=0;j<=k;j++){
			if(i+j<=s&&s-i-j<=k)c++;	
		}
	}
	cout<<c<<endl;
	return 0;
}


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

void merge_sort (int array[], int left, int right) {
  int i, j, k, mid;
  int work[right+1];  // 作業用配列
  if (left < right) {
    mid = (left + right)/2; // 真ん中
    merge_sort(array, left, mid);  // 左を整列
    merge_sort(array, mid+1, right);  // 右を整列
    for (i = mid; i >= left; i--) { work[i] = array[i]; } // 左半分
    for (j = mid+1; j <= right; j++) {
      work[right-(j-(mid+1))] = array[j]; // 右半分を逆順
    }
    i = left; j = right;
    for (k = left; k <= right; k++) {
      if (work[i] < work[j]) { array[k] = work[i++]; }
      else                   { array[k] = work[j--]; }
    }
  }
}

int main(void){
  int n;
  scanf("%d", &n);
  int m[n];
  int i;
  for(i=0;i<n;i++){
    scanf("%d", &m[i]);
  }
  int count = 0;
  merge_sort(m,0,n-1);
  printf("%d", m[n/2]-m[n/2-1]);
}

Measured memory_bytes: 7040
N, X, Y = map(int, input().split())
X -= 1
Y -= 1

ans = [0] * (N - 1)

for i in range(N - 1):
    for j in range(i + 1, N):
        d1 = abs(j - i)
        d2 = abs(X - i) + 1 + abs(j - Y)
        ans[min(d1, d2) - 1] += 1

[print(ans[i]) for i in range(N - 1)]



Measured memory_bytes: 46044
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = (ll)1e9;
const ll MOD = 1000000007;
long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
} /*
 long long combination(long n, long r, long long mod) {
   // nCrを返す　O(r)
   // 逆元はその場で対応
   if (n < r) return 0;
   //if (n < r) swap(n, r);
   long long bunbo = 1;
   long cnt = r;
   while (0 < cnt) {
     bunbo *= cnt;
     bunbo % mod;
     cnt--;
   }
   if (bunbo == 0) return 1;
   long long bunsi = 1;
   cnt = 0;
   while (cnt < r) {
     bunsi *= (n - cnt);
     bunsi %= mod;
     cnt++;
   }
   return (((bunsi % mod) * modinv(bunbo, mod))) % mod;
 }*/
int memo[2010][2010];
ll comb(int n, int r, int mod) {
  if (n < 0 || r < 0 || n < r) {
    return 0;
  }
  if (memo[n][r] != 0) return memo[n][r];
  if (r == 0 || n == r || n == 0) {
    return memo[n][r] = 1;
  }
  int k = comb(n - 1, r - 1, mod) % mod;
  int l = comb(n - 1, r, mod) % mod;
  memo[n - 1][r - 1] = k, memo[n - 1][r] = l;
  return memo[n][r] = (k + l) % mod;
}
long long longpow(long long n, long long a, long long mod) {
  if (a == 0) return 1;
  if (a == 1) return n % mod;
  if (a % 2 == 1) return (n * longpow(n, a - 1, mod)) % mod;
  ll t = longpow(n, a / 2, mod) % mod;
  return (t * t) % mod;
}
struct Combination {
  // Combnation(x)　xCxまでを生成
  // RetCombination(n,r) nCrを返す
  vector<vector<long long>> combination;
  Combination(int x) {
    combination.resize(x + 1);
    for (int i = 0; i < x + 1; i++) {
      combination[i].resize(x + 1);
    }
    combination[0][0] = 1;
    for (int i = 0; i < x; i++) {
      for (int j = 0; j <= i; j++) {
        combination[i + 1][j] += combination[i][j];
        combination[i + 1][j + 1] += combination[i][j];
        combination[i + 1][j] %= MOD, combination[i + 1][j + 1] %= MOD;
      }
    }
  }
  long long RetCombination(int n, int r) { return combination[n][r]; }
};
int main() {
  ll N, K;
  cin >> N >> K;
  Combination cm(N + 10);
  ll blue = K, red = N - K;
  REP(i, blue) {
    ll ans = comb(K - 1, i, MOD);
    // while (ans < 0) ans += MOD;
    ans *= comb(N - K + 1, i + 1, MOD);
    // while (ans < 0) ans += MOD;
    cout << ans % MOD << endl;
    if (ans % MOD == 20825) {
      int a = 19;
    }
  }
}

Measured memory_bytes: 49144
n,x=map(int,input().split())
if n==2and x==2:
    print('Yes',*[1,2,3],sep='\n')
    exit()
a=[[]for _ in range(2*n-1)]
a[n-1]=x
f=[0]*2*n
f[x]=1
try:
    if x>2*n-3:
        a[n-3]=x-2
        a[n-2]=x+1
        a[n]=x-1
        f[x-2]=f[x-1]=f[x+1]=1
    else:
        a[n-3]=x+2
        a[n-2]=x-1
        a[n]=x+1
        f[x-1]=f[x+1]=f[x+2]=1
    if f[0]:
        1/0
except:
    print('No')
    exit()
i=0
for j,v in enumerate(f[1:],1):
    if v:continue
    while a[i]:i+=1
    a[i]=j
print('Yes',*a,sep='\n')

Measured memory_bytes: 23572
using System;
using System.Collections.Generic;
using System.Linq;

namespace oasobi
{
    static class MainClass
    {
        public static void Main()
        {
            var X = int.Parse(Console.ReadLine());

            var u = 0;

            while(X>=500)
            {
                X -= 500;
                u += 1000;
            }

            while (X >= 5)
            {
                X -= 5;
                u += 5;
            }

            Console.WriteLine(u);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <ll, ll> P;

const ll MOD=1000000007;
ll dp[1010][20010];
ll W[1000], S[1000], V[1000];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin>>N;
    ll w[N], s[N], v[N];
    P p[N];
    rep(i,0,N){
        cin>>w[i]>>s[i]>>v[i];
        p[i]=P(s[i]+w[i],i);
    }
    sort(p,p+N);
    rep(i,0,N){
        W[i]=w[p[i].sc];
        S[i]=s[p[i].sc];
        V[i]=v[p[i].sc];
    }
    if(N==1){
        cout <<V[0]<<"\n";
        return 0;
    }
    rep(i,0,N){
        rep(j,0,20001){
            if(i==0){
                if(j>=W[i]) dp[i][j]=V[i];
                else dp[i][j]=0;
            }
            else{
                if(j==0) dp[i][j]=0;
                else{
                    dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
                    if(j-W[i]>=0&&j-W[i]<=S[i]){
                        dp[i][j]=max(dp[i][j],dp[i-1][j-W[i]]+V[i]);
                    }
                }
            }
        }
    }
    cout <<dp[N-1][20000]<<"\n";
}

Measured memory_bytes: 157952
n = int(input())
a = list(map(int, input().split()))
sumabs = 0
minuscnt = 0
zerocnt = 0
minabs = 10**9+1
for i in range(n):
  if a[i] < 0:
    minuscnt += 1
  elif a[i] == 0:
    zerocnt += 1
  sumabs += abs(a[i])
  minabs = min(minabs, abs(a[i]))
if zerocnt > 0 or minuscnt % 2 == 0:
  print(sumabs)
else:
  print(sumabs - minabs * 2)

Measured memory_bytes: 64752
#include<bits/stdc++.h>
using namespace std;
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);cout.tie(NULL);
        unsigned long long int n,k,i,score[200000];
        cin>>n>>k;
        i=0;
        while(i<n){
                cin>>score[i];
                if(i>=k){
                        
                        if(score[i]>score[i-k])
                       {
                        cout<<"Yes\n";}
                        else{
                                cout<<"No\n";
                        }
                }
                i++;
        }
return 0;
}
/*

        creation time:  15.09.2020 11:04:53

*/                      



Measured memory_bytes: 5184