akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm> //next_permutation

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
  int n;
  cin>>n;
  vector <int> p(n),q(n);
  for (int i=0;i<n;i++) {cin>>p[i];p[i]--;}
  for (int i=0;i<n;i++) {cin>>q[i];q[i]--;}
  vector<int>V(n);
  map<vector<int>,int> ord;
  int count=0;
  for(int i=0;i<n;i++) V[i]=i;
  do{
    ord[V]=count++;
  }while(next_permutation(V.begin(),V.end()));

int ans=abs(ord[p]-ord[q]);
cout<<ans;
  }


Measured memory_bytes: 5248
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int a, b,k;
	cin >> a >> b>>k;

	if (a>=k) {
		cout << a-k<<" "<<b << "\n";
	}
	else {
		cout << 0<<" "<<max(0LL,b-(k-a)) << "\n";
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型
using pint = pair<int, int>;

int main()
{
    int a, b;
    cin >> a >> b;
    string c = to_string(b);
    int con = a * pow(10, c.size()) + b;
    bool ok = false;
    rep(i, 1001)
    {
        if (i * i == con)
        {
            ok = true;
        }
    }
    if (ok)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
def add_edge(node, adj_lst, s1, s2):
  ind = 0
  max_len = min(len(s1), len(s2))
  while ind < max_len and s1[ind] == s2[ind]:
    ind += 1
  if ind == max_len:
    return max_len < len(s1)

  c1 = ord(s1[ind]) - ord("a")
  c2 = ord(s2[ind]) - ord("a")
  adj_lst[c1].add(c2)
  node.add(c1)
  node.add(c2)
  return False

def visit(n, visited, adj_lst):
  ret = False
  if visited[n] == 2:
    return True
  elif visited[n] == 0:
    visited[n] = 2
    for to in adj_lst[n]:
      ret = ret or visit(to, visited, adj_lst)
    visited[n] = 1
  return ret
 
def main():
  while True:
    n = int(input())
    if n == 0:
      break
    
    lst = [input() for _ in range(n)]
    node = set()
    adj_lst = [set() for _ in range(26)]
    blank_flag = False
    for i in range(n):
      for j in range(i + 1, n):
        blank_flag = blank_flag or add_edge(node, adj_lst, lst[i], lst[j])
    if blank_flag:
      print("no")
      continue
    
    visited = [0] * 26
    cycle_flag = False
  
    for n in node:
      cycle_flag = cycle_flag or visit(n, visited, adj_lst)
    if cycle_flag:
      print("no")
    else:
      print("yes")

main()


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

int main(){
  int n;
  cin >> n;
  vector<tuple<string,int,int>> sp(n);
  int p;
  for(int i=0;i<n;i++){
    cin >> get<0>(sp.at(i)) >> p;
    get<1>(sp.at(i))=100-p;
    get<2>(sp.at(i))=i+1;
  }
  sort(sp.begin(),sp.end());
  for(int i=0;i<n;i++){
    cout << get<2>(sp.at(i)) << endl;
  }
  
}
    


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#include <climits>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#include <bits/stdc++.h>
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

using ld = double;
using P = complex<ld>;
using G = vector<P>;
const ld pi = acos(-1);
const ld eps = 1e-10;
const ld inf = 1e12;

ld cross(const P& a, const P& b) { return a.real()*b.imag() - a.imag()*b.real(); }
ld dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }

using C = pair<ld, P>;
#define rad first
#define pnt second

C smallest_enclosing_disc(vector<P> ps){
    auto c3 = [](const P &a, const P &b, const P &c){
        ld A = norm(b - c);
        ld B = norm(c - a);
        ld C = norm(a - b);
        ld S = abs(cross(b - a, c - a));
        P p = (A*(B+C-A)*a + B*(C+A-B)*b + C*(A+B-C)*c) / (4*S*S);
        ld r = abs(p - a);
        return make_pair(r, p);
    };

    auto c2 = [](const P &a, const P &b){
        P c = (a + b) / (ld)2;
        ld r = abs(a - c);
        return make_pair(r, c);
    };

    auto in_circle = [](const P &a, const C &c){
        return norm(a - c.pnt) <= c.rad*c.rad + eps;
    };

    int n = ps.size();
    random_shuffle(ps.begin(), ps.end());
    C c = c2(ps[0], ps[1]);
    for(int i = 2; i < n; ++i){
        if(!in_circle(ps[i], c)){
            c = c2(ps[0], ps[i]);
            for(int j = 1; j < i; ++j){
                if(!in_circle(ps[j], c)){
                    c = c2(ps[j], ps[i]);
                    for(int k = 0; k < j; ++k){
                        if(!in_circle(ps[k], c)){
                            c = c3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}


signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<P> p(n);
  rep(i, n) {
    ld x, y;
    cin >> x >> y;
    p[i] = P(x, y);
  }
  C res = smallest_enclosing_disc(p);
  ld ans = res.first;
  cout << fixed << setprecision(9) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from operator import itemgetter

N_shop, M_required_drink  = map(int, raw_input().split())

shop_list = []
for tmp_shop in range(N_shop):
  shop_list.append(map(int, raw_input().split()))

total_money = 0
got_drink = 0
for i in sorted(shop_list, key=itemgetter(0)):
  limit_at_shop = i[1]
#  print(i)

  while got_drink < M_required_drink and limit_at_shop > 0:
    total_money = total_money + i[0]
    got_drink   = got_drink + 1
    limit_at_shop = limit_at_shop - 1
#    print("  %s %s %s" % (total_money, got_drink, limit_at_shop))

print(total_money)



Measured memory_bytes: 25076
import sys
input=sys.stdin.readline
inf=10**9
 
n,m=map(int, input().split())
 
dp=[[inf for _ in range(2**n)] for _ in range(m+1)]
dp[0][0]=0
 
for i in range(1, m+1):
    a,b=map(int, input().split())
 
    state=0
    c=list(map(int, input().split()))
    for x in c:
        state+=(1<<(x-1))
    
    for j in range(2**n):
        dp[i][j]=min(dp[i][j], dp[i-1][j])
        dp[i][j|state]=min(dp[i][j|state], dp[i-1][j|state], dp[i-1][j]+a)
 
if dp[m][2**n-1] == inf:
    print(-1)
    exit()
print(dp[m][2**n-1])

Measured memory_bytes: 78684
def main():
  N = int(input())
  X = [int(_) for _ in input().split()]
  Y = sorted(X)
  mid = (Y[(N-1)//2] + Y[N//2]) / 2
  for i in range(N):
    print(Y[N//2] if X[i] <= mid else Y[(N-1)//2])
  return

if __name__ == '__main__':
  main()
  


Measured memory_bytes: 26772
//I read the news today, oh boy
//About a lucky man who made the grade
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ll((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
#define roF(i,a,b) for(ll i = ll(a); i >= ll(b); i--)
using namespace std;

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

const ll N=1e6;
const ll MOD = 1e9+7;
const ld EPS = 1e-16;
const ll INF = 1e18;

int k, n;

vi pos, neg, cero;
ll prefp[N], prefn[N];
ld logp[N], logn[N];

int main(){
	fastio;
	cin>>n>>k;
	For(i,0,n){
		ll x; cin>>x;
		if(x>0) pos.pb(x);
		else if(x<0) neg.pb(-x);
		else cero.pb(x);
	}
	sort(all(pos));
	sort(all(neg));
	reverse(all(pos));
	reverse(all(neg));
	prefp[0]=prefn[0]=1;
	logp[0]=logn[0]=0;
	For(i,1,sz(pos)+1){
		prefp[i]=(prefp[i-1]*pos[i-1])%MOD;
		logp[i]=(logp[i-1]+log(ld(pos[i-1])));
	}
	For(i,1,sz(neg)+1){
		prefn[i]=(prefn[i-1]*neg[i-1])%MOD;
		logn[i]=(logn[i-1]+log(ld(neg[i-1])));
	}
	ld may = (sz(cero)>0? 0:-INF);
	ll ans;
	if(abs(may)<EPS) ans=0;
	int cantpos=k, cantneg=0;
	while(cantpos>=0){
		if(cantpos<=sz(pos) && cantneg<=sz(neg)){
			ld cur = logp[cantpos]+logn[cantneg];
			if(cur>may+EPS){
				may = cur;
				ans = (prefp[cantpos]*prefn[cantneg])%MOD;
			}
		}
		cantpos-=2;
		cantneg+=2;
	}
	reverse(all(pos));
	reverse(all(neg));
	For(i,1,sz(pos)+1){
		prefp[i]=(prefp[i-1]*pos[i-1])%MOD;
		logp[i]=(logp[i-1]+log(ld(pos[i-1])));
	}
	For(i,1,sz(neg)+1){
		prefn[i]=(prefn[i-1]*neg[i-1])%MOD;
		logn[i]=(logn[i-1]+log(ld(neg[i-1])));
	}
	cantpos=k-1,cantneg=1;
	while(cantpos>=0){
		if(cantpos<=sz(pos) && cantneg<=sz(neg)){
			ld cur = (logp[cantpos]-logn[cantneg])-1;
			if(cur>may+EPS){
				may = cur;
				ll partneg = (prefn[cantneg]*-1 + MOD)%MOD;
				ans = (prefp[cantpos]*partneg)%MOD;
			}
		}
		cantpos-=2;
		cantneg+=2;
	}
	
	cout << ans << endl;
	return 0;
}



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

int main(void){
    double x1,y1,x2,y2;
    cin >> x1;
    cin >> y1;
    cin >> x2;
    cin >> y2;
    
    cout << fixed << setprecision(8);
    cout << sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) << endl;
}


Measured memory_bytes: 3284
#include <iostream>

int main()
{
 int a,b,c,k;
 std::cin>>a>>b>>c>>k;
 if(k<=a){
     std::cout << k << std::endl;
     return 0;
    }
 
 if(a+b<k){
     std::cout << a-(k-a-b) << std::endl;
     return 0;
    }
 else{
     std::cout << a << std::endl;
     return 0;
    }

}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <set>
#define rep(i,j,k) for(int i = j; i <= k; i++)
#define dow(i,j,k) for(int i = j; i >= k; i--)
#define fi first
#define se second
using namespace std;


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


const int N = 105;
int x, n, p[105];
int main() {
	cin >> x >> n;
	rep(i,1,n) cin >> p[i];
	sort(p + 1, p + n + 1);
	int ans = 105;
	dow(i,105, 0) {
		int j = x + i;
		int a = 1;
		rep(k,1,n) if (p[k] == j) a = 0;
		if (a) ans = j;
		a = 1, j = x - i;
		rep(k,1,n) if (p[k] == j) a = 0;
		if (a) ans = j;
	}
	cout << ans << endl;

}

Measured memory_bytes: 3640
//empty sockets
#include<iostream>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int n, i;
	n = s.length();
	s.resize(0);
	for (i = 0; i < n; i++)
	{
		s.push_back('x');
	}
	cout << s << " " << endl;

	return 0;
}



Measured memory_bytes: 3608
<?php
$num = trim(fgets(STDIN));
$k = intval(fgets(STDIN));

$dp0 = array_fill(0, strlen($num)+1, array_fill(0, $k+1, 0));//not-max
$dp1 = array_fill(0, strlen($num)+1, array_fill(0, $k+1, 0));//max
$dp1[0][0] = 1;// N桁目 - 0以外の数
for($i = 1; $i <= strlen($num); $i++){
    for($j = 0; $j <= $k; $j++){
        $d = $num[$i-1];
        if($d == 0){
            $dp1[$i][$j] += $dp1[$i-1][$j];
        }else{
            $dp1[$i][$j] += $dp1[$i-1][$j-1] ?? 0;
        }
        $dp0[$i][$j] += ($dp0[$i-1][$j - 1]??0) * 9 + $dp0[$i-1][$j];
        if($d)$dp0[$i][$j] += $dp1[$i-1][$j] + ($dp1[$i-1][$j-1]??0) * ($d-1);
    }
}
echo $dp0[strlen($num)][$k] + $dp1[strlen($num)][$k];



Measured memory_bytes: 4728
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl



int main() {
	int N, A;
	cin >> N >> A;
	if ((N % 500) > A) wrln("No");
	else wrln("Yes");

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi;
const ll mod=1000000007;
int main(){
	int n;
	cin>>n; 
	ll a=1,b=1,c=1,d=1;
	rep(i,n){
		a=a*10%mod;
		b=b*9%mod;
		c=c*9%mod;
		d=d*8%mod;
	}
	cout<<(a-b-c+d+2*mod)%mod;
	re 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define pb push_back
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>=1;i--)
ll a[3][3], b[3][3];
void solve()
{
    ll i, j, n, x, y;
    rep(i, 3) rep(j, 3) cin >> a[i][j];
    cin >> n;
    while(n--)
    {
        cin >> x;
        rep(i, 3) rep(j, 3) if(a[i][j] == x)
        {
            b[i][j] = 1;
        }

    }
    bool pos = 0, p = 1;
    rep(i, 3)
    {
        p = 1;
        rep(j, 3)
        if(!b[i][j])
            p = 0;

        if(p)
            pos = 1;

    }
    rep(i, 3)
    {
        p = 1;
        rep(j, 3)
        if(!b[j][i])
            p = 0;

        if(p)
            pos = 1;

    }
    p = 1;
    rep(i, 3)
    if(!b[i][i])
        p = 0;
    pos |= p;
    p = 1;
    rep(i, 3)
    if(!b[i][2 - i])
        p = 0;
    pos |= p;
    cout << (pos ? "Yes" : "No");








}

int main()
{



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

}




Measured memory_bytes: 256
N,A,B=map(int,input().split())
mod=10**9+7

A,B=min(A,B),max(A,B)

data=[0]*B
data[0]=1
for i in range(1,B):
    data[i]=(data[i-1]+sum(data[i-1-k] for k in range(A,i)))%mod

#print(data)

dp=[0]*(N+1)
dp[0]=1
imos=[0]*(N+1)
imos[0]=1

for i in range(1,N+1):
    if i!=N:
        for j in range(1,min(i,B)):
            #dp[i]+=sum(dp[i-j-k]*data[j-1] for k in range(1,min(A,i-j+1)))
            R=i-j-1
            L=i-j-min(A,i-j+1)
            if R>L:
                if L>-1:
                    dp[i]+=(imos[R]-imos[L])*data[j-1]
                else:
                    dp[i]+=imos[R]*data[j-1]
                dp[i]%=mod
        if B>i:
            dp[i]+=data[i]
            dp[i]%=mod
    else:
        for j in range(B):
            #dp[i]+=sum(dp[i-j-k]*data[j] for k in range(1,min(A,i-j+1)))
            R=i-j-1
            L=i-j-min(A,i-j+1)
            if R>L:
                if L>-1:
                    dp[i]+=(imos[R]-imos[L])*data[j]
                else:
                    dp[i]+=imos[R]*data[j]
                dp[i]%=mod
        #print(dp[i])
        #dp[i]+=sum(dp[i-k] for k in range(1,A))
    imos[i]=dp[i]
    imos[i]+=imos[i-1]
    imos[i]%=mod


#print(dp)
print((pow(2,N,mod)-dp[N])%mod)

Measured memory_bytes: 74852
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
using namespace std;

typedef long long int ll;

int main () {
    char c; cin >> c;
    if ('a' <= c && c <= 'z') {
        cout << "a" << endl;
    } else {
        cout << "A" << endl;
    }

    return 0;
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
#define mx 100001
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define d double
void solve(){
	ll n,W;
	cin>>n>>W;
	vl w(n),v(n);
	rep(i,0,n) cin>>w[i]>>v[i];
	ll M=0;
  	for(int i=0;i<n;i++) M+=v[i];
	vl dp(M+1,inf);
	//dp[i]->min capacity of knapsack required to get the value i....
	dp[0]=0;
	for(int i=0;i<n;i++){
		vl tmp=dp;
		for(int j=v[i];j<=M;j++){
			tmp[j]=min(dp[j],w[i]+dp[j-v[i]]);
		}
		dp=tmp;
	}
	ll ans=minf;
	for(int i=0;i<=M;i++){
		if(dp[i]<=W) ans=max(ans,i);
	}
	cout<<ans;
	
}
int32_t main(){
int t=1;
//cin>>t;
while(t--){
	solve();
}
 
}

Measured memory_bytes: 1792
def main():
    n = input()
    inf = float('inf')
    M = [[inf]*n for i in xrange(n)]
    for i in xrange(n):
        Ai = map(int,raw_input().split())
        for j in xrange(Ai[1]):
            M[i][Ai[2+2*j]] = Ai[3+2*j]

    d = dijkstra(0,M,n)
    for i in xrange(n):
        print i, d[i]

def dijkstra(s,M,n):
    inf = float('inf')
    c = [-1]*n
    d = [inf]*n
    p = [-1]*n
    d[s] = 0

    while(True):
        mincost = inf
        for i in xrange(n):
            if (c[i] != 1) & (d[i] < mincost):
                mincost = d[i]
                u = i
        if mincost == inf:
            break

        c[u] = 1

        for v in xrange(n):
            if (c[v] != 1) & (M[u][v] != inf):
                if d[u] + M[u][v] < d[v]:
                    d[v] = d[u] + M[u][v]
                    p[v] = u
                    c[v] = 0
    return d

if __name__ == "__main__":
    main()

Measured memory_bytes: 6548
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

int main() {
    string S,T;
    cin >> S >> T;
    int ans=0;
    for (int i=0;i<3;i++){
        if (S[i] == T[i]) ans++; 
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
int  N,K;
    cin >> N >> K;
  vector<int> A(N);
for (int i = 0; i < N; i++) {
  cin >> A.at(i);
}
int count=0;
for (int i = 0; i < N; i++) {
  if (A.at(i)>=K) count++;
}
  cout << count << endl;  
}

Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

// [start, end]
bool is_palindrome(const int start, const int end, const string &S) {
    // printf("start: %d, end: %d, S: %s\n", start, end, S.c_str());
    for (int i = 0; i <= end - start; i++) {
        if (S[start + i] != S[end - i]) {
            return false;
        }
    }
    return true;
}

int main(void) {
    string S;
    cin >> S;
    const int slen = (int) S.size();

    int len1 = (slen - 1) / 2;
    int len2 = slen - (slen + 3) / 2 + 1;
    // printf("len1: %d, len2: %d\n", len1, len2);

    if (is_palindrome(0, len1 - 1, S) && is_palindrome(slen - 1 - len2 + 1, slen - 1, S) && is_palindrome(0, slen - 1, S)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int fc_1(int n){
  int popc = 0;
  int tmp = n;
  while(tmp != 0){
    if(tmp % 2 == 1) popc++;
    tmp /= 2;
  }
  return n % popc;
}

void fc_ans(vector<int> &p){
  rep(i, p.size()){
    int ans = 0;
    if(p.at(i) != -1){
      ans = 1;
      while(p.at(i) != 0){
        ans++;
        p.at(i) = fc_1(p.at(i));
      }
    }
    cout << ans << endl;
  }
}

void fst(string &x, vector<int> &p){
  int pc = 0;
  rep(i, x.size()){
    if(x.at(i) == '1') pc++;
  }
  int apl = 0, ami = 0;
  rep(i, x.size()){
    apl *= 2; ami *= 2;
    if(x.at(i) == '1'){
      apl++;
      ami++;
    }
    apl %= (pc+1);
    if(pc > 1) ami %= (pc-1);
  }
  vector<int> power_pl(x.size()), power_mi(x.size());
  int p_pl = 1, p_mi = 1;
  if(pc <= 1) p_mi = -1;
  rrep(i, x.size()){
    power_pl.at(i) = p_pl;
    power_mi.at(i) = p_mi;
    p_pl = (p_pl*2) % (pc+1);
    if(pc > 1) p_mi = (p_mi*2) % (pc-1);
  }

  rep(i, x.size()){
    if(x.at(i) == '1'){
      if(pc > 1){
        int add = (ami - power_mi.at(i) + pc - 1) % (pc - 1);
        p.at(i) = add;
      }else p.at(i) = -1;
    }else{
      int add = (apl + power_pl.at(i)) % (pc + 1);
      p.at(i) = add;
    }
  }

  // rep(i, p.size()){
  //   cerr << p.at(i) << " ";
  // }
  // cerr << endl;
}

int main(){
  int n;
  cin >> n;
  string x;
  cin >> x;
  vector<int> p(x.size());
  fst(x, p);
  fc_ans(p);
  return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

int N;
vector<int> A, B;
vector<int> graph[MAX_N];

int K;
map< pair<int, int>, int> color;    // 辺 first, second の色 val

void dfs(int node, int par, int par_col) {
    int col = 1;
    for(auto& next_node : graph[node]) {
        if(next_node == par) { continue; }
        // 色をつける
        int a = node;
        int b = next_node;
        if(a > b) { swap(a, b); }
        if(col == par_col) { col++; }
        color[make_pair(a, b)] = col;
        dfs(next_node, node, col);
        col++;
    }
}

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

    cin >> N;
    A.resize(N);
    B.resize(N);
    REP(i, N-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);

        A[i] = a;
        B[i] = b;

        color[make_pair(a, b)] = -1;
    }

    // K の決定
    K = 0;
    REP(i, N) { K = max(K, static_cast<int>(graph[i].size())); }

    dfs(0, -1, -1);

    printf("%lld\n", K);
    REP(i, N-1) {
        printf("%lld\n", color[make_pair(A[i], B[i])]);
    }

    return 0;
}


Measured memory_bytes: 16384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=(a);i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef vector<int> vi;

using D=double;
const int N=100010;
int n,m;
ll k;
D x[N];

int main() {
    scanf("%d",&n);
    rep(i,0,n) scanf("%lf",&x[i]);
    scanf("%d %lld",&m,&k);
    vi pm(n-1);
    iota(pm.begin(),pm.end(),0);
    rep(i,0,m) {
        int p;
        scanf("%d",&p); p--;
        swap(pm[p],pm[p-1]);
    }

    auto trans=[&](vi &f,vi &g) {
        vi h(n-1);
        rep(i,0,n-1) h[i]=f[g[i]];
        return h;
    };

    vi r(n-1);
    iota(r.begin(),r.end(),0);
    while (k) {
        if (k&1) r=trans(r,pm);
        pm=trans(pm,pm);
        k>>=1;
    }

    D c=x[0];
    printf("%.20lf\n",c);
    rep(i,0,n-1) {
        c+=x[r[i]+1]-x[r[i]];
        printf("%.20lf\n",c);
    }
}

Measured memory_bytes: 5224
#include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;

int main(){
	int n,s[1000];
	double a,m,D;
	while(true){
		cin >> n;
		if(n==0) break;
		a=0;m=0;D=0;
		for(int i = 0;i < n;i++){
			cin >> s[i];
			m += s[i];
		}
		m/=n;
		for(int i = 0;i < n;i++){
			a += pow((s[i]-m),2) ;
		}
		a/=n;
		D=sqrt(a);
		printf("%.8f\n",D);
	}
	return 0;
}

Measured memory_bytes: 1196
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]
a = sorted(a)
bc = sorted(bc, key=lambda x: -x[1])
a_len = len(a)
i = 0
for one in bc:
    for j in range(one[0]):
        if i > a_len-1:
            break
        if a[i] > one[1]:
            break
        a[i] = one[1]
        i += 1
print(sum(a))

Measured memory_bytes: 36932
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

ll func(ll num){
    return num * (num -1) / 2;
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    rep(i, N) A[i]--;
    vector<int> cnt(N);
    rep(i, N) cnt[A[i]]++;
    ll sum = 0;
    rep(i, N){
        sum += func(cnt[i]);
    }
    rep(i, N){
        ll res = sum;
        res -= func(cnt[A[i]]);
        res += func(cnt[A[i]]-1);
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }


  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
     if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  bool operator == (Mint &a) const {
    return x==a.x;
  }

  bool operator != (Mint &a) const {
    return x!=a.x;
  }
};

Mint dp[104][10];
int main(){
  int H, W, K;
  scanf("%d", &H);
  scanf("%d", &W);
  scanf("%d", &K);
  K--;
  dp[0][0].x=1;

  auto check = [&](int k){
    bool is1=false;
    while(k>0){
      if (k%2==1){
	if (is1) return false;
	is1 = true;
      } else {
	is1 = false;
      }
      k = k / 2;
    }
    return true;
  };
  
  for (int i=0; i<H; i++){
    for (int k=0; k<(1<<(W-1)); k++){
      if (!check(k)) continue;
      //printf("k=%d\n", k);
      int n = k;
      int last;
      std::vector<bool> used(W+4, false);
      for (int j=0; j<W-1; j++){
	if (n%2==1){
	  dp[i+1][j+1] += dp[i][j];
	  dp[i+1][j] += dp[i][j+1];
	  used[j]=true;
	  used[j+1]=true;
	}
	n = n/2;
      }
      for (int j=0; j<W; j++){
	if (!used[j]){
	  dp[i+1][j]+=dp[i][j];
	}
      }
      for (int j=0; j<W; j++){
	//printf("dp[%d][%d]=%lld\n", i+1, j,dp[i+1][j].x);
      }
      
    }
  }
  std::cout << dp[H][K].x << std::endl;
  return 0;
}


Measured memory_bytes: 3212
#include<iostream>
using namespace std;
int main(){
int H,W;
while(1){
cin >>H >>W;
if (H==0&&W==0) break;
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
if((i+j)%2==0){
cout <<'#';
}
else cout <<'.';
}
cout <<"\n";
}
cout <<endl;
}
return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
#include<string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <stdlib.h>
#include<string>
#define mp make_pair
#define ss second
#define ff first
#define pb push_back
#define io ios_base::sync_with_stdio;cin.tie(0);cout.tie(0)
#define READ freopen("input.txt","r", stdin)
#define mem(a,b)     memset(a, b, sizeof(a))
#define snd(a) scanf("%d",&a)
#define snl(a) scanf("%lld",&a)
#define snul(a) scanf("%ull",&a)
#define rep(i,k,n) for(int i=k;i<n;i++)
#define rev(j,n,k) for(int j=n;j>=k;j--)
#define TC int tc;cin>>tc;while(tc--)
#define FastRead ios_base::sync_with_stdio(false);cin.tie(NULL);

#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a / __gcd(a, b) ) * b)

#define PI 2*acos(0.0)
#define MAX 1000000000
#define inf 1e18
#define MOD 1000000007
#define case(i) "Case "<<i++<<": "
#define nscase(i) "Case "<<i++<<":"
#define base(n,b) floor(log(n)/log(b))+1
#define onecnt(x) __builtin_popcount(x)
#define to_binary(n) bitset<8>(n).to_string()
#define endl '\n'
#define esc cout<<"\n"

/*------------------------------Graph Moves----------------------------*/
///const int fx[]= {+1,-1,+0,+0};
///const int fy[]= {+0,+0,+1,-1};
///const int fx[]= {+0,+0,+1,-1,-1,+1,-1,+1};  // Kings Move
///const int fy[]= {-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
///const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
///const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef std::map<long long,int> mli;
typedef std::map<long long,long long> mll;
typedef std::map<int,int> mii;
using namespace __gnu_pbds;
typedef tree<
ll,
null_type,//set to another type while using map
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;

template <typename T>
std::string toString( T Number )
{
    std::ostringstream ss;
    ss << Number;
    return ss.str();
}


const ll ten5=100000;
const ll ten6 =1000000;
const ll ten7 =10000000;
const ll ten8 =100000000;
const ll ten9 =1000000000;
const ll mod=1000000007;


int main()
{
    io;
    int n,i,j,k=0;
    cin>>n;
    int a[n],b[n];
    rep(i,0,n)
    {
        cin>>a[i];
    }
    rep(i,0,n)
    {
        cin>>b[i];
        if(a[i]-b[i]>0)k+=(a[i]-b[i]);
    }
    cout<<k<<endl;

    return 0;
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
    ll A, B, N;
    cin >> A >> B >> N;
    ll ans = 0;
    if (N < B - 1) {
        ans = (A * N / B) - A * (N / B);
    }
    else
        ans = (A * (B - 1) / B) - A * ((B - 1) / B);

        cout << ans << endl;
}


Measured memory_bytes: 3636
/* 09:26 - 09:29 */

#include <iostream>
#include <vector>

using namespace std;

int main(void) {

	int n; cin >> n;
	vector<int> like(n);

	for (int i = 0; i < n; ++i) {
		cin >> like[i];
		--like[i];
	}

	int count = 0;
	for (int i = 0; i < n; ++i) {
		count += (like[like[i]] == i);
	}

	cout << count / 2 << endl;
	return 0;

}

Measured memory_bytes: 640
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

def main():
    a, b = input().split()

    aa = "".join([a] * int(b))
    bb = "".join([b] * int(a))

    if int(aa) > int(bb):
        print(aa)
    else:
        print(bb)


if __name__ == '__main__':
    main()

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

const int INF = 1000000000;

int d[70000000];

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < (1 << 26); i++) d[i] = INF;
    int b = 0;
    d[0] = 0;
    for(int i = 0; i < n; i++){
        b ^= (1 << (s[i] - 'a'));
        for(int j = 0; j < 26; j++) d[b] = min(d[b], d[b ^ (1 << j)] + 1);
    }
    if(b == 0) cout << 1 << endl;
    else cout << d[b] << endl;
}

Measured memory_bytes: 264836
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int n = stdIn.nextInt();
			if(n == 0)
			{
				break;
			}
			for(int i = 0; i < n; ++i)
			{
				int x1 = stdIn.nextInt();
				int y1 = stdIn.nextInt();
				int z1 = stdIn.nextInt();
				int w1 = stdIn.nextInt();
				int x2 = stdIn.nextInt();
				int y2 = stdIn.nextInt();
				int z2 = stdIn.nextInt();
				int w2 = stdIn.nextInt();
				System.out.println((x1 * x2 - y1 * y2 - z1 * z2 - w1 * w2) + " " + (x1 * y2 + y1 * x2 + z1 * w2 - w1 * z2) + " " + (x1 * z2 + z1 * x2 - y1 * w2 + w1 * y2) + " " + (x1 * w2 + w1 * x2 + y1 * z2 - z1 * y2));
			}
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<algorithm>
#include<math.h>
#include<limits.h>
#define _USE_MATH_DEFINES

using namespace std;

long long n, k, x, minu = 0, plu = 0, preM[100000] = {}, M[100000] = {}, P[100000] = {}, ans = LLONG_MAX;

int main(){
	cin >> n >> k;
	for (auto i = 0; i < n; i++) {
		cin >> x;
		if (x < 0) {
			minu++;
			preM[minu] = x;
		}
		else if (x > 0) {
			plu++;
			P[plu] = x;
		}
		else {
			k--;
		}
	}

	for (auto i = 1; i <= minu; i++) {
		M[i] = preM[minu - i + 1] * -1;
	}

	if (k == 0) {
		ans = 0;
	}

	for (auto i = 1; i <= min(k, plu); i++) {
		if (i == k) {
			ans = min(ans, P[i]);
		}
		else if(k - i <= minu) {
			ans = min(ans, M[k - i] * 2 + P[i]);
		}
	}

	for (auto i = 1; i <= min(k, minu); i++) {
		if (i == k) {
			ans = min(ans, M[i]);
		}
		else if (k - i <= plu) {
			ans = min(ans, P[k - i] * 2 + M[i]);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
while True:
    s,t=map(int,input().split())
    if s+t==0:
        break
    c=0
    for i in range(1,s+1):
        for j in range(i+1,s+1):
            for k in range(j+1,s+1):
                if i+j+k ==t:
                    c+=1
    print(c)     


Measured memory_bytes: 5592
k = int(input())
d = [0]*(k+1)
for i in range(1, k+1):
    d[i] = pow(k//i, 3)

for i in reversed(range(1, k+1)):
    for j in range(2*i, k+1, i):
        d[i] -= d[j]

ans = 0
for i in range(1, k+1):
    ans += i*d[i]
print(ans)



Measured memory_bytes: 9192
#include <stdio.h>
#include <iostream>
#include <climits>

bool is_product_overflow(long long a, long long b) {
	return (LLONG_MAX / b < a);
}

int main() {

	int  N;
	std::cin >> N;

	long long* A;
	A = new long long[N];
	long long mul = 1;

	for (int i = 0;i < N;i++) {
		std::cin >> A[i];
		if (A[i] == 0) {
			std::cout << "0" << std::endl;
			return 0;
		}
	}

	for (int i = 0;i < N;i++) {
		if (is_product_overflow(mul, A[i])) {
			std::cout << "-1" << std::endl;
			return 0;
		}
		else {
			mul = mul * A[i];
		}
	}

	if (mul <= 1000000000000000000) {
		std::cout << mul << std::endl;
	}
	else {
		std::cout << "-1" << std::endl;
	}
	

	return 0;
}

Measured memory_bytes: 4420
def main():
    x,y,z = map(int,input().split())
    x,y = swap(x,y)
    x,z = swap(x,z)
    print(x,y,z)

def swap(a,b):
    tmp = a
    a = b
    b = tmp
    return a,b


if __name__ == "__main__":
    main() 


Measured memory_bytes: 9116
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

ll gcd(ll a,ll b) { return b ? gcd(b, a%b) : a; }

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    string t=s.substr(0,3);
    cout<<t<<endl;
    return 0;
}

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

void split( std::vector<std::string> &list, std::string string, std::string separator )
{
  auto separator_length = separator.length();
  if ( separator_length == 0 )
  {
    list.push_back( string );
  } else {
    auto offset = std::string::size_type( 0 );
    while( 1 )
    {
      auto pos = string.find( separator, offset );
      if( pos == std::string::npos )
      {
        list.push_back( string.substr( offset ) );
        break;
      }
      list.push_back( string.substr( offset, pos - offset ) );
      offset = pos + separator_length;
    }
  }
}

template<typename T>
T min( T a, T b )
{
  return ( a < b ) ? a : b;
}

template<typename T>
T max( T a, T b )
{
  return ( a > b ) ? a : b;
}

int main(void)
{
  int N;
  std::cin >> N;
  
  std::vector<int> H = std::vector<int>(N);

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

  if( H[0] > 1 ){
    H[0] -= 1;
  }

  for( int i = 0;i < N-1;i++ ){
    if( H[i] < H[i+1] ){
      H[i+1] -= 1;
    }else{
      // Do nothing
    }

    if( H[i+1] < H[i] ){
      std::cout << "No" << std::endl;
      return 0;
    }
  }
  std::cout << "Yes" << std::endl;

  return 0;
}


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

int main()
{
    string s; cin >> s;
    int ans = 0, cnt = 0;

    for(int i = 0; i < s.size(); i++){
        switch (s[i]) {
            case 'A':
            case 'C':
            case 'G':
            case 'T':
                cnt++;
                break;
            default:
                ans = max(ans, cnt);
                cnt = 0;
                break;
        }
    }
    cout << max(ans, cnt) << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})
#define rep(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) static_cast<int>(x.size())
#define mp make_pair
#define fi first
#define se second

using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod(ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b & 1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

template<typename T> inline void remin(T& x, const T& y) { x = min(x, y); }
template<typename T> inline void remax(T& x, const T& y) { x = max(x, y); }

template<typename T> ostream& operator<<(ostream &os, const vector<T>& v) {
    os << "{"; string sep; for(const auto& x : v) os << sep << x, sep = ", "; return os << "}"; 
}

template<typename T, size_t size> ostream& operator<<(ostream& os, const array<T, size>& arr) {
    os << "{"; string sep; for(const auto& x : arr) os << sep << x, sep = ", "; return os << "}"; 
}

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { 
    return os << '(' << p.first << ", " << p.second << ')'; 
}

int main() {
    buff();
    long long tot = 1ll;
    long long bad = 1ll; // sequencias sem 0 e 9
    long long only_one = 1ll; // sequencias sem 9
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i) {
        tot = (tot * 10ll) % MOD;
        bad = (bad * 8ll) % MOD;
        only_one = (only_one * 9ll) % MOD;
    }
    long long res = tot;
    res = (res - only_one + MOD) % MOD;
    res = (res - only_one + MOD) % MOD;
    res = (res + bad) % MOD;
    cout << res << endl;
    return 0;
}



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

using namespace std;

struct sushi_t {
  int d;
  int t;
};

static int n, k;
static std::array<sushi_t, 100000> sushis{};

int64_t solve() {
  int64_t ret0 = 0;
  int64_t nn = 0;
  std::vector<int> worstSushis(n, -1);
  std::vector<int> replaceables{};
  int i = 0;
  for (; i < k; ++i) {
    const auto& s = sushis[i];
    int const prev = worstSushis[s.t];
    worstSushis[s.t] = i;
    ret0 += int64_t(s.d);
    if (prev < 0) {
      nn++;
    } else {
      replaceables.push_back(i);
    }
  }
  int64_t ret = ret0 + nn * nn;
  std::vector<int> replacements{};
  for (; i < n; ++i) {
    const auto& s = sushis[i];
    int const prev = worstSushis[s.t];
    worstSushis[s.t] = i;
    if (prev < 0) {
      replacements.push_back(i);
    }
  }

  int replaceableIdx = replaceables.size() - 1;
  int replacementIdx = 0;
  for (++nn;
       nn <= k && replaceableIdx >= 0 && replacementIdx < replacements.size();
       ++nn, --replaceableIdx, ++replacementIdx) {
    ret0 -= int64_t(sushis[replaceables[replaceableIdx]].d);
    ret0 += int64_t(sushis[replacements[replacementIdx]].d);
    if (ret0 + int64_t(k) * int64_t(k) <= ret) {
      break;
    }
    ret = std::max(ret0 + nn * nn, ret);
  }
  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  std::cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    auto& s = sushis[i];
    std::cin >> s.t >> s.d;
    s.t--;
  }
  std::sort(sushis.begin(), sushis.begin() + n,
            [](const auto& lhs, const auto& rhs) { return lhs.d > rhs.d; });
  std::cout << solve() << std::endl;
  return 0;
}

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

int main()
{
    int num;
    int a[100];
    
    cin >> num;
    
    for(int i = 0; i < num; ++i)
    {
        cin >> a[i];
    }
    
    for (int i = num - 1; i >= 0; --i)
    {
        cout << a[i];
        
        if (i > 0)
        {
            cout << " ";
        }
    }
    
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 3016
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ll long long
#define ld double
#define ull unsigned long long
#define PI pair < int, int > 

const int N = 1e6 + 123;
const int M = 123;
const ld Pi = acos(-1);
const ll Inf = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const int Sz = 501;
const int MOD = 1e9 + 7;

void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int mult(int a, int b) {
  return 1ll * a * b % mod;
}
int sum(int a, int b) {
  add(a, b);
  return a;
}

int n, m, x[N], y[N], ans;
vector < int > v[N];
bool need[501][501], bad[501];

void solve() {
  cin >> n >> m;
  for (int i = 1;i <= m;i++) {
    cin >> x[i] >> y[i];
  }
  for (int i = 1;i <= n;i++) {
    need[i][i] = 1;
    for (int id = m;id;id--) {
      int now = need[i][x[id]] + need[i][y[id]];
      if (now == 0) continue;
      if (now == 2) {
        bad[i] = 1;
        break;
      }
      if (need[i][x[id]]) need[i][y[id]] = 1;
      else need[i][x[id]] = 1;
    }
    continue;
    cout << "i = " << i << " bad = " << bad[i] << endl;
    for (int j = 1;j <= n;j++) cout << need[i][j];
    cout << endl;
  }
  for (int i = 1;i <= n;i++) {
    for (int j = i + 1;j <= n;j++) {
      if (bad[i] || bad[j]) continue;
    //  cout << i << " " << j << endl;
      bool fail = 0;
      for (int k = 1;k <= n;k++) {
        if (need[i][k] + need[j][k] == 2) {
          fail = 1;
          break;
        }
      }
      ans += !fail;
    }
  }
  cout << ans << endl;
}

int main() {
  #ifdef wws
   freopen("in", "r", stdin);
  // freopen("out", "w", stdout);
  #endif 
  ios_base::sync_with_stdio(0);
  int tt = 1; 
  while(tt--) solve();
  return 0;
}

Measured memory_bytes: 26880