akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll a;cin>>a;
    ll arr[a];
    for(int i=0;i<a;i++){
        cin>>arr[i];
    }
    ll ans=0;
    for(int i=0;i<a-2;i++){
        for(int j=i+1;j<a-1;j++){
            for(int k=j+1;k<a;k++){
                ll an=0;
                if(arr[i]!=arr[j] && arr[k]!=arr[j] && arr[i]!=arr[k]){
                    if(arr[i]+arr[j]>arr[k]) an++;
                    if(arr[k]+arr[j]>arr[i]) an++;
                    if(arr[i]+arr[k]>arr[j]) an++;
                }
                if(an==3){
                    ans++;
                }
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		System.out.println(a*b);
	}

}

Measured memory_bytes: 35760
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const ll  MAX=1e18+500;
const int sz=1e7+100;
const ll mod=1e9+7;
ll fact[sz];
ll bigmod(ll a,ll p)
{
    if(p==0) return 1;
    else if(p==1) return (a%mod);
    ll x=bigmod(a,p/2);
    x=(x*x)%mod;
    if(p & 1ll) x=(x*a)%mod;
    return x;
}
int main()
{
    Khela
    ll a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    cin>>x>>y;
    if((x+y)%3 != 0){
        cout<<"0"<<endl;
        return 0;
    }
    m=(x*2-y)/3;
    n=x-(2*m);
    
    if(m<0 || n<0){
        cout<<"0"<<endl;
        return 0;
    }
    fact[0]=1;
    for(i=1;i<=(m+n);i++){
        fact[i]=(fact[i-1]*i)%mod;
    }
    
    ll ans=fact[m+n];
    x=(fact[m]*fact[n])%mod;
    x=bigmod(x,mod-2);
    ans=(ans*x)%mod;

    cout<<ans<<endl;






}

Measured memory_bytes: 6400
#include <stdio.h>
#include <math.h>

int main(){
    

    int W, H;

    while(1){
        scanf("%d %d", &H, &W);
        if((H==0)&&(W==0)){
            break;
        }

        for(int h=0; h<H; h++){
            for(int w=0; w<W; w++){
                if(h%2==0){
                    if(w%2==0){
                        printf("#");
                    }
                    else{
                        printf(".");
                    }
                }
                else{
                    if(w%2==1){
                        printf("#");
                    }
                    else{
                        printf(".");
                    }
                }
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2140
n = int(input())
S = [int(i) for i in input().split()]

def merge(A, left, mid, right):
    L = A[left:mid]
    R = A[mid:right]
    i = 0
    j = 0
    L.append(1000000000)
    R.append(1000000000)
    for k in range(left,right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    return A

def mergeSort(A, left, right, cnt):
    if left+1 < right:
        mid = (left + right)//2
        A, cnt = mergeSort(A, left, mid, cnt)
        A, cnt = mergeSort(A, mid, right, cnt)
        A = merge(A, left, mid, right)
        cnt += right - left
    return A, cnt

S, comp_cnt = mergeSort(S, 0, n, 0)
print(*S)
print(comp_cnt)



Measured memory_bytes: 61656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] L = new long[N];
		for (int i = 0; i < N; i++) {
			L[i] = sc.nextInt();
		}
		sc.close();

		int result = 0;
		int chohuku2 = 0;
		int chohuku3 = 0;
		for (int i = 0; i < N; i++) {
			long a = L[i];
			for (int j = 0; j < N; j++) {
				if (j == i) {
					break;
				}
				long b = L[j];
				for (int k = 0; k < N; k++) {
					if (k == i || k == j) {
						break;
					}
					long c = L[k];
					if (a + b > c && a + c > b && b + c > a) {
						result = result + 1;
						if (a == b && b == c && c == a) {
							chohuku3++;
						} else if (a == b || b == c || c == a) {
							chohuku2++;
						}
					}

				}
			}
		}

		System.out.println(result - chohuku2 - chohuku3);
	}

}


Measured memory_bytes: 36484
#include <iostream>
#include <string>
#include <vector>
#include <set>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int walk(int now, vector<vector<int>> e, std::set<int> remain) {
  remain.erase(now);
  if (remain.size() == 0) return 1;

  int count = 0;

  for (const auto& next : e[now]) {
    if (remain.find(next) != remain.end()) {
      count += walk(next, e, remain);
    }
  }

  return count;
}

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

  vector<vector<int>> e(N);
  int a, b;
  rep(i, M) {
    cin >> a >> b;
    a--;
    b--;
    e[a].push_back(b);
    e[b].push_back(a);
  }

  std::set<int> remain;
  for(int i = 1; i < N; i++) {
    remain.insert(i);
  }
  cout << walk(0, e, remain) << endl;

  return 0;
}


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

int main() {
  int n,k,ans=0;
  cin>>n>>k;
  rep(i,n){
    int b;
    cin>>b;
    ans+=min(2*b,2*(k-b));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{

  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);

  ll k, a, b;
  cin >> k >> a >> b;

  ll ans;
  if (b - a <= 2)
  {
    ans = 1 + k;
  }
  else
  {
    ll bis = 1;
    if (k <= a - 1)
    {
      ans = 1 + k;
    }
    else
    {
      bis += a - 1, k -= a - 1;
      if (k % 2 == 1)
      {
        bis++, k--;
      }
      bis += (b - a) * k / 2;
      ans = bis;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import math

N,H = map(int, input().split())
a = []
b = []
for _ in range(N):
    a_tmp, b_tmp = map(int, input().split())
    a.append(a_tmp)
    b.append(b_tmp)


# 後々投げる刀で、もう斬撃で使わないものはいつ投げても同じ
# ある刀の斬撃の威力以下の投擲威力しか持たない刀は投げる意味がない
# 逆にどの刀の斬撃威力より高い投擲威力を持つ刀はどこかで投げるべき
# 投げるべき刀の合計投擲威力が敵の残り体力を上回った後に、それらの刀を威力が高い順に投げればよい

max_slash_damage = max(a)
damage_of_thrown_katanas = [x for x in b if x > max_slash_damage]
H_rest = H
ans = 0

n_slash = max(0, math.ceil((H_rest - sum(damage_of_thrown_katanas))/max_slash_damage))
H_rest -= max_slash_damage*n_slash
ans += n_slash

if H_rest <= 0:
    print(ans)
    exit()

damage_of_thrown_katanas.sort(reverse=True)
idx = 0

while H_rest > 0:
    H_rest -= damage_of_thrown_katanas[idx]
    idx += 1
    ans += 1

print(ans)

Measured memory_bytes: 12164
#include <iostream>

long long int pow(long long int x, unsigned long long int n)
{
    if (n == 1)
    {
        return x;
    }
    else if (n % 2 == 0)
    {
        return pow(x * x, n / 2);
    }
    else
        return pow(x * x, n / 2) * x;
}

long long int powmod(long long int x, unsigned long long int n, long long int mod = 1000000007)
{
    x = x % mod;
    //   std::cout << "x=" << x << ", n=" << n << std::endl;
    if (n == 1)
    {
        return x;
    }
    else if (n % 2 == 0)
    {
      return powmod(x * x % mod, n / 2);
    }
    else
      return powmod(x * x % mod, n / 2) * x%mod;
}

int main()
{
    long long m, n;
    std::cin >> m >> n;
    std::cout << powmod(m, n) << std::endl;
}



Measured memory_bytes: 3128
/* ex3_4
   urah  */

#include <stdio.h>

int main(void){
    int N, N_init;

    // 入力を受け取る
    scanf("%d", &N);

    // Nの初期値を保持しておく
    N_init = N;

    // ループを使って解く
    for (int i=1; i <= 9; i++) {
        // 一回でも1~9で割り切れた場合
        if (N % i == 0) { 
            N = N / i;
            for (int j = 1; j <= 9; j++){
                // 商は1~9のいずれかであるか
                if (N == j) {
                    printf("Yes\n");
                    return 0;
                }
            }
            // Nをiで割っているのでもとに戻す
            N = N_init;
        }
    }

    printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int main() {
  int H, W;
  cin >> H >> W;

  vector<string> grid(H);
  rep(i, H) { cin >> grid[i]; }

  int cx = 0;
  rep(i, H) {
    bool white = true;
    rep(j, W) { white = white && (grid[i][j] == '.'); }

    rep(j, W) { grid[cx][j] = grid[i][j]; }

    if (!white) {
      cx++;
    }
  }

  int cy = 0;
  rep(j, W) {
    bool white = true;
    rep(i, cx) { white = white && (grid[i][j] == '.'); }

    rep(i, cx) { grid[i][cy] = grid[i][j]; }

    if (!white) {
      cy++;
    }
  }

  rep(i, cx) {
    rep(j, cy) { cout << grid[i][j]; }
    cout << "\n";
  }

  return 0;
}

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

int gcd(int a, int b){
    if(a<b) swap(a, b);
    if(b==0) return a;
    return gcd(b, a%b);
}

int main() {
    int n; cin >> n;
    long long ans=0;
    vector<pair<long long, long long> > vp;
    for(int i=0; i<n; ++i){
        long long a, b; cin >> a >> b;
        vp.push_back({a, b});
    }
    reverse(vp.begin(), vp.end());
    for(int i=0; i<n; ++i){
        vp[i].first += ans;
        if(vp[i].first%vp[i].second!=0){
        ans += vp[i].second - vp[i].first%vp[i].second;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int n, m;
  cin >> n >> m;
  using pi = pair<int,int>;
  vector<pi> v(m);
  repr(i, m, 0) {
    pi p;
    cin >> p.second >> p.first;
    v[i] = p;
  }
  sorti(v);
  int cnt = 0;
  pi now = v[0];
  for (int i = 1; i < m; ++i) {
    pi next = v[i];
    if (now.first <= next.second) {
      cnt += 1;
      now = next;
    }
  }
  cout << cnt + 1 << endl;
}

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

typedef complex<double> P;

#define EPS (1e-10)
#define INF 999999999
#define PI 3.14159265

double dot(P a,P b){
	return (a.real() * b.real() + a.imag() * b.imag());
}

double cross(P a,P b){
	return (a.real() * b.imag() - a.imag() * b.real());
}

double distance_ls_p(P a,P b,P c){
	if(dot(b-a,c-a) < EPS) return abs(c-a);
	if(dot(a-b,c-b) < EPS) return abs(c-b);
	return abs(cross(b-a,c-a)) / abs(b-a);
}

double distance_ls_ls(P a,P b,P c,P d){
	return min(distance_ls_p(a,b,c),
         min(distance_ls_p(a,b,d),
         min(distance_ls_p(c,d,a), distance_ls_p(c,d,b) ) ) );
}

int is_intersected_ls(P a1,P a2,P b1,P b2){
	return ((cross(a2-a1,b1-a1) * cross(a2-a1,b2-a1) < 0) &&
					(cross(b2-b1,a1-b1) * cross(b2-b1,a2-b1) < 0));
}

bool sq_contains_ls(P a,P c,P s,P e){
	return a.real() < s.real() + EPS && s.real() < c.real() + EPS &&
		a.imag() <  s.imag() + EPS && s.imag() < c.imag() + EPS &&
		a.real() < e.real() + EPS && e.real() < c.real() + EPS &&
		a.imag() < e.imag() + EPS && e.imag() < c.imag() + EPS;
}

double calcR(double dist,double h){
	double theta = acos(h / sqrt(h * h + dist * dist));
	double alpha = PI - 2 * theta;
	double r = sin(theta) * sqrt(h * h + dist * dist) / sin(alpha);

	return r;
}

int main(void){
	int n;

	while(cin>>n && n){
		double ans = INF;
		P s,e;
		cin>>s.real()>>s.imag()>>e.real()>>e.imag();

		while(n--){
			P a,b,c,d;
			double h;

			cin>>a.real()>>a.imag()>>c.real()>>c.imag()>>h;

			b = P(c.real(),a.imag());
			d = P(a.real(),c.imag());

			if(is_intersected_ls(s,e,a,b) || is_intersected_ls(s,e,b,c) || is_intersected_ls(s,e,c,d) || is_intersected_ls(s,e,d,a) || sq_contains_ls(a,c,s,e)){
				ans = 0;
			}
			else{
				double dist = min(distance_ls_ls(s,e,a,b),min(distance_ls_ls(s,e,b,c),min(distance_ls_ls(s,e,c,d), distance_ls_ls(s,e,d,a))));
				double r = dist > h ? calcR(dist,h) : dist;
				if(r < 1000 + EPS) ans = min(ans,r);
			}
		}

		printf("%.5lf\n",ans==INF?0:ans);
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
    ll n,ans=0;
    cin >> n;
    vll l(n);
    rep(i,n) cin >> l[i];
    sort(all(l));
    //pvec(l);
    rep(i,n-2){
        REP(j,i+1,n-1){
            auto iter=lower_bound(all(l),l[i]+l[j]);
            ll tmp=iter-l.begin();
            tmp-=j+1;
            ans+=(tmp>0?tmp:0);
            //cout << "j+1=" << j+1 << endl;
            //cout << l[i]+l[j] << " " << tmp << endl;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here

    int N,M,x;

    cin >> N >> M;

    for(int i=0;i<M;i++){
        cin >> x;
        N -= x;
    }

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

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

int main(){
  string S;
  string T;
  cin >> S >> T ;
  int res=0;
  for (int i= 0 ; i<3; ++i){
  if(S[i]==T[i]){
    ++res;
    }
  }
  cout << res <<endl;

}


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

int main(){
  int x[3];cin >> x[0] >> x[1] >> x[2];
  int ans = 0;
  for(int i=0;i<2;i++){
    if(x[i] != x[i+1])ans += 1;
  }
  if(x[0] != x[2])ans += 1;
  if(ans == 0)ans += 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = input()
l = list(map(int, input().split()))
def bubble_sort(arr):
    change = True
    while change:
        change = False
        for i in range(len(arr) - 1):
            if arr[i] > arr[i + 1]:
                arr[i], arr[i + 1] = arr[i + 1], arr[i]
                change = True
    return arr
ans=[]
L= bubble_sort(l)
k=0
for i in range(0,len(l),2):
    k=k+L[i]
print(k)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    // https://atcoder.jp/contests/abc156/tasks/abc156_c

    int N;
    cin >> N;
    vector<int> address(101, 0);
    rep(i, 0, N)
    {
        int x;
        cin >> x;
        address[x]++;
    }

    ll ans = INT64_MAX;
    rep(i, 1, address.size())
    {
        ll cost = 0L;
        rep(k, 1, address.size())
        {
            cost += address[k] * (k - i) * (k - i);
        }

        ans = min(ans, cost);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
//#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve();
void precalc();
clock_t start;
//int timer = 1;

int testNumber = 1;

bool todo = true;

int main() {
#ifdef AIM
    freopen("/home/alexandero/ClionProjects/ACM/input.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    start = clock();
    int t = 1;
    cout.sync_with_stdio(0);
    cin.tie(0);
    precalc();
    cout.precision(10);
    cout << fixed;
    //cin >> t;
    int testNum = 1;
    while (t--) {
        //cerr << testNum << endl;
        //cout << "Case #" << testNum++ << ": ";
        solve();
        ++testNumber;
        //++timer;
    }

#ifdef AIM
    cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif

    return 0;
}

//BE CAREFUL: IS INT REALLY INT?

template<typename T>
T binpow(T q, T w, T mod) {
    if (!w)
        return 1 % mod;
    if (w & 1)
        return q * 1LL * binpow(q, w - 1, mod) % mod;
    return binpow(q * 1LL * q % mod, w / 2, mod);
}

template<typename T>
T gcd(T q, T w) {
    while (w) {
        q %= w;
        swap(q, w);
    }
    return q;
}
template<typename T>
T lcm(T q, T w) {
    return q / gcd(q, w) * w;
}

void precalc() {

}

//#define int li

//const int mod = 1000000007;

vector<int> dsu;

void init(int n) {
    dsu.resize(n);
    for (int  i= 0; i < n; ++i) {
        dsu[i] = i;
    }
}

int find_set(int v) {
    if (dsu[v] == v) {
        return v;
    }
    return dsu[v] = find_set(dsu[v]);
}

void merge(int q, int w) {
    q = find_set(q);
    w = find_set(w);
    dsu[w] = q;
}

void solve() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> poses(m);
    for (int i= 0; i < n;++i) {
        int k;
        cin >> k;
        for (int j = 0 ;j < k; ++j) {
            int lang;
            cin >> lang;
            --lang;
            poses[lang].push_back(i);
        }
    }
    init(n);
    for (int i= 0; i < m; ++i) {
        for (int j = 0; j + 1 < poses[i].size(); ++j) {
            merge(poses[i][j], poses[i][j + 1]);
        }
    }
    int cnt= 0;
    for (int i = 0; i < n; ++i) {
        cnt += dsu[i] == i;
    }
    if (cnt == 1) {
        cout << "YES";
    }
    else {
        cout << "NO";
        }

}


















































Measured memory_bytes: 4608
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

string cmp[16] = {"KIHBR", "KIHBRA", "KIHBAR", "KIHBARA", "KIHABR", "KIHABRA", "KIHABAR", "KIHABARA", "AKIHBR", "AKIHBRA", "AKIHBAR", "AKIHBARA", "AKIHABR", "AKIHABRA", "AKIHABAR", "AKIHABARA"};

int main(){
	
	string str;
	cin >> str;
	
	for(int i = 0; i < 16; i++){
		if(str == cmp[i]){
			cout << "YES" << endl;
			return 0;
		}
	}
	
	cout << "NO" << endl;
	
	return 0;
}

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

int main() {
    char S[4];

    cin >> S;
    if ( (S[0] != S[2] && S[0] == S[1] && S[2] == S[3]) ||
         (S[0] != S[1] && S[0] == S[2] && S[1] == S[3]) ||
         (S[0] != S[1] && S[0] == S[3] && S[1] == S[2]) ){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#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 a,b;
	cin >> a;
	cin >> b;
	
	if(a!=1 && b!= 1){
		cout << 1 << endl;
	}
	else if(a!=2 && b!= 2){
		cout << 2 << endl;
	}
	else{
		cout << 3 << endl;
	}

	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>
using namespace std;
#define all(x) (x).begin(), (x).end()

const long long MOD = 1e9 + 7;
const int N = 2000005;
int n;

long long fact[N + 1];
long long ufact[N + 1];
long long r[N + 1];

long long inq(long long x, long long y)
{
    if (y == 0) return 1;
    long long l = inq(x, y / 2);
    if (y % 2) return l * l % MOD * x % MOD;
    return l * l % MOD;
}

long long ans = 0;
long long w[N + 1];

long long cnk(long long n, long long k)
{
    if (k < 0 || k > n) return 0;
    return fact[n] * ufact[k] % MOD * ufact[n - k] % MOD;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    fact[0] = 1, ufact[0] = 1, r[1] = 1;
    for (int i = 2; i <= N; i++) r[i] = (MOD - (MOD / i) * r[MOD % i] % MOD) % MOD;
    for (int i = 1; i <= N; i++) fact[i] = fact[i - 1] * i % MOD, ufact[i] = ufact[i - 1] * r[i] % MOD;
    //for (int i = 0; i <= n; i++) cout << inq(fact[i], MOD - 2) << " " << ufact[i] << "\n";
    for (int i = 1; i <= n - 1; i++)
    {
        w[i] = cnk(i - 1, n - i - 1) * fact[i] % MOD * fact[n - i - 1] % MOD;
    }
    long long si = 0;
    for (int i = 1; i <= n - 1; i++)
    {
        ans = (ans + (w[i] - w[i - 1] + MOD) * i) % MOD;
        si = (si + w[i]) % MOD;
    }
    cout << ans;
}


Measured memory_bytes: 56576
N = int(input())
if N % 10 == 2 or N % 10 ==4 or N % 10 ==5 or N % 10 ==7 or N % 10 ==9:
  print('hon')
elif N % 10 == 0 or N % 10 ==1 or N % 10 ==6 or N % 10 ==8:
  print('pon')
elif N % 10 == 3:
  print('bon')

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<double> p(n);
    //cout << "e1" <<endl;
    rep(i,n){
        cin >> p[i];
        p[i] = (p[i]+1)/2;
    }
    double ans=0;
    //cout << "e2" << endl;
    

    double bef=0;
    rep(i,k){
        bef += p[i];
    }
    ans = bef;
    //cout << bef << endl;
    for(int i=k;i<n;i++){
        
        bef = bef -p[i-k] +p[i];
        //cout << p[i-k] << " " << p[i];
        
        //cout << "i=" << i << " bef=" << bef << endl;
        ans = max(ans,bef);
    }
    //cout << "e5" << endl;
    cout << fixed << setprecision(12) << ans << endl;
}

Measured memory_bytes: 1792
import math

def resolve():
    X = int(input())
    keika = 0
    yokin = 100

    if X <= yokin:
        print(keika)
        return

    while True:
        yokin = math.floor(yokin * 1.01)
        keika += 1
        if X <= yokin:
            print(keika)
            return


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9176
#include<cstdio>
const int MaxN=100010;
int N,M;
struct edge{int to;edge*next;}E[MaxN*2],*ne=E,*first[MaxN];
void link(int u,int v){*ne=(edge){v,first[u]};first[u]=ne++;}
bool vis[MaxN],col[MaxN];
int ccnt[2];
bool dfs(int i,bool c){
	vis[i]=1;col[i]=c;ccnt[c]++;
	bool res=1;
	for(edge*e=first[i];e;e=e->next){
		if(!vis[e->to]){
			if(!dfs(e->to,!c))res=0;
		}
		else if(col[e->to]==c)res=0;
	}
	return res;
}
int main(){
	scanf("%d%d",&N,&M);
	for(int i=0,a,b;i<M;i++)scanf("%d%d",&a,&b),link(a,b),link(b,a);
	if(dfs(1,0))printf("%lld\n",1ll*ccnt[0]*ccnt[1]-M);
	else printf("%lld\n",N*(N-1ll)/2-M);
}

Measured memory_bytes: 5248
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int max = -1;
        int secondMax = -1;
        for(int i = 0; i < n; i++) {
            int num = sc.nextInt();
            if(max < num) {
                secondMax = max;
                max = num;
            } else if (secondMax < num) {
                secondMax = num;
            }
            a[i] = num;
        }
        for(int num: a) {
          if(num == max) {
              System.out.println(secondMax);
          } else {
              System.out.println(max);
          }
        }
    }
}


Measured memory_bytes: 83256
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

//Winter Bells
public class Main{

	int[] d;
	void run(){
		Scanner sc = new Scanner(System.in);
		int INF = 1<<27;
		for(;;){
			int n = sc.nextInt(), m = sc.nextInt(), p = sc.nextInt();
			if((n|m|p)==0)break;
			int[][] wf = new int[n][n], e = new int[n][n];
			for(int[]a:wf)Arrays.fill(a, INF);
			for(int[]a:e)Arrays.fill(a, INF);
			for(int i=0;i<n;i++)wf[i][i]=0;
			for(int i=0;i<m;i++){
				int s = sc.nextInt(), t = sc.nextInt(), c = sc.nextInt();
				e[s][t] = e[t][s] = wf[s][t] = wf[t][s] = c;
			}
			for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)wf[i][j]=Math.min(wf[i][j], wf[i][k]+wf[k][j]);
			d = new int[n];
			PriorityQueue<Integer> q = new PriorityQueue<Integer>(n, new Comparator<Integer>() {
				public int compare(Integer o1, Integer o2) {
					return d[o1]-d[o2];
				}
			});
//			for(int i=0;i<n;i++){
//				d[i]=wf[0][i];
//				q.add(i);
//			}
//			long[] C = new long[n];
			double[] K = new double[n];
//			C[0] = 1;
//			while(!q.isEmpty()){
//				int v = q.poll();
//				for(int i=0;i<n;i++){
//					if(i==v || e[v][i]==INF)continue;
//					if(wf[0][n-1]==wf[0][v]+e[v][i]+wf[i][n-1]){
//						C[i]+=C[v];
//					}
//				}
//			}
//			q.clear();
			K[n-1] = 1;
			for(int i=0;i<n;i++){
				d[i] = -wf[0][i]; q.add(i);
			}
			while(!q.isEmpty()){
				int v = q.poll();
				for(int i=0;i<n;i++){
					if(i==v || e[i][v]==INF)continue;
					if(wf[0][n-1]==wf[0][i]+e[i][v]+wf[v][n-1]){
						K[i]+=K[v];
					}
				}
			}
//			debug(K);
			double[] res = new double[n];
			res[0] = 1;
			q.clear();
			for(int i=0;i<n;i++){
				d[i]=wf[0][i];
				q.add(i);
			}
			while(!q.isEmpty()){
				int v = q.poll();
				for(int i=0;i<n;i++){
					if(i==v || e[v][i]==INF)continue;
					if(wf[0][n-1]==wf[0][v]+e[v][i]+wf[i][n-1]){
						res[i]+=res[v]*K[i]/K[v];
					}
				}
			}
			while(p--!=0)System.out.printf("%.8f\n", res[sc.nextInt()]);
			System.out.println();
		}
	}
	
	void debug(Object...o){
		System.out.println(Arrays.deepToString(o));
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if((abs(b-a)<=d&&abs(c-b)<=d)||abs(c-a)<=d){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;        
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <stack>
#include <utility>
#include <queue>
using namespace std;
typedef long long int lld;
typedef pair<int, int> pii;



int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int bucket[30];
  fill(bucket, bucket+30, 0);
  string st;
  cin >> st;
  for (int i = 0; i < n; ++i) 
    bucket[st[i] - 'a']++;
  lld ans = 1, M = 1000000007;
  for (int i = 0; i < 30; ++i) {
    ans *= bucket[i] + 1;
    ans %= M;
  }
  cout << ans-1 << "\n";
  return 0;
}

Measured memory_bytes: 512
int main()
	{
		int X,A;
		
		scanf("%d %d",&X,&A);
		
		if(0<=X,A<=9)
		{
			if(X<A)
			{
				printf("0");
				
				
			
			}
		
			 if(X>=A)
			{
				printf("10");
			
			}
			
		}
		else 
		{
			printf("invalid");
		}
		
		
		return 0;
	}

Measured memory_bytes: 2148
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

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

	vector<ll> A(n), B;

	for (auto& a: A)
		cin >> a;

	for (auto i = A.rbegin(); i != A.rend(); i++)
	{
		auto a = (*i);
		auto j = upper_bound(B.begin(), B.end(), a);
		if (j == B.end())
			B.push_back(a);
		else
			(*j) = a;
	}

	cout << B.size() << endl;

	return 0;
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
long long n,k;
int main()
{
	scanf("%lld%lld",&n,&k);
	if(!k) {
		printf("%lld\n",n*n);
		return 0;
	}
	long long ans=0;
	for(int i=1;i<=n-k;++i){
		long long b=k+i;
		ans+=(n/b)*i;
		if(n%b>=k)
		ans+=n%b-k+1; 
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3792
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
	int N = scan.nextInt();

	if (N % 2 == 0) {
		System.out.println(N);
	}else {
		System.out.println(N * 2);
	}

	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include<string>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;
constexpr ll MOD = ll(1e9 + 7);

int n, p;
string s;
map<int, ll> mod_num;
vector<int> u;

int ctoi(char c) {
	int ret = c - '0';
	return ret;
}

int main(void) {
	cin >> n >> p;
	cin >> s;

	ll ret = 0;
	int substr_mod = 0;
	int ten_pow = 1;

	if (p == 2 || p == 5) {
		for (int i = 0; i < n; i++)
			if (ctoi(s[i]) % p == 0)
				ret += ll(i + 1);
	}
	else {
		mod_num[0]++;
		for (int i = n - 1; i >= 0; i--) {
			substr_mod += ctoi(s[i]) * ten_pow;
			substr_mod %= p;
			ten_pow = (ten_pow * 10) % p;
			ret += mod_num[substr_mod];
			mod_num[substr_mod]++;
		}
	}
	cout << ret << endl;
	return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

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

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

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (4 * M * A[i] >= sum) {
            ++cnt;
        }
    }

    cout << (cnt >= M ? "Yes\n" : "No\n");

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/perl
use Data::Dumper;

my $al = "abcdefghijklmnopqrstuvwxyz";
my ($n) = map { $_ - 0 } split(/\s+/,<STDIN>);
$n--;

my $b = 0;
my $bs = 0;

while(1){
  if( $b + 26 ** ($bs+1) > $n ){
    last;
  }
  $bs++;
  $b += ( 26 ** $bs );
}

my $n2 = $n - $b;

my $s = '';
for(my $i=0;$i<($bs+1);$i++){
  my $d = $n2 % 26;
  $s = substr($al,$d,1) . $s;
  $n2 -= $d;
  $n2 /= 26;
}
print "$s\n";




Measured memory_bytes: 6400
from fractions import gcd

def lcm(a, b):
    return (a*b) // gcd(a, b)

N, M = map(int, input().split())
S = input()
T = input()

n = N // gcd(N, M)
m = M // gcd(N, M)
k = gcd(N, M)

for i in range(k):
    if S[i * n] != T[i * m]:
        print(-1)
        exit()

print(lcm(N, M))

Measured memory_bytes: 5344
#include<stdio.h>

int main(){
  int product;
  int a, b;
  
  scanf("%d", &product);
  
  for(a=1; a<10; a++){
    for(b=1; b<10; b++){
      if(product == (a*b)){
        printf("Yes");
        return 0;
      }
    }
  }
  
  printf("No");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int A, B;
  cin >> A >> B;
  int ans = (A + B) % 24;
  cout << ans << endl;
  return 0;
}

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

template <int MOD_>
struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");
 
private:
	using ll = long long;
 
	int v;
 
	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}
 
public:
 
	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }
 
	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }
 
	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}
 
	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}
 
	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}
 
	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
using num = modnum<int(1e9) + 7>;

const int MAXN = 5010;
int N;
vector<int> adj[MAXN];

num dp[MAXN][MAXN];
num buf[MAXN];

int dfs(int cur, int prv) {
	int sz = 1;
	dp[cur][1] = 1;
	for (int nxt : adj[cur]) {
		if (nxt == prv) continue;
		int csz = dfs(nxt, cur);

		for (int i = 0; i <= sz + csz; i++) {
			buf[i] = 0;
		}
		for (int i = 0; i <= sz; i++) {
			for (int j = 0; j <= csz; j++) {
				buf[i+j] += dp[cur][i] * dp[nxt][j];
			}
		}
		for (int i = 0; i <= sz + csz; i++) {
			dp[cur][i] = buf[i];
		}
		sz += csz;
	}

	num coeff = -1;
	for (int i = 2; i <= sz; i += 2) {
		coeff *= i-1;
		dp[cur][0] += dp[cur][i] * coeff;
	}

	return sz;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int e = 0; e < N-1; e++) {
		int a, b; cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	dfs(1, 0);
	cout << -dp[1][0] << '\n';

	return 0;
}


Measured memory_bytes: 99072
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  ll n;
  cin >> n;
  if(n % 2 == 1){
    say(0);
  }else{
    // ll ans = n / 10;
    vector<ll> hoge;
    ll num = 10;
    while(true){
      if(n/num != 0){
        hoge.push_back(n/num);
        num *= 5;
      }else{
        break;
      }
    }
    if(hoge.empty()){
      say(0);
    }else{
    //   ll sum = 0;
    //   ll a = hoge.size();
    ll ans = 0;
    ans = sum_vll(hoge);
    say(ans);
    }
    //   reverse(hoge.begin(), hoge.end());
    //   rep_i(i, hoge.size()){
    //     if(i == 0){
    //       ans += a*hoge[i];
    //       a -= 1;
    //       sum += hoge[i];
    //     }
    //     ans += a*(hoge[i] - hoge[i - 1]);
    //     a -= 1;
    //     // sum += hoge[i];
    //   }
    //   say(ans);
    // }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main() {
  int n;
  cin >> n;
  vector<pair<string,char>> ans;
  ans.push_back({"a",'a'});
  if(n==1){ cout << "a" << endl; return 0;}
  for(int i=1; i<n;i++){
    vector<pair<string,char>> tmp;
    for(auto it:ans){
      for(int j=0; j<=i;j++){
        if(it.S+1>=(char)('a'+j)){
          tmp.push_back({it.F+(char)('a'+j), max(it.S,(char)('a'+j))});
        }
      }
    }
    swap(tmp,ans);
  }
  for(auto it:ans){ cout << it.F << endl; }
  return 0;
}

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

using namespace std;

main(){
  int a, b, c, d, e;
  cin >> a >> b >> c;
  int ans1 = min(a, min(b, c));
  cin >> d >> e;
  int ans2 = min(d, e);
  cout << ans1 + ans2 - 50 << endl;
}

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



int main()
{
    int a, b;
    char c;

    scanf("%d %c %d", &a, &c, &b);
    if(c == '+'){
        cout<<a+b<<endl;
    }
    else{
        cout<<a-b<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
/*input
a
aa
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const int maxn=2e5+5;
const int maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
int arr[maxn];
bool wk[maxn];
int main(){
    string s,t;
    cin>>s>>t;
    s+=t.back();
    if(s==t){
        cout<<"Yes";
    }
    else cout<<"No";
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MAX=1e18;
ll mod=1e9+7;
#define pb push_back
#define se second
#define fi first
#define maxe max_element
#define mine min_element
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define boost  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
vector<int> graph[205];
int color[205];
int nCk[100][100];
bool bipartite_jugding(int v, int c){
    color[v] = c;
    for(int i = 0; i < graph[v].size(); ++i){
        if(color[graph[v][i]] == c) return false;
        if(color[graph[v][i]] == 0 && !bipartite_jugding(graph[v][i], -c)){
            return false;
        }
    }
    return true;
}

 void combi() {
	for (int i = 0; i <= 99; ++i) nCk[i][0] = 1;
	for (int i = 1; i <= 99; ++i) for (int j = 1; j <= i; ++j) {
		nCk[i][j] = (nCk[i-1][j] + nCk[i-1][j-1]) % mod;
	}
}

long long expo(ll x,ll n,ll M)
{

    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*expo((x*x)%M,(n-1)/2,M))%M;

}
ll h,n;
void solve()
{
   cin>>h>>n;
   ll j=h-(h/n)*n;
   cout<<h/n+(j!=0)<<endl;
}

int main()
{
    boost;
  solve();
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int n, x, cnt;

  while(cin >> n >> x && n || x) {
    cnt=0;
    for(int i=1; i <= n-2; i++) {
      for(int j=i+1; j <= n-1; j++) {
        for(int k=j+1; k <= n; k++) {
          if(i+j+k == x) cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 3116
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N, K = MAP()

print(K*(K-1)**(N-1))

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

int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  int k;
  cin >> k;
  if (e - a > k)
    cout << ":(" << endl;
  else
    cout << "Yay!" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  int main(void) {
	int a,b,c;
  	int d,e,f;
  	int max;
    cin>>a;
    cin>>b;
  	cin>>c;
  	d = a + b;
  	e = a - b;
  	f = a * b;
  	max = d;
  	if( max < e){
      max = e;
    }
    if( max < f){
      max = f;
    }
  	
  	cout << max;
  
  	return 0 ;
    	
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<queue>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	double sum=a[0];
	for(int i=1;i<n;i++){
		sum+=a[i];
		sum=sum/2.0;
	}
	printf("%lf",sum);
	return 0;
}

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

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

  int N;
  cin >> N;

  int flg;
  while (flg == 1) {
    flg = 0;
    for (int i = 2; i <= (int)sqrt(N); i++) {
      if (N % i == 0) {
        flg = 1;
        break;
      }
    }
    if (flg == 1) {
      ++N;
    } else {
      break;
    }
  }

  cout << N << '\n';
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b;
scanf("%d %d",&a,&b);
if(a==0){
if(b>=1868 && b<=1911){
printf("M%d\n",b-1867);
}
else if(b<=1925){
printf("T%d\n",b-1911);
}
else if(b<=1988){
printf("S%d\n",b-1925);
}
else if(b<=2016){
printf("H%d\n",b-1988);
}
}
else if(a==1){
printf("%d\n",b+1867);
}
else if(a==2){
printf("%d\n",b+1911);
}
else if(a==3){
printf("%d\n",b+1925);
}
else if(a==4){
printf("%d\n",b+1988);
}
return 0;
}


Measured memory_bytes: 2136