akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
  ll N,K;  cin >> N >> K;
  vector<ll> S[N];
  for(ll i = 0; i < N; i++){
    ll t,d; cin >> t >> d; t--; S[t].push_back(d);}

 vector<ll> A; vector<ll> B;
  for(ll i = 0; i < N; i++){
    sort(S[i].rbegin(),S[i].rend());
    if( (ll)S[i].size()){
      for(ll j = 0; j < (ll) S[i].size(); j++){
        if(j == 0){A.push_back(S[i][j]);}
        else{ B.push_back( S[i][j]);} }
    }
  }

  
  
  sort(A.rbegin(),A.rend()); sort(B.rbegin(), B.rend());

  for(ll i = 1; i < (ll) A.size(); i++){
    A[i] += A[i-1];}
  for(ll j = 1; j < (ll) B.size(); j++){
    B[j] += B[j-1];} // accumulate
  
  ll ans = 0; 
  for(ll i = 1; i <= (ll) A.size(); i++){

    ll res = 0;
    if( i == K ){  res += A[K-1]; }
    else{
      if( K - (ll) B.size() <= i && i <= K - 1 && (ll) B.size() != 0 ){
        res += A[i-1] + B[K-i-1];}}
    if( res == 0){ continue;}
    res += i*i;    
    if( res > ans){ ans = max( ans , res); } }

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


Measured memory_bytes: 7032
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <numeric>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    auto operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class L, class R>
class Input<pair<L, R>> {
public:
    auto operator()() const {
        L l;
        R r;
        cin >> l >> r;
        return make_pair(l, r);
    }
};

template<class U>
class Input<vector<U>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    auto operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

class InputType
{
public:
    template<class T>
    operator T() const {
        Input<T> i{};
        return i();
    }
};

class InputType2
{
public:
    InputType2(size_t n)
        : n_(n)
    {}
    template<class T>
    operator T() const {
        Input<T> i{};
        return i(n_);
    }
private:
    size_t n_;
};

auto input() {
    return InputType();
}

auto input(size_t n) {
    return InputType2(n);
}

size_t bitcount(size_t n) {
    size_t c = 0;
    while (n) {
        if (n & 1ull)
            ++c;
        n >>= 1;
    }
    return c;
}

auto make_order(size_t n) {
    vector<size_t> a(n, 0);
    iota(begin(a), end(a), 0);
    return a;
}

template<class T>
auto next_permutation(T&& x) {
    using std::begin;
    using std::end;
    return next_permutation(begin(x), end(x));
}

using ll = long long;
using ull = unsigned long long;

int main() {
    size_t n = input();
    size_t m = input();
    size_t c = 0;
    if (n > 1)
        c += n * (n - 1) / 2;
    if (m > 1)
        c += m * (m - 1) / 2;
    cout << c << endl;
    return 0;
}


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

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    int R;
    cin >> R;
    if(R < 1200)cout << "ABC" << endl;
    else if(R < 2800)cout << "ARC" << endl;
    else cout << "AGC" << endl; 
}


Measured memory_bytes: 256
N=int(input().strip())
txy=[]
t1,x1,y1 = 0,0,0
flag=True
for i in range(N):
    t2,x2,y2 = map(int,input().split())
    dt=t2-t1
    dist=abs(x2-x1)+abs(y2-y1)
    if dist>dt or (dist-dt)%2!=0:
        flag=False
        break
print(["No", "Yes"][flag])

Measured memory_bytes: 3060
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;
using Graph = vector<vector<int>>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll k, s; cin >> k >> s;
  ll flag = 0;
  for(ll i = 0;i <= k;i++)
  {
    for(ll j = 0;j <= k;j++)
    {
      if(s - i - j >= 0&&s - i - j <= k) flag++;
    }
  }
  fin(flag);
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <iostream>
#include <climits>
#include <cstring>
#include <functional>
#include <iomanip>

using namespace std;

//using ll = long long;
#define rep(i, N) for(int i = 0;i < (int)N;i++)
#define LARGE INT_MAX / 2
#define PI 3.1415926535897932384626433832795


int a[3];
int main() {
	rep(i, 3) {
		cin >> a[i];
	}
	sort(a, a + 3);
	cout << a[2] * 10 + a[1] + a[0] << endl;
	return 0;
}

Measured memory_bytes: 256
_n, k = gets.split.map(&:to_i)
trees = readlines.map(&:to_i).sort
diffs = []
trees.each.with_index { |tree, i|
  unless trees[i+k-1].nil?
    diff = trees[i+k-1] - tree
    diffs << diff
    break if diff == 0
  end
}
puts diffs.min


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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
// ll mod_pow(ll x, ll n, ll mod){//x^n % mod
//     if (n == 0)
//         return 1;
//     ll res = mod_pow(x * x % mod, n / 2, mod);
//     if (n & 1)
//         res = res * x % mod;
//     return res;
// }
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    int res = 0;
    REP(i, N) {
        int tmp; cin >> tmp;
        if (tmp >= K) res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <stdbool.h>
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;

int main()
{
	long long int i, j, v, count = 1000000000000;
	long long int a = 0;
	
	cin >> v;

	for (i = 1;i*i <= v;i++)
	{
		
			if (v%i == 0)
			{
				a = 0;
				a += (v / i - 1 + i - 1);
				count = min(count, a);
			}


	}
	cout << count << endl;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

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

    int Rcnt = 0;
    rep(i,N){
        if(S[i] == 'R') Rcnt++;
    }

    int ans = 0;
    for(int i=Rcnt; i<N; i++){
        if(S[i] == 'R') ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3728
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
  int n, k; cin >> n >> k;
  int a[n];

  int index = 0;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    if(a[i] == 1) index = i;
  }
  
  double ans = 0;
  ans = ceil((n-1) / (k-1.));
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#-*- coding: utf-8 -*-
a,b,c,d = map(int,input().split())
i = 1
while True:
    if c <= 0:
        print("Yes")
        break
    elif a <= 0:
        print("No")
        break
    elif i % 2 != 0:
        c -= b
        i += 1
    else:
        a -= d
        i += 1


Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 1e9 + 7;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	vector<int> dp(2020);
	dp[0] = 1;
	for (int i = 0; i <= 2000; i++) {
		for (int j = 0; j + 3 <= i; j++) {
			dp[i] += dp[j];
			dp[i] %= MOD;
		}
	}
	int s;
	cin >> s;
	cout << dp[s] << "\n";
	return 0;
}

Measured memory_bytes: 3616
n = gets.to_i
d, x = gets.split.map(&:to_i)
a = n.times.map{gets.to_i}

eat = 0

a.each{|ai|
    0.upto(100).each{|i|
        if 1 + i * ai <= d
            eat += 1;
        end
    }
}

puts eat + x


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);
//const ll mod = 998244353;

ll lcm(ll a, ll b){
    return a / __gcd(a, b) * b;
}


int main(void)
{
    ll n, m, ans=1;
    cin >> n >> m;
    if(abs(n-m) > 1){
        puts("0");
        return 0;
    }
    rep(i,n){
        ans *= (n-i);
        ans %= mod;
    }
    rep(i,m){
        ans *= (m-i);
        ans %= mod;
    }
    if(n == m) ans *=2;
    cout << ans%mod << endl;
    return 0;
}


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

	string s1;
	cin >> s1;

	int n = s1.size();
	if(n == 1){
		cout << s1 << endl;
		return 0;
	} 

	long long total = 0;
	for (int i = 0; i < pow(2, n - 1); i++) //すべての＋のパターン
	{
		string s2 = s1;
		long long sum = 0;
		for (int j = 0; j < n - 1; j++) //各々のパターン ex.0+00 <= 12+345 1234+5
		{
			if (i & (1 << j)) { //+があったら
				int start = s1.size() - (j + 1); //4
				sum += stoll(s2.substr(start)); //5
				s2 = s2.substr(0, start);		 //1234
			}
			if (j == n - 2) sum += stoll(s2);
		}
		total += sum;
	}
	cout << total << endl;
}


Measured memory_bytes: 256
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll N = 2e3+3;
vvi adj(N,vi ());
ll n;

vi dikstra(ll s)
{
	vi d(n,inf);
	vi vis(n,0);
	d[s]=0;
	priority_queue< pii,vpii,greater<pii> > q;
	q.push(mp(0,s));
	while(!q.empty())
	{
		pii p = q.top();
		q.pop();
		if(vis[p.S]==1) continue;
		vis[p.S]=1;
		ll cur = p.S;
		rep(i,0,sz(adj[cur]))
		{
			ll ch = adj[cur][i];
			if(vis[ch]==1) continue;
			if(p.F+1<d[ch])
			{
				d[ch]=p.F+1;
				q.push(mp(d[ch],ch));
			}
		}
	}
	return d;
}

int solve()
{
	ll x,y;cin>>n>>x>>y;
	x--,y--;
	rep(i,0,n-1) adj[i].pb(i+1),adj[i+1].pb(i);
	adj[x].pb(y);
	adj[y].pb(x);


	vi ans(n);

	rep(i,0,n)
	{
		vi d = dikstra(i);
		rep(j,0,n) ans[d[j]]++;
	}

	rep(i,1,n) cout<<ans[i]/2<<"\n";


	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

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

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d; cin>>a>>b>>c>>d;
    int ans=0;
    rep(i,101){
        if (a<=i && i<b && c<=i && i<d) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> A(M);
  for (int i = 0; i < M; i++)
  {
    scanf("%lld", &A[i]);
  }
  ll sum = accumulate(A.begin(), A.end(), 0);
  if (N >= sum)
    cout << N - sum << endl;
  else
    cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
int a[24];
void roll1(){
  swap(a[15],a[14]);swap(a[18],a[20]);
  swap(a[27],a[0]);swap(a[1],a[28]);swap(a[2],a[29]);
}
void roll2(){
  swap(a[20],a[9]);swap(a[15],a[17]);
  swap(a[0],a[23]);swap(a[3],a[26]);swap(a[6],a[29]);
}
void roll3(){
  swap(a[9],a[11]);swap(a[17],a[12]);
  swap(a[6],a[21]);swap(a[7],a[22]);swap(a[8],a[23]);
}
void roll4(){
  swap(a[11],a[18]);swap(a[14],a[12]);
  swap(a[27],a[8]);swap(a[5],a[24]);swap(a[2],a[21]);
}
int check(){
  int p=0;
  for(int i=1;i<=8;i++)if(a[i]!=a[i-1])p++;
  for(int i=22;i<=29;i++)if(a[i]!=a[i-1])p++;
  if(a[20]!=a[19]||a[19]!=a[18])p++;
  if(a[9]!=a[10]||a[10]!=a[11])p++;
  if(a[12]!=a[13]||a[13]!=a[14])p++;
  if(a[15]!=a[16]||a[16]!=a[17])p++;
  //cout<<p<<endl;
  return p;
}
int dfs(int n){
  int p=1000000;
  if(n==9)return 1000; 
  if(check()==0)return n;
  roll1();p=min(dfs(n+1),p);roll1();
  roll2();p=min(dfs(n+1),p);roll2();
  roll3();p=min(dfs(n+1),p);roll3();
  roll4();p=min(dfs(n+1),p);roll4();
  return p;
}
int main(){
  int n;
  cin>>n;
  while(n--){
    for(int i=0;i<30;i++)
      cin>>a[i];
    cout<<dfs(0)<<endl;
  }
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    ll N, M, K; cin >> N >> M >> K;   
    vector<ll> A(N);
    vector<ll> B(M);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (ll i = 0; i < M; i++) {
        cin >> B[i];
    }

    ll cnt;
    ll ans;
    ll tmp;
    
    cnt = 0;
    tmp = 0;
    for (ll i = 0; i < N; i++) {
        if(tmp + A[i] > K){
            break;
        }
        tmp += A[i];
        cnt++;
    }

    ll ind = cnt - 1; //Aの最後のindex
    ll inb = 0; //Bの最後のindex + 1
    for (; inb < M; inb++) {
        if(tmp + B[inb] > K){
            break;
        }
        tmp += B[inb];
        cnt++;
    }
    ans = cnt;
    for (; ind >= 0; ind--) {
        cnt--;
        tmp -= A[ind];
        for (; inb < M; inb++) {
            if(tmp + B[inb] > K){
                break;
            }
            tmp += B[inb];
            cnt++;
        }
        ans = max(ans, cnt);
    }

    printf("%lld\n", ans);

}

Measured memory_bytes: 6316
n,k = map(int,input().split())
a = list(map(int,input().split()))
f = list(map(int,input().split()))

a.sort()
f.sort(reverse=True)

r = 10**12
l = -1

def test(x):
    point = 0
    for i in range(n):
        point += max(0,a[i]-x//f[i])
    return point <= k

def nibutan(low,hi):
    while True:
        ave = (low+hi)//2
        if test(ave):
            hi = ave
        else:
            low = ave
        if hi-low == 1:
            break
    return hi

print(nibutan(l,r))

Measured memory_bytes: 119500
#include <iostream>
#include <string>
#include <sstream>
#include <climits>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif

    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int a = x2 - x1;
    int b = y2 - y1;
    cout << x2 - b << " " << y2 + a << " " << x1 - b << " " << y1 + a << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <stdio.h>

int main(void) {
	int n, m, l;
	int a[101][101] = { 0 };
	int b[101][101] = { 0 };
	long c[101][101] = { 0 };
	int i, j, k;

	scanf("%d %d %d", &n, &m, &l);

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	for (j = 0; j < m; j++) {
		for (k = 0; k < l; k++) {
			scanf("%d", &b[j][k]);
		}
	}

	for (i = 0; i < n; i++) {
		for (k = 0; k < l; k++) {
			for (j = 0; j < m; j++) {
				c[i][k] += (long)a[i][j] * (long)b[j][k];
			}
		}
	}

	for (i = 0; i < n; i++) {
		for (k = 0; k < l; k++) {
			printf("%lu", c[i][k]);
			if (k + 1 < l) {
				printf(" ");
			}
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using P = pair<int, int>;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<P> s(n);
  rep(i, n) cin >> s[i].second >> s[i].first;
  sort(s.rbegin(), s.rend());
  ll sum = 0;
  set<int> st;
  priority_queue<int, vector<int>, greater<int>> que;
  rep(i, k) {
    sum += s[i].first;
    if (st.find(s[i].second) == st.end())
      st.insert(s[i].second);
    else
      que.push(s[i].first);
  }
  ll var = st.size();
  ll ans = sum+var*var;
  for (int i = k; i < n && !que.empty(); i++) {
    if (st.find(s[i].second) != st.end())
      continue;
    int num;
    num = que.top();
    que.pop();
    sum += s[i].first-num;
    st.insert(s[i].second);
    var++;
    chmax(ans, sum+var*var);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7152
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Program{
  public static void Main(){
    long[] nk = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
    long n = nk[0];
    long k = nk[1];
    
    long n1 = n - (n/k)*k;
    long n2 = Math.Abs(n1 - k);
    
    Console.WriteLine(Math.Min(n1,n2));
  }
}

Measured memory_bytes: 13268
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Snuke the Wizard
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 200000;
const int MAX_Q = 200000;

/* typedef */

typedef pair<char,int> pci;
typedef deque<bool> dqb;

enum { STAY, LOUT, ROUT };

/* global variables */

char s[MAX_N + 4];
pci ops[MAX_Q];

/* subroutines */

int check(int n, int q, int x) {
  for (int i = 0; i < q; i++)
    if (s[x] == ops[i].first) {
      x += ops[i].second;
      if (x < 0) return LOUT;
      if (x >= n) return ROUT;
    }
  return STAY;
}

/* main */

int main() {
  int n, q;
  scanf("%d%d%s", &n, &q, s);

  for (int i = 0; i < q; i++) {
    char st[4], sd[4];
    scanf("%s%s", st, sd);
    ops[i] = pci(st[0], (sd[0] == 'L') ? -1 : 1);
  }

  int l0 = -1, r0 = n;
  while (l0 + 1 < r0) {
    int x = (l0 + r0) / 2;
    if (check(n, q, x) == LOUT) l0 = x;
    else r0 = x;
  }
  //printf("l0=%d, r0=%d\n", l0, r0);

  int l1 = -1, r1 = n;
  while (l1 + 1 < r1) {
    int x = (l1 + r1) / 2;
    if (check(n, q, x) == ROUT) r1 = x;
    else l1 = x;
  }
  //printf("l1=%d, r1=%d\n", l1, r1);

  printf("%d\n", r1 - r0);
  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip> 

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef tuple<int,int,int> iii;

string to_string(string s) {
    return '"' + s + '"';
}
    
string to_string(const char* s) {
    return to_string((string) s);
}
    
string to_string(bool b) {
    return (b ? "true" : "false");
}
    
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
    
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void fastIO() {
    cin.sync_with_stdio(false);
    cin.tie(0);
}


int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

//#############################
const int MAXN = 1000005;
int n;
ll mw;
vector<ll> v, w;

ll memo[105][100005];

ll dp(int i, ll cw) {
    if (cw > mw)
        return -(1e18);
    if (i == n)
        return 0;
    if (memo[i][cw] != -1)
        return memo[i][cw];

    memo[i][cw] = max(dp(i+1, cw), v[i] + dp(i+1, cw+w[i]));
    return memo[i][cw];
}

int main() {
    cin >> n >> mw;
    ll x,y;
    for (int i = 0; i < n; i++) 
        cin >> x >> y, v.pb(y), w.pb(x);
    memset(memo, -1, sizeof(memo));
    ll ans = dp(0, 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 82304
#include "bits/stdc++.h"
using namespace std;
int main() {
    int N, M;
    cin >> N >> M;

    vector<int> A(N);
    vector<long long> B(N + 1);
    B[0] = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        B[i + 1] = (B[i] + A[i]) % M;
    }

    map<int, int> mp;
    long long ans = 0;
    for (int i = 0; i < B.size(); i++) {
        ans += mp[B[i]];
        mp[B[i]]++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, cnt=0,pp,qq;
  cin>>N;
  vector<int> nums(N),p(N),q(N);

  REP(i,N){
    nums[i]=i+1;
  }

  REP(i,N){
    int tmp;
    cin>>tmp;
    p[i]=tmp;
  }
  REP(i,N){
    int tmp;
    cin>>tmp;
    q[i]=tmp;
  }

  do {
    if(equal(ALL(nums), p.begin()))pp=cnt;
    if(equal(ALL(nums), q.begin()))qq=cnt;
    cnt++;
  } while (std::next_permutation(ALL(nums)));
  cout<<abs(pp-qq)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int main(void) {

    int S;
    cin >> S;

    int h = S / 3600;
    int m = (S - h * 3600) / 60;
    int s = S - (h * 3600) - (m * 60);

    printf("%d:%d:%d\n", h, m, s);

    return 0;
}

Measured memory_bytes: 1144
using System;
class Test
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int a = int.Parse(str[0]);
        int b = int.Parse(str[1]);
        int c = int.Parse(str[2]);
        int count = 0;
 
        for (int i = a; i <= b; i++)
        {
            if (c % i == 0) count++;
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define P pair<long long, long long>

using namespace std;
const long long INF = 2e18;


int main(){
  int t;
  cin >> t;
  for(int tt=0;tt<t;tt++){
    long long n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    vector<P> v;
    v.clear();
    v.emplace_back(P(2, a));
    v.emplace_back(P(3, b));
    v.emplace_back(P(5, c));
    map<long long, long long> m;
    m[0] = 0;
    m[1] = d;
    function<long long(long long)> dfs = [&](long long x){
      if(m.find(x)!=m.end())return m[x];
      long long ret=INF;
      if((long double)d * (long double)x<ret)ret=d*x;
      for(auto &p: v){
        long long num=p.first;
        long long cost=p.second;
        ret = min(ret, dfs(x/num)+cost+d*(x%num));
        if(x%num!=0){
          ret = min(ret, dfs(x/num + 1)+cost+d*(num-x%num));
        }
    }
    return m[x] = ret;
    };
    cout << dfs(n) << endl;
  }
}



Measured memory_bytes: 4384
ss = gets.chomp
t = gets.chomp

def match(start, t, ss)
  t.chars.each_with_index  do |tt, i|
    return false if ss[start+i] != '?' && ss[start+i] != tt
  end
  ss[0...start] + t + ss[(start+t.size)..-1]
end

candidates = []
(0..(ss.size - t.size)).each do |st|
  replaced = match(st, t, ss)
  if replaced
    candidates << replaced.gsub('?', 'a')
  end
end

puts candidates.empty? ? 'UNRESTORABLE' : candidates.sort[0]

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll h, w;
  cin >> h >> w;
  string snuke[h][w];
  ll i, j;
  for(i=0; i<h; i++) {
    for(j=0; j<w; j++) {
    cin >> snuke[i][j];
    if(snuke[i][j]=="snuke") goto found;
    }
  }
  
  found:
  char row='A';
  row += j;
  cout << row << i+1 << newl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main()
{
	int N;
	scanf("%d",&N);
	int b_2=0;
	int b_4=0;
	int els=0;
	for(int i=0;i<N;i++)
	{
		int num;
		scanf("%d",&num);
		if(num%4==0)
			b_4++;
		else
		if(num%2==0 && num%4!=0)
			b_2++;
		else
			els++;
	}
	if(b_2>0)
		b_2=1;
	if(b_4>=b_2+els-1)
		printf("Yes");
	else
		printf("No");
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define y1 FUCK_THE_y1
#define pI pair <int, int>
#define mp make_pair
#define fr first
#define sc second
#define LD long double
int n;
const int N = 300000;
int x1, y1, x2, y2;
int xi[N], yi[N];
    LD pi = acos(-1), ans;

pI L[N]; int tot;
int ai[N], cnt = 0;
int main()
{
    cin >> x1 >> y1 >> x2 >> y2;
    cin >> n;
    for (int i = 1; i <= n; ++ i)
        cin >> xi[i] >> yi[i];
    if (x1 > x2) swap(x1, x2), swap(y1, y2);
    if (y1 < y2)
    {
        for (int i = 1; i <= n; ++ i)
            if (xi[i] >= x1 && xi[i] <= x2 && yi[i] >= y1 && yi[i] <= y2)
                L[++ tot] = mp(xi[i], yi[i]);
        sort(L + 1, L + tot + 1);
        for (int i = 1; i <= n; ++ i)
        {
            int d = lower_bound(ai, ai + cnt + 1, L[i].sc) - ai;
            ai[d] = L[i].sc; if (d == cnt + 1) cnt ++;
        }
        ans = (x2 - x1 + y2 - y1) * 100.0 - cnt * (2 - pi / 2) * 10 + (cnt == min(y2 - y1, x2 - x1) + 1? pi * 5: 0);
    }
    else
    {
        for (int i = 1; i <= n; ++ i)
            if (xi[i] >= x1 && xi[i] <= x2 && yi[i] >= y2 && yi[i] <= y1)
                L[++ tot] = mp(xi[i], y1 - yi[i] + 1);
        sort(L + 1, L + tot + 1);
        for (int i = 1; i <= n; ++ i)
        {
            int d = lower_bound(ai, ai + cnt + 1, L[i].sc) - ai;
            ai[d] = L[i].sc; if (d == cnt + 1) cnt ++;
        }
        ans = (x2 - x1 + y1 - y2) * 100.0 - cnt * (2 - pi / 2) * 10 + (cnt == min(y1 - y2, x2 - x1) + 1? pi * 5: 0);
    }
    cout << setprecision(20) << ans << endl;
}


Measured memory_bytes: 4992
# cook your dish here
import bisect
n=int(input())
a = list(map(int,input().split()))	
a.sort()
b = list(set(a))

ass = []
if len(b) == 1:
    print(n)
elif len(b) == 2:
    if b[0] == b[1] or b[0] - 1 == b[1] or b[0] + 1 == b[1]:
        print(n)
    else:
        k1 = bisect.bisect_left(a,b[0])
        k2 = bisect.bisect_right(a,b[0])
        print(max(k2-k1,n-k2+k1))
else:
    for i in range(len(b)-2):
        if b[i+1] == b[i] + 2:
            k1 = bisect.bisect_left(a,b[i])
            k2 = bisect.bisect_right(a,b[i+1])
            ass.append(k2-k1)
        elif b[i+1] == b[i] + 1:
            if b[i+2] == b[i] + 2:
                k1 = bisect.bisect_left(a,b[i])
                k2 = bisect.bisect_right(a,b[i+2])
                ass.append(k2-k1)
            else:
                k1 = bisect.bisect_left(a,b[i])
                k2 = bisect.bisect_right(a,b[i+1])
                ass.append(k2-k1)
        else:
            k1 = bisect.bisect_left(a,b[i])
            k2 = bisect.bisect_right(a,b[i])
            ass.append(k2-k1)
    k1 = bisect.bisect_left(a,b[len(b)-1])
    k2 = bisect.bisect_right(a,b[len(b)-1])
    ass.append(k2-k1)
    k1 = bisect.bisect_left(a,b[len(b)-2])
    k2 = bisect.bisect_right(a,b[len(b)-2])
    ass.append(k2-k1)
    
    print(max(ass))

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

int main() {
  int K;
  vector<int> c;

  while(1) {
    int sum	= 0;
    cin >> K;
    if(K == 0)
      break;
    for(int i = 0; i < K*(K-1)/2; i++) {
      int C;
      cin >> C;
      sum += C;
      c.push_back(C);
    }

    cout << sum/(K-1) << endl;
  }

  return 0;
}



Measured memory_bytes: 3244
S = input()

prev = 'i'
for s in S:
    if s == 'h' and prev == 'i':
        pass
    elif s == 'i' and prev == 'h':
        pass
    else:
        print('No')
        break
    prev = s
else:
    if prev == "h":
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int sum = a + b + c;
  if(sum >=22) cout << "bust" << endl;
  else cout << "win" << endl;
  return 0;
}

Measured memory_bytes: 3616
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# 長さじゃなくて、棒自体で区別してるやんけー！

import numpy as np

N = int(readline())
L = np.array(read().split(),np.int32)

L.sort()

U=1000
counter = np.bincount(L,minlength=U+U+10)
cum = counter.cumsum()

add = L[:,None] + L[None,:]
max_c = cum[add-1]
cnt_c = max_c - np.arange(len(L)) - 1

answer = np.triu(cnt_c,1).sum()
print(answer)


Measured memory_bytes: 153024
#include<cstdio>
#include<algorithm>
using namespace std;
int a[4];
bool cmp(int a,int b){
	return a>b;
}
int main(){
	scanf("%d%d%d",&a[1],&a[2],&a[3]);
	int ans=0;
	while (1){
		sort(a+1,a+3+1,cmp);
		if (a[1]==a[2] && a[2]==a[3]){
			printf("%d\n",ans);
			return 0;
		}
		while (a[3]<a[2]) a[3]+=2,ans++;
		sort(a+1,a+3+1,cmp);
		while (a[2]<a[1]) a[2]++,a[3]++,ans++;
	}
	return 0;
}

Measured memory_bytes: 128
import sys
 
input = sys.stdin.readlines()
 
n = int(input[0])
hatList = list(input[1])
counter = 0

for i in range (n):
  if(hatList[i] == "R"):
    counter += 1
    
if counter > (n/2):
    print("Yes")
else:
	print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll N,A,i,cnt,ans=100000;
    cin >> N;
    for(i=0;i<N;i++){
      cin >> A;
      cnt=0;
      while(A%2==0){
        A/=2;
        cnt++;
      }
      ans=min(ans,cnt);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;

////// Mod int //////
struct mint {
	ll x;
	mint() :x(0) {}
	mint(ll x) :x((x% MOD + MOD) % MOD) {}
	// mint(ll x):x(x){}
	mint& fix() { x = (x % MOD + MOD) % MOD; return *this; }
	mint operator-() const { return mint(0) - *this; }
	mint& operator+=(const mint& a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
	mint& operator-=(const mint& a) { if ((x += MOD - a.x) >= MOD) x -= MOD; return *this; }
	mint& operator*=(const mint& a) { (x *= a.x) %= MOD; return *this; }
	mint operator+(const mint& a)const { return mint(*this) += a; }
	mint operator-(const mint& a)const { return mint(*this) -= a; }
	mint operator*(const mint& a)const { return mint(*this) *= a; }
	bool operator<(const mint& a)const { return x < a.x; }
	bool operator==(const mint& a)const { return x == a.x; }
};
istream& operator>>(istream& i, mint& a) { i >> a.x; return i; }
ostream& operator<<(ostream& o, const mint& a) { o << a.x; return o; }
typedef vector<mint> Vm;

/////////////////////

string s;
int n;

void init()
{
	cin >> s;
	n = SZ(s);
}

int main()
{
	init();

	Vm dp(13);
	dp[0] = 1;

	REP(i, n)
	{
		Vm tmpdp(13);
		REP(d, 10)
			REP(j, 13)
			if (s[i] == '?' || s[i] - '0' == d)
				tmpdp[(10 * j + d) % 13] += dp[j];

		dp = tmpdp;
	}

	cout << dp[5] << endl;
}

//// solved A-D in 38min on Sep 26, 2019 ////


Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
	int i, j, x, y, size, paper[14][14], white, max;
	white = max = 0;
	for (j=0; j<14; j++)
		for (i=0; i<14; i++)
			paper [i][j] = 0;
	while (scanf ("%d,%d,%d", &x, &y, &size) != EOF){
		x += 2;
		y += 2;
		switch (size){
			case 1:
				paper [x-1][y]++;
				paper [x+1][y]++;
				paper [x][y]++;
				paper [x][y-1]++;
				paper [x][y+1]++;
				break;
			case 3:
				paper [x-2][y]++;
				paper [x+2][y]++;
				paper [x][y-2]++;
				paper [x][y+2]++;
			case 2:
				for (j=-1; j<=1; j++)
					for (i=-1; i<=1; i++)
						paper [x+i][y+j]++;
		}
	}
	for (j=2; j<12; j++){
		for (i=2; i<12; i++){
			if (paper [i][j] == 0) white++;
			if (paper [i][j] > max) max = paper[i][j];
		}
	}
	printf ("%d\n%d\n", white, max);
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;

class Solve
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
		long N = long.Parse(Console.ReadLine());
		long pans = 0;
		long div = (long)Math.Sqrt(N);
       
		for(int i = 1; i <= div; i++)
		{
			if (N % i == 0) { pans = N / i; }
		}

        
		int ans = 0;
		while (pans > 0)
		{
			pans /= 10;
			ans++;
		}

		Console.WriteLine(ans);
	}
}


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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 500005
#define all(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define rt return 0;
#define len size()
using namespace std;



int32_t main(){
	IOS;
	string yy = "YES";
	string nn = "NO";
	int tt = 1; 
	//cin >> tt;
	while(tt--){
		
		int n;
		
		cin >> n;
		
		cout << (n + 999) / 1000 * 1000 - n;
	}
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for(ll i = 0;i < n;i++)
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  ll ab, bc, ca;
  cin >> ab >> bc >> ca;
  cout << ab * bc / 2 << endl;
}


Measured memory_bytes: 768
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    int N;
    cin >> N;
    vector<int> X(N);
    for(int i = 0; i < N; i++) cin >> X[i];
    sort(all(X));
    int start = X[0];
    int end = X.back();
    int min_d = INT_INF;
    for(int i = start; i <= end; i++){
        int dist = 0;
        for(int x : X){
            dist += (x - i) * (x - i);
        }
        min_d = min(min_d, dist);
    }
    cout << min_d << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <climits>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <bitset>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (n); ++i)
#define InitRep(i, begin, n) for (int i = (begin); i < (n); ++i)
#define RepItr(it, begin, end) for (auto it = (begin); it != (end); ++it)
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;
const static double PI = ::acos(-1);

constexpr int64 MOD = 1000000007;


int main()
{
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    vector<char> raw;
    Rep(i, n)
    {
        raw.push_back(s[i]);
        raw.push_back(t[i]);
    }
    string ans(raw.begin(), raw.end());

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
using namespace std;

int main() {
	int a,b,c,p=0,K,k=0;
	cin>>a>>b>>c>>K;
	p=a+b+c-max(max(a,b),c);
	k=max(max(a,b),c);
	for(int i=0;i<K;i++)
	{
		k*=2;
	}
	cout<<k+p;
	}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  string s;
  cin >> s;
  if(s[1] == 'B') cout << "ARC" << endl;
  else cout << "ABC" << endl;
}

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

int main() {
  string a,b = "", c = "0", d = "1", e = "b";
  cin >> a;

  for(int i = 0; i < a.size(); i++) {
    a[i] == c[0] ? b += "0" :
    a[i] == d[0] ? b += "1" :
    b.size() > 0 ? b = b.erase(b.size() - 1) : a = a;
  }
  cout << b << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         // if (siz[rx] < siz[ry]) swap(rx,ry);
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1LL) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

int main(void) {
    int N;
    ll K;
    cin >> N >> K;
    vector<int> A(200010);
    for (int i=1;i<=N;i++) cin >> A[i];

    vector<int> V;
    vector<bool> C(200010,false);
    int p = 1;
    while (!C[p]) {
        C[p] = true;
        V.push_back(p);
        p = A[p];
    }
    // for (auto itr: V) cout << itr << endl;

    auto itr = find(V.begin(), V.end(), p);
    ll X = itr - V.begin();
    ll Y = V.end() - itr;
    cout << V[(K>X)?(X+(K-X)%Y):K] << endl;

    return 0;
}


Measured memory_bytes: 5140
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
C=[0]*8
num_god=0
for a in A:
    if a//400<8:
        C[a//400]+=1
    else:
        num_god+=1
ans=0
for a in C:
    if a!=0:
        ans+=1
cnt=0
for a in C:
    if a==0:
        cnt+=1
if cnt==8:
    Min=1
else:
    Min=ans
Max=ans+num_god
print(Min,Max)

Measured memory_bytes: 38384