akhauriyash/Code-Regression huggingface dataset:
// ███▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓╬╬╬╬╬╬▓█
// ███▓███████▓▓╬╬╬╬╬╬╬╬╬╬╬╬▓███▓▓▓▓█▓╬╬╬▓█
// ███████▓█████▓▓╬╬╬╬╬╬╬╬▓███▓╬╬╬╬╬╬╬▓╬╬▓█
// ████▓▓▓▓╬╬▓█████╬╬╬╬╬╬███▓╬╬╬╬╬╬╬╬╬╬╬╬╬█
// ███▓▓▓▓╬╬╬╬╬╬▓██╬╬╬╬╬╬▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ████▓▓▓╬╬╬╬╬╬╬▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ███▓█▓███████▓▓███▓╬╬╬╬╬╬▓███████▓╬╬╬╬▓█
// ████████████████▓█▓╬╬╬╬╬▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬█
// ███▓▓▓▓▓▓▓╬╬▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ████▓▓▓╬╬╬╬▓▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ███▓█▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// █████▓▓▓▓▓▓▓▓█▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// █████▓▓▓▓▓▓▓██▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// █████▓▓▓▓▓████▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ████▓█▓▓▓▓██▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ████▓▓███▓▓▓▓▓▓▓██▓╬╬╬╬╬╬╬╬╬╬╬╬█▓╬▓╬╬▓██
// █████▓███▓▓▓▓▓▓▓▓████▓▓╬╬╬╬╬╬╬█▓╬╬╬╬╬▓██
// █████▓▓█▓███▓▓▓████╬▓█▓▓╬╬╬▓▓█▓╬╬╬╬╬╬███
// ██████▓██▓███████▓╬╬╬▓▓╬▓▓██▓╬╬╬╬╬╬╬▓███
// ███████▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬████
// ███████▓▓██▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓████
// ████████▓▓▓█████▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█████
// █████████▓▓▓█▓▓▓▓▓███▓╬╬╬╬╬╬╬╬╬╬╬▓██████
// ██████████▓▓▓█▓▓▓╬▓██╬╬╬╬╬╬╬╬╬╬╬▓███████
// ███████████▓▓█▓▓▓▓███▓╬╬╬╬╬╬╬╬╬▓████████
// ██████████████▓▓▓███▓▓╬╬╬╬╬╬╬╬██████████
// ███████████████▓▓▓██▓▓╬╬╬╬╬╬▓███████████
//#include "grader.h"
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <cassert>
#define For(i, a, b) for (int i = a; i < b; ++i)
#define Out(i, a, b) for (int i = a - 1; i >= b; --i)
#define pb push_back
#define x first
#define y second
#define files(FileName) read(FileName); write(FileName)
#define read(FileName) freopen((FileName + ".in").c_str(), "r", stdin)
#define write(FileName) freopen((FileName + ".out").c_str(), "w", stdout)
using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }

using namespace std;

const string FILENAME = "input";
const int MAXN = 2e5 + 1;

typedef long long base;
typedef pair <base, base> point;

int n, m;
bool used[MAXN];
vector <int> edge[MAXN];
int s, f;

deque <int> ans;

int main() {
	ios::sync_with_stdio(0);
//read(FILENAME);
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		edge[a].pb(b);
		edge[b].pb(a);
	}
	s = f = 1;
	used[f] = true;
	ans.push_back(f);
	while (edge[f].size()) {
		if (used[edge[f].back()]) {
			edge[f].pop_back();
		} else {
			f = edge[f].back();
			used[f] = true;
			ans.push_back(f);
		}
	}
	while (edge[s].size()) {
		if (used[edge[s].back()]) {
			edge[s].pop_back();
		} else {
			s = edge[s].back();
			used[s] = true;
			ans.push_front(s);
		}
	}
	cout << ans.size() << endl;
	while (ans.size()) {
		cout << ans.front() << ' ';
		ans.pop_front();
	}
}



Measured memory_bytes: 9068
#!/usr/bin/env python3
n, k = map(int, input().split())
d = []
a = []

for _ in range(k):
    d.append(int(input()))
    a.append(list(map(int, input().split())))

check = [False] * n

for i in range(k):
    for j in a[i]:
        check[j-1] = True

ans = 0
for i in range(n):
    if not check [i]:
        ans += 1

print(ans)
# thx for https://qiita.com/taxfree_python/items/491269d25cb7bcd9965b



Measured memory_bytes: 9188
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  int n; cin>>n;
  vector<pair<int,int>> d(n);
  rep(i,n){
    int x,y; cin>>x>>y;
    d[i].first=x;
    d[i].second=y;
  }
  rep(i,n-2){
    if(d[i].first==d[i].second){
      if(d[i+1].first==d[i+1].second){
        if(d[i+2].first==d[i+2].second){
          cout<<"Yes"<<endl;
          return 0;
        }
      }
    }
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll popcount(ll n){
    ll ret=0;
    while(n>0){
        ret+=n%2;
        n/=2;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    vector<int> v[n+1];
    rep(i,0,n-1){
        int a,b;cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    int par[n+1];
    par[1]=0;
    v[0].push_back(0);
    queue<int> q;
    q.push(1);
    int dis[n+1];
    dis[1]=0;
    bool used[n+1];
    fill(used,used+n+1,false);
    used[1]=true;
    used[0]=true;
    while(q.size()>0){
        int now=q.front();q.pop();
        rep(i,0,v[now].size()){
            int ne=v[now][i];
            if(used[ne])continue;
            used[ne]=true;
            par[ne]=now;
            q.push(ne);
            dis[ne]=dis[now]+1;
        }
    }
    int m;cin>>m;
    ll st[m];
    
    int ff[m],gg[m];
    rep(i,0,m){
        int f,g;cin>>f>>g;
        st[i]=0;
        ff[i]=f;gg[i]=g;
        int df=dis[f],dg=dis[g];
        for(;;){
            if(df<dg){
                st[i]+=Pow(2,g);
                g=par[g];
                dg--;
            }
            else if(dg<df){
                st[i]+=Pow(2,f);
                f=par[f];
                df--;
            }
            else{
                if(f==g){
                    break;
                }
                st[i]+=Pow(2,f);
                st[i]+=Pow(2,g);
                df--;
                dg--;
                f=par[f];
                g=par[g];
            }
        }
    }
    ll ans=0;
    for(int i=1;i<(1<<m);i++){
        int u=i;
        ll now=0;
        ll cnt=0;
        rep(j,0,m){
            if(u%2){
                cnt++;
                now|=st[j];
                
            }
            u/=2;
        }
        
        ll r=Pow(2,n-1-popcount(now));
        if(cnt%2)ans+=r;
        else ans-=r;
        
    }
    ans=Pow(2,n-1)-ans;
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int alphabet_s[26];
int alphabet_t[26];
int main() {
	string s,t;
	cin>>s>>t;
	for(int i=0;i<s.size();i++)
	{
		alphabet_s[s[i]-'a']++;
	}
	for(int i=0;i<t.size();i++)
	{
		alphabet_t[t[i]-'a']++;
	}
	vector<int>v_s,v_t;
	for(int i=0;i<26;i++)
	{
		if(alphabet_s[i])v_s.push_back(alphabet_s[i]);
		if(alphabet_t[i])v_t.push_back(alphabet_t[i]);
	}
	sort(v_s.begin(),v_s.end());
	sort(v_t.begin(),v_t.end());
	if(v_s==v_t)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define nl '\n'
typedef long long ll;
typedef long double ld;
//////////////////////////////////////////////////////////////////////

const ll INF = 4e18;
const int N = 221 , R = 8;
int n,m,r,a[R];
ll d[N][N],dp[R][1<<R];

int main(){
  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  
  cin>>n>>m>>r;
  
  for(int i=0;i<r;i++)cin>>a[i],a[i]--;

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++)d[i][j] = INF;
    d[i][i]=0;
  }
  
  for(int u,v,w,e=1;e<=m;e++){
    cin>>u>>v>>w;
    u--,v--;
    d[u][v] = d[v][u] = w;
  }

  for(int k=0;k<n;k++)
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	d[i][j] = min(d[i][j] , d[i][k]+d[k][j]);
  
  for(int i=0;i<r;i++){
    fill(dp[i],dp[i]+(1<<r),INF);
    dp[i][1<<i] = 0;
  }
  int all = (1<<r)-1;
  for(int mask=1;mask<=all;mask++)
    for(int last=0;last<r;last++){
      if((mask&(1<<last))==0)continue;
      int bit = 1<<last;
      int prevMask = mask^bit;
      for(int prev=0;prev<r;prev++){
	if(prev==last)continue;
	if((mask&(1<<prev))==0)continue;
	dp[last][mask] = min(dp[last][mask] ,
			     dp[prev][prevMask] + d[a[prev]][a[last]]);
      }
    }
  
  ll ans = INF;
  for(int i=0;i<r;i++)
    ans = min(ans , dp[i][all]);
  cout <<  ans << nl;
  
  return 0;
};


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

int main() {
  int n,m;
  string s;
  cin>>n>>m>>s;
  reverse(s.begin(),s.end());
  int now=0;
  vector<int> ans;
  while (now!=n) {
    now+=m;
    bool flag=false;
    int i;
    for (i=0; i<m; i++) {
      if (s[now]=='0'&&now<=n) {
	flag=true;
	break;
      }
      now--;
    }
    if (!flag) {
      cout<<-1<<endl;
      return 0;
    }
    ans.push_back(m-i);
  }
  reverse(ans.begin(),ans.end());
  for (int x: ans) {
    cout<<x<<' ';
  }
  return 0;
}




Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL a_cost[100005];
vector<int>vec_edge[100005];
int bin[100005];
int deep[100005];
int fin(int n);
int uid[100005];
typedef struct node
{
    int id;
    LL val;
    bool operator <(const node &cx)const
    {
        return cx.val < val;
    }
} ss;
priority_queue<ss>que;
ss ans[100005];
bool cmp(node p,node q);
int main(void)
{
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i = 0; i < n; i++)
        scanf("%lld",&a_cost[i]);
    for(int i = 0; i < n; i++)
        bin[i] = i,deep[i] = 1;
    while(m--)
    {
        int x,y;
        scanf("%d %d",&x,&y);
        int nx = fin(x);
        int ny = fin(y);
        if(nx!=ny)
        {
            if(deep[nx] > deep[ny])
            {
                deep[nx] += deep[ny];
                bin[ny] = nx;
            }
            else
            {
                deep[ny] += deep[nx];
                bin[nx] = ny;
            }
        }
    }
    for(int i = 0; i < n; i++)
    {
        int id = fin(i);
        vec_edge[id].push_back(i);
    }
    int cn = 0;
    for(int i = 0;i < n;i++)
    {
        if(vec_edge[i].size())
        {
            ans[cn] = node{i,vec_edge[i].size()};
            cn++;
        }
    }
    sort(ans,ans+cn,cmp);
    LL sum = 0;
    int cnt = 0;
    for(int i = 0; i < cn; i++)
    {   int ip = ans[i].id;
        if(vec_edge[ip].size())
        {
            int id = vec_edge[ip][0];
            LL min_val = a_cost[id];
            for(int j = 0; j < vec_edge[ip].size(); j++)
            {
                int ic = vec_edge[ip][j];
                if(min_val > a_cost[ic])
                    id = ic,min_val = a_cost[ic];
            }
            if(!que.empty())
            {
                node ask = que.top();
                que.pop();
                sum += ask.val + min_val;
                for(int j = 0; j < vec_edge[ip].size(); j++)
                {
                    int ic = vec_edge[ip][j];
                    if(ic != id)
                        que.push(node{ic,a_cost[ic]});
                }
            }
            else
            {
                cnt++;
                if(cnt == 2)
                {
                    sum = -1;
                    break;
                }
                else
                {
                    for(int j = 0; j < vec_edge[ip].size(); j++)
                    {
                        int ic = vec_edge[ip][j];
                            que.push(node{ic,a_cost[ic]});
                        //printf("%d\n",ic);
                    }
                }
            }
        }
    }
    if(sum == -1)
        printf("Impossible\n");
    else printf("%lld\n",sum);
    return 0;
}
int fin(int n)
{
    while(n!=bin[n])
        n = bin[n];
    return n;
}
bool cmp(node p,node q)
{
    return p.val > q.val;
}


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

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int64_t s = 1000000000;
  for (int i = 0; i <= max(x, y) * 2; i += 2) {
    int64_t t = i * c + max(0, (x - i / 2)) * a + max(0, (y - i / 2)) * b;
    if (t < s) s = t;
  }
  cout << s << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		double x1 = sc.nextDouble(), y1 = sc.nextDouble(), x2 = sc.nextDouble(), y2 = sc.nextDouble();
		System.out.printf("%.9f\n", Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
	}
}

Measured memory_bytes: 27988
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>

using namespace std;

const long waru = 1000000007;
long pow3[100010];

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

    pow3[0] = 1;
    for(int i=1; i<100010; i++)
    {
        pow3[i] = pow3[i-1] * 3 % waru;
    }

    long a[100001] = {};
    long c[100001] = {};
    long h[100001] = {};
    for(int i=0; i<s.length(); i++)
    {
        if(i != 0)
        {
            a[i] += a[i-1];
            c[i] += c[i-1];
            h[i] += h[i-1];
        }

        if(s[i] == 'A') a[i]++;
        if(s[i] == 'C') c[i]++;
        if(s[i] == '?') h[i]++;
    }

    long ans = 0;

    for(int i=1; i<s.length()-1; i++)
    {
        if(s[i] == 'B' || s[i] == '?')
        {
            int lh = h[s.length()-1] - h[i];
            int lc = c[s.length()-1] - c[i];

            // 1
            if(a[i-1] > 0 && lc > 0)
            {
                ans = (ans + a[i-1] * lc * pow3[h[i-1] + lh]) % waru;
            }

            // 2
            if(h[i-1] > 0 && lc > 0)
            {
                ans = (ans + h[i-1] * lc * pow3[h[i-1] - 1 + lh]) % waru;
            }

            // 3
            if(a[i-1] > 0 && lh > 0)
            {
                ans = (ans + a[i-1] * lh * pow3[h[i-1] + lh - 1]) % waru;
            }

            // 4
            if(h[i-1] > 0 && lh > 0)
            {
                ans = (ans + h[i-1] * lh * pow3[h[i-1] - 1 + lh - 1]) % waru;
            }
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3584
//PCK2015予選4
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int N;
    while(cin>>N,N!=0){
        string s;
        cin>>s;
        int field = 0;
        vector<int> P(N,0);
        for(int i=0;i<100;++i){
            ++P[i%N];
            if(s[i] =='S') field += P[i%N],P[i%N] = 0;
            if(s[i] == 'L') P[i%N]+=field,field=0;
        }
        sort(P.begin(),P.end());
        for(int i=0;i<N;++i) cout<<P[i]<<" ";
        cout<<field<<endl;
    }
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define int long long
#define sz(x) ((long long)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define oo 1e15;
const ld eps = 1e-9;
const ld pi = acosl(-1);
const int mod = 998244353;
const int mod1 = 1e9 + 7;


mt19937_64 rnd(time(0));

void faster()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios::sync_with_stdio(false);
}

signed main() {
    faster();
    // freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
    //______________________________________
    ///*__*/double start = clock();/*__*/
    //_____________________________________
    int n, W;
    cin >> n >> W;
    vector <pair <int, int> > v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i].second >> v[i].first;
    vector <vector <int> > dp(n + 1, vector <int> (W + 1, 0));
    for (int i = 1; i <= n; i++)
    {
        auto el = v[i - 1];
        for (int j = 0; j < el.second && j <= W; j++)
        {
            dp[i][j] = dp[i - 1][j];
        }
        for (int j = el.second; j <= W; j++)
        {
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - el.second] + el.first);
        }
    }
    int ans = 0;
    for (int j = 0; j <= W; j++)
        ans = max(ans, dp[n][j]);
    cout << ans;
    //______________________________________
    //  cerr << "Time " << (clock() - start)  * 1.0 / CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 80256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int b = sc.nextInt();
			int r = sc.nextInt();
			int g = sc.nextInt();
			int c = sc.nextInt();
			int s = sc.nextInt();
			int t = sc.nextInt();
			if((b|r|g|c|s|t)==0)break;
			System.out.println(100 + b*15 + r*15 + (b*5+r*3)*15 + g*7 + c*2 - (b*5+r*3)*2 - (t-b*5-r*3-s)*3);
		}
	}
}

Measured memory_bytes: 21012
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

[[maybe_unused]] constexpr ll LL_MAX = numeric_limits<ll>::max();
[[maybe_unused]] constexpr ll LL_MIN = numeric_limits<ll>::min();
[[maybe_unused]] constexpr ull ULL_MAX = numeric_limits<ull>::max();

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

template <typename T>
void chmin(T& x, T y) {
    x = min(x, y);
}

template <typename T>
void chmax(T& x, T y) {
    x = max(x, y);
}

ll csum(ll x, ll y) {
    if (x > 0 && y > 0 && x > LL_MAX - y) {
        return LL_MAX;
    }
    if (x < 0 && y < 0 && x < LL_MIN - y) {
        return LL_MIN;
    }
    return x + y;
}

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

int main() {
	ll N;
	cin >> N;
	ll ans = 0;
	rep(d,1,N+1) {
		ll n = N / d;
		ll ans_loc = d * ((n * (n+1)) / 2);
		ans += ans_loc;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3216
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
// clang-format on

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, R;
  cin >> N >> R;

  if (N >= 10) {
    cout << R << endl;
  } else {
    cout << R + 100 * (10 - N) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: utf-8 -*-

# def
def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

def str_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return np.array(x)

def int_map():
    return map(int,input().split())

def int_list():
    return list(map(int,input().split()))

def print_space(l):
    return print(" ".join([str(x) for x in l]))

# import
import numpy as np
import collections as col

N = int(input())

print((10**N-2*(9**N)+8**N)%(10**9+7))

Measured memory_bytes: 28880
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    #x = int(stdin.readline().rstrip())
    n,d = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    ans = 0
    for i in range(n):
        ds = (numbers[i][0] ** 2 + numbers[i][1] ** 2) ** 0.5
        if ds <= d:
            ans += 1
    print(ans)



if __name__ == '__main__':
    solve()


Measured memory_bytes: 42588
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using System;

public class P
{
    public int x { get; set; }
    public int y { get; set; }
}

public class Hello
{
    public static int ans = 0;
    public static int[] dx, dy;
    public static int h, w;
    public static bool[,] map;
    public static void Main()
    {
        dx = new int[] { 0, 1, 0, -1 };
        dy = new int[] { 1, 0, -1, 0 };
        string[] line = Console.ReadLine().Trim().Split(' ');
        h = int.Parse(line[0]);
        w = int.Parse(line[1]);
        map = new bool[h, w];
        for (int i = 0; i < h; i++)
        {
            var s = Console.ReadLine().Trim();
            for (int j = 0; j < w; j++)
                if (s[j] == '.') map[i, j] = true;
        }
        for (int i = 0; i < h; i++)
            for (int j = 0; j < w; j++)
                if (map[i, j]) getAns(i, j);
        Console.WriteLine(ans);
    }
    static void getAns(int sx, int sy)
    {
        var t = new int[h, w];
        for (int i = 0; i < h; i++)
            for (int j = 0; j < w; j++) t[i, j] = 1000; ;
        var q = new Queue<P>();
        q.Enqueue(new P { x = sx, y = sy });
        t[sx, sy] = 0;
        while (q.Count() > 0)
        {
            var a = q.Dequeue();
            for (int i = 0; i < 4; i++)
            {
                var nx = a.x + dx[i];
                var ny = a.y + dy[i];
                if (nx >= 0 && nx < h && ny >= 0 && ny < w && map[nx, ny] && t[a.x, a.y] +1 < t[nx,ny] )
                {
                    t[nx, ny] = t[a.x, a.y] + 1;
                    ans = Max(ans, t[nx, ny]);
                    q.Enqueue(new P { x = nx, y = ny });
                }
            }
        }
    }
}


Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

        Scanner cin=new Scanner(System.in);
        String a = cin.nextLine();

        int max = 0;
        int now = 0;

        for(int i = 0; i < a.length(); i++){
        	if(a.charAt(i) == 'T'){
        		now++;
        		if(now >= max){
        			max = now;
        		}
        	}else{
        		now--;
        	}
        }
        System.out.println(max * 2);
	}

}

Measured memory_bytes: 14196
from bisect import bisect_right
n = int(input())

color = [0] * (n+1)
for i in range(n):
    a = int(input())
    j = bisect_right(color, a)
    color[j-1] = a+1

ans = 0
for t in color:
    if t != 0:
        ans += 1

print(ans)



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

using namespace std;

bool f(long long x, long long K){
  vector<int> xd;
  while(x){
    xd.push_back(x % 10);
    x /= 10;
  }
  
  reverse(xd.begin(), xd.end());
  
  long long dp[xd.size()][10][2];
  for(int d = 0; d < 10; d++){
    if(d > 0 && d < xd[0]) dp[0][d][1] = 1;
    else dp[0][d][1] = 0;
    
    dp[0][d][0] = 0;
  }
  dp[0][xd[0]][0] = 1;
  
  for(int i = 1; i < xd.size(); i++){
    for(int d = 0; d < 10; d++){
      dp[i][d][1] = dp[i - 1][d][1];
      dp[i][d][0] = 0;
      
      if(d < xd[i]) dp[i][d][1] += dp[i - 1][d][0];
      
      if(d > 0){
        dp[i][d][1]++;
        
        dp[i][d][1] += dp[i - 1][d - 1][1];
        
        if(d < xd[i]) dp[i][d][1] += dp[i - 1][d - 1][0];
      }
      
      if(d < 9){
        dp[i][d][1] += dp[i - 1][d + 1][1];
        
        if(d < xd[i]) dp[i][d][1] += dp[i - 1][d + 1][0];
      }
    }
    
    if(abs(xd[i - 1] - xd[i]) <= 1){
      dp[i][xd[i]][0] = dp[i - 1][xd[i - 1]][0];
    }
  }
  
  long long sum = 0;
  for(int d = 0; d < 10; d++){
    sum += dp[(int)xd.size() - 1][d][1] + dp[(int)xd.size() - 1][d][0];
  }
  
  return sum >= K;
}

int main(){
  long long K;
  cin >> K;
  
  long long ok = (1ll << 61);
  long long ng = 0;
  while(ok - ng > 1){
    long long mid = (ok + ng) / 2;
    (f(mid, K) ? ok : ng) = mid;
  }
  
  cout << ok << endl;
  
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <math.h>

void func(double r)
{
	double S, l;

	l = 2 * M_PI*r;
	S = M_PI*r*r;

	printf("%f %f\n", S, l);
}

int main(void)
{
	double r;
	scanf("%lf", &r);

	func(r);

	return 0;
}

Measured memory_bytes: 648
N,P = map(int,input().split())
ans=1
i=2
if N==1:
  print(P)
  exit()
if N>=40 or P==1:
  print(1)
  exit()
  
while i<=(P**(1.001/N)):
  while P%(i**N) == 0:
    ans *= i
    P = P//(i**N)
  if i==2:
    i+=1
  else:
    i+=2
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 10000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
  P a[110000];
  int N,M,ans=0,temp=-1;
  cin>>N>>M;

  for(int i=0;i<M;i++){
    cin>>a[i].first>>a[i].second;
    a[i].first*=(-1);
    a[i].second*=(-1);
  } 

  sort(a,a+M);

  for(int i=0;i<M;i++){
    if(temp<=a[i].second*(-1) && temp>a[i].first*(-1)){
      continue;
    }else{
      ans++;
      temp=a[i].first*(-1)+1;
    }
  }
  cout<<ans<<endl;
}


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

#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			1'010'000'000'000'000'017LL
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )

using namespace std;

template<class T>
bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>
bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}


void Main()
{
	vi X(5, 0);
	rep(i, 0, 5) cin >> X[i];
	rep(i, 0, 5) {
		if (X[i] == 0) cout << i + 1 << endl;
	}
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	Main();
	return 0;
}

Measured memory_bytes: 3608
H, W = map(int, input().split())
grid = [input() for _ in range(H)]

L = [[0] * (W + 1) for _ in range(H + 1)]
R = [[0] * (W + 1) for _ in range(H + 1)]
A = [[0] * (W + 1) for _ in range(H + 1)]
B = [[0] * (W + 1) for _ in range(H + 1)]

for h in range(H):
    for w in range(W):
        if grid[h][w] == '.':
            L[h][w + 1] = L[h][w] + 1
            A[h + 1][w] = A[h][w] + 1

        hh = H - 1 - h
        ww = W - 1 - w
        if grid[hh][ww] == '.':
            B[hh - 1][ww] = B[hh][ww] + 1
            R[hh][ww - 1] = R[hh][ww] + 1

ans = 0
for h in range(H):
    for w in range(W):
        if grid[h][w] == '.':
            ans = max(ans, L[h][w] + R[h][w] + A[h][w] + B[h][w] + 1)
print(ans)


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

// Union-Find木
class UnionFind{
    public:
    vector<ll> par;//親ノード
    UnionFind(int n) : par(n,-1){}
    //根を求める（同時に経路圧縮）
    int root(int x){
        if(par[x]<0) return x;
        return par[x]=root(par[x]);
    }
    //根が等しいか判定
    bool issame(int x,int y){
        return root(x)==root(y);
    }
    //マージ
    bool unite(int x,int y){
        x=root(x);y=root(y);
        if(x==y)return false;
        if(par[x]>par[y]) std::swap(x,y);
        par[x] +=par[y];//根は-(size)
        par[y]=x;
        return true;
    }
    //属す根のサイズ
    int size(int x){
        return -par[root(x)];
    }
};

int main() {
    int N,K,L;
    cin >>N>>K>>L;

    int x,y;
    UnionFind road(N),train(N);
    rep(i,K){
        cin >> x>>y;x--;y--;
        road.unite(x,y);
    }
    rep(i,L){
        cin >> x>>y;x--;y--;
        train.unite(x,y);
    }
    //mapを用いてO(n)でcnt//mapのデフォが0なので便利
    map<pair<int,int >,int> mp;
    vector<pair<int,int>> vec(N);
    rep(i,N){
        vec[i]={road.root(i),train.root(i)};
        mp[vec[i]]++;
    }

    rep(i,N) cout << (i==0 ? "" :" ") << mp[vec[i]];
    cout <<endl;
    return (0);
}

Measured memory_bytes: 16640
fn main() {
    let v = read_vec::<u64>();
    let n = v[0];
    let k = v[1];

    if n > k {
        println!("{}", std::cmp::min(n % k, k - n % k));
    } else if n == k {
        println!("{}", 0);
    } else {
        println!("{}", std::cmp::min(n, k - n));
    }
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

using namespace std;

const int DIM = 2e5 + 7;

#define int long long

priority_queue <pair <int, int> > q;

int a[DIM];
int b[DIM];

int n;

int lft(int pos)
{
	pos--;
	
	if(pos == 0)
		pos = n;
	
	return pos;
}

int rht(int pos)
{
	pos++;
	
	if(pos == n + 1)
		pos = 1;
	
	return pos;
}

main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n;
	
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	
	for(int i = 1; i <= n; i++)
	{
		cin >> b[i];
		
		if(a[i] != b[i])
			q.push({b[i], i});
	}
	
	int ans = 0;
	
	while(!q.empty())
	{
		int val = q.top().first;
		int id = q.top().second;
		
		q.pop();
		
		int dif = val - a[id];
		
		int p = b[lft(id)] + b[rht(id)];
		
		int k = dif / p;
		k = max(k, 1LL);
		
		ans += k;
		
		val -= k * p;
		
		if(val < a[id])
		{
			cout << -1;
			return 0;
		}
		
		b[id] = val;
		
		if(val != a[id])
			q.push({val, id});
	}
	
	cout << ans;
}

Measured memory_bytes: 8944
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {
	
	int n;
	scanf("%d", &n);
	string s;
	scans(s);
	int acnt = 0, bcnt = 0;
	rep(i, s.length()){
	  if(s[i] == ')'){
	    if(!bcnt)++acnt;
	    else --bcnt;
	    }
	  else {
	    ++bcnt;
	    }
	}
	while(acnt--)printf("(");
	while(bcnt--)s.pb(')');
	prints(s);
	
	Please AC;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;



int main() {
    int n,m,x,y; cin >> n >> m >> x >> y;
    int mx = -101, ym = 101;
    vector<int> vec;
    for(int i = 0;i < n;i++){
        int a; cin >> a;
        mx = max(mx,a);
        if(x < a && a <= y) vec.push_back(a);
    }
    for(int i = 0;i < m;i++){
        int b; cin >> b;
        ym = min(ym,b);
        if(x < b && b <= y) vec.push_back(b);
    }
    string ans = "War";
    for(int i = 0;i < vec.size();i++){
        if(mx < vec[i] && vec[i] <= ym){
            ans = "No War";
            break;
        }
    }
    cout << ans;
}


Measured memory_bytes: 3656
#include<iostream>

using namespace std;

#define NUM_ALPHABET 26

int last[NUM_ALPHABET];

int main()
{
  int D;
  cin >> D;
  
  int c[NUM_ALPHABET];
  
  for(int i = 0; i < NUM_ALPHABET; i++)
    cin >> c[i];
  
  int s[D][NUM_ALPHABET];
  
  for(int d=0;d<D;d++)
      for(int i = 0; i < NUM_ALPHABET; i++)
		cin >> s[d][i];
  
  for(int d=1;d<=D;d++)
  {
    int max_i = -1;
    int max_s = -1;
    
    for(int i = 0; i < NUM_ALPHABET; i++)
    {
      //calc max
      int di = d - 1;
      int score = c[i] * (d - last[i]) + s[d-1][i];
      if(score>max_s)
      {
        max_i = i;
        max_s = score;
      }
    }
    
    last[max_i] = d;
    cout << max_i + 1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3672
#include<iostream>
#include <string>
#include <cstring>
using namespace std;
 
int main(){
    int K;
    string S;
    cin>> K;
    cin>>S;
  	if ((int)(S.length())<=K){
          cout<<S<<endl;
    } else {
        S = S.substr(0,K) + "...";
        cout<<S<<endl;
    }

    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define pb push_back
#define Int int64_t
using namespace std;

int64_t N;
int64_t K;
int main()
{
    cin>>N>>K;
    vector<Int> A(N),B(N);
    for(auto &x:A) cin>>x;
    for(auto &itr:B) cin>>itr;
    
    sort(A.begin(),A.end());
    sort(B.rbegin(),B.rend());
    
    Int low=0,high=1e12;
    Int answer=high;
    while(low<=high){
        Int mid=(low+high)>>1LL;
        Int sum=0;
        for(int i=0;i<N;++i) sum+=max((Int)0,A[i]-mid/B[i]);
        if(sum<=K){
            high=mid-1;
            answer=mid;
        }
        else low=mid+1;
    }

    cout<<answer<<"\n";
}

Measured memory_bytes: 6336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vrsort(v) sort((v).rbegin(), (v).rend())
#define vreverse(v) reverse((v).begin(), (v).end())
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define pb(a) push_back(a)
#define INF 2000000009
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  struct UndirectedGraph 
{
    using Pint = pair<ll, ll>;
    using Plint = pair<ll, ll>;
    ll V;
    ll E;
    ll dDefault;
    vector<ll> weights;
    vector<vector<Pint>> to;
    vector<Pint> edges;
 
    UndirectedGraph(ll V, ll dDefault=-1) : V(V), E(0), dDefault(dDefault),
                             to(vector<vector<Pint>>(V)) {}
 
    void add_edge(ll v1, ll v2, ll w)
    {
        to[v1].push_back(Pint(v2, E));
        // to[v2].push_back(Pint(v1, E));
        edges.push_back(Pint(v1, v2));
        weights.push_back(w);
        E++;
    }
 
    vector<ll> dist;
    void dijkstra(ll start)
    {
        dist = vector<ll>(V, dDefault);
        priority_queue<Plint, vector<Plint>, greater<Plint>> pq;
        pq.push(Plint(0, start));
 
        while (!pq.empty()) {
            Plint p = pq.top(); pq.pop();
            ll v = p.second;
            if (dist[v] >= 0 && dist[v] <= p.first) continue;
            dist[v] = p.first;
            // cout << "dist[" << v << "] = " << p.first << endl;
            for (auto vnxt : to[v]) {
                ll dnxt = dist[v] + weights[vnxt.second];
                if (dnxt < dist[vnxt.first] || dist[vnxt.first] < 0) {
                    pq.push(Plint(dnxt, vnxt.first));
                }
            }
        }
    }
};
  
  ll n;cin>>n;
  UndirectedGraph graph(n);
  ll a,b,c;
  
  rep(i,n-1){
    cin>>a>>b>>c;a--;b--;
    graph.add_edge(a,b,c);
    graph.add_edge(b,a,c);
  }
  
  graph.dijkstra(0);
  
  rep(i,n){cout<<graph.dist[i]%2<<endl;}
  
}

Measured memory_bytes: 14060
use std::io::prelude::*;

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

fn main() {
    let h = input::<usize>();
    let w = input::<usize>();
    let k = input::<usize>();
    const MOD: usize = 1000000007;

    let mut dp = vec![vec![0; w as usize + 1]; h as usize + 1];
    dp[0][1] = 1;
    for i in 0..h {
        for j in 1..w + 1 {
            for k in 0..1 << (w - 1) {
                if w > 1 {
                    let mut ok = true;
                    for l in 0..w - 2 {
                        if k & (1 << l) > 0 && k & (1 << (l + 1)) > 0 {
                            ok = false;
                        }
                    }
                    if !ok {
                        continue;
                    }
                }

                if j > 1 && k & (1 << (j - 2)) > 0 {
                    dp[i + 1][j - 1] += dp[i][j];
                    dp[i + 1][j - 1] %= MOD;
                } else if j < w && k & (1 << j - 1) > 0 {
                    dp[i + 1][j + 1] += dp[i][j];
                    dp[i + 1][j + 1] %= MOD;
                } else {
                    dp[i + 1][j] += dp[i][j];
                    dp[i + 1][j] %= MOD;
                }
            }
        }
    }
    let ans = dp[h][k];
    println!("{}", ans);
}


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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x));
#define umin(m, x) (m = min(m, x));

#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

const int INF = 1e9;
const ll LINF = 1e18;


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

    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    sort(rng(a));

    ll m;
    m = k - a[a.size() - 1] + a[0];
    rep(i, n - 1)
        umax(m, a[i + 1] - a[i]);

    cout << k - m << endl;

    return 0;
}


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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef long long ll;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define fi first
#define se second

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

    char c;
    cin >> c;
    if(c >= 'a')
        cout << "a\n";
    else
        cout << "A\n";

    return 0;
}



Measured memory_bytes: 3644
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}

module Main where

import qualified Data.ByteString.Char8 as B8
import Data.Maybe (fromJust)
import Data.Char (toUpper,isDigit)
import Data.List
import qualified Data.Map as M
import Data.Array.IO
import Data.IORef
import Data.Ix (range)
import Control.Monad
import Control.Applicative
import Text.Printf
import Data.Time.Calendar
import Debug.Trace

readDigits = map read <$> words <$> getLine :: IO [Int]
readDigits' = map read <$> lines <$> getContents :: IO [Int]

--
main :: IO ()
main = do
    fn <$> readDigits >>= putStrLn
    where
    fn [a,b]
        | a < b = "a < b"
        | a > b = "a > b"
        | a == b = "a == b"

Measured memory_bytes: 3660
// Problem : E - Dividing Chocolate
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e9 + 7;
const ll maxN = 1e3 + 5;
const ll MOD = 1e9 + 7;

int h, w, k;
string s;
int arr[maxN][maxN];

int solve(int mask) {
	int ile = __builtin_popcount(mask) + 1;
	int prev = 0;
	vector<pii> vec;
	REP(i, h) {
		if (mask & (1 << i)) {
			vec.pb({prev, i});
			prev = i + 1;
		}
	}
	vec.pb({prev, h - 1});
	assert(sz(vec) == ile);
	vi cnt(ile, 0);
	int ans = ile - 1;
	REP(i, w) {
		vi lastCol(ile, 0);
		REP(j, h) {
			if (arr[j][i] == 0) continue;
			// bierzemy arr[j][i]
			REP(z, ile) {
				if (vec[z].st <= j && vec[z].nd >= j) {
					cnt[z]++;
					lastCol[z]++;
				}
			}
		}
		REP(z, ile) {
			if (cnt[z] > k) {
				ans++;
				swap(cnt, lastCol);
				break;
			}
		}
		REP(z, ile) {
			if (cnt[z] > k) return inf;
		}
	}
	//cout << mask << " " << ans << endl;
	return ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> h >> w >> k;
	REP(i, h) {
		cin >> s;
		REP(j, w) {
			arr[i][j] = s[j] - '0';
		}
	}
	int ans = h * w * h;
	REP(mask, (1 << (h - 1))) {
		ans = min(ans, solve(mask));
	}
	cout << ans << endl;
	return 0;
}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
//---------------------------------------------------------------------------------------------------

int main(void){
    // Your code here!
    int n; cin >> n;
    vi a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i];
    Sort(a);
    Sort(b);
    if (n % 2 == 0) {
        int mi = a[n/2] + a[n/2-1],ma = b[n/2]+ b[n/2-1];
        cout << ma - mi + 1 << endl;
    } else {
        int mi = a[n/2],ma = b[n/2];
        cout << ma - mi + 1 << endl;
    }
}


Measured memory_bytes: 4816