akhauriyash/Code-Regression huggingface dataset:
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <complex>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;

int N;
vector<int> t[100002];
int ansK;
map<int,int> ans[100002];

void solve(int pos, int pre, int col) {
  int nextCol = 1;
  for (int i = 0; i < t[pos].size(); i++) {
    int next = t[pos][i];
    if (next == pre) {
      continue;
    }
    if (nextCol == col) {
      nextCol++;
    }
    ans[pos][next] = ans[next][pos] = nextCol;
    ansK = max(ansK, nextCol);
    solve(next, pos, nextCol);
    nextCol++;
  }
}

int main() {
  static int a[100002];
  static int b[100002];
  
  while (cin >> N) {
    for (int i = 0; i < N; i++) {
      t[i].clear();
      ans[i].clear();
    }

    for (int i = 0; i < N - 1; i++) {
      cin >> a[i] >> b[i];
      a[i]--;
      b[i]--;
      t[a[i]].push_back(b[i]);
      t[b[i]].push_back(a[i]);
    }

    ansK = -1;
    solve(0, -1, -1);

    cout << ansK << endl;
    for (int i = 0; i < N - 1; i++) {
      cout << ans[a[i]][b[i]] << endl;
    }
  }
}


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

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

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); --i)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    string s; cin >> s;

    if (s == "ABC") {
        cout << "ARC";
    } else {
        cout << "ABC";
    }

}


Measured memory_bytes: 3612
#include <stdio.h>
#include <iostream>

using std::cout;

int main() {
    int a, biscket_num, time;
    scanf("%d %d %d", &a, &biscket_num, &time);

    float final_time = time + 0.5;

    cout << biscket_num * (int)(final_time / a);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){

  int a,b,c;
  int X,Y,Z;
  int count1=0,count2=0,count3=0,count=0;

  while(cin >> a >> b >> c   ){
    
    if(a>=b && a>=c){
      X=a;Y=b;Z=c;}
    else if(b>=a && b>=c){
      X=b;Y=a;Z=c;}
    else if(c>=a && c>=b){
      X=c;Y=b;Z=a;}
    if(X>=Y+Z)break;
    else{count++;


    if(X*X==Y*Y+Z*Z){
      count1++;
      
    }
    else if(X*X< Y*Y +Z*Z){
      count2++;}
    else if(X*X> Y*Y +Z*Z){
      count3++;}
    }
  
  }

  cout << count << " " << count1 << " " << count2 << " " << count3 << endl;    
    
  return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<cstring>
#include<stack>
#define F first
#define S second
using namespace std;
typedef pair<long long, long long> pll;
string s1, s2;
long long m, n;
pll dp[3005][3005];
stack <char> st;
void re(long long a, long long b){
	if (a==0||b==0) return;
	if (dp[a][b].S==1){
		st.push(s1[a-1]);
		re(a-1, b-1);
	}
	if (dp[a][b].S==2) re(a-1,b);
	if (dp[a][b].S==3) re(a,b-1);
}
int main(){
	cin >> s1 >> s2;
	n=s1.size(), m=s2.size();
	for (int i=0;i<=n||i<=m;i++)
		dp[i][0].F=0, dp[0][i].F=0;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++){
			if (s1[i-1]==s2[j-1]) 
				dp[i][j].F=dp[i-1][j-1].F+1, dp[i][j].S=1;
			else if (dp[i-1][j].F>dp[i][j-1].F)  
				dp[i][j].F=dp[i-1][j].F, dp[i][j].S=2;
			else 
				dp[i][j].F=dp[i][j-1].F, dp[i][j].S=3;
		}
	re(n, m);
	while (!st.empty()) cout << st.top(), st.pop();
}

Measured memory_bytes: 141440
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    string s;
    cin >> s;
    int result=0,tmp_result=0;
    for(auto x:s){
        if(x=='A'||x=='T'||x=='G'||x=='C'){
            tmp_result++;
            result = max(result, tmp_result);
        }else{
            tmp_result = 0;
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>

using Edge = std::pair<int, int>;
using Graph = std::vector<std::vector<Edge>>;

Graph G;

std::vector<int> res;

void dfs(int v, int p, int c){
    res[v] = c;
    for(auto e : G[v]){
        if(e.first == p) continue;
        if(e.second & 1) dfs(e.first, v, 1-c);
        else dfs(e.first, v, c);
    }
}

int main(void){
    int n;
    std::cin >> n;

    G.assign(n, std::vector<Edge>());
    res.assign(n, 0);
    for(int i = 0; i < n - 1; i++){
        int u, v, w;
        std::cin >> u >> v >> w;
        --u, --v;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u,w));
    }

    dfs(0, -1, 1);
    for(auto v : res) std::cout << v << std::endl;
    return 0;
}

Measured memory_bytes: 8960
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

template <typename C>
void print_container(const C &c, const std::string &name)
{
  std::cout << name << ": ";
  std::for_each(c.cbegin(), c.cend(),
                [](auto x) { std::cout << x << ", "; });
  std::cout << std::endl;
}

int main()
{
  int N, M;
  std::cin >> N >> M;
  std::vector<int> foods(M);

  for(int i=0; i<N; i++) {
    int K;
    std::cin >> K;
    for(int j=0; j<K; j++) {
      int f;
      std::cin >> f;
      f--;  // 0 origin
      foods[f]++;
    }
  }
  // print_container(foods, "foods");

  int ret = 0;
  for(int i=0; i<M; i++) {
    if(foods[i] == N) ret++;
  }
  std::cout << ret << std::endl;

  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
using namespace std;
 

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
//#define int long long

 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
 
 
const int MAXN = 2e5 + 5;
const ll MOD = 1e9 + 7;
const ll INF = INT64_MAX;


mt19937 rnd(time(0));


signed main() {
	FAST_IO;
	int n, m, x;
	cin >> n >> m >> x;
	vector<vector<int>> a(n, vector<int> (m));
	vector<int> c(n);
	forn(i, n) {
		cin >> c[i];
		forn(j, m) {
			cin >> a[i][j];
		}
	}
	int ans = 1e9;
	for (int mask = 0; mask < (1 << n); mask++) {
		int cost = 0;
		vector<int> now(m);
		forn(b, 32) {
			if (mask & (1 << b)) {
				cost += c[b];
				forn(j, m) {
					now[j] += a[b][j];
				}
			}
		}
		bool ok = 1;
		forn(j, m) {
			if (now[j] < x) {
				ok = 0;
				break;
			}
		}
		if (ok) {
			ans = min(ans, cost);
		}
	}
	if (ans == 1000000000) {
		cout << "-1\n";
	} else {
		cout << ans << "\n";
	}
 	return 0;
}

Measured memory_bytes: 3644
n = int(input())
l =[int(i) for i in input().split()]
s_1 = l[0]
s_2 = sum(l)-s_1
answer = 0
x = s_2-s_1

i = 1
while x>0:
  x-=2*l[i]
  i +=1
  
a = -x
b = x+2*l[i-1]

if s_2-s_1<0:
  answer = s_1-s_2
else: answer = min(a,b)
  
print(answer)


Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10000000)
import math
import bisect
def input():
    return sys.stdin.readline()[:-1]

l = input()
mod = 10**9+7
from collections import deque
l = deque(l)

def llo(st):
    if len(st)==1 and st[0]=="0":
        return 1
    elif len(st)==1 and st[0]=="1":
        return 3
    tmp = st.popleft()
    if tmp=="0":
        return llo(st)
    else:
        return (pow(3,len(st),mod) + 2*llo(st))%mod



if "0" not in l:
    print(pow(3,len(l),mod))
else:
    ans = llo(l)
    print(ans)


Measured memory_bytes: 113264
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N, M  = MAP()
A = LIST()
sum_A = sum(A)
c = 0
 
for i in range(N):
  if A[i] >= sum_A/4/M:
    c = c+1
      
if c >= M:
  print("Yes")
else:
  print("No")

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

using ll = long long;

int main() {
  ll N;
  cin >> N;

  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 0;
  for (int i = 1; i <= sqrt(N); i++) {
    if (N % i != 0) continue;

    ll tmp = N / i - 1;
    if (N / tmp == N % tmp) ans += tmp;
  }

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


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

typedef long long ll;

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,l,n) for(int i=(l);i<(n);i++)

template<class T>
using vt = vector<T>;
template<class T>
using vvt = vector<vector<T>>;

#define MAX_N 100000
bool is_check[MAX_N];

int main(){
    int N,K,R,S,P,ans =0 ;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    rep(i,N) is_check[i] = false;
    reps(i,0,N){
        if(i - K < 0){
            if(T[i]=='r') ans += P;
            if(T[i]=='s') ans += R;
            if(T[i]=='p') ans += S;
        }
        else {
            if(T[i]!=T[i-K] || is_check[i-K]){
                if(T[i]=='r') ans += P;
                if(T[i]=='s') ans += R;
                if(T[i]=='p') ans += S;
            }
            else{
                is_check[i] = true;
            }
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 512
def main():
    n = int(input())
    h = list(map(int,input().split()))

    for i in range(1,n)[::-1]:
        if h[i-1] <= h[i]:
            continue
        h[i-1] = h[i-1]-1
        if h[i-1] > h[i]:
            print('No')
            return 0
    print('Yes')

if __name__ == '__main__':
    main()



Measured memory_bytes: 63856
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.OutputStream;
public class Main {
    static int M[][];
    static int V[][];
    static int H;
    static String a;
    static String b;
    public static void main(String args[]) {
        Sc sc = new Sc(System.in);
        H = sc.nI();
        int W = sc.nI();

        String[] B = new String[H];
        for(int i = 0; i<H; i++) {
            B[i] = sc.n();
        }
        M = new int[H+1][H+1];
        
        StringBuilder sb1 = new StringBuilder();
        StringBuilder sb2 = new StringBuilder();
        StringBuilder sb3 = new StringBuilder();
        StringBuilder sb[] = new StringBuilder[W];
        for(int i = 0; i<W; i++) {
            sb[i] = new StringBuilder();
        }
        for(int i = 0; i<H; i++) {
            for(int j = 0; j<W; j++) {
                sb[j].append(B[i].charAt(j));
            }
        }
        
        int sum = 0;
        for(int x = 0; x<W-1; x++) {
            for(int i = 0; i<=H; i++) {
                for(int j = 0; j<=H; j++) {
                    M[i][j] = -1;
                }
            }
            a = sb[x].toString();
            b = sb[x+1].toString();
            //System.out.println(a);
            V = new int[H+1][H+1];
            for(int i = 1; i<=H; i++) {
                for(int j = 1; j<=H; j++) {
                    V[i][j] = V[i-1][j-1];
                    if(a.charAt(i-1) == b.charAt(j-1)) V[i][j]++;
                }
            }
            sum += opt(H,H);
            //System.out.println(sum);
        }
        System.out.println(sum);
    }
    public static int opt(int l, int r) {
        if(l== 0 || r == 0) return 0;
        if(M[l][r] != -1) return M[l][r];
        M[l][r] = V[l][r] + Math.min(opt(l-1,r), opt(l, r-1));
        return M[l][r];
    }
}
class Sc {
    public Sc(InputStream i) {
        r = new BufferedReader(new InputStreamReader(i));
    }

    public boolean hasM() {
        return peekToken() != null;
    }

    public int nI() {
        return Integer.parseInt(nextToken());
    }

    public double nD() { 
        return Double.parseDouble(nextToken());
    }

    public long nL() {
        return Long.parseLong(nextToken());
    }

    public String n() {
        return nextToken();
    }

    private BufferedReader r;
    private String line;
    private StringTokenizer st;
    private String token;

    private String peekToken() {
        if (token == null) 
            try {
                while (st == null || !st.hasMoreTokens()) {
                    line = r.readLine();
                    if (line == null) return null;
                    st = new StringTokenizer(line);
                }
                token = st.nextToken();
            } catch (IOException e) { }
        return token;
    }

    private String nextToken() {
        String ans = peekToken();
        token = null;
        return ans;
    }
}

Measured memory_bytes: 46500
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false); //cin.tie(NULL); cout.tie(NULL)
#define mp make_pair
#define pb push_back
#define fs first
#define sc second

using namespace std;
typedef long long ll;
typedef long double ld;

void solve(){
	int n; cin >> n;
	int su = 0;
	int mx = 0;
	for (int i=1; i<=n; ++i){
		int x; 
		cin >> x;
		su += x;
		mx = max(mx,x);
	}
	cout << fixed << setprecision(0) << (ld)su-(ld)mx/2;
}	

int main(){ FIO;
	solve();
return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl

int main(){
   int n;
  cin >> n;
  string s;
  cin >> s;
  rep(i,s.size()){
    s[i] = (s[i] - 'A' + n)%26 + 'A';
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  // Your code here!
  string s;
  while (true){
      cin>>s;
      if (s=="0"){
          break;
      }
      int sum=0;
      for (int i=0; i<s.size();i++){
          int n=s[i]-48;
          sum+=n;
      }
      cout<<sum<<endl;
  }
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int64_t N, X, Y;
vector<int64_t> D(2010, -1);
vector<vector<int64_t>> Graph(2010);
vector<int64_t> Count(2010, 0);
queue<int64_t> Q;

int main()
{
  cin >> N >> X >> Y;
  for (int i = 1; i <= N; i++)
  {
    if (i != N)
      Graph.at(i).push_back(i + 1);
    if (i != 0)
      Graph.at(i + 1).push_back(i);
  }
  Graph.at(X).push_back(Y);
  Graph.at(Y).push_back(X);
  for (int k = 1; k <= N; k++)
  {
    Q.push(k);
    D.at(k) = 0;
    while (!Q.empty())
    {
      int64_t node = Q.front();
      Q.pop();
      for (int64_t i = 0; i < Graph.at(node).size(); i++)
      {
        int64_t nextNode = Graph.at(node).at(i);
        if (D.at(nextNode) == -1)
        {
          int64_t nextNodeCopy = nextNode;
          Q.push(nextNodeCopy);
          int64_t nextStep = D.at(node) + 1;
          D.at(nextNode) = nextStep;
          Count.at(nextStep)++;
        }
      }
    }
    for (int64_t i = 0; i < D.size(); i++)
      D.at(i) = -1;
  }
  for (int i = 1; i <= N - 1; i++)
  {
    cout << Count.at(i) / 2 << endl;
  }
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int n,c,N[4];
  int i,j,t,s,l,a;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    c=0;
    a=1;
    while(n!=6174){
      for(i=0;i<4;i++){
	N[3-i]=n%10;
	n/=10;
      }
      if(N[0]==N[1]&&N[1]==N[2]&&N[2]==N[3]){
	printf("NA\n");
	a=0;
	break;
      }
      for(i=0;i<4;i++){
	for(j=1;i+j<4;j++){
	  if(N[j-1]>N[j]){
	    t=N[j];
	    N[j]=N[j-1];
	    N[j-1]=t;
	  }
	}
      }
      s=0;
      l=0;
      for(i=0;i<4;i++){
	s*=10;
	l*=10;
	s+=N[i];
	l+=N[3-i];
      }
      n=l-s;
      c++;
    }
    if(a)printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 608
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
ans = [-1] * 9
for i in range(n):
    if b[i] in a[0]:
        ans[a[0].index(b[i])] = 0
    elif b[i] in a[1]:
        ans[a[1].index(b[i]) + 3] = 0
    elif b[i] in a[2]:
        ans[a[2].index(b[i]) + 6] = 0
if (ans[0] == 0 and ans[1] == 0 and ans[2] == 0) or\
   (ans[0] == 0 and ans[3] == 0 and ans[6] == 0) or\
   (ans[3] == 0 and ans[4] == 0 and ans[5] == 0) or\
   (ans[6] == 0 and ans[7] == 0 and ans[8] == 0) or\
   (ans[1] == 0 and ans[4] == 0 and ans[7] == 0) or\
   (ans[2] == 0 and ans[5] == 0 and ans[8] == 0) or\
   (ans[0] == 0 and ans[4] == 0 and ans[8] == 0) or\
   (ans[2] == 0 and ans[4] == 0 and ans[6] == 0):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 2e9;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  vector<int> a(n.size());
  rep(i, n.size()) a[i] = n[i] - '0';
  reverse(a.begin(), a.end());
  a.push_back(0);
  a.push_back(0);
  ll ans = 0;
  rep(i, n.size() + 1) {
    if (a[i] <= 4) ans += a[i];
    else if (a[i] == 5 && a[i + 1] <= 4) ans += a[i];
    else {
      ans++;
      while (1) {
        ans += 9 - a[i++];
        if (a[i] <= 3) break;
        else if (a[i] == 4 && a[i + 1] <= 4) break;
      }
      a[i--]++;
    }
  }
  cout << ans << endl;

  


  
  return 0;
}

Measured memory_bytes: 11140
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

struct v{
	ll index;
	ll value;
	bool operator <(const v& rhs) const{
		return value < rhs.value;
	}
};

vector <vector<ll>> graph;
vector <v> gsize;
vector <ll> value;
vector <ll> c;
ll ans = 0;

void dfs(ll v,ll p){
	for (int z=0;z<graph[v].size();z++){
		if (graph[v][z] == p) continue;
		ans += min(value[v],value[graph[v][z]]);
		dfs(graph[v][z],v);
	}
}

int main(){
	ll n;
	cin >> n;
	graph.resize(n+1);
	gsize.resize(n+1);
	value.resize(n+1);
	for (int z=0;z<=n;z++){
		gsize[z].index = z;
	}
	for (int z=0;z<n-1;z++){
		ll a,b;
		cin >> a >> b;
		graph[a].push_back(b);
		graph[b].push_back(a);
		gsize[a].value++;
		gsize[b].value++;
	}
	c.resize(n);
	for (int z=0;z<n;z++){
		cin >> c[z];
	}
	sort(c.rbegin(),c.rend());
	sort(gsize.rbegin(),gsize.rend());
	vector <bool>visited (n+1,false);
	ll temp = 0;
	value[gsize[0].index] = c[temp];
	temp++;
	visited[gsize[0].index] = true;
	queue <ll> que;
	for (int z=0;z<graph[gsize[0].index].size();z++){
		que.push(graph[gsize[0].index][z]);
	}
	while (!que.empty()){
		ll vertex = que.front();
		que.pop();
		value[vertex] = c[temp];
		visited[vertex] = true;
		temp++;
		for (int z=0;z<graph[vertex].size();z++){
			if (visited[graph[vertex][z]]) continue;
			que.push(graph[vertex][z]);
		}
	}
	dfs(1,0);
	cout << ans << endl;
	for (int z=1;z<=n;z++){
		cout << value[z] << " ";
	}cout << endl;
	cin >> n;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h> 
using namespace std;                          
#pragma GCC optimize("O3")
typedef long long ll;
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define vec(i, a)  for( auto i=a.begin();i != a.end(); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define mp make_pair
#define pb push_back
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define in  freopen("input.txt","r",stdin);
#define out freopen("output.txt","w",stdout);
#define sixfive in out 
typedef long double ld;
typedef std::pair<ll, ll> pii;
typedef std::vector<ll> vi;
const ll MOD = 1e9 + 7;
ll n_bits(ll n ) { ll x= __builtin_popcount(n) ;return x ;}
int main()
{    
    #ifndef ONLINE_JUDGE
    sixfive
    #endif
    fast
    ll t=1;
    //cin>>t;
    while(t--)
    {    
        int n;
        cin>>n;
        int k=n%10;
        if(k==2||k==4||k==5||k==7||k==9)
          return cout<<"hon",0;
        if(k==0||k==1||k==6||k==8)
          return cout<<"pon",0;
        cout<<"bon";
    }
    return 0;
}

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

template<typename T>
istream& operator >> (istream& istr, vector<T>& vec){
    for(T& x: vec) istr >> x;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& vec){
    if(!vec.empty()){
        ostr << vec.front();
        for(auto itr = ++vec.begin(); itr != vec.end(); itr++)
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    ostr << p.first << " " << p.second;
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
// vll x(n); x[i]=a;
typedef vector<pair<ll,ll>> vpll;
// vpll x(n); x[i]={a,b}; x[i].first/second;
typedef vector<vector<ll>> vvll;
// vvll x(m,vi(n)); x[i][j]=a;

#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

int main(){
    ll k, x;
    cin >> k >> x;
    for(int i = x-k+1; i <= x+k-1; i++){
        cout << i << " ";
    }
    cout << endl;
    return 0;
}

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

namespace ConsoleApp5
{
    class Program
    {
        public static bool IsPrime(long num)
        {
            if (num < 2) return false;
            else if (num == 2) return true;
            else if (num % 2 == 0) return false;

            double sqrtNum = Math.Sqrt(num);
            for (int i = 3; i <= sqrtNum; i += 2)
            {
                if (num % i == 0)
                {
                    return false;
                }
            }
            return true;
        }

        static void Main(string[] args)
        {
            String S = Console.ReadLine();
            String[] L = S.Split(' ');
            long A = long.Parse(L[0]);
            long B = long.Parse(L[1]);

            if (A < B)
            {
                long t = A;
                A = B;
                B = t;
            }

            long R = A % B;
            while (R != 0)
            {
                A = B;
                B = R;
                R = A % B;
            }

            int ans = 1;

            for (long i = 1; i * i <= B; i++)
            {
                if (B % i == 0)
                {
                    if(IsPrime(i) == true)
                    {
                        ans++;
                    }
                    if (i != B / i)
                    {
                        if (IsPrime(B/i) == true)
                        {
                            ans++;
                        }
                    }
                }
            }

            Console.WriteLine(ans);



        }
    }
}

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

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

  if (n%2 == 0) {
    ll dp0 = 0, dp1 = 0;
    for (int i=0; i<n; i++) {
      if (i%2 == 0) {
        dp1 = max(dp0, dp1);
        dp0 += A[i];
      }
      else {
        dp1 += A[i];
      }
    }
    cout << max(dp0, dp1) << endl;

  }
  else {
    ll dp0 = 0, dp1 = 0, dp2 = 0;
    for (int i=0; i<n; i++) {
      if (i%2 == 0) {
        dp1 = max(dp0, dp1);
        if (i != n-1) dp0 += A[i];
        if (i != 0) dp2 += A[i];
      }
      else {
        dp2 = max(dp1, dp2);
        dp1 += A[i];
      }
    }
    cout << max(max(dp0, dp1), dp2) << endl;
  }

  return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int N, K;
  cin >> N >> K;
  vector <int> h(N);
  rep(i,N) cin >> h.at(i);

  int ans = 0;
  rep(i,N){
    if (h.at(i) >= K) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3676
// C++ program to print all prime factors  
#include <bits/stdc++.h> 
using namespace std; 
  
// A function to print all prime  
// factors of a given number n  
 #define ll long long 
ll a,b;ll ans;


int main()  
{  
   vector<pair<ll,ll>>v;
 cin>>a; 
 for(ll i=1;i<=a;i++){
    ll x;
    cin>>x;v.push_back({x,i});
    
 }sort(v.begin(),v.end());
 for(ll i=0;i<a;i++){
   cout<<v[i].second<<" ";
 }
     
}  
  

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

vi g[MAXN];

int prv[MAXN], dis[MAXN], sz[MAXN];

void dfs(int s) {
	sz[s] = 1;
	REP(i, 0, SZ(g[s])) {
		int to = g[s][i];
		if (to != prv[s]) {
			prv[to] = s;
			dis[to] = dis[s] + 1;
			dfs(to);
			sz[s] += sz[to];
		}
	}
}

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 1, n) {
		int a, b;
		scanf("%d%d", &a, &b);
		g[a].pb(b);
		g[b].pb(a);
	}
	dfs(1);
	int cur = n;
	REP(i, 0, (dis[n] - 1) / 2) {
		cur = prv[cur];
	}
	if (sz[cur] * 2 < n) {
		printf("Fennec\n");
	} else {
		printf("Snuke\n");
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 14720
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w, k;
    cin >> h >> w >> k;
    string s[310];
    for (int i = 0; i < h;i++){
        cin >> s[i];
    }
    bool st[310];
    for (int i = 0; i < h;i++){
        st[i] = false;
        for (int j = 0; j < w;j++){
            if(s[i][j]=='#'){
                st[i] = true;
            }
        }
    }
    int res[310][310];
    for (int i = 0; i < h;i++){
        for (int j = 0; j < w;j++){
            res[i][j] = 0;
        }
    }
    int cnt = 0;
    for (int i = 0; i < h;i++){
        if(!st[i])
            continue;
        bool ok = false;
        for (int j = 0; j < w; j++)
        {
            if (s[i][j] == '#')
            {
                cnt++;
                ok = true;
            }
            if(!ok)
                continue;
            res[i][j] = cnt;
        }
    }
    vector<int> v;
    for (int i = 0; i < h; i++)
    {
        for (int j = w-1; j >=0;j--){
            if(!st[i])
                continue;
            if (res[i][j] == 0){
                res[i][j]=res[i][j+1];
            }
        }
    }
    for(int i=0;i<h;i++){
        if(!st[i]){
            for(int j=0;j<w;j++){
                if(i==0){
                    continue;
                }else{
                    res[i][j]=res[i-1][j];
                }
            }
        }
    }
    for(int i=h-1;i>=0;i--){
        if(!st[i]){
            for(int j=0;j<w;j++){
                if(i==h-1)continue;
                res[i][j]=res[i+1][j];
            }
        }
    }
    for (int i = 0; i < h;i++){
        for (int j = 0; j < w;j++){
            cout << res[i][j]<<' ';
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

const int MXN = 5e5 + 1;
const int MOD = 1e9 + 7;
int fact[MXN];
int add(int x, int y) {return (x+y) % MOD;}
int mul(int x, int y) {return (x*1ll*y) % MOD;}
int bp(int x, int y) {
	int ans = 1;
	while (y) {
		if (y&1) ans = mul(ans, x);
		x = mul(x, x);
		y >>= 1;
	}
	return ans;
}
int inv(int x) {return bp(x, MOD-2);}
int cmb(int n, int k) {
	return mul(fact[n], inv(mul(fact[k], fact[n-k])));
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n >> m;
	fact[0] = 1;
	for (int i=1; i<=m; i++) fact[i] = mul(fact[i-1], i);
	int ans = 0;
	for (int i=0; i<=n; i++) {
		int same = mul(mul(cmb(n, i), cmb(m, i)), fact[i]);
		int tmp = cmb(m-i, n-i);
		int diff = mul(mul(tmp, tmp), mul(fact[n-i], fact[n-i]));
		int cur = mul(same, diff);
		if (i&1) {
			ans = add(ans+MOD, -cur);
		}
		else {
			ans = add(ans, cur);
		}
	}
	cout << ans << '\n';
}

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

int main()
{
    /*
    int a,b;
    cin>>a>>b;
    if(a+b==3)
    {
        cout<<3<<endl;
    }
    else if(a+b==4)
    {
        cout<<2<<endl;
    }
    else
    {
        cout<<1<<endl;
    }
    */
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    string s_t;
    for(int i=0;i<n;i++)
    {   
        s_t.push_back(s[i]);
        s_t.push_back(t[i]);
    }   
    cout<<s_t<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;


#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define ll long long
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

vector<pair<ll,ll>> factors(ll n) {
	vector<pair<ll, ll>> f;
	for(ll i=2; i<=sqrt(n);i++) {
		ll ct = 0;
		while (n % i == 0) {
			n = n/i;
			ct++;
		}
		if (ct) f.push_back({i, ct++});
	}
	if (n>1) f.push_back({n, 1});
	return f;
}

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

int main() {

	ll a, b;
	cin >> a >> b;
	vector<pair<ll, ll>> v = factors(a);
	vector<pair<ll, ll>> w = factors(b);
	map<ll, ll> mv, mw;
	for(ll i=0; i<v.size(); i++) {
		mv[v[i].first] = v[i].second;
	}
	for(ll i=0; i<w.size(); i++) {
		mw[w[i].first] = w[i].second;
	}

	ll ans = 0;
	set<ll> d;
	for(ll i=0; i<v.size(); i++) {
		ll pot = min(v[i].second, mw[v[i].first]);
		if (pot>0 and !d.count(v[i].first)) d.insert(v[i].first);
	}

	cout << d.size()+1 << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int d[4] = {1,-1,4,-4};
map<string,int> m;
void bfs() {
	queue<string> q;
	q.push("01234567");
	while(!q.empty()) {
		string v = q.front(); q.pop();
		int pos = 0;
		rep(i,8) {
			if(v[i] == '0') pos = i;
		}
		rep(i,4) {
			if(0 <= pos+d[i] && pos+d[i] < 8 && !(pos == 3 && i == 0) && !(pos == 4 && i == 1)) {
				string s = v;
				swap(s[pos], s[pos+d[i]]);
				if(m[s] == 0) {
					q.push(s);
					m[s] = m[v]+1;
				}
			}
		}
	}
}

int main() {
	m["01234567"] = 1;
	bfs();
	char n;
	while(cin >> n) {
		string ret;
		ret += n;
		rep2(i,1,8) {
			cin >> n;
			ret += n;
		}
		cout << m[ret]-1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3444
use proconio::input;

fn culc(a: usize, b:usize) -> usize {
	if b == 0 {
      return a
    }
    culc(b, a % b)
}

fn main() {
  input! {
    K: usize
  }
  
  let mut map: Vec<[usize;201]> = Vec::with_capacity(201);
  for _ in 0..=200 {
    map.push([0;201]);
  } 
  let mut result = 0;
  
  for i in 1..=200 {
    for j in 1..=200 {
      map[i][j] = culc(i, j);
    }
  }
  
  for i in 1..=K {
    for j in 1..=K {
      let a = map[i][j];
      for k in 1..=K {
        result += map[a][k];
      }
    }
  }
  
  println!("{}", result);
}

Measured memory_bytes: 2276
#include<bits/stdc++.h>
using namespace std;
string s;
main(){
  cin>>s;
  string s2;
  for(int i=0;i<s.size();++i){
     if(s[i]=='B'){
       if(s2.size()>=1)s2.pop_back();
     }else{
       s2.push_back(s[i]);
     }
  }
  cout<<s2<<endl;
}


Measured memory_bytes: 256
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <chrono>
#include <random>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
#define dibs reserve
#define OVER9000 1234567890
#define tisic 47
#define soclose 1e-8
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
using uint = unsigned int;
using cat = long long;
using dbl = long double;
constexpr dbl pi = 3.14159265358979323846;
using namespace std;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(10);
	string S;
	cin >> S;
	cat ans = 0;
	for(int i = 0, cur = 0, last = 0; i < (int)S.length(); i++) {
		if(S[i] == '1') {
			ans += i/2+1;
			if(last) cur++, last--;
			else last++;
		}
		else {
			if(last == 1) cur++, last = 0;
			ans += cur;
		}
	}
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


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


int main() {
    long long int L, R;
    std::cin >> L >> R;

    if (R - L > 2019) {
        std::cout << 0 << std::endl;
        return 0;
    }

    long long int min = 10000;
    for (long long int i = L; i < R; i++) {
        for (long long int j = i + 1; j <= R; j++) {
            min = std::min((i * j) % 2019, min);
        }
    }
    std::cout << min << std::endl;
}


Measured memory_bytes: 3612
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,k,s,v;
  cin >> n >> k >> s;
  if(s==1000000000ll){
    v = 3;
  }else{
    v = s+1;
  }
  for(int i=0;i<n;i++){
    if(k!=0){
      cout << s;
      k--;
    }else{
      cout << v;
    }
    if(i==n-1) cout << endl;
    else cout <<" ";
  }
}


Measured memory_bytes: 1280
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

std::vector<std::pair<int64_t, int64_t>> FactorizeIntoPrimeFactors(const int64_t N) {
  std::vector<std::pair<int64_t, int64_t>> result;
  if (N <= 0LL || N == 1LL) {
    return result;
  }
  int64_t remaining = N;
  for (int64_t i = 2LL; i * i <= remaining; ++i) {
    int64_t count = 0LL;
    while (remaining % i == 0LL) {
      ++count;
      remaining /= i;
    }
    if (count > 0LL) {
      result.push_back(std::pair<int64_t, int64_t>(i, count));
    }
  }
  if (remaining > 1) {
    result.push_back(std::pair<int64_t, int64_t>(remaining, 1));
  }
  return result;
}

int64_t CalculatePower(const int64_t x, const int64_t n) noexcept {
  // log(n) order
  if (n == 0LL) {
    return 1LL;
  } else if (n == 1LL) {
    return x;
  } else if (x == 1LL) {
    return 1LL;
  }
  constexpr int64_t kPrime = 1000000007LL;
  int64_t result = CalculatePower((x * x) % kPrime, n / 2LL);
  if (n % 2LL == 1LL) {
    result = (result * x) % kPrime;
  }
  return result;
}

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

  int64_t N, P;
  cin >> N >> P;
  vector<Pair> f = FactorizeIntoPrimeFactors(P);
  int64_t result = 1LL;
  for (const auto p : f) {
    if (p.second >= N) {
      result *= CalculatePower(p.first, p.second / N);
    }
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
  cin >> a >> b;
  int ans = 1;
  for(int i = 0; i < a; i++){
  if(ans * 2 > ans + b)
    ans += b;
    else
      ans *= 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main{ 
        public static void main(String[] args){ 
            Scanner sc = new Scanner(System.in); 
            int n = sc.nextInt(); Card A[] = new Card[n]; 
            for(int i=0; i<n; i++){ 
                A[i] = new Card(); 
                A[i].pic = sc.next(); 
                A[i].num = sc.nextInt(); 
                A[i].idx = i; 
            } 
            quicksort(A, 0, n-1); 
            int flg=0, off; 
            int I[] = new int[4]; 
            for(int i=0; i<n; i+=off){ 
                I[0] = A[i].idx; 
                off = 1; 
                while(i+off<n && A[i].num==A[i+off].num) { 
                    I[off] = A[i+off].idx; 
                    off++; 
                } 
                if(off != 1){ 
                    for(int j=0; j<off-1; j++) { 
                        for(int k=j+1; k<off; k++){ 
                            if(I[j] > I[k]){ 
                                flg = 1; 
                                break; 
                            } 
                        } 
                        if(flg == 1) 
                            break; 
                    } 
                } 
                if(flg == 1) 
                    break; 
            } 
            if(flg == 0) 
                System.out.println("Stable"); 
            else System.out.println("Not stable"); 
            for(int i=0; i<n; i++){ 
                System.out.println(A[i].pic+" "+A[i].num); 
            } 
        } 
        static void quicksort(Card A[], int p, int r){ 
            if(p < r) { 
                int q = partition(A, p, r); 
                quicksort(A, p, q-1); 
                quicksort(A, q+1, r); 
            } 
        } 
        static int partition(Card A[], int p, int r){ 
            Card work; 
            int i = p-1; 
            for(int j=p; j<=r-1; j++){ 
                if(A[j].num <= A[r].num){ 
                    i++;
                    work = A[i];
                    A[i] = A[j];
                    A[j] = work; 
                } 
            } 
            i++; 
            work = A[i]; 
            A[i] = A[r]; 
            A[r] = work; 
            return i; 
        } 
    } 
    class Card{ 
        String pic; 
        int num; 
        int idx; 
    }



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

using namespace std;

int main(void)
{
	int n;
	while (cin >> n, n){
		long long t[n];
		for (int i = 0; i < n; i++){
			cin >> t[i];
		}

		sort(t, t + n);
		for (int i = 0; i < n-1; i++){
			t[i+1] += t[i];
		}
		long long ret = 0;
		for (int i = 0; i < n-1; i++){
			ret += t[i];
		}
		cout << ret << endl;
	}

	return 0;
}

Measured memory_bytes: 1260
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readline_s = sys.stdin.readline
readlines = sys.stdin.buffer.readlines


def main():

    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())
    k = int(input())

    if abs(a - e) <= k:
        ans = 'Yay!'
    else:
        ans = ':('

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <stdio.h>

int N;
int A[4];
double dp[301][301][301];

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        int a;
        scanf("%d", &a);
        A[a]++;
    }
    for (int k = 0; k <= 300; k++) {
        for (int j = k; j <= 300; j++) {
            for (int i = j; i <= 300; i++) {
                if (i == 0) continue;
                double p = (double)(i - j) / N;
                double q = (double)(j - k) / N;
                double r = (double)k / N;
                double s = 1 - p - q - r;
                dp[i][j][k] = (p * dp[i - 1][j][k] + q * dp[i][j - 1][k] + r * dp[i][j][k - 1] + 1) / (1 - s);
            }
        }
    }
    printf("%.15f\n", dp[A[1] + A[2] + A[3]][A[2] + A[3]][A[3]]);
}



Measured memory_bytes: 211200
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a ,b;
	cin>>a>>b;
	
	if(a<b){
		cout<<"a < b"<<endl;
		} 
	else if(a>b){
		cout<<"a > b"<<endl;
		}
    else{
		cout<<"a == b"<<endl;
		}		
	return 0 ;
}
	 





Measured memory_bytes: 3104
#include<stdio.h>
#include<stdlib.h>

#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

Node root;

void insert(int k){
  Node y=NIL;
  Node x=root;
  Node z;

  z=malloc(sizeof(struct node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while(x != NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  
  z->parent=y;
  if(y==NIL) root=z;
  else{
    if(z->key < y->key) y->left=z;
    else y->right = z;
  }
}

Node find(Node u,int k){
  while(u!=NIL && k!=u->key){
    if(k < u->key) u=u->left;
    else u=u->right;
  }
  return u;
}

void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  Node U;
  int n,i,x,y;
  char com[20];
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }
    else if(com[0]=='f'){
      scanf("%d",&y);
      U=find(root,y);
      if(U!=NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(com[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  
  return 0;
}



Measured memory_bytes: 20552
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 2 * 1E+05;

int N;

int A[MAX_N];

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

    cin >> N;

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

    list<int> lst;

    for (int i = 0; i < N; i++) {
        if ((N - i) & 1) {
            lst.push_front(A[i]);
        } else {
            lst.push_back(A[i]);
        }
    }

    for (auto ite = lst.begin(); ite != lst.end(); ite++) {
        cout << *ite << " ";
    }

    return 0;
}

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

int main()
{
  int x, a, b;
  cin >> x >> a >> b;
  auto _a = ((x < a) ? a - x : x - a);
  auto _b = ((x < b) ? b - x : x - b);
  cout << ((_a < _b) ? "A" : "B");
  return 0;
}


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

int h, w, n;

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

bool judge(vector<vector<int>> a) {
	int cnt;
	do {
		for (int i = 0; i < w; i++) {
			for (int j = h - 1, k = h - 1; j >= 0; j--) {
				if (a[j][i]) {
					if (j != k) swap(a[j][i], a[k][i]);
					k--;
				}
			}
		}
		vector<vector<bool>> flag(h, vector<bool>(w));
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (a[i][j]) {
					for (int d = 0; d < 2; d++) {
						int x = i, y = j;
						for (int k = 1;; k++) {
							x += dx[d];
							y += dy[d];
							if (x < 0 || x >= h || y < 0 || y >= w || a[x][y] != a[i][j]) {
								if (k >= n) {
									for (int tx = i, ty = j; tx != x || ty != y; tx += dx[d], ty += dy[d]) {
										flag[tx][ty] = true;
									}
								}
								break;
							}
						}
					}
				}
			}
		}
		cnt = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (flag[i][j]) {
					a[i][j] = 0;
					cnt++;
				}
			}
		}
	} while (cnt);
	bool res = true;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if(a[i][j]) res = false;
		}
	}
	return res;
}

int main()
{
	char c;
	cin >> h >> w >> n;
	vector<vector<int>> a(h, vector<int>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> c;
			if (c != '.') {
				a[i][j] = c - 'A' + 1;
			}
		}
	}
	bool res = false;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w - 1; j++) {
			if (a[i][j] != a[i][j + 1] && !res) {
				swap(a[i][j], a[i][j + 1]);
				if (judge(a)) {
					res = true;
				}
				swap(a[i][j], a[i][j + 1]);
			}
		}
	}
	cout << (res ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 3164