akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 2305843009213693951
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define all1(i) begin(i),end(i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

class unionfind{
    /*
    Copyright (c) 2020 0214sh7
    https://github.com/0214sh7/library/
    */
    private:
    std::vector<int> UF,rank;
    public:
    
    void init(int N){
        UF.clear();
        rank.clear();
        for(int i=0;i<N;i++){
            UF.push_back(i);
            rank.push_back(0);
        }
    }
    
    int root(int k){
        if(UF[k]==k){
            return k;
        }else{
            UF[k]=root(UF[k]);
            return UF[k];
        }
    }
    
    bool same(int p,int q){
        return root(p)==root(q);
    }
    
    void unite(int P,int Q){
        int p=root(P);
        int q=root(Q);
        if(p==q)return;
        if(rank[p]<rank[q])std::swap(p,q);
        UF[q]=p;
        if(rank[p]==rank[q])rank[p]++;
    }
    
};

int main(void){
    ll N,M;
    ll a,b;
    vector<ll> A,B;
    
    cin >> N >> M;
    REP(i,M){
        cin >> a >> b;
        a--;b--;
        A.push_back(a);
        B.push_back(b);
    }
    
    unionfind UF;
    UF.init(N);
    
    REP(i,M){
        UF.unite(A[i],B[i]);
    }
    
    vector<ll> C(N,0);
    REP(i,N){
        C[UF.root(i)]++;
    }
    
    ll Ans=0;
    REP(i,N){
        Ans=max(Ans,C[i]);
    }
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 10744
n, y = map(int, input().split())
resa, resb, resc = -1, -1, -1
for a in range(n + 1):
    for b in range(n + 1 - a):
        c = n - a - b
        total = 10000 * a + 5000 * b + 1000 * c
        if total == y:
            resa, resb, resc = a, b, c
print(resa, resb, resc)


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
	


int main() {
	char X, Y;
	cin >> X >> Y;
	cout << (X < Y ? '<' : (X == Y ? '=' : '>')) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;


int main(){
	ll N,K; cin >> N >> K;
    vector<ll> A(N,0);
    REP(i,N) { cin >> A[i]; A[i]--; } //0-indexed
    vector<bool> visited(N,false);
    visited[0] = true;
    ll now = 0, target;
    vector<ll> list;
    while(1){
      list.push_back(now); //0-indexed
      visited[now] = true;
      now = A[now];
      if(visited[now]){ target = now; break;}
    }
    vector<ll> list2;
    ll a = 0, b;
    REP(i,list.size()){
      if(list[i] == target && a == 0) b = i; 
      if(list[i] == target) a++;
      if(a == 2) break;
      if(a == 1) list2.push_back(list[i]);
    }
    if(K < b) cout << list[K] + 1;
    else
    {
		    K -= b;
    		K %= list2.size();
    		//REP(i,list2.size()) cout << list2[i] + 1; //1-indexed
    		cout << list2[K] + 1;
    }
  	return 0;
}

Measured memory_bytes: 9216
#include <cstdio>
#include <algorithm>
typedef long long ll;
using namespace std;
ll n, a[5][100005], b[5][100005];
int main() {
	int i, j, k;
	scanf("%lld", &n);
	for(i=0; i<3; i++) {
		for(j=0; j<n; j++) scanf("%lld", &a[i][j]);
		sort(a[i], a[i]+n);
	}
	for(j=0; j<n; j++) b[2][j] = n-j;
	for(i=1; i>=0; i--) {
		for(j=k=0; j<n; j++) {
			for(; k<n && a[i][j] >= a[i+1][k]; k++);
			b[i][j] = b[i+1][k];
		}
		for(j=n-1; j>=0; j--) b[i][j] += b[i][j+1];
	}
	printf("%lld", b[0][0]);
	return 0;
}

Measured memory_bytes: 6400
use proconio::input;
use proconio::marker::Chars;
#[allow(unused_mut)]
fn main() {
    input! {
        shift: usize,
        s: Chars
    }
    let upper: &str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    for i in s.iter() {
        match upper.chars().position(|t| t == *i) {
            Some(pos) => {
                let pos = shift + pos;
                let newpos = {
                    if 26 <= pos {
                        pos - 26
                    } else {
                        pos
                    }
                };
                print!("{}", upper.chars().nth(newpos).unwrap());
            }
            None => {}
        }
    }
    println!();
}


Measured memory_bytes: 2176
object Main extends App{
val n = scala.io.StdIn.readInt()
val Array(d,x) = scala.io.StdIn.readLine().split("\\s").map(_.toInt)
var choco = x
for (i<-1 to n){
  val a = scala.io.StdIn.readInt()
  choco += (d-1)/a + 1
}
println(choco)
}

Measured memory_bytes: 25656
#include <bits/stdc++.h>
#include<algorithm>
#define ll long long
#define pb push_back
#define popb pop_back
#define ull unsigned long long 
#define beg begin
using namespace std;
 
int main(void) {
     ios::sync_with_stdio(0);
     string s ;
     cin >> s ;
     int temp = 0 ;
     for(int i = 0 ; i < 4; i++)
     {
          if(s[i] == '+')
                temp++ ;
          else
               temp -- ;
     }
     cout << temp ;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
p = list(map(int, input().split()))
E = [0] * N
for i in range(N):
    P = 0.5 * p[i] * (p[i] + 1)
    E[i] = P / p[i]
S = sum(E[:K])
s = S
for i in range(N - K):
    s -= E[i]
    s += E[i + K]
    S = max(S, s)
print(S)

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

int main() {
  int n;
  cin >> n;
  string s = "";
  while(n) {
    if(n%2) {
      n--;
      s +="1";
    }
    else s += "0";
    n /= (-2);
  }
  reverse(s.begin(), s.end());
  cout << (s.empty() ?"0" :s) << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 

int main(){
  ll N; cin >> N;
  vector<pair<ll,ll>> A(N);
  rep(i,N) cin >> A[i].second >> A[i].first;

  sort(all(A));

  bool flag = true;
  rep(i,N){
    if (i>0) A[i].second += A[i-1].second;

    if (A[i].first<A[i].second){
      flag = false;
      break;
    }
  }
  
  cout << (flag? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
const int N=5e5;

#define C getchar()-48
int read()
{
  int s=0,t=1,k=C;
  for (;k<0||9<k;k=C) if (k==-3) t=-1;
  for (;0<=k&&k<=9;k=C) s=(s<<1)+(s<<3)+k;
  return s*t;
}

  int n,t;
  int a[N];
void in()
{
  cin>>n>>n;
  for (int i=0;++i<=n;)
    t+=1&(a[i]=read());
}

void GG()
{
  puts("Impossible");
}

void w1()
{
  cout<<a[1]<<endl;
  a[2]=a[1]/2+1;
  if (a[2]^a[1])
	  ++n,a[1]-=a[2];
  cout<<n<<endl;
  for (int i=0;++i<=n;)
    cout<<a[i]<<' ';
}

void w2(int f=0)
{
  for (int i=0;++i<=n;)
    if (a[i]&1)
      swap(a[i],a[(n-f)%n+1]),
			f^=1;
  for (int i=0;++i<=n;)
    printf("%d ",a[i]);
  puts("");
  ++a[1],--a[n]; 
  if (!a[n]) --n;
  cout<<n<<endl;
  for (int i=0;++i<=n;)
    printf("%d ",a[i]);
}

void sol()
{
  if (t>2) GG();
  else
	if (n==1) w1();
  else
	w2();
}

int main()
{
  in();
  sol();
  exit(0);
}

Measured memory_bytes: 256
def odd(n):
    return n % 2 == 1
    
def even(n):
    return n % 2 == 0

from math import factorial as fact
def c(n, r):
    if n < r:
        return 0
    if n == 0:
        return 0
    if r == 0:
        return 1
    return fact(n) // (fact(n-r) * fact(r))

n, p = map(int, input().split())
a = list(map(int, input().split()))
o = [i for i in a if odd(i)]
e = [i for i in a if even(i)]
x = len(o)
y = len(e)
yc = 0
for i in range(y):
    yc += c(y, i + 1)
ans = 0
if p == 0:
    ans += 1
i = 2 - p
while True:
    if i > x:
        break
    ans += c(x, i)
    ans += c(x, i) * yc
    i += 2
if p == 0:
    ans += yc
print(ans)

Measured memory_bytes: 3064
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

n = int(input())
a = [int(i) for i in input().split()]

ans = a[0]
for i in range(1, len(a)):
    ans = gcd(ans, a[i])

print(ans)


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

int main() {
    long long a,b,c,k; cin >> a >> b >> c >> k;
    long long t,n;
    if(k%2==1) {
        t = (k * (k-1))*a + (k * (k-1) + 1)*(b+c);
        n = (k * (k-1))*b + (k * (k-1) + 1)*(a+c);
    }
    else {
        t = ((k * (k+1))/2 + 1) * a + (k * (k+1))/2 * (b+c);
        n = ((k * (k+1))/2 + 1) * b + (k * (k+1))/2 * (a+c);
    }
    if(abs(t-n)>10e18) cout << "Unfair" << endl;
    else cout << t-n << endl;
    return 0;
}

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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;



int main() {
  st s;
  ci(s);
  ll sum=s[0]+s[1]+s[2];
  ll con='a'+'b'+'c';
  if(sum==con){
    co("Yes")
  }
  else{
    co("No")
  }
  
}


Measured memory_bytes: 256
# Union Find
n,m,k = map(int,input().split())

ab = [ list(map(int,input().split())) for _ in range(m) ]
cd = [ list(map(int,input().split())) for _ in range(k) ]

# print(ab)
# print(cd)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(n)

ls_friend = [0]*n
for i in range(m):
    ls_friend[ ab[i][0]-1 ] += 1
    ls_friend[ ab[i][1]-1 ] += 1
    uf.union( ab[i][0]-1, ab[i][1]-1 )

ls_block = [0]*n
for i in range(k):
    if uf.same( cd[i][0]-1, cd[i][1]-1 ):
        ls_block[ cd[i][0]-1 ] += 1
        ls_block[ cd[i][1]-1 ] += 1
    else:
        pass

# print(uf)

ls_ans = [0]*n
for i in range(n):
    ls_ans[i] += uf.size(i) - 1 - ls_friend[i] - ls_block[i]

print(" ".join(list(map(str,ls_ans))))

Measured memory_bytes: 125912
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n,d,x;
  cin >>n>>d>>x;
  rep(i,n){
    int a,cnt=1;
    cin>>a;
    while (cnt<=d) {
      cnt+=a;
      x+=1;
    }
  }
  cout<<x<<endl;
}

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

using namespace std;
int N;
const int MAX_N = 100000;
long long A[MAX_N];

void solve() {
	int cnt = 1, ans = 0;
	for (int i = 0; i < N - 1; i++) {
		if (A[i] == A[i + 1]) {
			cnt++;
		}
		else {
			if (cnt % 2 == 1) {
				ans++;
			}
			cnt = 1;
		}
	}
	if (cnt % 2 == 1) {
		ans++;
	}
	cout << ans << endl;
}

int main(void) {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A, A + N);
	solve();
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char* argv[]) {
  int n; cin >> n;
  int taro_p = 0, hanako_p = 0;

  for (int i = 0; i < n; i++) {
    string taro, hanako;
    cin >> taro >> hanako;
    if (taro == hanako) {
      taro_p += 1; hanako_p += 1;
    } else if (taro < hanako) {
      hanako_p += 3;
    } else {
      taro_p += 3;
    }
  }

  cout << taro_p << ' ' << hanako_p << endl;
  return 0;
}

Measured memory_bytes: 1212
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef string str;
typedef std::pair<ll,ll> pl;
typedef std::map<string, ll> msl;
typedef std::map<ll, ll> mll;
typedef std::vector<ll> vl;
const long double EPS = 1e-9;
 
#define rep(i, n) for(ll (i) = 0; (i) < (n) ; (i)++ )
#define For(i, a, b) for(ll (i) = (a); (i) < (b) ; (i)++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tol(c) char((c)+0x20)
#define tou(c) char((c)-0x20)
#define pb push_back
#define mp make_pair
#define pr(a) cout << (a)
#define prl(a) cout << (a) << endl
#define prl2(a,b) cout << (a) << " " << (b) << endl
#define prs(a) cout << (a) << " "
#define yn(condition) if ((condition)) prl("Yes"); else prl("No");
#define YN(condition) if ((condition)) prl("YES"); else prl("NO");
#define rpr(i,n,ans) rep((i),(n)) prs((ans[(i)]))
#define cpr(i,n,ans) rep((i),(n)) prl((ans[(i)]))
#define in1(a) cin >> (a)
#define in2(a,b) cin >> (a) >> (b)
#define in3(a,b,c) cin >> (a) >> (b) >> (c)
#define in4(a,b,c,d) cin >> (a) >> (b) >> (c) >> (d)
#define rin1(i,n,a) rep((i),(n)) cin >> (a[(i)])
#define rin2(i,n,a,b) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)])
#define rin3(i,n,a,b,c) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)]) >> (c[(i)])
#define e1 first
#define e2 second
#define ctol(c) ll((c)) - ll('0')
#define ltos(n) to_string((n))
#define items(kv, v) for(auto &(kv): (v))
#define ndig(N, n) ctol(ll(ltos((N))[ll(ltos((N)).length()) - (n)]))
#define beto(a,b,c) (a) < (b) && (b) < (c)
#define betc(a,b,c) (a) <= (b) && (b) <= (c) 
 
const ll mod = 1e9 + 7;
const ll INF = mod * mod;
const ll MAX_N = 100;
 
int main(void){
    ll n,d,x;
    ll a[MAX_N];
    ll answer;
    ll cnt = 0;
 
    in3(n,d,x);
    rin1(i,n,a);
    rep(i,n){
        ll t = 0;
        while (a[i] * t + 1 <= d){
            t ++;
            cnt ++;
        }
    }
 
    prl(x + cnt);
 
    return 0;
}

Measured memory_bytes: 256
import std.stdio,std.string,std.conv;

int main()
{
	string s;
	int a[1001];
	while((s = readln.chomp).length != 0)
	{
		string[] _s = s.split(" ");
		int n = _s[0].to!int;
		int m = _s[1].to!int;

		if(n == 0 && m == 0)
		{
			break;
		}

		foreach(i;0..n)
		{
			a[i] = 1;
		}

		int count = 0;
		int delete_count = 0;

		for(int i=0; i < n ; i++)
		{
			if(delete_count == n-1)
			{
				break;
			}
			
			if(a[i] == 1)
			{
				count++;
				
				if(count == m)
				{
					a[i] = 0;
					count = 0;
					delete_count++;
				}
			}
			
			if(i == n-1)
			{
				i = -1;
			}
		}

		foreach(i;0..n)
		{
			if(a[i] == 1)
			{
				(i+1).writeln;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1068
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "
const int MXN = 1e6+6;
string s[MXN];
int mi[MXN];
int mi_rev[MXN];
int sum[MXN];

int main()
  {
  ios_base::sync_with_stdio(0); 
  int n;
  cin >> n;
  VI all;
  REP(i, n)
    {
    cin >> s[i];
    for(auto j: s[i])
        {
        sum[i] += (j == '(') ? 1 : -1;
        mini(mi[i], sum[i]);
        }
    all.PB(i);

    reverse(ALL(s[i]));
    int ss = 0;
    for(auto j: s[i])
      {
      ss += j == ')' ? 1 : -1;
      mini(mi_rev[i], ss);
      }
    assert(abs(mi_rev[i]) == sum[i] - mi[i]);
    }
  sort(ALL(all), [&](int a, int b){
    if((sum[a] >= 0) != (sum[b] >= 0))return (sum[a] >= 0) > (sum[b] >= 0);
    if(sum[a] >= 0)
      {
      return mi[a] > mi[b];
      }
    else
      {
      return sum[b] - mi[b] < sum[a] - mi[a];        
      }
  });

  int s = 0;
  for(auto i: all)
    {
    if(s + mi[i] < 0)
      {
      puts("No");
      return 0;
      }
    s += sum[i];
    }
  if(s == 0)puts("Yes");
  else puts("No");
  }


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

using namespace std;
const int MAXN = 55;

int main()
{
    int n{0},k{0};
    while(cin>>n>>k){
        int a[MAXN];
        for (int i=0; i < n; i++)
            cin>> a[i];
        sort(a,a+n);
        int sum{0};
        for (int j=k,z=n-1; j > 0; j--,z--)
            sum += a[z];
        cout << sum <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<complex>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 200010
ll n,a[N];
int main(){
    cin>>n;
    lol(i,2*n-1)cin>>a[i];
    ll l=1,r=2*n;
    for(ll m=(l+r)/2;l<r-1;m=(l+r)/2){
	ll ma=1e9,mb=1e9;
	lol(i,2*n-2){
	    ll dis;
	    if(i<n-1)dis=n-i;
	    else dis=i-n+3;
	    bool tl=(a[i]<m),tr=(a[i+1]<m);
	    if(tl and tr)ma=min(ma,dis);
	    tl^=1,tr^=1;
	    if(tl and tr)mb=min(mb,dis);
	}
	if(ma==1e9&&mb==1e9){
	    if(a[0]<m)ma=0;
	    else mb=0;
	}
	//cout<<m<<" "<<ma<<" "<<mb<<endl;
	if(ma>mb)l=m; else r=m;
    }
    cout<<l<<endl;
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    string S;

    map<string, int> mp;

    rep(i, N){
        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;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <deque>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef double db;
typedef pair<int,int> pii;
const int mod = 1e9 +7;
const int win[7] = {0, 1, 0, 1, 1, 1, 1};
void q(void)
{
	cout << 1 << endl;
}

void solve()
{
	set <int>s;
	int n, k;
	cin >> n >> k;
	while(k--)
	{
		int d;
		cin >> d;
		while(d--)
		{
			int k;
			cin >> k;
			s.insert(k);
		}
	}
	int cnt=n;
	for(int i=1; i<=n; i++)
		if(s.find(i)!=s.end())
		cnt--;
	cout << cnt << endl;
}
int main()
{
		solve();
}

Measured memory_bytes: 3580
d, g = map(int, input().split())
# (問題数,ボーナス)のタプルで保存
p = [tuple(map(int, input().split())) for _ in range(d)]
ans = 1000
#  全完する問題の組み合わせを考える
for i in range(2 ** d):
    cnt = 0
    total = 0
    for j in range(d):
        # 全完する場合
        if (i >> j) & 1:
            # 問題数と得点＆ボーナスを追加
            cnt += p[j][0]
            total += (j + 1) * 100 * p[j][0] + p[j][1]
    #  まだ目標に届かない場合
    if total < g:
        # 得点の高い問題から取り掛かるのか最適
        for j in range(d - 1, -1, -1):
            # 全完しない予定だった問題を考慮する
            if (i >> j) & 1:
                continue
            for k in range(p[j][0]):
                if total >= g:
                    break
                # 得点と問題数を追加
                total += 100 * (j + 1)
                cnt += 1
    # 最小のものを求める
    ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
	int h,m,s,h1,m1,s1,sum[5]={0},sum1[5]={0},sam[5]={0},A[5][3]={0},suu=0;
		for(int i=0;i<3;i++){
	scanf("%d %d %d %d %d %d",&h,&m,&s,&h1,&m1,&s1);
	sum[0]=h*3600+m*60+s;
	sum1[0]=h1*3600+m1*60+s1;
	sam[0]=sum1[0]-sum[0];
	A[i][0]=sam[0]/3600;
	sam[0]=sam[0]-A[i][0]*3600;
	A[i][1]=sam[0]/60;
	sam[0]=sam[0]-A[i][1]*60;
	A[i][2]=sam[0]/1;
		}
		for(int i=0;i<3;i++){
	printf("%d %d %d\n",A[i][0],A[i][1],A[i][2]);
		}
	return 0;
}

Measured memory_bytes: 1032
import sys
input=sys.stdin.buffer.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
A,B,C = map(int,input().split())
if (A == B and A != C ) or (A == C and A != B ) or (C == B and A != C ):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
N, X = map(int, input().split())
x = list(map(int, input().split())) 

a = [abs(i - X) for i in x]

import fractions
#最大公約数
ans = a[0]
for i in range(1, N):
    ans = fractions.gcd(ans, a[i])

print(ans)

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

int main()
{
    long long n;
    cin >> n;
    long long p = n / 3, q = n / 5, r = n / 15;
    long long a;
    a = n * (n + 1) / 2 - p * (3 + 3 * p) / 2 - q * (5 + 5 * q) / 2 + r * (15 + 15 * r) / 2;
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 3632
import scala.io.StdIn


object Main extends App {
   val Array(n, k)  = StdIn.readLine().split(" ").map(_.toInt)

   val lnOf2 = Math.log(2)
   def log2(x: Double): Double = scala.math.log(x) / lnOf2
   def times(n: Int) :Int = {
     0.max(Math.ceil(log2(k.toDouble / n)).toInt)
   }

   def solve(n: Int, k: Int): Double  = {
     (1 to n).foldLeft(0.toDouble) {(acc, v) =>
//       println(acc)
  
         acc + (Math.pow(0.5.toDouble , times(v)))
  
  
  
     }
   }
  println(solve(n, k) / n)  



}
  



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

namespace abc134_c
{
    class Program
    {
        static void Main(string[] args)
        {
            
            var N = int.Parse(Console.ReadLine());
            var A = new List<int>();
            var AD = new SortedDictionary<int, List<int>>();

            for (int i = 0; i < N; i++)
            {
                int a = int.Parse(Console.ReadLine());
                A.Add(a);

                if (!AD.ContainsKey(a)) AD.Add(a, new List<int>());               
                AD[a].Add(i);
            }
            
            var amax = AD.Keys.Last();
            var imax = AD[amax];

            foreach (var ai in A)
                if (ai == amax && imax.Count > 1)
                    // 自身が最大値だが他にもいる
                    Console.WriteLine(ai);
                else if (ai == amax && imax.Count == 1)
                    // 自身が唯一の最大値→次の最大値
                    Console.WriteLine(AD.Keys.ToList()[AD.Keys.Count() - 2]);
                else
                    Console.WriteLine(amax);
        }

    }
}


Measured memory_bytes: 37356
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 25;

int n, tot, A[MAXN], B[MAXN], C[MAXN];

int main() {
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    for (int i = 0; i < n; i++) {
        scanf("%d", &B[i]);
        tot += B[i];
    }

    for (int i = 0; i < n - 1; i++) {
        scanf("%d", &C[i]);
    }

    for (int i = 1; i < n; i++) {
        if (A[i] == A[i - 1] + 1) {
            tot += C[A[i - 1] - 1];
        }
    }

    printf("%d\n", tot);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	string s,t; cin>>s>>t;
	int n=s.size(),m=t.size();
	if(n>m){
		cout<<"GREATER"<<endl;
		return 0;
	}
	else if(n<m){
		cout<<"LESS"<<endl;
		return 0;
	}
	int type=3;
	rep(i,0,n){
		string a,b;
		a.push_back(s[i]);
		b.push_back(t[i]);
		int c=stoi(a);
		int d=stoi(b);
		if(c>d){
			type=1;
			break;
		}
		else if(c<d){
			type=2;
			break;
		}
	}
	if(type==1) cout<<"GREATER"<<endl;
	else if(type==2) cout<<"LESS"<<endl;
	else cout<<"EQUAL"<<endl;
	
	return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#include <queue>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define all(x) (x).begin(), (x).end()

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int N, M;
	cin >> N >> M;
	priority_queue<int> que;
	vector <pair <int, int> > BC( M );
	rep( i, 0, N ){
		int input;
		cin >> input;
		que.push(-input);
	}
	rep( i, 0, M ){
		int b,c;
		cin >> b >>c;
		BC[i] = make_pair(c, b);
	}
	sort(all(BC), greater<pair <int, int>>());

	for(auto bc:BC){
		int num = 0;
		rep(j,0,bc.second){
			if (-que.top() < bc.first){
				que.pop();
				num++;
			}
			else{
				break;
			}
		}
		rep(i,0,num){
			que.push(-bc.first);
		}
	}
	ll ans = 0;
	rep(i,0,N){
		ans -= que.top();
		que.pop();
	}
	cout << ans << endl;

}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}


Measured memory_bytes: 1660
/* 
    Author : Jeff Ahn
    Mon 29 Jun 2020 04:24:51 AM PDT 
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define uint unsigned long long
#define endl '\n'

signed main() {
  fastio;
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  int maxi = 1000010;
  vector<int> p(maxi, 0);

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

  for (int i = 1; i < maxi; i++) {
    if (p[i]) {
      for (int j = i + i; j < maxi; j += i) {
        p[j]++;
      }
    }
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    int ai = a[i];
    if (p[ai] == 1) {
      res++;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 12680
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	if(n>=400&&n<=599) cout << 8 << endl;
	else if(n>=600&&n<=799) cout << 7 << endl; 
	else if(n>=800&&n<=999) cout << 6 << endl;
	else if(n>=1000&&n<=1199) cout << 5 << endl;
	else if(n>=1200&&n<=1399) cout << 4 << endl;
	else if(n>=1400&&n<=1599) cout << 3 << endl;
	else if(n>=1600&&n<=1799) cout << 2 << endl;
	else if(n>=1800&&n<=1999) cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 3636
x, n = gets.split.map(&:to_i)
p = gets
if p != nil
  p = p.split.map(&:to_i)
  rs = 1000000
  if p.select { |n| n == x } == []
    puts x
  else
    n.times do |i|
      aru = p.select { |n| n == x + i }
      if aru == [] and (( rs - x ).abs > i or ((rs - x).abs == i and rs > i))
        rs = x + i
      end
    end
    n.times do |i|
      aru = p.select { |n| n == x - i }
      if aru == [] and (( rs - x ).abs > i or ((rs - x).abs == i and rs > i))
        rs = x - i
      end
    end
    if rs == 1000000
      puts x - 1
    else
  		puts rs
    end
  end
else
  puts x
end

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    ll ans = INF;
    rep(i, 2 * 100000 + 1) {
        ll t = C * i;
        t += max(0LL, X - i / 2) * A;
        t += max(0LL, Y - i / 2) * B;
        ans = min(ans, t);
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N,M,X; cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int> > A(N,vector<int>(M));
    for(int i=0;i<N;i++){
        cin >> C[i];
        for(int j=0;j<M;j++){
            cin >> A[i][j];
        }
    }
    ll out = LNF;
    for(int i=0;i<(1<<N);i++){
        //cerr << i << endl;
        ll t=0;
        vector<int> r(M,0);
        for(int j=0;j<N;j++){
            if((1<<j)&i){
                t += C[j];
                for(int k=0;k<M;k++){ //使う
                    r[k] += A[j][k];
                }
            }
        }
        bool f=true;
        for(int j=0;j<M;j++){
            if(r[j]<X) f=false;
        }
        if(f){
            out = min(t,out);
        }
    }
    if(out==LNF){
        cout << -1 << endl;
    }else{
        cout << out << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main()
{
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	
	cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]) << endl;



}





Measured memory_bytes: 3596
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return true;}return false;}

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(n,m);
  int min_num = INF;
  bool exit = false;
  FOR(i,n,m){
    FOR(j,i+1,m+1){
      min_num = min(min_num, (i*j)%2019ll);
      if(min_num==0) exit=true;
      if(exit) break;
    }
    if(exit) break;
  }
  OUT(min_num);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
//#define MOD 1000000007
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;

vector<pair<int,int>> to[N];
int ans[N]={0};
int cou=0;
void dfs(int n,int p,int col){
	int k=1;
	for(auto &s:to[n]){
		
		if(s.first==p)continue;
		if(col==k)k++;
		ans[s.second]=k;
		k++;
		dfs(s.first,n,ans[s.second]);
	}
}
int main(){
	int n;
	cin>>n;
	REP(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		
		to[a].push_back({b,i});
		to[b].push_back({a,i});
	}
	REP(i,n-1){
		cou=max(cou,SZ(to[i]));
	}
	dfs(0,-1,-1);
	OUT(cou);
	REP(i,n-1){
		OUT(ans[i]);
	}
	return 0;
}

Measured memory_bytes: 9344
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;


int main(){
	
	int N,L;
	cin>>N>>L;
	string str[N];
	for(int i=0;i<N;i++){
		cin>>str[i];
	}
	sort(str,str+N);
	for(int i=0;i<N;i++){
		cout<<str[i];
	}
	cout<<endl;
	
	
	return 0;
}

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

int main() {
  int n,k;
  cin>>n>>k;
  vector<int> fruits(n);
  for(int i=0;i<n;i++){
    cin>>fruits.at(i);
  }
  sort(fruits.begin(),fruits.end());
  int ans=0;
  for(int i=0;i<k;i++){
    ans+=fruits.at(i);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <algorithm>
#include <functional>
using namespace std;
struct Place {
	int num,pt;
	bool operator> (const Place &X) const {
		if(pt==X.pt) return num<X.num;
		else return pt>X.pt;
	}
};
Place places[100];
int main() {
	int n,m;
	while(scanf("%d %d",&n,&m),n) {
		for(int i=0;i<m;i++) places[i].num=i+1,places[i].pt=0;
		for(int i=0;i<n;i++) for(int j=0;j<m;j++) {
			int x; scanf("%d",&x); places[j].pt+=x;
		}
		sort(places,places+m,greater<Place>());
		for(int i=0;i<m-1;i++) printf("%d ",places[i].num);
		printf("%d\n",places[m-1].num);
	}
}

Measured memory_bytes: 1044
#include <iostream>                                             
using namespace std;                                            
typedef long long ll;                                           
                                                                
int GCD(ll a,ll b) {                                            
  if (b==0) {                                                   
    return a;                                                   
  }                                                             
  return GCD(b,a%b);                                            
}                                                               
                                                                
int main() {                                                    
  ll a, b;                                                      
  while (cin >> a >> b) {                                       
    cout << GCD(a,b) << " " << a/GCD(a,b)*b << endl;            
  }                                                             
  return 0;                                                     
}                                                               
                                                                
                                                                
                                                                
           

Measured memory_bytes: 3028
#include<bits/stdc++.h>
using namespace std;
long long n;
map<long long,long long>m;
long long x;
vector<long long>v;
long long ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		m[x]++;
	}
	for(map<long long,long long>::iterator i=m.begin();i!=m.end();i++)
		if(i->second>=4) v.push_back(i->first),v.push_back(i->first);
		else if(i->second>=2) v.push_back(i->first);
	if(v.size()<2) cout<<0<<endl;
	else{
		sort(v.begin(),v.end());
		reverse(v.begin(),v.end());
		ans=v[0]*v[1];
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 6528
N = int(input())
P = [int(i) for i in input().split()]
P_sort = sorted(P)
import numpy as np
P_np = np.array(P)
P_sort_np = np.array(P_sort)
if len(P) == (P_np == P_sort_np).sum() or len(P)-2 == (P_np == P_sort_np).sum():
    print("YES")
else:
    print("NO")

Measured memory_bytes: 20440
#include <bits/stdc++.h>
#define int long long
#define S second
#define F first
#define pb push_back
#define sz size()
using namespace std;
const int N=1e6+7;
int b[N],c[N],dp[150][N] ;
int n,x=1,ans,k,w ;
pair < int , int > a[N] ;
vector < int > vec ;
vector < int > pos ;
multiset < int > st ;
main()
{
    cin >> n >> w ;
    for (int i=1;i<=n;i++)
        cin >> a[i].F >> a[i].S ;
    sort(a+1,a+n+1) ;
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=w;j++)
        if (j>=a[i].F)
            dp[i][j]=max(dp[i-1][j],a[i].S+dp[i-1][j-a[i].F]) ;
        else dp[i][j]=dp[i-1][j] ;
    }
    cout << dp[n][w] << endl ;
}


Measured memory_bytes: 81908
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  array<array<int, 3>, 3> A;
  for (auto& row : A)for (auto& elem : row)cin >> elem;
  int N;
  cin >> N;
  vector<int> B(N);
  for (auto& e : B)cin >> e;

  array<array<bool, 3>, 3> table = {};
  for (const auto e : B) {
    for (int y = 0; y < 3; ++y) {
      for (int x = 0; x < 3; ++x) {
        if (e != A[y][x])continue;
        table[y][x] = true;
      }
    }
  }
  bool ans = false;
  for (int i = 0; i < 3; ++i)ans |= count(begin(table[i]), end(table[i]), true) == 3;
  for (int x = 0; x < 3; ++x) {
    bool tmp = true;
    for (int y = 0; y < 3; ++y) {
      if (table[y][x])continue;
      tmp = false;
    }
    ans = ans || tmp;
  }
  ans = ans || (table[0][0] && table[1][1] && table[2][2]);
  ans = ans || (table[0][2] && table[1][1] && table[2][0]);
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
ll n;
vector<pair<ll,ll>>a[100010];
ll ans[100010];
void dep(ll now,ll cnt){
	if(now!=0&&a[now].size()==1){
		return;
	}
	for(ll i=0;i<a[now].size();i++){
		ll next=a[now][i].first;
		if(ans[next]!=-1){
			continue;
		}
		ll w=a[now][i].second;
		if(w%2==0){
			ans[next]=cnt;
			dep(next,cnt);
		}
		else{
			ans[next]=abs(cnt-1);
			dep(next,abs(cnt-1));
		}
	}
}
int main() {
	cin>>n;
	for(ll i=0;i<n-1;i++){
		ll x,y,c;
		cin>>x>>y>>c;
		x--;y--;
		a[x].push_back(make_pair(y,c));
		a[y].push_back(make_pair(x,c));
	}
	for(ll i=0;i<n;i++){
		ans[i]=-1;
	}
	ans[0]=0;
	dep(0,0);
	for(ll i=0;i<n;i++){
		cout << ans[i]<<endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 11008
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <map>
using namespace std;
#define ll long long

int main() {
	int r;
	cin >> r;
	if (r < 1200)cout << "ABC" << endl;
	else if (r < 2800)cout << "ARC" << endl;
	else cout << "AGC" << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
    "fmt"
)

type dice struct {
    t, s, e, w, n, b int
}

func main() {
    var t, s, e, w, n, b int
    fmt.Scan(&t, &s, &e, &w, &n, &b)
	d1 := dice{t: t, s: s, e: e, w: w, n: n, b: b}
	fmt.Scan(&t, &s, &e, &w, &n, &b)
	d2 := dice{t: t, s: s, e: e, w: w, n: n, b: b}
	is_ok := false
	for i:=0; i<4; i++{
		if d2.t == d1.t && d2.b == d1.b{
			is_ok = true
			break
		}
		d2.t, d2.e, d2.w, d2.b = d2.w, d2.t, d2.b, d2.e
	}
	for i:=0; i<4; i++{
		if d2.t == d1.t && d2.b == d1.b{
			is_ok = true
			break
		}
		d2.t, d2.s, d2.b, d2.n = d2.n, d2.t, d2.s, d2.b
	}
	if is_ok{
		is_ok = false
		for i:=0; i<4; i++{
			if d2.s == d1.s && d2.e == d1.e && d2.n == d1.n && d2.w == d1.w{
				is_ok = true
				break
			}
			d2.s, d2.e, d2.n, d2.w = d2.e, d2.n, d2.w, d2.s
		}
	}
	if is_ok{
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1152
import sys
sys.setrecursionlimit(100000)
input=sys.stdin.readline
def intinput():return map(int,input().split())

n,m=intinput()
s={i+1 for i in range(m)}
for i in range(n):
    l=list(intinput())
    r=set(l[1:])
    s&=r
print(len(s))

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

int main(void)
{
    int N;
    long long A[100000];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    int ans = 0;
    for(int i=0; i<N; i++){
        while(A[i]>1&&A[i]%2 == 0){
            A[i] /= 2;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384