akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        solve();
    }

    void solve() {
        int min = Integer.MAX_VALUE;
        for (int i = 1; i <= n / 2; i++) {
            int iT = i;
            int j = n - i;
            int iDig = 0;
            int jDig = 0;
            while (iT > 0) {
                iDig += iT % 10;
                iT /= 10;
            }
            while (j > 0) {
                jDig += j % 10;
                j /= 10;
            }
            if (iDig + jDig < min) {
                min = iDig + jDig;
            }
        }
        System.out.println(min);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21076
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 1000001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

int ceil(int x, int y) { return (x % y == 0) ? x / y : x / y + 1; }

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

int lcm(int x, int y) { return x / gcd(x, y) * y; }

ll fac[MAX], finv[MAX], inv[MAX];
void init_comb() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll comb(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;
}

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

  int x, y;
  cin >> x >> y;

  if ((x + y) % 3 != 0 || (2 * x - y) % 3 != 0) {
    cout << "0" << endl;
    return 0;
  }

  int c = (2 * x - y) / 3;

  if (c < 0 || x - 2 * c < 0) {
    cout << "0" << endl;
    return 0;
  }

  init_comb();

  ll ans = (((fac[x - c] * finv[x - (2 * c)]) % MOD) * finv[c]) % MOD;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#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 pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
const ll mod=1000000007; // 998244353 = (119<<23)+1
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
// head
const int nax=1e5+7;
int A,B,q;
ll a[nax],b[nax];
int main() {
	  ios::sync_with_stdio(false);
  	cin.tie(0);
		cin>>A>>B>>q;
		rep(i,0,A) cin>>a[i];
		rep(i,0,B) cin>>b[i];
		sort(a,a+A);
		sort(b,b+B);
		rep(i,0,q) {
			ll x,ans=1e17;
			cin>>x;
			int p1=lower_bound(a,a+A,x)-a;
			int p2=lower_bound(b,b+B,x)-b;
			if(p1>0&&p2>0) ans=min(ans,x-min(a[p1-1],b[p2-1]));
			if(p1<A&&p2<B) ans=min(ans,max(a[p1],b[p2])-x);
			if(p1>0&&p2<B) ans=min(ans,min(abs(x-a[p1-1]),abs(x-b[p2]))*2LL+max(abs(x-a[p1-1]),abs(x-b[p2])));
			if(p2>0&&p1<A) ans=min(ans,min(abs(x-a[p1]),abs(x-b[p2-1]))*2LL+max(abs(x-b[p2-1]),abs(x-a[p1])));
			cout<<ans<<'\n';
		}
		return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <set>
#define INF 1e8

using namespace std;
int main(){
  int n,m;
  while(cin>>n,n){
  	cin>>m;
    vector<vector<int> > g(n);
    for(int i=0;i<n;++i){
      g[i].reserve(n);
      for(int j=0;j<n;++j) g[i][j]=INF;
    }
    for(int i=0,a,b,d;i<m;++i){
      scanf("%d,%d,%d",&a,&b,&d);
      g[a][b]=d/100-1;
      g[b][a]=d/100-1;
    }
    int ans=0;
    set<int> v;
    v.insert(0);
    while(v.size()!=n){
      int min_cost=INF,to=0;
      for(set<int>::iterator vit=v.begin();vit!=v.end();++vit){
        for(int i=0;i<n;++i){
          if(v.find(i)==v.end()&&g[*vit][i]<min_cost){
            to=i;
            min_cost=g[*vit][i];
          }
        }
      }
      ans+=min_cost;
      v.insert(to);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1292
//g++  5.4.0
// Time-complexity : ( 3^n * n + 2^n * n * n )
#include<bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define pii pair< int,int >
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;


signed main()
{
    fast;
    int n;
    cin >> n;
    int a[n][n];
    for(int i=0 ; i<n ; i++ )
    {
        for(int j=0 ; j<n ; j++ )
        {
            cin >> a[i][j];
        }
    }
    int sum[(1<<n)];
    memset( sum,0,sizeof(sum) );
    for(int mask=0 ; mask<(1<<n) ; mask++ )
    {
        for(int i=0 ; i<n ; i++ )
                    {
                        for(int j=i+1 ; j<n ; j++ )
                        {
                            if( (1<<i)&mask && (1<<j)&mask )
                                sum[mask] += a[i][j];
                        }
                    }
    }
    
    int dp[(1<<n)];
    memset( dp,0,sizeof(dp) );
    
    for(int mask=0 ; mask<(1<<n)-1 ; mask++ )
    {
        for(int add_mask=0 ; add_mask<n ; add_mask++ )
        {
            if( !((1<<add_mask) & mask) )
            {
                int new_mask = mask|(1<<add_mask);
                int dummy_mask = mask;
                while( dummy_mask )
                {
                    int add = 0;
                    int have_grp = (dummy_mask|(1<<add_mask));
                    
                    dp[new_mask] = max( dp[new_mask] ,  sum[have_grp] + dp[ mask^dummy_mask ] );
                    dummy_mask = ( mask&(dummy_mask-1) );
                }
            }
        }
    }
    
    
    cout << dp[(1<<n)-1];
}





Measured memory_bytes: 1280
n, m = map(int, input().split())
if abs(n - m) >= 2:
    print(0)
elif abs(n - m) == 1:
    cnt = 1
    for i in range(n, 0, -1):
        cnt = cnt * i % (10 ** 9 + 7)
    for i in range(m, 0, -1):
        cnt = cnt * i % (10 ** 9 + 7)
    print(cnt)
else:
    cnt = 1
    for i in range(n, 0, -1):
        cnt = cnt * i % (10 ** 9 + 7)
    for i in range(m, 0, -1):
        cnt = cnt * i % (10 ** 9 + 7)
    print((cnt * 2) % (10 ** 9 + 7))

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
template<class T> inline bool chmax(T& a, T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){a=b;return 1;}return 0; }
//template end

template<typename M,typename N=M>
struct LazySegmentTree{
    using F=function<M(M,M)>; using G=function<M(M,N)>; using H=function<N(N,N)>;
    int sz,height; vector<M> data; vector<N> lazy;
    const F f;const G g; const H h; const M m1; const N n1;
    LazySegmentTree(int n,const F f,const G g,const H h,const M &m1,const N n1):f(f),g(g),h(h),m1(m1),n1(n1){
        sz=1,height=0; while(sz<n)sz<<=1,height++;
        data.assign(2*sz,m1); lazy.assign(2*sz,n1);
    }
    void build(vector<M> v){
        rep(i,0,v.size())data[i+sz]=v[i];
        rrep(k,sz-1,0)data[k]=f(data[2*k],data[2*k+1]);
    }
    M ref(int k){return lazy[k]==n1?data[k]:g(data[k],lazy[k]);}
    void recalc(int k){while(k>>=1)data[k]=f(ref(2*k),ref(2*k+1));}
    void thrust(int k){rrep(i,height,0)eval(k>>i);}
    void eval(int k){
        if(lazy[k]!=n1){
            lazy[2*k]=h(lazy[2*k],lazy[k]); lazy[2*k+1]=h(lazy[2*k+1],lazy[k]);
            data[k]=ref(k); lazy[k]=n1;
        }
    }
    void update(int a,int b,N x){
        thrust(a+=sz); thrust(b+=sz-1);
        for(int l=a,r=b+1;l<r;l>>=1,r>>=1){
            if(l&1)lazy[l]=h(lazy[l],x),++l;
            if(r&1)--r,lazy[r]=h(lazy[r],x);
        }
        recalc(a); recalc(b);
    }
    M query(int a,int b){
        thrust(a+=sz); thrust(b+=sz-1);
        M L=m1,R=m1;
        for(int l=a,r=b+1;l<r;l>>=1,r>>=1){
            if(l&1)L=f(L,ref(l++)); if(r&1)R=f(ref(--r),R);
        } return f(L,R);
    }
};

int s[200010],t[200010],x[200010];
int d[200010];

int main(){
    int n,q; scanf("%d%d",&n,&q);
    rep(i,0,n)scanf("%d%d%d",&s[i],&t[i],&x[i]);
    rep(i,0,q)scanf("%d",&d[i]);
    vector<int> ord(n); iota(ALL(ord),0);
    sort(ALL(ord),[](int i,int j){return x[i]<x[j];});
    LazySegmentTree<int> seg(q,
    [](int a,int b){return min(a,b);},
    [](int a,int b){return min(a,b);},
    [](int a,int b){return min(a,b);},inf,inf);
    for(int i:ord){
        int l=lower_bound(d,d+q,s[i]-x[i])-d;
        int r=lower_bound(d,d+q,t[i]-x[i])-d;
        seg.update(l,r,x[i]);
    }
    rep(i,0,q){
        int ans=seg.query(i,i+1);
        printf(ans==inf?"-1\n":"%d\n",ans);
    }
    return 0;
}

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

using namespace std;

int main(void){
  int size,num;
  char pict;
  vector<vector<bool>> vec(4,vector<bool>(13,false));

  cin>>size;

  for(int i=0;i<size;i++){
    cin>>pict;
    if(pict=='S'){
      cin>>num;
      vec.at(0).at(num-1)=true;
    }
    else if(pict=='H'){
      cin>>num;
      vec.at(1).at(num-1)=true;
    }
    else if(pict=='C'){
      cin>>num;
      vec.at(2).at(num-1)=true;
    }
    else{
      cin>>num;
      vec.at(3).at(num-1)=true;
    }
  }

  for(int j=0;j<4;j++){
    for(int i=0;i<13;i++){
      if(vec.at(j).at(i)) continue;
      switch(j){
        case 0:
          cout<<'S'<<" "<<i+1<<endl;
          break;
        case 1:
          cout<<'H'<<" "<<i+1<<endl;
          break;
        case 2:
          cout<<'C'<<" "<<i+1<<endl;
          break;
        case 3:
          cout<<'D'<<" "<<i+1<<endl;
          break;
      }
    }
  }

  return 0;
}



Measured memory_bytes: 3080
using System;
                        class Program
                         {
                                static void Main(string[] args)
                                {
                            　　long n,a,b;
                                    //a = int.Parse(Console.ReadLine()); //標準入力
                                    string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
                                    n = long.Parse(str[0]);  //数値で受け取りたい場合は変換する
                                    a = long.Parse(str[1]);
                                  	b = long.Parse(str[2]);
                                  
                                  if(((b - a) % 2) == 0)
                                  {
                                    Console.Write((b - a) / 2);
                                  }
                                  else
                                  {
                                    Console.Write((((b - a) / 2) + 1 + Math.Min((a - 1),(n - b))).ToString());
                                  }
                                }
                         }

Measured memory_bytes: 11092
# x = list(map(int, input().split()))   :  int の リスト入力
# x, y = map(int, input().split())      :  それぞれの変数に　int 入力
# z = set(map(int, input().split()))    :
# t = int(input())                      :   

a = int(input())    

print(a+a*a+a*a*a)

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

typedef long long ll;

static const int MAX = 1e6;
static const int NIL = -1;
static const ll INF = 1<<21;
static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

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

    map<string, int> mp;

    string s;
    //vector<int>::iterator it = V.begin();
    for(int i=0;i<n;i++) {
        cin >> s;
        auto af = mp.insert(make_pair(s,0));
        if(af.second==true) {
            mp[s] = 1;
        }
        else {
            mp[s]+=1;
        }
    }

    int maximum = 0;
    for(auto& x : mp) {
        maximum = max(maximum, x.second); 
    }

    for(auto& x : mp) {
        if(x.second==maximum) cout << x.first << endl;
    }

    return 0;
}


Measured memory_bytes: 26880
import sys
input = sys.stdin.readline
#素数判定
import math
def is_prime(n):
    if n == 1: return 0
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return 0
    return 1
  
Q = int(input())
#print(Q)
count_num = [0]*(10**5) #累積和

#print(count_num)

LR = []
l_min,r_max = float('inf'),0

for i in range(Q):
  l,r = map(int,input().split())
  l_min,r_max = min(l_min,l),max(r_max,r)
  LR.append([l,r])

 
count = 0
for i in range(l_min,r_max+1):
  if(i%2 == 1):
   if(is_prime(i) == 1):
    if(is_prime((i+1)//2) == 1): 
     count += 1
  count_num[i-1] = count


for i in range(Q):
  if(LR[i][0] == 1):
   ans = count_num[LR[i][1]-1]
  else:
   ans = count_num[LR[i][1]-1]-count_num[LR[i][0]-2] 
  print(ans)
#print(count_num)  

Measured memory_bytes: 21256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>

using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to)

int main() {
	string s;
	int sum = 0;
	double goods = 0;
	double cnt = 0;
	while(cin >> s) {
		string t, u;
		int i = 0;
		for(; s[i] != ','; i++) {
			t += s[i];
		}
		i++;
		for(; i != s.size(); i++) {
			u += s[i];
		}
		sum += atoi(t.c_str()) * atoi(u.c_str());
		goods += atoi(u.c_str());
		t = "", u = "";
		cnt++;
	}
	cout << sum << endl << (int) (goods / cnt + 0.5) << endl;
	return 0;
}

Measured memory_bytes: 1188
#include<iostream>
using namespace std;
int main(){
  while(true){
    int q;
    int n;
    bool found=false;
    int cmp = 0;
    cin >> n;
    int a[n];
    if( n == 0 ) break;
    for(int i = 0; i < n; ++i){
      cin >> a[i];      
    }
    cin >> q;
    int l = 0;
    int r = n-1;
    int prem=-1;
    while(l<=r){
      int m = (l+r)/2;
      //      if(prem==m)break;
      if(a[m]>q){
	++cmp;
	r=m-1;
      }else if(a[m]==q){
	++cmp;
	found=true;
	break;
      }else{
	++cmp;
	l=m+1;
      }
      prem=m;
    }
    //if(!found)++cmp;
    cout << cmp << endl;
  }
  return 0;
}

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

int vis[1000010];
int main(){
    ios_base::sync_with_stdio(false);
    vector<int> prime;
    for(int i=2;i<=2e5;i++){
        if(!vis[i])prime.push_back(i);
        for(int j=i;j<=2e5;j+=i)
            vis[j]=1;
    }

    int n;
    cin>>n;
    cout<<*lower_bound(prime.begin(),prime.end(),n);

}



Measured memory_bytes: 1280
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false); cin.tie(0);
	const int mod = 1e9 + 7;
	int h, w;
	cin >> h >> w;
	vector<vector<int>> dp(h, vector<int>(w));
	vector<string> g(h);
	for (int i = 0; i < h; i++) {
		cin >> g[i];
	}
	dp[0][0] = 1;
	queue<pair<int, int>> que;
	vector<vector<int>> vis;
	vis = dp;
	vis[0][0] = 1;
	que.push(make_pair(0, 0));
	int dx[] = {1, 0}, dy[] = {0, 1};
	while (que.size()) {
		pair<int, int> cur = que.front();
		que.pop();
		for (int i = 0; i < 2; i++) {
			int x = cur.first + dx[i];
			int y = cur.second + dy[i];
			if (x < 0 || y < 0 || x >= h || y >= w || g[x][y] == '#') continue;
			dp[x][y] += dp[cur.first][cur.second];
			dp[x][y] %= mod;
			if (!vis[x][y]) que.push(make_pair(x, y));
			vis[x][y] = 1;
		}
	}
	cout << dp[h - 1][w - 1] << endl;
	return 0;	
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define debug(n1) cout<<"debug... "<<n1<<"\n"
#define PI 3.141592653589793238462643383279502
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
class abc
{
    public:
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n;
    cin>>n;
    ve <ll> arr(n);
    rep (i,0,n)
    {
        cin>>arr[i];
    }
    ll x1=1;
    rep (i,0,n)
    {
        // cout<<"x1... "<<x1<<"\n";
        if (arr[i]==x1)
        {
            x1++;
        }
    }
    if (x1==1)
    {
        cout<<"-1";
        return 0;
    }
    cout<<n-x1+1<<"\n";
}


Measured memory_bytes: 1792
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		while(true) {
			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();
			
			if(op.equals("?")) {
				break;
			}else if(op.equals("+")){
				System.out.println(a+b);
			}else if(op.equals("-")) {
				System.out.println(a-b);
			}else if(op.equals("*")) {
				System.out.println(a*b);
			}else if(op.equals("/")) {
				System.out.println(a/b);
			}
		}
	}
}



Measured memory_bytes: 26192
from collections import deque

n=int(input())
l=[list(map(int,input().split())) for i in range(n-1)]

tree=[[]for _ in range(n)]
for a,b in l:
  a-=1
  b-=1
  tree[a].append(b)
  tree[b].append(b)

ans_num=0
for i in tree:
  ans_num=max(ans_num,len(i))

dq=deque()
dq.append((0,0))

seen=set()
seen.add(0)

ans_dict={}
while dq:
  x,color=dq.popleft()

  i=0
  for nx in tree[x]:
    if nx in seen:
      continue

    i+=1
    if i==color:
      i+=1

    seen.add(nx)
    dq.append((nx,i)),
    ans_dict[x+1,nx+1]=i
    ans_dict[nx+1,x+1]=i

print(ans_num)
for i in l:
  print(ans_dict[tuple(i)])

Measured memory_bytes: 83844
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n;

signed main() {
	cin >> n;
	cout << (n*(n - 1)) / 2 << endl;
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

ll W, H;
vector<ll> P, Q;

int main()
{
    ll ans = 0;
    ll edge = 0;
    cin >> W >> H;
    REP(i, W) {
        ll tmp;
        cin >> tmp;
        P.push_back(tmp);
        ans += tmp;
        edge++;
    }
    REP(i, H) {
        ll tmp;
        cin >> tmp;
        Q.push_back(tmp);
        ans += tmp;
        edge++;
    }
    //printf("ans: %lld\n", ans);
    //printf("edge: %lld\n", edge);
    SORT(P);
    SORT(Q);
    ll p_ind = 0, q_ind = 0;
    while(edge < (W+1) * (H+1) - 1) {
        if(P[p_ind] < Q[q_ind]) {
            ans += (H - q_ind) * P[p_ind];
            //printf("P[%lld]: %lld\n", p_ind, P[p_ind]);
            p_ind++;
            edge += (H - q_ind >= 0) ? (H - q_ind) : 0;
        } else {
            ans += (W - p_ind) * Q[q_ind];
            //printf("Q[%lld]: %lld\n", q_ind, Q[q_ind]);
            q_ind++;
            edge += (W - p_ind >= 0) ? (W - p_ind) : 0;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2548
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<int> vi;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    
    //freopen("E:\\Codes\\Problem\\C++\\AAA.txt", "r", stdin);
    //freopen("C:\\Users\\Dell\\Desktop\\Problem\\BBB.txt", "w", stdout);
	
	int n,k;
	cin>>n>>k;
	
	int arr[k];
	
	for(int i=0 ; i<k ; i++){
		cin>>arr[i];
	}
	
	while (true)
	{
		int fg=1;
		int tp=n;
		
		while(tp) //1000
		{
		int tck=tp%10;
		for(int i=0 ; i<k ; i++)
			{
			if(tck==arr[i])
				{
					fg=-1;
					break;
				}
			
			} 
		tp/=10;

		}
		
	if(fg==1)
	{
		cout<<n;
		return 0;
	}
	n++;
	
		
}
	
	

}



Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

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

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

int main() {
    int n;
    cin >> n;
    int t, a;
    cin >> t >> a;
    int h[n];
    for (int i = 0; i < n; i++) cin >> h[i];
    int ans = 0, diff = 1000000000;
    for (int i = 0; i < n; i++) {
        int tmp = 1000 * t - h[i] * 6;
        if (abs(1000 * a - tmp) < diff) {
            diff = abs(1000 * a - tmp);
            ans = i + 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char str[15];
int main()
{
    int n;
    bool ch = false;
    scanf(" %s",str+1);
    n = strlen(str+1);
    for(int i=1;i<=n;i+=2)
    {
        ch|=str[i]!='h'||str[i+1]!='i';
    }
    printf(ch ? "No\n" : "Yes\n");
    return 0;
}


Measured memory_bytes: 256
N = int(input())

cnt = 0
result = 0

num = [1,3,6,10,15,21,28,36,45,55,66]

def prime_factorize(n):
    """[summary]
    素因数分解の関数、整数を入力して配列を返す
    計算量はO(√N)
    Arguments:
        n {[int]} -- 素進数分解するための整数

    Returns:
        list -- 素因数分解した後の数字の配列
    """    
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def factorization(n):
    """[summary]
    素因数分解して、素数の種類とその素数の個数を二次元配列に入れる
    Arguments:
        n {int} -- 素因数分解する整数

    Returns:
        [arr] -- [[素数, 個数], [素数, 個数], ... ]
    """    
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr


L = factorization(N)

if N == 1:
    print(0)
else:
    for p,e in L:
        cnt = 1
        for i in range(2,100):
            cnt += i
            if e < cnt:
                result += i-1
                break
                
    print(result)

Measured memory_bytes: 9548
#107
h, w = map(int, input().split())
h1 = [0]*h
w1 = [0]*w

a = [input() for _ in range(h)]

for i in range(h):
    for j in range(w):
        if(a[i][j]=='#'):
            h1[i] = 1
            w1[j] = 1

for i in range(h):
    if h1[i]==1:
        for j in range(w):
            if(w1[j]==1):
                print(a[i][j], end='')
        print()

Measured memory_bytes: 4468
N = int(input())
S = [input() for _ in range(N)]

x = set(S)
d = {}
for i in x:
    d[i] = 0
for s in S:
    d[s]+=1

y = 0
for key, value in d.items():
    y = max(y, value)
name = []
for key, value in d.items():
    if value==y:
        name.append(key)
name.sort()
for n in name:
    print(n)


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

int main()
{
	map<string, int> w;
	w.insert({"SUN", 7});
	w.insert({"MON", 1});
	w.insert({"TUE", 2});
	w.insert({"WED", 3});
	w.insert({"THU", 4});
	w.insert({"FRI", 5});
	w.insert({"SAT", 6});

	string s;
	cin >> s;
	if(s == "SUN"){
		cout << w[s] << endl;
	}else{
		cout << w["SUN"] - w[s] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mp make_pair
const int maxn = 4e5+5;
const int MOD = 1e9+7;
#define mod(x) x % MOD
#define INF 0x3f3f3f3f

ll w[maxn], v[maxn];
ll dp[maxn];


int main(){
    int n = 0, W = 0;
    while(~scanf("%d %d",&n, &W)){
        for(int i = 1;i <= n;i++){
            scanf("%lld %lld", w + i, v + i);
        }
        for(int i = 1;i <= n;i++){
            for(int j = W;j >= w[i];j--){
                dp[j] = max(dp[j], dp[j-w[i]]+v[i]);
            }
        }
        
        printf("%lld\n", dp[W]);
    }
    return 0;
}

Measured memory_bytes: 5120
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstdio>
using namespace std;

typedef long long ll;

#define rep(i,x) for(int i = 0 ; i < x ; i ++)
#define pb push_back

int main(){
	int M,N,m0,md,n0,nd;
	scanf("%d%d%d%d%d%d",&M,&N,&m0,&md,&n0,&nd);
	
	vector<int> A;
	priority_queue<int,vector<int>,greater<int>> B;
	rep(i,M){
		A.pb(m0);
		m0 = (m0*58+md)%(N+1);
		//A.pb(m0);
	}
	sort(A.begin(),A.end());
	reverse(A.begin(),A.end());
	rep(i,N){
		B.push(n0);
		n0 = (n0*58+nd)%(M+1);
		//B.push(n0);
	}
	
	ll ret = 0 , res = 0;
	rep(i,M){
		while(B.size() > A[i]){
			res += B.top()-i;
			B.pop();
		}
		while(B.size() > 0 && B.top() == i){
			B.pop();
		}
		ret += B.size();
		ret += min ( res , (ll)A[i]-(ll)B.size() );
		res -= min ( res , (ll)A[i]-(ll)B.size() );
	}
	cout << ret << endl;
}

Measured memory_bytes: 37180
import java.util.Scanner;

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

        for(int i=0; i<k+2-1; i++){
            for(int j=i+1; j<k+2; j++){
                if(a * pow(2, i) < b * pow(2, j-i-1) && b * pow(2, j-i-1) < c * pow(2, k+1-j)){
                    System.out.println("Yes");
                    return;
                }
            }
        }

        System.out.println("No");
    }

    static int pow(int a, int b){
        int x = 1;
        for(int i=0; i<b; i++){
            x *= a;
        }
        return x;
    }
}


Measured memory_bytes: 35604
//IOI 2021
//this will accept, By the order of the peaky fucking blinders
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define ff first
#define ss second

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

const int MAXN = 3 * 1000 + 17, inf = 2e9 + 17;

int n, a[MAXN], b[MAXN];
vector<int> adj[MAXN];

int go(int v, int par, int turn) {
	if (!b[v])
		return 3 - turn;
	b[v]--;
	int res = 3 - turn;
	for (auto i : adj[v]) {
		if (i == par) {
			if (b[i] <= b[v])
				res = turn;
		}
		else {
			if (go(i, v, 3 - turn) == turn)
				res = turn;
		}
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i < n; i++) {
		int v, u;
		cin >> v >> u;
		adj[v].pb(u);
		adj[u].pb(v);
	}
	b[0] = inf;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++)
			b[j] = a[j];
		if (go(i, 0, 1) == 1)
			cout << i << ' ';
	}
	return 0;
}

/*
   Don't stare at laptop more than 20 minutes, read problem again :))))
   if you got a formula check it again
   check where you have to output 0 :D
   check if your Solution need long long
   check if you need to use modulo
   you can submit now
*/


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] a= new int[3];
		for(int i=0;i<3;i++) {
			a[i]=scan.nextInt();
		}
		Arrays.sort(a);
		int sum=0;
		for(int i=0;i<2;i++) {
			sum+=a[i];
		}
		System.out.println(sum);
		
	}

}


Measured memory_bytes: 26896
#include<bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)

int main() {
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   int a , b;
   cin >> a >> b;
   cout << (a < b ? string(b , a + '0') : string(a , b + '0')) << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), output("\n"))
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
	int n;
	cin >> n;
	switch(n){
		case 3:
		case 5:
		case 7:
			cout << "YES" << endl;
			break;
		default:
			cout << "NO" << endl;
			break;
	}
	return 0;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    int a, b;
    for(size_t i = 0; i < n; i++)
    {
        cin >> a >> b;
        ans += (b-a+1);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int h;
    cin >> h;
    int w;
    cin >> w;
    vector<string> a(h);
    for (int i = 0; i < h; i++) {
        cin >> a[i];
    }

    vector<bool> row(h, false);
    vector<bool> col(w, false);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (a[i][j] == '#') {
                row[i] = true;
                col[j] = true;
            }
        }
    }

    for (int i = 0; i < h; i++) {
        if (row[i]) {
            for (int j = 0; j < w; j++) {
                if (col[j]) {
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }
}

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

int main(){
  int N;
  cin >> N;
  map<string,int> m;
  string s;
  int64_t n=0;
  for(int i=0;i<N;i++){
    cin >> s;
    sort(s.begin(),s.end());
    if(m.count(s)){
      n+=m.at(s);
      m.at(s)++;
    }else{
      m[s]=1;
    }
  }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 11136
#include<iostream>
using namespace std;
int a,b,c,d;
int main()
{
	cin>>a>>b>>c>>d;
	if(a+b>c+d)
	  cout<<"Left\n";
	else if(a+b==c+d)
	  cout<<"Balanced\n";
	else cout<<"Right\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(ll, n, k);
    n %= k;
    Cout(min(n, abs(n-k)));
}




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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int sum = 0, mx = 0;
    REP(i, 0, N) {
        int L;
        cin >> L;
        sum += L;
        mx = max(mx, L);
    }
    sum -= mx;
    cout << (mx < sum ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <array>
#include <cstddef>
#include <iostream>
#include <stack>

int H, W;
const int HMAX = 1500;
const int WMAX = 1500;

int c[HMAX][WMAX];
int hist[HMAX][WMAX];
int dp[HMAX][WMAX];

struct Rectangle
{
    int height, pos;
};

int main()
{
    std::cin >> H >> W;

    for (size_t i = 1; i <= H; ++i)
    {
        for (size_t j = 1; j <= W; ++j)
        {
            std::cin >> c[i][j];
        }
    }

    // make histogram
    for (size_t j = 1; j <= W; ++j)
    {
        hist[0][j] = 0;
    }
    for (size_t j = 1; j <= W; ++j)
    {
        for (size_t i = 1; i <= H; ++i)
        {
            if (c[i][j] == 1)
            {
                hist[i][j] = 0;
            }
            else
            {
                hist[i][j] = hist[i - 1][j] + 1;
            }
        }
    }
    for (size_t i = 1; i <= H; ++i)
    {
        c[i][W + 1] = 0;
    }

    // for (size_t i = 1; i <= H; ++i)
    // {
    //     for (size_t j = 1; j <= W; ++j)
    //     {
    //         std::cout << hist[i][j] << " ";
    //     }
    //     std::cout << std::endl;
    // }

    int largest = 0;

    for (size_t i = 1; i <= H; ++i)
    {
        std::stack<Rectangle> s;
        for (int j = 1; j <= W+1; ++j)
        {
            if (s.empty() || hist[i][j] > s.top().height)
            {
                s.push(Rectangle{hist[i][j], j});
            }
            else if (hist[i][j] < s.top().height)
            {
                Rectangle rect;
                while (!s.empty() && s.top().height >= hist[i][j])
                {
                    rect = s.top();
                    s.pop();
                    int area = (j - rect.pos) * rect.height;
                    if (area > largest)
                    {
                        largest = area;
                    }
                }

                s.push(Rectangle{hist[i][j], rect.pos});
            }
        }
    }

    std::cout << largest << std::endl;
}



Measured memory_bytes: 19560
#include<stdio.h>
int main(){
  int n, x, i=0;
  int a, b, c;
  while (1) {
    scanf("%d %d", &n, &x);
    if (n == 0 && x == 0) {
      break;
    }
    for (a = 1; a <= n; a++) {
      for (b = a + 1; b <= n; b++) {
        c = x - a - b;
        if (b < c && c <= n) {
          i++;
        }
      }
    }
    printf("%d\n", i);
    i=0;
  }
}

Measured memory_bytes: 2740
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e  2.718281828459045
#define eps 1.0e18
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define memset(x,y) memset(x,y,sizeof(x))
#define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r
#define ll long long
using namespace std;
void bfs(int n){
	int cnt = 0;
	priority_queue <ll,vector<ll>,greater<ll> > q;
	for(int i = 1;i <= 9;i++) q.push(i);
	while(!q.empty()){
		ll x = q.top();
		q.pop();
		cnt++;
		if(cnt == n){
			printf("%lld\n",x);
			return ;
		}
		ll tmp = x %10;
		if(tmp-1ll >= 0ll) q.push(x*10ll+tmp-1ll);
		if(tmp >= 0) q.push(x*10ll+tmp);
		if(tmp+1ll <= 9ll) q.push(x*10ll+tmp+1ll);
	}
	return;
}
int main(){
	int n;
	scanf("%d",&n);
	bfs(n);
    return 0;
}

Measured memory_bytes: 2420
#include <stdio.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  double w;

  while ( scanf ( "%lf", &w ) == 1 )
  {
    if ( w <= 48. )
    {
      puts ( "light fly" );
    }
    else if ( w <= 51. )
    {
      puts ( "fly" );
    }
    else if ( w <= 54. )
    {
      puts ( "bantam" );
    }
    else if ( w <= 57. )
    {
      puts ( "feather" );
    }
    else if ( w <= 60. )
    {
      puts ( "light" );
    }
    else if ( w <= 64. )
    {
      puts ( "light welter" );
    }
    else if ( w <= 69. )
    {
      puts ( "welter" );
    }
    else if ( w <= 75. )
    {
      puts ( "light middle" );
    }
    else if ( w <= 81. )
    {
      puts ( "middle" );
    }
    else if ( w <= 91. )
    {
      puts ( "light heavy" );
    }
    else
    {
      puts ( "heavy" );
    }
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll a, b, c, d;
ll dfs(ll n, map<ll, ll> &mp) {
  if (mp.find(n) != mp.end())
    return mp[n];
  ll mn = LINF;
  if (n < LONG_LONG_MAX/d)
    mn = d*n;
  chmin(mn, (n-n/2*2)*d+a+dfs(n/2, mp));
  chmin(mn, ((n+1)/2*2-n)*d+a+dfs((n+1)/2, mp));
  chmin(mn, (n-n/3*3)*d+b+dfs(n/3, mp));
  chmin(mn, ((n+2)/3*3-n)*d+b+dfs((n+2)/3, mp));
  chmin(mn, (n-n/5*5)*d+c+dfs(n/5, mp));
  chmin(mn, ((n+4)/5*5-n)*d+c+dfs((n+4)/5, mp));
  return mp[n] = mn;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  rep(_, t) {
    ll n;
    cin >> n >> a >> b >> c >> d;
    map<ll, ll> mp;
    mp[0] = 0, mp[1] = d;
    ll ans = dfs(n, mp);
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
  int n; cin >> n;
  vector<string> judge = {"AC", "WA", "TLE", "RE"};
  map<string, int> ans;
  for (int i = 0; i < n; i++) {
    string s; cin >> s;
    ans[s]++;
  }
  for (auto e : judge) {
    cout << e << " x " << ans[e] << endl;
  }
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int x[5];
    for(int i=0; i<5; i++){
        cin >> x[i];
    }

    for(int i=0; i<5; i++){
        if(x[i]==0){
            cout << i+1;
            break;
        }
    }

    return 0;
}

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

vector<long long> F, A;
int n;
long long k;

bool valid(long long mid) {
    long long tempk = k;
    for(int i = 0; i < n; i++) {
        if(F[i] * A[i] > mid) {
            tempk -= A[i] - mid/F[i];
        }
    }
    return tempk >= 0;
}

long long bs() {
    long long l = 0, r = A[n - 1] * F[0] + 5, mid, ans = -1;
    while(l < r) {
        mid = (l + r) / 2;
        if(valid(mid)) r = mid;
        else l = mid + 1;
    }

    return r;
}

int main() {
    cin >> n >> k;
    A.resize(n);
    F.resize(n);
    for(int i = 0; i < n; i++) cin >> A[i];
    for(int i = 0; i < n; i++) cin >> F[i];
    sort(A.begin(), A.end());
    sort(F.begin(), F.end(), greater<>());
    cout << bs();

}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
typedef long long ll;
int main()
{
	ll N,M;
	cin>>N>>M>>s1>>s2;
	ll g=__gcd(N,M);
	ll L = N*M/g;
	bool flag=true;
	for(ll i=0,j=0;i<N&&j<M;i+=N/g,j+=M/g)
	{
		if(s1[i]!=s2[j])	flag=false;
	}
	if(flag)
		cout<<L<<endl;
	else cout<<"-1"<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<vector>
#include<iostream>
#include<algorithm>
#define ll long long

using namespace std;

int main()
{
    long long n;
    cin>>n;
    vector<string> v(n);
    for(long long i=0;i<n;i++)
    {
        cin>>v[i];
        sort(v[i].begin(),v[i].end());
    }
    sort(v.begin(),v.end());
    long long temp=1,sum=0;
    for(ll i=0;i<n-1;i++)
    {
        if(v[i]==v[i+1])
        {
            temp++;
        }
        else
        {
            sum+=(temp*(temp-1))/2;
            temp=1;
        }
    }
    if(temp>0)
    {
        sum+=(temp*(temp-1))/2;
    }
    cout<<sum<<endl;

}


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

using namespace std;

int main()
{
  int N, M; cin >> N >> M;
  vector<string> A(N), B(M);
  for (int i = 0; i < N; ++i) cin >> A[i];
  for (int i = 0; i < M; ++i) cin >> B[i];

  for (int lx = 0; lx < N; ++lx) {
    for (int ly = 0; ly < N; ++ly) {
      if (lx+M > N or ly+M > N) continue;

      int is_matched = true;
      for (int x = 0; x < M; ++x) {
        for (int y = 0; y < M; ++y) {
          if (B[x][y] != A[lx+x][ly+y]) is_matched = false;
        }
      }

      if (is_matched) {
        cout << "Yes";
        return 0;
      }
    }
  }

  cout << "No";
}

Measured memory_bytes: 256
foo x y
    |x `mod` 2 == 0 || y `mod` 2 == 0 = "No"
    |otherwise = "Yes"

main :: IO()
main = do
    line <- getLine
    let a = (read (takeWhile (/= ' ') line) :: Int)
    let b = (read (drop 1 (dropWhile (/= ' ') line)) :: Int)
    putStrLn (foo a b)

Measured memory_bytes: 508
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

ll n;
vvl ds;

bool bdfs(ll v, ll c, vl& cs) {
    if (cs[v] != 0 && cs[v] != c) return false;
    if (cs[v] != 0 && cs[v] == c) return true;

    cs[v] = c;
    bool res = true;
    rep(i, n) {
        if (ds[v][i] == 1) res &= bdfs(i, -c, cs);
    }
    return res;
}

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

    cin>>n;
    vector<string> grid(n);
    cin>>grid;
    ds = vvl(n, vl(n));
    rep(i, n) rep(j, n) {
        ds[i][j] = (grid[i][j] == '1') ? 1 : LINF;
        if (i == j) ds[i][j] = 0;
    }
    vl cs(n);
    bool res = bdfs(0, 1, cs);
    if (!res) {
        cout<<-1<<endl;
        return 0;
    }

    rep(k, n) rep(i, n) rep(j, n) chmin(ds[i][j], ds[i][k] + ds[k][j]);
    ll ans = 0;
    rep(i, n) rep(j, n) chmax(ans, ds[i][j]);
    cout<<ans + 1<<endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;

#define rep(i, N) for (ll i = 0; i < (ll)(N); ++i)
#define ALL(a) (a).begin(),(a).end()

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

ll GetDigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int main(){
	ll N,K;
	cin >> N >> K;
	cout << min(N%K,K-N%K) << endl;
	
	return 0;
}



Measured memory_bytes: 256