akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main
{
    public static void main(String []args)
    {
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int c1=0;
        int c2=0;
        int c3=0;
        int c4=0;
            for(int i=0;i<a;i++)
            {
                String s=sc.next();
                if(s.equals("AC"))
                    c1++;
                if(s.equals("WA"))
                    c2++;
                if(s.equals("TLE"))
                    c3++;
                if(s.equals("RE"))
                    c4++;
            }
            System.out.println("AC"+" "+"x" +" "+ c1);
            System.out.println("WA"+" "+"x" + " "+c2);
            System.out.println("TLE"+" "+"x" +" " +c3);
            System.out.println("RE"+" "+"x" + " " +c4);
    }
}


Measured memory_bytes: 58076
s = str(input())
for b in range(1 << (len(s)-1)):
    ops = []
    for i in range(len(s)-1):
        op = "+" if b & 1 << i else "-"
        ops.append(op)
    siki = ""
    ls = list(s)
    ops.append("")
    for i in range(len(ops)):
        siki += ls[i]+ops[i]
    e = eval(siki)
    if e == 7:
        print("{}{}{}".format(siki, "=", e))
        exit()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <string>
#include <algorithm>
#include <climits>
#include <set>
#include <queue>
#include <unordered_set>
using namespace std;

#define ll long long

const ll mod = 1e9 + 7;

class Solver
{
private:
	ll n;
	ll m;
public:
	Solver();
	void exec();
};

Solver::Solver(){
	cin >> n >> m;

}

void Solver::exec(){
	cout << (1900 * m + (n-m)*100) * pow(2, m) << endl;

}

int main(){
	Solver solution = Solver();
	solution.exec();
}


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

class Program
{
    public static void Main()
    {
        var line = Console.ReadLine().Split(' ').Select(p => int.Parse(p)).ToArray();

        var r = line[0];
        var D = line[1];
        var x = line[2];

        for(int i = 0;i<10;i++)
        {
            x = (r * x) - D;
            Console.WriteLine(x);
        }
    }

}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  int count = 0;
  
  cin >> A >> B;
  
  for(int i = A; i <= B; i++) {
    int s,t,u,v;
    s = i / 10000;
    t = (i % 10000) / 1000;
    u = (i % 100) / 10;
    v = (i % 10);
    
    if(s == v && t == u) {
      count++;
    }
  }
  cout << count << endl;
}

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

ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int m,n,k;
  cin >> n >> m >> k;

  if(k%n==0 || k%m==0){
    cout << "Yes" <<endl;
    return 0;
  }
  else{
    rep(i,m+1){
      rep(j,n+1){
        if(i==0 || j==0){ 
          if(n*i+m*j==k){
            cout << "Yes" <<endl;
     		return 0;
          }
        }
        else{
          if(n*i+m*j-2*max(i,j)*min(i,j)==k){
            cout << "Yes" <<endl;
     		return 0;
          }
        }
      }
    }
    cout << "No" <<endl;
  }
  
}


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

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

int main() {
    int n, k,tmp;
    cin >> n >> k;
    int ans = 0;
    rep(i,n){
        cin >> tmp;
        if(tmp>=k) ans++;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	ll x;cin >> x;
	ll ans = 0;
	ans += (x / 500) * 1000;
	x %= 500;
	ans += (x / 5) * 5;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
local n, k = io.read('*n', '*n')
local mfl =  math.floor
local mod = 1000000007
local ans = 0
for i = k, n + 1 do
    local pre = mfl(i * (i - 1) / 2)
    local suf = mfl((n + n - i + 1) * i / 2)
    ans = (ans + suf - pre + 1) % mod
end
print(ans)

Measured memory_bytes: 2760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
ll x;
int main()
{
	while(cin>>x)
	{
		int ans;
		ll l=1,r=1e9;
		//找到第一个val=1+2+..i>=x的i
		//val-i<x t=val-x<i 将t变为负号即可 
		while(l<=r)
		{
			ll mid=(l+r)>>1;
			ll val=(1+mid)*mid/2;
			if(val>=x)
			{	
				r=mid-1;
				ans=mid;
			}
			else
			l=mid+1;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

int main()
{
    ll n;
    cin >> n;
    vector<ll> c(n-1),s(n-1),f(n-1);
    rep(i,n-1){
        cin >> c[i] >> s[i] >> f[i];
    }
    rep(i,n-1){
        ll t=s[i]+c[i];
        for(int j=i+1;j<n-1;j++){
            if(t<s[j]) t=s[j];
            else if(t%f[j]==0);
            else t=t+f[j]-t%f[j];
            t+=c[j];
        }
        cout << t << endl;
    }
    cout << 0 << endl;
    return 0;
} 

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

int main() {
    int n; cin >> n;
    vector<int> t(n);
    int sum = 0;
    for (int& ti : t) cin >> ti, sum += ti;
    int m; cin >> m;
    while (m--) {
        int p, x; cin >> p >> x; p--;
        cout << sum - t[p] + x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include<string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b, c;
    cin >> a >> b >> c;
    if (a != b && b != c && a != c) {
        cout << 3 << endl;
    } else if ((a != b && a != c && b == c) || (a == b && a != c && b != c) || (a == c && b!= c && a != b)) {
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
using namespace std;

class osa_k{
private:
    vector<int> prime_sieve;
    vector<int> set_prime;
    int N;
    void eratosthenes(){
        for(int i=2;i*i<N;i++) {
            if(prime_sieve[i]<i) continue;
            for(int j=i*i;j<N;j+=i){
                if(prime_sieve[j]==j) prime_sieve[j] = i;
            }
        }                
    }

    void setPrimeSet(){
        for(int i=2;i<N;i++){
            if(prime_sieve[i]==i){
                set_prime.emplace_back(i);
            }
        }        
    }
public:    
    osa_k(const int n):N(n){
        prime_sieve.resize(n);
        iota(prime_sieve.begin(),prime_sieve.end(),0);
        eratosthenes();
        setPrimeSet();
    }

    //例えばi=8の時、{2,2,2}
    vector<int> getFactor(int i) {
        vector<int> res;
        while(i>1){
            res.emplace_back(prime_sieve[i]);
            i/=prime_sieve[i];
        }
        return res;
    }
    //例えばi=8の時、{2}
    vector<int> getFactorSet(int i){
        vector<int> res;
        while(i>1){
            res.emplace_back(prime_sieve[i]);
            i/=prime_sieve[i];
        }
        //重複を省く
        sort(res.begin(),res.end());
        decltype(res)::iterator result = unique(res.begin(), res.end());
        res.erase(result, res.end());
        return res;
    }
    //素数の集合を得る {2,3,5,7,11,...}
    vector<int> getPrimeSet(){
        return prime_sieve;
    }
    //iが素数:true
    bool isPrime(const int i){
        if((i==0)||(i==1)){
            return false;
        }
        if(prime_sieve[i]==i){
            return true;
        }
        return false;
    }
};



int main(){
    int n;cin>>n;
    osa_k o(1000005);
    vector<int> s(1000005);
    for(int i=1;i<=100000;i+=2){
        if(o.isPrime(i)&&o.isPrime((i+1)/2)){
            s[i]++;
        }
    }
    for(int i=1;i<=100003;i++){
        s[i]+=s[i-1];
    }

    for(int i=0;i<n;i++){
        int l,r;cin>>l>>r;
        cout<<s[r]-s[l-1]<<endl;
    }

    return 0;
}

Measured memory_bytes: 11552
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

// 条件を満たす最初の位置(存在しなければi1)を返す
template <class F>
int lower_bound(int i0, int i1, F f) {
    while (i0 < i1) {
        int i = (i0 + i1) / 2;
        if (f(i)) i1 = i; else i0 = i + 1;
    }
    return i0;
}

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

    int n, a, b;
    cin >> n >> a >> b;

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

    int c = a - b;
    int k = lower_bound(1, 1000000000, [&](int64_t k) {
        int64_t l = k;
        for (int i = 0; i < n; i++) {
            int64_t t = h[i] - b * k;
            if (t <= 0) continue;
            l -= (t + c - 1) / c;
            if (l < 0) return false;
        }
        // kが大きいほどtrueになる
        return true;
    });

    cout << k << endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
ll a[300005];
int main(){
    ll n;   
    boost;
    cin>>n;
    ll ac=0,wa=0,tle=0,re=0;
    while(n--){
    	string s;
    	cin>>s;
    	if(s=="AC")ac++;
    	if(s=="WA")wa++;
    	if(s=="TLE")tle++;
    	if(s=="RE")re++;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;	
    	
		
		
    
			
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
  cin >> a >> b >> c;
  int i = min(a,b);
  int cnt = 0;
  while(cnt >= 0)
  {
  if(a % i == 0 && b % i == 0)
  cnt++;
  if(cnt == c)
  {
  cout << i << endl;
    break;
  }
    i--;
  }
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
   vector<ll>d;
   ll key=0;
   string s;cin >>s;
   ll n=s.size();
   ll now=0;
    for (int i = 0; i < n; ++i) {
        if(s[i]-'0'==key){
            now++;
        }
        else {
            d.push_back(now);
            key=1-key;
            now=1;
        }
    }
    d.push_back(now);
    if(d.size()%2==1)d.push_back(0);
    ll l=0,r=0;
    ll ans=0;
//    for (int j = 0; j < d.size(); ++j) {
//        cout <<d[j]<<" ";
//    }
//    cout <<endl;
    for (int i = 0; i <d.size(); i+=2) {
        l+=d[i];
        r+=d[i+1];
        ll mint=min(l,r);
        ans+=mint*2;
        l-=mint;
        r-=mint;
    }
    cout <<ans <<endl;
}



Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int h, w, n; cin >> h >> w >> n;
    int a = max(h, w);
    cout << (n+a-1) / a << endl;
    
    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#define M 2000000

int N,S[M+1];
int left(int i){return i*2;}
int right(int i){return i*2 +1;}

void maxHeapify(int i){
  int l,r,lmax,swap;
  l = left(i);
  r = right(i);
  if(l <= N&&S[l]>S[i])
  {
  lmax = l;
  }
  else lmax = i;

  if(r <= N&& S[r]>S[lmax])
  {
    lmax = r;
  }
  if(lmax != i)
  {
    swap = S[i];
    S[i] = S[lmax];
    S[lmax] = swap;
    maxHeapify(lmax);
  }
}

int main(){
  int i;
  scanf("%d",&N);
for(i =1;i<=N;i++){
  scanf("%d",&S[i]);
  }
for(i=N/2;i>=1;i--){
  maxHeapify(i);
}
for(i = 1;i<=N;i++){
  printf(" %d",S[i]);
}
printf("\n");

return 0;
}

Measured memory_bytes: 2556
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <stdio.h>
#include <string.h>
#include <iomanip>
#include <set>
#include <list>
#include <map>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <cctype>

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define Mod 1000000007
#define PI 3.141592653589793238462643383279502884

using namespace std;

int dp[1000000];
int ar[1000000];
int solve(int n) {
	/*
	memset(dp, -1, n);
	dp[1] = ar[1];
	dp[2] = ar[2];
	for (int i = 3; i <= n; i++) {
		if (dp[i] != -1)
			return dp[i];
		else
			dp[i] = min(abs(ar[i] - ar[i + 1]), abs(ar[i] - ar[i + 2])) + dp[i - 1];
	}
	return dp[n];
	*/

	if (dp[n] != -1)
		return dp[n];
	if (n == 1)
		return dp[1] = 0;
	if (n == 2)
		return dp[2] = abs(ar[2] - ar[1]);
	else
		return dp[n] = min(abs(ar[n] - ar[n - 1]) + solve(n - 1), abs(ar[n] - ar[n - 2]) + solve(n - 2));
}



int main() {

	memset(dp, -1, 1000000);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> ar[i];
	}
	cout << solve(n) << '\n';
	system("Pause");
	return 0;
}

Measured memory_bytes: 6520
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int main() {
	int a, b, c, x, sum =0;
	cin >> a >> b >> c >> x;
	rep(i,a+1){
		rep(j, b+1){
			rep(k, c+1){
				if(i*500+j*100+k*50 ==x) sum++;
			}
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    int n, u, v[105], w[105];
    cin >> n >> u;
    for (int i = 0; i < n; i++) cin >> v[i] >> w[i];
    
    int dp[105][12005];
    for (int i = 0; i <= n; i++) {
        dp[i][0] = 0;
        for (int j = 1; j <= u; j++) dp[i][j] = -1;
    }
    for (int i = 0; i < n; i++) {
        for (int j = u; j >= 0; j--) {
            if (dp[i][j] != -1) dp[i + 1][j + w[i]] = max(dp[i][j] + v[i], dp[i][j + w[i]]);
            else dp[i + 1][j + w[i]] = dp[i][j + w[i]];
            dp[i + 1][j] = dp[i][j];
        }
    }
    
    int mx = 0;
    for (int i = 0; i <= u; i++) {
        mx = max(mx, dp[n][i]);
        //cout << i << " " << dp[n][i] << endl;
    }
    cout << mx << endl;

    
}



Measured memory_bytes: 7788
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //a
  char ch;
  cin >> ch;
  cout << (ch >= 'A' && ch <= 'Z' ? 'A' : 'a') << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

long long calc(long long l1, long long l2) {
    // l1 >= l2
    if (l1 % l2 == 0) {
        return l2 * ((l1 / l2) * 2 - 1);
    } else {
        return l2 * (l1 / l2) * 2 + calc(l2, l1 % l2);
    }
}

long long N, X;

int main(int argc, char **argv) {
    std::cin >> N >> X;

    long long ret = N + calc(std::max(X, N - X), std::min(X, N - X));

    std::cout << ret << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
n, y = map(int, input().split())
for y10000 in range(n + 1):
    for y5000 in range(n - y10000 + 1):
        y1000 = n - y10000 - y5000
        if 10000 * y10000 + 5000 * y5000 + 1000 * y1000 == y:
            print(y10000, y5000, y1000)
            exit()
print("-1 -1 -1")

Measured memory_bytes: 2940
# https://atcoder.jp/contests/dp/tasks/dp_l

'''
dp[i,j] ... dequeに[i,j]が残っているときに行動するプレイヤーのスコアの最大
dp[i,j] = max(a[i-1]-dp[i-1,j], a[j+1]-dp[i,j+1]) #これじゃgreedyと同じじゃん

dp[i,j] ... dequeに[i,j)が残っているときにその状態からスタートするプレイヤーが達成できるスコアの最大 (区間を伸ばしていく感じ)

初期値 dp[i,i]==0

dp[i,j]=max(a[i]-dp[i+1,j], a[j-1]-dp[i,j-1])
'''
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち

import numpy as np
from functools import partial
array = partial(np.array, dtype=np.int64)
zeros = partial(np.zeros, dtype=np.int64)
full = partial(np.full, dtype=np.int64)


def a_int(): return int(readline())


def ints(): return np.fromstring(readline(), sep=' ', dtype=np.int64)


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import

N = a_int()
A = ints()

dp = zeros((N + 1, N + 1))

from numba import njit


@njit('(i8,i8[:],i8[:,:])', cache=True)
def solve(N, A, dp):
    for i in range(N - 1, -1, -1):
        for j in range(i + 1, N + 1):
            dp[i, j] = max(A[i] - dp[i + 1, j], A[j - 1] - dp[i, j - 1])
    print(dp[0, N])
    # print(*dp, sep='\n')


solve(N, A, dp)


Measured memory_bytes: 157084
N,K,Q = map(int,input().split())
p = [0]*(N+1)
for i in range(Q):
  a = int(input())
  p[a] += 1
#print(p)
for i in range(1,N+1):
  if K-(Q-p[i]) <= 0:
    print("No")
  else:
    print("Yes") 

Measured memory_bytes: 4680
N, Y = map(int, input().split())
Y //= 1000

for x in range(N+1):
    if (-N - 9 * x + Y) % 4 == 0 and (5*N - Y + 5*x) % 4 == 0:
        y = (-N - 9 * x + Y) // 4
        z = (5*N - Y + 5*x) // 4
        
        if y >= 0 and z >= 0 and x + y + z == N and 10*x + 5 * y + z == Y:
            print(x, y, z)
            break
            
else:
    print(-1, -1, -1)

Measured memory_bytes: 3064
N, M = map(int, input().split())
ps = [input().split() for _ in range(M)]
passed = [0]*(N+1)
cnt = [0]*(N+1)
ac_num = 0
wa_num = 0

for p, s in ps:
  p = int(p)
  if s == "WA":
    cnt[p] += 1
  elif s == "AC" and passed[p] == 0:
    wa_num += cnt[p]
    ac_num += 1
    passed[p] = 1

print(ac_num, wa_num)


Measured memory_bytes: 68696
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i = 0; i < N; i++)
    cin >> h[i];
  vector<int> dp(N + K + 10);
  for (int i = 0; i < N + K + 10; i++)
    dp[i] = INT32_MAX;
  dp[0] = 0;
  for (int i = 0; i < N; i++)
  {
    for (int j = 1; j <= K; j++)
      dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
  }
  cout << dp[N - 1] << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int num;
  vector<int> array;
  for(int i = 0; i < N; ++i)
  {
    cin >> num;
    array.push_back(num);
  }
  sort(array.begin(), array.end());
  reverse(array.begin(), array.end());

  int min = 101;
  int cnt = 0;
  for(auto a : array){
    if(a < min){
      cnt++;
      min = a;
    }
  }
  cout << cnt << endl;
}


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

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] a = Input.ScanIntArray();
          
          Console.WriteLine(a[0]-a[1]+1);
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 11348
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int r = sc.nextInt();

		target = new int[r];

		for(int i = 0; i < r; i++){
			target[i] = sc.nextInt() - 1;
		}

		index = new int[r];
		used = new boolean[r];

		int matrix[][] = new int[n][n];

		for(int i = 0; i < n; i++){
			Arrays.fill(matrix[i], INF);
		}

		for(int i = 0; i < m; i++){
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			int c = sc.nextInt();

			matrix[a][b] = c;
			matrix[b][a] = c;
		}

		distAll = warshallFloyd(matrix);

//		for(int i = 0; i < n; i++){
//			for(int j = 0; j < n; j++){
//				System.out.print(distAll[i][j] + " ");
//			}
//			System.out.println();
//		}

		System.out.println(solve(0));
	}

	static int target[];
	static long distAll[][];
	static int index[];
	static boolean used[];

	static final int INF = Integer.MAX_VALUE;

	static long solve(int depth){
		if(depth == target.length){
			long result = 0;

			for(int i = 0; i < target.length - 1; i++){
				int from = target[index[i]];
				int to = target[index[i + 1]];
//				System.out.println("from "+from+" to "+to + " cost "+distAll[from][to]);
				result += distAll[from][to];
			}
//			System.out.println("result = "+result);
			return result;
		}

		long result = Long.MAX_VALUE;
		for(int i = 0; i < target.length; i++){
			if(used[i]){
				continue;
			}

			used[i] = true;
			index[depth] = i;
			result = Math.min(solve(depth + 1), result);
			used[i] = false;
		}

		return result;
	}


	static long[][] warshallFloyd(int[][] matrix){
		int n = matrix.length;

		long[][] dist = new long[n][n];

		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(i == j){
					dist[i][j] = 0;
				}
				else {
					dist[i][j] = matrix[i][j];
				}
			}
		}

		for(int k = 0; k < n; k++){
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					if(dist[i][k] == INF || dist[k][j] == INF){
						continue;
					}
					dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j]);
				}
			}
		}

		return dist;
	}
}

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

int main(){
    int n;
    cin >> n;
    int ans;
    if(n<10) ans = n;
    else if(n<100) ans = 9;
    else if(n<1000) ans = 9+(n-99);
    else if(n<10000) ans = 909;
    else if(n<100000) ans = 909+(n-9999);
    else ans=90909;
    cout << ans << endl;
return 0;
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  string s;
  cin>>s;
  int flag=0;
  if(s[0]=='A'){
    FOR(i,2,(int)s.size()-1){
      if(s[i]=='C') flag++;
    }
  }
  FOR(i,0,(int)s.size()){
    if(s[i]=='A'||s[i]=='C'||('a'<=s[i]&&s[i]<='z')){
    }
    else flag=2;
  }

  if(flag==1) cout<<"AC"<<endl;
  else cout<<"WA"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

ll Gcd(ll a,ll b){
    if(a < b)swap(a, b);

	if(a%b == 0)return(b);

	else return(Gcd(b, a%b));
}

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

    ll ans;
    rep(i, n){
        ll a;
        cin >> a;
        if(i == 0)ans = a;
        else ans = Gcd(ans, a);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		for(int i = 0 ; i < n ; i++) {
			h[i] = sc.nextInt();
		}

		// 最大の高さを覚えておく
		int maxH = h[0];
		int ans = 1;
		for(int i = 1 ; i < n ; i++) {
			int current = h[i];
			if(current >= maxH) {
				ans++;
				maxH = current;
			}
		}
		System.out.println(ans);
		sc.close();

	}

}


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

int main()
{ int a,b;
   while(~scanf("%d %d",&a,&b))
   {  if(a==2&&b==2)
         printf("Yes\n");
         else if(a==2||b==2)
            printf("No\n");
         else if((a==1||a==3||a==5||a==7||a==8||a==10||a==12)&&(b==1||b==3||b==5||b==7||b==8||b==10||b==12))
            printf("Yes\n");
         else if((a==4||a==6||a==9||a==11)&&(b==4||b==6||b==9||b==11))
           printf("Yes\n");
           else
            printf("No\n");
   }

    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<pi> vpi;
typedef vector<vpi> vpii;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<pd> vpd;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef std::string str;
typedef std::vector<str> vs;

#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"

const int MOD = 1000000007;
const ll INF = std::numeric_limits<ll>::max();
const int MX = 100101;
const ld PI = 3.14159265358979323846264338327950288419716939937510582097494L;

template<typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
template<typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
template<typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
template<typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }

template<typename T>
void print(vector<T> vec, string name = "") {
	cout << name;
	for (auto u : vec)
		cout << u << ' ';
	cout << '\n';
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	char ch;
	cin >> ch;
	cout << char(ch + 1) << endl;
}

/* Look for:
* special cases (n=1?)
* overflow (ll vs int?)
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* array bounds
*/


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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

const ll INF = 1LL << 60;

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 double PI=3.14159265358979323846;

int main() {
  double a,b,h,m;cin>>a>>b>>h>>m;
  double x=30*h+30*(m/60);
  double y=6*m;
  double dxy=abs(x-y);
  double angle=dxy*PI/180;
  double ans2=a*a+b*b-2*a*b*cos(dxy*PI/180);
  double ans=pow(ans2,0.5);
  cout<<fixed<<setprecision(12)<<ans<<endl;
}



Measured memory_bytes: 4356
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
ll a[200005];
 
int main(){
    
		ll t;
		string a,b;
		cin>>a>>b;
		ll f=1;
		for(ll i=0;i<a.size();i++)if(a[i]!=b[i]) f=0;
		
		if(f)cout<<"Yes";
		else cout<<"No";
	
	
}


Measured memory_bytes: 3628
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long[] count = new long[100001];
        long sum = 0;
        for(int i=0; i<n; i++) {
            int a = Integer.parseInt(sc.next());
            sum += a;
            count[a]++;
        }
        int q = Integer.parseInt(sc.next());
        int[] b = new int[q];
        int[] c = new int[q];
        for(int i=0; i<q; i++) {
            b[i] = Integer.parseInt(sc.next());
            c[i] = Integer.parseInt(sc.next());
            sum -= b[i] * count[b[i]];
            sum += c[i] * count[b[i]];
            count[c[i]] += count[b[i]];
            count[b[i]] = 0;
            System.out.println(sum);
        }
        
    }
}


Measured memory_bytes: 62012
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    for (auto e: v) os << e << ",";
    os << "]";
    return os;
}

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// print floating-point number
// cout << fixed << setprecision(12) <<

// }}}

ll N, M;
ll a[100010];

void solve()
{
    priority_queue<ll> q;
    REP (i, N) q.push(a[i]);
    REP (i, M) {
        ll v = q.top();
        if (v == 0) break;
        q.pop();
        q.push(v/2);
    }
    ll ans = 0;
    while (!q.empty()) {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    REP (i, N) cin >> a[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
// 287644PV
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(6)<<(x)
const int mod = 1000000007;

void addSelf(int&x, int y)
{
    x+= y;
    if(x >= mod)
        x-=mod;
}
void subSelf(int&x, int y)
{
    x -= y;
    if(x < 0)
        x += mod;
}

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

int64_t power(int base, int expo)
{
    int64_t sol = 1;
    for (int i = 0; i <expo ; ++i) {
        sol *= base;
    }
    return sol;
}

bool compare1(pair<int,int> i,pair<int,int> j) // 1 < i < n
{
    return i.second < j.second;
}

bool compare2(pair<int,int> i, pair<int,int> j) //n > n-i > 1
{
    return i.first > j.first;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin >> n >> k;

    cout << ceil((double)(n-k)/(double)(k-1))+1;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,i,j,a=0,b=0,c=0,d=0;
    cin>>t;
    string s[t];
    for(i=0;i<t;i++)
    {
        cin>>s[i];
    }
    for(i=0;i<t;i++)
    {
        if(s[i].compare("AC")==0)
        a++;
        else if(s[i].compare("WA")==0)
            b++;
        else if(s[i].compare("TLE")==0)
            c++;
        else if(s[i].compare("RE")==0)
            d++;

    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;

return 0;
}



Measured memory_bytes: 6724
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] bArr = new int[n - 1];

        for (int i = 0 ; i < n - 1; i++) {
            bArr[i] = sc.nextInt();
        }

        int sum = 0;
        sum += bArr[0];
        for (int i = 1; i< n - 1; i++) {
            sum += Math.min(bArr[i - 1], bArr[i]);
        }
        sum += bArr[n - 2];

        System.out.println(sum);
    }


    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>

#define pii pair <int, int>
#define pb push_back
#define ll long long
#define ss second
#define ff first
#define N 500010

using namespace std;

int a, b;

int main()
{
	cin >> a >> b;
	
	if(a+b < 24)
		cout << a+b;
	else
		cout << a+b-24;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
using namespace std;

int main()
{
	string s;
	cin >> s;
	bool a[26];
	for (int i = 0; i < 26; i++) {
		a[i] = false;
	}
	for (int i = 0; i < s.size(); i++) {
		a[s[i] - 'a'] = true;
	}
	for (int i = 0; i < 26; i++) {
		if (!a[i]) {
			cout << (char)(i + 'a') << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;
}

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

int main(){
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater<char>());
  if(s<t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


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

    if(max(a,b) <= 8)P("Yay!");
    else P(":(");
    
	return  0;
}

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef unsigned long long ull ;
typedef long double ld ;

const ll MOD = 998244353, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

ll arrPow[1005] ;

int main()
{
    arrPow[0] = 0 ;
    for (ll i = 1; i <= 1000; i++) {
        arrPow[i] = ceil(pow(i, (ll)5)) ;
    }
    ll x, val, abVal, a, b, flag = 0 ;
    cin >> x ;

    for (int i = 0; i <= 1000; i++) {
        val = arrPow[i] - x ;
        a = i ;
        abVal = abs(val) ;
        for (int j = 0; j <= 1000; j++) {
            if (arrPow[j] == abVal) {
                if (val >= 0) {
                    b = j ;
                }
                else if (val < 0) {
                    b = -j ;
                }
                flag = 1 ;
                break ;
            }
        }
        if (flag)   break ;
    }
    cout << a << " " << b ;

    return 0 ;
}


Measured memory_bytes: 4104
from sys import stdin

N, K = [int(i) for i in stdin.readline().rstrip().split()]
x = [int(i) for i in stdin.readline().rstrip().split()]

ans = min((abs(x[0]) + abs(x[K - 1] - x[0])),
          (abs(x[K - 1]) + abs(x[0] - x[K - 1])))

for i in range(1, len(x) - K + 1):
    left = i
    right = i + K - 1

    letf_to_right = abs(x[left]) + abs(x[right] - x[left])
    right_to_left = abs(x[right]) + abs(x[left] - x[right])

    tmp = min(letf_to_right, right_to_left)

    if tmp < ans:
        ans = tmp

print(ans)


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define INF 1e9
#define st string
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define fopen freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define test(x) int t; cin >> t; while(t--) x();

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

void solve(){
    int x; cin >> x;
    if(x >= 500){
        int quin = x / 500;
        x -= quin*500;
        if(x >= 5 && x < 500){
            int cc = x / 5;
            cout << quin * 1000 + cc * 5;
            return;
        }
        cout << quin * 1000;
        return;
    }
    if(x < 500 && x >= 5){
        int cinc = x / 5;
        cout << 5 * cinc;
        return;
    }
    cout << 0 << endl;
}

int main(){
    fastio
    solve();
    return 0;
}

// 2000000000
// 20000000000


Measured memory_bytes: 3616
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long K = sc.nextLong();
		
		if(K % 2 == 0) {
			if(A - B > Math.pow(10, 18)) {
				System.out.println("Unfair");
			} else {
				System.out.println(A - B);
			}
		} else {
			if(B - A > Math.pow(10, 18)) {
				System.out.println("Unfair");
			} else {
				System.out.println(B - A);
			}
		}
	}
}


Measured memory_bytes: 25044
N,M = map(int,input().split())

s = [[] for _  in range(M)]
k=[0]*M

for i in range(M):
    temp = list(map(int,input().split()))
    k[i] = temp[0]
    s[i]= temp[1:]
    
p = list(map(int,input().split()))

cnt = 0

for i in range(1<<N):
    
    switch = []
    #各電球でOnのスイッチの数
    result =[0]*M
    
    #点灯しているスイッチを取得
    for j in range(N):
        if (i>>j&1):
            switch.append(j+1)
        else:
            continue
        

    #各ボタンの店頭している数をチェック
    for  w in range(len(switch)):
        temp = switch[w]
        for x in range(M):
            if s[x].count(temp)>0:
                result[x]+=1
                    
    flg =  True
    
    for u in range(M):
        if result[u]%2!=p[u]:
            flg = False
            
    if flg ==True:
        cnt+=1
        

print(cnt)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
	int n,a,b;
	int sol = 0;
	cin >> n;
	for(int i = 0;i < n;i++)
	{
		cin >> a >> b;
		sol+=b-a+1;
	}
	cout << sol << endl;
	return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

bool f[3010];
int A, B, C, D, E, F;
int sa = -1, sb = -1;

int main() {
	cin >> A >> B >> C >> D >> E >> F;
	A *= 100; B *= 100;
	f[0] = 1;

	rep(i, 3010) if (f[i]) {
		if (i + C < 3010) f[i + C] = 1;
		if (i + D < 3010) f[i + D] = 1;
	}

	rep(i, 40) {
		rep(j, 40) {
			if (i + j == 0) continue;
			int wa = i * A + j * B;
			if (wa > F) continue;
			int sg = min(F - wa, wa / 100 * E);

			while (!f[sg]) {
				--sg;
			}

			if (sa == -1) {
				sa = wa, sb = sg;
			} else {
				if (sg * (sa + sb) > sb * (wa + sg)) {
					sa = wa, sb = sg;
				}
			}
		}
	}
	cout << sa + sb << " " << sb << endl;

	return 0;
}

Measured memory_bytes: 256