akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long int
main(){
    int n;
    cin >> n;
    int a[n];
    int cnt=0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt += a[i];
	}
	if (cnt % (n*(n + 1) / 2)) {
		cout << "NO" << endl;
		return 0;
	}
	int k = cnt / (n*(n + 1) / 2);
	int cnt2 = 0;
	for (int i = 0; i < n; i++) {
		int x = a[(i + 1) % n] - a[i];
		if (k < x) {
			cout << "NO" << endl;
			return 0;
		}
		if ((k - x) % n) {
			cout << "NO" << endl;
			return 0;
		}
		cnt2 += (k - x) / n;
	}
	if (cnt2 == k)cout << "YES" << endl;
	else cout << "NO" << endl;
    
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdbool.h>

bool is_lunlun(unsigned long int x) {
    bool ans = true;
    if (x / 10 > 0) {
        unsigned long int temp = x % 10;
        x = x /10;
        while (x > 0) {
            if (x % 10 != temp && x % 10 + 1 != temp && temp + 1 != x % 10) {
                ans = false;
                break;
            }
            temp = x % 10;
            x = x / 10;
        }
    }
    return ans;
}

int lb(int x) {
    if (x == 0) return 0;
    else return x-1;
}

int ub(int x) {
    if (x == 0 || x == 9) return 9;
    else return x+1;
}

unsigned long int answer(int i[]) {
    unsigned long int ans = 0;
    int j;
    for (j=0; j<10; j++) {
        ans = ans * 10 + (unsigned long int)i[j];
    }
    return ans;
}

bool judge(int i[]) {
    int j;
    for (j=0; i[j] == 0; j++) ;
    bool ans = true;
    int temp = i[j];
    for (j++; j < 10; j++) {
        if (temp-i[j] > 1 || temp-i[j] < -1) {
            ans = false;
            break;
        }
        temp = i[j];
    }
    return ans;
}

int main(void) {
    int k;
    scanf("%d", &k);

    int count = -1;
    int i[10] = {0};
    unsigned long int ans;

    for (i[0] = 0; i[0] <= 9; i[0]++) {
        for (i[1] = lb(i[0]); i[1] <= ub(i[0]); i[1]++) {
            for (i[2] = lb(i[1]); i[2] <= ub(i[1]); i[2]++) {
                for (i[3] = lb(i[2]); i[3] <= ub(i[2]); i[3]++) {
                    for (i[4] = lb(i[3]); i[4] <= ub(i[3]); i[4]++) {
                        for (i[5] = lb(i[4]); i[5] <= ub(i[4]); i[5]++) {
                            for (i[6] = lb(i[5]); i[6] <= ub(i[5]); i[6]++) {
                                for (i[7] = lb(i[6]); i[7] <= ub(i[6]); i[7]++) {
                                    for (i[8] = lb(i[7]); i[8] <= ub(i[7]); i[8]++) {
                                        for (i[9] = lb(i[8]); i[9] <= ub(i[8]); i[9]++) {
                                            if (judge(i)) count += 1;
                                            if (count == k) goto ANS;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    ANS:
        ans = answer(i);
        printf("%ld\n", ans);

    return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  string s[h];
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#')
        cout << '#';
      else {
        int count = 0;
        for (int k = max(i - 1, 0); k <= min(i + 1, h - 1); k++) {
          for (int l = max(j - 1, 0); l <= min(j + 1, w - 1); l++) {
            if (s[k][l] == '#') count++;
          }
        }
        cout << count;
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int main() {
	int n;
	string s1,s2;
	cin >> n >> s1 >> s2;
	for(int i = 0; i < 2*n; i++){
		if(i&1) cout << s2[i/2];
		else cout << s1[i/2];
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
#define MOD 1e9+7

int main(){
    ll a,b,x;
    cin >> a >> b >> x;
    ll ans=b/x-(a/x+1)+1;
    if(a%x==0) ans++;
    cout << ans << endl;
}

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

using namespace std;

using ll = long long;
using p  = pair<ll, ll>;
constexpr ll INF = 1LL << 62;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N, T;
    cin >> N >> T;
    
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    ll l = 0;
    ll r = 0;
    ll diff = 0;
    ll count = 0;
    while (r < N - 1) {
        r++;
        // cout << A[l] << ", " << A[r] << ": " << count << endl;
        if (A[l] > A[r]) {
            l = r;
        } else {
            ll d = abs(A[l] - A[r]);
            if (d > diff) {
                diff = d;
                count = 1;
            } else if (d == diff) {
                count++;
            }
        }
    }
    
    cout << count << endl;

    return 0;
}



Measured memory_bytes: 1024
a, b, n = map(int, input().split())
ans = 0
# floor(a * x / b)
# = floor(a * floor(x / b) + a * (x / b - floor(x / b)))
# = a * floor(x / b) + floor(a * (x / b - floor(x / b))))
print(int(a * min(b - 1, n) / b))


Measured memory_bytes: 9152
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, T;
    cin >> A >> B >> T;
    cout << B * floor((T + 0.5) / A) << "\n";
}

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

int main(){
  int x;
  cin>>x;
  string s;
  string h="HIT";
  string home="HOMERUN";
  string o="OUT";
  
  for(int j=0;j<x;j++){
    int count=0;
    int point=0;
    int r=0;

 
    for(int i=0;i<100;i++){
      cin>>s;
 
      if(s==h){
	r++;
	if(r==4){
	  point++;
	  r--;
	}
      }

      if(s==home){
	point++;
	point+=r;
	r=0;
      }

      if(s==o){
	count++;
	if(count==3)break;
      }
    }
      cout<<point<<endl;

    
  }
  }



Measured memory_bytes: 2988
import sys
import bisect
n,m=map(int,input().split())
l=[[int(i) for i in l.split()] for l in sys.stdin]
s=[[0] for i in range(10**5+1)]
for i in l:
  s[i[0]].append(i[1])
for i in range(len(s)):
  s[i].sort()
for i in l:
  print('{:06}{:06}'.format(i[0],bisect.bisect_left(s[i[0]],i[1])))

Measured memory_bytes: 35316
#include <iostream>
#include <vector>
#include <queue>
#include<map>
#include<algorithm>
#include<set>
#include<iomanip>
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1; i<=n;i++)
#define rrep(i,n) for(int i = n-1;i >=0;i--)
#define ALL(a) a.begin(),a.end()
#define PI  acos(-1)
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
typedef long long int ll;
typedef long double ld;
const int MOD = 1e9 + 7;
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 }, sum = 0,h,w;
int main() {
    int n,m=1; cin >> n;
    while (m <= n) {
        m *= 2;
    }cout << m/2 << endl;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -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; }

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 998244353;

const double PI = acos(-1.0);
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll N;
    cin>>N;
    vector<ll> D(N);
    rep(i,N){
        cin>>D[i];
    }
    if(D[0] !=  0){
        cout<<0<<endl;
        return 0;
    }
    rep1(i,N){
        if(D[i] == 0){
            cout<<0<<endl;
            return 0;
        }
    }
    //print(D);
    sort(all(D));
    rep(i,N-1){
        if(D[i+1]-D[i] >1){
            cout<<0<<endl;
            return 0;
        }
    }
    D.push_back(INF);
    int cnt = 1;
    vector<ll> CNT;
    rep(i,N){
        if(D[i] == D[i+1]){
            cnt++;
        }
        else{
            CNT.push_back(cnt);
            cnt = 1;
        }
    }
    //print(CNT);
    rep(i,CNT.size()){
        if(CNT[i] == 0){
            cout<<0<<endl;
            return 0;
        }
    }
    ll ans = 1;
    rep(i,CNT.size()-1){
        ans *= modpow(CNT[i],CNT[i+1],MOD);
        ans %= MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2800
n,k=map(int, input().split())
h_list=[]
min_df=0

for i in range(n):
  h_list.append(int(input()))

h_list.sort()

for j in range(n-k+1):
  if j == 0:
    min_df = h_list[k-1] - h_list[0]
  else:
    df = h_list[j+k-1] - h_list[j]
    if df < min_df:
      min_df = df

print(min_df)
    


Measured memory_bytes: 7384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, X, min, max;
  vector<int> answers;
  cin >> K >> X;
  
  min = X - K + 1;
  max = X + K - 1;
  
  for (int i=min; i <= max; i++){
    if (i >= -1000000 && i <= 1000000){
      cout << i;
      if (i  != max){
        cout << " ";
      }else {
        cout << "" << endl;
      }
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define debug(x) cout << #x << " = " << x << endl
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

double a,b;
int main()
{
	cin >> a>>b;
	
	double s=(a+b)/2;
	cout << abs(ceil(s-(0.4)));


}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  
  s += '.';
  vector<int> cur(10, n);
  vector<vector<int>> nex(n+1, vector<int>(10, n));
  for (int i=n-1; i>=0; --i) {
    nex.at(i) = cur;
    cur.at(s.at(i) - '0') = i;
  }
  
  int res = 0;
  for (int i=0; i<10; ++i) {
    for (int j=0; j<10; ++j) {
      for (int k=0; k<10; ++k) {
        if (s.at(nex.at(nex.at(cur.at(i)).at(j)).at(k)) != '.') ++res;
      }
    }
  }
  cout << res << endl;
  return 0;
}

            

Measured memory_bytes: 2432
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    intmax_t N;
    intmax_t ans = 0;

    scanf("%jd", &N);

    uintmax_t d[100] = {};
    for (size_t i = 1; i <= N; i++) {
        char s[7];
        size_t len;
        sprintf(s, "%zu", i);
        len = strlen(s);
        d[(s[0] - '0') * 10 + (s[len - 1] - '0')]++;
    }

    for (size_t i = 1; i <= 9; i++) {
        for (size_t j = i; j <= 9; j++) {
            // printf("%d\n", d[i * 10 + j]);
            if (i == j) {
                ans += d[i * 10 + j] * d[i * 10 + j];
            } else {
                ans += (d[i * 10 + j]) * (d[j * 10 + i]) * 2;
            }
        }
    }

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

    return 0;
}


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

int N;
int num[100010];

int main() {
	cin >> N;
	int Amax = 0;
	for (int i = 0; i < N; i++) {
		int a;  cin >> a;
		a++;
		num[a - 1]++;
		num[a + 2]--;
		Amax = max(a, Amax);
	}

	int ans = 0;
	for (int i = 1; i <= Amax + 2; i++) {
		num[i] += num[i - 1];
		if (num[i] > ans) {
			ans = num[i];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

ll power(ll a,ll n){ll ret=1;for(;n>0;n>>=1,a=a*a%MOD)if(n%2==1)ret=ret*a%MOD;return ret;}
ll comb(ll n,ll r){ll x=1,y=1;rep(i,0,r){x=x*(n-i)%MOD;y=y*(i+1)%MOD;}return x*power(y,MOD-2)%MOD;}

void solve() {
  VAR(int, N, M);
  print(comb(N, 2) + comb(M, 2));
}


Measured memory_bytes: 256
s=input()
t=input()

def mch(x,y):
    l=[False]*len(x)
    for i in range(len(x)):
        if x[i]=='?':l[i]=True
        elif x[i]==y[i]:l[i]=True
    return True if all(l) else False

l=[]
for i in range(len(s)-len(t)+1):
    if mch(s[i:i+len(t)],t):l.append((s[:i]+t+s[i+len(t):]).replace('?','a'))
print('UNRESTORABLE' if len(l)==0 else sorted(l)[0])

Measured memory_bytes: 3064
#include <stdio.h>


int field[100][100],Max;

void Move(int,int,int);

int main(){
  int m,n,i,j;
  
  while(1){
    scanf("%d",&m);
    scanf("%d",&n);
    if(m == 0 && n == 0) break;

    for(i = 0;i<m+2;i++){
      field[i][0] = 0;
      field[i][n+1] = 0;
    }
    Max = 0;
    for(i = 1;i<n+1;i++){
      field[0][i] = 0;
      field[m+1][i] = 0;
      for(j = 1;j<m+1;j++){
        scanf("%d",&field[j][i]);
      }
    }
    for(i = 1;i<n+1;i++){
      for(j = 1;j<m+1;j++){
        if(field[j][i] == 1) Move(j,i,0);
      }
    }

    printf("%d\n",Max);
  }
  return 0;

}
        
void Move(int m,int n,int count){
  count++;
  field[m][n] = 0;
  if (field[m+1][n] == 1) Move(m+1,n,count);
  if (field[m-1][n] == 1) Move(m-1,n,count);
  if (field[m][n+1] == 1) Move(m,n+1,count);
  if (field[m][n-1] == 1) Move(m,n-1,count);
  field[m][n] = 1;
  if(Max < count) Max = count;
}

Measured memory_bytes: 0
import math
n = int(input())
nn = 1
xl = []
yl = []
ll = 0
for i in range(n):
    x,y = map(int, input().split())
    xl.append(x)
    yl.append(y)
 
j = 0
while j < n-1:
    k = j+1
    while k <= n-1:
        ll += math.sqrt((xl[j]-xl[k])**2 + (yl[j] - yl[k])**2)
        k += 1
    j += 1
 
print(ll*2/n)

Measured memory_bytes: 8932
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int k;cin>>k;
	string s;cin>>s;
	int n=s.size();
	if(n<=k)cout<<s;
	else cout<<s.substr(0,k)<<"...";
	return 0;
}

Measured memory_bytes: 3588
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,m=sort(parseMap(split(readline())))
    mod=10^9+7
    npr=[1 for i in 1:10^5]
    for i in 2:10^5
        npr[i]=(npr[i-1]*i)%mod
    end
    ans=npr[n]*npr[m]
    if n+1<m
        ans=0
    elseif n==m
        ans*=2
    end
    println(ans%mod)
end
main()

Measured memory_bytes: 169336
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	int n; cin>>n;
	vector<pair<int,int>> vec(n);
	rep(i,0,n)cin>>vec[i].first>>vec[i].second;
	sort(all(vec));
	cout<<vec[n-1].first+vec[n-1].second<<endl;
	
	return 0;
}

Measured memory_bytes: 4052
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
const int N=3e5+10;
int tr[N],n,a[N],ans,b[N];
int check(int l,int r){
	vector<int> d[2];
	int mx=0,mn=1e9;
	for (int i=l;i<=r;i++){
		mx=max(mx,a[i]);
		mn=min(mn,a[i]);
		if (!b[i]){
			d[i<a[i]].push_back(a[i]);
//			d[i>a[i]].push_back(a[i]);
		}
	}
	for (int i=1;i<d[0].size();i++){
		if ((d[0][i-1]>d[0][i]))
			return 1;
	}
	for (int i=1;i<d[1].size();i++){
		if ((d[1][i-1]>d[1][i]))
			return 1;
	}
	return (mx!=r)||(mn!=l);
}
int main(){
	cin>>n;
	for (int i=1;i<=n;i++)scanf("%d",&a[i]),b[i]=(a[i]==i);
	for (int i=2;i<=n;i++){
		if (!b[i-1]&&!b[i]&&!b[i+1]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	int las=1;
	for (int i=1;i<=n;i++){
		if (b[i]==b[i+1]){
			if (check(las,i)){
				cout<<"No"<<endl;
				return 0;
			}
			las=i+1;
		}
	}
	if (las<=n){
		if (check(las,n)){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 3900
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;
using namespace std;

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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	ll N,X; cin >> N >> X;
	V<mp::cpp_int> x(N+1,0),y(N+1,0),z(N+1,LLINF);
	for(int i = 1; i <= N; ++i) cin >> x[i];
	for(int i = 1; i <= N; ++i) y[i] = y[i-1] + x[i];
	for(int i = N; 1 <= i; --i){
		z[i] = (y[N] - y[N-i]) + N*X + i*X;
		for(int j = N; 0 < j; j -= i){
			mp::cpp_int k = (N-j)/i + 1, cnt = 0; 
			if(j - i <= 0) cnt = y[j];
			else cnt = ((y[j] - y[j - i]) - (y[j - i] - y[max(j - 2*i,0)]));
			z[i] += cnt*(k + 1)*(k + 1);
		}	
	}
	mp::cpp_int ans = mp::cpp_int(1e30);
	for(int i = 1; i <= N; ++i) chmin(ans,z[i]);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 18944
#include<iostream>
#include<vector>
#include<string>
#include<cctype>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)

int search(vector<char> &v, char c){
    for(int i = v.size() - 1; i >= 0; i--){
        if(v[i] == c){
            int a = 0, b = 0;
            FOR(j, i + 1, v.size()){
                if(v[j] == '(') a++;
                else if(v[j] == '[') b++;
                else if(v[j] == ')'){
                    if(a <= 0) return -1;
                    else a--;
                }
                else if(v[j] == ']'){
                    if(b <= 0) return -1;
                    else b--;
                }
            }
            if(a == 0 && b == 0) return i;
            else return -1;
        }
    }
    return -1;
}

int main(){
    string str;
    while(getline(cin, str)){
        if(str == ".") break;
        bool OKflg = true;
        vector<char> v;
        REP(i, str.length()){
            if(str[i] == '(') v.push_back('(');
            else if(str[i] == '[') v.push_back('[');
            else if(str[i] == ')'){
                int tmp = search(v, '(');
                if(tmp == -1){
                    OKflg = false;
                    break;
                } else REP(j, v.size() - tmp + 1) v.pop_back();
            }
            else if(str[i] == ']'){
                int tmp = search(v, '[');
                if(tmp == -1){
                    OKflg = false;
                    break;
                } else REP(j, v.size() - tmp + 1) v.pop_back();
            }
        //debug
        //REP(i, (int)(v.size())) cout <<v[i] <<", "; cout <<endl;
        }
        if(OKflg && v.size() == 0) cout <<"yes" <<endl;
        else cout <<"no" <<endl;
    }
    return 0;
}

Measured memory_bytes: 1196
#include <iostream>

using namespace std;

int main()
{
   int a, b;
   cin >> a >> b;
   
   if (a == b)
       cout << "a == b" << endl; 
   else if (a > b)
       cout << "a > b" << endl;
   else
       cout << "a < b" << endl;
   
   return 0;
}


Measured memory_bytes: 3064
from sys import exit
N,M = [int(n) for n in input().split()]
Mat = [set() for _ in range(N)]#Nの隣接リスト
for i in range(M):
    a,b = [int(n) for n in input().split()]
    Mat[a-1].add(b-1)
    Mat[b-1].add(a-1)
N-=1
for ne in Mat[0]:
    # print(N,Mat[ne])
    if N in Mat[ne]:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")


Measured memory_bytes: 67668
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int N, D1, D2; vector<int> P, D;

	while (true)
	{
		cin >> N;

		if (N == 0) { break; }

		P = vector<int>(N);
		D = vector<int>(N);

		for (int i = 0; i < N; i++)
		{
			cin >> P[i] >> D1 >> D2;

			D[i] = D1 + D2;
		}

		int maxptr = distance(D.begin(), max_element(D.begin(), D.end()));

		cout << P[maxptr] << ' ' << D[maxptr] << endl;
	}

	return 0;
}

Measured memory_bytes: 3160
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int n;
string w[111];
map<string, int>mp;

int main() {
	cin >> n;
	REP(i, n) {
		cin >> w[i];
		if (mp[w[i]] >= 1) {
			cout << "No" << endl;
			return 0;
		}
		if (i) {
			if (w[i - 1][w[i - 1].size() - 1] != w[i][0]) {
				cout << "No" << endl;
				return 0;
			}
		}
		mp[w[i]]++;
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
/* * * * * * * * * * * **
*                      *
*	   saurabh8522	   *
*	  I will handle	   *
*		   IT.		   *
*                      *
* * * * * * * * * * * **/
#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ld long double
#define zero(a) memset((a),0,sizeof((a)))
#define one(a) memset((a),1,sizeof((a)))
#define minus(a) memset((a),-1,sizeof((a)))
#define all(g) g.begin(),g.end()
#define ppb pop_back
using namespace std;
typedef long long int ll;
#define MOD 1000000007
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll numdigit(ll n){return floor(log10(n)) + 1;}
bool isPowerTwo (ll x) { return x && (!(x&(x-1))); } 
vector<int>grp[100001];
ll dp[100001];
ll in[100001];
bool visited[100001];
ll n,m;
void bfs(){
	queue<int>q;
	for(int i=1;i<=n;i++){
		if(in[i]==0){
			q.push(i);
		}
	}
	while(!q.empty()){
		int a=q.front();
		q.pop();
		if(visited[a]) continue;
		visited[a]=true;
		for(int i=0;i<grp[a].size();i++){
			if(--in[grp[a][i]]==0){
				q.push(grp[a][i]);
				dp[grp[a][i]]=max(dp[grp[a][i]],dp[a]+1);
			}
			
		}
	}
}
int  main(){
	FastRead;
	ll t=1;
	// cin>>t;
	while(t--){
		// ll n,m;
		cin>>n>>m;
		zero(in);
		for(int i=0;i<m;i++){
			int u,v;
			cin>>u>>v;
			grp[u].push_back(v);
			in[v]++;
		}
		zero(dp);
		zero(visited);
		bfs();
		ll ans=0;
		for(int i=1;i<=n;i++){
			ans=max(ans,dp[i]);
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 7424
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long N, X[1 << 18];
long long minx = (1LL << 60);

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> X[i];

	for (int i = -200; i <= 200; i++) {
		long long sum = 0;
		for (int j = 1; j <= N; j++) sum += (X[j] - i) * (X[j] - i);
		minx = min(minx, sum);
	}
	cout << minx << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF 1<<30
#define LINF 1LL<<60

struct edge {
	int to; // ?????????
	int cap; // ??????
	int rev; // ??????
	edge() {}
	edge(int to, int cap, int rev) :to(to), cap(cap), rev(rev) {}
};

// from??????to??????????????????cap???????????°?????????????????????
void add_edge(int from, int to, int cap, vector<vector<edge>>& G) {
	G[from].push_back(edge(to, cap, G[to].size()));
	G[to].push_back(edge(from, 0, G[from].size() - 1));
}

// ?¢?????????????DFS??§??¢???
int dfs(int v, int t, int f,vector<vector<edge>>&G,vector<int>& used) {
	if (v == t) return f;
	used[v] = true;
	for (int i = 0; i < G[v].size(); i++) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap), G, used);
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

// s??????t???????????§???????±???????
int max_flow(int s, int t,vector<vector<edge>>&G,vector<int>& used) {
	int flow = 0;
	for (;;) {
		for (int i = 0; i < used.size(); i++) used[i] = 0;
		int f = dfs(s, t, INF, G, used);
		if (f == 0) return flow;
		flow += f;
	}
}


/* use example */
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int V, E; cin >> V >> E;
	vector<vector<edge>> G(V); // ??°???????????£??\???????????¨???
	vector<int> used(V, 0); // DFS??§?????§???????????????????????°
	for (int i = 0; i < E;i++) {
		int s, t, c; cin >> s >> t >> c;
		add_edge(s, t, c, G);
	}
	cout << max_flow(0, V - 1,G,used) << endl;
	return 0;
}

Measured memory_bytes: 3196
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
	private static final int X = 0;
	private static final int Y = 1;
	
	private static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		ArrayList<Double> p1 = new ArrayList<Double>(2);
		ArrayList<Double> p2 = new ArrayList<Double>(2);
		ArrayList<Double> p3 = new ArrayList<Double>(2);
		ArrayList<Double> pTarget = new ArrayList<Double>(2);
		
		ArrayList<Boolean> results = new ArrayList<Boolean>();
		
		try{
			while(true){
				setInputs(p1, p2, p3, pTarget);
		
				ArrayList<Double> cog = getCenterOfGravity(p1, p2, p3);  
		
				results.add(isInTriangle(p1, p2, p3, cog, pTarget));
				
				p1.clear();
				p2.clear();
				p3.clear();
				pTarget.clear();
				cog.clear();
			}
		}catch(NoSuchElementException e){
			//½àµÈ¢
		}
		
		for(int i = 0; i < results.size(); i++){
			printIsInTriangle(results.get(i));
		}
	}
	
	private static void printIsInTriangle(boolean isInTriangle){
		String result;
		if(isInTriangle){
			result = "YES";
		}
		else{
			result = "NO";
		}
		System.out.println(result);
	}
	
	private static boolean isInTriangle(
			ArrayList<Double> p1,
			ArrayList<Double> p2,
			ArrayList<Double> p3,
			ArrayList<Double> cog,
			ArrayList<Double> pTarget){
		//¼üp1,p2Æ¼üpTarget,cogªð··éêApTargetÍOp`p1p2p3ÌO
		if(isInBiggerArea(p1, p2, pTarget) && !(isInBiggerArea(p1, p2, cog))){
			return false;
		}
		if(!(isInBiggerArea(p1, p2, pTarget)) && isInBiggerArea(p1, p2, cog)){
			return false;
		}
		
		//¼üp2,p3Æ¼üpTarget,cogªð··éêApTargetÍOp`p1p2p3ÌO
		if(isInBiggerArea(p2, p3, pTarget) && !(isInBiggerArea(p2, p3, cog))){
			return false;
		}
		if(!(isInBiggerArea(p2, p3, pTarget)) && isInBiggerArea(p2, p3, cog)){
			return false;
		}
		
		//¼üp1,p3Æ¼üpTarget,cogªð··éêApTargetÍOp`p1p2p3ÌO
		if(isInBiggerArea(p1, p3, pTarget) && !(isInBiggerArea(p1, p3, cog))){
			return false;
		}
		if(!(isInBiggerArea(p1, p3, pTarget)) && isInBiggerArea(p1, p3, cog)){
			return false;
		}
		
		return true;
	}
	
	private static boolean isInBiggerArea(
			ArrayList<Double> p1,
			ArrayList<Double> p2,
			ArrayList<Double> p3){
		double result = (p3.get(Y) - p1.get(Y)) * (p2.get(X) - p1.get(X)) + (p2.get(Y) - p1.get(Y)) * (p1.get(X) - p3.get(X));
		if(result > 0){
			return true;
		}
		else{
			return false;
		}
	}
	
	private static ArrayList<Double> getCenterOfGravity(
			ArrayList<Double> p1,
			ArrayList<Double> p2,
			ArrayList<Double> p3){
		ArrayList<Double> cog = new ArrayList<Double>(2);
		cog.add((p1.get(X) + p2.get(X) + p3.get(X)) / 3);
		cog.add((p1.get(Y) + p2.get(Y) + p3.get(Y)) / 3);
		return cog;
	}
	
	private static void setInputs(
			ArrayList<Double> p1,
			ArrayList<Double> p2,
			ArrayList<Double> p3,
			ArrayList<Double> p4){
		p1.add(sc.nextDouble());
		p1.add(sc.nextDouble());
		p2.add(sc.nextDouble());
		p2.add(sc.nextDouble());
		p3.add(sc.nextDouble());
		p3.add(sc.nextDouble());
		p4.add(sc.nextDouble());
		p4.add(sc.nextDouble());
	}
}

Measured memory_bytes: 12000
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,A,B=map(int,input().split())
    ans=0
    for i in range(1,N+1):
        if A<=sum(list(map(int,list(str(i)))))<=B:
            ans+=i
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 41324
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define pb         push_back
#define mp         make_pair
#define ll         long long
#define PI         acos(-1.0)
#define ALL(A)     ((A).begin(), (A).end())
#define vsort(v)   sort(v.begin(),v.end())
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int N;
string s;
int who[100010];

bool solve(int a, int b){
    who[0] = a;
    who[1] = b;
    FOR(k, 2, N){
        who[k] = (who[k-1] ^ (s[k-1] == 'o')) ? who[k-2] : 1 - who[k-2];
    }
    if ((who[N-2] ^ (who[0]) ^ (who[N-1]) ^ (s[N-1] == 'x'))) return false;
    if ((who[N-1] ^ who[1]) ^ (who[0] ^ (s[0] == 'x'))) return false; 
    return true;
}

int main(void){
    cin >> N;
    cin.ignore();
    getline(cin, s);
    bool check;
    if(solve(0, 0)) FOR(i, 0, N) cout << (who[i] ? "W" : "S");
    else if(solve(0, 1)) FOR(i, 0, N) cout << (who[i] ? "W" : "S");
    else if(solve(1, 0)) FOR(i, 0, N) cout << (who[i] ? "W" : "S");
    else if(solve(1, 1)) FOR(i, 0, N) cout << (who[i] ? "W" : "S");
    else cout << "-1";
    cout << endl;
}

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

#define ll long long

using namespace std;

const int MAXN = 200010;
const int MAXM = 100010;
const int MAXINT = 2147483647;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;

int n, m, k;
ll ans, tot, cnt;

int a[MAXN];

string s;

inline int read() {
	int s = 0, f = 1;
	char ch = getchar();
	while ('0' > ch || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
	while ('0' <= ch && ch <= '9') {s = (s << 3) + (s << 1) + ch - 48; ch = getchar();}
	return s * f;
}

bool cmp(int x, int y) {
	return x > y;
}

int main(){
	int T;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	sort(a + 1, a + n + 1, cmp);
	ans = a[1];
	int last = a[2], p = 1;
	for (int i = 3; i <= n; i++) {
		if (i % 2) {
			last = a[++p];
		}
		ans += last;
 	}
	cout << ans << endl;
	return 0;
}

/*

*/


Measured memory_bytes: 4548
function main(input) {
    parser(input);
}
const parser = (input) => {
    const tmp = input.split('\n');
    const [n, k] = tmp[0].split(' ')
    tmp.shift();
    const map = {};
    for (let i = 1; i <= Number(n); i++ ){ 
        map[i] = 0;
    }
    tmp.forEach((item, index) => {
        if (index % 2 !== 0) {
            const okasiKubaru = item.split(' ');
            okasiKubaru.forEach(okasi => {
                map[Number(okasi)] = map[Number(okasi)] + 1;
            })
        }
    });
    let count = 0;
    Object.keys(map).map((key) => {
        if (map[key] === 0) {
            count ++;
        }
    });
    console.log(count);
}

// test
// const Q1 = `3 2
// 2
// 1 3
// 1
// 3`;
// const Q2 = `3 3
// 1
// 3
// 1
// 3
// 1
// 3
// `;
// main(Q1);
// main(Q2);
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define int long long

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	vector<pair<int, int>> s(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		s[i].first = a[i] + b[i];
		s[i].second = i;
	}
	sort(s.rbegin(), s.rend());
	vector<int> c(n);
	for (int i = 0; i < n; i++) {
		c[s[i].second] = (i & 1);
	}
	int res[2] = {};
	for (int i = 0; i < n; i++) {
		if (c[i] == 0) res[0] += a[i];
		else res[1] += b[i];
	}
	cout << res[0] - res[1] << endl;
	return 0;	
}

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


int main(){
	int n;
	cin >> n;
	int count = 0;
	if (n / 10 == 9)
	{
		cout << "Yes" << endl;
	}else if (n % 10 == 9)
	{
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

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

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

  vector<int> a(100010);
  for(int i = 1; i <= n; i++){
    cin >> a.at(i);
  }

  int tmp = 1;
  for(int i = 0; i <= n; i++){
    if(a.at(tmp) == 2){
      cout << i+1 << endl;
      break;
    }
    if(i == n){
      cout << -1 << endl;
      break;
    }

    tmp = a.at(tmp);
  }
}


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

#define rep(i, n) for(int i = 0; i < n; i++)

int main()
{
  int N, K, ans = 1;
  cin >> N >> K;
  rep(i, N)
    {
      ans = ans*2 < ans + K ? ans*2 : ans + K;
    }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    /*
     * 操作1,2をそれぞれx,y回行うと水は
     * 100ax+100by[g]になる。
     * この形の数でf以下のものを探す。
     */
    set<int> water;
    for (int x = 0; 100 * a * x <= f; ++x) {
        for (int y = 0; 100 * a * x + 100 * b * y <= f; ++y) {
            int w = 100 * a * x + 100 * b * y;
            if (w != 0) water.insert(w);
        }
    }

    /*
     * 操作3,4をそれぞれx,y回行うと砂糖は
     * cx+dy[g]になる。
     * この形の数でe/(100+e)*f以下のものを探す。
     */
    set<int> sugar;
    for (int x = 0; c * x * (100 + e) <= e * f; ++x) {
        for (int y = 0; (c * x + d * y) * (100 + e) <= e * f; ++y) {
            sugar.insert(c * x + d * y);
        }
    }

    double tmp = 0.0;
    int ansWeight, ansSugar;
    for (auto w:water) {
        for (auto s:sugar) {
            /*
             * 砂糖は最大でew/100[g]溶ける。
             */
            if (s + w <= f && 100 * s <= e * w &&
                (double) (100 * s) >= tmp * (s + w)) {
                tmp = (double) (100 * s) / (s + w);
                ansWeight = s + w, ansSugar = s;
            }
        }
    }

    cout << ansWeight << " " << ansSugar << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Random;
    import java.util.Scanner;
     
    public class Main {
     
    static Scanner sc = new Scanner(System.in);
    static int N;
    static int[][] g;
     
    static void solve() {
    Random rand = new Random();
    int[] hist = new int[N];
    for (int i = 0; i < 100; ++i) {
    System.out.println(rand.nextInt(N) + 1);
    System.out.flush();
    int ai = sc.nextInt() - 1;
    ++hist[ai];
    }
    double[] exp = new double[N];
    double sum = 0;
    for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
    exp[i] += 1. * g[i][j] * hist[j] / 100;
    }
    sum += exp[i];
    }
    for (int i = 100; i < 1000; ++i) {
    double r = rand.nextDouble() * sum;
    for (int j = 0; j < N; ++j) {
    r -= exp[j];
    if (r <= 0) {
    System.out.println(j + 1);
    System.out.flush();
    break;
    }
    }
    }
    }
     
    public static void main(String[] args) {
    N = sc.nextInt();
    g = new int[N][N];
    for (int i = 0; i < N; ++i) {
    String line = sc.next();
    g[i][i] = 1;
    for (int j = i + 1; j < N; ++j) {
    if (line.charAt(j) == 'o') {
    g[i][j] = 3;
    } else {
    g[j][i] = 3;
    }
    }
    }
    solve();
    }
    }

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

int main()
{
  fastio();

  int a,b;

  cin >> a >> b;

  cout << max(a - 2*b, 0) << endl;

  return 0;
}


Measured memory_bytes: 256
//#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(x...) cerr << __LINE__ << ": " << #x << " = "; DBG::_print(x)
#else
#define DEBUG(x...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

const int INF = 1e9;

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int N, M;
   cin >> N >> M;
   VVI adj(N+1);
   REP(m, M) {
      int u, v;
      cin >> u >> v;
      adj[u].push_back(v);
      adj[v].push_back(u);
   }

   queue<int> q;
   q.push(1);
   VI D(N+1, INF);
   D[1] = 0;
   VI P(N+1, -1);
   while (!q.empty()) {
      int u = q.front();
      q.pop();
      for (int v : adj[u]) {
         if (D[v] > D[u] + 1) {
            D[v] = D[u] + 1;
            P[v] = u;
            q.push(v);
         }
      }
   }

   FOR(u, 2, N)
      if (P[u] < 0) {
         cout << "No\n";
         return 0;
      }

   cout << "Yes\n";
   FOR(u, 2, N)
      cout << P[u] << '\n';

   return 0;
}


Measured memory_bytes: 10652
#include<cstdio>
int main()
{
	char s[6];
	scanf("%s",s+1);
	int a=s[1]-'0';
	int b=s[2]-'0';
	int c=s[3]-'0';
	int d=s[4]-'0';
	if(a+b+c+d==7){
		printf("%d+%d+%d+%d=7\n",a,b,c,d);
	}else if(a+b+c-d==7){
		printf("%d+%d+%d-%d=7\n",a,b,c,d);
	}else if(a+b-c+d==7){
		printf("%d+%d-%d+%d=7\n",a,b,c,d);
	}else if(a+b-c-d==7){
		printf("%d+%d-%d-%d=7\n",a,b,c,d);
	}else if(a-b+c+d==7){
		printf("%d-%d+%d+%d=7\n",a,b,c,d);
	}else if(a-b+c-d==7){
		printf("%d-%d+%d-%d=7\n",a,b,c,d);
	}else if(a-b-c+d==7){
		printf("%d-%d-%d+%d=7\n",a,b,c,d);
	}else if(a-b-c-d==7){
		printf("%d-%d-%d-%d=7\n",a,b,c,d);
	}
	return 0;
}

Measured memory_bytes: 128
a,b,k=map(int,input().split())
c=[i for i in range(a,min(a+k,b+1))]
d=[i for i in range(max(a,b-k+1),b+1)]
e=c+d
e=list(set(e))
e.sort()
for i in range(len(e)):
    print(e[i])

Measured memory_bytes: 3444
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl
#define CE cout<<endl
#define V <<" "<<

ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[200010];
bool r,ra,rb,rc[200010];
string s,sa,sb,sc;
char ca,cb,cc,cd[200010];
vector<ll> va,vb,vc,vd,ve;
set<int> st;

vector<ll> krk(vector<ll> target){
    vector<ll> result;
    int repeats=1,number=target[0];
    for(int i=1;i<target.size();i++){
        if(number==target[i])repeats++;
        else{
            number=target[i];
            result.push_back(repeats);
            repeats=1;
        }
    }
    result.push_back(repeats);
    return result;
}

int main(){
    cin>>n>>s;
    for(auto it:s){
        va.push_back(ll(it));
    }
    vb=krk(va);
    C vb.size() E;


}


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


int main()
{
    int n;
    cin >> n;
    int dp1[n];
    int dp2[n];
    int dp3[n];
    int a,b,c;
    cin >> a >> b >> c;

    memset(dp1, 0, sizeof dp1);
    memset(dp2, 0, sizeof dp2);
    memset(dp3, 0, sizeof dp3);

    dp1[0]=a;
    dp2[0]=b;
    dp3[0]=c;

    //cout << dp1[0] << " " << dp2[0] << " " << dp3[0] << "adasda" << endl;

    for (int i=1;i<n;i++){
        cin >> a >> b >> c;
        dp1[i]=max(dp2[i-1]+a, dp3[i-1]+a);
        dp2[i]=max(dp1[i-1]+b, dp3[i-1]+b);
        dp3[i]=max(dp2[i-1]+c, dp1[i-1]+c);
        //cout << dp1[i] << " " << dp2[i] << " " << dp3[i] << "adasda" << endl;
    }
    cout << max(max(dp1[n-1], dp2[n-1]),dp3[n-1]);
}


Measured memory_bytes: 1408
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<vector>
#include<cassert>

using namespace std;

#define int long long
#define reps(i,f,n) for(int i=f;i<n;i++)
#define rep(i,n) reps(i,0,n)
#define f first
#define s second

typedef pair<int,int> pii;

const int N = 8;
const int M = 8;
const int W = 21111;
const int T = 21111;
const int INF = 1e16;
int n,m,w,t;

map<string, int> dict;
pii  item[M];

pii pos[N];
int shop[N][M];


int memo[(1<<N)][N];


void memoInit(){
	for(int i=0;i<(1<<N);i++)rep(j,N)memo[i][j]=-1;
}
int Root(int state, int num){

	if(state==0)return 0;

	if(memo[state][num]!=-1)return memo[state][num];
	if(state==(1<<num))return abs(pos[num].f) + abs(pos[num].s);
	state &= ~(1<<num);

	int ans = INF;
	for(int i=0;i<n;i++){
		if((state & (1<<i)) > 0){
			int dist = abs(pos[num].f - pos[i].f) + abs(pos[num].s - pos[i].s);
			ans = min(ans, Root(state, i) + dist);
		}
	}

	return memo[state][num] = ans ;
}

int GetTime(int state){


	int ans = INF;
	for(int i=0;i<n;i++){

		if( (state&(1<<i))>0 ) {
			int r  = Root(state,i);
			ans = min(ans, r + abs(pos[i].f) + abs(pos[i].s));
		}
	}
	return ans;
}

int GetValue(int state){
	
	
	int has[M] = {0};
	rep(i,M)has[i] = -1;

	rep(i,n){
		if((state&(1<<i)) > 0){
			rep(j,m){
				if(shop[i][j]!=-1){
					has[j] = max(has[j], shop[i][j]);
				}
			}
		}
	}


	int dp[W] = { 0};

	int ans = 0;
	for(int i=0;i<w+1;i++){

		rep(j,7){
			if(has[j]==-1)continue;
			int wi = item[j].f;
			int vi = has[j];
			dp[i+wi] = max(dp[i+wi], dp[i] + vi);
		}
		ans = max(ans, dp[i]);
	}

	return ans;
}

vector<pii> GetCand(){

	vector<pii> cand;
	for(int i=0;i<(1<<n);i++){
		cand.push_back(pii(GetTime(i), GetValue(i)));
	}
	return cand;
}

int dp[T] = {0};

int solve(){

	vector<pii> cand = GetCand();

	for(int i=0;i<cand.size();i++){
		//printf("*** %lld %lld\n",cand[i].f, cand[i].s);
	}
	rep(i,T)dp[i]=0;


	int ans = 0;
	rep(i,t+1){
		rep(j,cand.size()){
			pii c = cand[j];
			if(i+c.f >= T){
				continue;
			}

			dp[i + c.f] = max(dp[i+c.f], dp[i] + c.s);
			ans = max(ans, dp[i]);
		}
	}

	return ans;
}

signed main(){
	memoInit();
	cin>>n>>m>>w>>t;

	rep(i,m){
		string s;
		int a,b;
		cin>>s>>a>>b;
		dict[s] = i;
		item[i] = pii(a,b);
	}

	rep(i,N)rep(j,M)shop[i][j] = -1;

	rep(i,n){
		int a,x,y;
		cin>>a>>x>>y;
		pos[i] = pii(x,y);

		rep(j,M)shop[i][j]=-1;
		rep(j,a){
			string s;
			int p;
			cin>>s>>p;
			int num = dict[s];
			shop[i][num] = max(shop[i][num], max(0ll, item[num].s-p));
		}
	}

	cout<<solve()<<endl;
}

Measured memory_bytes: 1576