akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
        int h, w, k;
        cin >> h >> w >> k;
        char c[h][w];
        int i, j;
        int ans = 0;
        for(i = 0; i < h; i++) {
                for(j = 0; j < w; j++) {
                        cin >> c[i][j];
                }
        }

        int black = 0;
        int is, js;
        for(is = 0; is < 1<<h; is++) {
                for(js = 0; js < 1<<w; js++) {

                        for(i = 0; i < h; i++) {
                                if (is>>i & 1) {
                                        continue;
                                }
                                for(j = 0; j < w; j++) {
                                        if (js>>j & 1) {
                                                continue;
                                        }
                                        if (c[i][j] == '#') {
                                                black++;
                                        }
                                }
                        }
                        if (black == k) {
                            ans++;
                        }
                        black = 0;

                }
        }
        cout << ans << endl;
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        int a=scan.nextInt();
        int b=scan.nextInt();

        if(n*a>b){
            System.out.println(b);
        }else{
            System.out.println(a*n);
        }
    }
}


Measured memory_bytes: 23508
MOD = 7+1000000000

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

def solve():
  X,Y = map(int,input().split())
  if (X+Y)%3:
    return 0
  if (2*X-Y)%3:
    return 0
  m = (2*X-Y)//3
  n = X - 2*m
  if m < 0 or n < 0:
    return 0
  return (combination(m+n,m))

print(solve())

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

//Rank Checker
public class Main{

	static class T implements Comparable<T>{
		public int id;
		public int s;
		public T(int id, int s) {
			this.id = id;
			this.s = s;
		}
		public int compareTo(T o) {
			return o.s-s;
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<T> l = new ArrayList<T>();
		while(true){
			String[] s = sc.next().split(",");
			int id = Integer.parseInt(s[0]);
			int solve = Integer.parseInt(s[1]);
			if((id|solve)==0)break;
			l.add(new T(id,solve));
		}
		Collections.sort(l);
		while(sc.hasNext()){
			int q = sc.nextInt();
			int r = 0;
			int pre = -1;
			for(int i=0;i<l.size();i++){
				T t = l.get(i);
				if(pre!=t.s)r++;
				pre = t.s;
				if(t.id==q){
					System.out.println(r);
					break;
				}
			}
		}
	}
}

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

int main() {
  int A, B, C, D, a, b;
  cin >> A >> B >> C >> D;
  a = A+B;
  b = C+D;
  if (a == b) {
    cout << "Balanced" << endl;
  }else if(a > b){
    cout << "Left" << endl; 
  }else{
    cout << "Right" << endl; 
  }
  // ここにプログラムを追記
}


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer> inline _typer read() {
	_typer init = 0;
	char ch = getchar(), k = 0;
	for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
	for ( ; isdigit(ch); ch = getchar())
		init = (init << 3) + (init << 1) + (ch ^ 48);
	return k ? -init : init;
}
const ll N = 100005, INF = 1e9;
const ll Mod = 1e9 + 7;

/*******************************************************************************
 *
 *
 *
 ******************************************************************************/

int n, k;
struct EDGE {
	int to, nex;
} edge[N << 1];
int head[N], cntedge, In[N];
void Addedge(int u, int v) {
	edge[++cntedge] = (EDGE) { v, head[u] };
	head[u] = cntedge, ++In[v];
}

ll Fac[N], Mfa[N];
void ex_gcd(ll a, ll b, ll &x, ll &y) {
	if (!b) {
		x = 1, y = 0;
	} else ex_gcd(b, a % b, y, x), y -= a / b * x;
}
ll Mod_Inv(ll a, ll b) {
	ll x, y;
	ex_gcd(a, b, x, y);
	return (x % Mod + Mod) % Mod;
}
void Pre_make() {
	Fac[0] = 1, Mfa[0] = 1;
	rep (i, 1, k) {
		Fac[i] = Fac[i - 1] * i % Mod;
		Mfa[i] = Mod_Inv(Fac[i], Mod);
		// cout << i << " " << Fac[i] << " " << Mfa[i] << endl;
	}
}

ll Ans = 1, Siz[N];
void Dfs(int u, int f) {
	for (int i = head[u], v; i; i = edge[i].nex) {
		v = edge[i].to;
		if (v == f) continue;
		Dfs(v, u);
		++Siz[u];
	}
	int a = Siz[u], b = k - 2;
	if (u == 1) ++b;
	// cout << u << " " << a << " " << b << endl;
	if (b < a) {
		puts("0");
		exit(0);
	}
	// cout << a << " " << b << endl;
	Ans = Ans * Fac[b] % Mod * Mfa[b - a] % Mod;
	// cout << Ans << " " << Fac[b] << " " << Mfa[b - 1] << endl;
}

int main() {
	n = read<int>(), k = read<int>();
	Pre_make();
	rep (i, 2, n) {
		int x = read<int>(), y = read<int>();
		Addedge(x, y); Addedge(y, x);
	}
	Dfs(1, 0);

	cout << Ans * k % Mod << endl;
	return 0;
}



Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define tez ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll dp[101][100001];
 
 
ll solve(ll n,ll v,ll wt[],ll val[])
{
     if(v==0)return 0;
    // if(n<0)return INT_MAX;
     if(v<0)return INT_MAX;
     if(n==0)return INT_MAX;
     if(dp[n][v]!=-1)
     return dp[n][v];
     return dp[n][v]=min(solve(n-1,v,wt,val),solve(n-1,v-val[n],wt,val)+wt[n]);
     
}
int main()
{
     tez;
     ll n,w;
     cin>>n>>w;
     ll wt[n+1],val[n+1];
     for(ll i=0;i<101;i++)
     {
          for(ll j=0;j<100001;j++)
          {
               dp[i][j]={-1};
          }
     }
     for(ll i=1;i<=n;i++)
     {
          cin>>wt[i]>>val[i];
     }
     ll v;
     for( v=100000;v>=0;v--)
     {
      //    cout<<v<<"\n";
          ll ans=solve(n,v,wt,val);
          if(ans<=w)
          {
               break;
          }
     }
     cout<<v<<"\n";
     
}

Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
ll mod=1e9+7,A[200001];
ll inv(ll a){
    ll n=mod-2,ans=1;
    while(n>0){
        if(n%2) ans=ans*a%mod;
        n=n/2;
        a=a*a%mod;
    }
    return ans;
}
ll nCr(ll a,ll b){
    ll ans=A[a];
    ans=ans*inv(A[b])%mod;
    ans=ans*inv(A[a-b])%mod;
    return ans;
}
int main(){
    ll h,w,a,b,ans=0;
    cin>>h>>w>>a>>b;
    A[0]=1;
    rep(i,200000) A[i+1]=A[i]*(i+1)%mod;
    rep(i,h-a) ans=(ans+nCr(i+b-1,i)*nCr(h+w-i-b-2,w-b-1)%mod)%mod;
    cout<<ans;
}

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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        ll a; cin >> a;
        a = 1e10 - a;
        A[i] = a;
    }

    multiset<ll> se;
    for(ll a : A){
        auto it = se.upper_bound(a);
        if(it==se.end()){
            se.insert(a);
        }else{
            se.erase(it);
            se.insert(a);
        }
    }
    p(se.size());

    
    return 0;
}

Measured memory_bytes: 5760
/** 
If comrades that you trust gather around you, hope can take physical form and become visible. That’s what I believe.
*/
#include <bits/stdc++.h>
using namespace std;
/**
(▀̿Ĺ̯▀̿ ̿) (ง ͠° ͟ل͜ ͡°)ง
*/
const int MOD = 2019;
inline auto to_int(char& ch) -> int {
    return (int) ch - '0';
}
const int N = 2e5 + 7;
int f[N];
auto bin_pow(int a, int b) -> int {
    a %= MOD;
    int ret = 1;
    while (b) {
        if (b & 1) ret = (long long) ret * a % MOD;
        a = (long long) a * a % MOD;
        b >>= 1;
    }
    return ret;
}
auto main() -> int {
	ios_base::sync_with_stdio(false); cin.tie(0);
    string s; cin >> s; 
    int n = s.size();
    int cur = 0;
    map<int, int> tr;
    tr[0] = 1;
    long long ans = 0LL;
    for (int i = n - 1; i >= 0; --i) {
        auto nxt = to_int(s[i]) * bin_pow(10, n - 1 - i) % MOD;
        cur = (nxt + cur) % MOD;
        ans += tr[cur];
        tr[cur]++;
    }   
    // for (auto &v : tr) cerr << v.first << ' ' << v.second <<  '\n';
    cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3780
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
#import math
#import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
#ts=time.time()
sys.setrecursionlimit(10**6)
#input=sys.stdin.readline
show_flg=False
show_flg=True


def gcd(a,b):
    a,b=max(a,b),min(a,b)
    if a%b==0:
        return b
    rt=gcd(a%b,b)
    return rt

a,b=MI()
g=gcd(a,b)
og=g
ans=set()
ans.add(1)



for i in range(2,int(g**0.5)+2):
    if g%i==0:
        ans.add(i)
        while g%i==0:
            g//=i

x=len(ans)
if g>int(og**0.5) and og!=1:
    x+=1
    
print(x)


Measured memory_bytes: 41152
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++){for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << p.first << " " << p.second;}
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){for(auto &z:v)os << z << " ";cout<<"|"; return os;}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  ll now=a[0];
  rep(i,0,n){
    res+=max(0LL,now-a[i]);
    chmax(now,a[i]);
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 4760
#include <algorithm>
#include <iostream>
#include <queue>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

typedef tuple<ll, ll> sushi;
//貪欲法 Greedy

int main() {
  ll N, K;
  cin >> N >> K;
  vector<sushi> V(N);

  for (ll i = 0; i < N; i++) {
    ll t, d;
    cin >> t >> d;
    t--;
    V[i] = sushi(d, t);  // tupleの代入の仕方はこれ dtの順番に注意。
  }

  sort(V.begin(), V.end());
  reverse(V.begin(), V.end());  //降順ソート

  vector<ll> cnt(N + 1, 0);  // 1-indexed
  priority_queue<sushi, vector<sushi>, greater<sushi>> PQ;
  // priority_queueで昇順にするにはこう

  ll ans = 0;
  ll tmpans = 0;

  for (ll i = 0; i < K; i++) {
    ll val = get<0>(V[i]);  // tupleの要素取得はこれ 0-indexed
    ll kind = get<1>(V[i]);
    tmpans += val;
    cnt[kind]++;
    PQ.push(V[i]);
  }

  ll count_num = 0;  //何種類の寿司を使ったか
  for (ll i = 0; i < N; i++) {
    if (cnt[i] > 0) count_num++;
  }

  ans += tmpans + count_num * count_num;

  for (ll i = K; i < N; i++) {
    ll val = get<0>(V[i]);
    ll kind = get<1>(V[i]);

    if (cnt[kind] > 0) continue;  //種類count_numが増えるかどうか判定

    while (!PQ.empty()) {
      ll qval = get<0>(PQ.top());
      ll qkind = get<1>(PQ.top());
      PQ.pop();

      if (cnt[qkind] == 1) continue;
      //入れ替えると結局種類数が減るので何もしない
      //一つしかないので次回から考慮する必要がないのでpushしない

      cnt[qkind]--;
      tmpans -= qval;
      cnt[kind]++;
      tmpans += val;
      count_num++;
      ans = max(ans, tmpans + count_num * count_num);

      break;
    }
  }

  cout << ans << endl;
}



Measured memory_bytes: 5748
#include <iostream>

using namespace std;

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

int main(int argc, const char * argv[]) {
  string s;
  cin >> s;
  string a = "ACGT";
  int max_count = 0;
  int count = 0;
  rep(i, s.size()){
    rep(j, a.size()){
      
      if(s[i] == a[j]){
        count++;
        max_count = max(max_count, count);
        break;
      }
      if(j == 3){
        count = 0;
      }
    }
  }
  cout << max_count << endl;
  return 0;
}


Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, r;
  cin >> n >> r;
  
  if(n >= 10){
   cout << r << endl; 
  }else{
   cout << r + (10 - n)*100 << endl; 
  }
  
  return 0;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <cassert>
#include <unordered_map>
#define int long long

using namespace std;

typedef pair<int, int> pa;
typedef long long ll;
typedef long double ld;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin >> n;
    int g = 0;
    while (n) {
        if (n % 10 == 7)
            g = 1;
        n /= 10;
    }
    if (g)
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 3688
n = int(input())
s = input()

r_list = []
g_list = []
for _ in range(n):
    if s[_] == "R":
        r_list.append(_)
    elif s[_] == "G":
        g_list.append(_)

count = 0
for r in r_list:
    for g in g_list:
        if min(r, g) - abs(r - g) > 0:
            if s[min(r, g) - abs(r - g)] == "B":
                count += 1
        if max(r, g) + abs(r - g) < n:
            if s[max(r, g) + abs(r - g)] == "B":
                count += 1
        if (r + g) % 2 == 0:
            if s[(r + g) // 2] == "B":
                count += 1


print(len(r_list) * len(g_list) * (n - len(r_list) - len(g_list)) - count)

Measured memory_bytes: 69444
#include <stdio.h>

int main(void) {
	unsigned unit_price;
	unsigned num;
	unsigned total = 0u;// total price
	unsigned sum = 0u;	// total sale amount
	unsigned count = 0u;// item amount

	while (scanf("%u,%u",&unit_price,&num) != EOF) {
		if (unit_price == 0) break;
		total += unit_price*num;
		sum += num;
		++count;
	}
	printf("%u\n%u\n",total,(unsigned)((float)sum/count + 0.5f));
	return 0;
}

Measured memory_bytes: 604
import java.util.Scanner;

class Process {
  String name;
  int time;
}

public class Main {
  private static int head, tail;
  private final static int MAX = 100000;
  private static Process[] Queue = new Process[MAX];

  public static void main(final String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int q = sc.nextInt();
    int elaps = 0;
    for (int i = 1; i <= n; i++) {
      Queue[i] = new Process();
      Queue[i].name = sc.next();
      Queue[i].time = sc.nextInt();
    }
    head = 1;
    tail = n + 1;
    while (head != tail) {
      Process p = dequeue();
      int time = Math.min(p.time, q);
      p.time -= time;
      elaps += time;
      if (p.time > 0)
        enqueue(p);
      else {
        System.out.printf("%s %d\n", p.name, elaps);
      }
    }
  }

  private static void initialize() {
    head = tail = 0;
  }

  private static boolean isEmpty() {
    return head == tail;
  }

  private static boolean isFull() {
    return head == (tail + 1) % MAX;
    // if (tail == MAX) {
    // return head == 0;
    // } else
    // return tail - 1 == head;
  }

  private static void enqueue(Process x) {
    if (isFull()) {
      throw new Error("Queue Over Flow");
    }
    Queue[tail] = x;
    if (tail + 1 == MAX)
      tail = 0;
    else
      tail++;
  }

  private static Process dequeue() {
    if (isEmpty()) {
      throw new Error("Queue Under Flow");
    }
    Process x = Queue[head];
    if (head + 1 == MAX)
      head = 0;
    else
      head++;
    return x;
  }

}


Measured memory_bytes: 103276
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
#define erase(s) s.erase(s.end()-1) //文字列sの末尾削除

ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
string RLE(string s){
  ll n=s.size();
  char now='.';
  ll count=1;
  string press;
  loop(i,n){
    if(s[i]!=now){
      if(i){
        press+=now;
        press+=to_string(count);
      }
      now=s[i];
      count=1;
      continue;
    }
    else count++;
  }
  press+=now;
  press+=to_string(count);
  return press;
}
int main() {
  cout << fixed << setprecision(30);
  ll n;
  cin>>n;
  vec p(n);
  vec q(n);
  loop(i,n)cin>>p[i];
  loop(i,n)cin>>q[i];
  vec v(n);
  loop(i,n)v[i]=i+1;
  bool pcheck=true;
  bool qcheck=true;
  ll count=0;
  ll pp,qq;
  do{
    count++;
    pcheck=true;
    qcheck=true;
    loop(i,n)if(v[i]!=p[i])pcheck=false;
    loop(i,n)if(v[i]!=q[i])qcheck=false;
    if(pcheck)pp=count;
    if(qcheck)qq=count;
}while(next_permutation(v.begin(), v.end()));
  putout(abs(pp-qq));
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){

  ll N,A,B;
  cin >> N >> A >> B;
  ll h[N];
  rep(i,N) cin >> h[i];
  sort(h, h+N);
  ll ub=1e9+1;
  ll lb=0;
  ll diff=A-B;
  while(ub-lb>1){
    ll mid=(ub+lb)/2;
    ll t = mid;
    ll low_v=mid*B;
    ll si=upper_bound(h,h+N,low_v)-h;
    for(int j=si;j<N;j++){
      t-=(h[j]-B*mid+(diff-1))/diff;
    }
    if(t>=0) ub=mid;
    else lb=mid;          
  }
  cout << ub << endl;
  return 0;

}


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

/*==========type============*/
typedef long long ll;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
typedef std::pair<std::string,ll> psl;

/*==========constant============*/
#define INF INT_MAX
#define INF_L LONG_MAX
#define INF_LL LLONG_MAX
#define MOD 1000000007

/*==========function============*/
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

using namespace std;

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

    ll n,d;
    cin >> n >> d;

    ll ans = 0;
    REP(i,0,n){
      ll a,b;
      cin >> a >> b;
      if(sqrt(a*a + b*b) <= d)ans++;
    }

    cout << ans << endl;

    return 0;
}    


Measured memory_bytes: 3620
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
    index = 0
    dmin = float("inf")
    for j in range(m):
        d = abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1])
        if d < dmin:
            dmin = d
            index = j
    print(index+1)


Measured memory_bytes: 3064
// Problem : C - Peaks
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<string, string> pss;
#define pb push_back
#define PI acos(-1.0)
#define EPS 1e-4
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fout(S,x)            cout<<fixed<<setprecision(x)<<(S)<<endl
#define present(c,x) ((c).find(x) != (c).end())
#define T() ll t;cin>>t;while(t--)
#define mem(input,b) memset(input,b,sizeof(input))
#define ff first
#define ss second
#define fread(input) freopen("input","r",stdin)
#define fwrite(b) freopen("b","w",stdout)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define FOREACH(i,c) for (__typeof ((c).begin()) i = (c).begin() ; i != (c).end() ; i++)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int main(){
    fastio;
    int n,m;
    cin>>n>>m;
    vector<int>a(n+1);
    for(int i=1;i<=n;++i){
    	cin>>a[i];
    }
	bool good[n];
	for(int i=1;i<=n;++i)
		good[i] = true;
	while(m--){
    	int x,y;
    	cin>>x>>y;
    	if(a[x]<=a[y])
    		good[x] = false;
    	if(a[y]<=a[x])
    		good[y] = false;
    }
    int ans = 0;
    for(int i=1;i<=n;++i)
    	if(good[i] == true)
    		ans++;
    cout<<ans;
    return 0;
}    


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<int>;
using A = array<int, 2>;
using P = pair<int, int>;
constexpr int MOD{1000000000 + 7};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr array<int, 4> dx{1, 0, -1, 0}, dy{0, 1, 0, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
constexpr int div_roundup(int a, int b)
{
    return (a + b - 1) / b;
}

// vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));

// *****************************************************************************

void solve()
{
    ll n;
    cin >> n;
    vector<ll> a(n + 1), b(n);
    for (ll i = 0; i < n + 1; i++)
        cin >> a[i];
    for (ll i = 0; i < n; i++)
        cin >> b[i];

    ll monster = 0;
    for (ll i = 0; i < n; i++)
    {
        if (a[i] >= b[i])
        {
            monster += b[i];
            a[i] -= b[i];
        }
        else
        {
            monster += a[i];
            b[i] -= a[i];
            a[i] = 0;

            if (a[i + 1] >= b[i])
            {
                monster += b[i];
                a[i + 1] -= b[i];
            }
            else
            {
                monster += a[i + 1];
                b[i] -= a[i + 1];
                a[i + 1] = 0;
            }
        }
    }

    cout << monster << endl;
}

// *****************************************************************************

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(0);

    solve();
}


Measured memory_bytes: 1792
# ABC172　C - Walking Takahashi
X,K,D=map(int,input().split())

q=abs(X)//D
if q>K:
    print(abs(X)-K*D)
else:
    if (K-q)%2==0:
        print(abs(X)-q*D)
    else:
        print(abs(abs(X)-(q+1)*D))

Measured memory_bytes: 9180
N=int(input())
S=list(map(int,input().split()))

DP=[10**6]*(10**6)

def chmin(a,b):
    if a>b:
        return b
    else:
        return a

def chmax(a,b):
    if a>b:
        return a
    else:
        return b

DP[0]=0
DP[1]=abs(S[1]-S[0])

for i in range(2,N):
    DP[i]=chmin(DP[i-1]+abs(S[i-1]-S[i]),DP[i-2]+abs(S[i-2]-S[i]))
    
print(DP[N-1])

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;

typedef long long ll;

int main(){

    int n,k;
    cin >> n >> k;

    vector<int> h(n);

    rep(i, n){
        cin >> h[i];
    }

    ll ans = LLONG_MAX;

    for(int bit = 0; bit < (1<<n); bit++){

        vector<int> tmph = vector<int>(h);

        int preh = 0;
        ll tmpans = 0;

        for(int i = 0; i < n; i++){
            if(bit & (1<<i)){
                if(tmph[i] <= preh){
                    tmpans = tmpans + ((preh + 1) - tmph[i]);
                    tmph[i] = preh + 1;
                    preh = preh + 1;
                }else{
                    preh = tmph[i];
                }
            }else{
                preh = max(preh, tmph[i]);
            }

        }

        int count = 1;
        int tmp = tmph[0];

        rep(i, n - 1){
            if(tmp < tmph[i + 1]){
                count++;
                tmp = tmph[i + 1];
            }
        }

        if(count >= k){
            ans = min(ans, tmpans);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//Author- VMAX


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define ld     long double 
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=a;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define pre(n) cout<<fixed<<setprecision(n);
#define      gcd(a,b)    __gcd(a,b)
#define bs            binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define pi 3.14159265358979323846
#define all(x) x.begin(),x.end()
#define re return 0;
// *#######################################################################################*

/*
bool isp(ll n)
{
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return false;
        }
        
    }
}
  */      
       int main()
       
       {
           
           
           fast
           ll n;
           cin>>n;
           ll j,i;
          vector<ll>a(n+2,1);
           for(i=2;i<=n;i++)
           {
               for(j=i;j<=n;j+=i)
               {
                   a[j]++;
               }
           }
           
           ll s=0;
           
           fo(i,n)
           {
               s+=a[i]*i;
               //o1(a[i])
           }
           
           
           o(s)
           
           
       
 
          re
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll N,M;
ll i, j;
int main(){
    scanf("%lld%lld",&N,&M);
    if(N==M){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int n, q; string s;
	cin >> n >> s >> q;
	VE<set<int>> st(26); // アルファベットの場所を記録
	V pos(n); // i番目のアルファベットを持っておく
	rep(i, n) {
		st[s[i] - 'a'].insert(i);
		pos[i] = s[i] - 'a';
	}
	queue<int> ans;
	rep(qqq, q) {
		int k;
		cin >> k;
		if (k == 1) {
			int a; char c;
			cin >> a >> c;
			a--;
			c -= 'a';
			int prev = pos[a];
			pos[a] = c; // 文字の更新
			st[prev].erase(a); // 元の文字の消去
			st[c].insert(a); // 新しい文字の挿入
		}
		if (k == 2) {
			int l, r;
			cin >> l >> r;
			l--, r--;
			int res = 0;
			rep(i, 26) {
				if (!st[i].empty()) {
					auto itr = st[i].lower_bound(l);
					if (itr == st[i].end()) continue;
					if (*itr <= r) res++;
				}
			}
			ans.push(res);
		}
	}
	while (!ans.empty()) {
		cout << ans.front() << endl;
		ans.pop();
	}
	return 0;
}

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

    vector<vector<bool>> is_w(100, vector<bool>(100, false));
    for (int i = 0; i < 50; i++) {
        fill(is_w[i].begin(), is_w[i].end(), true);
    }

    cout << 100 << " " << 100 << endl;
    A--;
    for (int i = 51; i < 100; i += 2) {
        for (int j = 1; j < 100 && A > 0; j += 2) {
            is_w[i][j] = true;
            A--;
        }
    }
    assert(A == 0);

    B--;
    for (int i = 1; i < 50; i += 2) {
        for (int j = 1; j < 100 && B > 0; j += 2) {
            is_w[i][j] = false;
            B--;
        }
    }
    assert(B == 0);

    for (auto const &row: is_w) {
        for (bool cell: row) {
            cout << (cell ? '.' : '#');
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Chars;
use std::collections::VecDeque;
use std::cmp::max;

fn main()
{
    input! {
    n:usize,
    edge:[Chars;n]
    }

    let mut ans = -1;
    'main: for i in 0..n {
        // 頂点iをv0に配置
        let mut v = vec![-1; n];
        let mut q = VecDeque::new();
        q.push_back((i, 0));
        v[i] = 0;

        let mut mx = 0;
        while let Some((idx, cst)) = q.pop_front() {
            let cst = cst + 1;
            for j in 0..n {
                if edge[idx][j] == '0' {
                    continue;
                }

                if v[j] >= 0 {
                    if cst % 2 != v[j] {
                        // 2分グラフでない
                        continue 'main;
                    }
                    continue;
                }
                v[j] = cst % 2;
                mx = max(mx, cst + 1);
                q.push_back((j, cst));
            }
        }
        ans = max(ans, mx);
    }

    println!("{}", ans);
}

Measured memory_bytes: 2400
#include <iostream>
#include <algorithm>
#include <vector>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef pair<int, int> pii;

int n, X;
int B[100001];
int L[100001];
int U[100001];

llong init;
llong val(int i) {
    return (llong)U[i] * (X - B[i]) + (llong)L[i] * B[i];
}
llong sum[100001];
vector<int> ord;

bool check(llong v) {
    if (v % X == 0) return 0 <= init + sum[v / X];
    for (int it = 1; it <= n; ++it) {
        int i = ord[it - 1];
        int ch = v % X;
        llong sum1;
        if (it <= v / X) sum1 = sum[v / X + 1] - val(i);
        else sum1 = sum[v / X];
        sum1 += init;
        sum1 += (llong)L[i] * B[i];
        sum1 += max((llong)U[i] * (ch - B[i]), (llong)L[i] * (ch - B[i]));
        if (0 <= sum1) return 1;
    }
    return 0;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> X;
    for (int i = 1; i <= n; ++i) {
        cin >> B[i] >> L[i] >> U[i];
        init -= (llong)L[i] * B[i];
    }
    for (int i = 1; i <= n; ++i) ord.push_back(i);
    sort(ord.begin(), ord.end(), [&](int a, int b) {
        return val(a) > val(b);
    });
    for (int it = 1; it <= n; ++it) {
        int i = ord[it - 1];
        sum[it] = sum[it - 1] + val(i);
    }
    llong s = 0, e = (llong)n * X;
    while (s < e) {
        llong m = (s + e) / 2;
        if (check(m)) e = m;
        else s = m + 1;
    }
    printf("%lld\n", s);
    return 0;
}

Measured memory_bytes: 2680
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)

int main() {
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A);
    rep(i,A) cin >> a[i];
    vector<int> b(B);
    rep(i,B) cin >> b[i];
    vector<vector<int>> xyc(M,vector<int>(3));
    rep(i,M){
        rep(j,3){
            int xycij; cin >> xycij;
            if(j != 2) xycij--;
            xyc[i][j] = xycij;
        }
    }
    int cost = 100000000;
    rep(i,M){
        int costi = a[xyc[i][0]]+b[xyc[i][1]]-xyc[i][2];
        cost = min(cost,costi);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    cost = min(cost,a[0]+b[0]);
    cout << cost << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int max_n = 200000;
int main() {
  int n,k;
  cin >> n >> k;
  vector<int> A(max_n,0);
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    A.at(a) ++;
  }
  sort(A.begin(),A.end());
  int ans;
  for(int i=0;i<max_n-k;i++){
    ans += A.at(i);
  }
  cout <<ans <<endl;
}
    
    
  




Measured memory_bytes: 1024
<>=~$";@a=glob`dd`;$a[$_-1]%2&&($%=$_%$'?$_:$_<$`*$'&&$_-1+$')&&++$a[$%]+push@_,[map{$_/$'+1|0,$_%$'+1}$_-1,$%]for 1..$`*$';print@_.$/,map"@$_
",@_

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

using namespace std;

vector<vector<int>> vv;
vector<pair<int, string>> v;
void dfs(int n, int c){
	for(int i=0; i< c; i++) cout << ".";
	cout << v[n].second << endl;
	for(int i=0; i < vv[n].size(); i++){
		dfs(vv[n][i], c+1);
	}
}

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

	v.push_back(make_pair(0, ""));
	for(int i=0; i < n; i++){
		int a; string b;
		cin >> a >> b;
		v.push_back(make_pair(a, b));
	}
	for(int i=0; i < v.size(); i++){
		vector<int> list;
		for(int j=i+1; j < v.size(); j++){
			if(i == v[j].first) list.push_back(j);
		}
		vv.push_back(list);
	}
	dfs(vv[0][0], 0);
}

Measured memory_bytes: 1452
#include <stdio.h>
int main(){
int a[11],i,j,tmp;
for(i=1;i<=10;i++)
  scanf("%d",a+i);
for(i=1;i<=9;i++)
 for(j=i+1;j<=10;j++)
   if(a[i] < a[j]) {
	   tmp=a[i];a[i]=a[j];a[j]=tmp;
	   }
printf("%d\n%d\n%d\n",a[1],a[2],a[3]);
return 0;	
}

Measured memory_bytes: 600
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<int>;


int main()
{
	int N, K;

	cin >> N >> K;

	if (K == 1)cout << 0 << endl;

	else cout << N - K << endl;

	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
path=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  path[a-1].append(b-1)
  path[b-1].append(a-1)
mod=10**9+7
stack=[0]
visited=[1]+[0]*(n-1)
ans=k
while stack:
  v=stack.pop(0)
  c=k-2 if v!=0 else k-1
  for d in path[v]:
    if visited[d]:
      continue
    visited[d]=1
    ans=(ans*c)%mod
    c-=1
    stack.append(d)
print(ans)

Measured memory_bytes: 23472
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 3002
using namespace std;
int head[N],ver[N*2],nxt[N*2],l;
int n,i,a[N],f[N];
int read()
{
	char c=getchar();
	int w=0;
	while(c<'0'||c>'9') c=getchar();
	while(c<='9'&&c>='0'){
		w=w*10+c-'0';
		c=getchar();
	}
	return w;
}
void insert(int x,int y)
{
	l++;
	ver[l]=y;
	nxt[l]=head[x];
	head[x]=l;
}
void dfs(int x,int pre)
{
	int minx=1<<30;
	for(int i=head[x];i;i=nxt[i]){
		int y=ver[i];
		if(y!=pre){
			dfs(y,x);
			if(!f[y]) minx=min(minx,a[y]);
		}
	}
	if(minx<a[x]) f[x]=1;
}
int main()
{
	n=read();
	for(i=1;i<=n;i++) a[i]=read();
	for(i=1;i<n;i++){
		int u=read(),v=read();
		insert(u,v);
		insert(v,u);
	}
	for(i=1;i<=n;i++){
		memset(f,0,sizeof(f));
		dfs(i,0);
		if(f[i]) printf("%d ",i);
	}
	puts("");
	return 0;
}

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

int N;
vector<int> g[100000];
int dist[2][100000], id;

void dfs(int idx, int par=-1){
	if(~par) dist[id][idx] = dist[id][par]+1;
	for(int j=0; j<g[idx].size(); j++) if(g[idx][j]!=par) dfs(g[idx][j], idx);
}

int main(){
	cin >> N;
	for(int i=0; i<N-1; i++){
		int a, b;
		cin >> a >> b;
		--a,--b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	id = 0;
	dfs(0);
	id = 1;
	dfs(N-1);
	
	int ret=0;
	for(int i=0; i<N; i++){
		if(dist[0][i]<=dist[1][i]) ++ret;
	}
	if(ret>=(N+2)/2) cout << "Fennec";
	else cout << "Snuke";
	return 0;
}

Measured memory_bytes: 11136
#include <iostream>
using namespace std;
int judge(int x)
{
  if(x==1||x==3||x==5||x==7||x==8||x==10||x==12)return 1;
  else if(x==4||x==6||x==9||x==11)return 2;
  else return 3;
}
int main(void)
{
  int x,y; cin>>x>>y;
  x=judge(x);
  y=judge(y);
  if(x==y)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}

Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a:usize = read();
    let b:usize = read();
    let mut arr = vec![1, 2, 3];
    arr.retain(|&x| x != a);
    arr.retain(|&x| x != b);
    println!("{}", arr[0]);
}


Measured memory_bytes: 4352
// Aizu Vol-1 0121: Seven Puzzle 
// 2017.8.4

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

char *gets(char *);
char buf[100], *p;

int getInt(void)
{
	while (isspace(*p)) p++;
	return *p++ - '0';
}

#define MAGIC 37

typedef struct { char x; int a; } T;
T s[50]; int top;

#define HASHSIZ 37003		// must > 20160
typedef struct { int s; char v; } NODE;
NODE nd[HASHSIZ+5], *hashend = nd + HASHSIZ;

int lookup(int s)
{
	NODE *np = nd + s % HASHSIZ;
	while (1) {
		if (np->s == s) return np->v;
		if (np->s == 0) break;
		if (++np == hashend) np = nd;
	}
	return 0;
}

void insert(int s, char v)
{
	NODE *np = nd + s % HASHSIZ;
	while (1) {
		if (np->s == 0) { np->s = s, np->v = v; break; }
		if (np->s == s) { np->v = v; break; }
		if (++np == hashend) np = nd;
	}
}

char to[8][4] = {
	{ 1, 4, 10 }, { 0, 2, 5, 10 }, { 1, 3, 6, 10 }, { 2, 7, 10 },
	{ 0, 5, 10 }, { 1, 4, 6, 10 }, { 2, 5, 7, 10 }, { 3, 6, 10 } };

int swap(int a, int x, int y)
{
	int i, aa[10];

	for (i = 7; i >= 0; i--) aa[i] = a % 10, a /= 10;
	a = aa[x], aa[x] = aa[y], aa[y] = a;
	for (a = 0, i = 0; i < 8; i++) a = 10 * a + aa[i];
	return a;
}

int main()
{
	int x, a, i, j, n;

	s[0].a = 1234567, s[0].x = 0, top = 1, insert(1234567, 1);
	while (top > 0) {
		x = s[--top].x, a = s[top].a, n = lookup(a) + 1;
		if (n > MAGIC) continue;
		for (i = 0; (j = to[x][i]) < 10; i++) {
			int k = swap(a, x, j);
			int m = lookup(k);
			if (!m || m > n) s[top].a = k, s[top++].x = j, insert(k, n);
		}
	}
	while (gets(p = buf) != NULL) {
		for (i = 0, a = 0; i < 8; i++) a = a * 10 + getInt();
		printf("%d\n", lookup(a) - 1);
	}
	return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, sum = 0;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		ll up = ( (n / i) * (n / i + 1) ) / 2;
		sum += i * up;
	}
	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 

const int mod = 1000000007;
const int inf = 1e9;

int main(){
    repn(i,1,9){
        repn(j,1,9){
            printf("%dx%d=%d\n",i,j,i*j);
        }
    }
    
}


Measured memory_bytes: 3104
#pragma GCC optimize("O2")
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<unordered_map>
#include<set>
#include<cmath>
#include<climits>
#include<random>
#include <iomanip>
#include <bitset>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
 
/////////////////////////////////////////////
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
///////////////////////////////
#define int long long

void solve(){

	int n;
	cin>>n;
	map<string,int> mp;

	while(n--){

		string s;
		cin>>s;
		mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<endl;
	cout<<"WA x "<<mp["WA"]<<endl;
	cout<<"TLE x "<<mp["TLE"]<<endl;
	cout<<"RE x "<<mp["RE"]<<endl;
}
 
signed main(){
 
	fast;
	int t = 1;
	//cin>>t;
	for(int i = 1 ; i <= t ; ++i)
		solve();
}


Measured memory_bytes: 3668
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
#include<time.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ")
#define pdd(a,n,m)for(int i=0;i<m;i++)pd(a,m)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

string s;
ll k;
ll dp[1111][2][5];
ll N[1111];

int main(){
  cin>>s>>k;
  int n=s.size();
  rep(i,n)N[i]=s[i]-'0';
  dp[0][0][0]=1;
  rep(i,n){
    rep(f,2){
      rep(j,4){
        for(int x=0;x<=(f?9:N[i]);x++){
          if(x!=0)dp[i+1][f||x<N[i]][j+1]+=dp[i][f][j];
          else dp[i+1][f||x<N[i]][j]+=dp[i][f][j];
        }
      }
    }
  }
  cout<<dp[n][0][k]+dp[n][1][k]<<endl;

  return 0;
}


Measured memory_bytes: 256