akhauriyash/Code-Regression huggingface dataset:
#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;
using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int
#define pll				pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007
#define hell            998244353 

ll mod_pow(ll a,ll b,ll m) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2 , mod);
}

const int maxn = 1e5 + 10;

vector< vector<pair<int , int>> > edge(maxn);

int n , q , k;

int vis[maxn];
int path[maxn];

void dfs(int u,int par) {
	
	vis[u] = 1;
	
	for(auto v : edge[u]) {
		if(v.first != par) {
			
			path[v.first] += path[u] + v.second;
			
			dfs(v.first , u);
		}
	}
}

void solve()
{
	cin >> n;
	
	for(int i = 1; i < n; ++i) {
		int x , y , z;
		
		cin >> x >> y >> z;
		
		edge[x].pb({y , z});
		edge[y].pb({x , z});
	}
	
	cin >> q >> k;
	
	dfs(k , 0);
	
	for(int i = 0; i < q; ++i) {
		int x , y;
		
		cin >> x >> y;
		
		cout << path[x] + path[y] << endl;
	}
}

signed main() {
    fast;
    
    int t = 1;
    
	//cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 16320
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>

using namespace std;

#define ll long long

int main() {
    
    ll n;
    cin >> n;
    ll a[n],b[n];
    for (ll i=0;i<n;i++) {
        cin >> a[i];
        b[i]=a[i];
    }
    sort(a,a+n,greater<ll>());
    for(ll i=0;i<n;i++){
        if(b[i]==a[0]) cout << a[1] << endl;
        else cout << a[0] << endl;
    }
}



Measured memory_bytes: 4736
<?php
list($n) = ints();
$a = ints();
$max = 0;
$ans = 0;
for ($i = 0; $i < $n; ++$i) {
    $ans += max(0, $max - $a[$i]);
    $max = max($max, $a[$i]);
}
echo $ans;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 38068
import std.stdio, std.string, std.conv, std.algorithm;
void main(){
	long n, m, v, p, i, u, a;
	scanf("%d %d %d %d\n", &n, &m, &v, &p);
	auto A = readln.split.to!(long[]);
	A.sort!"a>b"();

	long sum;
	for(i = p - 1; i < A.length; i ++){
		a = A[i];
		if(a + m >= A[p - 1] && (i - (p - 1)) * (a + m) - sum + m * (p - 1 + n - i) >= m * v) sum += a;
		else break;
	}
	i.writeln;
}

Measured memory_bytes: 4532
while True :
    
    x=int(input())
    if x==0 : break
    i=0
    b=0
    mx=0
    mn=1000
    while i<x :
        c=int(input())
        if mx<c : mx=c
        if mn>c : mn=c
        b=b+c
        i=i+1
    print(int((b-mx-mn)/(x-2)))


Measured memory_bytes: 5592
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  int sum = accumulate(all(a), 0LL);
  if (sum == x) {
    cout << n << endl;
  } else if (sum < x) {
    cout << n - 1 << endl;
  } else {
    int ans = 0;
    rep(i, n) {
      if (x - a[i] >= 0) {
        ans++;
        x -= a[i];
      } else {
        break;
      }
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	bool flag = true;
	int N, M;
	vector<int> A;
	
	cin>>N>>M;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		if(A[i] %2 == 0) {
			A[i] /= 2;
		} else {
			flag = false;
		}
	}
	
	// cout<<"flag " <<flag<<endl;
		
	if(!flag){
		
		cout<<0<<endl;
		
	} else {
		int tc = -1;
		for(int i = 0; i < N; i++){
			int z = A[i], con = 0;
			
			while(z%2 == 0){
				con++;
				z/= 2;
			}
			
			if(tc == -1) tc = con;
			
			if(con != tc) {
				flag = false;
				break;
			}
		}
		
		if(!flag) {
			cout<<0<<endl;
			return 0;
		}
		
		int hoge = 1;
		
		for(int i = 0; i < N; i++){
			hoge = hoge/__gcd(hoge, A[i]) * A[i];
		}
		
		// cout<<hoge<<endl;
		
		
		
		if(!flag) {
			cout<<0<<endl;
		} else {
			
			
			if(!flag) {
				 cout<<0<<endl;
			} else {
				int z = M/hoge;
				cout<< (z + 1)/ 2 <<endl;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;
  cin>>n>>a>>b;
  int temp,sum=0;
  for(int i=0;i<=n;i++){
    int ans=0;
    temp=i;
    while(temp>=10){
      ans+=(temp%10);
      temp/=10;
    }
    ans+=temp;
    if(ans>=a && ans<=b){
      sum+=i;
    }
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
from collections import deque
import itertools
ans = deque()
l = []
r = deque()
for i in range(N):
  l.append(chr(97+i))
  r.append(l.copy())
  

p = [[[] for _ in range(N)] for _ in range(N)]
p[0][0].append('a')
for i in range(1,N):
  for j in r[i]:
    x = ord(j)-97
    for n,k in enumerate(p[i-1][max(0,x-1):],max(0,x-1)):
      for m in k:
        p[i][max(n,x)].append(m+j)


p = p[-1]
p = list(itertools.chain.from_iterable(p))
p = sorted(p)
for q in p:
  print(q)

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

using namespace std;
int main()
{
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double lo = 30.*h + 0.5*m;
    double sh = 6.*m;
    double aa;
    if(lo>sh){
        aa = lo - sh;
    }
    else{
        aa = sh - lo;
    }
    double cc = a*a + b*b - 2.*a*b*cos(aa*M_PI/180);
    cout << fixed << setprecision(15)<< sqrt(cc);
}

Measured memory_bytes: 4228
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=40;
int n;
char a[maxn][3];
char b[maxn][3];
char c[maxn][3];
void bubble_sort()
{
    for(int i=0;i<n;i++)
    {
        for(int j=n-1;j>0;j--)
        {
            if(b[j][1]<b[j-1][1]) swap(b[j],b[j-1]);
        }
    }
}
void select_sort()
{
    for(int i=0;i<n;i++)
    {
        int minh=i;
        for(int j=i;j<n;j++)
        {
            if(c[j][1]<c[minh][1]) minh=j;
        }
        if(i!=minh) swap(c[i],c[minh]);
    }
}

int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%s",&a[i]);
    }
    memcpy(b,a,sizeof(a));
    bubble_sort();
    for(int i=0;i<n;i++)
    {
        if(i) printf(" ");
        printf("%s",b[i]);
    }
    printf("\nStable\n");
    memcpy(c,a,sizeof(a));
    select_sort();
    for(int i=0;i<n;i++)
    {
        if(i) printf(" ");
        printf("%s",c[i]);
    }
    printf("\n");
    bool flag=true;
    for(int i=0;i<n;i++)
    {
        if(strcmp(b[i],c[i])!=0)
        {
            flag=false;
            break;
        }
    }

    if(flag)
    {
        printf("Stable\n");
    }
    else
    {
         printf("Not stable\n");
    }





    return 0;
}

Measured memory_bytes: 3236
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}
ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
void solve()
{
	ll s;
	cin >> s;
	ll v = (ll)1e9;
	ll x3, y3;
	y3 = (s + v - 1) / v;
	x3 = v * y3 - s;
	cout << "0 0 1000000000 1 " << x3 << " " << y3;
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
		solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  vector<int> a(3);
  rep(i,0,3) cin>>a[i];
  asort(a);
  if(a[0]+a[1]==a[2]) cout<<"Yes";
  else cout<<"No";
  cout<<endl;
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e18
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i, N) cin >> a[i];
  ll sum = 0;
  REP(i, N) sum += (a[i] - 1);
  cout << sum << endl;

  return 0;
}

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

using namespace std;

using ll=long long ;

void solve() {
    int n; ll k;
    cin >> n >> k;
    vector<int> cnt(70, 0);
    for (int _ = 0; _ < n; _++) {
        ll x; cin >> x;
        for (int i = 0; i < 63; i++) {
            if (x & (1ll<<i))
                cnt[i]++;
        }
    }

    ll dp[66][2];
    memset(dp, -1, sizeof dp);
    dp[63][0] = 0;
    for (int i = 62; i >= 0; i--) {
        int x = cnt[i]; ll j = 1ll<<i;
        if (k & j) {
            dp[i][0] = max(dp[i][0], dp[i+1][0] + (n-x)*j);
            dp[i][1] = max(dp[i][1], dp[i+1][0] + x*j);
            if (dp[i+1][1] != -1)
            dp[i][1] = max(dp[i][1], dp[i+1][1] + max(x,n-x) * j);
        } else {
            dp[i][0] = max(dp[i][0], dp[i+1][0] + x*j);
            if (dp[i+1][1] != -1)
            dp[i][1] = max(dp[i][1], dp[i+1][1] + max(x,n-x) * j);
        }
    }
    ll res = max(dp[0][0], dp[0][1]);
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

#define sz(x) (int)(x.size())
#define FOR(x,y,z) for(int x = y; x <= z; x++)
#define int long long

const int N = 1e5 + 2, inf = 1e18;

string s, t;
int n, k;
int dp[302][302][302];

int go(int l, int r, int rem){
    if(rem < 0)
        return -inf;
    if(l >= r)
        return l == r;

    int &ans = dp[l][r][rem];
    if(~ans) return ans;

    ans = 0;
    if(s[l] == s[r])
        ans = max(ans, 2 + go(l + 1, r - 1, rem));
    ans = max(ans, 2 + go(l + 1, r - 1, rem - 1));
    ans = max({ans, go(l + 1, r, rem), go(l, r - 1, rem)});
    return ans;

}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);  

    memset(dp, -1, sizeof(dp));
    cin >> s >> k;
    n = sz(s);
    cout << go(0,n-1,k);
}

Measured memory_bytes: 218864
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> r(n);
	rep(i, m){
		int a,b;
		cin >> a >> b;
		r[a-1].push_back(b-1);
		r[b-1].push_back(a-1);
	}
	//cout << r[0].size() << endl;
	vector<int> check(n, -1);
	int cnt = 1;
	vector<int> cur = {0};
	check[0] = 1;

	while(cur.size() > 0){
		int p = cur[0];
		//cout << p<< endl;
		rep(i, r[p].size()){
			int next = r[p][i];
			if(check[next] == -1){
				check[r[p][i]] = p;
				cur.push_back(next);
				cnt++;
			}
		}
		cur.erase(cur.begin());
	}
	if(cnt == n){
		cout << "Yes" <<endl;
		rep(i, n-1){
			cout<<check[i+1]+1<<endl;
		}
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 10648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    a--,b--,c--,d--;
    string s;
    cin>>s;
    bool flag=false;
    rep(i,len(s)){
      if(s[i]=='#' && i+1<=len(s)-1 && s[i+1]=='#'){
        if(max(c,d)>=i && i+1>=a){
          cout<<"No"<<endl;
          return 0;
        }
      }
      if(i+1<=len(s)-1 && i+2<=len(s)-1 && s[i]=='.' && s[i+1]=='.' && s[i+2]=='.'){
        if(i+1>=b && c>=i+2 && d>=i+1) flag=true;
      }
    }
    if(c<d){
      cout<<"Yes"<<endl;
    }else if(flag){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
}

Measured memory_bytes: 592
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define N 10100
#define mo 1000000007
#define ll long long
using namespace std;
int n,m,k,f[N],ans=0,a[N];
int mi(ll a,ll b)
{
	ll c=1;
	for(;b;b/=2,a=a*a%mo) if(b%2==1) c=c*a%mo;
	return c;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i*i<=n;i++)
	if(n%i==0)
	{
		a[++m]=i;
		if(i!=n/i) a[++m]=n/i;
	}
	sort(a+1,a+m+1);
	fo(i,1,m)
	{
		f[i]=mi(k,(a[i]+1)/2);
		fo(j,1,i-1)
		{
			if(a[i]%a[j]==0) f[i]=(f[i]-f[j]+mo)%mo;
		}
		ans=(ans+(ll)f[i]*(a[i]%2==1?(ll)a[i]:(ll)(a[i]+1)/2)%mo)%mo;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	ll n, m; cin >> n >> m;
	ll x = min(n, m / (ll)2);
	n -= x; m -= x * (ll)2;
	x += m / (ll)4;
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);
    int result;
    result = C - (A - B);
    if(result < 0){
        printf("0");
    }else{
        printf("%d", result);
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

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

  int ans = 0;
  for(int i = 1; i <= N; i++){
    if(i < 10 || (100 <= i && i < 1000) || (10000 <= i && i < 100000)) ans++;
  }

  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 256
n, k = map(int, input().split())
d = [0]*(10**5+1)
for _ in range(n):
    a, b = map(int, input().split())
    d[a] += b
    
cnt = 0
for i in range(1, 10**5+1):
    cnt += d[i]
    if cnt >= k:
        break
print(i)

Measured memory_bytes: 5736
#include <bits/stdc++.h>
#define x first
#define y second
#pragma gcc optimize("O3")
#pragma gcc optimize("Ofast")
#pragma gcc optimize("unroll-loops")
using namespace std;
const long long INF = 1e18;
const long long mod = 998244353;
typedef long long ll;
typedef long double ld;
typedef pair <int,int> pi;
typedef pair <ll,ll> pl;
typedef vector <int> vec;
int n,k;
pi a[25];
ll d[200005],sd[200005];
vector <pi> gu;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> k;
	for(int i = 1;i <= k;i++) cin >> a[i].x >> a[i].y;
	sort(a+1,a+k+1);
	int l = a[1].x, r = a[1].y;
	for(int i = 2;i <= k;i++) {
		if(r+1 < a[i].x) {
			gu.push_back({l,r});
			r = 0, l = a[i].x;
		}
		r = max(r,a[i].y);
	}
	gu.push_back({l,r});
	d[1] = 1;
	sd[1] = 1;
	for(int i = 2;i <= n;i++) {
		for(pi j : gu) {
			int l = max(0,i-j.y), r = max(0,i-j.x);
			d[i] = (d[i]+sd[r]-sd[l-1]+mod)%mod;
		}
		sd[i] = sd[i-1]+d[i];
	}
	cout << d[n];
 	return 0;
}

Measured memory_bytes: 6780
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> W;
	vector< int > w(N), v(N);
	rep(i, N) cin >> w[i] >> v[i];
	vector< vector< int > > dp(N + 1, vector< int >(4 * N, -1));
	dp[0][0] = 0;
	rep(k, N) {
		for (int i = N - 1; i >= 0; i--) {
			for (int j = dp[0].size() - 1; j >= 0; j--) {
				if (dp[i][j] > -1) {
					int p = w[k] - w[0];
					if (j + p < dp[0].size())
						chmax(dp[i + 1][j + p], dp[i][j] + v[k]);
				}
			}
		}
	}
	int ans = 0;
	rep(i, N + 1) rep(j, 4 * N) {
		if (i * w[0] + j <= W)
			chmax(ans, dp[i][j]);
	}
	//cout << dp;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] p = new String[n];
        for (int i = 0; i < n; i++) {
            p[i] = sc.next();
            int price = sc.nextInt();
            p[i] = p[i] + "," + (200 - price) + "," + (i + 1);
        }
        Arrays.sort(p);

        for (String s : p) {
            System.out.println(s.split(",")[2]);
        }
    }
}

Measured memory_bytes: 21716
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define mod  1000000007

ll pow(int n , int m){
  ll r=1;
  while(m>0){
    r=r*n;
    m--;
  }
  return r;
}

int main(int argc, char const *argv[]) {
  int n,m;
  std::cin >> n >> m;
  ll ans=(1900*m + 100*(n-m))*pow(2,m);

  std::cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
int N,i=0,j=0,t=0,M;
cin>>N;
int T[N+5];
for(i=1;i<=N;i++)
{
cin>>T[i];
t+=T[i];
}
cin>>M;
int p[M+5],x[M+5];
for(j=1;j<=M;j++)
{
cin>>p[j]>>x[j];
cout<<t+(x[j]-T[p[j]])<<endl;
}}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<math.h>
#include<list>
#include<complex>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


ll const MOD = 1e9 + 7;
ll mod_p(ll x, ll y) {
	x %= MOD;
	y %= MOD;
	return (x + y + MOD) % MOD;
}

ll mod_m(ll x, ll y) {
	x %= MOD;
	y %= MOD;
	return x * y%MOD;
}

ll mod_pow(ll x, ll t) {
	x %= MOD;
	if (t == 0) {
		return 1;
	}
	else {
		ll v = mod_pow(x, t / 2);
		if (t % 2 == 0) {
			return v * v % MOD;
		}
		else {
			return v * v%MOD * x %MOD;
		}
	}
}

ll mod_inv(ll x) {
	return mod_pow(x, MOD - 2);
}

struct edge
{
	long long to; long long len;
	bool operator<(const edge& rhs) const {
		return len > rhs.len;
	}
};
ll const MAX = 1e5 + 5;
vll G[MAX];
ll node[MAX] = {};
ll parent[MAX] = {};

void dfs(ll start) {
	parent[start] = 0;
	queue<ll> qu;
	qu.push(start);
	while (!qu.empty()) {
		ll cur = qu.front();
		qu.pop();
		for (auto next : G[cur]) {
			node[next]--;
			if (node[next] == 0) {
				parent[next] = cur;
				qu.push(next);
			}
		}
	}
}

int main() {
	ll n, m;
	cin >> n >> m;
	REP(i, 1, n + m - 1) {
		ll x, y;
		cin >> x >> y;
		node[y]++;
		G[x].push_back(y);
	}
	ll start;
	REP(i, 1, n) {
		if (node[i] == 0) {
			start = i;
		}
	}
	dfs(start);
	REP(i, 1, n) {
		cout << parent[i] << endl;
	}
}

Measured memory_bytes: 8320
use std::io;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).expect("");
    buf.trim().to_string()
}

fn read_i32() -> i32 {
    read_line().parse().expect("")
}

fn read_vi32() -> Vec<i32> {
    read_line().split(' ').into_iter()
        .map(|w| w.parse().expect(""))
        .collect()
}

fn main() {
    let k = read_i32();
    if let &[a, b] = &read_vi32()[..] {
        println!("{}",
                 if a <= b / k * k {
                     "OK"
                 } else {
                     "NG"
                 }
                );
    }
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a,b,ans;
    cin>>a>>b;

    ans=a+b;
    if(ans>23){
        ans-=24;
    }
    
    cout<<ans<<endl;
   
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int n;
  scanf("%i", &n);
  
  int a[n], min = 1000000, max = -1;
  for (int i = 0; i < n; i++) {
    scanf("%i", &a[i]);
    min = min > a[i] ? a[i] : min;
    max = max > a[i] ? max : a[i];
  }
  
  printf("%i\n", max-min);
  
  return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		int ans = 999;
		int n=a.length();
		
		for(int i=0;i<n-2;i++)
		{
			String num = a.substring(i,i+3);
			int temp = Integer.parseInt(num);
			ans = Math.min(ans,Math.abs(753-temp));
		}
		
		System.out.println(ans);
		
		
		
		

	}
}

Measured memory_bytes: 23760
#include <bits/stdc++.h>
#define Tayeb ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
using namespace std;
int main()
{
    Tayeb;
    string str;
    cin >> str;
    int l=str.length();
    for(int i=0; i<l; i++)
    {
        cout << "x";
    }
    cout << "\n";

    return 0;

}




Measured memory_bytes: 3656
/*
 *
 * Author: r3gz3n
 * 
 * 3b 13 12 9 56 4e
 * 6 56 a a 5f f
 * 6 56 47 18 56 d
 * 13 46 14 1f 13 27
 * 52 52 a 5a 47 1
 * 1d 13 b 1b 49 17
 *
 */


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;


#define pb push_back


#define rep(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)

#define repeach(i, a) for(auto i: a)


#define endl '\n'


typedef vector<int> vii;


class Solution {
public:
    const int static MAX = 15;
    vii adj[MAX];
    int p[MAX];
    void solve(std::istream& in, std::ostream& out) {
		int n, m, k, b;
        in >> n >> m;
        rep(i, 1, m+1, 1) {
            in >> k;
            rep(j, 0, k, 1) {
                in >> b;
                b--;
                adj[b].pb(i);
            }
        }
        rep(i, 1, m+1, 1) {
            in >> p[i];
        }
        int ans = 0;
        vii A;
        rep(i, 0, (1 << n), 1) {
            int x = i;
            A = vector<int>(m+1, 0);
            k = 0;
            rep(j, 0, n, 1) {
                if (x & (1 << j)) {
                    repeach(y, adj[j]) A[y]++;
                }
            }
            rep(l, 1, m+1, 1) if (((A[l]+p[l]) & 1) == 0) k++;
            if (k == m) ans++;
        }
        out << ans << endl;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 256
bingo=[list(input().split()) for i in range(3)]
n=int(input())
ans=[[0,0,0],[0,0,0],[0,0,0]]
for i in range(n):
    a=input()
    for j in range(3):
        for k,l in enumerate(bingo[j]):
            if a==l:
                ans[j][k]=1 
if (ans[0][0]==ans[0][1]==ans[0][2]==1)\
    or (ans[1][0]==ans[1][1]==ans[1][2]==1)\
        or (ans[2][0]==ans[2][1]==ans[2][2]==1) \
            or (ans[0][0]==ans[1][0]== ans[2][0]==1) \
                or (ans[0][1]==ans[1][1]==ans[2][1]==1) \
                    or (ans[0][2]==ans[1][2]==ans[2][2]==1) \
                        or (ans[0][0]==ans[1][1]==ans[2][2]==1) \
                            or (ans[0][2]==ans[1][1]==ans[2][0]==1):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	string s;
	cin>>s;
	cout<<s.substr(0,s.size()-8)<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#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 repa(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
#define COUT(x) cout<<(x)<<endl
#define YES(x) cout<<(x?"YES":"NO")<<endl
#define Yes(x) cout<<(x?"Yes":"No")<<endl
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a / gcd(a, b)*b;}
//cout << fixed << setprecision(15);
int N, M, K, H, W, L, R, X;
string S, T;

signed main(){
  cin >> N;
  if(N>=2000){cout << 1 << endl; return 0;}
  if(N<100) {cout << 0 << endl; return 0;}
  int a = N/100;
  N %= 100;
  if( a*5 >= N) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 3644
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pii pair<int,int>
#include <bits/stdc++.h>
#define pll pair<ll,ll>
#define vi vector<int>
#define ld long double
#define ll long long
#define sh short int
#define pb push_back
#define mid (l+r)/2
#define S second
#define F first
using namespace std;
const ll inf = 1e18;
const ll mod = 1e9+7;
ll a[200009];
int main(){
    ll n,k; fast,cin>>n>>k;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n); ll sum = 0;
    for(int i=0;i<max(0ll,n-k);i++){
        sum += a[i];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 1792
#include <stdio.h>

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

int main() {
  long long int a, b, lcm, ans, c, d;
  scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
  lcm = c*d/gcd(c, d);
  ans = b-a+1;
  ans -= b/c - (a-1)/c;
  ans -= b/d -(a-1)/d;
  ans += b/lcm - (a-1)/lcm;
  printf("%lld\n", ans);
  return 0;
}


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

int main(){
    int N, A[300];
    cin >> N;
    int sum = 0;

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


    bool isOdd = true;

    for(int i=0; i<N; i++){

        if(A[i] % 2 != 0){
            isOdd = false;
        }

    }


    while(isOdd){
        for(int i=0; i<N; i++){
            if(A[i] % 2 == 0){
                A[i] = A[i] / 2;
                sum += 1;
            }

            else{
            isOdd = false;
            }
        }
    }

    cout << sum/N << endl;
}


Measured memory_bytes: 256
import itertools

n = int(input())
table = []
for _ in range(n):
    table.append(list(map(int, input().split())))

perm = list(itertools.permutations(list(range(n))))
m = len(perm)
ans = 0
for p in perm:
    tmp = 0
    limit = len(p)
    for pi in range(limit - 1):
        a = (table[p[pi]][0] - table[p[pi + 1]][0]) ** 2
        b = (table[p[pi]][1] - table[p[pi + 1]][1]) ** 2
        g = (a + b) ** 0.5
        tmp += g
    ans += tmp

print(ans / m)



Measured memory_bytes: 48364
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

MP = int(input())
M = 1
ans = 0

while MP > 1:
    ans += M
    M = 2*M
    MP = MP//2
ans += M

print(ans)


Measured memory_bytes: 9132
a, b, x = input().split()
a = int(a)
b = int(b)
x = int(x)

if a % x == 0 and x <= b:
    print(b // x - a // x + 1)
elif x <= b:
    print(b // x - a // x)
elif a % x == 0 and x > b:
    print(1)
else:
    print(0)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
long long  arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
long long sum1=0;
int max1=arr[0];
for(int i=1;i<n;i++)
{
    if(arr[i]<max1)
    {
        sum1=sum1+max1-arr[i];
    }
    else if(max1<arr[i])
    {
        max1=arr[i];
    }
    
}
cout<<sum1;
}

Measured memory_bytes: 5180
#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;
#define ll long long
#define hii cout << "hii" << endl
#define int ll
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) 
	{ 
		cerr << name << " : " << arg1 << endl;
	}
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) 
    {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#endif
 
 
const int N = 3e5 + 5;
const int MAXN = 1e5 + 5;
const int M = 1e5;
const int mod = 1e9 + 7;
const int MOD = 1e9 + 7;
const ll INF = 1e15;
const int LG = 21;


int arr[N];
int n, m, x;

void solve() 
{
	int n, k;
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
	{
		cin >> arr[i];
	}
	vector<int> cycle;
	map<int, int> seen;
	int start = 0;
	int curr = 1;
	int tt = 100;
	while(1)
	{
		if(seen[curr])
		{
			start = curr;
			break;
		}
		cycle.push_back(curr);
		seen[curr] = 1;
		curr = arr[curr];
	}
	int len = 0;
	int reqd = 0;
	bool active = 0;
	for(int i = 0; i < cycle.size(); i++)
	{
		if(start == cycle[i])
		{
			active = 1;
		}
		if(active)
		{
			len++;
		}
		else
		{
			reqd++;
		}
	}
	if(k <= reqd)
	{
		cout << cycle[k] << endl;
	}
	else
	{
		k -= reqd;
		k %= len;
		cout << cycle[reqd + k] << endl;
	}
}
 
 
int32_t main() 
{	
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

Measured memory_bytes: 18432
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
constexpr long long int INF = 1001001001001001LL;
constexpr long long int MOD = 1000000007LL;
constexpr double PI = 3.1415926535897932;
constexpr long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
constexpr long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = 1; i <= (n); i++)
#define DREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define SREP(i,s,t) for(int i = s; i < t; i++)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define PB push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  int n; cin >> n;
  for(int x = 1; x <= 3 * n; x++) {
    if((x * 108) / 100 == n) {
      cout << x << endl;
      return 0;
    }
  }

  cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll k,x; cin >> k >> x;
	if(k*500>=x) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n; i++)
#define all(a) (a).begin(),(a).end();




int main(){
  int n,h,w;
  cin >> n >> h >> w;
  vector<int> x(n);
  for(int i=0;i<n;i++){
    cin >> x[i];
  }
  int l=0,r;
  int ans=0;
  for(int i=0;i<n;i++){
    if(i%2==0){
      r=(i+1)*w+x[i];
      l=i*w+x[i];
    }
    else{
      if((i+1)*w-x[i]>r) ans+=r-i*w+x[i];
      else ans+=(i+1)*w-x[i]-l;
    }
  }
  cout << ans*h << endl;
  return 0;
}




Measured memory_bytes: 3088
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
using namespace std;

const double pi = acos(-1);

#define nyan cout<<"(=^•ω•^=)"<<endl;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)

int N,M;
int x[2000],y[2000],z[2000];
int c1[8]={1,1,1,1,-1,-1,-1,-1};
int c2[8]={1,-1,1,-1,1,-1,1,-1};
int c3[8]={1,1,-1,-1,1,1,-1,-1};
int v[8];
int s[2000];
int ans;

signed main(){
    cin>>N>>M;
    rep(i,N)cin>>x[i]>>y[i]>>z[i];
    for(int i=0;i<8;i++){
        rep(j,N)s[j]=c1[i]*x[j]+c2[i]*y[j]+c3[i]*z[j];
        sort(s,s+N);
        reverse(s,s+N);
        rep(j,M)v[i]+=s[j];
    }
    rep(i,8)ans=max(ans,v[i]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
    #![allow(dead_code)]
    use std::io::prelude::*;
    use std::cmp::{max, min};
    use std::collections::BinaryHeap;

    const MOD: i64 = 1e9 as i64 + 7; 

    fn main(){
        let s: Vec<char> = read::<String>().chars().collect();
        let mut f = true;
        for (i, c) in s.iter().enumerate(){
            match *c{
                'R' if (i + 1) % 2 == 0 => {f = false; break;},
                'L' if (i + 1) % 2 == 1 => {f = false; break;},
                _ => {},
            }
        }
        let ans = if f {"Yes"} else {"No"};
        println!("{}", ans);
    }

    fn read<T>() -> T
    where
        T: std::str::FromStr,
    {
        let stdin = std::io::stdin();
        let token: String = stdin
            .lock()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        token.parse().ok().unwrap()
    }


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

	int ans = 0;
	for (int len = 1; len < N; ++len) {
		string l = S.substr(0, len);
		string r = S.substr(len);
		int num = 0;
		for (char c = 'a'; c <= 'z'; ++c) {
			if (l.find(c) != string::npos && r.find(c) != string::npos) {
				++num;
			}
		}
		ans = max(ans, num);
	}
	cout << ans << endl;
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = rbegin(s); i != rend(s); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.ne(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
ll a[100005];
pair<ll, int> xy[100005];
ll ans[100005];
void solve() {
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n) xy[i] = { a[i],i };
    sort(xy, xy + n, greater<>());
    ll y = inf;
    rep(i, n) {
        mins(y, xy[i].second);
        ans[y] += ((ll)i + 1) * (xy[i].first - xy[i + 1].first);
    }
    rep(i, n) cout << ans[i] << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 4224
/*
[abc115] D - Christmas
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

int N;
ll X;

ll count(int level, ll idx) {
    if (level == 0) {
        return idx;
    }
    ll len = (1LL << (level + 2)) - 3;
    if (idx == 0) {
        return 0;
    }
    if (idx <= len / 2) {
        return count(level - 1, idx - 1);
    }
    if (idx < len) {
        return (1LL << (level)) - 1 + 1 + count(level - 1, idx - len / 2 - 1);
    }
    return (1LL << (level + 1)) - 1;
}

ll solve() { return count(N, X); }

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

    cout << solve() << endl;

    return 0;
}


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

int main() {
  int x;
  cin >> x;
  
  if(x == 22){
    cout << "Christmas Eve Eve Eve" << endl;
  }
  
  else if(x == 23){
    cout << "Christmas Eve Eve" << endl;
  }
  
  else if(x == 24){
    cout << "Christmas Eve" << endl;
  }
  
  else if(x == 25){
    cout << "Christmas" << endl;
  }    
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
    char suit;
    int number;
} Card;

void swap_Card(Card *x, Card *y)
{
    Card temp = *x;
    *x = *y;
    *y = temp;
}

int main(void)
{
    int N;
    scanf("%d\n", &N);

    int i;
    Card BC[N];
    Card SC[N];

    for (i = 0; i < N; i++) {
        Card c;
        scanf("%c", &c.suit);
        scanf("%d ", &c.number);
        BC[i] = c;
        SC[i] = c;
    }

    int j;

    for (i = 0; i < N - 1; i++) {
        for (j = N - 1; j > i; j--) {
            if (BC[j].number < BC[j - 1].number)
                swap_Card(&BC[j], &BC[j - 1]);
        }
    }

    for (i = 0; i < N - 1; i++) {
        int min_i = i;
        for (j = i + 1; j < N; j++) {
            if (SC[j].number < SC[min_i].number)
                min_i = j;
        }
        swap_Card(&SC[i], &SC[min_i]);
    }

    for (i = 0; i < N - 1; i++)
        printf("%c%d ", BC[i].suit, BC[i].number);
    printf("%c%d\n", BC[N - 1].suit, BC[N - 1].number);

    puts("Stable");

    for (i = 0; i < N - 1; i++)
        printf("%c%d ", SC[i].suit, SC[i].number);
    printf("%c%d\n", SC[N - 1].suit, SC[N - 1].number);

    for (i = 0; i < N; i++) {
        if (BC[i].suit != SC[i].suit) {
            puts("Not stable");
            return 0;
        }
    }
    puts("Stable");

    return 0;
}



Measured memory_bytes: 2100