akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <math.h>
#include <list>
#include <algorithm> 
#include <queue>

using namespace std;

#define max 126

struct square{
	int x, y;
	bool flg;	//到達フラグ
	bool sflg;	//障害物フラグ
	int dist;	//距離
};

void push_q( queue<square> *q, int x, int y, int d, int t,  vector< vector< square > > *s ){
	if( ( x < 0 ) || ( x > max ) ) return;
	if( ( y < 0 ) || ( y > max ) ) return;
	if( s -> at(x).at(y).flg == true ) return;
	if( s -> at(x).at(y).sflg == true ) return;
	if( d > t ) return;
	//if( s->at(x).at(y).dist > 0 && s->at(x).at(y).dist < d ) return;

	square sq;
	sq.x = x;
	sq.y = y;
	sq.dist = d;
	sq.flg = true;

	s->at(x).at(y) = sq;

	q -> push( sq );

}

void search_bfs( queue<square> *q, vector< vector< square > > *sq, int t){
	while( q -> empty() == false ) {
		square s;
		s = q -> front();
		q -> pop();

		push_q( q, s.x + 1, s.y, s.dist + 1, t, sq);
		push_q( q, s.x - 1, s.y, s.dist + 1, t, sq);
		push_q( q, s.x + 1, s.y + 1, s.dist + 1, t, sq);
		push_q( q, s.x - 1, s.y - 1, s.dist + 1, t, sq);
		push_q( q, s.x, s.y + 1, s.dist + 1, t, sq);
		push_q( q, s.x, s.y - 1, s.dist + 1, t, sq);
	}
}

int main(void){
  // FILE* fp_in = freopen("data.txt", "r", stdin);

	while(1){
		int t, n;
		cin >> t >> n;
		if( t == 0 && n == 0 ) break;

		vector< vector< square > > sq;
		for(int i = 0; i < max + 1; i++) {
			vector< square > sqr;
			for(int j = 0; j < max + 1; j++) {
				square s;
				s.flg = false;
				s.dist = 0;
				s.sflg = false;
				s.x = i;
				s.y = j;
				sqr.push_back(s);
			}
			sq.push_back( sqr );
		}

		for(int i = 0; i < n; i++) {
			int xpos, ypos;
			cin >> xpos >> ypos;
			xpos += max / 2;
			ypos += max / 2;
			sq[xpos][ypos].sflg = true;
		}

		queue< square > q;
		square squr;
		cin >> squr.x >> squr.y;
		squr.x += max / 2;
		squr.y += max / 2;
		squr.dist = 0;
		squr.flg = true;
		squr.sflg = false;
		sq[squr.x][squr.y] = squr;
		q.push( squr );

		search_bfs( &q, &sq, t );

		int ans = 0;
		for(int i = 0; i < max + 1; i++) {
			for(int j = 0; j < max + 1; j++) {
				if( sq[j][i].flg == true ) ans ++;
			}
		}

		cout << ans << endl;

	}

	//while(1){}
    return 0;
}

Measured memory_bytes: 1352
n = int(input())
x = list(map(int, input().split()))
y = x[:]
x.sort()
b1 = x[int(n/2) - 1]
b2 = x[int(n/2)]
for i in range(n):
    if y[i] <= b1:
        print(b2)
    else:
        print(b1)

Measured memory_bytes: 25620
N=int(input())
P=list(range(100))
for y in range(100):
 P[y]=0
for i in range(N):
 if i+1<=9:
  c=(i+1)*11
  P[c]+=1
 else:
  z=str(i+1)
  d=len(z)
  e=int((i+1)/(10**(d-1)))
  f=(i+1)%10
  g=10*e+f
  P[g]+=1
k=0
for i in range(9):
 for j in range(9):
  s=(i+1)*10+(j+1)
  t=(j+1)*10+(i+1)
  z=P[s]*P[t]
  k+=z
print(k)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    string op;
    int a,b;
    cin >> a >> op >> b;
    while (1<2){
    if (op == "?") break;
    else if (op == "+") cout << a+b << endl;
    else if (op == "-") cout << a-b << endl;
    else if (op == "*") cout << a*b << endl;
    else if (op == "/") cout << a/b << endl;
    cin >> a >> op >> b;
    }
    return 0;
    
}



Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <cstdlib>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
#define SORTR(v) sort((v).begin(),(v).end(),greater<int>())
const ll INF = (1LL << 40);
typedef pair<int, int> P;
const int MOD = 1000000007;

int main() {

	int n;
	cin >> n;

	vector<int>a(n);

	REP(i, n) cin >> a[i];

	//map<int, int>mp;
	vector<int>freq(n+1,0);

	REP(i, n) {
		//mp[a[i]]++;
		freq[a[i]]++;
	}

	//vector<int>ans(n);

	ll sum = 0;
	for (int i = 0; i < n + 1;i++) {
		if (freq[i] >= 2) {
			ll d = freq[i];
			sum += d * (d - 1) / 2;
		}
	}

	for (int i = 0; i < n; i++) {
		ll e = freq[a[i]];
		if (e >= 3) {
			cout << sum - e + 1 << endl;
		}
		else {
			cout << sum - (e - 1)*e / 2 << endl;
		}
	}

	return 0;

}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int n,y;

int main(){
    cin >> n >> y;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n-i;j++){
            int k = n-(i+j);
            if(i+j+k <= n && i*10000+j*5000+k*1000 == y){
                cout << i << ' ' << j << ' ' << k << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;

}


Measured memory_bytes: 768
// https://atcoder.jp/contests/abc166/tasks/abc166_e
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> v(N);
    unordered_map<int, int> mp;
    REP(i, N) {
        cin >> v[i];
        mp[i - v[i]]++;
    }
    int ans = 0;
    REP(i, N) { ans += mp[i + v[i]]; }
    cout << ans << endl;
    return 0;
}


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

struct Ps{
  int r,c;
  Ps():r(0),c(0){}
  Ps(int r,int c):r(r),c(c){}
  Ps operator+(const Ps&p)const
  { return Ps(r+p.r,c+p.c);  }
  friend istream& operator>>(istream&is,Ps&p)
  {is >> p.r >> p.c; return is;  }
};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int h,w; cin >> h >> w;
  Ps s,g; cin >> s >> g;
  s = s+Ps(-1,-1);
  g = g+Ps(-1,-1);
  bitset<1000> mz[1000];
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j)
      mz[i][j] = []{char c; cin >> c; return c=='.';}();
  optional<int> distance[1000][1000];
  deque<pair<Ps,int>> dq;
  dq.emplace_front(move(s),0);
  while(!dq.empty()){
    auto [ps,di] = move(dq.front());
    dq.pop_front();
    if(distance[ps.r][ps.c])continue;
    distance[ps.r][ps.c] = di;
    mz[ps.r][ps.c] = 0;
    if(ps.r==g.r && ps.c==g.c)break;
    for(int i = -2; i <= 2; ++i){
      for(int j = -2; j <= 2; ++j){
	Ps nps(ps.r+i,ps.c+j);
	if(nps.r < 0 || nps.c < 0 || nps.r >= h || nps.c >= w)continue;
	if(!mz[nps.r][nps.c])continue;
	if(abs(i)+abs(j) > 1){
	  dq.emplace_back(move(nps),di+1);
	} else {
	  mz[nps.r][nps.c] = 0;
	  dq.emplace_front(move(nps),di);
	}
      }
    }
  }
  cout << (distance[g.r][g.c] ? distance[g.r][g.c].value() : -1) << endl;
}


Measured memory_bytes: 11792
N,X=map(int,input().split())
if X==1 or X==2*N-1:
  print('No')
  exit()
print('Yes')
if N==2:
  print('1\n2\n3')
  exit()
P=[0]*(2*N-1)
P[N-1]=X
P[N-2]=X-1
P[N]=X+1
P[N+1]=1
if X==2:
  P[N-2]=X+1
  P[N]=1
  P[N+1]=X+2
S=set(P)
Z=2
for i in range(2*N-1):
  if P[i]:
    continue
  while Z in S:
    Z+=1
  P[i]=Z
  S.add(Z)
  Z+=1
print(*P,sep='\n')

Measured memory_bytes: 63856
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10005;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int H, N, a, b;
    cin >> H >> N;
    vector<pii> v(N);
    for (int i = 0; i < N; i++) {
        cin >> a >> b;
        v[i] = pii(a, b);
    }
    vector<int> dp(MAX, INF);
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 1; j < MAX; j++) {
            dp[j] = min(dp[j], dp[max(0, j - v[i].first)] + v[i].second);
        }
    }
    cout << dp[H] << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int H, W, i, j;
	while (1) {
		scanf("%d %d", &H, &W);
		if ((H == 0) && (W == 0)) {
			break;
		}
		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 2048
#include <stdio.h>

int main(void){
  int x[4], y[4];
  scanf("%d", x);
  scanf("%d", y);
  scanf("%d", x+1);
  scanf("%d", y+1);

  int dx = x[1] - x[0];
  int dy = y[1] - y[0];
  int Dx = -dy;
  int Dy = dx;
  
  x[2] = x[1] + Dx;
  y[2] = y[1] + Dy;

  x[3] = x[2] - dx;
  y[3] = y[2] - dy;
  
  printf("%d %d %d %d\n", x[2], y[2], x[3], y[3]);
  
  return 0;
}


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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))

int main(){
    FAST
    long double n; cin >> n;
    long double odds = (n + 1)/2;
    odds = floor(odds);
    cout << setprecision(10) <<(odds)/n;
    return 0;
}


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

int main(){
    vector<int> D(3);
    cin >> D[0];
    cin >> D[1];
    cin >> D[2];

    sort(D.begin(), D.end(), greater<int>());
    string max_s = to_string(D[0]) + to_string(D[1]);
    cout << stoi(max_s) + D[2] << endl;
}

Measured memory_bytes: 256
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]
dp = [[0, 0, 0] for _ in range(2 * n)]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + abc[i][k])

print(max(dp[n]))


Measured memory_bytes: 84952
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define ll int128_t
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define smax(a,b) a=max(a,b)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

// int const mod = 7340033;
int const mod = 998244353;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}

int inverse(int x){
    return power(x,mod-2,mod);
}

int const N = 5e5+5;
int const inf = 2e16;

void solve(){  
    int i,j;
    int n; cin>>n;
    int cnt[n+1]={0};
    for(i=2;i<=n;i++){
        int x; cin>>x;
        cnt[x]++;
    }
    for(i=1;i<=n;i++){
        cout<<cnt[i]<<endl;
    }
}             


int32_t main(){
    IOS;
    int t;
    t = 1;
    // precompute();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}


/*

*/

Measured memory_bytes: 5220
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
using namespace std;

int main(){
    int n,w2=0;
    cin >> n;
    vector<long long> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(a[i]%2==0) w2=1;
    }
    long long ans=0;
    if(w2!=0){
        for(int i=0; i<n; i++){
            if(a[i]!=1){
                int x=log2(a[i]);
                for(int j=0; j<=x; j++){
                    if(a[i]%2==0) a[i]/=2;
                    else{
                        ans+=j;
                        break;
                    }
                }
            }
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        String S  = sc.next();
        char[]ss = S.toCharArray();

        int cou = 0;
        for(int i=0; i<S.length(); i++){
            if(i%2==0){
                if(ss[i] =='L'){
                cou++;
}
            }else{
                if(ss[i] =='R'){
                cou++;
            }
}
}
        if(cou==0){
            System.out.print("Yes");
         }else{
            System.out.print("No");
        }
    }
}


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

#define FOR(i,l,r) for(int i = (int) l;i < (int) r;i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N,M;
int edge [101] [101];
const int INF = 1e9;

int main()
{
	scanf("%d%d",&N,&M);
	fill(edge [1],edge [N + 1],INF);
	vector<int> A(M),B(M),C(M);
	FOR(i,0,M){
		scanf("%d%d%d",&A [i],&B [i],&C [i]);
		edge [A [i]] [B [i]] = edge [B [i]] [A [i]] = C [i];
	}

	FOR(k,1,N + 1) FOR(i,1,N + 1) FOR(j,1,N + 1){
		chmin(edge [i] [j],edge [i] [k] + edge [k] [j]);
		edge [j] [i] = edge [i] [j];
	}

	int ans = 0;
	FOR(i,0,M){
		ans += edge [A [i]] [B [i]] != C [i];
	}

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
        
        if(S.equals("ABC")){
       	 System.out.println("ARC");
        }else{
         System.out.println("ABC");
        }
    }
}


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

int main() {
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; ++i) cin >> A[i];
    int min=A[1];
    int max=A[1];

    for(int i=0; i<N; ++i){
    if ( A[i] < min ) min =A[i];
    if ( max < A[i] ) max =A[i];
}
int ans = max-min;
    cout << ans << endl;
}

Measured memory_bytes: 504
Option Strict On

Module Module1

    Sub Main()
        'let'
        Dim N As Long = CLng(Console.ReadLine())

        'var'
        Dim ans As String

        If N < CLng(10 ^ 3) Then
            ans = "ABC"
        Else
            ans = "ABD"
        End If

        Console.WriteLine(ans)

    End Sub
End Module

Measured memory_bytes: 13268
#include<iostream>
#include<stdio.h>
#include<string.h>
#define N 220000
using namespace std;
long long h[N],v[N],w[N],Next[N],p[N],tot;
long long n,m,c[N],ans,bns,f[4],oo;
void add(int x,int y,int z){
	tot++;
	Next[tot]=h[x];
	v[tot]=y;
	w[tot]=z;
	h[x]=tot;
}
int dfs(int x){
	f[c[x]]++;
	for(int i=h[x];i;i=Next[i]){
		bns+=w[i]==1;
		if(c[v[i]]==-1){
			c[v[i]]=(c[x]+w[i])%3;
			dfs(v[i]);
		}
		if(c[v[i]]!=(c[x]+w[i])%3)oo=1;
	}
}
int main(){
	memset(c,-1,sizeof(c));
	scanf("%d%d",&n,&m);
	tot=1;
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y,1);
		add(y,x,2);
	}
	for(int i=1;i<=n;i++){
		if(c[i]!=-1)continue;
		f[0]=f[1]=f[2]=c[i]=bns=oo=0;
		dfs(i);
		if(oo)ans+=(f[0]+f[1]+f[2])*(f[0]+f[1]+f[2]);
		else if(f[1]*f[2]==0)ans+=bns;
		else ans+=f[0]*f[1]+f[1]*f[2]+f[2]*f[0];
	}
	printf("%lld\n",ans);
}


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

#define P 1000000007
#define N 200005

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

long int modinv(long int a){
  return modpow(a,P-2);
}

long int fact[N],inv[N],finv[N];

void pre(){
  fact[0]=fact[1]=1;
  inv[1]=1;
  finv[0]=finv[1]=1;
  for(int i=2;i<N;i++){
    fact[i]=(fact[i-1]*i)%P;
    inv[i]=P-(inv[P%i]*(P/i))%P;
    finv[i]=finv[i-1]*inv[i]%P;
  }
}

long int comb(long int n,long int k){
  return fact[n]*(finv[n-k]*finv[k]%P)%P;
}

int main(){
  pre();
  int H,W,A,B;
  cin>>H>>W>>A>>B;
  
  long int sum=0;
  
  for(int i=0;i<min(H-A,W-B);i++){
    sum=(sum+comb(H-A-1+B,B+i)*comb(A+W-B-1,A+i)%P)%P;
  }
  
  cout<<sum<<endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int MOD = 1000000007;
#define int long long
signed main() {
	int n,m;
	cin >> n >> m;
	vector<int> x(n);
	vector<int> y(m);
	
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> y[i];
	}
	int sx = 0;
	int sy = 0;
	for (int i = 0; i < n - 1; i++) {
		sx = (sx + ((((n - 1 - i)*(i + 1)) % MOD)*((x[i + 1] - x[i]) % MOD))) % MOD;
	}
	for (int i = 0; i < m - 1; i++) {
		sy = (sy + ((((m - 1 - i)*(i + 1)) % MOD)*((y[i + 1] - y[i]) % MOD))) % MOD;
	}

	cout << ((sx*sy)%MOD) << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

using namespace std;

int main() {

	long n, a[51], b[51], c[51], sum = 0, k,m[51];

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i == 0)continue;
		m[i] = a[i] - a[i - 1];

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

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

	for (int i = 0; i < n; i++) {
		k = a[i] - 1;
		sum = sum + b[k];
		if (m[i]==1)sum = sum + c[k-1];

	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <list>

using namespace std;
#define MAX 1000

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,q,command,t,x,s;
    list<int>myList[MAX];
    cin >> n >> q;
    
    for (int i = 0;i < q;++i) {
        cin >> command;
        switch(command){
                // insert
            case 0:
                cin >> t >> x;
                myList[t].insert(myList[t].end(), x);
                break;
                // get max
            case 1:
                cin >> t;
                if(!myList[t].empty()){
                    for(auto it = myList[t].begin();it != myList[t].end();++it){
                        cout << *it;
                        
                        if(++it != myList[t].end()){
                            cout << " ";
                        }
                        it--;
                    }
                }
                cout << endl;                
                break;
                // splice
            case 2:
                cin >> s >> t;
                if(!myList[s].empty()){
                    myList[t].splice(myList[t].end(), myList[s]);
                }
                break;
        }
    }
}



Measured memory_bytes: 18800
using System;
using System.Collections.Generic;

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            //問題168
            string[] line = Console.ReadLine().Split(' ');

            double A = double.Parse(line[0]);
            double B = double.Parse(line[1]);
            double H = double.Parse(line[2]);
            double M = double.Parse(line[3]);


            double Arad = System.Math.PI * (0.5f - 2.0f * (H + M / 60.0f) / 12.0f);
            double Brad = System.Math.PI * (0.5f - 2.0f * (M / 60.0f));

            //Console.WriteLine(Arad);
            //Console.WriteLine(Brad);

            //Console.WriteLine(System.Math.Sin(Arad));
            //Console.WriteLine(A*System.Math.Sin(Arad));

            //Console.WriteLine(B * System.Math.Sin(Brad));



            double xvec = A * System.Math.Cos(Arad) - B * System.Math.Cos(Brad);
            double yvec = A * System.Math.Sin(Arad) - B * System.Math.Sin(Brad);

            //Console.WriteLine(yvec);
            //Console.WriteLine(yvec);



            xvec = Math.Pow(xvec, 2.0f);
            yvec = Math.Pow(yvec, 2.0f);

            //Console.WriteLine(xvec);
            //Console.WriteLine(yvec);

            double ans = Math.Pow(xvec + yvec, 0.5f);

            Console.WriteLine(ans);
        }


    }
}


Measured memory_bytes: 28064
n = int(input())
x = [0]*n
for i in range(n):
    x[i] = list(map(int,input().split()))
x.sort(key= lambda val : val[0])
i = 0
while 1:
    if i >= len(x)-1:
        break
    
    if x[i][0] + x[i][1] > x[i+1][0] - x[i+1][1]:
        if x[i][0] + x[i][1] > x[i+1][0] + x[i+1][1]:
            del x[i]
        else:
            del x[i+1]
    else:
        i += 1
print(len(x))

Measured memory_bytes: 29560
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
  long int H;
  int N;
  long int sum;
  cin >> H;
  for(int i=0;i<50;i++){
    if((long double)(H) < pow(2.0,i)) {
      N = i;
      break;
    }
  }
  for(int j=0;j<N;j++){
    sum = sum + (long int)(pow(2.0,j));
  }
  cout << sum << endl;
  return 0;
}


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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

int h[maxn], dp[maxn];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &h[i]);

    dp[1] = 0;
    dp[2] = abs(h[1] - h[2]);
    for (int i = 3; i <= n; i++) {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    printf("%d\n", dp[n]);
	return 0;
}


Measured memory_bytes: 4736
import itertools

N = int(input())
F = [list(map(int,input().split())) for _ in range(N)]
P = [list(map(int,input().split())) for _ in range(N)]
ans = -float('inf')
r = (0,0,0,0,0,0,0,0,0,0)
for w in itertools.product(range(2), repeat=10):
    if w == r:
        continue
    result = 0
    for i in range(N):
        f = F[i]
        count = 0
        for j in range(10):
            if f[j] == 1 and w[j] == 1:
                count += 1
        result += P[i][count]
    ans = max(ans, result)
print(ans)


Measured memory_bytes: 3064
import math
import random
from scipy.misc import comb
class Prime:
    seed_primes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
    def is_prime(self,n):
        is_prime_common=self.is_prime_common(n)
        if is_prime_common is not None:return is_prime_common
        if n<2000000:return self.is_prime_brute_force(n)
        return self.is_prime_miller_rabin(n)
    def is_prime_common(self,n):
        if n==1:return False
        if n in Prime.seed_primes:return True
        if any(map(lambda x:n%x==0,self.seed_primes)):return False
    def is_prime_brute_force(self,n):
        for k in range(2,int(math.sqrt(n))+1):
            if n%k==0:return False
        return True
    def is_prime_miller_rabin(self,n):
        d=n-1
        while d&1==0:d>>=1
        witnesses=self.get_witnesses(n)
        for w in witnesses:
            y=pow(w,d,n)
            while d!=n-1and y!=1and y!=n-1:
                y=y*y%n
                d<<=1
            if y!=n-1and d&1==0:return False
        return True
    def get_witnesses(self,num):
        def _get_range(num):
            if num<2047:return 1
            if num<1373653:return 2
            if num<25326001:return 3
            if num<3215031751:return 4
            if num<2152302898747:return 5
            if num<3474749660383:return 6
            if num<341550071728321:return 7
            if num<3825123056546413051:return 9
            return 12
        return self.seed_primes[:_get_range(num)]
    def gcd(self,a,b):
        if a<b:return self.gcd(b,a)
        if b==0:return a
        while b:a,b=b,a%b
        return a
    @staticmethod
    def f(x,n,seed):
        p=Prime.seed_primes[seed%len(Prime.seed_primes)]
        return(p*x+seed)%n
    def find_factor(self,n,seed=1):
        if self.is_prime(n):return n
        x,y,d=2,2,1
        count=0
        while d==1:
            count+=1
            x=self.f(x,n,seed)
            y=self.f(self.f(y,n,seed),n,seed)
            d=self.gcd(abs(x-y),n)
        if d==n:
            return self.find_factor(n,seed+1)
        return self.find_factor(d)
    def find_factors(self,n):
        primes={}
        if self.is_prime(n):
            primes[n]=1
            return primes
        while n>1:
            factor=self.find_factor(n)
            primes.setdefault(factor,0)
            primes[factor]+=1
            n//=factor
        return primes
n,m=map(int,input().split())
a=1
for c in Prime().find_factors(m).values():
    a=a*comb(n+c-1,c,exact=1)%(10**9+7)
print(a)

Measured memory_bytes: 13952
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int mod=1000000007,MX=200000;

int H,W,A,B,fac[MX+5],ifac[MX+5],ans;

inline int C(int n,int m){return (LL)fac[n]*ifac[m]%mod*ifac[n-m]%mod;}
inline int Pow(int a,int b)
{
    int ans=1;
    for(;b;b>>=1,a=(LL)a*a%mod)
        if(b&1)ans=(LL)ans*a%mod;
    return ans;
}

int main()
{
    cin>>H>>W>>A>>B;
    fac[0]=1;
    for(int i=1;i<=MX;i++)fac[i]=(LL)fac[i-1]*i%mod;
    ifac[MX]=Pow(fac[MX],mod-2);
    for(int i=MX;i;i--)ifac[i-1]=(LL)ifac[i]*i%mod;
    if(H==A+1)
    {
        cout<<C(H-2+W-B,H-1)<<endl;
        return 0;
    }
    for(int i=1;i<=B;i++)
        ans=(ans+(LL)C(H-A+i-3,i-1)*C(A+W-B-1,A))%mod;
    for(int i=B+1;i<=W;i++)
        ans=(ans+(LL)C(H-A+i-3,i-1)*C(A+W-i,A))%mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>

int main(){
  double target;
  while(scanf("%lf",&target)>0){
    double y = 4.9*target*target/(9.8*9.8);
    for(int n=1;;n++){
      if(5*n-5 >= y){
	printf("%d\n",n);
	break;
      }
    }
  }
}

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

int main()
{
  int n;
  cin >> n;
  set <string> se;
  int cond = 1;
  char c;
  for(int i = 0; i < n; i++){
      string s;
     cin >> s;
     if(i){
        if(s[0] != c) cond = 0;
        if(se.count(s)) cond = 0;
     }
     c = s[s.size()-1];
     se.insert(s);      
  }
  if(cond) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {

int a, b, c, i, s ;

s=0 ;

scanf("%d %d %d", &a, &b, &c) ;

for(i= a ; i<= b ; i ++) {

if(c%i == 0) {

s=s+1 ;

}

}

printf("%d\n" ,s);

return 0;

}

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

namespace HABIT{
    #define f(a,b,c,d) for(register int a=b,c=d;a<=c;a++)
    #define g(a,b,c,d) for(register int a=b,c=d;a>=c;a--)
    #define LOCAL
    typedef int i32;
    typedef unsigned int u32;
    typedef long long int i64;
    typedef unsigned long long int u64;
    typedef pair<i32,i32> pii;
    const i32 MAXN=2e5+10;
    typedef i64 ar[MAXN];
    typedef vector<i64> vi;
    
    template<typename T> inline T Max(T a) { return a; }
    template<typename T,typename... Args> inline T Max(T a,Args... args){
        T b=Max(args...);
        return (a>b)?a:b;
    }
    template<typename T> inline T Min(T a) { return a; }
    template<typename T,typename... Args> inline T Min(T a,Args... args){
        T b=Min(args...);
        return (a<b)?a:b;
    }

    #ifdef LOCAL
        inline char gc() { return getchar(); }
    #else
        inline char gc() {
            static char s[1<<20|1]={0},*p1=s,*p2=s;
            return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
        }
    #endif
    inline i64 read(){
        register i64 ans=0;register char c=gc();register bool neg=0;
        while(c<48||c>57) neg^=!(c^'-'),c=gc();
        while(c>=48&&c<=57) ans=(ans<<3)+(ans<<1)+(c^48),c=gc();
        return neg?-ans:ans;
    }

    char Output_Ans[1<<20|1],*Output_Cur=Output_Ans;
    inline void output() { Output_Cur-=fwrite(Output_Ans,1,Output_Cur-Output_Ans,stdout); }
    inline void print(char c){
        if(Output_Cur-Output_Ans+1>>20) output();
        *(Output_Cur++)=c;
    }
    inline void print(char *s) { while(*s) print( *(s++) ); }
    inline void print(u64 x){
        if(!x) { print('0'); return ; }
        char buf[30]={0},*p=buf+28;
        while(x) *(p--)=x%10+48,x/=10;
        print(p+1);
    }
    inline void print(u32 x) { print( (u64)x ); }
    inline void print(i64 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
    inline void print(i32 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
}
using namespace HABIT;

i32 N;
ar A,Ans;
vi Edg[MAXN],Mq;

inline void pre(){
    N=read();
    f(i,1,I,N) A[i]=read();
    f(i,1,I,N-1){
        i32 U=read(),V=read();
        Edg[U].push_back(V);
        Edg[V].push_back(U);
    }
    Mq.push_back(0);
}

void dfs(i32 Now,i32 Pa){
    i32 Pos,Tmp;
    bool Isend=0;
    if(A[Now]>*(Mq.end()-1)){
        Isend=1;
        Ans[Now]=Mq.size();
        Mq.push_back(A[Now]);
    }
    else{
        Pos=lower_bound(Mq.begin(),Mq.end(),A[Now])-Mq.begin();
        Tmp=Mq[Pos];
        Ans[Now]=Mq.size()-1;
        Mq[Pos]=A[Now];
    }

    f(i,0,I,Edg[Now].size()-1)
        if(Edg[Now][i]!=Pa)
            dfs(Edg[Now][i],Now);
    
    if(Isend) Mq.pop_back();
    else Mq[Pos]=Tmp;
}

int main(){
    pre();
    dfs(1,0);
    f(i,1,I,N)
        print(Ans[i]),print('\n');
    output();
    return 0;
}

Measured memory_bytes: 32776
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] p = new int[n];

		for (int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
		}

		int count = 0;

		for (int i = 0; i < n - 2; i++) {
			if (Math.max(Math.max(p[i], p[i + 1]), p[i + 2]) != p[i + 1]) {
				if (Math.min(Math.min(p[i], p[i + 1]), p[i + 2]) != p[i + 1]) {
					count++;
				}
			}
		}

		System.out.println(count);
	}
}

Measured memory_bytes: 22864
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        int E = sc.nextInt();
        int F = sc.nextInt();
        int capacity = 100*F;
        
        int ans1 = A*100;
        int ans2 = 0;
        //100,200,...,3000
        for(int w=1;w<=F;w++){
        	//if you cannot pour (100*w)grams, skip this loop
        	boolean waterOk = false;
        	for(int i=0;i<=w/A;i++){
        	    if((w-A*i)%B==0){
        	        waterOk = true;
        	        break;
        	    }
        	}
        	if(!waterOk)continue;
        	
        	int bestSugar = Math.min(w*E, F-w*100);
        	if(bestSugar<0) continue;
        	for(int s=bestSugar;s>0;s--){
        	    for(int i=0;i<=s/C;i++){
        	        if((s-C*i)%D==0){//you can make (w+s,s) aq.
        	        	if(1.0*ans2/ans1 <= 1.0*s/(w*100+s)){
        	        	    ans1 = w*100+s;
        	        	    ans2 = s;
        	        	    continue;
        	        	}
        	        }
        	    }
        	}
        }
        System.out.println(ans1 + " " + ans2);
    }
}

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

int main(){
  const int MAX_N = 10000;
  int n;
  long int num;
  long int max, min, sum;
  cin >> n;
  cin >> num;
  max = num;
  min = num;
  sum = num;
  for(int i=0; i<n-1; i++){
    cin >> num;
    if(max < num){
      max = num;
    }
    if(num < min){
      min = num;
    }
    sum += num;
  }
  cout << min << " " << max << " " << sum<< endl;
  return 0;
}


Measured memory_bytes: 3108
#include<cstdio>
int main()
{
	int a,b,c,d;
	while(scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF)
	{
		int ant1=a*b;
		int ant2=c*d;
		if(ant1>=ant2)
		printf("%d\n",ant1);
		else
		printf("%d\n",ant2);
	}
return 0;
} 

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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template <typename Head> void dump(Head &&head) {
  cerr << head;
  dump();
}
template <typename Head, typename... Tail>
void dump(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  dump(forward<Tail>(tail)...);
}
#define debug(...)                                                             \
  do {                                                                         \
    cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = ";                        \
    dump(__VA_ARGS__);                                                         \
  } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template <typename T> struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL << 60;

const string pa = "pairwise coprime";
const string st = "setwise coprime";
const string no = "not coprime";

vector<ll> divisor(ll n)
{
  vector<ll> res;
  for (ll i=1; i*i<=n; i++) {
    if (n%i == 0) {
      res.push_back(i);
      if (i != n/i) res.push_back(n/i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}

int main() {

  ll n; cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  vector<ll> l(n);
  l[0] = a[0];
  vector<ll> r(n);
  r[n-1] = a[n-1];
  for (int i=1; i<n; i++) {
    l[i] = gcd(l[i-1], a[i]);
    r[n-i-1] = gcd(r[n-i], a[n-i-1]);
  }
  if (l[n-1] > 1) {
    cout << no << endl;
    return 0;
  }

  vector<ll> mp(1000001);
  for (int i=0; i<n; i++) {
    vector<ll> div = divisor(a[i]);
    for (auto v:div) {
      if (v == 1) continue;
      mp[v]++;
      if (mp[v] >= 2) {
        cout << st << endl;
        return 0;
      }
    }
  }
  cout << pa << endl;

  return 0;
}


Measured memory_bytes: 34668
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    long n, k;
    cin >> n >> k;
    int a[n], last[200001], next[n];
    fill(last, last+200001, -1);
    fill(next, next+n, 2000000);
    for (auto &ai:a) cin >> ai;
    for (int i=0; i<2*n; i++) {
        int ai = a[i % n];
        if (0 <= last[ai] && last[ai] < n && next[last[ai]] > i) next[last[ai]] = i + 1;
        last[ai] = i;
    }
    int cur = 0;
    long cnt = 0;
    vector<long> starts;
    while (true) {
        starts.push_back(cnt);
        cnt += next[cur] - cur;
        cur = next[cur] % n;
        if (cur == 0) break;
    }
    auto st = prev(upper_bound(starts.begin(), starts.end(), (n * k) % cnt));
    for (int i=(*st % n); i<n; ) {
        if (next[i] <= n) {
            i = next[i];
            continue;
        }
        cout << a[i] << ' ';
        i++;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5488
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define DEBUG if(0)
#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#endif

#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r){bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r){bool a=l<r;if(a)l=r;return a;}
template <typename T>istream& operator>>(istream &is,vector<T> &v){for(auto &it:v)is>>it;return is;}

constexpr char ln = '\n';
constexpr int mod = 1e9+7;
const string ok = "Yes";
const string ng = "No";
vector<LL> solve(vector<int>& a,vector<int>& b,vector<LL> dp){
    int id=0;
    int n=b.size();
    int m=dp.size();
    vector<LL> cnt(m+1);
    vector<LL> ret(n);

    FOR(i,0,m){
        cnt[i+1]=cnt[i]+dp[i];
    }
    REP(i,n){
        while(a[id]<b[i])id++;
        ret[i]=cnt[id];
    }
    return ret;
}

int main(){
    int N;
    cin>>N;
    vector<int> A(N),B(N),C(N);
    cin>>A>>B>>C;
    A.pb(1e9+7);
    B.pb(1e9+7);
    sort(ALL(A));
    sort(ALL(B));
    sort(ALL(C));

    vector<LL> dp(N+1,1);
    dp=solve(A,B,dp);
    dp=solve(B,C,dp);
    FOR(i,1,N)dp[i]+=dp[i-1];
    cout<<dp.back()<<endl;
    return 0;
}


Measured memory_bytes: 4592
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
ll A, B;

// gcd lcm
ll calc_gcd(ll a, ll b) {
    if (b == 0) return a;
    return calc_gcd(b, a % b);
}

ll calc_lcm(ll a, ll b) {
    ll g = calc_gcd(a, b);
    return a / g * b;
}

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

  cin >> A >> B;
  cout << calc_lcm(A, B) << "\n";
  return 0;
}

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

typedef long long ll;

char N[20];
int lsm, mx;

int main() {
	scanf("%s", N);

	int len = strlen(N);

	for (int i = 0; i < len; ++i) {
		if (N[i] != '0') mx = max(mx, lsm + N[i] - '0' - 1 + 9 * (len - i - 1));
		lsm += N[i] - '0';
	}

	mx = max(mx, lsm);

	printf("%d\n", mx);
}

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

using namespace std;

int const HMAX = 200 + 11;
int const DMAX = 10;
int const INF  = 1e9;

int c[DMAX][DMAX], a[HMAX][HMAX], dist[DMAX][DMAX];

void floyd_warshall(void)
{
    for (int i = 0; i < DMAX; i++)
    {
        for (int j = 0; j < DMAX; j++)
        {
            if (i == j)
                dist[i][j] = 0;
            else if (c[i][j])
                dist[i][j] = c[i][j];
            else
                dist[i][j] = INF;
        }
    }
    for (int k = 0; k < DMAX; k++)
    {
        for (int i = 0; i < DMAX; i++)
        {
            for (int j = 0; j < DMAX; j++)
            {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
}

int main(void)
{
    int h, w, ai;

    cin >> h >> w;
    for (int i = 0; i < 10; ++i)
        for (int j = 0; j < 10; ++j)
            cin >> c[i][j];

    floyd_warshall();
    int ans = 0;
    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            cin >> ai;
            if (ai == -1 or ai == 1)
                continue;
            ans += dist[ai][1];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3540
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (ll)1e9+7
#define LLINF (ll)1e30
// #define int ll
using namespace std;
const int MOD = 1e9 +7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int sum=0;
    cin>>s;
    rep(i,s.size()){
        if(s[i]=='o') sum++;
    }
    if(sum+(15-s.size())>=8){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
N,M = map(int,input().split())

par = [-1]*(N+1)


def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    else:
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True


def same(x,y):
    return find(x) == find(y)


def size(x):
    return -par[find(x)]

A = [0]*M
B = [0]*M
for i in range(M):
    A[i], B[i] = map(int,input().split())


ans = [0]*M
ans[-1] = N*(N-1)//2
for j in range(M-1,0,-1):
    if same(A[j],B[j]):
        ans[j-1] = ans[j]

    else:
        sa = size(A[j])
        sb = size(B[j])
        ans[j-1] = ans[j] - sa*sb
    unite(A[j], B[j])

for i in range(M):
    print(ans[i])

Measured memory_bytes: 16892
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>

using namespace std;



int main() {
	int *a=new int[5];
	int k;
	for (int i = 0; i < 5;i++)cin >> a[i];
	cin >> k;
	bool flag = true;
	for (int i = 0; i < 4&flag==true;i++) {
		for (int j = i + 1; j < 5&flag==true; j++) {
			if (abs(a[i] - a[j]) > k) {
				flag = false;
				break;
			}
		}
	}
  	if (flag) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define ll long long int
    #define fi first
    #define se second
    #define pb push_back
    #define pii pair < int , int >
    #define mp make_pair
    #define vec vector < ll >
    #define vecp vector < pii  >
    #define forl(i,q1,n,q2) for(ll i=q1;i<q2;i++)
    #define null NULL
    #define mm 100005
    #define inf 9999999999



     int main()
     {
         ll t;
         t=1;
         while(t--){


        ll n;
         cin>>n;
         ll a[n];
         ll ans[n];
         ll l=9999999;
         memset(ans,l,sizeof(ans));
         ans[0]=0;
         forl(i,0,n,n)cin>>a[i];
           // cout<<ans[1];
         forl(i,0,n,n)
         {

             ans[i+1]=min(ans[i+1],(ans[i]+abs(a[i]-a[i+1])));
             ans[i+2]=min(ans[i+2],(ans[i]+abs(a[i]-a[i+2])));
             //cout<<ans[i+1]<< " "<<ans[i+2]<<endl;
         }
         cout<<ans[n-1]<<endl;
      }

}



Measured memory_bytes: 1792
import itertools

class UnionFind:
    def __init__(self, size):
        self.parent = [-1] * (size + 1)  # 非負なら親ノード，負ならグループの要素数

    def root(self, x):  # root(x): xの根ノードを返す．
        if self.parent[x] < 0:
            return x
        elif self.parent[self.parent[x]] < 0:
            return self.parent[x]
        else:
            self.parent[x] = self.root(self.parent[x])  # xをxの根に直接つなぐ
            return self.parent[x]

    def merge(self, x, y):  # merge(x,y): xのいるグループと$y$のいるグループをまとめる
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.parent[x] > self.parent[y]:  # xの要素数がyの要素数より「小さい」とき入れ替える
            x, y = y, x
        self.parent[x] += self.parent[y]  # xの要素数を更新
        self.parent[y] = x  # yをxにつなぐ
        return True

    def issame(self, x, y):  # same(x,y): xとyが同じグループにあるならTrue
        return self.root(x) == self.root(y)

    def size(self, x):  # size(x): xのいるグループの要素数を返す
        return -self.parent[self.root(x)]

import collections
N,K,L = list(map(int,input().split(" ")))
tree1 = UnionFind(N)
tree2 = UnionFind(N)
anss = collections.defaultdict(lambda :0)
querys = []
for _ in range(K):
    p,q = map(int,input().split(" "))
    tree1.merge(p,q)
for _ in range(L):
    r, s = map(int, input().split(" "))
    tree2.merge(r, s)

for i in range(1,N + 1):
    anss[(tree1.root(i),tree2.root(i))] += 1
temp = [0] * (N + 1)
for i in range(1,N + 1):
    temp[i] =  anss[(tree1.root(i),tree2.root(i))]
print(*temp[1:])



Measured memory_bytes: 106968
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
	static long mod = (long)(1e9+7);
	public static void main(String[] args) { //Ball out 
		/*
		 * */
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		long[] dp = new long[N+1];
		for (int i = 1; i <= N; i++) {
			dp[i]=i;
		}
		for (int i = 1; i <= N; i++) {
			int nine = 9;
			while (nine<=i) {
				dp[i]=min(dp[i],dp[i-nine]+1);
				nine*=9;
			}
			int six = 6;
			while (six<=i) {
				dp[i]=min(dp[i],dp[i-six]+1);
				six*=6;
			}
		}
		O.pln(dp[N]);
	}
	public static double max(double a, double b) {return Math.max(a, b);}
	public static double min(double a, double b) {return Math.min(a, b);}
	public static long min(long a, long b) {return Math.min(a,b);}
	public static long max(long a, long b) {return Math.max(a,b);}
	public static int min(int a, int b) {return Math.min(a,b);}
	public static int max(int a, int b) {return Math.max(a,b);}
	public static long abs(long x) {return Math.abs(x);}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return max(a,b);
		return GCD(min(a,b),max(a,b)%min(a,b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}

Measured memory_bytes: 26520