akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

struct L {
  int a, b, c;
  L(int a = 0, int b = 0, int c = 0): a(a), b(b), c(c) {}
};

signed main() {
  int N, M; 
  cin >> N >> M;

  vector<L> vx, vy;
  map<int, int> mx, my;
  mx[0] = 0; my[0] = 0;

  REP(i, N){
    int a, b, c;
    cin >> a >> b >> c;
    mx[a] = 0;
    mx[b] = 0;
    my[c] = 0;
    vx.emplace_back(a, b, c);
  }
  REP(i, M){
    int a, b, c;
    cin >> a >> b >> c;
    mx[a] = 0;
    my[b] = 0;
    my[c] = 0;
    vy.emplace_back(a, b, c);
  }

  vector<int> xs, ys;
  for(auto& p : mx){
    p.second = xs.size();
    xs.emplace_back(p.first);
  }
  for(auto& p : my){
    p.second = ys.size();
    ys.emplace_back(p.first);
  }

  int H = xs.size()*2;
  int W = ys.size()*2;

  vector<vector<int>> d(H, vector<int>(W));
  REP(i, N){
    int a = mx[vx[i].a]*2;
    int b = mx[vx[i].b]*2;
    int c = my[vx[i].c]*2;
    FOR(x, a, b+1) d[x][c] = -1;
  }
  REP(i, M){
    int a = mx[vy[i].a]*2;
    int b = my[vy[i].b]*2;
    int c = my[vy[i].c]*2;
    FOR(x, b, c+1) d[a][x] = -1;
  }

  int sx = mx[0]*2;
  int sy = my[0]*2;

  queue<pair<int, int>> q;
  q.emplace(sx, sy);

  d[sx][sy] = 1;

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

  while(!q.empty()){
    auto [x, y] = q.front(); q.pop();

    REP(i, 4){
      int nx = x+dx[i];
      int ny = y+dy[i];
      if(OUT(0, nx, H) || OUT(0, ny, W)) continue;
      if(d[nx][ny] != 0) continue;
      d[nx][ny] = 1;
      q.emplace(nx, ny);
    }
  }

  int ans = 0;
  REP(i, H) REP(j, W){
    if(d[i][j] != 1) continue;
    if(i == 0 || i == H-1 || j == 0 || j == W-1){
      cout << "INF" << "\n";
      return 0;
    }
    if(i%2 == 0 || j%2 == 0) continue;

    int ex = xs[i/2+1]-xs[i/2];
    int ey = ys[j/2+1]-ys[j/2];
    ans += ex*ey;
  }

  cout << ans << "\n";

  return 0;
}


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

int main() {
  string s;
  cin >> s;
  if(s.size() == 2){
    cout << 1 << endl;
  }
  for(int i = s.size()-2;i >= 2;i -= 2){
    for(int j = 0;j < i/2;j++){
      if(s.at(j) != s.at(i/2+j)){
        break;
      }
      else if(j == i/2-1){
        cout << i << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
#include<stdio.h>


int main(void){

  int m[10][10];
  int x, y, s;
  int i, j;
  int empty, max;

  for(i=0; i<10; i++){
    for(j=0; j<10; j++){
      m[i][j]=0;
    }
  }

  empty=max=0;

  while(scanf("%d,%d,%d", &x, &y, &s)!=EOF){
    if(s==1){
      m[x][y]++;      
      if(x-1>=0) m[x-1][y]++;
      if(x+1<10) m[x+1][y]++;
      if(y-1>=0) m[x][y-1]++;
      if(y+1<10) m[x][y+1]++;
    }
    else if(s==2){
      for(i=-1; i<=1; i++){
	if(0<=x+i && x+i<10){ 
	  for(j=-1; j<=1; j++){
	    if(0<=y+j && y+j<10) m[x+i][y+j]++;
	  }
	}
      } 
    }
    else if(s==3){
      for(i=-1;i<=1; i++){
        if(0<=x+i && x+i<10){
          for(j=-1; j<=1; j++){
            if(0<=y+j && y+j<10) m[x+i][y+j]++;
	  }
	}
      }
      if(x-2>=0) m[x-2][y]++;
      if(x+2<10) m[x+2][y]++;
      if(y-2>=0) m[x][y-2]++;
      if(y+2<10) m[x][y+2]++;
    }
  }


  for(i=0; i<10; i++){
    for(j=0; j<10; j++){
      if(max<m[i][j]) max=m[i][j];
      if(m[i][j]==0) empty++;
    }
  }

  printf("%d\n%d\n", empty, max);

  return(0);
}



Measured memory_bytes: 2060
n=int(input())
a=[]
for i in range(n):
    a.append([0,0,0])
    a[i][0],a[i][1],a[i][2]=map(int,input().split())
b=[a[0][0],a[0][1],a[0][2]]
for i in range(1,n):
    b1=b[:]
    b[0]=max(a[i][0]+b1[1],a[i][0]+b1[2])
    b[1]=max(a[i][1]+b1[0],a[i][1]+b1[2])
    b[2]=max(a[i][2]+b1[1],a[i][2]+b1[0])
print(max(b))


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

int main() {
  int n;
  cin >> n;
  cout << (n*800) - ((n/15)*200) << endl;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>

#define SENTINEL (1000000001)

int c = 0;
int S[500000];
int L[250001];
int R[250001];
char str[5500000];
char *p = str;

static void Merge(int A[], int left, int mid, int right);
static void MergeSort(int A[], int left, int right);
static int getNum(void);
static void putNum(int n);

int main(void) {
	int i;
	int n;
	
	fread(str, sizeof(str[0]), sizeof(str)/sizeof(str[0]), stdin);
	n = getNum();
	for (i = 0; i < n; ++i) {
		S[i] = getNum();
	}
	
	MergeSort(S, 0, n);
	
	--n;
	for (i = 0; i < n; ++i) {
		putNum(S[i]);
		putchar(' ');
	}
	putNum(S[i]);
	putchar('\n');
	
	putNum(c);
	putchar('\n');

	return 0;
}

int getNum(void) {
	int n = 0;
	while ((*p >= '0') && (*p <= '9')) {
		n = n * 10 + (int)(*p - '0');
		++p;
	} 
	++p;
	return n;
}

void putNum(int n) {
	int d = n / 10;
	if (n < 10) {
		putchar(n + '0');
		return;
	}
	if (d) putNum(d);
	putchar((n % 10) + '0');
}

void Merge(int A[], int left, int mid, int right) {
	int i, j, k;
	int n1 = mid - left;
	int n2 = right - mid;
	memcpy(L, A + left, n1 * sizeof(int));
	memcpy(R, A + mid, n2 * sizeof(int));
	L[n1] = R[n2] = SENTINEL;
	i = j = 0;
	for (k = left; k < right; ++k) {
		++c;
		if (L[i] <= R[j]) {
			A[k] = L[i];
			++i;
		} else {
			A[k] = R[j];
			++j;
		}
	}
}

void MergeSort(int A[], int left, int right) {
	int mid;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		MergeSort(A, left, mid);
		MergeSort(A, mid, right);
		Merge(A, left, mid, right);
	}
}

Measured memory_bytes: 9200
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

#define rep(i,n) for(int i=0; i<int(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int main() {
	int c1, c5, c10,c50, c100, c500;
	cin >> c1 >> c5 >>c10 >>  c50 >> c100 >> c500;

	int ans = c1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500;
	if (ans >= 1000)cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 3100
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

template<typename W>
class WeightedUnionFind{
private:
    vector<int> par,height,size;
    vector<W> dif_w;
public:
    WeightedUnionFind(int n,W unit=0){
        par.resize(n);
        REP(i,n){
            par[i] = i;
        }
        height.resize(n,0);
        size.resize(n,1);
        dif_w.resize(n,unit);
    }
    int root(int x){
        if(par[x]==x){
            return x;
        }else{
            int r = root(par[x]);
            dif_w[x] += dif_w[par[x]];
            return par[x] = r;
        }
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
    bool unite(int x,int y,W w){
        w += weight(x);
        w -= weight(y);
        x = root(x);
        y = root(y);
        if(x==y)return false;
        if(height[x]<height[y]){
            par[x]=y;
            size[y]+=size[x];
            dif_w[x] = -w;
        }else{
            par[y]=x;
            size[x]+=size[y];
            dif_w[y] = w;
            if(height[x]==height[y])height[x]++;
        }
        return true;
    }
    int cnt(int x){
        x=root(x);
        return size[x];
    }
    W weight(int x){
        root(x);
        return dif_w[x];
    }
    W dif(int x,int y){//y-x
        return weight(y)-weight(x);
    }
};

int main(){
    int n,m;
    cin >> n >> m;
    WeightedUnionFind<int> uf(n);
    REP(i,m){
        int l,r,d;
        cin >> l >> r >> d;
        l--;r--;
        if(uf.same(l,r)){
            int dif = uf.dif(l,r);
            if(d!=dif){
                put("No");
                return 0;
            }
        }else{
            uf.unite(l,r,d);
        }
    }
    put("Yes");
    return 0;
}


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

ll gcd2(ll a, ll b) {
	ll p = max(a,b);
	ll q = min(a,b);

	if (q == 0) return p;
	return gcd2(q, p%q);
}

ll gcd3(ll a, ll b, ll c) {
	return gcd2(gcd2(a,b),c);
}

int main() {
	ll k;
	ll ans = 0;
	cin >> k;
	for(ll a=1;a<=k;a++)
		for (ll b=1;b<=k;b++)
			for (ll c=1;c<=k;c++)
				ans += gcd3(a,b,c);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	managers := scanIntSlice(n - 1)

	subs := map[int]int{}
	for _, m := range managers {
		subs[m-1] = subs[m-1] + 1
	}

	for i := 0; i < n; i++ {
		fmt.Printf("%d\n", subs[i])
	}
}

func scanIntSlice(size int) []int {
	input := []int{}
	for i := 0; i < size; i++ {
		var in int
		fmt.Scanf("%d", &in)
		input = append(input, in)
	}
	return input
}


Measured memory_bytes: 15872
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;

#define  GODSPEED       ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first                 
#define  s              second
#define  newl           cout<<"\n";
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<"\n";
#define  deb2(a,b)      cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()           
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const int  N     =  5e5+5;
const int  mod   =  1e9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const int  LEVEL =  log2(N)+1;

int n;

void solve(){
	int ct = 0;
	cin >> n;
	for(int i = 1; i <= n; i++){
		int x, y; cin >> x >> y;
		if(x != y) ct = 0;
		else{
			ct++;
			if(ct == 3){
				deb1("Yes")
				return;
			}
		}
	}
	deb1("No")
}

int main(){
	GODSPEED;
	int test = 1;
	//cin >> test;
	for(int i = 1; i <= test; i++){
		solve();
	}
	#ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif
}

Measured memory_bytes: 3612
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

n, d = wi()
print((n + 2 * d + 1 - 1) // (2 * d + 1))

Measured memory_bytes: 6472
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main () {

  ll N;
  vector<ll> P;

  cin >> N;

  ll temp;
  REP(i, 0, N) {
    cin >> temp;
    P.push_back(temp);
  }

  // debug
  // cout << endl;
  // REP(i, 0, N){
  //   cout << P[i] << " ";
  // }
  // cout << endl;

  ll min = inf;
  ll ans = 0;
  REP(i, 0, N) {
    if (P[i] <= min) {
      ans++;
      min = P[i];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <bitset>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define p pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000'000'007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;
int main(){
    string sa,sb,sc;
    cin >> sa >> sb >> sc;
    int a = 0,b = 0,c = 0;
    int s = 0;
    while(a <= sa.size() && b <= sb.size() && c <= sc.size()){
        if(s == 0){
            if(a == sa.size()){
                cout << "A" << endl;
                return 0;
            }
            if(sa[a] == 'b') s = 1;
            else if(sa[a] == 'c') s = 2;
            a++;
        }
        else if(s == 1){
            if(b == sb.size()){
                co("B");
                return 0;
            }
            if(sb[b] == 'a') s = 0;
            else if(sb[b] == 'c') s = 2;
            b++;
        }
        else{
            if(c == sc.size()){
                co("C");
                return 0;
            }
            if(sc[c] == 'a') s = 0;
            else if(sc[c] == 'b') s = 1;
            c++;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double dp[302][302][302];
int n;
double func(int f,int g,int h)
{
	//cout<<f<<" "<<g<<" "<<h<<endl;
	if(f==0&&g==0&&h==0)
		return 0.0d;
	if(dp[f][g][h]!=-1)
		return dp[f][g][h];
	double d1=0.0d,d2=0.0d,d3=0.0d;
	if(f>0)
		d1=f*func(f-1,g,h);
	if(g>0)
		d2=g*func(f+1,g-1,h);
	if(h>0)
		d3=h*func(f,g+1,h-1);
	dp[f][g][h]=(d1+d2+d3+n)/(f+g+h);
	//cout<<f<<" "<<g<<" "<<h<<" "<<dp[f][g][h]<<endl;
	return dp[f][g][h];
}
int main()
{
	int f=0,g=0,h=0,i,x,j,k;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		if(x==1)
			f++;
		else if(x==2)
			g++;
		else if(x==3)
			h++;
	}
	//memset(dp,-1.0d,sizeof(dp));
	for(i=0;i<=300;i++)
	{
		for(j=0;j<=300;j++)
		{
			for(k=0;k<=300;k++)
				dp[i][j][k]=-1.0d;
		}
	}
	cout<<fixed<<setprecision(12)<<func(f,g,h)<<endl;
	//cout<<dp[f][g][h]<<endl;
}


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

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

// 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 
// 14 15 15 15 16 16 16 17 17 17

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) scanf("%lld", &a[i]);

    map<ll, ll> fd;
    ll ans = 1;
    
    rep(i, n) {
        ll t = a[i];
        
        if (t == 0) {
            ans *= 3 - fd[0];
            ans %= MOD;
            fd[0] += 1;
        } else {
            ans *= fd[t - 1] - fd[t] % MOD;
            if (fd[t-1] - fd[t] <= 0) {
                cout << 0 << endl;
                return 0;
            }
            // cout << ans << " " << fd[t-1] << endl;
            ans %= MOD;
            fd[t] += 1;
        }
    }

    cout << ans % MOD << endl;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int A, B, C;
    cin >> A >> B >> C;

    if(A%2 == 1 || B%2 == 1 || C%2 == 1){
        cout << 0<< endl;
        return 0;
    }
    
    if(A == B && B == C){
        cout << -1 << endl;
        return 0;
    }

    int A0 = A, B0 = B, C0 = C, ans = 0;
    while(A%2 == 0 && B%2 == 0 && C%2 == 0){
        A = (B0 + C0)/2;
        B = (C0 + A0)/2;
        C = (A0 + B0)/2;
        A0 = A;
        B0 = B;
        C0 = C;
        ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int x, y;
    cin >> x >> y;

    int score = 0;
    if (x == 1 && y == 1) {
        score += 400'000;
    }

    rep(i, 2)
    {
        switch (x) {
        case 1:
            score += 300'000;
            break;
        case 2:
            score += 200'000;
            break;
        case 3:
            score += 100'000;
            break;
        default:
            break;
        }
        swap(x, y);
    }

    cout << score << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
using namespace std;
int main(){
  int n;
  string x;
  string st;
  cin >>n;
  for(int i=0;i<n;i++){
    cin >> x;
    cin >> st;
    for(int j=x.size()-1;j>=0;j--){
      if(x[j]=='C'){
	char stock;
	stock = st[0];
	st.erase(st.begin());
	st+=stock;
      }
      else if(x[j]=='J'){
	char stock;
	stock = st[st.size()-1];
	//	cout << "p1"<<endl;
	st.erase(st.size()-1);
	//cout <<"p2"<<endl;
	st.insert(st.begin(),stock);
      }
      else if(x[j]=='E'){
	string stock;
	stock.clear();
	int l=st.size()/2;
	for(int k=0;k<l;k++){
	  stock+=st[k];
	}
	string stock2;
	stock2.clear();
	int od = st.size()%2;
	for(int k=l+od;k<l*2+od;k++){
	  stock2+=st[k];
	}
	char st3;
	if(od==1){
	  st3=st[l];
	  st=stock2+st3+stock;
	}
	else{
	  st=stock2+stock;
	}
      }
      else if(x[j]=='A'){
	string stock;
	stock.clear();
	for(int k=0;st.empty()!=true;k++){
	  stock += st[0];
	  st.erase(st.begin());
	}
	//cout << stock <<endl;
	for(int k=stock.size()-1;k>=0;k--){
	  st+=stock[k];
	}
      }
      else if(x[j]=='M'){
	for(int k=0;k<st.size();k++){
	  if(st[k]>='0'&&st[k]<'9'){
	    st[k]++;
	  }
	  else if(st[k]=='9'){
	    st[k]='0';
	  }
	}
      }
      else if(x[j]=='P'){
	for(int k=0;k<st.size();k++){
	  if(st[k]>'0'&&st[k]<='9'){
	    st[k]--;
	  }
	  else if(st[k]=='0'){
	    st[k]='9';
	  }
	}
      }	

      //cout <<"it is "<<x[j]<<endl;
      //cout << st << endl;
    }
    cout << st << endl;
  }
  return 0;
}

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

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

int main() {
    int n; cin >> n;
    vector<long long> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];
    
    vector<long long> left(n+1, 0);
    for(int i = 0; i< n; ++i) left[i+1] = GCD(left[i], a[i]);
    vector<long long> right(n+1, 0);
    for(int i = n-1; i>= 0; --i) right[i] = GCD(right[i+1], a[i]);
    
    long long res = 0;
    for(int i = 0; i < n; ++i) res = max(res, GCD(left[i], right[i+1]));
    
    cout << res << endl;
}


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

int main() {
  char s[110];
  char t[110];
  scanf("%s%s", s,t);
  printf("%s%s\n", t,s);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define MOD 1000000007
using namespace std;
double dp[3005][3005];
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int N;
  cin >> N;
  double p[3005];
  for (int i = 1; i <= N; ++i) cin >> p[i];
  memset(dp, 0, sizeof(dp));
  dp[1][0] = p[1];
  dp[0][1] = 1 - p[1];
  for (int i = 2; i <= N; ++i)
    {
      dp[i][0] = dp[i - 1][0] * p[i];
      dp[0][i] = dp[0][i - 1] * (1 - p[i]);
      for (int j = 1; j < i; ++j)
        dp[j][i - j] = dp[j - 1][i - j] * p[i] + dp[j][i - j - 1] * (1 - p[i]);
    }
  double sum = 0;
  for (int i = 0; i <= N; ++i)
    if (i > N - i) sum += dp[i][N - i];
  cout << setprecision(10) << sum << endl;
  return 0;
}


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

using namespace std;

int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int a[n];
	int k=0;
	for( int i=0;i<n;i++ ){
		a[i]=k;
		if( s[i]=='W' ){
			k++;
		}
	}
	k=0;
	int t=INT_MAX;
	for(int i=n-1;i>=0;i--){
		a[i]+=k;
		if(s[i]=='E'){
			k++;
		}
		t=min(t,a[i]);
	}
	cout<<t<<endl;
	return 0;
}

Measured memory_bytes: 1796
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    int a,b,i,flag,j;
    char c[100];
    while(scanf("%d%d\n%s",&a,&b,c)==3)
    {
        for(i=0,flag=0;i<a;i++)
        {
            if(c[i]<'0'||c[i]>'9')
            {
                flag=1;
                break;
            }
        }
        if(c[i]!='-')
            flag=1;
        for(j=1;j<=b;j++)
        {
            if(c[i+j]<'0'||c[i+j]>'9')
            {
                flag=1;
                break;
            }
        }
        if(flag==1)
            printf("No\n");
        else
            printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		long k = sc.nextLong();
		sc.close();

		int idx = -1;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == '1') {
				idx = i;
			} else {
				break;
			}
		}
		if (idx == -1) {
			System.out.println(s.charAt(0));
		} else if (idx >= k - 1) {
			System.out.println("1");
		} else {
			System.out.println(s.charAt(idx + 1));
		}
	}
}


Measured memory_bytes: 22868
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }



int main() {
	
	ll N;
	cin >> N;
	vll A(N), B(N);
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];
	vll Sa(N), Sb(B);
	rep(i, N) {
		if (i == 0) Sa[0] = A[i];
		else Sa[i] = Sa[i - 1] + A[i];
	}
	ford(i, 0, N) {
		if (i == N - 1) Sb[N - 1] = B[N - 1];
		else Sb[i] = Sb[i + 1] + B[i];
	}

	ll ans = -INF;
	rep(i, N) {
		ans = max(ans, Sa[i] + Sb[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
k, n = map(int, input().split())
a = list(map(int, input().split()))

maxi = 0
for i in range(1, n):
    maxi = max(maxi, abs(a[i] - a[i-1]))
maxi = max(maxi, a[0] + (k-a[n-1]))

print(k-maxi)

Measured memory_bytes: 26444
import heapq
n = int(input())
x=0
d=list(map(int,input().split()))
while len(d)>=2:
    d.sort()
    x=(d[0]+d[1])/2
    heapq.heappop(d)
    heapq.heappop(d)
    d.append(x)
print(x)
  
  

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <list>
#include <string>
#include <map>
#include <numeric>
#include <queue>
#include <stack>

using namespace std;
using ll = long long;

int main(){

	int n;
	ll ans = 0;
	int p[100010] = { 0 };

	cin >> n;

	for (int i = 1; i <= n; i++) {
		cin >> p[i];
	}

	if (p[n - 1] != n - 1) {
		for (int i = 1; i <= n; i++) {
			if (p[i] == i) {
				swap(p[i], p[i + 1]);
				ans++;
			}
		}
	}
	else {
		for (int i = n; i > 0 ; i--) {
			if (p[i] == i) {
				swap(p[i], p[i - 1]);
				ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int n;
int main() {
    
        scanf("%d", &n);
        printf("%d\n", (1000 - (n % 1000)) % 1000);
    
    
    return 0;
}


Measured memory_bytes: 3824
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[20]; bool vis[1 << 20];
int rec(int used) {
	if (vis[used]) return 20;
	int r = 0;
	int b[20] = { 0 }, c[20] = { 0 };
	for (int i = 0; i < 20; i++) {
		if (used & (1 << i)) b[r] = a[i], c[r++] = i;
	}
	int ret = r;
	for (int i = 0; i < r; i++) {
		int ty = i >> 2, tx = i & 3;
		for (int j = -1; j <= 1; j++) {
			for (int k = -1; k <= 1; k++) {
				if (!j && !k) continue;
				int ry = ty + j, rx = tx + k, t = 4 * ry + rx;
				if (0 <= ry && ry < 5 && 0 <= rx && rx < 4 && t < r) {
					if (a[c[i]] == a[c[t]]) {
						int used2 = used - (1 << c[i]) - (1 << c[t]);
						ret = min(ret, rec(used2));
					}
				}
			}
		}
	}
	vis[used] = true;
	return ret;
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		fill(vis, vis + (1 << 20), false);
		for (int j = 0; j < 20; j++) cin >> a[j];
		cout << rec((1 << 20) - 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 4112
#include <iostream>
#include <math.h>
using namespace std;

int n,m;
int main(){
	while(cin >> n && n && cin >> m && m){
		int taro[n],hanako[m],i,j;
		int sum_t=0, sum_h=0;
		for(i=0; i<n; i++){
			cin >> taro[i];
			sum_t += taro[i];
		}
		for(i=0; i<m; i++){
			cin >> hanako[i];
			sum_h += hanako[i];
		}
		int t, h, min=202, d=sum_t-sum_h;
		for(i=0; i<n; i++){
			for(j=0; j<m; j++){
				if(!(d+2*(hanako[j]-taro[i])) && min>(taro[i] + hanako[j])){
					min = taro[i] + hanako[j]; 
					t = i;
					h = j;
				}
			}
		}
		if(min==202) cout << "-1" << endl;
		else cout << taro[t] << " " <<  hanako[h] << endl;
	}
}

Measured memory_bytes: 1160
using System;

class Program
{
    static int[] d;

    static void Main(string[] args)
    {
        d = Array.ConvertAll(Console.ReadLine().ToCharArray(), x => x - '0');
        var ans = dfs(0, 0);
        Console.WriteLine(ans);
    }

    static long dfs(int i, long a)
    {
        if (d.Length <= i)
        {
            return a;
        }

        var p = 0L;
        var ans = 0L;
        for (; i < d.Length; i++)
        {
            p = p * 10 + d[i];
            ans += dfs(i + 1, a + p);
        }
        return ans;
    }
}


Measured memory_bytes: 11092
import java.math.BigInteger;
import java.util.*;
public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		

		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		
		long gcd = c * d / gcd(c , d);
		
		long acc = (a - 1) / c;
		long add = (a - 1)  /d;
		long acd = (a - 1) / gcd;
		
		long bcc = b / c;
		long bdd = b / d;
		long bcd = b / gcd;
		
		long ansa = a - (acc + add - acd);
		long ansb = b - (bcc + bdd - bcd);

		
		
		System.out.println(ansb - ansa + 1);
		
		
		
		

		
		
	}
	
    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
	
}

 

Measured memory_bytes: 21844
#２つの整数 a と b を読み込んで、以下の値を計算するプログラム

list = input().split()
a = int(list[0]); b = int(list[1])

d = int(a / b); r = a % b; f = a / b

print(d, r, "{:.5f}".format(f))


Measured memory_bytes: 5608
A, B, C = map(int, input().split())
K = int(input())

k = 0

while(1):
    if B <= A:
        B = B * 2
        k += 1
    else: break

while(1):
    if C <= B or C <= A:
        C = C * 2
        k += 1
    else: break


if k <= K: print("Yes")
else: print("No")

Measured memory_bytes: 9184
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
i8 = np.int64
i4 = np.int32


def main():
    stdin = open('/dev/stdin')
    pin = np.fromstring(stdin.read(), i8, sep=' ')
    N = pin[0]
    M = pin[1]
    L = pin[2]
    ABC = pin[3: M * 3 + 3].reshape((-1, 3))
    A = ABC[:, 0] - 1
    B = ABC[:, 1] - 1
    C = ABC[:, 2]
    Q = pin[M * 3 + 3]
    st = (pin[M * 3 + 4: 2 * Q + M * 3 + 4] - 1).reshape((-1, 2))
    s = st[:, 0]
    t = st[:, 1]

    graph = csr_matrix((C, (A, B)), shape=(N, N))
    dist = np.array(floyd_warshall(graph, directed=False))
    dist[dist > L + 0.5] = 0
    dist[dist > 0] = 1
    min_dist = np.array(floyd_warshall(dist))
    min_dist[min_dist == np.inf] = 0

    min_dist = (min_dist + .5).astype(int)
    x = min_dist[s, t] - 1
    print('\n'.join(x.astype(str)))


if __name__ == '__main__':
    main()

Measured memory_bytes: 39344
#include <bits/stdc++.h>
 
using namespace std;
 
int N, M, size;
int ans, a[10];
vector<int> ast;
 
int _2(int x){
    int s = x*2, t = 0;
 
    while(s > 0){
	t += s % 10;
	s /= 10;
    }
    return t;
}
 
void solve(int d, int sum){
    if(d == size){
	if(sum % 10 == 0){
	    ans++;
	}
	return;
    }
 
    int _ast = ast[d];
    for(int i = 0 ; i < M ; i++){
	if(_ast == 2){
	    int s = _2(a[i]);
	    solve(d+1,sum+s);
	}else{
	    solve(d+1,sum+a[i]);
	}
    }
}
 
int main(){
    char ch;
    int sum = 0; ans = 0;
 
    cin >> N;
    for(int i = 0 ; i < N ; i++){
	cin >> ch;
	if((N-i)%2 == 0){
	    if(ch == '*'){
		ast.push_back(2);
	    }else{
		sum += _2(ch - '0');
	    }
	}else{
	    if(ch == '*'){
		ast.push_back(1);
	    }else{
		sum += (ch - '0');
	    }
	}
    }   
 
    cin >> M;
    for(int i = 0 ; i < M ; i++){
	cin >> a[i];
    }
    size = ast.size();
    solve(0, sum);
    cout << ans << endl;    
   
    return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	auto A=vecin(N);
	sort(ALL(A),greater<int>());
	int sumA=0,sumB=0;
	REP(i,N){
		if(!(i%2)) sumA+=A[i];
		else sumB += A[i];
	}
	
	out(sumA-sumB);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = 1001002003004005006ll;
const int inf = 1001001001;
const int mod = 1000000007;

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; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	a--;
	ll res1 = a - a / c - a / d + a / lcm(c , d);
	ll res2 = b - b / c - b / d + b / lcm(c, d);
	cout << res2 - res1 << endl;
	return 0;
}

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

int main(){
	int N; cin>>N;
	while(N--){
		int t,x,y; cin>>t>>x>>y;
		if(t<x+y || (t&1)!=((x+y)&1)){ puts("No"); return 0; }
	}
	puts("Yes");
}

Measured memory_bytes: 256
#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++)

int main(){
    int N;
    string s, t;
    cin >> N >> s >> t;
    string S = s + t;
    int len = (int)S.size();
    int anc = len / 2 - 1;
    int anc_n = anc + 1;
    int cnt = 0;
    int ans = 0;
    for(int i = anc, j = anc_n; i >= 0; i--, j++){
        cnt++;
        string a = S.substr(i, cnt);
        string b = S.substr(anc_n, cnt);
        if(a == b) ans = cnt;
    }    
    cout << len - ans << endl;
    return 0;
}

Measured memory_bytes: 256
fn concent(w: usize, s: usize) -> f64 {
    if w == 0 {
        0.0
    } else {
        s as f64 / w as f64
    }
}

fn main() {
    let (a, b, c, d, e, f) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).ok();
        let v: Vec<usize> = buf.split_whitespace().map(|x| x.parse().unwrap()).collect();
        (v[0], v[1], v[2], v[3], v[4], v[5])
    };

    let mut water = vec![false; f + 1];
    let mut sugar = vec![false; f + 1];

    for i in 0..50 {
        for j in 0..50 {
            let x = a * i + b * j;
            if x * 100 > f {
                break;
            }

            water[x] = true;
        }
        if a * i > f {
            break;
        }
    }

    for i in 0..5000 {
        for j in 0..5000 {
            let x = c * i + d * j;
            if x > f {
                break;
            }

            sugar[x] = true;
        }
        if c * i > f {
            break;
        }
    }

    let mut ans_water = a;
    let mut ans_sugar = 0;
    for w in 0..f + 1 {
        if !water[w] {
            continue;
        }
        for s in 0..f - w + 1 {
            if !sugar[s] {
                continue;
            }
            let total = w * 100 + s;
            let c = concent(w, s);
            if total > f {
                continue;
            }
            if c > e as f64 {
                continue;
            }

            if c > concent(ans_water, ans_sugar) {
                ans_water = w;
                ans_sugar = s;
            }
        }
    }

    println!("{} {}", ans_sugar + ans_water * 100, ans_sugar);
}


Measured memory_bytes: 4352
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

fill = b[a[-1]-1]
for i in range(n-1):
  fill += b[a[i]-1]
  if a[i]+1 == a[i+1]:
    fill += c[a[i]-1]
    
print(fill)

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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<c-d+b<<" "<<d+c-a<<" "<<c-d+b+a-c<<" "<<d+c-a+b-d<<endl;
}


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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int cnt(int a, int b) {
  int res = 0;
  while(a < b) {
    a *= 2;
    res++;
  }
  return res;
}

int po(int a, int b) {
  int res = 1;
  for(int i=0;i<b;++i) {
    res *= a;
  }
  return res;
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n, k; cin >> n >> k;
  long double ans = 0.0;
  for(int i=1;i<=n;++i) {
    ans += (1.0 / n) * (1.0 / po(2, cnt(i, k)));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

from collections import deque


if __name__ == '__main__':

    n, m = [int(s) for s in input().split()]
    E = [set() for _ in range(n)]
    for _ in range(m):
        s, t = [int(s) for s in input().split(" ")]
        E[s].add(t)

    color = [0] * n
    indeg = [0] * n
    for s in range(n):
        for t in E[s]:
            indeg[t] += 1

    Q = deque()
    out = []

    def bfs(s):
        Q.append(s)
        color[s] = 1
        while Q:
            u = Q.popleft()
            out.append(u)
            for v in E[u]:
                indeg[v] -= 1
                if indeg[v] == 0 and color[v] == 0:
                    color[v] = 1
                    Q.append(v)

    for u in range(n):
        if indeg[u] == 0 and color[u] == 0:
            bfs(u)

    print("\n".join(map(str, out)))



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

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


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

void selection_sort(int a[], int n) {
  int c = 0;
  rep(i, 0, n) {
    int minj = i;
    rep(j, i, n) {
      if (a[j] < a[minj])
        minj = j;
    }
    if (a[i] > a[minj]) {
      swap(a[i], a[minj]);
      c++;
    }
  }

  rep(i, 0, n) {
    if (i > 0)
      cout << " ";
    cout << a[i];
  }
  cout << endl;
  cout << c << endl;
}

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

  int n;
  cin >> n;
  int a[n];
  rep(i, 0, n) cin >> a[i];
  selection_sort(a, n);
}



Measured memory_bytes: 3168
<?php
$numOfMount = trim(fgets(STDIN));
$hights = explode(' ', trim(fgets(STDIN)));

$count = 1;
for ($i = 1; $i < $numOfMount; $i++) {
    $badView = 0;
	for ($j = 0; $j < $i; $j++) {
    	if ($hights[$j] > $hights[$i]) {
        	$badView++;
        }
    }
  	if ($badView === 0) {
    	$count++;
    }
}
  
echo $count, PHP_EOL;

Measured memory_bytes: 4728
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int n,row,size,tmp;
	cin >> n;
	int** mat = new int* [n];
	for (int i = 0;i < n;i++) {
		cin >> row >> size;
		mat[row - 1] = new int[n];
		for (int j = 0;j < n;j++) {
			mat[row - 1][j] = 0;
		}
		for (int j = 0;j < size;j++) {
			cin >> tmp;
			mat[row - 1][tmp - 1] = 1;
		}
	}
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < n-1;j++) {
			cout << mat[i][j] << " ";
		}
		cout << mat[i][n - 1] << endl;
	}
}


Measured memory_bytes: 3132
import sys
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

a = list(itertools.permutations(range(1,N+1)))

ip = a.index(P)
iq = a.index(Q)

if ip-iq >= 0:
  print(ip-iq)
else:
  print(iq-ip)

Measured memory_bytes: 8052
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int a,b,i;
    cin>>a>>b;
    string s;
    cin>>s;
    int f=0;
    for (i=0;i<s.size();i++)
    {
        if (i<a)
        {
            if (s[i]>=48 && s[i]<=57)
                continue;
            else
            {
                f=1;
                break;
            }
        }
        else if (i==a)
        {
            if (s[i]=='-')
                continue;
            else
            {
                f=1;
                break;
            }
        }
        else
        {
            if (s[i]>=48 && s[i]<=57)
                continue;
            else
            {
                f=1;
                break;
            }
        }
    }
    if (f)
        cout<<"No\n";
    else
        cout<<"Yes\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define plll pair<ll, pll>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t x){
	if(was_output)cout << " ";
	was_output = true;
	cout << x;
}

void outendl(){
	was_output = false;
	cout << endl;
}

int n, m;
vvector<int> roads;
vvector<double> dp;
vector<double> sum;
vector<double> used;
vector<double> selecter;

double func(int place){
	if(place==n)return 0;
	double res = 0;
	rep(i, roads[place].size()){
		double d = dp[place][i];
		if(d<0)d = 1 + func(roads[place][i]);
		dp[place][i] = d;
		res += d;
	}
	sum[place] = res;
	res /= roads[place].size();
	return res;
}

double func2(int place){
	if(place==n)return 0;
	if(used[place]<=0)return used[place];
	double res = 0;
	if(roads[place].size()==1){
		return func2(roads[place][0]);
	}
	rep(i, roads[place].size()){
		chmin(res, func2(roads[place][i]));
		chmin(res, ((sum[place]-dp[place][i])/(roads[place].size()-1) - sum[place] / roads[place].size())*selecter[place]);
	}
	used[place] = res;
	return res;
}

void add(){
	for(int i=1;i<n;++i){
		foreach(j, roads[i]){
			selecter[j] += selecter[i] / roads[i].size();
		}
	}
}


int main(){
	cin >> n >> m;
	roads.resize(n+1);
	dp.resize(n+1);
	sum.resize(n+1, 0);
	selecter.resize(n+1, 0);
	used.resize(n+1, 1);
	rep(i, m){
		int s, t;
		cin >> s >> t;
		roads[s].push_back(t);
		dp[s].push_back(-1);
	}
	selecter[1]=1;
	add();
	double r = func(1);
	double l = func2(1);
	printf("%.10lf\n", r+l);

	return 0;
}



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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

template< typename T >
struct Edge {
	int from,to;
	T cost;

	Edge(int to,T cost):from(-1),to(to),cost(cost) {}
	Edge(int from,int to,T cost):from(from),to(to),cost(cost) {}
};

template< typename T >
using Edges=vector< Edge<T> >;

template< typename T >
bool bellman_ford(Edges<T> &edges,int s,vector<T> &dist) {
	const auto INIT=numeric_limits<T>::max();
	int n=(int)dist.size();
	dist.assign(n,INIT);
	dist[s]=0;
	bool negative_cycle=false;
	for(int i=0;i<n;i++) {
		for(auto e:edges) {
			if(dist[e.from]==INIT) continue;
			if(dist[e.to]<=dist[e.from]+e.cost) continue;
			dist[e.to]=dist[e.from]+e.cost;
			if(i==n-1) {
				dist[e.to]=-INIT;
				negative_cycle=true;
			}
		}
	}
	return !negative_cycle;
}

using Weight=int;

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

	int n,m,s;
	cin>>n>>m>>s;
	Edges<Weight> edges;
	vector<Weight> dist(n);
	const auto INIT=numeric_limits<Weight>::max();
	for(int i=0;i<m;i++) {
		int a,b;Weight c;
		cin>>a>>b>>c;
		edges.emplace_back(a,b,c);
	}
	if(bellman_ford(edges,s,dist)) {
		REP(i,n) {
			if(dist[i]==INIT) cout<<"INF"<<endl;
			else cout<<dist[i]<<endl;
		}
	}
	else cout<<"NEGATIVE CYCLE"<<endl;

	return 0;
}



Measured memory_bytes: 3260
require 'set'

def main
  n = gets.chomp.to_i
  n_arr = gets.chomp.split(/\s/).collect { |x| x.to_i}
  q = gets.chomp.to_i
  q_arr = gets.chomp.split(/\s/).collect { |x| x.to_i}

  s1, s2 = Set.new, Set.new
  n_arr.each { |elem| s1 << elem}
  q_arr.each { |elem| s2 << elem}

  puts (s1 & s2).size
end

main

Measured memory_bytes: 25136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n,k;
  string s;
  cin >> n >> k >> s;
  s[k - 1] = (s[k - 1] - 'A') + 'a';
  cout << s << endl;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    double ans = 0;
    double PI = acos(-1);
    double s = x / a;

    if (s >= a * b / 2) {
        double h = (a * b - s) * 2 / a;
        double rad = atan2(h, a);
        ans = rad * 180.0 / PI;
    } else {
        double h = s * 2 / b;
        double rad = atan2(h, b);
        ans = 90 - rad * 180.0 / PI;
    }
    printf("%.10f\n", ans);
}

Measured memory_bytes: 256