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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,M;
ll T;
vector<pll> xyv;
ll mk[50505],mk2[50505];

ll i, j, k;
ll ans[101010];

void T1(){
    vector<bitset<50005>> bt(N+5);
    fornum(i,0,N){
        bt[i + 1][i + 1] = true;
    }
    for (i = M - 1; i >= 0;--i)
    {
        ll x = xyv[i].first;
        ll y = xyv[i].second;
        bt[y] = bt[x] = bt[x] | bt[y];
    }
    bitset<50005> btc = bt[1];
    fornum(i,1,N){
        btc &= bt[i + 1];
    }
    fornum(i,0,N){
        if(btc[i+1])
            break;
    }
    if(i==N){
        printf("-1");
        return;
    }
    ll a = i + 1;
    bitset<50005> bt2;
    bt2[a] = true;
    for (i = M - 1; i >= 0;--i)
    {
        ll x = xyv[i].first;
        ll y = xyv[i].second;
        if(bt2[y]){
            ans[i] = 1;
        }
        bt2[x] = bt2[y] = bt2[x] || bt2[y];
    }
    fornum(i,0,M){
        if(ans[i]==0){
            printf("^");
        }else{
            printf("v");
        }
    }
}


void T2(){
    if(N==2){
        printf("-1");
        return;
    }
    fornum(i,0,N){
        mk[i + 1] = i + 1;
        mk2[i + 1] = 1;
    }
    for (i = M - 1; i >= 0;--i){
        ll x = xyv[i].first;
        ll y = xyv[i].second;
        if(mk2[mk[x]]>1){
            ans[i] = 1;
            --mk2[mk[x]];
            ++mk2[mk[y]];
            mk[x] = mk[y];
        }else{
            ++mk2[mk[x]];
            --mk2[mk[y]];
            mk[y] = mk[x];
        }
    }
    fornum(i,0,M){
        if(ans[i]==0){
            printf("^");
        }else{
            printf("v");
        }
    }
}




int main(){
    scanf("%lld%lld%lld", &N,&M,&T);
    fornum(i,0,M){
        ll x, y;
        scanf("%lld%lld", &x, &y);
        xyv.push_back({x, y});
    }

    if(T==1){
        T1();
    }else{
        T2();
    }
    
    
    
    return 0;
}

Measured memory_bytes: 308336
use std::io::Read;

fn calc(a: &Vec<u64>) -> Vec<usize> {
    let n = a.len();
    let m = 15;
    let mut dp = vec![vec![0; n]; m + 1];
    for i in 0..(m + 1) {
        dp[i][n - 1] = 2 * i;
    }
    for i in (0..(n - 1)).rev() {
        let mut x = a[i];
        let mut y = a[i + 1];
        let mut k = 0;
        for j in 0..(m + 1) {
            while x > y {
                k += 1;
                y *= 4;
            }
            if k <= m {
                dp[j][i] = dp[k][i + 1] + 2 * j;
            } else {
                dp[j][i] = dp[m][i + 1] + 2 * j + 2 * (k - m) * (n - 1 - i);
            }
            x *= 4;
        }
    }
    dp[0].clone()
}

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let mut a: Vec<u64> = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect();
    let x = calc(&a);
    a.reverse();
    let y = calc(&a);
    let mut ans = x[0];
    for i in 1..n {
        ans = std::cmp::min(ans, x[i] + y[n - i] + i);
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 43260
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
ll maxl(ll a, ll b){ return ((a<b)?b:a);}
ll minl(ll a, ll b){ return ((a>b)?b:a);}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int x;
    cin >> x;
    cout << 1-x << endl;
   
}



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

// ABC127B - Algae
// https://atcoder.jp/contests/abc127/tasks/abc127_b

void ABC127B() {

	int r, D, x;
	cin >> r >> D >> x;

	vector<int> xi(11); //2000～2010
	xi[0] = x;
	for (int i = 0; i < 10; i++)
	{
		xi[i + 1] = r * xi[i] - D;
		cout << xi[i + 1] << endl;
	}
}

int main() {
	ABC127B();

	return 0;
}


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

int main()
{
	int n,a;

	std::cin >> n;

	std::vector<int> ball;

	for(int i=0; i<n; ++i)
	{
		for(int i=0; i<10; ++i)
		{
			std::cin >> a;

			ball.push_back(a);
		}
		
		int right=-1,left=-1;

		right = ball[0];

		bool flg1 = 1;

		bool rightOK;

		bool leftOK;

		for(int i=1; i<10; ++i)
		{
			rightOK = ball[i]>right;

			leftOK = (ball[i]>left || left==-1);

			if(rightOK && leftOK)
			{
				if(right>left)
				{
					right = ball[i];
				}
				else
				{
					left = ball[i];
				}
			}
			else if(rightOK)
			{
				right =  ball[i];
			}
			else if(leftOK)
			{
				left = ball[i];
			}
			else
			{
				flg1 = 0;

				break;
			}
		}

		std::cout << (flg1 ? "YES\n" : "NO\n");

		ball.clear();
	}
}

Measured memory_bytes: 1172
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        String word = s.next();
        long sum=0;
        for(int i=0;i<word.length();i++){
            sum+=(word.charAt(i)-'0');
        }
        if(sum%9==0) System.out.println("Yes");
        else System.out.println("No");

    }

}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 29508
// 0201.cpp : テ」ツδ。テ」ツつ、テ」ツδウ テ」ツδ療」ツδュテ」ツつクテ」ツつァテ」ツつッテ」ツδ?テ」ツδ陛」ツつ。テ」ツつ、テ」ツδォテ」ツ?ァテ」ツ?凖」ツ??

//#include "stdafx.h"
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<map>

using namespace std;

map<string,int> s1;
map<string,vector<string> > s2;
int INF=100000000;
int gold(string s){
	int res=0;
	int res2=INF;
	res=s1[s];
	if(s2[s].size()>0)res2=0;
	for(int i=0;i<s2[s].size();i++){
		res2+=gold(s2[s][i]);
	}
	res=min(res,res2);
	return res;
}

int main(void){
	int n,m;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		s1.clear();
		s2.clear();
		for(int i=0;i<n;i++){
			string str;
			int c;
			cin >> str >> c;
			s1[str]=c;
		}
		scanf("%d",&m);
		for(int i=0;i<m;i++){
			string str;
			int k;
			cin >> str >> k;
			for(int j=0;j<k;j++){
				string s;
				cin >> s;
				s2[str].push_back(s);
			}
		}
		string s3;
		cin >> s3;
		printf("%d\n",gold(s3));
	}
    return 0;
}

Measured memory_bytes: 1288
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
   string s;
   cin>>s;
   long long a;
   cin>>a;
   bool flag=true;
   rep(i,a){
       int p;
       cin>>p;
       if(p==2){
           int x;
           cin>>x;
           string c;
           cin>>c;
           if(flag){
                if(x==2){
                    s.append(c);
                }
                else{
                    s.insert(0,c);
                }
           }
           else{
               if(x==2){
                    s.insert(0,c);
                }
                else{
                    s.append(c);
                }
           }
       }
       else{
           flag=!flag;
       }
   }
   if(!flag){
       reverse(s.begin(),s.end());
   }
   cout<<s<<endl;
}



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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order
//order_of_key

const int maxn = 55;
int n,m;
char g[maxn][maxn];

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

  cin>>n>>m;
  for (int i=0; i<n; i++) {
    for (int j=0; j<m; j++) {
      cin>>g[i][j];
    }
  }

  for (int i=0; i<n; i++) {
    for (int j=0; j<m; j++) {
      if (g[i][j]=='.') continue;
      if (i>0 && g[i-1][j]=='#') continue;
      if (j>0 && g[i][j-1]=='#') continue;
      if (i+1<n && g[i+1][j]=='#') continue;
      if (j+1<m && g[i][j+1]=='#') continue;
      out("No");
    }
  }

  cout<<"Yes\n";
  

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define REP(i,n) for (int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define read(x) scanf("%d",&x)
int n,m;
int a[100005];
vector<int> ans;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>m;
	REP(i,m) cin>>a[i];
	int cnt_odd=0;
	REP(i,m) if (a[i]&1) ++cnt_odd;
	if (cnt_odd>2){
		cout<<"Impossible";return 0;
	}
	if (n==1){
		cout<<1<<endl<<1<<endl<<1<<endl;return 0;
	}
	if (m==1){
		cout<<a[1]<<endl;
		cout<<2<<endl;cout<<1<<' '<<a[1]-1<<endl;
		return 0;
	}
	if (cnt_odd==1){
		REP(i,m) if (a[i]&1){
			cout<<a[i];
			ans.pb(a[i]+1);
		}
		REP(i,m) if (!(a[i]&1)){
			cout<<' '<<a[i];
			ans.pb(a[i]);
		}
		cout<<endl;
		ans[ans.size()-1]--;
	}
	if (cnt_odd==0){
		ans.pb(1);
		REP(i,m){
			cout<<a[i]<<' ';
			ans.pb(a[i]);
		}
		cout<<endl;
		ans[ans.size()-1]--;
	}
	if (cnt_odd==2){
		REP(i,m) if (a[i]&1){
			if (cnt_odd==2){
				cout<<a[i];ans.pb(a[i]+1);--cnt_odd;
			}
			else{
				swap(a[i],a[m]);
			}
		}
		REP(i,m) if (!(a[i]&1)){
			cout<<' '<<a[i];ans.pb(a[i]);
		}
		cout<<' '<<a[m]<<endl;if (a[m]>1) ans.pb(a[m]-1);
	}
	cout<<ans.size()<<endl;
	for (int i=0;i<ans.size();++i) cout<<ans[i]<<' ';
	return 0; 
}

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

int N,H,W;
int main () {
    cin >> N >> H >> W;
    int cnt = 0;
    for(int i=0; i<N; i++) {
        int a,b;
        cin >> a >> b;
        if( H <= a && W <= b ) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

int solve(vector<int> a) {
    int sum = 0;
    for(int ai : a) {
        sum += ai;
    }

    vector<int> dp(sum + 1, INT_MIN);
    dp[0] = 0;

    for(int ai : a) {
        for(int x = sum / ai * ai; x >= ai; x -= ai) {
            dp[x] = max(dp[x], dp[x - ai] + 1);
        }
    }

    int res = 0;
    for(int i = 1; i <= sum; i <<= 1) {
        res = max(res, dp[i]);
    }
    return res;
}

int main(){
    int n;
    while(cin >> n && n > 0) {
        vector<int> A(n);
        REP(i, n) cin >> A[i];

        map<int, vector<int>> m;
        REP(i, n) {
            int x = A[i];
            while(x % 2 == 0) x /= 2;
            m[x].push_back(A[i] / x);
        }

        int ans = 0;
        for(auto p : m) {
            ans = max(ans, solve(p.second));
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1748
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <chrono>
#include <utility>

using namespace std;

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

constexpr int cm = 1<<17;
char buff[cm], *ci = buff + cm, ct;

inline char readchar() {
  if (ci - buff == cm) {
    fread(buff, 1, cm, stdin);
    ci = buff;
  }
  return *ci++;
}

inline int readint() {
  int num = 0;
  if (ci - buff + 16 > cm) {
    while ((ct = readchar()) >= '0') {
      num = (num << 3) + (num << 1) + ct - '0';
    }
  } else {
    while ((ct = *ci++) >= '0') {
      num = (num << 3) + (num << 1) + ct - '0';
    }
  }
  return num;
}

int main(){
  auto start = chrono::system_clock::now();

  int n = readint();

  vector<queue<int>> v(1002, queue<int> ());
  rep(i, n) {
    rep(j, n - 1) {
      int a = readint();
      v[i + 1].emplace(a);
    }
  }

  for (int day = 1; day <= n * (n - 1) / 2; ++day) {
    bool done[1002] = {};
    for (int i = 1; i <= n; ++i) {
      if (done[i]) continue;
      if (v[i].empty()) continue;
      int next = v[i].front();
      if (done[next]) continue;
      if (v[next].front() == i) {
        v[i].pop(); v[next].pop();
        done[i] = done[next] = true;
      }
    }
    if (all_of(done, done + n, [](const bool& x){return x == false;})){
      printf("-1");
      return 0;
    }
    if (all_of(v.begin(), v.end(), [](const queue<int>& x){return x.empty();})) {
      printf("%d", day);
      return 0;
    }
    auto now = chrono::system_clock::now();
    auto dur = now - start;
    auto msec = chrono::duration_cast<chrono::microseconds>(dur).count();
    if (msec >= 26700) {
      printf("%d", n * (n - 1) / 2);
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    while (true) {
        string s;
        int y, m, d;
        cin >> s;
        if (s[0] == '#') break;
        cin >> y >> m >> d;
        if (y > 31) {
            cout << "?" << " ";
            printf("%d %d %d\n", y-30, m, d);
        }
        else if (y == 31) {
            if (m >= 5) {
                cout << "?" << " ";
                printf("%d %d %d\n", y-30, m, d);
            }
            else {
                cout << "HEISEI" << " ";
                printf("%d %d %d\n", y, m, d);
            }
        }
        else {
            cout << "HEISEI" << " ";
            printf("%d %d %d\n", y, m, d);
        }
    }
    return 0;
}


Measured memory_bytes: 3244
import java.util.Scanner;

/**
 * Skill Up.
 */
public class Main {
    public static void main(String[] args) {
        var scanner = new Scanner(System.in);
        var n = scanner.nextInt();
        var m = scanner.nextInt();
        var x = scanner.nextInt();

        // load input data
        var costs = new int[n];
        var a = new int[n][m];
        for (int i = 0; i < n; i++) {
            costs[i] = scanner.nextInt();
            for (int j = 0; j < m; j++) {
                a[i][j] = scanner.nextInt();
            }
        }
        // process
        var totalCost = Integer.MAX_VALUE;
        var found = false;
        for (int i = 0; i < Math.pow(2, n); i++) {
            var c = 0;
            var level = new int[m];
            var achieved = true;
            for (int j = 0; j < n; j++) {
                if ((1 & i >> j) == 1) {
                    c += costs[j];
                    for (int k = 0; k < m; k++) {
                        level[k] += a[j][k];
                    }
                }
            }
            for (int l : level) {
                if (l < x) {
                    achieved = false;
                    break;
                }
            }
            if (achieved) {
                totalCost = Math.min(totalCost, c);
                found = true;
            }
        }
        System.out.println(found ? totalCost : -1);
    }
}


Measured memory_bytes: 37740
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt(); 
      if(A>=B && A>=C){
    System.out.println(A*10+B+C);
      }else if(B>=A && B>=C){
	System.out.println(B*10+A+C);
      }else{
	System.out.println(C*10+A+B);
      }
      }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int fr[100005],nex[400005],vi[400005],wi[400005],tot=0;
void add(int x,int y,int z){
	nex[++tot]=fr[x];vi[tot]=y;wi[tot]=z;fr[x]=tot;
}
int n,m,vs[100005],d[100005];
void dfs(int x,int fa){
	vs[x]=1;
	for(int i=fr[x];i;i=nex[i])if(fa!=vi[i]){
		if(d[vi[i]]!=0x7f7f7f7f){
			if(wi[i]!=d[vi[i]]-d[x]){
				puts("No");exit(0);
			}
		}else{
			d[vi[i]]=d[x]+wi[i];
			dfs(vi[i],x);
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,x,y,z;i<=m;++i){
		scanf("%d%d%d",&x,&y,&z);
		add(x,y,z);
		add(y,x,-z);
	}
	memset(d,0x7f,sizeof d);
	for(int i=1;i<=n;++i)if(!vs[i])dfs(i,i);
	puts("Yes");
	return 0;
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const ll mod=1000000007;
int main(void){
    int n,k,ans=0,a[100000];
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<k;i++) ans+=a[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 3652
n, l = map(int,input().split())
num = 0
l1 = []
for i in range(n):
  num += l + i
  if l + n-1 < 0:
    l1.append(num-(l+n-1))
  elif l > 0:
    l1.append(num-(l))
  else:
    l1.append(num)
if l + n-1 > 0:
  print(max(l1))
else:
  print(min(l1))

Measured memory_bytes: 3064
MOD = int(1e9) + 7

def main():
    buf = input()
    buflist = buf.split()
    N = int(buflist[0])
    M = int(buflist[1])
    if M == 1:
        print(1)
        return
    prime_factor = prime_factorization(M)
    factor_count = []
    for k, v in prime_factor.items():
        factor_count.append(v)
    max_factor = max(factor_count)
    nPr = [1]
    nCr = [1]
    factorial = [1]
    rHn = [1]
    for i in range(N, 0, -1):
        nPr.append((nPr[-1] * i) % MOD)
        nCr.append((nCr[-1] * i * modinv(N - i + 1)) % MOD)
    for i in range(1, N + max_factor + 1):
        factorial.append((factorial[-1] * i) % MOD)
    for i in range(1, max_factor+1):
        rHn.append((factorial[N+i-1] * modinv(factorial[N-1]) * modinv(factorial[i])) % MOD)
    combination = 1
    for x in factor_count:
        # n個のボールをr個の箱に入れる場合の組み合わせ総数は？
        # = rHn
        # = n+r-1Cn
        combination = (combination * rHn[x]) % MOD
    print(combination)


def prime_factorization(x):
    n = x
    i = 2
    factor = {}
    while i * i <= n:
        while n % i == 0:
            if i in factor:
                factor[i] += 1
            else:
                factor.update({i : 1})
            n //= i
        i += 1
    if n > 1 or not factor:
        if n in factor:
            factor[n] += 1
        else:
            factor.update({n : 1})
    return factor

def modinv(x, m = MOD):
    b = m
    u = 1
    v = 0
    while b:
        t = x // b
        x -= t * b
        x, b = b, x
        u -= t * v
        u, v = v, u
    u %= m
    if u < 0:
        u += m
    return u

if __name__ == '__main__':
    main()


Measured memory_bytes: 15048
#include<stdio.h>
int main()
{
  int n,change;
  scanf("%d",&n);
 if(n>=1 && n<=10000) 
 {
   if(n%1000==0)
   {
     change=0;
   }
   else
   {
      n=n%1000;
     change=1000-n;
   }
  
 }
  printf("%d",change);
}


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

int main() {
	int N[3], a;
	for (int i = 0;i < 3;i++)
		cin >> N[i];
	for (int i = 0;i < 2;i++)
		if (N[i] > N[i + 1]) {
			a = N[i];
			N[i] = N[i + 1];
			N[i + 1] = a;
		}
	cout << N[2] * 10 + N[1] + N[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define allR(x) (x).rbegin(), (x).rend()
using ll = long long;
using P = pair<int, int>;
const int INF = 2'000'000'000;

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

  cout << a+a*a+a*a*a << endl;

  return 0;
}


Measured memory_bytes: 3620
import sys
input = sys.stdin.readline
N, M = map(int,input().split())
P = []
for i in range(M) :
    p, y = map(int,input().split())
    P.append([p, y, i])

P.sort(key = lambda x: (x[0],x[1]))

ans = [0 for i in range(M)]
count = 1

for i in range(M) :
    num = P[i][2]
    if i > 0 :
        if P[i][0] == P[i-1][0] :
            count += 1
        else :
            count = 1
    ans[num] = str(P[i][0]).zfill(6) + str(count).zfill(6)

for t in ans :
    print(t)


Measured memory_bytes: 32040
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

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

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

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

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  int h1,m1,h2,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;
  int a,b;
  a=h1*60+m1;
  b=h2*60+m2;
  cout<<b-a-k<<endl;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			
			int cnt = 0;
			int[] m = new int[n];
			for(int i=0;i<n;i++){
				String s = sc.next();
				if(s.equals("ru")) m[i] = 1;
				else if(s.equals("lu")) m[i] = -2;
				else if(s.equals("rd")) m[i] = -1;
				else if(s.equals("ld")) m[i] = 2;
			}
			
			for(int i=0;i<n-1;i++){
				if(m[i]*m[i+1]==-2){
					cnt++;
					i++;
				}
			}
			
			System.out.println(cnt);
		}
	}
	
}

Measured memory_bytes: 26924
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	scanf("%d",&n);
	for(int i=n;i>=0;i--){
		if((int)sqrt(i)*(int)sqrt(i)==i){
			printf("%d\n",i);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

const int MAX_N = 100000;
const int MAX_E = 100000;
int n,m; //頂点数,辺数
struct edge{ll to, cost; };
struct edge_for_que{
    ll cost, to ,from; 

    bool operator > ( const edge_for_que& right) const{
        return this -> cost > right.cost;
    }
};

vector<edge> G[MAX_N];
bool used[MAX_N];
vector<P> mintree[MAX_N];

int prim(){
    int res = 0;
    priority_queue< edge_for_que, vector<edge_for_que>, greater<edge_for_que> >  que;
    edge_for_que p = {0,0,0};
    que.push(p);
    while(!que.empty()){
        edge_for_que p = que.top(); que.pop();
        if(used[p.to]) continue;
        used[p.to] = true;
        res+=p.cost;
        rep(i,G[p.to].size()){
            edge_for_que q = {G[p.to][i].cost,G[p.to][i].to,p.to};
            que.push(q);
        }
    }
    return res;
}

P x[MAX_N],y[MAX_N];
int main(){
    cin >> n;
    int x_,y_;
    rep(i,n){
        cin >> x_ >> y_;
        x[i]=P(x_,i),y[i]=P(y_,i);
    }
    sort(x,x+n);
    sort(y,y+n);
    rep(i,n-1){
        edge e1 = {x[i+1].second,x[i+1].first-x[i].first};
        edge e2 = {x[i].second,x[i+1].first-x[i].first,};
        edge e3 = {y[i+1].second,y[i+1].first-y[i].first};
        edge e4 = {y[i].second,y[i+1].first-y[i].first};
        G[x[i].second].push_back(e1);
        G[x[i+1].second].push_back(e2);
        G[y[i].second].push_back(e3);
        G[y[i+1].second].push_back(e4);
    }
    // rep(i,n){
    //     rep(j,G[i].size()){
    //         cout << i << G[i][j].to << G[i][j].cost << endl;
    //     }
    // }
    ll ans = prim();
    cout << ans << endl;
}

Measured memory_bytes: 23408
import sys
a,b=map(int,input().split())
f=True
for i in range(1,1010):#max_a=1
    if int(i*0.08)==a and int(i*0.1)==b:
        ans=i
        f=False
        break
if f:
  print(-1)
else:
  print(ans)


Measured memory_bytes: 2940
n = int(input())
a, b = map(int,input().split())
p = list(map(int,input().split()))
a_cnt = b_cnt = c_cnt = 0

for i in range(n):
  if p[i]<=a:
    a_cnt+=1
  elif p[i]>=a+1 and b>=p[i]:
    b_cnt+=1
  elif p[i]>=b+1:
    c_cnt+=1

print(min(a_cnt, b_cnt, c_cnt))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAXN (int)(1e5+1)
using namespace std;
vector<int>adj[MAXN];
bool visited[MAXN];
int dist[MAXN];
void dfs(int u)
{
	visited[u]=true;
	for(auto v:adj[u])
	{
		if(!visited[v])
			dfs(v);
		dist[u]=max(dist[u],dist[v]+1);
	}
}
int main()
{
	fastio;
	int n,m,x,y;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>x>>y;
		adj[x].push_back(y);
	}
	for(int i=1;i<=n;i++)
	{
		if(!visited[i])
			dfs(i);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		ans=max(ans,dist[i]);
	cout<<ans<<endl;			
}


Measured memory_bytes: 8320
s = input()
k = s.split("LR")
children = [0 for _ in range(len(s))]
place = 0
for i, kk in enumerate(k):
    if 0 < i:
        kk = "R" + kk
    if i < len(k) - 1:
        kk = kk + "L"
    temp_r = 0
    temp_l = 0
    if kk == "RL":
        temp_r = 1
        temp_l = 1
    else:
        for i, color in enumerate(kk):
            if (i % 2 == 0):
                temp_r += 1
            elif (i % 2 == 1):
                temp_l += 1
    num_r = kk.count("R")
    if num_r % 2 == 1:
        children[num_r + place] = temp_l
        children[num_r - 1 + place] = temp_r
    else:
        children[num_r + place] = temp_r
        children[num_r - 1 + place] = temp_l
    place += len(kk)
print(*children)

Measured memory_bytes: 7288
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    cin>>N>>K;
    int score;
    long double prob,ans=0;
    reps(i,1,N+1){
        prob = 1;
        score = i;
        while(score<K){
            score *= 2;
            prob /= 2;
        }
        ans += prob;
    }
    ans /= N;
    cout<<setprecision(12)<<ans<<endl;
}

Measured memory_bytes: 256
import * as fs from "fs";

function main(lines: string[][]) {
  const number = parseInt(lines[0][0]);
  const numbers = [];
  for (let i = 1; i <= number; i++) {
    numbers.push(i);
  }
  const filterd = numbers.filter((num) => {
    if (num % 15 === 0) {
      return false;
    } else if (num % 3 === 0) {
      return false;
    } else if (num % 5 === 0) {
      return false;
    } else {
      return true;
    }
  });

  const sum = filterd.reduce((prev, cur) => prev + cur, 0);
  console.log(sum);
}

const lines = fs
  .readFileSync("/dev/stdin", "utf8")
  .split("\n")
  .map((l) => l.split(" "))
  .filter((input) => !(input.length === 1 && input[0] === ""));

main(lines);


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

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

string S, T;

int main() {
  std::cout << std::fixed << std::setprecision(20);

  cin >> S >> T;

  int ans = 999999;

  if(S.size() == T.size()){
    int n = 0;
    REP(j,T.size()){
      if(T[j] != S[j]){
        n++;
      }
    }
    ans = min(ans,n);
  }

  REP(i, S.size()- T.size()){
    string a = S.substr(i,T.size());
    int n = 0;
    REP(j,T.size()){
      if(T[j] != a[j]){
        n++;
      }
    }
    ans = min(ans,n);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)


int main(){
    ll x;
    cin>>x;
    if(x==1){
        cout<<0<<endl;
    }
    else{
        cout<<1<<endl;
    }
}

Measured memory_bytes: 3620
#include<iostream>
#include<cmath>
#include<vector>
#include<climits>
#include<algorithm>
#include<numeric>
#include<iomanip>
#include<map>
#include<set>
#include<random>
#include<cassert>
using namespace std;
#define ll long long int
#define ld long double
const ll Mod = 1000000007;
ll CaseN=1;
const ld PI = 22/7.0;

bool mycmp(string s,string t)
{
if(s.size()<t.size())
{
return true;	
}		
return false;
}


void solve()
{
 
  bool ans = false;
  char s;
  cin>>s;
  	
  	if(s=='e' || s=='i' || s=='o'  || s=='u'  ||  s=='a')
  	ans = true;
  	
	 if(ans)
  {
  cout<<"vowel"<<endl; 
  }
  else
   {
  cout<<"consonant"<<endl;
  }
 
 
 // cout<<"Case #"<<CaseN<<": ";
   CaseN++;
	// print your ans below;
    
return ;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
	solve();	
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		double lagu = (double)a / c;
		double math = (double)b / d;
		int ans_lagu = (int)Math.ceil(lagu);
		int ans_math = (int)Math.ceil(math);
		if(lagu > math){
			System.out.println(l - ans_lagu);
		}else{
			System.out.println(l - ans_math);
		}
	}
}

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

using namespace std;

bool f[10];

bool ok (int n) {
	while (n) {
		if (f[n % 10])
			return false;
		n /= 10;
	}
	return true;
}

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	for (int i = 0; i < k; i++) {
		int x;
		scanf("%d", &x);
		f[x] = 1;
	}
	while(!ok(n)) {
		n++;
	} 
	printf("%d\n", n);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int a[110];

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

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

    int ans = 0;
    int count = 1;
    int prev = a[0];

    int i = 0;

    for(int i = 1; i < N; ++i) {
        if(prev == a[i]) {
            ++count;

            if(i == N-1) {
                ans += count/2;
            }

        } else {
            ans += count/2;
            count = 1;
        }

        prev = a[i];
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;
typedef pair<int,int> pii;


int H,W,K;
char grid[805][805];
int dist[805][805];
int x0,y0;

int main() {
	cin >> H >> W >> K;
	for (int i=0; i<H; i++) {
		for (int j=0; j<W; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				x0 = i;
				y0 = j;
			}
			dist[i][j] = -1;
		}
	}

	int mind = H*W;
	queue<pii> q;
	q.push(pii(x0,y0));
	while (q.size() > 0) {
		pii cur = q.front();
		q.pop();
		int x=cur.first, y=cur.second;
		if (x < 0 || x >= H || y < 0 || y >= W) continue;
		if (dist[x][y] >= 0 || grid[x][y] == '#') continue;
		dist[x][y] = min(min(x,y),min(H-x-1,W-y-1));
		mind = min(mind,dist[x][y]);
		q.push(pii(x-1,y));
		q.push(pii(x+1,y));
		q.push(pii(x,y-1));
		q.push(pii(x,y+1));
	}

	//cout << mind << endl;
	
	if ((mind+K-1)/K < (dist[x0][y0]+K-1)/K)
		cout << (dist[x0][y0]+K-1)/K << "\n";
	else
		cout << (dist[x0][y0]+K-1)/K + 1 << "\n";
}

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

using ll=long long;
void chmin(ll &a,ll b){
  if(a>b)a=b;
}

int main(){
  int t;cin>>t;
  while(t--){
    int n,ans=0;cin>>n;
    vector<ll>v(n),now;
    for(int i=0;i<n;i++)cin>>v[i];
    string s;cin>>s;
    for(int i=n-1;i>=0;i--){
      for(ll p:now)chmin(v[i],v[i]^p);
      if(v[i])
        if(s[i]=='0')now.push_back(v[i]);
        else ans=1;
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000003
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int q;
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll F[3000005],R[3000005];
void make(){
	F[0] = 1;
	for(int i=1;i<1000005;i++) F[i] = F[i-1]*i%mod;
	for(int i=0;i<1000005;i++) R[i] = modpow(F[i],mod-2);
}

ll calc(ll a,ll d,ll n){
	if(n == 0) return 1;
	if(d == 0) return modpow(a,n);
	ll ret = modpow(d,n)%mod;
	ll L = a*modpow(d,mod-2)%mod;
	L = (L%mod+mod)%mod;
	ll RR = L+n-1;
	//L...RR
	if(L == 0) return 0;
	if(RR >= mod) return 0;
	ll x = F[RR];
	x = x*R[L-1]%mod;
	return (ret*x%mod+mod)%mod;
}
int main(){
	scanf("%d",&q);
	make(); //return 0;
	while(q--){
		ll a,d,n; scanf("%lld%lld%lld",&a,&d,&n);
		ll ans = 1;
	//	for(int i=0;i<n;i++) ans = ans*(a+1LL*i*d)%mod; cout << ans << endl;
		if(n>1000003){
			ll x = calc(a,d,1000003);
			ll y = calc(a,d,n%1000003);
			printf("%lld\n",modpow(x,n/1000003)*y%mod);
		}
		else{
			printf("%lld\n",calc(a,d,n));
		}}}

Measured memory_bytes: 19328
#include<bits/stdc++.h>
using namespace std;
#define N 100
#define INF 1<<25
int n,p[N+1],m[N+1][N+1];
int matrixchainmultiplication(){
  for(int i=1;i<=n;i++) m[i][i]=0;
  for(int l=2;l<=n;l++){
    for(int i=1;i<=n-l+1;i++){
      int j=i+l-1;
      m[i][j]=INF;
      for(int k=i;k<=j-1;k++){
        m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }
  return m[1][n];
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++) cin>>p[i]>>p[i+1];
  cout<<matrixchainmultiplication()<<endl;
  return 0;
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int main() {
  vector<vector<int>> card(3, vector<int> (3, 0));
  vector<vector<bool>> bingo(3, vector<bool> (3, false));
  for(int i = 0; i < 3; i++) {
    for(int j = 0; j < 3; j++) {
      cin >> card[i][j];
    }
  }
  int N; cin >> N;
  for(int i = 0; i < N; i++) {
    int b; cin >> b;
    for(int k = 0; k < 3; k++) {
      for(int j = 0; j < 3; j++) {
        if(card[k][j] == b) bingo[k][j] = true;
      }
    }
  }
  bool judge = false;
  for(int i = 0; i < 3; i++) {
    if(bingo.at(i).at(0) && bingo[i][1] && bingo[i][2] 
       || bingo.at(0).at(i) && bingo[1][i] && bingo[2][i]) {
      judge = true;
      break;
    }
  }
  if(!judge && ((bingo.at(0).at(0) && bingo[1][1] && bingo[2][2])
    || (bingo.at(2).at(0) && bingo[1][1] && bingo[0][2]))) {
    judge = true;
  }
  if(judge) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

const ll infll=9223372036854775806;
const int inf=2147483646;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll i,j,t1,t2,n,m,ans=0;
	cin>>n>>m;
	vector<pair<ll,ll>> g;
	for (i=0;i<n;i++){
		cin>>t1>>t2;
		g.push_back(make_pair(t1,t2));
	}
	sort(g.begin(),g.end());
	for (i=0;i<n;i++){
		if (g[i].second<=m){
			ans+=g[i].second*g[i].first;
			m-=g[i].second;
		}
		else {
			ans+=m*g[i].first;
			break;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2420
#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
constexpr char ln = '\n';

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

int main(){
  ld n;
  cin >> n;
  n /= 3.0;
  ld ans = n*n*n;
  cout << fixed << setprecision(10) << ans << ln;
  return 0;
}

Measured memory_bytes: 256
s = gets.chomp
t = gets.chomp
min = 10 ** 5
0.upto(s.length - t.length) do |i|
	cnt = 0
	t.length.times do |j|
		cnt += 1 if s[i + j] != t[j]
	end
	min = cnt if min > cnt
end
puts min

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

int main(){
  int64_t N;
  cin >> N;
  vector <int64_t> A(N);
  int64_t ans=0;
  bool flag=false;
  int64_t c=0;
  for(int64_t i=0;i<N;i++){
    cin >> A.at(i);
    if(A.at(i)%2!=0){
      c++;
    }
  }
  if(c>=2){
    flag=true;
  }
  int64_t n=0;
  sort(A.begin(),A.end());
  for(int64_t i=0;i<N;i++){
    if(A.at(i)%A.at(1)==0){
      n++;
    }
  }
  if(n==N-1){
    ans=A.at(1);
    cout << ans << endl;
    return 0;
  }
  n=0;
   for(int64_t i=A.at(0);i>0;i--){
     if(flag){
       if(i%2==0){
         continue;
       }
     }
    for(int64_t j=0;j<N;j++){
      if(A.at(j)%i==0){
        n++;
      }
    }
    if(n>=N-1){
      ans=i;
      break;
    }
    n=0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x;
  cin >> x;
  int mx = 1;
  for(int i = 2; i <= sqrt(x) && mx != x; i++){
    int n = (log(x)/log(i));
    int m = pow(i,n);
    if(pow(i, n + 1) <= x) m *= i; 
    mx = max(mx,m);
  }
  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

pair<int,int> d[105];

bool oke(int pos)
{
  if (d[pos].fi == d[pos].se && d[pos+1].fi == d[pos+1].se && d[pos+2].fi == d[pos+2].se) return true;
  return false;
}

int main()
{
  int n;
  cin >> n;
  for(int i=1; i<=n; i++)
  {
    cin >> d[i].first >> d[i].second;
  }
  for(int i=1; i<=n-2; i++)
  {
    if (oke(i))
    {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  return 0;
}


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

using namespace std;
using i64 = long long int;
using ui64 = unsigned long long int;

////////////////////////////////

int main()
{
    using pii = pair<int,int>;
    #define mp make_pair
    int n;
    map< int,pair<int,int> > p;
    while(cin >> n,n){
        p.clear();
        p[0] = mp(0,0);
        for(int i=1;i<n;i++){
            int u,v;
            cin >> u >> v;
            if(v == 0){
                p[i] = mp(p[u].first - 1, p[u].second);
            }else if (v == 1){
                p[i] = mp(p[u].first, p[u].second - 1);
            }else if (v == 2){
                p[i] = mp(p[u].first + 1, p[u].second);
            }else if (v == 3){
                p[i] = mp(p[u].first, p[u].second + 1);
            }
        }
        int si = 0 ,sj = 0,ti = 0,tj = 0;
        for(auto&& x:p){
            si = min(si, x.second.first);
            sj = min(sj, x.second.second);
            ti = max(ti, x.second.first);
            tj = max(tj, x.second.second);
        }
        cout << (ti-si+1) << " " << (tj-sj+1) << endl;
    }
}




Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
using namespace std;
int main (void) {
    int n;

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

    sort(a, a + n);
    double half = (double)a[n - 1] / 2;
    int mi = INT_MAX;
    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
        if (abs(a[i] - half) < mi) {
            mi = abs(a[i] - half);
            ans = i;
        }
    }
    cout << a[n - 1] << " " << a[ans] << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(), v.end()

ll ans[301][301];

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    map<char, ll> m;
    for (ll i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H')
        {
            m[s[0]]++;
        }
    }

    vector<ll> v(5, 0);

    if (m.empty())
    {
        cout << 0 << endl;
    }
    else
    {
        ll p = 0;
        for (auto i : m)
        {
            v[p] = i.second;
            p++;
        }
        ll ans = 0;
        for (ll i = 0; i < 5; i++)
        {
            for (ll j = i+1; j < 5; j++)
            {
                for (ll k = j+1; k < 5; k++)
                {
                    ans += v[i] * v[j] * v[k];
                }
            }
            
        }
        

        cout << ans << endl;
    }
}

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

int main() {
    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    vector<int> dp(n, INT_MAX);
    for(int& x : h) {
        cin>>x;
    }
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i=2; i<n; i++) {
    	int mind = INT_MAX;
    	int lim = (0>i-k) ? 0 : i-k;
    	for(int j=lim; j<i; j++) {
    		if(dp[j] + abs(h[j] - h[i]) < mind ) {
    			mind = dp[j] + abs(h[j] - h[i]);
    		}
    	}
    	dp[i] = mind;
    }
    cout<<dp[n-1];
    return 0;
}

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

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

const int N = 16;
int n, tc, a, b, res;
vector<ii> e[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> tc;
    for (int j = 0; j < tc; ++j) {
      cin >> a >> b;
      e[i].push_back(ii(a - 1, b));
    }
  }

  for (int i = 1; i < (1 << n); ++i) {
    bool ok = true;
    for (int j = 0; j < n; ++j) {
      if (i & (1 << j)) {
        for (auto p : e[j]) {
          int k = p.first, h = p.second;
          if (h) {
            if (!(i & (1 << k))) ok = false;
          } else {
            if (i & (1 << k)) ok = false;
          }
        }
        if (!ok) break;
      }
    }
    if (ok)
      res = max(res, __builtin_popcount(i));
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

ll modpow(ll a, ll n, ll m)
{
  ll ret = 1;
  while (n > 0)
  {
    if (n % 2 == 1) ret = ret * a % m;
    a = a * a % m;
    n /= 2;
  }
  return ret;
}

int main()
{
  ll N, P;
  cin >> N >> P;
  string S;
  cin >> S;

  if (P == 2 || P == 5)
  {
    ll ans = 0;
    for (ll i = N - 1; i >= 0; i--)
    {
      if ((S.at(i) - '0') % P == 0)
        ans += i + 1;
    }
    FINALANS(ans);
  }

  ll ans = 0;

  vector<ll> A(N);
  for (ll i = 0; i < N; i++)
  {
    A.at(i) = S.at(i) - '0';
    A.at(i) %= P;
    A.at(i) *= modpow(10, N - i - 1, P);
    A.at(i) %= P;
  }

  map<ll, ll> mp;
  mp[0]++;
  mp[A.front()]++;
  for (ll i = 1; i < N; i++)
  {
    A.at(i) += A.at(i - 1);
    A.at(i) %= P;
    mp[A.at(i)]++;
  }

  for (auto m : mp)
  {
    ll x = m.second;
    ll tmp = x * (x - 1) / 2;

    ans += tmp;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2564
#include <iostream>
#include <cstdio>
#include <cstring>
#define MOD 1000000007
using namespace std;
const int MAXN = 45;
int f[MAXN][1<<17],forbid,n,x,y,z,kill;
inline bool legal(int x)
{
	return (x&forbid)!=forbid;
}
inline void add(int &x,int a)
{
	x+=a;
	if(x>=MOD)x-=MOD;
}
bool can[1<<17];
int main()
{
	scanf("%d%d%d%d",&n,&x,&y,&z);
	forbid=(((((1<<x)|1)<<y)|1)<<(z-1));
	kill=(1<<17)-1;
	for(int i=0,limit=1<<17;i<limit;++i)can[i]=legal(i);
	f[0][0]=1;
	for(int i=0;i<n;++i){
		for(int sta=0,limit=1<<17;sta<limit;++sta){
			if(!can[sta])continue;
			for(int j=1;j<=10;++j){
				if(!can[(((sta<<1)|1)<<(j-1))&kill])continue;
				add(f[i+1][(((sta<<1)|1)<<(j-1))&kill],f[i][sta]);
			}
		}
	}
	int ans=1;
	for(int i=1;i<=n;++i)
		ans=(long long)ans*10%MOD;
	int del=0;
	for(int i=0,limit=1<<17;i<limit;++i)add(del,f[n][i]);
	cout<<(ans-del+MOD)%MOD<<endl;
	return 0;
}


Measured memory_bytes: 22272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, k;
    cin >> n >> k;
    vector<ll> cnt(26);
    rep(i, n) {
        string p;
        cin >> p;
        cnt[p[0] - 'A']++;
    }
    priority_queue<ll> pq;
    rep(i, 26) pq.push(cnt[i]);
    ll ans = 0;
    while(true) {
        vector<ll> tmp;
        bool f = true;
        rep(i, k) {
            ll v = pq.top(); pq.pop();
            if (v == 0) {
                f = false;
                break;
            }
            tmp.push_back(v - 1);
        }
        if (!f) break;
        rep(i, k) pq.push(tmp[i]);
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3664