akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
typedef long long ll;
const ll MAX=510000;
const ll mod = 1e9 + 7;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L,G;
ll ans;
string S,T;
ll h[101010];
ll y[101010];
ll a[201010];
ll c[101010];
ll k[101010];
ll b[201010];
ll d[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll r[101010];
ll v[101010];
ll s[101010];
ll x[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main(){
    cin>>S;
    rep(i,0,S.size()){
        if((i+1)%2==0){
            if(S[i]=='R'){
                cout<<"No"<<endl;
                return 0;
            }
        }else{
            if(S[i]=='L'){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

#define task "A" //ABC126
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define pb push_back
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;

// Limit

// Struct

// Variables
int n,k,mu;
double res=0;
// Function

int main()
{
	//freopen(task".in","r",stdin);
	//freopen(task".out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	cin >> n >> k;
	rep(i,1,n)
	{
	    double tem=1;
	    if (i<k) mu=ceil(log2((double)((double)k/(double)i)));
	    else mu=0;
	    rep(j,1,mu) tem*=0.5;
	    res+=tem*(double)(1.0/(double)(n));
	    //cout << "mu : " << mu << '\n';
	}
	cout << fixed << setprecision(13) << res;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  int a,b,c;
  cin >> a;
  cin >> b;
  
  if(a%b==0){
    cout << 0 <<endl;
  }else{
	cout << 1 <<endl;
  }
  
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    string S,T,U;
    int A,B;
    cin>>S>>T>>A>>B>>U;
    if(S==U)A--;
    else if(T==U)B--;
    cout<<A<<" "<<B<<endl;
}

Measured memory_bytes: 256
from collections import Counter

N, T = map(int, input().split())
As = list(map(int, input().split()))

T //= 2
profits = [0] * (N - 1)
minA = As[0]
for i, A in enumerate(As[1:]):
    profits[i] = T * (A - minA)
    minA = min(minA, A)

cnts = Counter(profits)
print(cnts[max(cnts.keys())])


Measured memory_bytes: 22112
#include <stdio.h>
#include <string.h>

const char *day_of_week[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

int main()
{
  char s[4];
  scanf("%s",s);
  for (int i=0; i<7; i++) {
    if (strcmp(day_of_week[i],s) == 0)
      printf("%d\n",7-i);
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	char c;int res=0,flag=1;
	for(;!isdigit(c);c=getchar())if(c=='-')flag=-1;
	for(;isdigit(c);c=getchar())res=res*10+c-'0';
	return res*flag;
}
int n,ans;
map<int,int>a;
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		a[read()]++;
	}
	for(auto it:a)
	{
		int key=it.first,num=it.second;
		ans+=key>num?num:num-key;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4736
#define _USE_MATH_DEFINES
//#include <bits/stdc++.h>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <complex>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

long long wa=0;
long long ac=0;
long long wa_ed[100010]={};
bool ac_ed[100010]={};

void solve(long long N, long long M, std::vector<long long> p, std::vector<std::string> S){
  REP(i,M){
    if(ac_ed[p[i]])continue;
    if(S[i]=="WA"){
      wa_ed[p[i]]++;
    } else {
      ac++;
      wa+=wa_ed[p[i]];
      ac_ed[p[i]]=true;
    }
  }
  cout<<ac<<" "<<wa<<endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  std::vector<long long> p(M);
  std::vector<std::string> S(M);
  for(int i = 0 ; i < M ; i++){
    scanf("%lld",&p[i]);
    std::cin >> S[i];
  }
  solve(N, M, std::move(p), std::move(S));
  return 0;
}

Measured memory_bytes: 4224
n = int(input())
p_list = list(map(int,input().split()))
count = 0
for i in range(1,n-1):
    if (p_list[i] < p_list[i+1] and p_list[i] > p_list[i-1]) or (p_list[i] > p_list[i+1] and p_list[i] < p_list[i-1]):
        count += 1
print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

int main(){

  int n,W;
  cin >> n >> W;

  int v[n],w[n];

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

  int d[n+1][W+1];
  //d[i][w]は最初のi個の中から重さw以下となるように選んだ際の最大

  for(int i=0;i<W+1;i++){
    d[0][i]=0;
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<=W;j++){
      if(w[i]<=j)d[i+1][j]=max(d[i][j-w[i]]+v[i],d[i][j]);
      else d[i+1][j]=d[i][j];
    }
  }

  cout << d[n][W] << endl;




}


Measured memory_bytes: 7048
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int n, m;
bool graph[50][50];
bool seen[50];

void dfs(int v){
    seen[v]=true;
    for(int v2=0; v2<n; v2++){
        if(!graph[v][v2]) continue;
        if(seen[v2]) continue;
        dfs(v2);
    }
}

int main(){
    int ans = 0;
    cin >> n >> m;
    int a[m], b[m];
    rep(i,m){
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        graph[a[i]][b[i]]=true;
        graph[b[i]][a[i]]=true;
    }
    for(int i=0; i<m; i++){
        graph[a[i]][b[i]]=false;
        graph[b[i]][a[i]]=false;
        for(int j=0; j<n; j++) seen[j]=false;
        
        dfs(0);
        bool bridge = false;
        for(int j=0; j<n; j++){
            if(!seen[j]){
                ans++;
                break;
            }
        }
        graph[a[i]][b[i]]=true;
        graph[b[i]][a[i]]=true;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
typedef long long lli;
#define mod 1000000007
const int INF = 1e6;
const int MAX = 1e5+10;
#define fori(n) for(int i=0;i<n;i++)
#define forj(n) for(int j=0;j<n;j++)
#define forli(n) for(lli i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define print(a) cout<<a<<endl
#define print2(a,b) cout<<a<<" "<<b<<endl
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define sortvec(a) sort(a.begin(),a.end())
 
//FUNCTONS
lli llipower(lli x, lli y){lli res = 1;x = x % mod; while (y > 0){if (y & 1) res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
lli llipowerp(lli x, lli y,lli p){lli res = 1;x = x % p; while (y > 0){if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p;}return res;}
lli gcd(lli a, lli b){ if (!a) return b; return gcd(b%a,a);}
lli binarySearch(vector<int> arr, int l, int r, int x){ 
	if (r >= l) { 
		lli mid = l + (r - l) / 2; 
		if (arr[mid] == x) return mid; 
		if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x); 
		return binarySearch(arr, mid + 1, r, x); 
	} 
	return -1;
}

template <typename T>
void printvec(vector<T> inp){
	for(int i=0;i<inp.size();i++){
		cout<<inp[i]<<" ";
	}
	cout<<endl;
}
template <typename T>
T ceildiv(T x, T y){
	return 1 + ((x - 1) / y);
}
lli modInverse(lli a, lli m){//m is PRIME 
    lli g = gcd(a, m); 
    if (g != 1) return -1;
    else return llipowerp(a, m-2, m);
} 
int main(){

	int n,m;
	cin>>n>>m;
	vector<int> s(m);
	vector<int> c(m);
	fori(m){
		cin>>s[i]>>c[i];

	}
	vector<int> num(n,-1);
	bool con=true;
	fori(m){
		if(s[i]==1 && c[i]==0 && n>1){
			con=false;
			break;
		}
		else{
			if(num[s[i]-1]==-1) num[s[i]-1]=c[i];
			else{
				if(num[s[i]-1]!=c[i]){
					con=false;
					break;
				}
			}
		}
	}
	if(con){
		fori(n){
			if(num[i]!=-1) cout<<num[i];
			else{
				if(i!=0) cout<<0;
				else{
					if(n==1) cout<<0;
					else cout<<1;
				}
			}
		}
		cout<<endl;
	}
	else cout<<-1<<endl;

}
 
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int A,B,C,D,E,F;
int sum = 0, sugar = 0;
double ans = -1.0;

int main(int argc, char** argv) {
	cin>>A>>B>>C>>D>>E>>F;
	for(int i=0;i * A * 100<=F;i++) {
		int va = i * A * 100;
		for(int j=0;j*B*100+va<=F;j++) {
			int vw = j * B * 100 + va;
			int m_sugar = vw / 100 * E;
			for(int k=0;k*C <= m_sugar;k++) {
				int cs = k * C;
				for(int e=0;e*D + cs <= m_sugar;e++) {
					int ss = e * D + cs;
					if(vw + ss > F)continue;
					double ratio = (double)ss / ((double)ss + vw);
					if(ratio > ans) {
						ans = ratio;
						sum = vw + ss;
						sugar = ss;
					}
				}
			}
		}
	}
	cout<<sum<<" "<<sugar<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
dat = []
for i in range(n):
    std_in = input().split()
    dat.append([std_in[0], int(std_in[1])])
     
for i, e in enumerate(dat, start=1):
    e[1] = -e[1]  # 点数を降順ソートするために点数をマイナスにする。
    e.append(i)  # ソート前の順序
     
sorted_list = sorted(dat)  # 都市名と点数のマイナス値で昇順ソート
     
for i, s in enumerate(sorted_list):
    # 順序を出力
    print(sorted_list[i][2])


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

int main() {
  
  int N;
  cin >> N;
  
  int res=0;
  if(N%2==0){ res=N*N/4; }
  else{ res=((N-1)/2)*((N-1)/2+1); }

  
  cout << res << endl;
  

}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<string>
typedef long long int ll;

using namespace std;


string back(string s){
	string ret="";
	for(int i=s.size()-1;i>=0;i--){
		ret+=s[i];
	}
	return ret;
}

int main(){
	string s;
	cin>>s;
	cout<<back(s)<<endl;
	return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
int n;
vector<vector<int> >g;
vector<int> p,q;

void bfs(int a,int pre){
    p[a] = p[pre]+1;
    for(auto x:g[a]){
        if(x!=pre){
            bfs(x,a);
        }
    }
}
void bfs2(int a,int pre){
    q[a] = q[pre]+1;
    for(auto x:g[a]){
        if(x!=pre){
            bfs2(x,a);
        }
    }
}


int main(){
    cin >> n;
    g.resize(n);
    p.resize(n);
    q.resize(n);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].PB(b);
        g[b].PB(a);
    }
    p[0] = 0;
    q[n-1] = 0;
    bfs(0,0);
    bfs2(n-1,n-1);
    int s = 0;
    int t = 0;
    rep(i,n){
        //cerr << p[i] << " " << q[i] << endl;
        if(p[i]<=q[i]){
            s++;
        }else{
            t++;
        }
    }
    //cerr << s << " " << t << endl;
    if(s>t){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }
    return 0;
}

Measured memory_bytes: 11136
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string t;
    cin >> t;
    int n = (int)t.size();
    vector<char> ans(n);
    REP(i,n){
        if(t[i]=='P'){
            ans[i] = 'P';
        }else if(t[i]=='D'){
            ans[i] = 'D';
        }else{
            ans[i] = 'D';
        }
    }
    REP(i,n) cout << ans[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 3900
#include "bits/stdc++.h"
using namespace std;

#define debug(args...) fprintf(stderr, args);

typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 1e5 + 10;

int n, m;
int a[maxn];

int par[maxn];
int sz[maxn];

int C;

void init() {
    C = n;
    for(int i = 1; i <= n; ++i) {
	par[i] = i;
	sz[i] = 1;
    }
}

int root(int v) {
    if(par[v] == v) return v;
    return par[v] = root(par[v]);
}

void merge(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return;
    if(sz[y] > sz[x]) swap(x, y);
    sz[x] += sz[y];
    par[y] = x;
    --C;
}

ll ans;
multiset<int> Q[maxn];
multiset<pii> cur;

int cnt[maxn];

ll solve() {
    if(n == 1 || C == 1) return ans = 0;
    if(2 * (C - 1) > n) return ans = -1;
    int nodes = 2 * (C - 1);
    for(int i = 1; i <= n; ++i) Q[root(i)].insert(a[i]);
    for(int i = 1; i <= n; ++i)
	if(root(i) == i) {
	    ans += *Q[i].begin();
	    Q[i].erase(Q[i].begin());
	    ++cnt[i];
	    --nodes;
	    for(auto k: Q[i]) cur.insert({k, i});
	}

    while(nodes > 0) {
	int A = cur.begin()->first;
	int v = cur.begin()->second;
	cur.erase(cur.begin());
	if(cnt[v] == C - 1) continue;
	ans += A;
	++cnt[v];
	--nodes;
    }
    
    return ans;
}

int main() {
    scanf("%d %d", &n, &m);
    for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    init();
    for(int i = 1; i <= m; ++i) {
	int x, y;
	scanf("%d %d", &x, &y);
	++x, ++y;
	merge(x, y);
    }
    ll cost = solve();
    if(cost == -1) printf("Impossible\n");
    else printf("%lld\n", cost);
    return 0;
}


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

using namespace std;
typedef long long int ll;
#define vll vector<ll>
#define vvll vector<vll>
#define mll map<ll,ll>
#define f(i,m,n) for(i=m;i<n;i++)
#define ee endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define take(v,n) for(i=0;i<n;i++) cin>>v[i];
#define NO() cout<<"NO"<<endl
#define YES() cout<<"YES"<<endl
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sot(v) sort(v.begin(),v.end());
bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}

void solve()
{
	ll i,j,k,l,n;
	cin>>n;
	string s;
	map<string,ll> m;
	f(i,0,n)
	{
		cin>>s;
		m[s]++;
	}
	cout<<"AC x "<<m["AC"]<<ee;
	cout<<"WA x "<<m["WA"]<<ee;
	cout<<"TLE x "<<m["TLE"]<<ee;
	cout<<"RE x "<<m["RE"]<<ee;
}


int main() {
    fast;
    ll i,j,l,k,t,n;
    //cin>>t;
    t=1;
    while(t--)
    solve();
}

Measured memory_bytes: 3612
import sys
from itertools import combinations
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

class UnionFindTree:
    def __init__(self, n):
        self.nodes = list(range(n+1))
    def find(self, x):
        if self.nodes[x] == x:
            return x
        parent = self.find(self.nodes[x])
        self.nodes[x] = parent
        return parent
    def unite(self, a, b):
        a = self.find(a)
        b = self.find(b)
        if a == b:
            return
        self.nodes[a] = self.nodes[b]
    def is_same(self, a, b):
        return self.find(a) == self.find(b)


N=II()
INL=[tuple(LI()) for i in range(N)]
INL.sort()

if N == 1:
    print(1)
    exit()
elif N == 2:
    print(1)
    exit()
elif N > 2:
    res = INTMAX
    for ptr1, ptr2 in combinations(INL,2):
        union = UnionFindTree(N)
        dx, dy = ptr2[0]-ptr1[0], ptr2[1]-ptr1[1] 
        for i in range(N):
            for j in range(i, N):
                if INL[i][0] + dx == INL[j][0] and INL[i][1]+dy == INL[j][1]:
                    union.unite(i,j)
        st = set()
        for i in range(N):
            st.add(union.find(i))
        res = min(res,len(st))
    print(res)


Measured memory_bytes: 60396
# Undirected Graph


class Edge:
    __slots__ = ('v', 'w')

    def __init__(self, v, w):
        self.v = v
        self.w = w

    def either(self):
        return self.v

    def other(self, v):
        if v == self.v:
            return self.w
        else:
            return self.v


class Graph:
    def __init__(self, v):
        self.v = v
        self._edges = [[] for _ in range(v)]

    def add(self, e):
        self._edges[e.v].append(e)
        self._edges[e.w].append(e)

    def adj(self, v):
        return self._edges[v]

    def edges(self):
        for es in self._edges:
            for e in es:
                yield e


def articulation_points(graph):
    visited = [0] * graph.v
    low = [0] * graph.v
    parent = [-1] * graph.v

    s = 0
    children = 0
    visit = 0
    stack = [s]
    vs = set()

    while stack:
        v = stack.pop()
        if not visited[v]:
            visit += 1
            visited[v] = visit
            low[v] = visit

        for e in graph.adj(v):
            w = e.other(v)
            if not visited[w]:
                parent[w] = v
                if v == s:
                    children += 1
                stack.append(v)
                stack.append(w)
                break
            elif w != parent[v]:
                low[v] = min(low[v], visited[w])
        else:
            u = parent[v]
            if u < 0:
                pass
            elif parent[u] < 0:
                if children > 1:
                    vs.add(u)
            else:
                if low[v] >= visited[u]:
                    vs.add(u)
                low[u] = min(low[u], low[v])

    return vs


def run():
    v, e = [int(i) for i in input().split()]
    graph = Graph(v)

    for _ in range(e):
        s, t = [int(i) for i in input().split()]
        edge = Edge(s, t)
        graph.add(edge)

    for v in sorted(articulation_points(graph)):
        print(v)


if __name__ == '__main__':
    run()



Measured memory_bytes: 13772
#include<bits/stdc++.h>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pii pair<int,int>
using namespace std;
ll dp[3003][3003][5];
ll mat[3003][3003];
int main()
{
    fast;
    
    ll n,m,k,j,i;
    cin>>n>>m>>k;
    while(k--)
    {
    	ll r,c,v;
    	cin>>r>>c>>v;
    	mat[r][c] = v;
    }
    for(i=1;i<=n;i++)
    {
    	for(j=1;j<=m;j++)
    	{
    		ll ha = max({dp[i-1][j][0],dp[i-1][j][1],dp[i-1][j][2],dp[i-1][j][3]});
    		dp[i][j][0] = max({ha,dp[i][j-1][0]});
    		dp[i][j][1] = max({ha+mat[i][j], dp[i][j-1][0] + mat[i][j],dp[i][j-1][1]});
    		dp[i][j][2] = max(dp[i][j-1][1] + mat[i][j],dp[i][j-1][2]);
    		dp[i][j][3] = max(dp[i][j-1][2] + mat[i][j],dp[i][j-1][3]);
    	}
    }
    cout<<max({dp[n][m][0],dp[n][m][1],dp[n][m][2],dp[n][m][3]});
}

Measured memory_bytes: 425688
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k,i,j;
    cin>>n>>k;
    ll arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    ll dp[n+1];
    memset(dp,0,sizeof(dp));
    dp[1]=abs(arr[1]-arr[0]);
    ll minn=mod;
    for(i=2;i<n;i++)
    {
        minn=mod;
        for(j=1;j<=min(k,i);j++)
        {
            if((dp[i-j]+abs(arr[i]-arr[i-j]))<minn)
            {
                minn=(dp[i-j]+abs(arr[i]-arr[i-j]));
            }
        }
        dp[i]=minn;
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
   
using namespace std;
     
#define PB(x) push_back(x)
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x) make_pair(x);
    
#define debug(x) cerr << #x << '=' << x << endl;
#define debug2(x, y) cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(a) for (int x: a) cerr << x << ' '; cerr << endl;
#define debugm(a, h, w) for (int i = 0; i < h; i++, cout << endl) for (int j = 0; j < w; j++) cout << a[i][j] << ' ';
#define int long long
     
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;

const int INF = 1e13;
const int mmod = 1000000007;

int32_t main()
{
	string s;
	cin >> s;
	bool found = true;
	for (int i = 0; i < (int)s.size(); i++) {
		if ((i+1)&1) {
			if (s[i] == 'L') found = false;
		} else {
			if (s[i] == 'R') found = false;
		}
	}
	if (!found) cout << "No" << endl;
	else cout << "Yes" << endl;
}



Measured memory_bytes: 256
open Printf
open Scanf

let () =
  let n, m = scanf "%d %d\n" (fun x y -> (x, y)) in
  let rec read x =
    let ar = Array.init x (fun _ -> let p = scanf "%s\n" (fun i -> i) in p) in ar in
  let pa = read n in
  let pb = read m in
  let eq (si, sj) =
    let rec iter i =
      if i = m then true
      else
        if String.sub pa.(si+i) sj m  <> pb.(i) then false else iter (i+1) in
    iter 0 in
  let rec loop (i, j) =
    if i > n - m then "No"
    else
      if j > n - m then loop (i+1, 0) else
        if eq (i, j) then "Yes" else loop (i, j+1) in
  loop (0, 0) |> printf "%s\n"


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    f64 R; cin >> R;
    cout << setprecision(3) << 2 * R * 3.14159265 << endl;

    return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), is_sorted(),


signed main(){
    FASTER;
    int a,b;cin>>a>>b;
    if((a+b)%2==0){
        cout<<(a+b)/2;
    }else{
        cout<<"IMPOSSIBLE";
    }
}



Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
	int x, y, z;
	cin >> x >> y >> z;
	x -= z;
	cout << x / (y + z) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;

int main() {
    double ans = 0;
    ll n,k;
    cin >> n >> k;
    rep(i, 1, n+1){
        double p = 1;
        int x = i;
        while (x < k){
            p *= 0.5;
            x *= 2;
        }
        ans += p/n;
    }
    printf("%.10f\n", ans);
    return 0;
}


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

int main(){
  int n,m,x,a;
  cin >>n>>m>>x>>a;
  int ztox;
  while(a<x){
    ztox+=1;
    cin >>a;
  }
  cout << min(ztox,m-ztox) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#define LL long long
using namespace std;
LL n,a[100010],m,ans[100010],sta[100010],top=0,X[100010],A[100010],k;
bool vis[100010];
void solve(LL x)
{
	top=0;
	while(!vis[x])
	{
		sta[top++]=x;vis[x]=true;
		x=a[x];
	}
	//printf("solve:%lld\n",x);
	//for(int i=0;i<top;i++) printf("%lld ",sta[i]);printf("\n");
	for(LL i=0;i<top;i++) ans[sta[i]]=X[sta[(k+i)%top]];
}
int main()
{
	memset(vis,false,sizeof(vis));
	scanf("%lld",&n);
	for(LL i=1;i<=n;i++) scanf("%lld",&A[i]);
	for(LL i=1;i<=n;i++) a[i]=i,X[i]=A[i]-A[i-1];
	//for(int i=1;i<=n;i++) printf("%lld ",X[i]);printf("\n");
	scanf("%lld %lld",&m,&k);
	for(LL i=1;i<=m;i++)
	{
		LL c;scanf("%lld",&c);
		swap(a[c],a[c+1]);
	}
	//for(int i=1;i<=n;i++) printf("%lld ",a[i]);printf("\n");
	for(LL i=1;i<=n;i++)
	{
		if(vis[i]) continue;
		solve(i);
	}
	//for(int i=1;i<=n;i++) printf("%lld ",ans[i]);printf("\n");
	LL sum=0;
	for(LL i=1;i<=n;i++) sum+=ans[i],printf("%lld.0\n",sum);
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define V vector<int>
#define ll long long
using namespace std;


int main() {
    int n; cin >> n;
    int a[n];
    rep(i, 0, n) cin >> a[i];

    int Max = 0, Maxiti;

    rep(i, 0, n){
        if(a[i] > Max){
            Max = a[i];
            Maxiti = i;
        }
    }

    rep(i, 0, Maxiti){
        cout << Max << endl;
    }

    int M = 0;
    rep(i, 0, n){
        if(i == Maxiti) continue;
        M = max(M, a[i]);
    }
    cout << M << endl;

    rep(i, Maxiti+1, n){
        cout << Max << endl;
    }
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  double x,ans=0.0;
  string v;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> x >> v;
    if(v=="BTC"){
      ans+=x*380000.000000000;
    }else{
      ans+=x;
    }
  }
  printf("%.10lf\n", ans);
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

N, M = map(int, input().split())
pair = defaultdict(set)
for _ in range(M):
    a, b = map(int, input().split())
    pair[a].add(b)
    pair[b].add(a)

Q = []
visited = set()
max_group = 0
for i in range(N):
    if i not in visited:
        count = 1
        Q.append(i)
        visited.add(i)
        while Q:
            x = Q.pop()
            for friend in pair[x]:
                if friend not in visited:
                    Q.append(friend)
                    visited.add(friend)
                    count += 1
        if max_group < count:
            max_group = count
print(max_group)

Measured memory_bytes: 94904
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <vector>
#include <queue>
using namespace std;
#define mod 1000000007
#define INF 0x7fffffffff
#define N 100100
#define endl '\n'
long long p[1000000],q[1000000];
long long sum[1000000];
int main()
{
    long long n,m;
    long long ans=0;
    scanf("%lld",&n);
    for(int i=1;i<=n;i++) scanf("%lld",&p[i]);
    int x=1;
    for(int i=1;i<=n;i++)
    {
        if(p[i]<x) continue;
        if(p[i]==x) {x++;continue;}
        if(p[i]%x==0) ans=ans+p[i]/x-1;
        else ans=ans+p[i]/x;
        if(x==1) x++;
    }
    cout<<ans<<endl;
    return 0;
}


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


if __name__ == '__main__':
    n = int(input())
    h = list(map(int, input().split(' ')))
    _num = 0
    _flag = False
    for num in h:
        if _num > num:
            _flag = True
            break
        elif _num != num:
            _num = num - 1


    if _flag:
        print('No')
    else:
        print('Yes')


Measured memory_bytes: 14252
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int div = m/n;
		
		while(true){
			if(m%div==0){
				System.out.println(div);
				break;
			}
			else
				div--;
		}
	}
}


Measured memory_bytes: 23764
# B - Trained?
N = int(input())
a = [int(input()) for k in range(N)]
count = 1
tmp = a[a[0]-1]
while count <= N:
    if a[0] == 2:
        print(count)
        exit()
    elif tmp == 2:
        count += 1
        print(count)
        exit()
    else:
        tmp = a[tmp-1]
        count += 1

print(-1)

Measured memory_bytes: 7184
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {

  int N;
  cin >> N;

  vector<int> A(N);

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

  int tmp = 1;
  double keta = 0;

  for(int i = 0; i < N; i++){
    keta += log10(A[i]);
    if(keta > 18){
      cout << -1 << endl;
      return 0;
    }
    tmp = tmp * A[i];
  }

  if(tmp > 1000000000000000000){
    cout << -1 << endl;
  }else{
    cout << tmp << endl;
  }
}


Measured memory_bytes: 4048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace lec09A
{
    class Program
    {
        static void Main(string[] args)
        {
            int size;
            size = int.Parse(Console.ReadLine());
            int[] array = new int[size];
            string input = Console.ReadLine();
            string[] split = input.Split(' ');

            for ( int i= 0; i < size; i++)
            {
                array[i] = int.Parse(split[i]);

            }

            /*
            foreach (int element in array){
                Console.Write("{0}",element);
            }*/

            for (int i = 0; i < size; i++)
            {
                Console.Write("node {0}: key = {1}, " , i + 1  , array[i]);
                if ( (i + 1 ) /  2 > 0)
                {
                    Console.Write("parent key = {0}, ",array[ ((i+1) / 2 ) - 1 ] );
                }
                if ( (i+1) * 2 <= size )
                {
                    Console.Write("left key = {0}, ", array[ ( i+1)*2 -1]);
                }
                if ((i + 1) * 2  + 1<= size)
                {
                    Console.Write("right key = {0}, ", array[(i + 1) * 2 +1-1]);
                }
                Console.WriteLine();
            }


            Console.ReadLine();
        }
    }
}



Measured memory_bytes: 15948
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
const ll N = 1e6 + 2;
const ll N1 = 2e5 + 2;
const ll mod = 2e9 +7;

ll power(ll a, ll b){
    ll ret = 1;
    while(b){
        if(b%2==1){
            ret = (ret*a);
        }                                                                                                                                                   
        b/=2;
        a = (a*a);
    }
    return ret;
}
ll C(ll n , ll r){
    if(r == 0){
        return 1;
    }
    ll ret = 1;
    for(int i=1;i<=r;i++){
        ret *= (n - i + 1);
        ret /= i;
    }
    return ret;
}

int main(){
    fast_io;
    int n;
    cin >> n;
    int a[n+2];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int dp[n+2];
    memset(dp , 0 , sizeof(dp));
    dp[0] = 0;
    for(int i=1;i<n;i++){
        if(i == 1){
            dp[i] = dp[i-1] + abs(a[i] - a[i-1]);
        }
        else{
            dp[i] = min(abs(a[i-1] - a[i]) + dp[i-1] , dp[i-2] + abs(a[i-2] - a[i]));
        }
    }
    /*for (int i = 0; i < n; ++i){
        cout << dp[i] << " ";
    }*/
    cout << dp[n-1] << endl;
}

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

using namespace std;

//#define cin fi
//#define cout fo

//ifstream fi (".INP");
//ofstream fo (".INP");

int main(){
//	freopen("test.txt" , "r" , stdin);
//	ios_base:: sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
	int k;
	cin >> k;
	while(k--){
		cout << "ACL";
	}
	return 0;
}




Measured memory_bytes: 3580
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

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

N = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(N)]

ans = A[0] - 1
p = 2
for a in A[1:]:
    if a > p:
        ans += (a - 1) // p
    if a == p:
        p += 1
print(ans)


Measured memory_bytes: 7888
#include <iostream>
#include <cstdio>
#include <stack>
using namespace std;
 
double eval(double a, double b, char oper){
    if( oper == '+' ) return a + b;
    if( oper == '-' ) return a - b;
    if( oper == '*' ) return a * b;
    if( oper == '/' ) return a / b;
    return 0.0;
}
 
int main(){
    string expr;
    while( getline(cin, expr) ){
        stack<double> stk;
        string::iterator it = expr.begin();
        while( true ){
            if( ( *it == '-' && it+1 != expr.end() && isdigit( *(it+1) ) ) ||
                isdigit( *it ) ){
                string::iterator tmp = it;
                if( *it == '-' ) it++;
                double a = 0;
                while( it != expr.end() && *it != '\n' && *it != ' ' ){
                    a *= 10;
                    a += *it - '0';
                    it++;
                }
                if( *tmp == '-' ) a *= -1;
                stk.push( a );
            }else{
                double b, c;
                b = stk.top();
                stk.pop();
                c = stk.top();
                stk.pop();
                stk.push( eval(c, b, *it) );
                it++;
            }
            if( it == expr.end() ) break;
            it++;
        }
        printf("%.6lf\n", stk.top());
        stk.pop();
    }
    return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
long long a[1000009][3];
int n;
long long dp[100009][3];

long long recur(int i, int id2){
    if(dp[i][id2] != -1){
        return dp[i][id2];
    }else if(i == n){
        return 0;
    }
    dp[i][id2] = -1;
    for(int j = 0; j < 3; j++){
        if(j == id2){
            continue;
        }else{
            dp[i][id2] = max(dp[i][id2], a[i][j] + recur(i+1,j));
        }
    }
    return dp[i][id2];
}

int main(){
    cin>>n;
    memset(dp,-1,sizeof dp);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            cin>>a[i][j];
        }
    }
    cout<<max(recur(0,0),max(recur(0,1),recur(0,2)));
}


Measured memory_bytes: 14208
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

N, M, X  = [int(x) for x in stdin.readline().rstrip().split()]

CA = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]

dp = [[[0 for _ in range(M)] for _ in range(4)] for _ in range(N+1)]
dp_money = [[0 for _ in range(2)] for _ in range(N+1)]

tm = [0 for _ in range(2**N)] 
tl = [[0 for _ in range(M)] for _ in range(2**N)]

knowledge_list = [[0 for _ in range(M)]]
money_list = [0]

for i in range(N):
    C = CA[i][0]
    A = CA[i][1:]

    # 購入する場合
    tmp2 = []
    
    for i, knowledge in enumerate(knowledge_list):
        tmp = []
        for k in range(len(knowledge)):
            tmp.append(knowledge[k] + A[k])
        
        tmp2.append(tmp)
        money_list.append(money_list[i]+C)

    knowledge_list = knowledge_list + tmp2

ans = INF
for i in range(len(money_list)):
    if min(knowledge_list[i]) >= X:
        ans = min(ans, money_list[i])

if ans != INF:
    print(ans)
else:
    print(-1)


            


Measured memory_bytes: 75048
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

p1 = 0
p2b = 0
p3b = 0
pn = 0
for i in range(n):
  p1 += abs(x[i] - y[i])
  p2b += abs((x[i] - y[i]) ** 2)
  p3b += abs(((x[i] - y[i]) ** 3))

p2 = p2b ** 0.5
p3 = p3b ** (1 / 3)
pn = max([abs(x[i] - y[i]) for i in range(n)])

print("{:.10f}".format(p1)) 
print(p2)
print(p3)
print("{:.10f}".format(pn))


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

// dp[i][j]: 残り i 日 で最後 j をえらぶ時の最大の幸福度
// dp[N][j] = 0
// dp[i][j] = maximum(c[k] + dp[i+1][k]) where k != j

int score[100010][3];
int dp[100010][3];

int main() {
    int N;
    cin >> N;
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < 3; ++j) {
            scanf("%d", &score[i][j]);
        }
    }

    for(int i = 0; i < 100010; ++i) {
        for(int j = 0; j < 3; ++j) {
            dp[i][j] = 0;
        }
    }

    for(int i = 0; i < 3; ++i) {
        dp[N][i] = 0;
    }
    for(int i = N; i > 0; --i) {
        for(int j = 0; j < 3; ++j) {
            for(int k = 0; k < 3; ++k) {
                if(j == k) continue;
                dp[i-1][j] = max(dp[i-1][j], dp[i][k] + score[i-1][k]);
            }
        }
    }
    
    cout << max(max(dp[0][0], dp[0][1]), dp[0][2]) << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 
   
int main(){
int a,b,c;
cin >> a >> b >> c;
if(a==b && b==c)cout << "Yes" << endl;
else cout << "No" << endl;
} 

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

#ifdef LOCAL_DEBUG
#include "bits/mytest.h"
#endif

using namespace std;


#pragma region user_defined
#define CLR(arr,val) fill(arr.begin(),arr.end(),val);
#define CLR0(arr)  CLR(arr,0)

#define d2clear(arr,data) for(int i =0;i<arr.size();i++){for(int j =0;j<arr[i].size();j++){arr[i][j]=data;}}
#define d2print(arr) for(int i =0;i<arr.size();i++){for(int j =0;j<arr[i].size();j++){cout<<arr[i][j];} cout<<endl;}
#define d2array(name,type,rows,cols,data) vector< vector<type>  > name(rows,vector<type>(cols,data))

#define forit(arr,it) for(auto it=arr.begin();it!=arr.end();it++)
#define rforit(arr,it) for(auto it=arr.rbegin();it!=arr.rend();it++)

#define LL unsigned long long
#define A(n) n.begin(),n.end()
#define maxn(a,b) ((a)=((a)>(b)?(a):(b)))
#define minn(a,b) ((a)=((a)<(b)?(a):(b)))

#define min(a,b)  ( (a)<(b)?(a):(b)   )
#define max(a,b)  ( (a)>(b)?(a):(b)  )
#define last(a)   a[a.size()-1]
#define first(a)  a[0]
#define println(a) cout<<a<<endl;
#define mp(a,b)  make_pair(a,b)
#pragma endregion

//#define MULTI_CASE


LL gcd(LL a, LL b) {
	while (a%b) {
		LL tmp = a;
		a = b;
		b = tmp%b;
	}
	return b;
}
LL myceil(LL a, LL b) {
	LL ret = a / b;
	if (ret*b == a) return ret;
	else return ret + 1;
}
class Solution {

public:
	void solve(istream & cin = std::cin, ostream & cout = std::cout) {
		int n; cin >> n;
		LL a, b; cin >> a >> b; n--;
		while (n--) {
			LL x, y; cin >> x >> y;
			LL g = gcd(x, y);
			x = x / g;
			y = y / g;
			if (x >= a &&y >= b) {
				a = x; b = y;
			}
			else {
				if (x < a && y < b) {
					LL rate1 = myceil(a, x);
					LL rate2 = myceil(b, y);
					LL rate = max(rate1, rate2);
					a = x*rate;
					b = y*rate;
				}
				else if (x < a) {
					LL rate = myceil(a, x);
					a = x*rate;
					b = y*rate;
				}
				else if (y < b) {
					LL rate = myceil(b, y);
					a = x*rate;
					b = y*rate;
				}


			}


		}
		cout << a + b << endl;
	}

};


int main() {
#ifdef LOCAL_DEBUG 

	MyTest::Judge::JudgeNormal judge;
	MyTest::Config config;
	config.judge = &judge;
	MyTest::Test test(config);

	const string ITEM_NAME("CC.cpp");
	const string FILE_NAME(__FILE__);
	auto it = FILE_NAME.find_last_of('\\');
	auto inputfile = FILE_NAME.substr(0, it + 1) + ITEM_NAME.substr(0, ITEM_NAME.find_last_of('.')) + "_input.txt";
	auto outputfile = FILE_NAME.substr(0, it + 1) + ITEM_NAME.substr(0, ITEM_NAME.find_last_of('.')) + "_output.txt";
	freopen(inputfile.c_str(), "r", stdin);
	//freopen(outputfile.c_str(), "w", stdout);

	while (test.ReadCaseInOneFile()) {
		test.Begin();
		Solution s;
		s.solve(test.Input(), test.Output());
		test.End();
	}
	test.DisplayInfo();
#else   //online judge
#ifdef MULTI_CASE 
	int t; cin >> t;
	while (t--) {
		Solution s;
		s.solve();
	}
#else
	Solution s;
	s.solve();
#endif
#endif



	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	string s[3];
	rep(i,3)cin>>s[i];
	vi co(3);
	int t=0;
	while(1){
		if(co[t]==s[t].size()){
			cout<<(char)('A'+t)<<endl;
			return 0;
		}
		char c=s[t][co[t]];
		co[t]++;
		t=c-'a';
	}
}







Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#define min(x,y) ((x) < (y) ? (x) : (y))
#define max(x,y) ((x) > (y) ? (x) : (y))

typedef struct
{
  char suit;
  char value;
} Card;

void swap(Card *a,Card *b)
{
  Card tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}

void print(Card a[],int n)
{
  int i, value, sort;
  for(i = 1; i <= n; i++)
    {
      printf("%c%c",a[i].suit,a[i].value);
      if(i != n) printf(" ");
    }
  printf("\n");
}

void print_judge(bool a)
{
  if(a) printf("Stable\n");
  else printf("Not stable\n");
}
 
void Selectionsort(Card a[],Card b[],const int n)
{
  int i, j, min_index;
  bool judge = true;
  for(i = 1; i <= n; i++)
    {
      min_index = i;
      for(j = i; j <= n; j++)
	{
	  if(a[j].value < a[min_index].value) min_index = j;
	}
      if(min_index != i)
	{
	  swap(&a[i],&a[min_index]);
	}
    }
  print(a,n);
  for(i = 1; i <= n; i++) if(a[i].suit != b[i].suit) judge = false;
  print_judge(judge);
}

void Bubblesort(Card a[],const int n)
{
  int i , j;
  bool judge = true;
  for(i = 1; i <= n; i++)
    {
      for(j = n; j >= i+1; j--)
	{
	  if(a[j].value < a[j-1].value)
	    {
	      swap(&a[j],&a[j-1]);
	    }
	}
    }
  print(a,n);
  print_judge(judge);
}

int main(){
  Card C1[101], C2[101];
  int n, i;
  char ch;

  scanf("%d%c", &n, &ch);
  for ( i = 1; i <= n; i++ ){
    scanf("%c%c%c", &C1[i].suit, &C1[i].value, &ch);
    C2[i] = C1[i];
  }
  Bubblesort(C1,n);
  Selectionsort(C2,C1,n);
  return 0;
}

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

int main() {
  int N,a,b,c;
  cin >> N;
  a = N % 1000;
  if (N % 1111 == 0){
    cout << "Yes" << endl;
  }else if (N % 1110 < 10){
    cout << "Yes" << endl;
  }else if (a % 111 == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define all(c) begin(c),end(c)
using ll = long long;
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

void solve()
{
	vector<int> H;
	vector<int> W;
	vector<int> J;
	while (true)
	{
		int N, M;
		cin >> N >> M;
		if (N == 0 && M == 0)break;
		H = vector<int>(N + 1);
		W = vector<int>(M + 1);
		J.clear();
		for (int i = 0; i < N; i++)
		{
			cin >> H[i + 1];
			H[i + 1] += H[i];
		}
		for (int i = 0; i < N; i++)
		{
			for (int j = i + 1; j < N + 1; j++)
			{
				J.emplace_back(H[j] - H[i]);
			}
		}
		sort(all(J));

		for (int i = 0; i < M; i++)
		{
			cin >> W[i + 1];
			W[i + 1] += W[i];
		}

		ll ans = 0;
		for (int i = 0; i < M; i++)
		{
			for (int j = 0; j < M + 1; j++)
			{
				ans += upper_bound(all(J), W[j] - W[i]) - lower_bound(all(J), W[j] - W[i]);
			}
		}
		cout << ans << endl;
	}

}

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


Measured memory_bytes: 11216
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n) ;i++)

using namespace std;
using p=pair<int,int>;
typedef long long ll;
const double pi=3.14159265;

int main() {
  ll n;
  cin >> n;
  vector<ll>ans(n);
  rep(i,n-1){
    ll a;
    cin >> a;
    ans[a-1]++;
  }
  rep(i,n){
    cout << ans[i] << endl;
  }
  return 0;
 
}

Measured memory_bytes: 4840