akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            String[] s = new String[n];
            for (int i = 0; i < n; i++) {
                s[i] = in.next();
            }
            int[] cnt = new int[26];
            int[] ans = new int[26];
            Arrays.fill(ans, 100);
            for (int i = 0; i < n; i++) {
                Arrays.fill(cnt, 0);
                for (int j = 0; j < s[i].length(); j++) {
                    cnt[s[i].charAt(j) - 'a']++;
                }
                for (int j = 0; j < 26; j++) {
                    if (cnt[j] == 0) cnt[j] = 0;
                    ans[j] = Math.min(ans[j], cnt[j]);
                }
            }


            // 出力
            for (int i = 0; i < 26; i++) {
                if (ans[i] != 0) {
                    for (int j = 0; j < ans[i]; j++) {
                        out.print(String.valueOf((char) (i + 'a')));
                    }
                }
            }
            out.printf("\n");

        }

    }
}



Measured memory_bytes: 35852
from string import ascii_lowercase as alph

def gen_pattern(N, pre="", m=0):
  if len(pre)+1 == N:
    for c in alph[:m+1]:
      yield pre+c
  else:
    for c in alph[:m]:
      yield from gen_pattern(N, pre+c, m)
    yield from gen_pattern(N, pre+alph[m], m+1)

for pattern in gen_pattern(int(input())):
  print(pattern)


Measured memory_bytes: 5028
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int i,j,n,a[100],A,B,x;
	A=0;
	B=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(a[i]>a[j]){
				swap(a[i],a[j]);
			}
		}
	}
	for(i=0;i<n;i++){
		if(i%2==0){
			A=A+a[i];
		}
		else{
			B=B+a[i];
		}
	}
	x=A-B;
	cout<<x<<endl;
	
	return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#define fastio                              ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main(){
    fastio;
    long long n, d, sum = 0, x;
    cin >> n >> d;
    for(long long i = 0; i < d; i++){
        cin >> x;
        sum += x;
    }
    if(n < sum) cout << -1;
    else cout << n-sum;
}

Measured memory_bytes: 3656
#include<stdio.h>

int main(){
	
	int n,d,x;
	int i;
	char a[100];
	int ans=0;
	
	scanf("%d %d %d",&n,&d,&x);

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

	for(i=0;i<n;i++){
		if(d%a[i]==0){
			ans+=d/a[i];
		}
		else{
			ans+=(d/a[i]+1);
		}
	}

	ans+=x;
	printf("%d",ans);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>

#define nl '\n';

using namespace std;

long long n, a, mini = 1000000005, maxi;

int main(){

    cin >> n;

    for(long long i = 0; i < n; i++){
        cin >> a;
        mini = min(mini, a);
        maxi = max(maxi, a);

    }

    cout << maxi-mini;







}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out

// char** arr = new char*[r];
// for(long long i = 0; i < r; i++) arr[i] = new char[c];

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000000
using namespace std;
typedef long long ll;

int ans = -MAX;
int n;
int f[100][10];
int p[100][11];
int a[10];
void calc(){
  int score = 0;
  int notAll0 = false;
  rep(i, 0, 10) if(a[i]&1) notAll0 = true;
  if(!notAll0)  return;
  rep(i, 0, n) {
    int c = 0;
    rep(j, 0, 10) {
      if(a[j]&f[i][j]) c++;
    }
    score += p[i][c];
  }
  ans = max(ans, score);
}

void dfs(int pos){
  if(pos==10){
    calc();
    return;
  }
  a[pos]=0; dfs(pos+1);
  a[pos]=1; dfs(pos+1);
}

int main(){
  cin >> n;
  rep(i, 0, n)  rep(j, 0, 10) cin >> f[i][j];
  rep(i, 0, n)  rep(j, 0, 11) cin >> p[i][j];
  dfs(0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        boolean a = sc.next().equals("H") ? true : false;
        boolean b = sc.next().equals("H") ? true : false;
        if(a==b)
        System.out.println("H");
        else
        System.out.println("D");
    }
}

Measured memory_bytes: 20820
/*
TASK: <Task>
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define EPS 1e-9
#define ALL(x) (x).begin(),(x).end()
#define mp(x,y) make_pair((x),(y))
#define pb(x) push_back((x))
#define FOR(i,st,ed) for(int (i)=(st);(i)<(ed);(i)++)
typedef pair<int,int> PII;
typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef long long LL;

int N,M,T;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//freopen("xxx.in","r",stdin);
	//freopen("xxx.out","w",stdout);
	int i,j,k;
	cin >> N >> M;
    for(i=0;i<=N;i++) {
        if(10000*i>M)
            break;
        for(j=0;i+j<=N;j++) {
            if(10000*i+5000*j>M)
                break;
            k=N-i-j;
            if(10000*i+5000*j+1000*k==M) {
                printf("%d %d %d\n",i,j,k);
                return 0;
            }
        }
    }
    cout << "-1 -1 -1\n";
	return 0;
}


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


int main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> v(m);
    for (int i = 0; i < m; i++) {
        int k; cin >> k;
        v[i].resize(k);
        for (int j = 0; j < k; j++) {
            cin >> v[i][j];
            v[i][j]--;
        }
    }
    vector<int> p(m);
    for (int i = 0; i < m; i++) cin >> p[i];

    int ans = 0;
    for (int bit = 0; bit < (1<<n); bit++) {
        int flag = 1;
        for (int i = 0; i < m; i++) {
            int cnt = 0;
            for (int j = 0; j < v[i].size(); j++) {
                if (bit & (1<<v[i][j])) {
                    cnt = 1 - cnt;
                }
            }
            if (cnt != p[i]) flag = 0;
        }
        if (flag) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
class WeighttedUnionFind:
	def __init__(self, n):
		self.par = [i for i in range(n+1)]
		self.rank = [0] * (n+1)
		#根への距離を管理
		self.weight = [0] * (n+1)

	#検索
	def find(self, x):
		if self.par[x] ==x:
			return x
		else:
			y = self.find(self.par[x])
			#根への重みを追加しながら根まで走査
			self.weight[x] +=self.weight[self.par[x]]
			self.par[x] = y
			return y

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

		#xの木の高さ < yの木の高さ
		if self.rank[rx] < self.rank[ry]:
			self.par[rx] = ry
			self.weight[rx] = w - self.weight[x] + self.weight[y]

		#xの木の高さ>=yの木の高さ
		else:
			self.par[ry] = rx
			self.weight[ry] = -w - self.weight[y] + self.weight[x]
			#木の高さが同じだった場合の処理
			if self.rank[rx] == self.rank[ry]:
				self.rank[rx] +=1
	#同じ集合に属するか
	def same(self, x, y):
		return self.find(x) == self.find(y)
	#xからyへのコスト
	def diff(self, x, y):
		return self.weight[x] - self.weight[y]

N, M = map(int, input().split())
wuf = WeighttedUnionFind(N)

for _ in range(M):
	l, r, d = map(int, input().split())

	if not wuf.same(l, r):
		wuf.union(l, r, d)

	else:
		if wuf.diff(l, r) !=d:
			print("No")
			exit()
print("Yes") 


Measured memory_bytes: 84416
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll a, b, c, k;
    ll ans = 0;

    cin >> a >> b >> c >> k;

    if (a >= k)
    {
        ans += k;
    }
    else if (a + b >= k)
    {
        ans += a;
    }
    else
    {
        ans += a - (k - a - b);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N =1e5+5;
const ll mod=1e9+7;
int a[110];
    int n;
bool ok()
{
    for(int i=1;i<n;i++)
        if(a[i]>a[i+1])
            return 0;
    return 1;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }

        if(ok()){printf("YES\n");return 0;}
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
    {
        swap(a[i],a[j]);

        if(ok()){printf("YES\n");return 0;}
        swap(a[i],a[j]);
    }
    printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
using namespace std;
using ll = long long;
using graph = std::vector<std::vector<long long>>;
int main(){
    int N;
    cin >> N;
    string s[N];
    ll t[N];
    for(int i = 0; i < N; i++){
        cin >> s[i] >> t[i];
    }
    string x;
    cin >> x;
    ll sum = 0;
    bool f = false;
    for(int i = 0; i < N; i++){
        if(f){
            sum += t[i];
        }else{
            if(x == s[i]){
                f = true;
            }
        }
    }
    cout << sum << endl;
}

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

bool judgeShiritori(vector<string> words) {
    bool flag=false;
    for(int i = 0; i < words.size()-1; i++) {
        if(words[i][words[i].size()-1] == words[i+1][0]) {
            flag = true;
        }
        else {
            flag = false;
        }
        if(!flag) return false;
    }
    return true;
}

int main() {
  vector<string> words(3);
  cin >> words[0]; cin >> words[1]; cin >> words[2];
  if(judgeShiritori(words)) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
x = [list(map(str,input().split())) for i in range(n)]
res = 0
for i in range(n):
    if x[i][1]=="JPY":
        res += int(x[i][0])
    else:
        res += float(x[i][0])*380000.0
print(res)

Measured memory_bytes: 3060
n,k = map(int,input().split())
a = list(map(int,input().split()))
checked=[False]*(1+n)
checked_num=[0]*(1+n)
checked[1]=True
tree = [1]
ind = 1
count = 0
judge = 0
for _ in range(k):
    count += 1
    ind_ = a[ind-1]
    if checked[ind_]:
        cycle = count-checked_num[ind_]
        tree = tree[checked_num[ind_]:]
        print(tree[(k-count)%cycle])
        judge = 1
        break
    checked_num[ind_]=count
    checked[ind_]=True
    tree += [ind_]
    ind = ind_

if judge == 0:
    print(ind)

Measured memory_bytes: 32372
#include<stdio.h>
#include<algorithm>
using namespace std;
long long mod=1000000007;
int M=1050000;
long long inv[1100000];
long long fact[1100000];
long long factinv[1100000];
long long C(int a,int b){
	if(a<b)return 0;
	return fact[a]*factinv[b]%mod*factinv[a-b]%mod;
}
long long pw(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		b/=2;
		a=a*a%mod;
	}
	return ret;
}
int main(){
	inv[1]=fact[0]=factinv[0]=1;
	for(int i=1;i<M;i++)fact[i]=fact[i-1]*i%mod;
	for(int i=2;i<M;i++)inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	for(int i=1;i<M;i++)factinv[i]=factinv[i-1]*inv[i]%mod;
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	long long ret=0;
	int L=0;
	int R=0;
	long long cur=1;
	for(int i=a;i<=a+b+c;i++){
		long long ks=C(i-1,a-1)*pw(3,a+b+c-i)%mod;
		// b no kosuu
		int lm=0; lm=max(lm,i-a-c);
		int rm=i-a; rm=min(rm,b);
		if(i>a){
			cur=cur*2%mod;
			if(L<lm){
				cur=(cur+mod-C(i-a-1,L))%mod;
			}
			if(R>=rm){
				cur=(cur+mod-C(i-a-1,R))%mod;
			}
		}
		ret=(ret+ks*cur)%mod;
		L=lm;R=rm;
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 25600
#include <cstdio>
#include <iostream>

using namespace std;

const int MAX_N = 30, MAX_M = 30;
int N, M;
int li[MAX_N][MAX_M + 1];
int ali[MAX_M + 1];

int main() {
	int k = 0;
	int ans = 0;
	scanf("%d %d", &N, &M);
	for (int i = 0; i < N; i++) {
		scanf("%d", &k);
		for (int j = 0; j < k; j++) {
			scanf("%d", &li[i][j]);
		}

		for (int j = 0; j < k; j++) {
			ali[li[i][j]] += 1;
		}
	}

	for (int i = 0; i < M + 1; i++) {
		if (ali[i] == N) ans++;
	}

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

	return 0;
}

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




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


  vector<int> rcount(26,0);
  vector<int> lcount(26,0);
  for(int i=0;i<s.size();i++){
    rcount[s[i]-'a']++;
  }
  int maxcount=0;

  for(int pos=0;pos < s.size()-1-1;pos++){
    rcount[s[pos]-'a']--;
    lcount[s[pos]-'a']++;
    int count=0;
    for(int j=0;j<26;j++){
      if (lcount[j]>0 && rcount[j]>0){
        count++;
      }
    }
    if (maxcount < count)maxcount = count;
  }


  cout << maxcount << endl;
  // cout <<  max( max(a + b, a * b) , a - b ) ;

  return 0;
}






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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  if (A >= B && A >= C) {
    A = A * pow(2, K);
  }
  else if (B >= A && B >= C) {
    B = B * pow(2, K);
  }
  else {
    C = C * pow(2, K);
  }
  cout << A + B + C;
}

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

int main() {
  int a,b;
  cin >> a >> b;
  if(a==b){
    cout << "a == b" << endl;
  }else if(a>b){
    cout << "a > b" << endl;
  }else{
    cout << "a < b" << endl;
  }
}


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

const int N = 1e5 + 5;
int n;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n;
    
    map<vector<int>, int> cnt;
    
    for (int i = 0; i < n; i++){
        string s;
        cin >> s;
        vector<int> fea(26, 0);
        for (auto c: s) {
            fea[c - 'a'] ++;
        }
        cnt[fea] ++;
    }
    
    ll sum = 0;
    for(auto i: cnt){
        sum += 1ll * (i.second - 1) *i.second/2;
    }
    
    cout << sum << "\n";
    
    
    return 0;
}


Measured memory_bytes: 19072
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#define ALL(a) (a).begin(),(a).end()

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};


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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 510000; 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;
}

priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>que;

int main() {
  // 前処理
  //COMinit();

	ll X,Y;
  cin>>X>>Y;

  if(abs(X,Y)>1){
  cout<<"Alice"<<endl;
  }else{
  cout<<"Brown"<<endl;
  }

  return 0;
 
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string t,h;
  int n,pt=0,ph=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> t >> h;
    if(t==h)pt++,ph++;
    else if(t>h) pt+=3;
    else ph+=3;
  }
  cout << pt << " " << ph << endl;
}


Measured memory_bytes: 3208
#include<iostream>
using namespace std;
bool In[15];
bool Check(int x) {
    while(x) {
        if(In[x%10]) return false;
        x /= 10;
    }
    return true;
}
int main() {
    int n,k,x;
    cin >> n >> k;
    for(int i = 1; i <= k; ++i)
        cin >> x, In[x] = true;
    for(int i = n;; ++i) {
        if(Check(i)) {
            printf("%d\n",i);
            break;
        }
    }
return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll visited[100100];
int main() {
    ll n,m;
    cin>>n>>m;
    vector<ll>adj[100100];
    queue<ll>q;
    ll dist[100100];
    dist[1]=0;
    q.push(1);
    ll a,b;
    for(ll i=1;i<=m;i++)
    {
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    ll par[100100];
    visited[1]=1;
    while(!q.empty())
    {
        ll x=q.front();
        q.pop();
        for(ll i:adj[x])
        {
            if(visited[i]==0)
            {
                par[i]=x;
                visited[i]=1;
                dist[i]=dist[x]+1;
                q.push(i);
            }
        }
    }
    cout<<"Yes\n";
    for(ll i=2;i<=n;i++)
    {
        cout<<par[i]<<endl;
    }
}


Measured memory_bytes: 13740
N = int(input())
l = []
for i in range(N):
  a = list(input().split())
  a.append(i)
  a[1] = int(a[1])
  l.append(a)
l.sort(key=lambda x:(x[0],x[1]), reverse=True)
l.sort(key=lambda x:x[0])
for i in l:
  print(i[2]+1)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<pair<int, char>> V(a+b+c);
	int p;
	for(int i = 0; i < a; i++){
		cin >> p;
		V[i] = mpair(p, 'c');
	}
	for(int i = 0; i < b; i++){
		cin >> p;
		V[a+i] = mpair(p, 'b');
	}
	for(int i = 0; i < c; i++){
		cin >> p;
		V[a+b+i] = mpair(p, 'a');
	}
	sort(all(V));
	int X = 0, Y = 0, A = 0;
	ll sum = 0;
	for(int i = a+b+c-1; i >= 0; i--){
		if(V[i].second == 'c'){
			if(X < x && A < x+y){
				X++;
				A++;
				sum += V[i].first;
			}
		}
		if(V[i].second == 'b'){
			if(Y < y && A < x+y){
				Y++;
				A++;
				sum += V[i].first;
			}
		}
		if(V[i].second == 'a'){
			if(A < x+y){
				A++;
				sum += V[i].first;
			}
		}
		if(A == x+y)break;
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 2560
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math

N=int(input())
AB=sorted([list(map(int,input().split())) for i in range(N)],key=lambda x:x[0])
CD=sorted([list(map(int,input().split())) for i in range(N)],key=lambda x:x[0])
count=0
for c,d in CD:
    #print(AB,c,d)
    tmp=[[AB[i][1],i] for i in range(len(AB)) if AB[i][0]<c and AB[i][1]<d]
    if tmp:
        idx=tmp[0][1]
        _max=tmp[0][0]
        for a,i in tmp:
            if a>_max:

                _max=a
                idx=i

        AB.pop(idx)
        count+=1
print(count)


Measured memory_bytes: 38896
#include "bits/stdc++.h"
using namespace std;
using Node = pair<string, int>; // left: 0, right: 1
const long long INF = 1LL << 60;

int main() {
	int N;
	cin >> N;
	vector<string> S(N);
	vector<long long> C(N);
	for (int i = 0; i < N; ++i) {
		cin >> S[i] >> C[i];
	}
	long long res = INF;
	map<Node, long long>dp;
	priority_queue<pair<long long, Node>, vector<pair<long long, Node>>, greater<pair<long long, Node>>> que;

	auto func = [&](const string &left, const string & right) {
		int i = (int)left.size() - 1;
		int j = 0;
		while (true) {
			if ((i == -1) || (j == (int)right.size())) {
				break;
			}
			if (left[i] != right[j]) {
				return Node("", -1);
			}
			--i;
			++j;
		}
		if (left.size() >= right.size()) {
			string res = left.substr(0, (int)left.size() - (int)right.size());
			return Node(res, 0);
		}
		else {
			string res = right.substr((int)left.size());
			return Node(res, 1);
		}
	};

	auto relax = [&](const string &left, const string & right, long long cost) {
		auto v = func(left, right);
		if (-1 == v.second) {
			return;
		}
		if ("" == v.first) {
			res = min(res, cost);
		}
		else {
			que.push(make_pair(cost, v));
			if (dp.count(v)) {
				dp[v] = min(dp[v], cost);
			}
			else {
				dp[v] = cost;
			}
		}
	};


	for (int i = 0; i < N; ++i) {
		for (int j = 0; j <= S[i].size(); ++j) {
			string left = S[i].substr(0, j);//0_j-1
			string right = S[i].substr(j);
			relax(left, right, C[i]);
		}
		for (int j = 0; j < S[i].size(); ++j) {
			string left = S[i].substr(0, j);//0_j-1
			string right = S[i].substr(j + 1);
			relax(left, right, C[i]);
		}
	}

	while (!que.empty()) {
		auto tmp = que.top();
		que.pop();
		long long dist = tmp.first;//cost
		string cur = tmp.second.first;
		int type = tmp.second.second;
		if (dist > dp[Node(cur, type)]) {
			//if(dist < dp[tmp.secound]){
			continue;
		}
		for (int i = 0; i < N; ++i) {
			if (0 == type) {
				relax(cur, S[i], dist + C[i]);
			}
			else {
				relax(S[i], cur, dist + C[i]);
			}
		}
	}
	if (INF == res) {
		cout << -1 << endl;
	}
	else {
		cout << res << endl;
	}
	return 0;
}


Measured memory_bytes: 3840
#include<iostream>
#include<math.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define lrep(i,n) for(long int i=0;i<(n);i++)
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;
	cout <<a*b;
	return 0;
}

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

using namespace std;


#define rep(i,m,n) for(long long i=m;i<n;i++) 

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

  vector<long long> x(7);
  rep(i,0,7) cin >> x[i];
  
  long long res=0;
  long long a=x[3],b=x[4],c=x[0];
  rep(ai,0,2){
   rep(bi,0,2){ 
    rep(ci,0,2){
      if(ai&&!a) continue;
      if(bi&&!b) continue;
      if(ci&&!c) continue;
      long long num=0;
      num+=(a-ai)/2+(b-bi)/2+(c-ci)/2;
      num*=2;
      if(ai&&bi&&ci) num+=3;
      res=max(res,num);
    }
   }
  }
  
  res+=x[1];
  cout << res << endl;
 
}

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

#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i,a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
int x, y;
int ans[2005];
int d[2005][2005];
void solve() {
    cin >> n >> x >> y;
    rep(i, n) loop(j, i + 1, n)
        d[i][j] = min({ j - i, abs(x - i - 1) + abs(y - j - 1) + 1, abs(y - i - 1) + abs(x - j - 1) + 1 });

    rep(i, n) loop(j, i + 1, n) ++ans[d[i][j]];
    reps(i, n - 1) cout << ans[i] << endl;
}

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


Measured memory_bytes: 15360
N, A = map(int, input().split())
X = list(map(int, input().split()))
Y = [x - A for x in X]

dp = [[0 for _ in range(20000)] for _ in range(N + 1)]

def bias(n):
    return n + 5000

dp[0][bias(0)] = 1

for i in range(N):
    for s in range(-5000, 5000):
        dp[i + 1][bias(s)] += dp[i][bias(s)]
        dp[i + 1][bias(s + Y[i])] += dp[i][bias(s)]

print(dp[N][bias(0)] - 1)

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



int main(){
    int n, h, cont = 0;
    cin >> n;
    int maxi = 0;
    for (int i=0; i < n; ++i){
        cin >> h;
        if (h >= maxi) cont++;
          maxi = max(maxi, h);
        
    }
    cout << cont;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define endl "\n"

ll power(ll a, ll b){
  ll res = 1;

  while (b > 0){
    if (b%2) res *= a;
    a *= a;
    b /= 2;
  } 

  return res;
}

 
int main ()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #define int ll
  
  int n;
  cin >> n;

  map <int, int> mp;
 
  int ans = 0;
  vector <int> numbers(n);
  for (int i=0; i<n; i++){
    
    cin >> numbers[i];
    mp[numbers[i]+i]++;
  }

  for (int j=1; j<n; j++){
    ans += mp[j - numbers[j]];
  }

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


Measured memory_bytes: 27308
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        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 long Solve(long A, long B, long C, long X, long Y)
        {
            long min = X * A + Y * B;
            min = Math.Min(X * 2 * C + Math.Max(Y - X, 0) * B, min);
            min = Math.Min(Y * 2 * C + Math.Max(X - Y, 0) * A, min);
            return min;
        }
        static void Main(string[] args)
        {
            var V = ReadLongs();
            Console.WriteLine(Solve(V[0], V[1], V[2], V[3], V[4]));
        }
    }
}


Measured memory_bytes: 13140
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA
*/
#include <bits/stdc++.h>
using namespace std;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld\n",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define nl printf("\n")
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli,lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
//#define nl cout<<"\n"
#define MX1 100005
#define MX2 1000005
#define sqr(a) a*a*a
#define bs binary_search
#define lb lower_bound
#define ub upper_bound

lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
int main()
{
      /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif*/
    opt;
    lli a,b,c,d,n,ans=0;
    cin>>a>>b>>c>>d>>n;
    ans=min(4*n*a,min(2*n*b,n*c));
    lli temp=(n/2)*d;
    temp+=(n%2)*(min(4*a,min(2*b,c)));
    cout<<min(ans,temp);
}


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

int main() {
	int a, b;
	cin >> a >> b;

	for (int i = 1; i < 1255; i++) {
		if (int(i*0.08) == a && int(i*0.1) == b) {
			cout << i << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 256
n, t = map(int, input().split())
ct =[]
for i in range(n):
  tmp = list(map(int, input().split()))
  if tmp[1] <= t:
    ct.append(tmp)
if len(ct) == 0:
  print('TLE')
else:
  ct.sort()
  print(ct[0][0])

Measured memory_bytes: 3060
#include <stdio.h>

#ifdef DEBUG
#define DPRTF(x) printf x
#define TRACE (printf("%s:%s:%d\n", __FILE__, __func__, __LINE__))
#define ERR(x) (TRACE, (x))
#else
#define DPRTF(x)
#define TRACE
#define ERR(x) (x)
#endif

int main(int argc, char *argv[])
{
    int N = 0;
    scanf("%d", &N);

    if (N % 2 == 0) {
        printf("0.5000000000\n");
    } else if (N % 2 == 1) {
        printf("%f\n", (float)((float)((int)(N/2)+1)/(float)N));
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;

int par[200010],sz[200010];
void init(int n){
	for(int i=0;i<n;i++){
		par[i] = i; sz[i] = 1;
	}
}

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

void unite(ll x, ll y){
	x = find(x); y = find(y);
	if(x==y) return;
	if(sz[x]<sz[y]) swap(x,y);
	par[y] = x; sz[x] += sz[y];
}

bool same(ll x, ll y){
	return find(x)==find(y);
}
typedef pair<ll,pair<ll,ll>> P;
priority_queue<P,vector<P>,greater<P>> que;
int main(){
	int i,n,q;
	cin >> n >> q;
	init(n);
	for(i=0;i<q;i++){
		ll a,b,c; cin >> a >> b >> c;
		que.push({c,{a,b}});
		que.push({c + 1,{(a + 1)%n,b}});
	}
	ll res = 0;
	while(que.size()){
		P p = que.top();
		que.pop();
		ll u = p.second.first,v = p.second.second;
		if(same(u,v)) continue;
		unite(u,v); res += p.first;
		p.first += 2; (p.second.first += 1) %= n; (p.second.second += 1) %= n;
		que.push(p);
	}
	cout << res << endl;
}
	

Measured memory_bytes: 15852
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int n;
  cin >> n;
  double sum = 0;
  rep(i,n){
    double buf;
    cin >> buf;
    sum += 1.0/buf;
  }
  cout << setprecision(12) << 1.0 / sum << endl;
}



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


#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ll long long


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int a, b;
    cin >> a >> b;

    cout << ((a * b) % 2 == 0 ? "No\n" : "Yes\n");

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

int main() {
    int n;
    cin >> n;
    auto a = vector<double>(n);
    for (auto &a_i : a)
        cin >> a_i;

    auto rsum = 0.0;
    for (auto &a_i : a)
        rsum += (1 / a_i);

    printf("%.10f\n", (1 / rsum));
    return 0;
}


Measured memory_bytes: 256
/*
 * ID: ITP1_8_C
 * Problem: counting characters
 */

#include <stdio.h>
#include <ctype.h>
#define MAX 1024

int main(void)
{
    int s[128] = {0};
    char line[MAX + 1];
    int i;

    while (fgets(line, sizeof(line), stdin) != NULL) {
        for (i = 0; i < MAX; i++) {
            if (line[i] == '\n')
                break;
            if (isalpha(line[i]))
                s[tolower(line[i])]++;
        }
    }

    for (i = 'a'; i <= 'z'; i++)
        printf("%c : %d\n", i, s[i]);

    return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int NUM = 2e5 + 5;

int main(){
    ios
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        ll a,b; cin>>a>>b;
        char c; cin>>c;
        int d; cin>>d;
        b*=100;
        b+=d;
        ll ans=(a*b)/100;
        cout<<ans;
    }
}

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

int main(){
	int N;
	cin >> N;
	int A[N];
	int c[N];
	rep(i,N) c[i] = 0;
	rep(i,N) {
		int a;
		cin >> a;
		a--;
		A[i] = a;
		c[a]++;
	}
	ll tot = 0;
	rep(i,N) {
		tot += (ll)c[i]*(c[i]-1)/2;
	}
	rep(i,N) {
		int a = A[i];
		cout << tot - (c[a]-1) << endl; 
	}
	return 0;
}


Measured memory_bytes: 5172
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

N = int(input())
if (N ** 0.5).is_integer():
    num1 = int(N ** 0.5)
    num2 = num1
else:
    arr = make_divisors(N)
    num1 = arr[len(arr)//2 - 1]
    num2 = N // num1
print(num1 + num2 - 2)

Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define rusha scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define rushb scanf("%d",&t);while(t--)
#define debug(x) cout<<" L-B-W-- "<<x<<" --N-B\n"
#define pb push_back
#define pii pair<int,int>
#define vii vector<int>
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof a)
#define all(x) (x.begin(),x.end())
#define judgef printf("%s\n",f?"Yes":"No")
#define Judgef printf("%s\n",f?"YES":"NO")
#define sz(x) ((int)(x).size())
#define sf(x) (sizeof(x))
using namespace std;
typedef long long ll;
typedef double db;
const double pai = acos(-1.0);
const double eps = 1e-8;
const int mod=998244353;
//const int mod=1e9+7;
const int inf=1e9+7;
//const ll inf=0x7f7f7f7f1234abcd;
const int maxn=2e5+10;
inline ll ksm(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;x=x*x%mod;y>>=1;}return res;}
inline ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}
inline ll lcm(ll a,ll b){return a * b / __gcd(a, b);}
int t,n,m,k;
int a[maxn];
int main()
{
    scanf("%d",&n);
    n%=10;
    if(n==3) puts("bon");
    else if(n==0||n==1||n==6||n==8) puts("pon");
    else  puts("hon");
    return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef long int li;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<double, double>P;
typedef tuple<ll, int, int>T;
#define PI 3.14159265358979


int main(){
  int N;
  cin>>N;
  vector<ll>A(N);
  rep(i,N){cin>>A[i];}
  ll dp[3000][3000];
  rep(i,N){
    rep(j,N){
      dp[i][j]=0ll;
   }
  }
  //k=0だけ前もって入れとく
  if((N-1)%2==0){
    rep(i,N){
      dp[i][i]+=A[i];
    }
  }
  else{
    rep(i,N){
      dp[i][i]-=A[i];
    }
  }
  for(int k=1;k<N;k++){
  	if((N-k-1)%2==0){
      rep(i,N){
        int j=i+k;
        if(j>=N){continue;}
        	dp[i][j]=max(dp[i+1][j]+A[i],dp[i][j-1]+A[j]);
      }
    }
  	else{
      rep(i,N){
        int j=i+k;
        if(j>=N){continue;}
        	dp[i][j]=min(dp[i+1][j]-A[i],dp[i][j-1]-A[j]);
      }
    }
  }
  cout<<dp[0][N-1];
}

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

int main(){
    int n,m; cin>>n>>m;
    vector<P> key;
    rep(i,m){
        int a,b; cin>>a>>b;
        int bit = 0;
        rep(j,b){
            int c; cin>>c; c--;
            bit |= 1<<c;
        }
        key.emplace_back(bit,a);
    }

    vector<int> dp(1<<n,1e9);
    dp[0] = 0;
    rep(bit,1<<n){
        rep(i,m){
            int t = bit | key[i].first;
            chmin(dp[t], dp[bit]+key[i].second);
        }
    }
    int ans = dp.back();
    if(ans==1e9) ans=-1;
    cout << ans << endl;
    return 0;
}

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

public class Main {

    public static void main(String[] args) throws IOException {
        
        BufferedReader std = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(std.readLine());
        String str = std.readLine();
        String[] strs = str.split(" ");
        
        for(int i = strs.length-1; i >= 0; i--){
            if(i != 0){
                System.out.print(strs[i] + " ");
            } else {
                System.out.print(strs[i]);
            }
        }
        System.out.println();
    
    }

}

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

int main()
{
    int64_t N, M;
    cin >> N >> M;

    if (N == 1 && M == 1)
        cout << 1 << endl;
    else if (N == 1)
        cout << M - 2 << endl;
    else if (M == 1)
        cout << N - 2 << endl;
    else
        cout << (N - 2) * (M - 2) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	Scanner sc;
	public void run(){
		sc = new Scanner(System.in);
		ArrayList<Integer> n = new ArrayList<Integer>();

		while(sc.hasNextInt()){
			int value = sc.nextInt();
			int value2 = sc.nextInt();
			if(value == 0 && value2 == 0){
				break;
			}
			else{
				calc(value, value2);
			}
		}
	}
	public void calc(int n, int r){
		int[] cards = new int[r];
		ArrayList<Integer> pList = new ArrayList<Integer>();
		ArrayList<Integer> cList = new ArrayList<Integer>();
		for(int i = 0; i < r; i++){
			pList.add(0, sc.nextInt());
			cList.add(0, sc.nextInt());
		}
		int t = 1;
		for(int i = 0; i < r; i++){
			int p = pList.get(0);
			int c = cList.get(0);
			if(c >= t) t = p + t -1;
			else if((t-c) < p){
				t = t - c;
			}
			pList.remove(0);
			cList.remove(0);
		}
		System.out.println(n - t + 1);
	}
	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 28328
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

template <int MaxN = 100000, long long mod = 1000000007LL>
class Modlib {
    long long _fact[MaxN + 1];

public:
    // x^n
    long long pow(long long x, long long n) const {
        long long ret = 1LL;
        long long t = x % mod;
        while (n > 0) {
            if (n & 1LL) {
                ret *= t;
                ret %= mod;
            }
            t *= t;
            t %= mod;
            n >>= 1;
        }
        return ret;
    }
    // xの逆元
    // https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
    long long inv(long long a) const {
        long long b = mod, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        u %= mod;
        if (u < 0)
            u += mod;
        return u;
    }
    // n!
    long long fact(long long n) const {
        return _fact[n];
    }
    // nPk
    long long perm(long long n, long long k) const {
        return fact(n) * inv(fact(n - k)) % mod;
    }
    // nCk
    long long comb(long long n, long long k) const {
        return perm(n, k) * inv(fact(k)) % mod;
    }

    constexpr Modlib() : _fact{} {
        _fact[0] = _fact[1] = 1LL;
        for (int i = 2; i <= MaxN; ++i) {
            _fact[i] = _fact[i - 1] * i % mod;
        }
    }
};

constexpr ll mod = 998244353LL;
constexpr auto modlib = Modlib<300000, mod>();

int main() {
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    ll ans = 0;
    for (ll i = 0; i <= n; ++i) {
        ll j = k - a * i;
        if (j % b != 0)
            continue;
        j /= b;
        if (!(0 <= j && j <= n))
            continue;
        ans += modlib.comb(n, i) * modlib.comb(n, j) % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[4],i,j,ans=0;
int main()
{
	for(i=1;i<=3;i++)
	cin>>a[i];
	for(i=1;i<=3;i++)
	{
		sort(a,a+3+1);
	}
	ans=a[1]+a[2];
	cout<<ans;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  long long h,w;
  scanf("%lld %lld",&h,&w);
  if     (h==1&&w==1)printf("1\n");
  else if(h==1||w==1)printf("%lld\n",h+w-3);
  else               printf("%lld\n",(h-2)*(w-2));
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
  int t,x,y;
  cin >> x >> y;
  if(x > y){
    t = x;
    x = y;
    y = t;
  }
  for(int i=0;i<y;i++){
    cout << x;
  }
  return 0;
}


Measured memory_bytes: 256
import sys
from operator import itemgetter as ig
from collections import defaultdict as dd

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def int1(n):
    return int(n) - 1
def input():
    return next(args)
def parse(*params):
    if len(params) == 1:
        return params[0](next(args))
    return tuple(p(v) for p, v in zip(params, next(args).split()))
def debug(*v):
    if __debug__:
        print(*v, file=sys.stderr)

# エントリーポイント
def main():
    N, K = parse(int, int)
    H = [parse(int) for _ in range(N)]

    h = sorted(H)
    l, r = 0, K

    sum_h = [0]
    for n in range(1, N):
        sum_h += [sum_h[-1] + (h[n] - h[n - 1])]
    debug(sum_h)

    diff_h = tuple(sum_h[l + K - 1] - sum_h[l] for l in range(N - K + 1))
    debug(diff_h)
    print(min(diff_h))

if __name__ == '__main__':
    args = iter(sys.stdin.read().split("\n"))
    main()


Measured memory_bytes: 25064
def gcd(a, b):
    if b < a:
        a, b = b, a
    while a % b != 0:
        b, a = a, b % a
    return b

N = int(input())
l = list(map(int, input().split()))
ans = l[0]
for i in range(1, N):
    ans = gcd(ans, l[i])
print(ans)

Measured memory_bytes: 14252
n,a,b=map(int,input().split())
v=list(map(int,input().split()))
v.sort()
v=v[::-1]
print(sum(v[:a])/a)
def com(x,y):
    a=1
    b=1
    y=min(y,x-y)
    for i in range(x,x-y,-1):
        a*=i
    for i in range(1,y+1):
        b*=i
    return a//b
ans=0
x=v.count(v[a-1])
y=v[:a].count(v[a-1])
if v[0]!=v[a]:
    ans+=com(x,y)
else:
    for j in range(a,min(b,x)+1):
        ans+=com(x,j)
print(ans)

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

int main(){
  int64_t X;
  cin >> X ;

  int64_t Y=100;
  int res=0;

  for (int i = 1; i < 3761; i++) {
   Y = Y*1.01;
   if (Y>=X){
     res = i;
     break;
   }
  }

 cout << res << endl;
 return 0;

}

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

using namespace std;

typedef long long ll;

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    ll h[n];
    for (int i = 0; i < n; ++i) {
        scanf("%lld", &h[i]);
    }
    vector<ll> dp(n, LLONG_MAX);
    dp[0] = 0LL;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j <= i + k; j++) {
            if (j < n) dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }
    printf("%lld\n", dp[n - 1]);
    return 0;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int a;
	string s;
	cin >> a >> s;

	cout << (a < 3200 ? "red" : s) << endl;



	return 0;
}

Measured memory_bytes: 256