akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<25);
const ll INFLL = (1ll<<60);
const ll BASE = 998244353ll;

#define l_ength size

ll MOD[2]={(ll)(1e9+7),(ll)(1e9+9)};

void mul_mod(ll& a, ll b, int k){
	a *= b;
	a %= MOD[k];
}

void add_mod(ll& a, ll b, int k){
	a = (a<MOD[k])?a:(a-MOD[k]);
	b = (b<MOD[k])?b:(b-MOD[k]);
	a += b;
	a = (a<MOD[k])?a:(a-MOD[k]);
}

ll h[1001001][2];

int ufr[575575],ufp[575575];

void ufinit(int n){
	int i;
	for(i=0; i<n; ++i){
		ufp[i] = i;
		ufr[i] = 1;
	}
}

int ufind(int x){
	if(ufp[x] == x){
		return x;
	}
	return ufp[x] = ufind(ufp[x]);
}

bool unionf(int x, int y){
	x = ufind(x);
	y = ufind(y);
	if(x==y){
		return true;
	}
	if(ufr[x] < ufr[y]){
		swap(x,y);
	}
	ufp[y] = x;
	ufr[x] += ufr[y];
	return false;
}

int main(void){
	int n,m,i,j,k,ans=0;
	ll x[2]={0ll,0ll},y[2],z[2]={1ll,1ll};
	bool flag = true;
	string s,t;
	cin >> s; n = s.l_ength();
	cin >> t; m = t.l_ength();
	ufinit(n);
	for(j=0; j<m; ++j){
		for(k=0; k<2; ++k){
			mul_mod(x[k],BASE,k);
			add_mod(x[k],t[j],k);
			h[j+1][k] = h[j][k];
			mul_mod(h[j+1][k],BASE,k);
			add_mod(h[j+1][k],s[j%n],k);
			mul_mod(z[k],BASE,k);
		}
	}
	for(i=0; i<n; ++i){
		for(k=0; k<2; ++k){
			y[k] = h[i+m][k];
			add_mod(y[k],MOD[k]-(h[i][k]*z[k])%MOD[k],k);
		}
		if(x[0] == y[0] && x[1] == y[1]){
			if(unionf(i,(i+m)%n)){
				flag = false;
			}
		}
		for(k=0; k<2; ++k){
			h[i+m+1][k] = h[i+m][k];
			mul_mod(h[i+m+1][k],BASE,k);
			add_mod(h[i+m+1][k],s[(i+m)%n],k);
		}
	}
	for(i=0; i<n; ++i){
		ans = max(ans,ufr[i]-1);
	}
	cout << ((flag)?ans:(-1)) << endl;
	return 0;
}


Measured memory_bytes: 21384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int H1,M1,H2,M2,K;
    cin >>H1>>M1>>H2>>M2>>K;
    int len = (H2-H1) * 60 + (M2-M1);
    cout << len-K << endl;

}

Measured memory_bytes: 3608
n,k,q = map(int,input().split())
# a=[int(input()) for i in range(q)]
ans=[k-q]*n
for i in range(q):
    ans[int(input())-1] += 1
# print(ans)
for i in ans:
    if i>0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 6664
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int N;
    cin >> N;
    VI A(N), B(N), C(N - 1);
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> B[i];
    REP(i, N - 1) cin >> C[i];

    int ans = accumulate(ALL(B), 0);
    REP(i, N - 1) if (A[i + 1] - A[i] == 1) {
        ans += C[A[i] - 1];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n = gets.to_i

def encoder(x)
  a = x.to_s[0]
  b = x.to_s[-1]
  
  a+b
end

map = {}
(1..n).each do |i|
  encoded = encoder(i)
  if map[encoded]
    map[encoded] += 1
  else
    map[encoded] = 1
  end
end

count = 0
(1..n).each do |j|
  encoded = encoder(j)
  oposite = encoded[1]+encoded[0]
  
  count += map[oposite] if map[oposite]
end

puts count


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

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

  ll ans = (x / 500) * 1000;
  ans += ((x - (x / 500) * 500) / 5) * 5;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using std::cin;
using std::cout;

#include<string>
using std::string;

int main(void){
  int k;
  string s;
  
  cin >> k;
  cin >> s;
  
  if(s.size() > k){
    s = s.substr(0,k) + "...";
  }
  cout << s << '\n';
  return 0;
}

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

using namespace std;
#define X first
#define Y second
#define pb push_back
typedef double db;
typedef long long ll;
typedef pair<int,int> P;
int d;ll res=0;

int main()
{
    scanf("%d",&d);
    if(d%9) return puts("0"),0;
    d/=9;ll t1=0,t2=1;
    for(int i=1;i<=17;i++,t2*=10)
    {
        t1=t1*10+1;
        ll lft=d,cur=t1,lp=t2,rp=1,sum=1;
        
        while(lp>=rp)
        {
            int dgt=(lft%(rp*10))/rp;
            sum*=10-abs(dgt)-(rp==1);
            lft-=cur*dgt;cur-=lp+rp;
            lp/=10;rp*=10;
        }
        if(i%2==0) sum*=10;
        if(!lft) res+=sum;
    }
    printf("%lld",res);
    return 0;
}

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

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    readint;
    auto xs = readints;
    xs.sort();
    xs.reverse();

    int alice = 0;
    int bob = 0;
    for (int i = 0; i < xs.length; i += 2) {
        alice += xs[i];
        if (i + 1 < xs.length)
            bob += xs[i + 1];
    }
    writeln(alice - bob);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a, b, c;
    
    scanf("%d %d %d", &a, &b, &c);
    
    if(a<b && b<c){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 580
#include<stdio.h>

int main(){
	int point[100]={0},base=0,n,i,out=0;
	char move[100];
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		while(scanf("%s",move)!=EOF){
			
			if (strcmp(move, "HIT")==0)base++;
			else if (strcmp(move, "HOMERUN")==0){ point[i]+=(base+1); base=0; }
			else if (strcmp(move, "OUT")==0)out++;
			
			if(base==4){ point[i]++; base=3; }
			if(out==3){ out=0; base=0; i++; }
		}
	}
	
	for(i=0;i<n;i++)printf("%d\n",point[i]);
	
return 0;
}

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

int main() {
    unsigned long long N, x;
    cin >> N >> x;

    unsigned long long a[N];
    unsigned long long sum = 0;
    for (int i = 0; i < N; i++){
        cin >> a[i];
        sum += a[i];
    }

    if (sum == x){
        cout << N << endl;
        return 0;
    }

    int ans = 0;
    sum = 0;
    sort(a, a + N);
    for (int i = 0; i < N; i++){
        sum += a[i];
        if (sum <= x){
            ans++;
        }
    }
    if (N == ans){
        ans--;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int N = 1e5 + 7;

LL sum[N], a[N], b[N], c[N];

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) scanf("%lld", &a[i]), b[i] = b[i - 1] + max(a[i], 0LL), sum[i] = sum[i - 1] + a[i];
	for (int i = n; i >= 1; i--) c[i] = c[i + 1] + max(a[i], 0LL);
	LL ans = 0;
	for (int i = 1; i <= n - k + 1; i++){
		ans = max(ans, max(0LL, sum[i + k - 1] - sum[i - 1]) + b[i - 1] + c[i + k]);
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define rrep(i,m,n) for(int i = m; i >= n; i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;
string N;
ll dp[11][2][2][2][2][2][2];
ll rec(ll k=0, bool tight=true, bool c3=false, bool c5=false, bool c7=false, bool other=true, bool zero=true){
    if(k == N.size()){
        return (c3 && c5 && c7 && other);
    }
    ll x = N[k] - '0';
    ll r = (tight ? x : 9);
    if(dp[k][tight][c3][c5][c7][other][zero] != -1) return dp[k][tight][c3][c5][c7][other][zero];
    ll res = 0;
    rep(i,0,r+1){
        res += rec(k+1, tight && i == r, c3||i==3, c5||i==5, c7||i==7, (zero&&i==0)||(other && (i == 3 || i == 5 || i == 7)), zero&&i==0);
    }
    dp[k][tight][c3][c5][c7][other][zero] = res;
    return res;


}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    memset(dp, -1, sizeof(dp));
    print(rec());
}


Measured memory_bytes: 256
#include <iostream>

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

ll digit_sum(ll x){
    ll ret = 0;
    while(x > 0){
        ret += x % 10;
        x /= 10;
    }
    return ret;
}

int main(){
    ll n;
    cin >> n;
    ll ans = 100;
    for(ll a = 1; a < n; ++a){
        ans = min(ans, digit_sum(a) + digit_sum(n - a));
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
int main(void){
    int N;
    cin >> N;
    
    vector<long> number(N + 1);
    
    for (int idx = 1; idx <= N - 1; idx++) {
        cin >> number[idx];
        if (idx == 1) {
          number[0] = number[idx];   
        }
        if (idx == N - 1) {
          number[N] = number[idx];
        }
    }
    
    long result = 0;
    for (int idx = 0; idx < N; idx++) {
        long a = number[idx];
        long b = number[idx + 1];
        result += a > b ? b : a;
    }
    
    cout << result << endl;
}

//0 0 153 10 10 23 23
// 0 0   10 10 10 23

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define REP(k, n) for (ll k = 0; k < (ll)(n); ++k)
#define REPREV(k, n) for (ll k = (ll)(n)-1; k >= 0; --k)
#define FOR(k, a, b) for (ll k = (ll)(a); k < (ll)(b); ++k)
#define FORREV(k, a, b) for (ll k = (ll)(b)-1; k >= (ll)(a); --k)
#define FOREACH(e, v) for (auto e : v)

#define TGET(t, i) get<i>(t)
#define TSET(t, i, a) get<i>(t) = a
// MinHeap - priority_queue<ll, vll, greater<ll>> pq;

#define EVEN(n) ((n)&1) == 0
#define ODD(n) ((n)&1) == 1
#define MOD(x, m) ((x) % (m) + (m)) % (m)

#define SORT(v) sort(v.begin(), v.end())
#define SORTREV(v) sort(v.rbegin(), v.rend())
#define SHUFFLE(v) random_shuffle(v.begin(), v.end())
//srand(unsigned(time(0)));

#define REMOVEAT(v, i) v.erase(v.begin() + i)
#define REVERSE(v) reverse(v.begin(), v.end())

template <typename T>
void join(vector<T>& arr, string sep) {
    bool first = true;
    for (auto t : arr) {
        if (first) {
            first = false;
            cout << t;
        } else {
            cout << sep << t;
        }
    }
    cout << "\n";
}

#define POS "POSSIBLE"
#define IMPOS "IMPOSSIBLE"

// #define INF LLONG_MAX
// #define MINF LLONG_MIN
#define INF 9e18
#define MINF -INF

void solve() {
    ll x, y;
    cin >> x >> y;
    if (y % 2 == 1) {
        cout << "No\n";
        return;
    }
    FOR(i, 0, x+1) {
        ll j = x - i;
        if (i*2 + j*4 == y) {
            cout << "Yes\n";
            return;
        }
    }
    cout << "No\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt = 1;
    // cin >> tt;
    for (int t = 1; t <= tt; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }

    return 0;
}

Measured memory_bytes: 3608
n,m = gets.split(' ').map(&:to_i)
a = gets.split(' ').map(&:to_i).sort.reverse
minVote = a.sum / (4.0*m)
answer = true
m.times do |i|
    answer = false if a[i] < minVote
end

puts answer ? 'Yes' : 'No'




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

using namespace std;
typedef  long long ll;

#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sdo(a) scanf("%lf",&a)
#define sdo2(a,b) scanf("%lf %lf",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
const int maxn=1e6+10;
const int mod=1e9+7;

struct xx{
int x,d,l,r;
};
xx a[maxn];
bool cmp(xx a,xx b)
{
    if(a.l==b.l)
        return a.r<b.r;
    return a.l<b.l;
}
int main()
{
    int n,k,s;
    while(cin>>n>>k>>s)
    {
        for(int i=0;i<k;i++)
            printf("%d ",s);
        for(int i=k;i<n;i++)
            printf("%d ",s==mod-7?mod-8:mod-7);
    }
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int h,w,a,b;
	cin >> h >> w >> a >> b;

	for (int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			if ((i < b && j < a) || (i >= b && j >= a)){
				cout << 0;
			}
			else{
				cout << 1;
			}
		}
		cout << endl;
	}

	return 0;
}

// int main(){
// 	int h,w,a,b;
// 	cin>>h>>w>>a>>b;
// 	for(int i=0;i<h;i++){
// 		for(int j=0;j<w;j++){
// 			if((i<b)^(j<a))
// 				cout<<1;
// 			else
// 				cout<<0;
// 		}
// 		cout<<"\n";
// 	}
// }

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;
const double pi = acos(-1);

void solve() {
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> A(n), F(n);
    rep(i, n) cin >> A[i];
    rep(i, n) cin >> F[i];
    sort(all(A), greater<ll>());
    sort(all(F));
    ll l = -1, r = LINF;
    while((r - l) > 1) {
        ll mid = (r + l) / 2;
        ll cnt = 0;
        rep(i, n) {
            if (A[i] * F[i] <= mid) continue;
            cnt += (A[i] * F[i] - mid + F[i] - 1) / F[i];
        }
        if (cnt > k) l = mid;
        else r = mid;
    }
    cout << r << endl;
}

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


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

int main() {
    int n;
    cin >> n;
    vector<int> h(n,0);
    rep(i,n)cin >> h.at(i);
    int max_height = 0;
    int res = 0;
    rep(i,n){
        if(max_height <= h.at(i)){
            res++;
            max_height = h.at(i);
        }
    }
    cout << res << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int addTax(int a, int x)
{
    return a * (100 + x) / 100;
}

int main()
{
    for(;;){
        int x, y, s;
        cin >> x >> y >> s;
        if(x == 0)
            return 0;

        int ret = -1;
        for(int a=1; a<s; ++a){
            for(int b=1; b<s; ++b){
                if(addTax(a, x) + addTax(b, x) == s)
                    ret = max(ret, addTax(a, y) + addTax(b, y));
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 1160
parseInt(x) = parse(BigInt, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
  N = parseInt(readline())
  D=zeros(N) ; E=zeros(N)
  for i in 1:N
    D[i],E[i] = parseMap(split(readline()))
  end
  tmp=false
  for i in 3:N
    if D[i]==E[i] && D[i-1]==E[i-1] && D[i-2]==E[i-2]
      tmp = true
    end
  end
  if tmp
    println("Yes")
  else
    println("No")
  end
end
main()


Measured memory_bytes: 183704
#112 B
N,T= map(int,input().split())

cnt=0
ans =1000
for i in range(N):
    x =[int(j) for j in input().split()]
    
    if x[1]<=T:
        ans=min(ans,x[0])
        cnt+=1
if cnt>0:
    print(ans)
else:
    print('TLE')

Measured memory_bytes: 3060
N,K = input().split(' ')
N = int(N)
K = int(K)
points = [int(x) for x in input().split(' ')]
line = input()
point = 0
W = {
  "r":"p",
  "s":"r",
  "p":"s"
}
P = {
  "r":points[0],
  "s":points[1],
  "p":points[2]
}
mem = [0]*K
for i in range(N):
  if i < K:
    mem[i] = W[line[i]]
    point += P[W[line[i]]]
  else:
    if mem[i%K] == W[line[i]]:
      mem[i%K] = 'N'
    else:
      mem[i%K] = W[line[i]]
      point += P[W[line[i]]]
print(point)

Measured memory_bytes: 3956
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, M, X = map(int, input().split())
    A = set(list(map(int, input().split())))
    X0 = set(list(range(0, X)))
    XN = set(list(range(X, N + 1)))
    print(min(len(X0 & set(A)), len(XN & set(A))))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
long n,i,a[214514],c,r;
int main()
{
	for(i=1,cin>>n;i<=n;i++)cin>>a[i],a[i]+=a[i-1];
	sort(a,a+n+1);
	a[n+1]=1145141919810;
	for(i=0,c=1;i<=n;i++)
	{
		if(a[i]==a[i+1])
		{
			c++;
		}
		else
		{
			r+=c*(c-1)/2;
			c=1;
		}
	}
	cout<<r<<endl;
}

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


void solve(long long R){
    cout << 2 * R * M_PI << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long R;
    scanf("%lld", &R);
    long long M;
    solve(R);
    return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
  ll N;
  cin>>N;
 vector<string>A(N);
  for(int i=0;i<N;i++){
  cin>>A[i];
  }
  
  sort(A.begin(),A.end());
  
int count=0;
  int ct=0;
  
for(int i=0;i<N-1;i++){
if(A[i]==A[i+1]){
  count=count+1;
}
  else{count=0;}
  ct=max(ct,count);
}
  
  
  count=0;
  
for(int i=0;i<N-1;i++){
if(A[i]==A[i+1]){
  count=count+1;
}
  else{count=0;}
  if(count==ct){
  cout<<A[i]<<endl;
  }
}
  
  if(ct==0){
  cout<<A[N-1]<<endl;
  }
  

}


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

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  if (a > b)
    cout << 0 << endl;
  else if (n == 1 && a != b)
    cout << 0 << endl;
  else if (n == 1 && a == b)
    cout << 1 << endl;
  else {
    cout << (n - 2) * (b - a) + 1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	bool f=false;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]%2==0){
			if(!(a[i]%3==0||a[i]%5==0)){
				f=true;
			}
		}
	}
	if(f) cout<<"DENIED"<<endl;
	else cout<<"APPROVED"<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let (n, a, b) = {
        let i = read::<usize>();
        (i[0], i[1], i[2])
    };

    let mut hn = Vec::new();
    for _ in 0..n { hn.push(read_one::<usize>()); }

    let valid = |t: usize| -> bool {
        let mut cnt: usize = 0;
        for &h in hn.iter() {
            if h > t * b {
                cnt += ((h - t * b) as f64 / (a - b) as f64).ceil() as usize;
            }
        }
        cnt <= t
    };

    let mut l = 0;
    let mut r = *hn.iter().max().unwrap() as isize;
    while r - l > 1 {
        let m = (l + r) / 2;
        if valid(m as usize) {
            r = m;
        } else {
            l = m;
        }
    }

    println!("{}", r);
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

int a[4][105];
LL sum[105];
bool cmp(int x, int y){
	return x > y;
}
int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= 2; i++){
		for(int j = 1; j <= n; j++){
			scanf("%d", &a[i][j]);
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= i; j++) sum[i] += a[1][j];
		for(int k = i; k <= n; k++)	sum[i] += a[2][k];
	}
	sort(sum, sum + 100, cmp);
	cout << sum[0] << endl;
	return 0;
}

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	vector<int> v(5);
	REP(i,5) cin >> v[i];

	int k; cin >> k;

	bool ans = true;
	REP(i,4){
		FOR(j,i+1,5){
			if(v[j]-v[i] > k) ans = false;
		}
	}

	cout << (ans ? "Yay!" : ":(") << endl;


	return 0;

}


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

int main(){
    int n,y;
    cin>>n>>y;
    y/=1000;
    for(int i=0;i<=n;i++){
        for(int j=0;j+i<=n;j++){
            if((10*i+5*j+(n-i-j)==y)&&(n-i-j)>=0){
                cout<<i<<' '<<j<<' '<<n-i-j<<'\n';
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MAX_N 105
#define MAX_M 11
#define PI 3.14159265359
#define rep(i,n) for(int i=0; i<n; ++i)
#define INF 1001001001

typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;
    set<string> keihin;

    rep(i,n) {
        string s;
        cin >> s;
        keihin.insert(s);
    }
    cout << keihin.size() << endl;

    return 0;
}

Measured memory_bytes: 19232
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define MAX_N 100
#define LIMIT 20


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

  int a[MAX_N];
  int n;

  cin >> n;
  for(int i=0;i<n;i++) {
    cin >> a[i];
  }
  // DP
  ll dp[n-1][LIMIT+1];
  for(int i=0;i<n-1;i++) {
    for(int j=0;j<=LIMIT;j++) {
      dp[i][j] = 0;
    }
  }
  dp[0][a[0]] = 1;
  for(int i=1;i<=n-2;i++) {
    for(int j=0;j<=LIMIT;j++) {
      if(j+a[i] <= LIMIT) dp[i][j] += dp[i-1][j+a[i]];
      if(j-a[i] >= 0) dp[i][j] += dp[i-1][j-a[i]];
    }
  }
  cout << dp[n-2][a[n-1]] << endl;
}

Measured memory_bytes: 1204
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String C = stdIn.next();    
        stdIn.close();

        String[] alp = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
        for (int i = 0; i < 26; i++) {
            if (C.equals(alp[i])) {
                C = alp[i+1];
                System.out.println(C);
                break;
            }
        }
    }
}

Measured memory_bytes: 21972
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
int x;
int main()
{
	cin>>x;
	if (x==1)
		cout<<0;
	if (x==0)
		cout<<1;
	return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
typedef pair< int, int > pii;

pii getRange(int w, int d, int x, int y, char f) {
	if (f == 'N') {
		int a = x - (d - y), b = (w - x) - (d - y);
		return pii(a, w - b);
	}
	
	if (f == 'E') {
		int a = (d - y) - (w - x), b = y - (w - x);
		return pii(w + a, w + d - b);
	}
	
	if (f == 'S') {
		int a = (w - x) - y, b = x - y;
		return pii(w + d + a, 2*w + d - b);
	}
	
	if (f == 'W') {
		int a = y - x, b = (d - y) - x;
		return pii(2*w + d + a, 2*w+2*d - b);
	}
	
	return pii(-1,-1);
}

int solve(int n, vector< vector< int > >& collision, vector< int >& order, int s) {
	int ret = 0;
	vector< bool > bad(n, false);
	for_(i,0,n) {
		int v = order[(s + i) % n];
		if (bad[v]) continue;
		++ret;
		for (int u : collision[v]) bad[u] = true;
	}
	return ret;
}

struct Rng {
	int id, L, R;
	Rng(int __id, pii p) : id(__id), L(p.first), R(p.second) {}
	bool operator < (const Rng& o) const { return R < o.R; }
};

int main() {
	int n, w, d;
	cin >> n >> w >> d;
	
	int UB = 2*w + 2*d;
	vector< Rng > vp;
	for_(i,0,n) {
		int x, y; char f;
		cin >> x >> y >> f;
		pii p = getRange(w, d, x, y, f);
		vp.push_back(Rng(i, p));
		vp.push_back(Rng(i, pii(p.first + UB, p.second + UB)));
	}
	
	sort(vp.begin(), vp.end());
	vector< int > order, vis(n, false);
	for (Rng r : vp) if (!vis[r.id]) order.push_back(r.id), vis[r.id] = true;
	
	vector< vector< int > > collision(n, vector< int >());
	for (Rng x : vp) for (Rng y : vp) {
		if (x.id == y.id) continue;
		if (x.R >= y.L && x.L <= y.R) collision[x.id].push_back(y.id);
	}
	
	int ans = 0;
	for_(i,0,n) ans = max(ans, solve(n, collision, order, i));
	cout << ans << endl;
}

Measured memory_bytes: 8768
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

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

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int> > A(N);
	rep(i,N) {
		A[i].resize(M);
		rep(j,M) {
			cin >> A[i][j];
			A[i][j]--;
		}
	}

	int res = N;
	bool flg = true;
	bool remove[310] = {};
	while(flg) {
		flg = false;
		int cnt[310] = {};
		int mx = 0;
		rep(i,N) {
			rep(j,M) {
				if(!remove[A[i][j]]) {
					cnt[A[i][j]]++;
					break;
				}
			}
		}
		rep(i,M) mx = max(mx, cnt[i]);
		res = min(res, mx);
		rep(i,M) {
			if(mx == cnt[i]) remove[i] = true;
			if(!remove[i]) flg = true;
		}
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 640
A = []
N,M = list(map(int,input().split()))
if M == 0:
    if N == 1:
        print(0)
        exit()
    else:
        print("1" + "0"*(N-1))
        exit()
for i in range(M):
    A.append(list(input().split()))
for i in range(10 ** N):
    str_i = str(i)
    try:
        if N == len(str_i):
            for j,k in A:
                if str_i[int(j)-1] == k:
                    pass
                else:
                    break
            if str_i[int(j)-1] == k:
                print(i)
                exit()
    except IndexError:
        print("-1")
        exit()
print("-1")

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

int main()
{
  int a, b;

  cin >> a >> b;

  if(8<a || 8<b)
    cout << ":(";

  else
  {
    cout << "Yay!";
  }
}


Measured memory_bytes: 3600
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
	int n, q;
	scanf("%d %d", &n, &q);
	long A[100000];
	for (long i = 0; i < n; i++) A[i] = pow(2, 31) - 1;
	for (long i = 0; i < q; i++){
		long c, x, y;
		scanf("%ld %ld %ld", &c, &x, &y);
		if (c == 0) A[x] = y;
		else printf("%ld\n", *min_element(A + x, A + y + 1));
	}
	return 0;
}

Measured memory_bytes: 3484
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    //int A = sc.nextInt();
    int[] num = new int[5];
    //String str = sc.next();
    
    for(int i=0; i<5; i++){
       num[i] = sc.nextInt();
    }
    
    num[0] = num[0] * 60;
    num[2] = num[2] * 60;

    System.out.println((num[2]+num[3])-(num[0]+num[1]+num[4]));
    //if(str[0].equals("H"));
  }
}


Measured memory_bytes: 35580
#include<iostream>
#include<algorithm>
#include<sstream>
using namespace std;
int n;
int a[200000];
int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	if (n & 1){
		for (int i = n - 1; i >= 0; i -= 2){
			cout << a[i] << " ";
		}
		for (int i = 1; i < n; i += 2){
			cout << a[i];
			if (i != n-2)cout << " ";
		}
		cout << endl;
		return 0;
	}
	else{
		for (int i = n - 1; i >= 0; i-=2){
			cout << a[i] << " ";
		}
		for (int i = 0; i <n; i += 2){
			cout << a[i];
			if (i != n-2)cout << " ";
		}
		cout << endl;
		return 0;
	}
}

Measured memory_bytes: 2944
/**
 *    author:  tourist
 *    created: 06.07.2020 10:30:49       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, x, y;
  cin >> n >> x >> y;
  --x; --y;
  vector<int> ans(n);
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int cur = abs(i - j);
      cur = min(cur, abs(i - x) + 1 + abs(j - y));
      cur = min(cur, abs(i - y) + 1 + abs(j - x));
      ans[cur] += 1;
    }
  }
  for (int i = 1; i < n; i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
int main(void)
{
    int n, a, b, c;
    int S[13] = {0};
    int H[13] = {0};
    int C[13] = {0};
    int D[13] = {0};
    scanf("%d", &n);
    for(a = 1; a <= n; a++)
    {
        char mark;
        scanf(" %c", &mark);
        if('S' == mark)
        {
            scanf("%d", &c);
            S[c-1] = 1;
        }
        if('H'== mark)
        {
            scanf("%d", &c);
            H[c-1] = 1;
        }
        if('C'== mark)
        {
            scanf("%d", &c);
            C[c-1] = 1;
        }
        if('D'== mark)
        {
            scanf("%d", &c);
            D[c-1] = 1;
        }
    }
    for(b = 0; b <= 12; b++)
    {
        if(S[b] == 0)
        {
            printf("S %d\n", b+1);
        }
    }
    for(b = 0; b <= 12; b++)
    {
        if(H[b] == 0)
        {
            printf("H %d\n", b+1);
        }
    }
    for(b = 0; b <= 12; b++)
    {
        if(C[b] == 0)
        {
            printf("C %d\n", b+1);
        }
    }
    for(b = 0; b <= 12; b++)
    {
        if(D[b] == 0)
        {
            printf("D %d\n", b+1);
        }
    }
    return 0;
}


Measured memory_bytes: 2660
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    W, H, x, y = map(int, input().split())

    area = W * H * 0.5
    res = 0
    if W % 2 == 0 and H % 2 == 0 and x == W // 2 and y == H // 2:
        res = 1

    print(area, res)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 2940
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include<iomanip>

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	int n;
	cin >> n;
	vector<int> data(n+1);
	ff(i, 1, n) {
		cin >> data.at(i);
	}
	data.at(0) = data.at(1);
	data.at(n) = data.at(n - 1);
	int ans = 0;
	ff(i, 0, n) {
		ans+= min(data.at(i), data.at(i + 1));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
///CHECKING @Tanvir
#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<int, pii>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair




const int mod = 1e9 + 7;

int ADD(int a, int b, int m = mod) {
    int s = a;
    s += b;
    if( s >= m )
      s -= m;
    return s;
}

int MUL(int a, int b, int m = mod) {
    return (1LL * a * b % m);
}

int power(int a, int b, int m = mod) {
    int res = 1;
    while( b ) {
        if( b & 1 ) {
            res = 1LL * res * a % m;
        }
        a = 1LL * a * a % m;
        b /= 2;
    }
    return res;
}


const int maxn = 1e5 + 5;




int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cout.tie(0);
    int n, k;
    cin>>n>>k;
    vi arr(n);
    for(int i=0; i<n; i++) cin>>arr[i];
    sort(arr.begin(), arr.end(), greater<int>());
    ll sum =0;
    for(int i=k; i<n; i++){
        sum += arr[i];
    }
    cout<<sum<<"\n";




    return 0;
}

/**********************************************************************************
Find the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning when she can use Special Move at most
K  times.


Sort descending

sort(a.begin(), a.end(), greater<int>());



*************************************************************************************/


Measured memory_bytes: 1024
[A, B] = list(map(int, input().split(' ')))

answer = 0

A1_digit = len(bin(A - 1)) - 2
Abit_list = []
Amin_bit = '1' if 1 <= (A - 1) % 4 <= 2 else '0'
Abit_list.append(Amin_bit)

for i in range(2, A1_digit + 1):
    rem = (A - 1) % 2 ** i
    A_bit = '0' if rem < 2 ** (i - 1) or (rem - 2 ** (i - 1)) % 2 == 1 else '1'
    Abit_list.append(A_bit)

B_digit = len(bin(B)) - 2
Bbit_list = []
Bmin_bit = '1' if 1 <= B % 4 <= 2 else '0'
Bbit_list.append(Bmin_bit)
for i in range(2, B_digit + 1):
    rem = B % 2 ** i
    B_bit = '0' if rem < 2 ** (i - 1) or (rem - 2 ** (i - 1)) % 2 == 1 else '1'
    Bbit_list.append(B_bit)

Abit_list.reverse()
Bbit_list.reverse()
Axor = int(''.join(Abit_list), 2)
Bxor = int(''.join(Bbit_list), 2)

print(Axor ^ Bxor)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
        try(Scanner sc = new Scanner(System.in)){
            String line = sc.nextLine();
            int length=line.length();
            for(int i=0;i<length;i++){
                char ch = line.charAt(i);
                if(Character.isLowerCase(ch)){
                    System.out.print(Character.toUpperCase(ch));
                }else if(Character.isUpperCase(ch)) {
                    System.out.print(Character.toLowerCase(ch));
                }else{
                    System.out.print(ch);
                }
            }
        }
        System.out.printf("\n");
    }
}


Measured memory_bytes: 26588
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <deque>
#include <functional>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

// #define int long long

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;

signed main(void)
{
  int a, b; cin >> a >> b;
  cout << max(a + b, max(a - b, a * b)) << endl;
  
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N, Y = map(int, input().split(' '))
for x in range(N+1):
    for y in range(N-x+1):
        z = N - (x + y)
        n = 10000 * x + 5000 * y + 1000 * z
        if n == Y:
            print(x, y, z)
            exit()

print(-1, -1, -1)



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

int main(){
	int a, b;
	char op;

	while(1){	
	cin >> a >> op >> b;
	
	 if(op == '?') break; 
	
	if(op == '+') cout << a + b <<endl;
	else if(op == '-') cout << a - b <<endl;
	else if(op == '*') cout << a * b <<endl;
	else if(op == '/') cout << a / b <<endl;
	else cout <<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3116
#include<iostream>

using namespace std;


int F(int x){
    int num = 0;

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

    return num;
}

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

    int num = F(N);

    if(num == 1)
        cout << N << endl;
    
    else if(num == 2)
        cout << 9 << endl;
    
    else if(num == 3)
        cout << 9+(N-100)+1 << endl;
    
    else if(num == 4)
        cout << 909 << endl;

    else if(num == 5)
        cout << 909 +(N-10000)+1 << endl;
    
    else if(num == 6)
        cout << 90909 << endl;

    return 0;


}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n;
    cin>>n;
    cout<<n/2+n%2<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  
  int N;  cin >> N;
  string s;  cin >> s;
  
  int ans = 0;
  for(int split_point = 0 ; split_point < N ; split_point++){
	map<char, bool> leftField, rightField;
    for(int i = 'a'; i <= 'z' ; i++)  leftField[i] = false, rightField[i] = false;
    
    for(int i = 0 ; i < split_point ; i++)	leftField[s[i]]  = true;
    for(int i = split_point ; i < N ; i++)	rightField[s[i]] = true;
    
    int keep = 0;
    for(int i = 'a'; i <= 'z' ; i++)
      if(leftField[i] && rightField[i])  keep += 1;
    
    ans = (ans < keep) ? keep : ans;
  }
  
  cout << ans << endl;
    
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>
#include <cmath>
#include <limits>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;



int main() {
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    if(k % 2 == 0) {
        int ki = k / 2;
        int ansnums1 = n / k;
        int ansnums2 = n / ki - ansnums1;
        ans = pow(ansnums1, 3) + pow(ansnums2, 3);
    } else {
        int ansnums = n / k;
        ans = pow(ansnums, 3);
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	vector<string> ba,ca,bc,outro;
  int n;
  string str;
  cin >> n;
  for(int i = 0;i<n;i++){
  	cin >> str;
    if(str[0]=='B'){
    	if(str.back() == 'A')
      	ba.push_back(str);
      else
      	bc.push_back(str);
    }else if(str.back() == 'A')
    	ca.push_back(str);
    else
    	outro.push_back(str);
  }
  string s = "";
  if(ca.size()){
  	s+=ca.back();
    ca.pop_back();
  }
  while(ba.size()){
  	s+=ba.back();
    ba.pop_back();
  }
  if(bc.size()){
  	s+=bc.back();
  	bc.pop_back();
  }
  while(ca.size() and bc.size()){
  	s += ca.back();
    ca.pop_back();
    s += bc.back();
    bc.pop_back();
  }
  while(ca.size()){
  	s+=ca.back();
    ca.pop_back();
  }
	while(bc.size()){
  	s+= bc.back();
    bc.pop_back();
  }  
  while(outro.size()){
  	s+=outro.back();
    outro.pop_back();
  }
  //cout<<s<<endl;
  int cont = 0;
  for(int i = 0;i<s.size()-1;i++)
  	if(s[i]=='A' and s[i+1] =='B')
    	cont++;
  cout<<cont;
  
  
  
  
  
  
  
  


}

Measured memory_bytes: 896
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
typedef long long LL;
using namespace std;
const int maxn=52;
const int maxm=maxn*maxn*maxn; const int IINF=1E9+77;
const LL INF=1E18+77;

int N,X,D,M[maxn],P[maxn],T;
LL DP[2][maxm];


struct NODE{
	int v;
	LL s;
	int c;
	bool operator <(const NODE &o)const{
		if(v*o.s != o.v*s){
			return v*o.s > o.v*s;
		}else{
			return s<o.s;
		}
	}
}nodes[maxn];

struct EDGE{
	int to,next;
}edges[maxn];
int cEdge=1,head[maxn];
void addEdge(int from,int to){
	edges[cEdge]=(EDGE){to,head[from]};
	head[from]=cEdge++;
}

void dfs(int u){
	nodes[u]=(NODE){1,M[u],u==1?IINF:D};
	for(int k=head[u];k;k=edges[k].next){
		int v=edges[k].to;
		dfs(v);
		nodes[u].v+=nodes[v].v;
		nodes[u].s+=nodes[v].s;
	}
}

pair<LL,int> Q[maxn][maxn*maxn];
int qh[maxn],qr[maxn];

void push(int x,LL v,int p){
	while(qh[x]!=qr[x] && v < Q[x][qr[x]-1].first) --qr[x];
	Q[x][qr[x]++]=make_pair(v,p);
}

LL query(int x,int p){
	while(qh[x]!=qr[x] && Q[x][qh[x]].second < p) ++qh[x];
	return Q[x][qh[x]].first;
}

int main(){
	scanf("%d%d%d",&N,&X,&D);
	scanf("%d",M+1);
	for(int i=2;i<=N;++i){
		scanf("%d%d",M+i,P+i);
		addEdge(P[i],i);
	}

	dfs(1);

	//for(int i=1;i<=N;++i) cerr<<nodes[i].v<<" "<<nodes[i].s<<" "<<nodes[i].c<<endl;

	for(int i=1;i<nodes[1].v;++i){
		DP[T][i]=INF;
		//if(i<9) cerr<<"DP["<<1<<"]["<<i<<"]="<<DP[T][i]<<endl;
	}
	for(int i=nodes[1].v;i<maxm;++i){
		DP[T][i]=DP[T][i-nodes[1].v]+nodes[1].s;
		//if(i<9) cerr<<"DP["<<1<<"]["<<i<<"]="<<DP[T][i]<<endl;
	}
	//cerr<<endl;

	for(int i=2;i<=N;++i){
		T^=1;
		int v=nodes[i].v;
		LL s=nodes[i].s;
		int c=min(nodes[i].c,maxn);
		nodes[i].c-=c;
		for(int j=0;j<maxm;++j){
			push(j%v,DP[T^1][j]-(j/v)*s,j/v);
			DP[T][j]=query(j%v,(j/v)-c)+(j/v)*s;
			//if(j<9) cerr<<"DP["<<i<<"]["<<j<<"]="<<DP[T][j]<<endl;
		}
		memset(qh,0,sizeof(qh));
		memset(qr,0,sizeof(qr));
		//cerr<<endl;
	}

	for(int i=maxm-2;i>=0;--i){
		DP[T][i]=min(DP[T][i],DP[T][i+1]);
		//if(i<9) cerr<<"DP["<<i<<"]="<<DP[T][i]<<endl;
	}

	//cerr<<"??"<<endl;

	sort(nodes+1,nodes+N+1);
	int p=1,V=0,ans=0;
	LL S=0;
	for(int i=maxm-1;i>=0;--i){
		while(true){
			while(p<=N && !nodes[p].c) ++p;
			if(p<=N && DP[T][i]+S+nodes[p].s <= X){
				int t=(X-DP[T][i]-S)/nodes[p].s;
				if(t>nodes[p].c) t=nodes[p].c;

				V+=nodes[p].v*t;
				S+=nodes[p].s*t;
				nodes[p].c-=t;
			}else{
				break;
			}
		}
		if(DP[T][i]+S <= X){
			//if(i+V > ans) cerr<<":"<<i<<" "<<V<<endl;
			ans=max(ans,i+V);
		}
	}

	printf("%d\n",ans);
}

Measured memory_bytes: 4608
from collections import defaultdict

N, K = map(int, input().split())
c = defaultdict(int)
for i in range(N):
    a, b = map(int, input().split())
    c[a] += b

counter = 0
for a, b in sorted(c.items(), key=lambda x: x[0]):
    counter += b
    if counter >= K:
        break
print(a)


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

int sum_of_digits(int n){
    int sum = 0;
    while(n>0){
        sum += n%10;
        n/=10;
    }
    return sum;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int total = 0;
    for (int i=0; i<=n; i++){
        int sum = sum_of_digits(i);
        if (sum >= a && sum <=b){
            total +=i;
        }
    }
    cout << total << endl;
}

Measured memory_bytes: 3580