akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream&o,const pair<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
mt19937 rnd(random_device{}());

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
V<ll>fac,rfac; void setFac(int n,int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}

ll randInt(ll l,ll r){return uniform_int_distribution<ll>(l,r)(rnd);}
double randDouble(double l,double r){return uniform_real_distribution<double>(l,r)(rnd);}
void dout(double d){printf("%.12f\n",d);}

const double PI = acos(-1);
const double EPS = 1e-10;
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;

const int N = 1e3;
const int NN = 5e5;
int n, nn;
int _z[N][N];
VV<int> e;
inline int z(int a, int b){ return (a>b) ? _z[b][a] : _z[a][b]; }
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  nn = n*(n-1)/2;
  e.resize(nn);
  {
    int idx = 0;
    FOR(i, 0, n)FOR(j, i+1, n) _z[i][j] = idx++;
    FOR(i, 0, n){
      int p; cin >> p; p--;
      FOR(j, 0, n-2){
        int a; cin >> a; a--;
        e[z(i, p)].pb(z(i, a));
        p = a;
      }
    }
  }
  each(itr, e) uniq(*itr);

  int vc = 0, ans = 0;
  queue<int> q, q2;
  vector<int> c(nn, 0);
  for(int i=0; i<nn; i++) for(int a:e[i]) c[a]++;
  for(int i=0; i<nn; i++) if(!c[i]) q.push(i);
  while(!q.empty()){
    ans++;
    while(!q.empty()){
      int a = q.front(); q.pop();
      vc++;
      for(int b:e[a]){
        c[b]--;
        if(!c[b]) q2.push(b);
      }
    }
    swap(q, q2);
  }
  cout << (vc==nn ? ans : -1) << endl;
}

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

int main(void){
    int a[4];
    int b[4];
    int hit, blow;
    while(cin>>a[0]>>a[1]>>a[2]>>a[3]){
        cin>>b[0]>>b[1]>>b[2]>>b[3];
        hit=0;
        blow=0;
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                if(a[i]==b[j]){
                    if(i==j){
                        hit+=1;
                    }
                    else{
                        blow+=1;
                    }
                }
            }
        }
        cout<<hit<<" "<<blow<<endl;
    }
    return 0;
}



Measured memory_bytes: 3080
/* 
    @author : srinathbalaji_99
*/


#include<bits/stdc++.h>

#define PB push_back
#define MP make_pair
#define endl '\n'
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define rep(i, a, b, inc) for(long long i = a; i < b; i += inc)
#define REP(i, n) rep(i, 0, n, 1)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define PLL pair<long long, long long>
#define VL vector<long long>
#define VS vector<string>
#define VLL vector<PLL>
#define VVL vector<VL>
#define MPLL map<long long, long long>
#define UMPLL unordered_map<long long, long long>
#define SETL set<long long>
#define MSETL multiset<long long>
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) (a * b)/GCD(a, b)
#define ff first
#define ss second
#define pall(a) REP(i, sizeof(a)/sizeof(a[0]))cout << a[i] << " ";cout << endl;
#define pvall(v) REP(i, v.size())cout << v[i] << " ";cout << endl;
#define gall(a, n) REP(i, n)cin >> a[i];
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef unsigned long long ULL;
typedef long long LL;
typedef long double LD;


using namespace std;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main()
{
    fast();

    LL t,n,i,j,k,x,y,c,m;
    cin >> n;
    LL a[n];
    gall(a, n);
    LL maxx = *max_element(a, a + n);
    LL it = max_element(a, a + n) - a;
    LL secondmaxx = MIN;
    REP(i, n){
        if(i == it){
            continue;
        }
        secondmaxx = max(secondmaxx, a[i]);
    }
    REP(i, n){
        if(a[i] != maxx){
            cout << maxx << endl;
        }
        else{
            cout << secondmaxx << endl;
        }
    }
    
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
  cin>>n;
  vector<long long> v(n);
  bool isZero = false;
  for(int i=0; i<n; i++) {
    cin>>v[i];
    if(v[i] == 0) isZero = true;
}
  if(isZero) cout<<0<<endl;
  else {
    int64_t ans = v[0];
    for(int i=1; i<n; i++) {
    	if(v[i] > 1000000000000000000/ans) {
          ans = -1;
          break;
        }
      else {
      	ans *= v[i];
      }
    }
   cout<<ans<<endl; 
  }
}


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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type / Class / Struct Definitions:
using ll = long long;
using ull = unsigned long long;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    string s;
    cin >> s;
    rep(i, s.size()) {
        if(s[i] == 'h') {
            if(i + 1 < s.size() && s[i + 1] == 'i') {
                i++;
            } else {
                cout << "No" << endl;
                return 0;
            }
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256
# coding: utf-8
# Here your code !
employeeSalesList = []

def resetDataset():
    del employeeSalesList[0 : len(employeeSalesList) + 1]

def readDataCount():
    return int(input())

def searchEmployeeSales(employeeId):
    for data in employeeSalesList:
        if data[0] == employeeId:
            return data
    
    newData = [employeeId, 0]
    employeeSalesList.append(newData)
    return newData

def checkSales():
    employeeId, price, volume = list(map(int, input().split(" ")))
    employeeSales = searchEmployeeSales(employeeId)
    employeeSales[1] += price * volume

def printEmployeeOfDataset():
    found = False
    for data in employeeSalesList:
        if data[1] >= 1000000:
            print(data[0])
            found = True
    if not found:
        print("NA")

resetDataset()
dataCount = readDataCount()
while dataCount > 0:
    for _ in range(dataCount):
        checkSales()
    printEmployeeOfDataset()
    resetDataset()
    dataCount = readDataCount()

Measured memory_bytes: 7928
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    vector<P> a(n);
    rep(i, n){ cin >> a[i].first >> a[i].second;}
    int ans = 0;
    rep(i, n){
        ans += a[i].second - a[i].first +1;
    }
    cout << ans << endl;
}



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

hash = {
    'AC': 0,
    'WA': 0,
    'TLE': 0,
    'RE': 0,
}
for i in range(n):
    s = str(input())
    hash[s] += 1

print("AC x " + str(hash['AC']))
print("WA x " + str(hash['WA']))
print("TLE x " + str(hash['TLE']))
print("RE x " + str(hash['RE']))


Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define m 998244353
#define MAXN 50000 + 5
#define BLK_SIZE 225
using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define int ll 
#define all(arr) arr.begin() , arr.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i , a , n) for(int i = a ; i < n ; i++)
#define s(arr) sort(all(arr))
#define r(arr) reverse(all(arr))
#define rs(arr) s(arr) ; r(arr)
#define con continue
#define endl "\n"
 
//debug
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 
int modexpo(int a , int b)
{
    int res = 1;
    while(b)
    {
        if (b & 1)
            res = (res * a) % m;
        b = b / 2;
        a = (a * a) % m;
    }
    return res;
}

signed main()
{
    FAST;
    int n;
    cin >> n;
    vector<int> iden , a , b;
    rep(i , 0 , n)
    {
        int x;
        cin >> x;
        iden.pb(i + 1);
        a.pb(x);
    }
    rep(i , 0 , n)
    {
        int x;
        cin >> x;
        b.pb(x);
    }
    int s = 0;
    vector<int> foo;
    do{
        if (iden == a)
            foo.pb(s);
        if (iden == b)
            foo.pb(s);
        s++;
    }while(next_permutation(iden.begin(), iden.end()));
    cout << abs(foo[0] - foo[1]);
    return 0;
}


Measured memory_bytes: 256
s = input()
rls = [1]
c = 1

def limit(i, j):
  l = (i+1)//2 + j//2
  r = i//2 + (j+1)//2
  return ["0" for _ in range(i-1)] + [str(l), str(r)] + ["0" for _ in range(j-1)]

for i in range(len(s)-1):
  if s[i+1] == s[i]:
    rls[-1] += 1
  else:
    rls.append(1)
  
    
for i in range(len(rls)//2):
  temp = limit(rls[2*i], rls[2*i + 1])
  print(" ".join(temp), end = "")
  if i != len(rls)//2 - 1:
    print(" ",end="")


Measured memory_bytes: 60760
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  string s;
  cin>>s;
  cout<<s.substr(0,3)<<endl;
  return 0;
}


Measured memory_bytes: 3596
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
inline int read(){
	int x=0;char ch=getchar();
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x;
}
using i64 = long long;

const int N = 300000 + 7;

int n, q;
int v[N], w[N];
i64 f[520][N];
int x, c = 100000;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d%d", w + i, v + i);
	for (int i = 1; i <= n && i <= 512; ++i) {
		std::copy(f[i / 2], f[i / 2] + c + 1, f[i]);
		for (int j = c; j >= v[i]; --j)
			f[i][j] = std::max(f[i][j], f[i][j - v[i]] + w[i]);
	}
	scanf("%d", &q);
	while (q--) {
		std::function<i64(int, int)> get = [&](int x, int c) -> i64 {
			if (c < 0) return -1ll << 60;
			return x <= 512 ? f[x][c] : std::max(get(x / 2, c), get(x / 2, c - v[x]) + w[x]);
		};
		scanf("%d%d", &x, &c), printf("%lld\n", get(x, c));
	}
	return 0;
}



Measured memory_bytes: 407848
n=int(input())
l=list(map(int,input().split()))
con=l[0]-1

for i in range(n-1):
  con=max(con,l[i])
  if l[i]-l[i+1]>1:
    print("No")
    exit()
  if l[i]>l[i+1] and l[i+1]<con-1:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 20508
include Math
define_method :max, -> (a,b) { a > b ? a : b }
define_method :min, -> (a,b) { a < b ?  a : b }
define_method :swap, -> (a,b) { a, b = b, a }
define_method :rep, -> (num, &block) { num.times do |i| block.call(i) end }
define_method :repl, -> (st,en, &block) { st.upto en-1 do |i| block.call(i) end }
define_method :array, -> (size,init = nil) { Array.new(size){init} }
define_method :darray, -> (size1, size2, init = nil) { Array.new(size1){Array.new(size2){init}} }
define_method :gi, -> () { gets.split.map(&:to_i) }
define_method :gs, -> () { gets.chomp }
define_method :putall, -> (obj) { obj.each do |o| puts o end }
define_method :fi, ->() {first}


n = gi[0]

count = (n/11)*2 
amari = n%11

if amari > 6
	count += 2
elsif amari > 0
	count += 1
end


puts count


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
int W,a,b;
cin >> W >> a >> b;
if(max(a,b) -min(a,b) -W < 0){
cout << "0" << endl;
}else{
cout << max(a,b) -min(a,b) -W << endl;
}
return 0;
}

Measured memory_bytes: 256
A = list(map(int, input().split()))
A.sort()
B = A[2]-A[1]
A[0] += A[2]-A[1]

if (A[2] - A[0])%2 ==0:
  B += (A[2]-A[0])/2
else:
  B += (A[2]-A[0])//2+2
print(int(B))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debug(x) cout<<#x<<":"<<x<<" "
#define all(a) (a).begin(), (a).end()
#define cast static_cast
#define vi vector<int>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
typedef long long int ll;
using namespace std;
ll modF=1e9+7;
ll INF=1e11;

void solve(){
	int l,r,d;
	cin>>l>>r>>d;
	int ans=0;
	for(int i=l;i<=r;i++){
		if(i%d==0){
			ans++;
		}
	}
	cout<<ans<<"\n";
}	

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


Measured memory_bytes: 3648
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let _ = get!();
    let s = get().as_bytes();
    let mut tb = vec![0_i64; 26];
    for &ch in s.iter() {
    	let p = ch as usize - b'a' as usize;
        tb[p] += 1;
    }
    let m = 1_000_000_007;
    let mut ans = 1;
    for &x in tb.iter() {
    	if x > 0 {
        	ans = (ans * (x + 1)) % m;
        }
    }
    ans = (ans + m - 1)  % m;
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数


int main()
{
  int n ;
  double a ;
  cin >> n;
  
  if(n%2==0){
    a = n/2 ;
  }
  else{
    a = n/2+1 ;
  }
  
  cout << SP(10) << a/n <<endl ;


  return 0 ;
}

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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  string s;
  int a;
  cin >> s;
  for (int i = 0; i < 4; i++){
    if (s[i] == '+'){
      a++;
    }
    else{
      a--;
    }    
  }
  cout << a << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <algorithm>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>
#include <stack>
#include <limits>
#include <ctime>

using namespace std;

#define ll long long
#define sc(n) static_cast<ll>(n)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {
	IO;
#ifdef _DEBUG
	ifstream cin("In.txt");
#endif	
	ll n;
	unordered_map<ll, ll>mp;
	cin >> n;
	ll x;
	ll ans = 1;
	for (size_t i = 0; i < n; i++) {
		cin >> x;
		mp[x]++;
		if (mp[x] > 1) {
			ans = 0;
		}
	}
	cout<<(ans ? "YES":"NO")<<endl;
	return 0;
}

Measured memory_bytes: 8520
/*
 *
 */
#include <cstdio>
#include <iostream>

using namespace std;

int main(){
    //freopen("a4.in", "r", stdin);
    string s;
    cin >> s;
    bool nflag = false;
    bool eflag = false;
    bool wflag = false;
    bool sflag = false;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'N') {
            nflag = true;
        } else if (s[i] == 'E') {
            eflag = true;
        } else if (s[i] == 'W') {
            wflag = true;
        } else if (s[i] == 'S') {
            sflag = true;
        }
    }

    bool nsflag = (nflag && !sflag) || (!nflag && sflag);
    bool ewflag = (eflag && !wflag) || (!eflag && wflag);

    if (nsflag || ewflag) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
 public static void main(String[] args){
 Scanner s = new Scanner(System.in);
   String str = s.nextLine();
   int k =0;
   
   for(int i=0; i<str.length(); i++){
    if(str.charAt(i)=='0'){
    k++;
    }
   }
  System.out.print(2*Math.min(k, (int)str.length()-k));
   
 }
  
  
}

Measured memory_bytes: 27780
#include <bits/stdc++.h>
#include <algorithm>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

namespace search {
    bool binary_search(int x, vector<int> k) { int i, l = 0, r = k.size(); while (r - l >= 1) { i = (l + r) / 2; if (i == x) return true; else if (i < x) l = i + 1; else r = i; } return false; }
}

using namespace search;

int N, Y;

void solve() {
    for (int i = 0; 2000 >= i; i++) {
        for (int j = 0; 2000 >= j; j++) {
            if (10000 * i + 5000 * j + (N - i - j) * 1000 == Y && N - i - j >= 0) {
                cout << i << " " << j << " " << N - i - j << endl;
                return;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return;
}

int main(){
    cin >> N >> Y;
    solve();
    return 0;
}


Measured memory_bytes: 256
t = gets.chop.chars
q = []
t.each.with_index do |c, idx|
  case c
  when 'P', 'D'
    q << c
  when '?'
    prev = q.last
    case prev
    when 'P'
      q << 'D'
    else
      n = t[idx+1]
      case n
      when 'P', nil
        q << 'D'
      when 'D'
        q << 'P'
      else
        q << 'P'
      end
    end
  end
end
puts q.join

Measured memory_bytes: 34796
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

int
main(void){
  int n;
  string s;
  cin >> n >> s;

  int c = 0;
  int max = 0;
  for(int i=0; i<n; i++){
    if(s[i] == 'I'){
      c++;
      if(c > max){
	max = c;
      }
    }else if(s[i] == 'D'){
      c--;
    }else{

    }
  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
main()
{
        char table[201], work[201];
        int s, i, h;
        while(1){
                scanf("%s", table);
                if(table[0] == '-'){
                        break;
                }
                scanf("%d", &s);
                for(i = 0; i < s; i++){
                        scanf("%d", &h);
                        strcpy(work, table + h);
                        *(table + h) = '\0';
                        strcat(work, table);
                        strcpy(table, work);
                }
                printf("%s\n", table);
        }
}

Measured memory_bytes: 1796
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
void rle(string s,vector<char> &cha,vector<ll> &num){
    ll a=0,cnt=0;
    string t;char x=s[0];
    while(a<s.size()){
        if(x==s[a])cnt++;
        else{
            cha.pb(x);num.pb(cnt);
            x=s[a];cnt=1;
        }
        a++;
    }
    cha.pb(x);num.pb(cnt);
}
int main(){
    string s;cin >> s;
    ll x,y;cin >> x >>y;
    vector<char> ch;
    vl num;
    rle(s,ch,num);
    vl lr,ud;ll tcnt=0;
    rep(i,num.size()){
        if(ch[i]=='T')tcnt+=num[i];
        else {
            if(tcnt==0)x-=num[i];
            else{
                if(tcnt%2==0)lr.pb(num[i]);
                else ud.pb(num[i]);
            }
        }
    }
    ll dx=0,dy=0;sort(all(lr));sort(all(ud));rev(all(lr));rev(all(ud));
    for(auto p:lr){
        if(x>dx)dx+=p;
        else dx-=p;
    }
    for(auto p:ud){
        if(y>dy)dy+=p;
        else dy-=p;
    }
    if(dx==x&&dy==y)cout <<"Yes" <<endl;
    else cout << "No" <<endl;
}

Measured memory_bytes: 384
n = int(input())
x = list(map(int, input().split()))
triangles = set()
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if x[i] != x[j] and x[i] != x[k] and x[j] != x[k]:
                if x[i] + x[j] > x[k] and x[i] + x[k] > x[j] and x[j] + x[k] > x[i]:
                    ans += 1
                    triangles.add((x[i], x[j], x[k]))
                    triangles.add((x[i], x[k], x[j]))
                    triangles.add((x[j], x[i], x[k]))
                    triangles.add((x[j], x[k], x[i]))
                    triangles.add((x[k], x[i], x[j]))
                    triangles.add((x[k], x[i], x[j]))
print(ans)


Measured memory_bytes: 97824
#include <iostream>
#include <vector>
using namespace std;
const int mod = 1e9 + 7;
 vector<int> pref_sum(3001);

 int sum_Q(int l, int r)
 {
    if(l > r) return 0;
    int a = pref_sum[r];
    if(l - 1 >= 0) a -= pref_sum[l - 1];
    return (a + mod) % mod;
 }
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;

    vector<int> dp(3001, 0);

   
    

    dp[1] = 1;

    for (int i = 1; i < n; ++i)
    {
        vector<int> newdp(3001, 0);
       

        pref_sum[0] = dp[0];
        for (int j = 1; j < 3001; ++j)
        {
            pref_sum[j] = pref_sum[j-1] + dp[j];
            pref_sum[j] %= mod;
        }

        if(s[i-1] == '>')
        {
            for (int j = 1; j <= i + 1; ++j)
            {
                newdp[j] += sum_Q(j, i);
                newdp[j] %= mod;
            }
        }
        else
        {
            for (int j = 1; j <= i + 1; ++j)
            {
                newdp[j] += sum_Q(1, j - 1);
                newdp[j] %= mod;
            }
        }

        dp = newdp;


    }

    int fin_ans = 0;


    for (int i = 0; i < 3001; ++i)
    {
         fin_ans += dp[i];
         fin_ans %= mod;
    }
    cout << fin_ans % mod;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
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; }

int main () {
  int n = in();

  auto f = [&](int x) {
    int cnt = 0;
    for (int i = 1; i <= x; ++i) {
      if (x%i == 0) cnt++;
    }
    return cnt == 8;
  };

  int ans = 0;
  for (int i = 1; i <= n; i+=2) {
    if (f(i)) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i <= k; i++)
#define SZ 100010
#define PB push_back
#define MEM(n, val) memset((n), val, sizeof(n))
#define INF 1000000000
#define F first
#define S second
#define MP make_pair
#define LL long long

int pic, n;
int ara[100010];


int main()  {
//    freopen("in.txt", "r", stdin);
    cin >> pic >> n;
    FOR(i, 0, n - 1)   {
        cin >> ara[i];
    }

    sort(ara, ara + n);
    vector<int> vv;
    FOR(i, 1, n - 1)   {
        vv.PB(ara[i] - ara[i - 1]);
    }
    sort(vv.begin(), vv.end());
    int ans = 0;
    int comp = n;

    FOR(i, 0, (int)vv.size() - 1)   {
        if(comp <= pic)    {
            break;
        }
        ans += vv[i];
        comp--;
    }
    cout << ans;

    return 0;
}
/**
*/


Measured memory_bytes: 1276
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        StringBuilder sb = new StringBuilder();
        sb.append(s.charAt(0));
        sb.append(s.length()-2);
        sb.append(s.charAt(s.length()-1));
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

vector<long long> divisor(long long n) {
    vector<long long> res;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i * i != n) {
                res.push_back(n / i);
            }
        }
    }
    sort(res.begin(), res.end());
    return res;
}

long long extgcd(long long a, long long b, long long &x, long long &y) {
    long long d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long n;
    cin >> n;
    n *= 2;
    auto d = divisor(n);
    long long ans = n - 1;
    for (long long a : d) {
        long long b = n / a;
        if (__gcd(a, b) != 1LL) {
            continue;
        }
        long long x, y;
        extgcd(a, b, x, y);
        x *= -1;
        debug(a, b, x, y, b * y - a * x);
        if (x > 0 && y > 0) {
            ans = min(ans, a * x);
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3788
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

void solve(){  
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	rep(i,0,n){
		cout<<s[i]<<t[i];
	}
	cout<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
#define MOD 100000000;
#define EPS 0.001
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
    string s;
    cin>>s;
    int ans = 0;
    for(auto l : s) if(l=='-') ans--; else ans++;
    cout<<ans;
}


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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<ll> siz;

    UnionFind(int N) : par(N),siz(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
        siz.assign(N,-1);
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        if(siz[rx]<siz[ry]) swap(rx,ry);
        siz[rx]+=siz[ry];
        par[ry] = rx; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

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

int main(){
  ll n,m;
  cin >> n >> m;
  UnionFind tree(n);
  vector<ll> a(m),b(m);
  for(int i=0;i<m;++i){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  ll su=n*(n-1)/2;
  vector<ll> ans;
  for(int i=0;i<m;++i){
    ans.push_back(su);

    ll A=a[m-1-i];
    ll B=b[m-1-i];
    if(tree.same(A,B)){
      continue;
    }else{
      ll sa=tree.size(A);
      ll sb=tree.size(B);
      //cout << sa << " " << sb << endl;
      su-=sa*sb;
      tree.unite(A,B);
    }
  }
  reverse(ans.begin(),ans.end());
  int si=ans.size();
  for(int i=0;i<si;++i){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 8052
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size)scanf("%d",&(name)[i])

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI2(N,K);
    print(N%K==0?0:1);
    return 0;
}

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


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var ans = "Yes";
        var tmp = a[0] ^ a[1];
        for (int i = 2; i < a.Length; i++)
        {
            tmp = tmp ^ a[i];
        }
        
        if(tmp != 0) ans ="No";
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 38220
int main(void)
{
  int a, b, x;
  scanf("%d %d", &a, &b);
  if(a >= b){
    x += a;
    if(a-1 >= b) {
      x += a-1;
    } else {
      x += b;
    }
  } else {
    x += b;
    if(a >= b-1) {
        x += a;
    } else {
        x += b-1;
    }
  } 
  printf("%d",x);
  return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include<numeric>
#include<cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
#define N 1500000
const long long mod=1e9+7;
const int INF=1001001001;
//const int inf=100000;
//const ll ful=1e18;
using namespace std;
//namespace mp = boost::multiprecision;
int main() 
{
	int x;
	cin>>x;
	int lim=1500000;
	bool flag;
	for(int i=x;i<N;++i)
	{
		flag=true;
		for(int j=2;j*j<i;++j)
		{
			if(i%j==0)
			{
				flag=false;
			}
		}
		if(flag)
		{
			cout<<i;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (int i=0; i < n; i++)
		cin >> a.at(i);
	for (int i=0; i < n; i++)
		cin >> b.at(i);

	int sum=0;
	for (int i=0; i < n; i++)
	{
		if (a.at(i) > b.at(i))
			sum += a.at(i) - b.at(i);
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define SF scanf
#define PF printf
#define MAXN 10010
#define MOD 998244353
using namespace std;
typedef long long ll;
int dp[MAXN][MAXN];
char a[MAXN],b[MAXN];
int cnta,cntb;
ll fac[MAXN],ifac[MAXN];
ll ans;
ll fsp(ll x,int y){
	ll res=1;
	while(y){
		if(y&1)
			res=res*x%MOD;
		x=x*x%MOD;
		y>>=1;
	}	
	return res;
}
void prepare(){
	fac[0]=1;
	for(int i=1;i<=10000;i++)
		fac[i]=fac[i-1]*i%MOD;
	ifac[10000]=fsp(fac[10000],MOD-2);
	for(int i=10000;i>=1;i--)
		ifac[i-1]=ifac[i]*i%MOD;
}
ll C(int n,int m){
	return fac[n]*ifac[m]%MOD*ifac[n-m]%MOD;	
}
int main(){
	prepare();
	SF("%s%s",a,b);
	int len=strlen(a);
	for(int i=0;i<len;i++){
		if(a[i]=='1'){
			if(b[i]=='1')
				cnta++;
			else
				cntb++;
		}
	}
	dp[0][0]=1;
	for(int i=0;i<=cnta;i++)
		for(int j=1;j<=cntb;j++){
			if(i!=0)
				dp[i][j]=1ll*dp[i-1][j]*i%MOD*j%MOD;
			dp[i][j]=(dp[i][j]+1ll*dp[i][j-1]*j%MOD*j%MOD)%MOD;
		}
	//PF("{%d %d}\n",dp[0][1],dp[1][1]);
	for(int i=0;i<=cnta;i++){
		int les=cnta-i;
		//PF("{%d %lld %lld %lld}\n",dp[i][cntb],fac[les],C(cnta,les),C(cnta+cntb,les));
		ans=(ans+1ll*dp[i][cntb]*fac[les]%MOD*fac[les]%MOD*C(cnta,les)%MOD*C(cnta+cntb,les)%MOD)%MOD;
	}
	PF("%lld",ans);
}

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

int main(){
    int K;
    cin>>K;
    
    queue<ll> que;
    for(int i=1;i<10;++i)que.push(i);
    
    rep(i,K-1){
        ll x=que.front();
        que.pop();
        
        if(x%10!=0)que.push(x*10+x%10-1);
        que.push(x*10+x%10);
        if(x%10!=9)que.push(x*10+x%10+1);
    }
    
    ll ans=que.front();
    
    cout<<ans<<endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int64_t> A(N);
  double l = 0;
  for(int i=0; i<N; i++){
    cin >> A.at(i);
    l += A.at(i);
  }
  int64_t ans = 0;
  int64_t lh1 = 0;
  
  for(int i=0; i<N; i++){
    if(lh1 == l/2){
      cout << 0 << endl;
      return 0;
    }else if(lh1 < (l+1)/2){
      lh1 += A.at(i);
    }else{
      break;
    }
  }
  
  int64_t lh2 = 0;
  for(int i=N-1; i>=0; i--){
    if(lh2 == l/2){
      cout << 0 << endl;
      return 0;
    }else if(lh2 < (l+1)/2){
      lh2 += A.at(i);
    }else{
      break;
    }
  }
  
  int64_t lh;
  if(lh1<lh2) lh = lh1;
  else lh = lh2;
  
  ans = abs(2*lh - l);
  cout << ans << endl;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using static Assistant.Input;
using System.Linq;
using Assistant;

namespace ABC150A
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = ReadInt;
            var X = ReadInt;
            if (K * 500 >= X) Console.WriteLine("Yes");
            else Console.WriteLine("No");



        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] NextLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        //drawmap
        //drawarray
    }
}


Measured memory_bytes: 11220
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }


/*
<url:https://onlinejudge.u-aizu.ac.jp/services/room.html#RitsCamp18Day3/problems/D>
問題文============================================================

 えびちゃんは素因数分解マシンの不良品を持っています。
 この機械は、2 以上の自然数 M を与えると O(logM) でその素因数分解を行ってくれますが、
 困ったことに数字以外を表示できないバグがありました。
 
 一般に、M の素因数分解が p1e1×p2e2×…×pKeK (ただし i<j ならば pi<pj、また各 pi は素数) の場合を考えます。
 M を与えると、この機械は i=1 から順に以下のように出力を行います。全ての数字はスペース区切りで表示されます。
 
 ei=1 ならば pi を出力する
 ei>1 ならば pi ei を出力する
 
 たとえば、22 や 2048 を与えると 2 11 と表示され、24 や 54 を与えると 2 3 3 と表示されます。
 
 さて、えびちゃんは表示された素因数分解をメモしておいたのですが、
 与えた自然数をメモしておくのを忘れていたことに気づきました。
 素因数分解のメモが与えられるので、元の自然数としてありえるものがいくつあるかを求めてください。
 ただし、メモが間違っていて、条件を満たす自然数が一つも存在しないこともあります。
 
 また、その個数は非常に大きくなる場合があるので、109+7 (素数) で割ったあまりを出力してください。
 
=================================================================

解説=============================================================

================================================================
*/

#define MAX_N 1000005
bool is_prime[MAX_N];
const ll MOD = 1e9+7;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0){
            return false;
        }
    }
    return true;
}

void init(){
    for(int i = 1; i < MAX_N;i++){
        is_prime[i] = IsPrime(i);
    }
}
ll solve(){
    ll N; cin >> N;
    vector<ll> q(N);
    for(auto& in:q)cin >> in;

    if(!is_prime[q[0]]) return 0;

    int cnt = 0;
    for(int i = 0; i < N;i++){
        if(!is_prime[q[i]]) cnt++;
        else cnt = 0;
        if(cnt == 2) return 0;
    }

    vector<ll> dp(N+1,0);
    dp[0] = 1;
    for(int i = 0; i < N;i++){
        if(is_prime[q[i]]){
            if(i+1 == N || is_prime[q[i+1]] && (q[i] < q[i+1])){
                (dp[i+1] += dp[i])%=MOD;
            }
            if(i+2 == N || is_prime[q[i+2]] && (q[i] < q[i+2])){
                (dp[i+2] += dp[i])%=MOD;
            }
        }
    }
    return dp[N]%MOD;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    init();
    cout << solve() << endl;
	return 0;
}



Measured memory_bytes: 5480
#include <iostream>


using namespace std;
int main() {
  int n;
  string num;
  int sum = 0;

  cin >> n;
  num = to_string(n);
  for(int i = 0; i < (int)num.size(); ++i){
      int ind = num[i] - '0';
      sum += ind;
  }

  if (n % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
from math import atan, degrees

a, b, x = list(map(int, input().split()))

ans = 0
if x > (a*a*b / 2):
    ans = atan(2*(a**2 * b - x)/a**3)
else:
    ans = atan(a*b**2 / (2*x))

print(degrees(ans))


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

typedef long long ll;
#define rep(i,n) for( ll (i)=0; (i)<(n); ++(i) )
#define rpi(i,n) for( int (i)=0; (i)<(n); ++(i) )
#define rpv(d) for(auto& v:d)
#if __cplusplus < 201703L
  std::ostream& co_(){ return std::cout << std::endl; }
  std::istream& cn_(){ return std::cin; }
  template<class Head, class... Args>
  std::ostream& co_( Head&& head, Args&&... args ){ std::cout << head; return co_(std::forward<Args>(args)...); }
  template<class Head, class... Args>
  std::istream& cn_( Head&& head, Args&&... args ){ std::cin >> head; return cn_(std::forward<Args>(args)...); }
#else
  template<class... Args>
  std::ostream& co_( Args... args ){ return std::cout << ... << args << std::endl; }
  template<class... Args>
  std::istream& cn_( Args... args ){ return std::cin >> ... >> args; }
#endif
#define co(...) co_(__VA_ARGS__);
#define cn(...) cn_(__VA_ARGS__);
#define all(x) (x).begin(), (x).end()
#define rgt(x,i) (x).begin(), (x).begin()+(i)

int main(){
  string s;cn(s)
  vector<ll> up(s.length());
  vector<ll> st(s.length());
  rep(i,s.length()){
    int t = s[s.length()-i-1] - '0';
    if (i){
      up[i] = min( up[i-1] + 10-(t + 1), st[i-1] + 10-t );
      st[i] = min( up[i-1] + (t + 1), st[i-1] + t );
    }else{
      up[i] = 10-t;
      st[i] = t;
    }
  }
  co(
    min(up[s.length()-1]+1,st[s.length()-1])
  )
}

Measured memory_bytes: 17028
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;
import std.numeric;

void solve()
{
    char['z'+1] t; t[' ']=' ';
    auto s = readln().chomp();
    foreach(a;1..26)
        if(gcd(a,26)!=1) continue;
        else
            foreach(b;0..26)
            {
                foreach(i,v;iota(26).map!(y=>(a*y+b)%26).array())
                    t[v+'a']=cast(char)(i+'a');
                auto r = s.map!(c=>t[c]).array();
                if(r.split().any!(w=>w=="that"||w=="this"))
                { writeln(r);return; }
            }
}

void main()
{
    foreach(_;0..readln().chomp().to!int()) solve();
}

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

using namespace std;

#define llong long long 
int w,h;
int sum;
int area[50][50];
int nw[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int nh[8] = {1, 1, 0, -1, -1, -1, 0, 1};

void solve(int H, int W){
	if(area[H][W] == 0)return;
	area[H][W] = 0;
	for(int i = 0; i < 8; i++){
		int sh = H + nh[i];
		int sw = W + nw[i];
		if(sh < 0 || sw < 0 || sh >= h || sw >= w) continue;
		solve(sh, sw);
	}

	return;
}

int main(){

	while(cin >> w >> h, w){
		sum = 0;
		fill_n(*area, 50 * 50, 0);
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> area[i][j];
			}
		}	

		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(area[i][j] == 1){
					sum++;
					solve(i, j);
				}
			}
		}

		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3124
let () = Scanf.scanf "%d\n" @@ fun n ->
  let bs = Array.init (n - 1) @@ fun _ -> Scanf.scanf "%d " @@ fun b -> b in
  Printf.printf "%d\n" @@
  Array.fold_left ( + ) (bs.(0) + bs.(n - 2)) @@
  Array.init (n - 2) @@ fun i -> min bs.(i) bs.(i + 1)



Measured memory_bytes: 384