akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import deque
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    N = int(input_raw[0])
    info_list = []
    for i in range(N):
        input_raw = read_func().strip().split()
        [x, y, h] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
        info_list.append((h, x, y))

    info_list.sort(reverse = True)
    for Cx in range(101):
        for Cy in range(101):
            pre_H = -1
            is_all_eq = True
            for info in info_list:
                x = info[1]
                y = info[2]
                h = info[0]
                if h == 0:
                    if pre_H - abs(Cx - x) - abs(Cy - y) > 0:
                        is_all_eq = False
                        break
                else:
                    H =  h + abs(Cx - x) + abs(Cy - y)

                    if pre_H == -1 or H == pre_H:
                        pre_H = H
                    else:
                        is_all_eq = False
                        break;
            if is_all_eq == True:
                break
        if is_all_eq == True:
                break

    print Cx, Cy, H

if __name__ == '__main__':
    main()


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

#define pb push_back
#define ff first
#define ss second

const long long MAXN = 1e5 + 21, inf = 1e18 + 21, LG = 20;

bool f[MAXN];
int n;
long long a[MAXN], dp[MAXN];

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
	cin >> a[i];
    
    sort(a + 1, a + n + 1);
    
    for (int i = 1; i <= n; i++)
	dp[i] = dp[i - 1] + a[i];

    f[n] = true;

    for (int i = n - 1; i > 0; i--) {
	if (dp[i] * 2 >= a[i + 1])
	    f[i] = f[i + 1];
	else
	    f[i] = false;
    }

    int ans = 0;
    for (int i = 1; i <= n; i++)
	ans += f[i];
    cout << ans << '\n';
    return 0;
}


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

typedef long long int ll;

#define endl '\n'


int main()
{

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

    ll A,B,C,D;

    cin>>A>>B>>C>>D;

    ll c1 = (A-1)/C;

    ll c2 = B/C;

    ll x = c2-c1+1;

    ll d1 = (A-1)/D;
    ll d2 = B/D;

    ll y = d2-d1+1;

    ll val = (C*D)/(__gcd(C,D));

    ll lch1 = (A-1)/val;
    ll lch2 = B/val;

    ll z = lch2-lch1+1;
    //cout<<x<<" "<<y<<endl;
    //cout<<val<<" "<<z<<endl;2
    cout<<(B-A+2)-(x+y-z)<<endl;

}


Measured memory_bytes: 256
/* Simplicity and Goodness */
 
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;

int f[10][10];

void solve()
{   
    int n;
    scn(n);

    for(int i=1; i<=n; i++) {
        string here = to_string(i);
        int l = here[0] - '0';
        int r = here.back() - '0';
        f[l][r] ++;
    }    

    ll ans = 0;

    for(int l=1; l<10; l++) {
        for(int r=1; r<10; r++) {
            ans += 1LL * f[l][r] * f[r][l];
        }
    }

    lprin(ans);
}

int main()
{
    int t = 1;
    // scn(t);

    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3824
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

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

#define INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-8)
#define PI (acos(-1))32
const ll MOD = 1000000007ll;

int main() {
	ll x;
	cin >> x;
	
	ll l = -1, r = 1e8;
	
	while (r - l > 1) {
		ll m = (r + l) / 2;
		if (m * (m + 1) / 2 >= x) r = m;
		else l = m;
	}
	cout << r << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
int n,k;
const int P=1e9+7;
inline int add(int a,int b)
{
	return (a + b)>=P?(a+b-P):(a+b);
}
inline int mul(int a,int b)
{
	return 1LL * a * b % P;
}
int fpow(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)
			res=mul(res,a);
		b>>=1;
		a=mul(a,a);
	}
	return res;
}
const int MAXN=32000;
int f[2][MAXN<<1],sum[101][MAXN<<1];
int t=0,L[MAXN<<1],R[MAXN<<1];
int mx(int x)
{
	x=n/x;
	int l=1,r=t,ans=1;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(L[mid]<=x)
			ans=mid,l=mid+1;
		else
			r=mid-1;			
	}
	return ans;
}
int main()
{
	n=read(),k=read();
	for(int l=1,r;l<=n;l=r+1)
	{
		r=n/(n/l);
		L[++t]=l;
		R[t]=r;
	}
	int id=0;
	f[0][1]=1;
	for(int i=1;i<=t;++i)
		sum[0][i]=1;
	for(int i=1;i<=k;++i)
	{
		id^=1;
		sum[id][0]=0;
		for(int j=1;j<=t;++j)
		{
			int k=mx(L[j]);
			f[id][j]=mul(R[j]-L[j]+1,sum[id^1][k]);
			sum[id][j]=add(sum[id][j-1],f[id][j]);
		}
	}
	cout<<sum[id][t]<<endl;
	return 0;
}


Measured memory_bytes: 1792
Printf.printf "%d\n" @@ Scanf.scanf "%s" @@ fun s ->
  let t = Array.init (String.length s) (fun i -> s.[i]) in
  let x = Array.fold_left (fun z c -> z + (int_of_char c - 48) mod 10) 0 t in
  (int_of_char s.[0] - 49) + (9 * (String.length s - 1)) |> max x

Measured memory_bytes: 384
n = int(input())
a = list(map(int,input().split()))
dp = [0]*n
dp[0] = 1000
for i in range(1,n):
  dp[i] = dp[i-1]
  for j in range(i):
    kabu = dp[j]//a[j]
    money = dp[j]+(a[i]-a[j])*kabu
    dp[i] = max(dp[i],money)
print(dp[-1])

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 100000000000000
#define N 610

double cnter;
vector<vector<ll>> dest(N,vector<ll>(N,0));
vector<ll> concnt(N,0);
vector<double> perc(N,0);
vector<double> tot(N,0);

int main(){
    ll n, m, s, t; cin >> n >> m;
    REP(i,m){
        cin >> s >> t;s--;t--;
        dest[s][t]=1;
        concnt[s]++;
    }
    perc[0]=1;
    REP(i,n)REP(j,n)if (dest[i][j]){
        perc[j]+= (double)perc[i]/concnt[i];
    }
    cnter = 0;
    REP(i,n-1) cnter+=perc[i];
    tot[n-1]=0;
    FORD(i,n-2,0){
        double cnt = 0;
        REP(j,n) if (dest[i][j]) cnt+=tot[j]+1;
        tot[i]=cnt/concnt[i];
    }
    /*REP(i,n) cout << perc[i] << " ";
    cout << endl;
    REP(i,n) cout << tot[i] << " ";
    cout << endl;*/
    double ans = cnter;
    REP(i,n){
        if (concnt[i]<=1) continue;
        vector<vector<double>> dell(n,vector<double>(2,0));
        REP(j,n)if (dest[i][j]){
            dell[j][0]=tot[j];
            dell[j][1]=j;
        }
        sort(dell.begin(),dell.end());
        dest[i][dell[dell.size()-1][1]]=0;
        concnt[i]--;
        cnter = 0;
        vector<double> ansl(n,0);
        ansl[n-1]=0;
        FORD(i,n-2,0){
            double cnt2 = 0;
            REP(j,n) if (dest[i][j]) cnt2+=ansl[j]+1;
            ansl[i]=cnt2/concnt[i];
        }
        dest[i][dell[dell.size()-1][1]]=1;
        concnt[i]++;
        //cout << i << " " << dell[dell.size()-1][1] << " " << cnter << endl;
        ans = min(ans,ansl[0]);
    }
    cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 3200
n=int(input())
l=[1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 7, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 8, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 7, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 9, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 7, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 8, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 7, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2]
for i in range(n):
    print(*l[:n-i-1])

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

int main() {
  int n,o,p;
  cin >>n;
  o = 1;
  p=2;
  if(n<3){
    cout <<n <<endl;
    return 0;
  }
  else{
    while(p<=n){
      p = p*2;
    }
  }
  cout <<p/2 <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,X;
  cin >> N>>X;
  vector<int> l(N);
  for (int i=0;i<N;i++){
    cin >> l.at(i);
  }
  
  int d=0;
  int c=1;
  for (int i=0;i<N;i++){
    d+=l.at(i);
    if(d<=X)c++;
    else break;
  }
  cout << c<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll n;

ll ans;

bool check(ll a) {
  bool c3 = false, c5 = false, c7 = false;
  while(a > 0) {
    if (a % 10  == 3) c3 = true;
    else if (a % 10 == 5) c5 = true;
    else if (a % 10 == 7) c7 = true;

    a /= 10;
  }
  return (c3 && c5 && c7);
}

void dfs(ll x) {
  if (x > n) {
    return;
  }
  dfs(x * 10 + 3);
  dfs(x * 10 + 5);
  dfs(x * 10 + 7);

  if(check(x)) ans ++;

  return;
}

int main(){
  cin >> n;

  dfs(0);
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define req(i,a,b) for(ll i=(a);i>=(b);--i)
#define name "a"
#define pb push_back
#define sz size()
#define ff first
#define ss second
#define xd '\n'
#define dc " "
typedef pair < ll , ll > ii;
const ll maxn = 1e5+7, oo = 1e18, base = 311, mod = 1e9+7;
const double PI = 3.141592654;
ll t, n, m, x[maxn], y[maxn], res, hang[maxn], cha[maxn];
ll goc(int i)
{
    if (i != cha[i])
        cha[i] = goc(cha[i]);
    return cha[i];
}
bool hopnhat(int x, int y)
{
    x = goc(x);
    y = goc(y);
    if (x == y)
        return false;
    if (hang[x] == hang[y])
        ++hang[x];
    if (hang[x] > hang[y])
        cha[y] = x;
    else cha[x] = y;
    return true;
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen(name".inp","r",stdin);
    //freopen(name".out","w",stdout);
    cin >> n >> m;
    rep (i, 1, m)
        cin >> x[i] >> y[i];
    rep (i, 1, n)
        hang[i] = 0, cha[i] = i;
    rep (i, 1, m)
    {
        if (hopnhat(x[i], y[i]))
            ++res;
    }
    cout << n - 1 - res;
}


Measured memory_bytes: 6684
#include<bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define rep(i,n) for(ll i=0;i<n;i++)
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;
// using namespace atcoder;

const ll mod=1000000007;//998244353;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n;
  cin >> n;
  vec t(30);
  t[0]=1;
  for(ll i=0;i<29;i++)t[i+1]=t[i]*2;
  ll m=t[n];
  multiset<ll,greater<ll>> s;//これから生まれるべきスライム
  for(ll i=0;i<m;i++){
    ll a;
    cin >> a;
    s.insert(a);
  }
  s.insert(-1);
  
  bool ok=true;
  multiset<ll,greater<ll>> b;//既に生まれたスライム
  ll c=*s.begin();
  b.insert(c);
  s.erase(s.lower_bound(c));

  for(ll i=0;i<n;i++){
    ll a=t[i];
    vec q;
    for(ll j=0;j<a;j++){
      ll c=*b.begin();
      b.erase(b.lower_bound(c));
      q.push_back(c);
      ll d=*s.upper_bound(c);
      if(d==-1){
        ok=false;
        break;
      }
      q.push_back(d);
      s.erase(s.lower_bound(d));
    }
    for(ll j=0;j<q.size();j++){
      b.insert(q[j]);
    }
    if(!ok)break;
  }
  if(ok)cout << "Yes" << endl;
  else cout << "No" << endl;

  //for(ll i=0;i<m;i++)cout << s[i] << " ";


  return 0;
}

Measured memory_bytes: 18720
import java.io.*;
import java.util.*;
 
public class Main {
 
	void submit() {

	    String C = nextString();
	    String C_before = C.substring(0, (C.length()-1)/2);
	    String C_after = C.substring(((C.length()+3)/2)-1, C.length());	    

        StringBuffer C_sb = new StringBuffer(C);
        StringBuffer C_bsb = new StringBuffer(C_before);
        StringBuffer C_asb = new StringBuffer(C_after);

        String C_rev = C_sb.reverse().toString();        
        String C_before_rev = C_bsb.reverse().toString();
        String C_after_rev = C_asb.reverse().toString();        

        String flg = "No";
        
        if(C.equals(C_rev) && C_before.equals(C_before_rev) && C_after.equals(C_after_rev)){
            flg = "Yes";
        }     
        out.println(flg);
	}
 
	void preCalc() {
 
	}
 
	void stress() {
 
	}
 
	void test() {
 
	}
 
	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}
 
	static final Random rng = new Random();
 
	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}
 
	public static void main(String[] args) throws IOException {
		new Main();
	}
 
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
 
	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}
 
	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
 
	int nextInt() {
		return Integer.parseInt(nextToken());
	}
 
	long nextLong() {
		return Long.parseLong(nextToken());
	}
 
	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n; 
	vector<ll> a, b;
	while( n-- ){
		ll x, y; cin >> x >> y;
		a.push_back(x+y);
		b.push_back(x-y);
	}
	cout << max(
		(*max_element( a.begin(), a.end() )) - (*min_element( a.begin(), a.end() )),
		(*max_element( b.begin(), b.end() )) - (*min_element( b.begin(), b.end() ))
	) << endl;
}

Measured memory_bytes: 6616
import sys
s = input()

if s=="SUN":
  print("7")
  sys.exit()

if s=="MON":
  print("6")
  sys.exit()

if s=="TUE":
  print("5")
  sys.exit()

if s=="WED":
  print("4")
  sys.exit()
  
if s=="THU":
  print("3")
  sys.exit()

if s=="FRI":
  print("2")
  sys.exit()
  
if s=="SAT":
  print("1")
  sys.exit()

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

int main()
{
    int size, count_ac = 0, inicio, fin, times, ans;
    cin >> size >> times;
    string word;
    cin >> word;
    vector<int> v_ac;
    for(int i = 0; i < word.length(); i++)
    {
        if(word[i - 1] == 'A' && word[i]=='C')
        {
            count_ac++;
            v_ac.push_back(count_ac);
        }
        else
            v_ac.push_back(count_ac);
    }
    for (int i = 0; i < times; i++ )
    {
        cin >> inicio >> fin;
        
        ans = v_ac[fin - 1] - v_ac[inicio - 1];
        cout << ans << endl;
    }

}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define vi vector<int>

using ll = long long;
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const ll DIV =1e9+7;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
inline ll inv(ll x, ll div){return pow(x, div - 2, div);}
#define chmax(a,b) a=max(a,b)
int gcj_out_cnt = 1;
#define gcj_put cout<<"Case #"<<gcj_out_cnt++<<": ";

/*Coding Space*/
ll a[1000001];
ll b[1000001];
tuple<ll,ll> c[1000001];
int main(){
  int n;  cin >> n;
  rep(i,n){
    cin >> a[i] >> b[i];
    c[i] = tuple<ll,ll>{-(a[i] + b[i]), i};
  }
  sort(begin(c),end(c));
  ll av = 0;
  ll bv = 0;
  rep(i,n){
    int value, index; tie(value,index) = c[i];
    if(i%2 == 0){
      av += a[index];
    }else{
      bv += b[index];
    }
    //cerr << index << endl;
  }
  cout << av - bv << endl;
}


Measured memory_bytes: 20800
#include <stdio.h>
int main(void) {
	long long a, b;
	scanf("%lld%lld", &a, &b);
	if ((a + b) % 2 == 1) {
		printf("IMPOSSIBLE\n");
		return 0;
	}
	else
		printf("%lld", (a + b) / 2);
	return 0;
}

Measured memory_bytes: 128
while True:
    try:
        n = int(input())
    except:
        break
    ans = 0
    table = [[a,b,c,d] for a in range(10) for b in range(10) for c in range(10) for d in range(10)]
    for abcd in table:
        ans += sum(abcd) == n
    print(ans)


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

int main()
{
  int A,B,C,D;cin>>A>>B>>C>>D;
  int bucket[101] = {0};

  for(int i = A; i < B+1; i++) {
    bucket[i] ++;
  }

  for(int i = C; i < D+1; i++) {
    bucket[i] ++;
  }

  int ans = 0;
  for (int i = 0; i < 101; i++) {
    if (bucket[i] == 2) {
      ans ++;
    }
  }

  if (ans > 0) cout << ans-1 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, m, n) for (int i = m; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];

    int c = 0;
    rep(i, n -2) repi(j, i+1, n-1) repi(k, j+1, n) {
        if (l[i] != l[j] && l[j] != l[k] && l[i] != l[k]) {
            int maxL = max(l[i], max(l[j], l[k]));
            if (maxL < l[i] + l[j] + l[k] - maxL) {
                c++;                
            }
        }
    }

    println(c)
    return 0;
}

Measured memory_bytes: 3628
S = input()
T = S.replace("RL", "$$")
devided_S = []
ans = [-1 if T[i] == "$" else 0 for i in range(len(S))]

while True:
    index = S.find("LR")
    if index == -1:
        devided_S.append(S)
        break
    devided_S.append(S[:index+1])
    S = S[index+1:]

more_than_0 = []
for block in devided_S:
    r, l = block.count("R"), block.count("L")
    
    if (r+l) % 2 == 0:
        for _ in range(2):
            more_than_0.append((r+l)//2)
    else:
        count_r = (r+l)//2 + (r > l)
        count_l = len(block) - count_r
        more_than_0.append(count_r)
        more_than_0.append(count_l)
        if max(r, l) % 2 == 0:
            more_than_0[-1], more_than_0[-2] = more_than_0[-2], more_than_0[-1]

more_than_0.reverse()
for n in ans:
    if n == -1:
        print(more_than_0.pop(), end=" ")
    else:
        print(n, end=" ")
print()


Measured memory_bytes: 101252
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < (int)n;i++)
#define repb(i, n) for(int i = (int)n;i >= 0;i--)
#define reps(i, m, n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i, m, n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
using namespace std;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[]) {
  int n,b;
  cin>> n>>b;
  if(n+b==15) cout<< "+"<<endl;

  else if(n*b==15) cout<< "*"<<endl;

  else  cout<< "x"<<endl;
}


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

using namespace std;

int a[15][15];
int c[15];
int main() {
 int n, m, x;

 cin >> n >> m >> x;

 for (int i = 0;  i < n; i++) {
    cin >> c[i];
    for (int j = 0; j < m; j++) {
        cin >> a[i][j];
    }
 }

 int ans = 1e9 * 2;
 for (int mask = 0; mask < (1 << n); mask++) {
    vector <int> curr(m, 0);
    int pr = 0;
    for (int i = 0; i < n; i++) {
        if ((1 << i) & mask) {
            pr += c[i];
            for (int j = 0; j < m; j++) {
                curr[j] += a[i][j];
            }
        }
    }
    bool f = true;
    for (int j = 0; j < m; j++) {
        if (curr[j] < x) {
            f = false;
            break;
        }
    }
    if (f) {
        ans = min(ans, pr);
    }
 }
 if (ans == 1e9 * 2) {
    cout << -1;
 }
 else
    cout << ans;
 return 0;
}


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

int main() {
 
  string S ;
  cin >> S ;
  int count = 0;
  for (int i = 0; i < S.size() ; i++) {
if (S.at(i) =='x') {
    count++;
    }
  }
 if(count <= 7){
  cout << "YES" << endl;
}else{
   cout << "NO" << endl;
 }
}

Measured memory_bytes: 256
void main()
{
    long n, k;
    rdVals(n, k);
    long[] h = n.rdCol;

    h.sort!"a < b";
    long[] diff = new long[n-1];
    foreach (i; 0 .. n-1)
    {
        diff[i] = h[i+1] - h[i];
    }

    long total = diff[0..k-1].sum;
    long result = diff[0..k-1].sum;
    foreach (i; k-1 .. n-1)
    {
        total += diff[i] - diff[i-k+1];
        result = min(result, total);
    }

    result.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

string s[1000];

int dist[1001][1001];

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

int mx[] = {-1,-1,1,1,-2,-2,-2,-2,-2,-1,0,1,2,2,2,2,2,1,0,-1};
int my[] = {-1,1,1,-1,-2,-1,0,1,2,2,2,2,2,1,0,-1,-2,-2,-2,-2};

int main(){
	int n,m,i,j;
	scanf("%d %d",&n,&m);
	int r1,c1,r2,c2;
	scanf("%d %d %d %d",&r1,&c1,&r2,&c2);
	r1--; r2--;c1--;c2--;
	for(i=0;i<n;i++){
		cin>>s[i];
	}
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			dist[i][j] = inf;
		}
	}

	dist[r1][c1] = 0;
	deque<ii> q;
	q.push_front(ii(r1,c1));
	while(!q.empty()) {
		ii front = q.front(); q.pop_front();
		int x = front.first, y = front.second;
		for(i=0;i<4;i++){
			int xbaru = x + dx[i], ybaru = y + dy[i];
			if(xbaru >= 0 && xbaru < n && ybaru >=0 && ybaru < m) {
				if(s[xbaru][ybaru] == '.' && dist[xbaru][ybaru] > dist[x][y]){
					dist[xbaru][ybaru] = dist[x][y];
					q.push_front(ii(xbaru, ybaru));
				}
			}
		}
		for(i=0;i<20;i++){
			int xbaru = x + mx[i], ybaru = y + my[i];
			if(xbaru >= 0 && xbaru < n && ybaru >=0 && ybaru < m) {
				if(s[xbaru][ybaru] == '.' && dist[xbaru][ybaru] > (dist[x][y] + 1)){
					dist[xbaru][ybaru] = dist[x][y] + 1;
					q.push_back(ii(xbaru, ybaru));
				}
			}
		}
	}

	if(dist[r2][c2] == inf){printf("-1\n");}
	else{printf("%d\n",dist[r2][c2]);}

	
	return 0;
};

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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;



int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	string s;
	cin >> s;

	if (s[1] == 'R') s[1] = 'B';
	else s[1] = 'R';

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<string.h>
using namespace std;
//const int sss[10] = { 0, 6, 5, 4, 3, 2, 1 };
struct DICE
{
	int f[8];
};
DICE dice[101];
DICE rin(DICE x,char a)
{
	int k[10];
	for (int i = 1; i < 7; i++)
	{
		k[i] = x.f[i];
	}
	switch (a)
	{
	case'N':
		x.f[1] = k[2];
		x.f[5] = k[1];
		x.f[6] = k[5];
		x.f[2] = k[6];
		break;
	case'E':
		x.f[3] = k[1];
		x.f[1] = k[4];
		x.f[4] = k[6];
		x.f[6] = k[3];
		break;
	case'S':
		x.f[2] = k[1];
		x.f[1] = k[5];
		x.f[5] = k[6];
		x.f[6] = k[2];
		break;
	case'W':
		x.f[1] = k[3];
		x.f[3] = k[6];
		x.f[6] = k[4];
		x.f[4] = k[1];
		break;
	}
	return x;
}
DICE yok(DICE x)
{
	DICE a = x;
	x.f[2] = a.f[3];
	x.f[3] = a.f[5];
	x.f[5] = a.f[4];
	x.f[4] = a.f[2];
	return x;
}

bool sen(DICE x, DICE y)
{
	for (int i = 1; i < 8; i++)
	{
		for (int q = 0; q < 4; q++)
		{
			for (int z = 0; z < 6; z++)
			{
				if (x.f[z + 1] != y.f[z + 1])break;
				if (z == 5)
					return true;
			}
			y=yok(y);
		}
		if (i != 1&&i!=6)
		{
			y = rin(y, 'W');
		}
		else y = rin(y, 'N');
	}
	return false;
}

int main()
{
	for (int i = 0; i < 6; i++)
	{
		cin >> dice[0].f[i + 1];
	}
	for (int i = 0; i < 6; i++)
	{
		cin >> dice[1].f[i + 1];
	}
	if (sen(dice[0], dice[1]))cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;

}

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    long long sum = 0;
    int small = 1e9;
    bool odd = 0;
    while (n--) {
        int tmp;
        cin >> tmp;
        sum += abs(tmp);
        small = min(abs(tmp), small);
        if (tmp < 0)
            odd = !odd;
    }
    if (odd) {
        sum -= 2 * small;
    }
    cout << sum;
}


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

using namespace std;
#define int long long
const int MOD = 1000000007;
vector<int> add(vector<int> X, int a) {
	X.push_back(a);
	int cur = 0;
	for (int b = 0; b < 61; b++) {
		int bit = (int)1 << b;
		for (int i = cur; i < X.size(); i++) {
			if (X[i] & bit) {
				for (int j = i + 1; j < X.size(); j++) {
					if (X[j] & bit) {
						X[j] ^= X[i];
					}
				}
				swap(X[i], X[cur]);
				cur++;
				break;
			}
		}
	}
	while (X.size() > 0 && X.back() == 0) X.pop_back();
	return X;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int T;
	cin >> T;
	while (T--) {
		int N;
		cin >> N;
		vector<int> A(N);
		int res = 0;
		for (int i = 0; i < N; i++) {
			cin >> A[i];
		}
		string S;
		cin >> S;
		vector<int> X;
		for (int i = N - 1; i >= 0; i--) {
			vector<int> Y = add(X, A[i]);
			if (S[i] == '0') {
				X = Y;
			} else {
				if (Y.size() > X.size()) {
					res = 1;
					break;
				}
			}
		}
		cout << res << "\n";
	}
	return 0;
}

Measured memory_bytes: 3660
#include<cstdio>
#include<vector>
using namespace std;
vector<int>combination(int n,int from){
  if(n<=0){return vector<int>{0};}
  vector<int> result;
  for(int i=from;i<10;i++){
    for(int r:combination(n-1,i+1)){
      result.push_back(r+i);
    }
  }
  return result;
}
int main(){
  int n,s;
  while(scanf("%d %d",&n,&s)>0){
    if(!(n|s)){break;}
    int count =0;
    for(int a:combination(n,0))
      if(a==s) count++;
    printf("%d\n",count);
  }
}

Measured memory_bytes: 1040
my $N = <>;chomp $s;

if($N==1){
    print "0";exit;
}

my $mod = 10**9+7;

my $count =0;
my $non=8;
my $zero=1;
my $nine=1;

for($i=1;$i<$N;$i++){
    $count = ($count *10 + $zero + $nine)%$mod;
    $zero = ($zero*9 + $non)%$mod;
    $nine = ($nine*9 + $non)%$mod;
    $non  = ($non *8)%$mod;
}

print "$count";

Measured memory_bytes: 4680
import java.util.Scanner;

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

        String n = sc.next();
        int len = n.length();
        
        int numI = -1;
        boolean flg = false;
        for (int i = 1; i < len; i++) {
            if (n.charAt(i) != '9') {
                numI = n.charAt(i-1) - '0';
                flg = i != 1;
                break;
            }
        }
        int sum = 0;
        for (int i = 0; i < len; i++) {
            sum += n.charAt(i) - '0';
        }
        
        int ans;
        if (numI != -1) {
            ans = 9 * (len - 1) + numI - 1;
            if (flg) ans += -9 + n.charAt(0) - '0';
        } else {
            ans = 9 * (len - 1) + n.charAt(0) - '0';
        }
        System.out.println(Math.max(sum, ans));
    }
}

Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B, C;
	cin >> A >> B >> C;
	if(C-(A-B) > 0){
		cout << C - (A-B) << endl;
	} else {
		cout << 0 << endl;
	}
}


Measured memory_bytes: 256
#include <iostream> 
#include <cstdio> 
#define endl '\n' 
using namespace std; 

int a[100009] , cnt ; 

int main()
{ 
	int n ; cin >> n ; 
	for(int i = 0 ; i < n ; i++) cin >> a[i] ; 
	
	int q ; cin >> q ; 
	while(q--){ 
		int num ; cin >> num ; 
		
		int hi = n , lo = 0 , mid ; 
		while(hi - lo > 1){ 
			mid = (hi + lo) / 2 ; 
			
			if(a[mid] < num) lo = mid + 1 ; 
			else if(a[mid] >= num) hi = mid ; 
		}
		
		if(a[lo] == num) cnt++ ; 
		else if( a[hi] == num) cnt++ ;
	}
	
	cout << cnt << endl ; 
	return 0 ; 
}



Measured memory_bytes: 3460
#include <stdio.h>
#include <stdlib.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
typedef long long ll;

int main(void)
{
    int ans = 0;

    int n;
    scanf("%d", &n);

    int a[n];
    rep(i, n)
    {
        int tmp = 0;
        scanf("%d", &tmp);
        a[tmp - 1] = i + 1;
    }

    rep(i, n)
        printf("%d ", a[i]);

    return 0;
}

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

using namespace std;

typedef long long  ll;

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

    const int size = (int)('z' - 'a') + 1;
    string s;
    int k;

    cin >> s >> k;

    int idx = 0;
    while (k != 0) {
        if (idx == (int)(s.size() - 1)) {
            s[idx] = (char)(((int)(s[idx] - 'a') + k) % size + 'a');
            k = 0;
        }
        else {
            if (s[idx] != 'a') {
                int num = size - (int)(s[idx] - 'a');
                if (num <= k) {
                    k -= num;
                    s[idx] = 'a';
                }
            }
            ++idx;
        }
    }

    cout << s << endl;

    return 0;
}


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

typedef long long ll;

ll N, K;
vector<ll> a(1010);
vector<ll> v;

ll calc(ll k) {
    ll ret = 0;
    for (ll x : v) {
        if ((x & k) == k) {
            ret++;
        }
    }
    return ret;
}

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    for (int i = 0; i < N; i++) {
        ll sum = 0;
        for (int j = i; j < N; j++) {
            sum += a[j];
            v.push_back(sum);
        }
    }

    ll mask = 0;
    for (int i = 40; i >= 0; i--) {
        if (calc(mask | (1LL << i)) >= K) {
            mask |= (1LL << i);
        }
    }

    cout << mask << endl;
}


Measured memory_bytes: 6260
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define lld long double
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli h,n;
	cin>>h>>n;

	REP(i,0,n){
		lli a;
		cin>>a;
		h-=a;
		if(h<=0){
			cout<<"Yes"<<endl;
			return 0;
		}
	}

	cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<vector>
#include <queue>
using namespace std;
int main()
{
	int a, b;
	while (1) {
		cin >> a >> b;
		if (a == 0 && b == 0)break;
		int aa[5] = { a / 1000,(a / 100) % 10,(a / 10) % 10,a % 10,0 };
		int bb[5] = { b / 1000,(b / 100) % 10,(b / 10) % 10,b % 10,0 };
		int c = 0;
		int d = 0;
		if (aa[0] == bb[0]) {
			bb[0] = -1;
			c++;
		}
		if (aa[1] == bb[1]) {
			bb[1] = -1;
			c++;
		}
		if (aa[2] == bb[2]) {
			bb[2] = -1;
			c++;
		}
		if (aa[3] == bb[3]) {
			bb[3] = -1;
			c++;
		}
		if (aa[0] == bb[1]) {
			bb[1] = -1;
			d++;
		}
		if (aa[0] == bb[2]) {
			bb[2] = -1;
			d++;
		}
		if (aa[0] == bb[3]) {
			bb[3] = -1;
			d++;
		}
		if (aa[1] == bb[0]) {
			bb[0] = -1;
			d++;
		}
		if (aa[1] == bb[2]) {
			bb[2] = -1;
			d++;
		}
		if (aa[1] == bb[3]) {
			bb[3] = -1;
			d++;
		}
		if (aa[2] == bb[0]) {
			bb[0] = -1;
			d++;
		}
		if (aa[2] == bb[1]) {
			bb[3] = -1;
			d++;
		}
		if (aa[2] == bb[3]) {
			bb[3] = -1;
			d++;
		}
		if (aa[3] == bb[0]) {
			bb[0] = -1;
			d++;
		}
		if (aa[3] == bb[1]) {
			bb[1] = -1;
			d++;
		}
		if (aa[3] == bb[2]) {
			bb[2] = -1;
			d++;
		}
		cout << c << " " << d << endl;
		c = 0; d = 0;
	}
	
}


Measured memory_bytes: 3032
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n,z,w;
  cin>>n>>z>>w;
  int a[n+1]={};
  for(int i=1;i<=n;i++) cin>>a[i];
  if(n==1){
    cout<<abs(w-a[1])<<endl;
    return 0;
  }
  cout<<max(abs(w-a[n]),abs(a[n]-a[n-1]))<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <stack>
using namespace std;
static const int INF = 1e9+7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define PI 3.14159265359

int main(){
    int n; cin >> n;
    int arare[91] = {};
    rep(i, n){
        char ch; cin >> ch;
        arare[int(ch)] = 1;
    }
    int result = 0;
    rep(i, 91){
        result += arare[i];
    }
    if(result == 3){
        cout << "Three" << endl;
    }else{
        cout << "Four" << endl;
    }
    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
double pi=3.141592653589793;

const int MOD = 1000000007;

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

ll N,M;
vector<ll>A(106);

void batten(ll i,ll k){
	if(i==N)return;
	if((A[i]%k)>(A[i+1]%k)){
		swap(A[i],A[i+1]);
		batten(i+1,k);
		return;
	}else{
		batten(i+1,k);
		return;
	}
}

ll mapdata[310][310];
	
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll M;
	cin>>M;
	ll keta=0;
	ll sumdigit=0;
	for(int i=0;i<M;i++){
		ll d,c;
		cin>>d>>c;
		sumdigit+=d*c;
		keta+=c;
	}
	cout<<((sumdigit-1)/9)+keta-1<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x,y;
	cin>>x>>y;
	ll ans=0;
	if(x==1) ans+=300000;
	if(x==2) ans+=200000;
	if(x==3) ans+=100000;
	if(y==1) ans+=300000;
	if(y==2) ans+=200000;
	if(y==3) ans+=100000;
	if(x==1 && y==1) ans+=400000;
	cout<<ans<<endl;
}

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

int main()
{
  long int N,ans=1,l;
  long int *A;
  double ans_d=1.0,l_d;
  l=pow(10,18);
  l_d=pow(10,18);
  cin>>N;
  A=new long int[N];
  for(int i=0;i<N;i++)
  {
    cin>>A[i];
    if(A[i]==0)
    {
      cout<<0;
      delete[] A;
      return 0;
    }
  }
  for(int i=0;i<N;i++)
  {
    ans_d=ans_d*(double)A[i];
    ans=ans*A[i];
    if(ans_d>l_d)
    {
      cout<<-1;
      delete[] A;
      return 0;
    }
    if(ans>l)
    {
      cout<<-1;
      delete[] A;
      return 0;
    }
  }
   
  cout<<ans;
  delete[] A;
}

Measured memory_bytes: 3668
/*
Original problem: https://atcoder.jp/contests/abc135/tasks/abc135_d
Author: sammochen
*/

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)

#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef vector<ll> VLL;
typedef vector<int> VI;

const ll mod = 1e9+7;

namespace SOLVE {
	ll addto(ll& a, ll b) {
		a += b;
		if (a >= mod) {
			a -= mod;
		}
	}

    void main() {
        string s;
		cin >> s;
		int n = s.size();
		// dp[i][13] is the number after the ith string with rem 13
		VLL dp(13);

		dp[0] = 1;

		REP(i,0,n) { // each char
			VLL next(13);
			REP(rem,0,13) { // each rem
				if (s[i] == '?') {
					REP(digit, 0, 10) { // each unknown digit
						addto(next[(rem * 10 + digit) % 13], dp[rem]);
					}
				} else {
					int digit = s[i] - '0';
					addto(next[(rem * 10 + digit) % 13], dp[rem]);
				}
			}
			dp = next;
		}
		cout << dp[5];
    }
}


signed main() {
	int t;
	t = 1;
	// cin >> t;
	while (t--) {
		SOLVE::main();
	}

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, B, C, D; cin >> A >> B >> C >> D;
  int turn = 0;
  while(A > 0 && C > 0){
    if(turn%2 == 0){
      C -= B;
    }else{
      A -= D;
    }
    turn++;
  }
  if(A > 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3652
#include <cstdio>
#include <vector>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < int(n); ++(i))
using ll = long long;
using namespace std;

ll powmod(ll x, ll y, ll p) { // O(log y)
    assert (0 <= x and x < p);
    assert (0 <= y);
    ll z = 1;
    for (ll i = 1; i <= y; i <<= 1) {
        if (y & i) z = z * x % p;
        x = x * x % p;
    }
    return z;
}
ll inv(ll x, ll p) { // p must be a prime, O(log p)
    assert ((x % p + p) % p != 0);
    return powmod(x, p-2, p);
}
template <int mod>
int fact(int n) {
    static vector<int> memo(1,1);
    if (memo.size() <= n) {
        int l = memo.size();
        memo.resize(n+1);
        repeat_from (i,l,n+1) memo[i] = memo[i-1] *(ll) i % mod;
    }
    return memo[n];
}
template <int mod>
int choose(int n, int r) { // O(n) at first time, otherwise O(\log n)
    if (n < r) return 0;
    r = min(r, n - r);
    return fact<mod>(n) *(ll) inv(fact<mod>(n-r), mod) % mod *(ll) inv(fact<mod>(r), mod) % mod;
}

constexpr ll mod = 1e9+7;
int main() {
    int n, m, k; scanf("%d%d%d", &n, &m, &k);
    ll result = 0;
    if (n == 0) {
        result += powmod(3, m + k, mod);
    } else {
        ll y = 1;
        repeat_from (l, n, n+m+k+1) {
            ll x = choose<mod>(l-1, n-1);
            // ll y = 0;
            // int yl = max(0, l-n-k);
            // int yr = min(l-n, m) + 1; // [l, r)
            // repeat_from (i, yl, yr) {
            //     y += choose<mod>(l-n, i);
            // }
            // y %= mod;
            ll z = powmod(3, n+m+k-l, mod);
            result += x * y % mod * z % mod;
            // update
            y *= 2;
            if (l-n-k >= 0) y -= choose<mod>(l-n, l-n-k);
            if (m <= l-n) y -= choose<mod>(l-n, m);
            y %= mod;
            if (y < 0) y += mod;
        }
    }
    result %= mod;
    printf("%lld\n", result);
    return 0;
}


Measured memory_bytes: 5740
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
  int n, k;
  int ans = 0;
  

  scanf("%d%d", &n, &k);

  if(k == 1){
    ans = 0;
  }else if(n < k){
    ans = 0;
  }else{
    ans = n-k;
  }

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

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, ans=0;
	cin >> n;
	int a[n+1];
	for(int i=1;i<=n;i++){cin>>a[i];ans+=a[i];}
	for(int i=1;i<=n;i++){
		if(a[i]>=(ans-a[i])){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
 } 

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

risuto = [1]
for i in range(N):
    if (risuto[-1] + K > risuto[-1] * 2):
        risuto.append(risuto[-1] * 2)
    else:
        risuto.append(risuto[-1] + K)
        
print(max(risuto))

Measured memory_bytes: 3060
#include<iostream>
#include<string>

using namespace std;

const int N = 4;
const int N2 = 16;
const int LIMIT = 100;

const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
const char dir[4] = {'u', 'l', 'd', 'r'};

int MDT[N2][N2];

struct puzzle {
    int f[N2];
    int space;
    int MD;
};

puzzle state;
int limit;
int path[LIMIT];

int getAllMD(puzzle p) {
    int sum = 0;
    for (int i = 0; i < N2; i++) {
        if (p.f[i] == N2)continue;
        sum += MDT[i][p.f[i] - 1];
    }
    return sum;
}

bool dfs(int depth, int prev) {
    if (state.MD == 0)return true;
    if (depth + state.MD > limit)return false;

    int sx = state.space / N;
    int sy = state.space % N;
    puzzle tmp{};

    for (int r = 0; r < 4; r++) {
        int tx = sx + dx[r];
        int ty = sy + dy[r];
        if (tx < 0 || tx >= N || ty < 0 || ty >= N)continue;
        if (abs(prev - r) == 2)continue;
        tmp = state;
        state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
        state.MD += MDT[sx * N + sy][state.f[tx * N + ty] - 1];
        swap(state.f[sx * N + sy], state.f[tx * N + ty]);
        state.space = tx * N + ty;
        if (dfs(depth + 1, r)) {
            path[depth] = r;
            return true;
        }
        state = tmp;
    }

    return false;
}

string IDA(puzzle in) {
    in.MD = getAllMD(in);

    for (limit = in.MD; limit <= LIMIT; limit++) {
        state = in;
        if (dfs(0, -3)) {
            string ans;
            for (int i = 0; i < limit; i++)ans += dir[path[i]];
            return ans;
        }
    }
    return "unsolvable";
}

int main() {
    for (int i = 0; i < N2; i++) {
        for (int j = 0; j < N2; j++) {
            MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
        }
    }

    puzzle in{};

    for (int i = 0; i < N2; i++) {
        cin >> in.f[i];
        if (in.f[i] == 0) {
            in.f[i] = N2;
            in.space = i;
        }
    }

    string ans = IDA(in);
    cout << ans.length() << endl;

    return 0;
}



Measured memory_bytes: 3208