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

// #define ONLINE_JUDGE

#define V vector
#define P pair

using LL = long long;
#define FOR(i, x, y) \
    for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) \
    for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifndef ONLINE_JUDGE
#define dbg(x...)                             \
    do {                                      \
        cerr << "\033[32;1m" << #x << " -> "; \
        err(x);                               \
    } while (0)
void err() { cerr << "\033[39;0m" << endl; }
template <template <typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) {
    for (auto v : a) cerr << v << ' ';
    err(x...);
}
template <typename T, typename... A>
void err(T a, A... x) {
    cerr << a << ' ';
    err(x...);
}
#else
#define dbg(...)
#endif
#define sz(x) (int)x.size()

LL bin(LL a, LL b, LL p) {
    LL res = 1;
    a = (a % p + p) % p;
    for (; b; b >>= 1, a = a * a % p)
        if (b & 1) res = res * a % p;

    return res;
}

const int N = 1e5+50;


void solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (1) {
        c -= b;
        if (c <= 0) {
            puts("Yes");
            return;
        }
        a -= d;
        if (a <= 0) {
            puts("No");
            return;
        }
    }
    
}

int main() {

    // int t;
    // cin >> t;
    // while (t--) solve();

    solve();

    return 0;
}

Measured memory_bytes: 3636
import collections

n=int(input())
edges=[list(map(int,input().split())) for _ in range(n-1)]
g=[[] for _ in range(n+1)]
for i in range(n-1):
  a,b=edges[i]
  g[a].append(b)
  g[b].append(a)
k=0
pos=0
for i in range(n+1):
  if len(g[i])>k:
    k=len(g[i])
    pos=i
print(k)
dic={}
q=collections.deque()
q.append((pos,0))
checked=[0]*(n+1)
checked[pos]=1
while 1:
  if len(q)==0:
    break
  u,c=q.popleft()
  l=len(g[u])
  tcs=[i+1 for i in range(l)]
  if c in tcs:
    tcs.remove(c)
  pos=0
  for i in range(len(g[u])):
    v=g[u][i]
    if checked[v]==0:
      checked[v]=1
      q.append((v,tcs[pos]))
      dic[(u,v)]=tcs[pos]
      dic[(v,u)]=tcs[pos]
      pos+=1
for i in range(n-1):
  a,b=edges[i]
  print(dic[(a,b)])

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



int main(){
  int N,M;
  cin>>N>>M;
  
  vector<int> vec(N);
  vector<int> mus(2*M);
  for(int i=0;i<2*M;i++){
    cin>>mus.at(i);
  } 
  for(int i=0;i<2*M;i++){
    vec.at(mus.at(i)-1)+=1;
  }
  for(int i=0;i<N;i++){
    cout<<vec.at(i)<<endl;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long sa;
int main()
{
    ios_base::sync_with_stdio(false);
    sa s=0,i,n;
    cin>>n;
    //sa ara[200000];
    for(i=1;i<=n;i++)
    {
        if(i%3==0 || i%5==0)
            continue;
        else
        {
            s=s+i;
        }
    }
    cout<<s<<endl;
    return 0;
}


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

int main(){
  int H,W;

  while(1){
    cin>>H>>W;
    if(H==0 && W==0){
      break;
    }
    for(int i=0; i<H; i++){
      for(int j=0; j<W; j++){
        if((i+j)%2==0){
          cout<<"#";
        }else{
          cout<<".";
        }
      }
      cout<<endl;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision;
// #define int cpp_int
using namespace std;

#define fastio 			ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int 			long long
#define ll 				long long
#define ld 				long double
#define vi 				vector<int>
#define pii 			pair<int,int>
#define vpii 			vector< pair<int,int> >
#define uset			unordered_set
#define umap 			unordered_map
#define maxpq 			priority_queue<int>
#define minpq			priority_queue<int,vi,greater<int>()>

#define all(v) 			v.begin(),v.end()
#define part(v,s,e)		v.begin()+s,v.begin()+e
#define rev(v)			reverse(v.begin(),v.end())
#define sz(x)			(int)x.size()
#define def(v)			memset(v,-1,sizeof(v));
#define def0(v)			memset(v,0,sizeof(v));
#define minv(a)			*min_element(all(a))
#define maxv(a)			*max_element(all(a))
#define sumv(a)			accumulate(all(a),0)

#define	lb				lower_bound
#define	ub				upper_bound
#define	desc			greater<int>()
#define	pb				emplace_back
#define	mp				make_pair
#define	F				first
#define	S				second

#define	mod 			1000000007
#define	inf 			1000000000000000
#define infty			1000000000000000000LL
#define	md				998244353
#define	PI				acos(-1.0)
#define	endl 			"\n"
#define	rr				return
#define	br				cout<<"\n";

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a/(__gcd(a,b)))*b

#define setbits(x) 		__builtin_popcountll(x)
#define zerobits(x)		__builtin_ctzll(x)

#define ip(v)	 		for(auto& i:v)	cin>>i;
#define op(v) 			for(auto i:v)	cout<<i<<" ";cout<<endl;
#define deb(x) 			cout <<"Value of " #x << " : " << x << endl;



void solve()
{	

	int n;
	cin>>n;

	int a[n];
	ip(a);

	map<int,int>m;

	for(int i=0;i<n;i++)
	{
		m[a[i]]=i+1;
	}

	for(int i=0;i<n;i++)
	{
		cout<<m[i+1]<<" ";
	}

}	

int32_t main()
{

	fastio
	cout<<setprecision(15)<<fixed;



	int t=1;
	// cin>>t;
	
	for(int i=1;i<=t;i++)
	{
		// cout<<"Case "<<i<<" : "<<endl;
		solve();
	}
	
	#ifndef ONLINE_JUDGE	
		cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
	#endif

	return 0;
}

Measured memory_bytes: 7936
#include <iostream>
#include <vector>
#include <sstream>
#include <algorithm>

using namespace std;

struct NUM{
	int num;
	int sc;
};

int main() {

	vector<vector<NUM> > m;	
	while(!cin.eof()){
		string str;
		cin >> str;
		int cnt = count_if(str.begin(),str.end(),[](char c){return c==',';});
		
		vector<NUM> v;
		stringstream  st(str);
		for(int i=0;i<=cnt;i++){
			char c;
			if(i>0) st >> c;
			int n;
			st >> n;
			v.push_back({n,0});
		}
//		cout << v.size() << endl;
		m.push_back(v);
		if( m.size()>1 && v.size()==1)break;
	}

	m[0][0].sc=m[0][0].num;
	for(int i=1;i<m.size();i++){
		for(int x=0;x<m[i].size();x++){
			if( m[i].size()>m[i-1].size() ){
				if( x==0 ){
					m[i][x].sc=m[i][x].num + m[i-1][x].sc;
				}
				else if( x==m[i].size()-1 ){
					m[i][x].sc=m[i][x].num + m[i-1][x-1].sc;
				}else{
					m[i][x].sc=max(
						m[i][x].num + m[i-1][x].sc,
						m[i][x].num + m[i-1][x-1].sc);
				}
			}else{
				m[i][x].sc=max(
					m[i][x].num + m[i-1][x].sc,
					m[i][x].num + m[i-1][x+1].sc);
			}
		}
	}

	cout << m.back().front().sc << endl;

	return 0;
}

Measured memory_bytes: 1272
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )
import Data.List


cReadLn :: IO Int
cReadLn = fst . fromJust . C.readInt <$> C.getLine

getParms :: IO [Int]
getParms = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [n,k] <- getParms
  as    <- getParms
  print $ f n k as

f :: Int -> Int -> [Int] -> Int
f n k as 
  | k >= l = 0
  | k <  l = g as'' (l-k) 0
  where
    as'  = group . sort $ as
    l    = length as'
    as'' = map length $ sortOn length as'

    g :: [Int] -> Int -> Int -> Int
    g _      0 x = x
    g (b:bs) k x = g bs (k-1) (x + b)

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

int main() {
int n;
  cin >> n;
 vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int count1, count2;
  if ((n / 2) * 2 == n) {
    for (int i = 0; i < n / 2; i++) {
    count1+= vec.at(2 * i);
    count2+= vec.at(2 * i + 1);
    }
  } 
   else {
      for (int i = 0; i < n / 2; i++) {
    count1+= vec.at(2 * i);
    count2+= vec.at(2 * i + 1);
    }
  count1+= vec.at(n - 1);
   } 
      cout << count1 - count2 << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class HashTable {
    final static int M = 1046257;
    String[] table;

    HashTable() {
        table = new String[M];
    }

    int toInt(char c) {
        switch (c) {
            case 'A':
                return 1;
            case 'C':
                return 2;
            case 'G':
                return 3;
            case 'T':
                return 4;
            default:
                return 0;
        }
    }

    int toKey(String s) {
        int sum = 0, p = 1;
        for (char c : s.toCharArray()) {
            sum += p * toInt(c);
            p *= 5;
        }
        return sum;
    }

    int h1(int key) {
        return key % M;
    }

    int h2(int key) {
        return 1 + (key % (M - 1));
    }

    void insert(String s) {
        int key = toKey(s);
        int i = 0;
        while (true) {
            int hash = (h1(key) + i * h2(key)) % M;
            if (table[hash] == null) {
                table[hash] = s;
                break;
            }
            i++;
        }
    }

    String find(String s) {
        int key = toKey(s);
        int i = 0;
        while (true) {
            int hash = (h1(key) + i * h2(key)) % M;
            if (table[hash] == null) {
                return null;
            } else if (table[hash].equals(s)) {
                return table[hash];
            }
            i++;
        }
    }
}

public class Main {
    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
            int n = Integer.parseInt(in.readLine());
            HashTable table = new HashTable();
            String[] line;
            for (int i = 0; i < n; i++) {
                line = in.readLine().split(" ");
                if (line[0].startsWith("i")) {
                    table.insert(line[1]);
                } else if (line[0].startsWith("f")) {
                    String found = table.find(line[1]);
                    if (found == null) {
                        System.out.println("no");
                    } else {
                        System.out.println("yes");
                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}



Measured memory_bytes: 197020
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define rrep(i,n) for (int i=(int)(n)-1; i>=0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
template<typename T> using Graph = vector<vector<T>>;
template<typename T> using Spacial = vector<vector<vector<T>>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

template<typename T> struct is_pair : false_type{};
template<typename T1, typename T2> struct is_pair<pair<T1, T2>> : true_type{};
template<typename T> struct is_vector : false_type{};
template<typename T> struct is_vector<vector<T>> : true_type{};

template<typename T1, typename T2>
istream &operator >> (istream &istr, pair<T1, T2> &p) {
  istr >> p.first >> p.second;
  return istr;
} 
template<typename T1, typename T2>
ostream &operator << (ostream &ostr, const pair<T1, T2> &p) {
  ostr << p.first << " " << p.second;
  return ostr;
}
template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) return ostr;
  bool vp = is_vector<T>() || is_pair<T>();
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    ostr << (vp ? "\n" : " ") << *itr;
  }
  return ostr;
}

template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

int modpow(int a, long long n, int mod = MOD) {
  int ret = 1;
  do {
    if (n & 1) ret = 1LL * ret * a % mod;
    a = 1LL * a * a % mod;
  } while (n >>= 1);
  return ret;
}

template<typename T>
T GCD(T a, T b) { return b ? GCD(b, a%b) : a; }
template<typename T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

template<typename T1, typename T2>
bool CompareBySecond(pair<T1, T2> a, pair<T1, T2> b) {
  return a.second != b.second ? a.second < b.second : a.first < b.first;
}
template<typename T>
bool CompareBySlope(pair<T, T> a, pair<T, T> b) {
// counterclockwise from 12 o'clock direction
  if (a.first * b.first < 0) return a.first < b.first;
  if (a.first == 0) return a.second >= 0 || b.first > 0;
  if (b.first == 0) return b.second < 0 && a.first < 0;
  return a.second * b.first < a.first * b.second;
}


/* -------- <templates end> -------- */


void solve() {
  int n, k; cin >> n >> k;
  vi hp(n);
  rep(i,n) cin >> hp[i];
  sort(RALL(hp));
  int ans = 0;
  for (int i=k; i<n; ++i) {
    ans += hp[i];
  }
  cout << ans << endl;
}


/* -------- <programs end> -------- */


signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


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

const long long INF = 1LL << 50;

int main(void){

    int N, M; cin >> N >> M;

    const int NMAX = 1000;
    const int MMAX = 2000;
    int a[MMAX], b[MMAX];
    long long c[MMAX];

    for(int i = 0; i < M; i++){
        cin >> a[i] >> b[i] >> c[i];
        c[i] = -c[i];
    }

    long long dist[NMAX];
    for(int i = 0; i < N; i++){
        dist[i] = INF;
    }

    dist[0] = 0;

    for(int loop = 0; loop < N-1; loop++){
        for(int i = 0; i < M; i++){
            if(dist[a[i] - 1] == INF) continue;

            if(dist[b[i] - 1] > dist[a[i] - 1] + c[i]){
                dist[b[i] - 1] = dist[a[i] - 1] + c[i];
            }
        }
    }

    long long ans = dist[N - 1];

    bool negative[NMAX];
    for(int i = 0; i < N; i++){
        negative[i] = false;
    }

    for(int loop = 0; loop < N; loop++){
        for(int i = 0; i < M; i++){
            if(dist[a[i] - 1] == INF) continue;

            if(dist[b[i] - 1] > dist[a[i] - 1] + c[i]){
                dist[b[i] - 1] = dist[a[i] - 1] + c[i];
                negative[b[i] - 1] = true;
            }
            if(negative[a[i] - 1] == true) negative[b[i] - 1] = true;
        }
    }

    if(negative[N - 1]) cout << "inf" << endl;
    else cout << -ans << endl;

    return 0;
}

Measured memory_bytes: 256
s=input()
a=s[0:2]
b=s[2:]
if a != "00" and int(a) <= 12:
    if b != "00" and int(b) <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif b != "00" and int(b) <= 12:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a, b;
	cin >> a >> b;
	if(a == 1 && b == 1)
	{
		cout << "1";
	}
	else if(a == 1)
	{
		cout << b - 2 << '\n';
	}
	else if(b == 1)
	{
		cout << a - 2 << '\n';
	}
	else
	{
		long long ans = a * b;
		ans -= (a * 2);
		ans -= (b * 2);
		ans += (long long)4;
		cout << ans << '\n';
	}
	return 0;
}

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

using namespace std;

#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)

int main() {

  int n;
  cin >> n;
  vector<int> count(n, 0);
  Rep(i, n - 1) {
    int a;
    cin >> a;
    count[a - 1]++;
  }

  Rep(i, n) {
    cout << count[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 4048
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int n;
    cin>>n;
    v(string) x(n);
    for(int i = 0 ; i < n ; i++ ){
        cin>>x[i];
        sort(x[i].begin() , x[i].end());
    }
    sort(x.begin() , x.end());
    int ans = 0;
    for(int i = 0 ; i< n ; ){
        int j = i;
        int c = 0;
        while(j < n && x[i] == x[j]){
            c++;
            j++;
        }
        ans += c * (c - 1) / 2;
        i = j;
    }
    cout<<ans<<endl;

}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 5760
from functools import reduce

MOD = 10**9 + 7
n, a, b = map(int, input().split())

def combination2(n, r, MOD=10**9+7):
    if not 0 <= r <= n: return 0
    r = min(r, n - r)
    numerator = reduce(lambda x, y: x * y % MOD, range(n, n - r, -1), 1)
    denominator = reduce(lambda x, y: x * y % MOD, range(1, r + 1), 1)
    return numerator * pow(denominator, MOD - 2, MOD) % MOD

print((pow(2,n,MOD) - combination2(n,a) - combination2(n,b)-1)%MOD)

Measured memory_bytes: 73552
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)


#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
"""
#バケット法行こうか
"""
#solution:
N,=pin()#第一引数
ans=0
htbacket=[[0]*10 for i in range(10)]
for i in range(1,N+1):
    a=int(str(i)[0])#先頭と末尾
    b=int(str(i)[-1])
    htbacket[a][b]+=1
#print(htbacket)

for i in range(10):
    for j in range(10):
        pass
        #htbacket[a],[b]とペアを取れる数を列挙したい
        if i==j:
            ans+=htbacket[i][j]**2
        else:
            ans+=htbacket[i][j]*htbacket[j][i]
print(ans)
#print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""

Measured memory_bytes: 70632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  string w;
  cin >> w;
  map<char, int> m;

  for(char c: w) {
    m[c]++;
  }

  for(auto i = m.begin(); i != m.end(); ++i) {
    if (i->second % 2 != 0) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 3640
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n = I()
G = [[] for _ in range(n)]
for _ in range(n-1):
    a,b=LI()
    G[a-1]+=[b-1]
    G[b - 1] += [a - 1]


def dfs(v, visited):
    """
    :param v: X側の未マッチングの頂点の1つ
    :param visited: 空のsetを渡す（外部からの呼び出し時）
    :return: 増大路が見つかればTrue
    """
    for u in G[v]:
        if u in visited:
            continue
        visited.add(u)
        if matched[u] == -1 or dfs(matched[u], visited):
            matched[u] = v
            return True
    return False

cnt = 0
matched = [-1] * n
for i in range(n):
    cnt += int(dfs(i, set()))

if cnt == n:
    print("Second")
else:
    print("First")





Measured memory_bytes: 100132
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	k := nextInt()

	// nがkの倍数であればy=0に収束する
	if n%k == 0 {
		fmt.Println(0)
		return
	}

	// y=x とy=abs(x-k)の交点より、nが左にいるならそのままnを出す
	// n<k/2 をfloatとか使わないで かいた
	if n*2 < k {
		fmt.Println(n)
		return
	}

	fmt.Println(abs(n%k - k))

}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

long long N;

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= 3500; i++) {
		for (int j = 1; j <= 3500; j++) {
			int h = i, n = j;
			long long denom = 4ll * h * n - N * h - N * n;
			long long numer = (long long)N * h * n;
			if (denom != 0 && numer % denom == 0 && numer/denom > 0) {
				printf("%d %d %lld\n", i, j, numer/denom);
				return 0;
			}
		}
	}
}


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

int main(){
double x,y,a,b;
cin >>x >>y;
b=(-2*x+y)/2;
a=x-b;
  //cout <<a <<" " <<b;
  if((a<0 || b<0)  ) cout <<"No" <<endl;
else if(ceil(a) != floor(a) ||ceil(b) != floor(b) ){ //切り上げも切り捨ても等しくない＝小数
   cout <<"No" <<endl;
}
  else if(a+b==x && 2*a+4*b==y) cout <<"Yes" <<endl;
  else cout <<"No" <<endl;
return 0;
}

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

int main(){
  string n;
  int sa;
  int ans=100000;
  cin >> n;
  for(int i=0;i<n.size()-2;i++){
    sa = abs(753-(((n[i]-'0')*100+(n[i+1]-'0')*10+(n[i+2]-'0'))));
    if(ans>sa){
      ans=sa;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include "stdio.h"

int main(void){
  int x,y,z,i,j,b,f,r,v;
  scanf("%d", &x);
  int a[12][10];
  for(i = 0; i < 12; i++){
    for(j = 0; j < 10; j++){
      a[i][j] = 0;
    }
  }
  for(i = 0; i < x; i++){
    scanf("%d %d %d %d", &b, &f, &r, &v);
    a[3*(b-1)+f-1][r-1] += v;
  }
  for(i = 0; i < 12; i++){
    for(j = 0; j < 10; j++){
      printf(" %d", a[i][j]);
    }
      printf("\n");
    if((i==2) || (i==5) || (i==8)){

      puts("####################");

    }

  }
}



Measured memory_bytes: 2036
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Modular
    {
        private const int M = 1000000007;
        private long value;

        public Modular(long value) { this.value = value; }
        public static implicit operator Modular(long a)
        {
            var m = a % M;
            return new Modular((m < 0) ? m + M : m);
        }
        public static Modular operator +(Modular a, Modular b) { return a.value + b.value; }
        public static Modular operator -(Modular a, Modular b) { return a.value - b.value; }
        public static Modular operator *(Modular a, Modular b) { return a.value * b.value; }
        private static Modular Pow(Modular a, int n)
        {
            switch (n)
            {
            case 0:
                return 1;
            case 1:
                return a;
            default:
                var p = Pow(a, n / 2);
                return p * p * Pow(a, n % 2);
            }
        }
        public static Modular operator /(Modular a, Modular b) { return a * Pow(b, M - 2); }
        private static readonly List<int> facs = new List<int> { 1 };
        private static Modular Fac(int n)
        {
            for (int i = facs.Count; i <= n; ++i) { facs.Add((int)(Math.BigMul(facs.Last(), i) % M)); }
            return facs[n];
        }
        public static Modular Ncr(int n, int r)
        {
            return (n < r) ? 0
                 : (n == r) ? 1
                            : Fac(n) / (Fac(r) * Fac(n - r));
        }
        public static explicit operator int(Modular a) { return (int)a.value; }
    }

    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(int X, int Y)
        {
            if ((X + Y) % 3 == 0)
            {
                int n = (X + Y) / 3;
                int r = X - n;
                return (0 <= r && r <= n) ? (int)Modular.Ncr(n, r) : 0;
            }
            return 0;
        }

        static void Main(string[] args)
        {
            var V = ReadInts();
            Console.WriteLine(Solve(V[0], V[1]));
        }
    }
}


Measured memory_bytes: 18272
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#include <unordered_map>


using namespace std;
typedef long long ll;

int main(){
    // read in lleger 
    ll n;
    
    multiset<ll> s; 
    unordered_map<ll, ll>m;
    std::unordered_map<ll,ll>::iterator it;

    cin >> n;
    vector<ll> a (n, 0);

    REP(i, n) {
        cin >> a[i];
        m[a[i]]++;
    }

    ll total = 0;
    for(auto iter = m.begin(); iter != m.end(); ++iter){
        // ll k = iter->first;
        ll v = iter->second;
        total += v * (v-1)/2;
    }
 
    // cout << total << endl;
    REP(i, n){
        it = m.find(a[i]);
        ll val = it->second;
        cout << total - val + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 10312
open Printf
open Scanf

let () =
  let n, m, k = scanf "%d %d %d " (fun x y z -> (x, y, z)) in
  let rec loop i j =
    if i > n then "No"
    else if j > m then loop (i+1) 0
    else if m * i + n * j - 2 * i * j = k then "Yes"
    else loop i (j+1) in
  loop 0 0 |> printf "%s\n"


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
const int  nmax = 200001;
vector<int> graph[nmax];
bool visited[nmax];
vector <ll>value(nmax,0);

int dfs(int i,int n,int num){
    value[i]+=num;
    visited[i]=true;
    for(int v:graph[i]){
        if(visited[v])continue;
        dfs(v,n,value[i]);
    }
    return 0;
}

int main(){
    int n,q;
    cin >> n >> q;
    ll a[n],b[n];
    ll p[q],x[q];
    
    REP(i,n-1){
        cin >> a[i] >> b[i];
        graph[a[i]].push_back(b[i]);
        graph[b[i]].push_back(a[i]);
    }
    REP(i,q){
        cin >> p[i] >> x[i];
        value[p[i]]+=x[i];
    }
    
    dfs(1,n,0);
    FOR(i,1,n+1){
        cout << value[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 30720
#include<algorithm>
#include<bitset>
#include<iostream>
#include<iomanip>
#include<set>
#include<string>
#include<math.h>
#include<stack>
#include<string>
#include<queue>
#include<vector>
using namespace std;
typedef long long int ll;
typedef pair<int, ll> P;

//--------------
///#define DEBUG
//--------------

#ifdef DEBUG
	#define debugprint(x) cout<<x<<" "
	#define debugendl cout<<endl
	#define debug(x) x
#else
	#define debugprint(x)
	#define debugendl
	#define debug(x)
#endif

class zahyo{
	public:
	int x;
	int y;
	zahyo(){
		x=0;
		y=0;
	}
	zahyo(int x_,int y_){
		x=x_;
		y=y_;
	}
	void print(){
		cout<<x<<" "<<y;
	}
	zahyo operator+(zahyo add){
		add.x=this->x+add.x;
		add.y=this->y+add.y;
		return add;
	}
	zahyo operator-(zahyo add){
		add.x=this->x-add.x;
		add.y=this->y-add.y;
		return add;
	}
	zahyo operator*(int t){
		zahyo temp;
		temp.x=this->x*t;
		temp.y=this->y*t;
		return temp;
	}
	zahyo operator%(int t){
		zahyo temp(this->x%t,this->y%t);
		return temp;
	}
	zahyo operator/(int t){
		zahyo temp(this->x/t,this->y/t);
		return temp;
	}
	bool operator==(const zahyo add) const{
		if(add.x==this->x and add.y==this->y){return true;}
		else{return false;}
	}
	bool operator!=(const zahyo add) const{
		if(add.x==this->x or add.y==this->y){return false;}
		else{return true;}
	}
	bool operator<(const zahyo add) const{
		if(this->x<add.x){return true;}
		else if(this->x==add.x and this->y<add.y){return true;}
		else{return false;}
	}
	bool operator>(const zahyo add) const{
		if(this->x>add.x){return true;}
		else if(this->x==add.x and this->y>add.y){return true;}
		else{return false;}
	}
	void input(){
		cin>>x>>y;
	}
};

int main(){
	string a,b;
	cin>>a>>b;
	int ans=0;
	for(int i=0;i<=a.size()-b.size();i++){
		int temp=0;
		for(int j=0;j<b.size();j++){
			if(a[i+j]==b[j]){
				temp++;
			}
		}
		ans=max(ans,temp);
	}
	cout<<b.size()-ans<<endl;

}


Measured memory_bytes: 3620
N, K = map(int, input().split())
kaijo = [i for i in range(N)]
for i in range(1, N + 1):
    tmp = i
    j = 0
    while True:
        if tmp >= K:
            kaijo[i - 1] = j
            break
        tmp *= 2
        j += 1
ans = sum(pow(0.5, i) for i in kaijo)
print(ans / N)


Measured memory_bytes: 45680
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	static int mod = 1000000007;
	static List<List<Integer>> list;
	static long[] dp0, dp1;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		list = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			list.add(new ArrayList<>());
		}
		for (int i = 0; i < n - 1; i++) {
			sa = br.readLine().split(" ");
			int x = Integer.parseInt(sa[0]) - 1;
			int y = Integer.parseInt(sa[1]) - 1;
			list.get(x).add(y);
			list.get(y).add(x);
		}
		br.close();

		dp0 = new long[n];
		dp1 = new long[n];
		dfs(0, -1);
		System.out.println((dp0[0] + dp1[0]) % mod);
	}

	static void dfs(int cur, int p) {
		dp0[cur] = 1;
		dp1[cur] = 1;
		for (int next : list.get(cur)) {
			if (next == p) {
				continue;
			}
			dfs(next, cur);
			dp1[cur] *= dp0[next];
			dp1[cur] %= mod;
			dp0[cur] *= (dp0[next] + dp1[next]);
			dp0[cur] %= mod;
		}
	}
}


Measured memory_bytes: 80240
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> ans(10001);
    for (int i = 1; i <= 100; ++i) {
        for (int j = 1; j <= 100; ++j) {
            for (int k = 1; k <= 100; ++k) {
                int val = i*i+j*j+k*k+i*j+j*k+k*i;
                if(val <= 10000){
                    ans[val]++;
                }
            }
        }
    }
    for (int i = 1; i <= n; ++i) {
        cout << ans[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long LLINF = 1LL<<60;
const int INF = 1e9;
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; }
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

struct UnionFind {
    int n;
    vector<int> par; 

    UnionFind(int N) : par(N) { 
        for(int i = 0; i < N; i++) par[i] = i;
        n = N;
    }

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

    void unite(int x, int y) { 
        int rx = root(x); 
        int ry = root(y); 
        if (rx == ry) return;
        n--;
        par[rx] = ry; 
    }

    bool same(int x, int y) { 
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size() {return n;}
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m; cin >> n >> m;
    UnionFind tree(n);
    rep(i,m) {
        int u,v,z; cin >> u >> v >> z;
        u--; v--;
        tree.unite(u,v);
    }
    cout << tree.size() << endl;

    return 0;
}

Measured memory_bytes: 768
/*
author: Apoorv Singh
*/

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

typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " " << (x) << endl;
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
#define FORR(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"

int modulo = 1e9 + 7;

template <class X>

void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}

int fpow(int a, int n)
{
    int ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m; cin >> n >> m;
    int dp[n+1] = {0}; dp[0] = 1;
    int arr[n+1] = {0};
    FOR(i,0,m) 
    {
        int x; cin >> x;
        arr[x] = 1;
    }
    FOR(i,0,n)
    {
        if (!arr[i+1]) dp[i+1] = (dp[i+1] + dp[i])%modulo;
        if (i+2 <= n and !arr[i+2]) dp[i+2] = (dp[i+2] + dp[i])%modulo;
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

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

int main()
{
	int n, k;
	cin>>n>>k;
	if(n%k==0){
		cout<<0<<endl;
	}else{
		cout<<1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


using namespace std;


#define all(c) c.begin(), c.end()


// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}

template<class T>
vector<T> next_vec(istream& in, size_t n) {
  vector<T> ret(n);
  for (size_t i = 0; i < n; ++i) {
    ret[i] = next<T>(in);
  }
  return ret;
}


void solve(istream& in, ostream& out) {
  auto n = next<int>(in);
  auto a = next_vec<int>(in, 2 * n);
  sort(all(a));
  int res = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    res += a[i];
  }
  out << res << "\n";
}

//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
const int mod = 1e9 + 7;
const int INF = 1e9;
using namespace std;
typedef long long ll;

int main()
{
    string A,B,C;
    cin >> A >> B >> C;
    int a=0,b=0,c=0,d=0;
    while(true){
        if(d == 0){
            d = A[a] - 'a';
            a++;
        }else if(d == 1){
            d = B[b] - 'a';
            b++;
        }else if(d == 2){
            d = C[c] - 'a';
            c++;
        }
        if(a == A.size() && d == 0){
            cout << 'A';
            return 0;
        }else if(b == B.size() && d == 1){
            cout << 'B';
            return 0;
        }else if(c == C.size() && d == 2){ 
            cout << 'C';
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	string s,t; cin>>s>>t;
	s += t;
	int a = stoi(s); int b = sqrt(a);
	cout<<(b * b == a ? "Yes" : "No")<<endl;
}

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

int main(){
    int A,B;
    cin>>A>>B;
    int ans =0;
    for(int i=A; i<=B; i++){
      string II = to_string(i);
      if(II[0]==II[4]&&II[1]==II[3]){
        ans++;
      }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n,a,b;
    long f,s,t;
    cin >> n >> a >> b;
    vector<int> p(n);
    for(int i = 0; i < p.size(); ++i){
        cin >> p[i];
    }
    
    f = count_if(p.begin(), p.end(), bind2nd(less_equal<int>(),a));
    t = count_if(p.begin(), p.end(), bind2nd(greater_equal<int>(),b+1));
    s = n - (f+t);
    
    cout << min(f , min(s, t)) << endl;
}


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

using namespace std;
const int MAXN = 101;
int w[MAXN];
int v[MAXN];
long long dp[MAXN][100001];

int main()
{
    int N, W;
    cin >> N >> W;
    for(int i = 1; i <= N; i++) cin >> w[i] >> v[i];
    int best = 0;
    for(int i = 0; i <= N; i++)
    {
        for(int j = 0; j <= 100000; j++)
        {
            if(i==0||j==0)
            {
                dp[i][j] = 0;
                continue;
            }
            dp[i][j] = dp[i-1][j];
            if(v[i]>j) continue;
            if(v[i]==j&&(w[i]<dp[i][j]||dp[i][j]==0)) dp[i][j] = w[i];
            if(dp[i-1][j-v[i]]!=0&&(w[i]+dp[i-1][j-v[i]]<dp[i][j]||dp[i][j]==0)) dp[i][j] = w[i]+dp[i-1][j-v[i]];
            if(dp[i][j]!=0&&j>best&&dp[i][j]<=W) best = j;
        }
    }
    cout << best;
}

Measured memory_bytes: 79104
#include <cstdio>
#include <iostream>
#include <tgmath.h>
#include <queue>
#include <cstring>
#include <map>
#include <set>
typedef long long ll;
using namespace std;

int N,K,L;

int p,q,r,s;


struct UnionFind{
vector<int> par;
vector<int> rankTree;


void init(int n){
    for(int i=0;i<n;i++){
        par.push_back(i);
        rankTree.push_back(i);
    }    
}

int find(int x){
    if(par[x] == x){
        return x;
    }
    return find(par[x]);
}

bool same(int x,int y){
    return find(x) == find(y);
}

void unite(int x, int y){
    if(same(x,y)){
        return;
    }

    int rootx = find(x);
    int rooty = find(y);
    
    if(rankTree[rootx] < rankTree[rooty]){
        par[rootx] = rooty;
        return;
    }
    par[rooty] = rootx;
    if(rankTree[rootx] == rankTree[rooty]){
        rankTree[rootx] ++;
    }
}
};





int main(){
    cin >>N >> K>> L;
    UnionFind u1 = UnionFind();
    u1.init(N+1);
    UnionFind u2 = UnionFind();
    u2.init(N+1);
    for(int i=0;i<K;i++){
        cin >> p >> q;
        u1.unite(p,q);
    }
    for(int i=0; i<L;i++){
        cin >> r >> s;
        u2.unite(r,s);
    }
    map<pair<int,int>,int> m;
    for(int i=1; i<=N; i++){
        // cout << "i="<< u1.find(i) << "i="<< u2.find(i) << "ans="<<ans[u1.find(i)][u2.find(i)]  <<endl;

        m[make_pair(u1.find(i),u2.find(i))]++;
        // cout << "i="<< u1.find(i) << "i="<< u2.find(i) << "ans="<<ans[u1.find(i)][u2.find(i)]  <<endl;
    }
    for(int i=1;i<=N;i++){
        cout << m[make_pair(u1.find(i),u2.find(i))] << " ";
    }
    cout << endl;
    return 0;

}

Measured memory_bytes: 15124
import sys
import math
def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
n = II()
a = LI()
a.sort(reverse=True)
ans = 0
for i in range(1,n):
	ans+=a[i-math.ceil(i/2)]
print(ans)

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

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

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll MOD = TEN(9) + 7;
const int MX = TEN(6) * 2 + 10;

ll inv[MX], fact[MX], ifact[MX];

void init() {
    inv[1] = 1;
    for (int i = 2; i < MX; ++i) {
        inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
    }
    fact[0] = ifact[0] = 1;
    for (int i = 1; i < MX; ++i) {
        fact[i] = fact[i-1] * i % MOD;
        ifact[i] = ifact[i-1] * inv[i] % MOD;
    }
}

ll comb(int n, int r) {
    if (n < 0 || r < 0 || r > n) return 0;
    return fact[n] * ifact[r] % MOD * ifact[n - r] % MOD;
}

inline ll way(int p, int q) {
	return comb(p + q, p);
}

int main() {
	init();

	vector<int> X(6), Y(6);
	rep(i, 6) cin >> X[i];
	rep(i, 6) cin >> Y[i];

	ll ans = 0;

	vector<pair<pii, int>> vl = {mp(mp(X[0]-1,Y[0]-1),1),mp(mp(X[0]-1,Y[1]),-1),mp(mp(X[1],Y[0]-1),-1),mp(mp(X[1],Y[1]),1)};
	vector<pair<pii, int>> vr = {mp(mp(X[4],Y[4]),1),mp(mp(X[5]+1,Y[4]),-1),mp(mp(X[4],Y[5]+1),-1),mp(mp(X[5]+1,Y[5]+1),1)};
	vector<pair<pair<pii, pii>, int>> edges;

	for (int i = X[2]; i <= X[3]; ++i) {
		edges.eb(mp(mp(i, Y[2]-1), mp(i, Y[2])), -i - Y[2]);
		edges.eb(mp(mp(i, Y[3]), mp(i, Y[3]+1)), i + Y[3] + 1);		
	}

	for (int i = Y[2]; i <= Y[3]; ++i) {
		edges.eb(mp(mp(X[2]-1, i), mp(X[2], i)), -i - X[2]);
		edges.eb(mp(mp(X[3], i), mp(X[3]+1, i)), i + X[3] + 1);	
	}

	for (auto p : vl) {
		for (auto q : vr) {
			for (auto e : edges) {
				ll c = way(e.fi.fi.fi - p.fi.fi, e.fi.fi.se - p.fi.se) * way(q.fi.fi - e.fi.se.fi, q.fi.se - e.fi.se.se) % MOD;
				c = c * p.se * q.se * e.se % MOD;
				if (c < 0) c += MOD;
				ans += c;
				if (ans >= MOD) ans -= MOD;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 131040
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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 double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int k;
    string s;
    cin >> k >> s;
    for (int i = 0; i < min((int)s.size(), k); ++i) cout << s[i];
    if (s.size() > k) cout << "...";
    cout << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int64_t N, K, S;
    cin >> N >> K >> S;
    int64_t S_zurasi = S + 1;
    if (S == 1000000000) {
        S_zurasi = S - 1;
    }
    for (int i=0; i < N; i++) {
        if (i < K) {
            cout << S;
        } else {
            cout << S_zurasi;
        }

        if (i < N-1) {
            cout << " ";
        }
    }

    cout << endl;
    return 0;
}

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

int main()
{
	int n, m, p, x;
	int result = 0;
	cin >> n;
	int t[n];

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

	cin >> m;

	for (int i = 0; i < m; i++)
	{
		cin >> p >> x;

		cout << result - (t[p-1] - x) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import sys

N = int(sys.stdin.readline())
A = map(int, sys.stdin.readline().split())

mod = 10**9 + 7

cnt = [0] * 61
for a in A:
    for i in range(61):
        if a >> i & 1:
            cnt[i] += 1

ans = 0
p = 1
for i in cnt:
    ans = (ans + (p * i * (N - i)) % mod) % mod
    # ans %= mod
    p = p * 2 % mod
    # p %= mod

print(ans % mod)


Measured memory_bytes: 123132