akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        Dice dice = new Dice(sc, x);
        if(check(dice)){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
    
    public static boolean check(Dice dice) {
        char[] pat = {'N','N','E','E','E','N'};
        for(int j = 0; j < dice.data.length; j++){
            for(int k = 0; k < dice.data.length; k++){
                if(j >= k){ continue; }
                for(char p:pat){
                    if(Arrays.equals(dice.data[j], dice.data[k])){
                        return true;
                    }
                    dice.roll(j, p);
                    for(int i = 0; i < 4; i++){
                        if(Arrays.equals(dice.data[j], dice.data[k])){
                            return true;
                        }
                        dice.roll(j, 'Z');
                    }
                }
            }
        }
        return false;
    }
}

class Dice {
    static int[][] data;

    public Dice(Scanner sc, int x){
        data = new int[x][6];
        for(int i = 0; i < data.length; i++){
            for(int j = 0; j < data[i].length; j++){
            data[i][j] = sc.nextInt();
            }
        }
    }

    public static void roll(int n, char p) {
        int temp = data[n][0];
        switch(p){
            case 'E':
                data[n][0] = data[n][2];
                data[n][2] = data[n][5];
                data[n][5] = data[n][3];
                data[n][3] = temp; break;
            case 'W':
                data[n][0] = data[n][3];
                data[n][3] = data[n][5];
                data[n][5] = data[n][2];
                data[n][2] = temp; break;
            case 'S':
                data[n][0] = data[n][1];
                data[n][1] = data[n][5];
                data[n][5] = data[n][4];
                data[n][4] = temp; break;
            case 'N':
                data[n][0] = data[n][4];
                data[n][4] = data[n][5];
                data[n][5] = data[n][1];
                data[n][1] = temp; break;
            case 'Z':
                temp = data[n][1];
                data[n][1] = data[n][2];
                data[n][2] = data[n][4];
                data[n][4] = data[n][3];
                data[n][3] = temp; break;
            default:
        }
    }
}

Measured memory_bytes: 29816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cout << "[" << #var << "] " << var << endl
const ll mod = 1000000007;
const int INF = 1001001001;

int a[15][15];

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    int ans = INF;

    vector<int> c(n);
    

    rep(i, n) {
        cin >> c[i];
        rep(j, m) {
            cin >> a[i][j];
        }
    }

    rep(i, 1<<n) {
        vector <int> s(m);
        int sum = 0;
        rep(j, n) {
            if ((i>>j&1)==0) continue;
            sum += c[j];
            rep(k, m) {
                s[k] += a[j][k];
            }
        }
        bool ok = true;
        rep(j, m) {
            if (s[j]<x) ok = false;
        }
        if (ok) {
            ans = min(ans, sum);
        }
    }
    
    if (ans==INF) ans = -1;
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int MAXN=1000000,n;
bool prime[1000005];
void make_prime(){
    memset(prime,1,sizeof(prime));
    prime[0]=prime[1]=false;
    int t=sqrt(MAXN);
    for(int i=2;i<=t;i++){
        if(prime[i]){
            for(int j=2*i;j<MAXN;j+=i){
                prime[j]=false;
            }
        }
    }
    return;
}
int main(){
	scanf("%d",&n);
	make_prime();
	for(int i=1;i<=MAXN;i++){
		if(i>=n&&prime[i]){
			printf("%d",i);
			return 0;
		}
	}
	return 0;
}


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

int main() {
  int a,b;
  
  cin >> a >> b;
  
  if ( a * b % 2 == 1 ){
    cout << "Odd" << endl;
  }
  
  else{
    cout << "Even" << endl;
  }  
}

Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

#define MAX_N 25

int
main(int argc, char **argv)
{
	int a[MAX_N];

	while (true)
	{
		int n;
		scanf("%d", &n);
		if (n == 0)
			break;

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

		int j = 0;
		int k = 32;
		while (k != 0)
		{
			k -= (k - 1) % 5;
			if (k < 0)
				k = 0;

			printf("%d\n", k);
			if (k == 0)
				break;

			k -= a[j];
			if (k < 0)
				k = 0;

			j = (j + 1) % n;
			printf("%d\n", k);
		}
	}

	return 0;
}


Measured memory_bytes: 2036
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let k = read::<usize>();
    let mut ans = 0;
    for _i in 0..n {
        let h = read::<usize>();
        if h >= k {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<string, bool> P;
typedef pair<ll, P> PP;

const ll INF = 10000000000000000;

int main()
{
    int n;
    cin >> n;
    string s[52];
    ll c[52];
    priority_queue<PP, vector<PP>, greater<PP>> que;
    map<P, ll> mp;
    for(int i = 0; i < n; i++){
        cin >> s[i] >> c[i];
        que.push(PP(c[i], P(s[i], true)));
        que.push(PP(c[i], P(s[i], false)));
        mp[P(s[i], true)] = c[i];
        mp[P(s[i], false)] = c[i];
    }
    ll ans = INF;
    while(que.size()){
        PP p = que.top();
        que.pop();
        string t = p.second.first;
        bool left = p.second.second;
        ll d = p.first;
        if(d >= ans) break;
        if(mp[p.second] < d) continue;
        int k = t.size();
        bool f = true;
        for(int i = 0; i < k; i++){
            if(t[i] != t[k - i - 1]){
                f = false;
                break;
            }
        }
        if(f){
            ans = min(ans, d);
            continue;
        }
        for(int i = 0; i < n; i++){
            int l = s[i].size();
            bool f = true;
            if(left){
                for(int j = 0; j < min(k, l); j++){
                    if(t[j] != s[i][l - j - 1]){
                        f = false;
                        break;
                    }
                }
            }
            else{
                for(int j = 0; j < min(k, l); j++){
                    if(s[i][j] != t[k - j - 1]){
                        f = false;
                        break;
                    }
                }
            }
            if(f){
                P p;
                if(left){
                    if(k <= l) p = P(s[i].substr(0, l - k), false);
                    else p = P(t.substr(l), true);
                }
                else{
                    if(k <= l) p = P(s[i].substr(k), true);
                    else p = P(t.substr(0, k - l), false);
                }
                if(mp[p] == 0 || d + c[i] < mp[p]){
                    que.push(PP(d + c[i], p));
                    mp[p] = d + c[i];
                }
            }
        }
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 3668
#include <iostream>
using namespace std;
int main() {
    int a,b;
    cin >> a >> b ;
    if (a>b)
        cout<<"a > b"<< endl;
    else if(a<b)
        cout<<"a < b"<<endl;
    else
        cout<<"a == b"<<endl;
    return 0;
    
}

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

long long MOD=1000000007LL;

int main(){
	int N;
	cin >> N;
	vector<pair<int,int>> ab;
	for(int i=0;i<N;i++){
		int a;
		cin >> a;
		ab.push_back(make_pair(a,1));
	}
	for(int i=0;i<N;i++){
		int b;
		cin >> b;
		ab.push_back(make_pair(b,2));
	}
	
	sort(ab.begin(),ab.end());
	long long ans=1LL;
	long long a=0LL,b=0LL;
	for(int i=0;i<2*N;i++){
		if(ab[i].second==1){
			if(b==0LL)a++;
			else{
				ans*=b;
				b--;
			}
		}
		else{
			if(a==0LL)b++;
			else{
				ans*=a;
				a--;
			}
		}
		if(ans>=MOD)ans%=MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3444
from collections import defaultdict

from operator import mul
from functools import reduce
 
def cmb(n,r):
    if n < r:
        return 0
    r = min(n-r,r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    sum_A = [0] * (N+1)

    for i in range(1,N+1):
        sum_A[i] = (sum_A[i-1] + A[i-1]) % M
        
    ans = 0
    d = defaultdict(int)
    for i in range(N+1):
        d[sum_A[i]] += 1

    for i,j in d.items():
        ans += cmb(j,2)

    print(ans)

main()

Measured memory_bytes: 62576
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
   string s;
   cin >> s;
   bool isbad = false;
   if(s[0] == s[1])
      isbad = true;
   if(s[1] == s[2])
      isbad = true;
   if(s[2] == s[3])
      isbad = true;
   
   if(isbad)
      cout << "Bad" << endl;
   else
      cout  << "Good" << endl;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
 
int G[N*2][N*2];
int getNum(int x1,int y1,int x2,int y2){//以(x1,y1)为左上角(x2,y2)为右下角的点的数量
    return G[x2][y2]-G[x1][y2]-G[x2][y1]+G[x1][y1];
}
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        int x,y;
        char c;
        scanf("%d %d %c",&x,&y,&c);
        if(c=='W')//反色
            x+=k;
        //取模压缩
        x=x%(k*2);
        y=y%(k*2);
        G[x+1][y+1]++;//从点(1,1)开始
    }
 
    for(int i=1;i<=2*k;i++)
        for(int j=1;j<=2*k;j++)
            G[i][j]+=G[i-1][j]+G[i][j-1]-G[i-1][j-1];//容斥
 
    int res=-INF;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            int temp1=getNum(0,0,i,j);
            int temp2=getNum(0,j+k,i,2*k);
            int temp3=getNum(i+k,0,2*k,j);
            int temp4=getNum(i+k,j+k,2*k,2*k);
            int temp5=getNum(i,j,i+k,j+k);
            int sum=temp1+temp2+temp3+temp4+temp5;
            res=max(res,max(sum,n-sum));
        }
    }
    printf("%d\n",res);
 
    return 0;
}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i=j; i<k; i+=step)
#define loop(i, j, k) for (int i=j; i<k; i++) 
#define rloop1(i, j, k, step) for (int i=j; i>=k; i-=step)
#define rloop(i, j, k) for(int i=j; i>=k; i--)
#define rep(i, k) for(int i = (0); i < (k); i++ )
#define rrep(i, k) for(int i = k-1; i >= 0; i-- )

#define forall(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define pop pop_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define endl "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;


void solve()
{
  int n,k,l;
  cin>>n;
  vi a;
  rep(i,n){
    cin>>k;
    a.pb(k);
  }
  l = a[0];
  ll z =0;
  loop(i,1,n){
    if(a[i]<l){
      z += abs(l-a[i]);
    }
    else
      l = a[i];
  }
  cout<<z<<endl;
}
int  main() 
{
  auto start=clock();
  fast_io;
    int t=1;
    //cin>>t;
    while(t--){
      solve();
    }
    auto stop =clock();
    cerr<<"time taken:"<<double(stop-start)/double(CLOCKS_PER_SEC)<<" s"<<endl;
  return 0; 
}


Measured memory_bytes: 4216
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a;
    int b;
    int n;
    cin >> a>>b;
    
    n=a-2*b;
    
    if(n<0){
        
        cout << 0 <<endl;
    }
    
    else{
        
        cout <<n <<endl;
    }
    
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
    int num,i,tsum=0,hsum=0,cmp,f;
    char line[101],line1[101];
    scanf("%d\n",&num);
    for(i=0;i<num;i++){
        scanf("%s%s",line,line1);
        f=strcmp(line,line1);
        if(!f){
            tsum++;
            hsum++;
        }
        else if(f>0)
            tsum+=3;
        else
            hsum+=3;
    }
    printf("%d %d\n",tsum,hsum);
    return 0;
}

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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    ll A, B, K;
    cin >> A >> B >> K;
    for (ll i = A; i <= B; ++i)
    {
        if (i <= A + K - 1 || i >= B - K + 1)
        {
            cout << i << endl;
        }
    }
}


Measured memory_bytes: 256
K, N = map(int, input().split())
A = list(map(int, input().split()))

max_dis = 0
for i in range(len(A)):
    if i == N-1:
        max_dis = max(max_dis, K-A[N-1]+A[0])
    else:
        max_dis = max(max_dis, A[i+1]-A[i])

print(K-max_dis)

Measured memory_bytes: 25836
#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define INT_MAX_VALUE 2147483647
#define LONG_LONG_MAX_VALUE 9223372036854775807
#define ll long long

struct XX{
    string name;
    ll v;
    ll cnt1;
    ll cnt2;
    ll cnt3;
    ll ten;
    ll q;
};

class xxGreater {
public:
    bool operator()(const XX& riLeft, const XX& riRight) const {
        //第2条件
        if((riLeft.q) == (riRight.q)){
            return riLeft.q < riRight.q;//<:昇順(小さいものから順番)、>:降順(大きいものから順番)
            //プライオリティキューの場合は > で、top()すると値の小さいものがとれる
        }
        //第1条件
        return (riLeft.q) < (riRight.q);
    }
};


//map<long long,long long> prime_f(long long n){
//    map<long long,long long>res;
//    for(int i=2;i*i<=n;i++){
//        while(n%i==0){
//            ++res[i];
//            n/=i;
//        }
//    }
//    if(n!=1)res[n]=1;
//    return res;
//}

int asum(string P){
    int sum=0;
    int strength=1;
    for(int i=0;i<P.size();i++){
        if(P.substr(i,1)=="S"){
            sum+=strength;
        }else{
            strength*=2;
        }
    }
    return sum;
}

int main(int argc, const char * argv[])
{
    //scanf("%s",S);
    //scanf("%d",&N);
    //scanf("%lld %lld",&target1,&target2);
    //sscanf(tmp.c_str(),"%dd%d%d",&time[i], &dice[i], &z[i]);
    //getline(cin, target);
    //ifstream ifs( "1_06.txt" );//テスト用
    //ifs >> a;
    //ここから
    
    //入力高速化
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int sa[3];
    cin >> sa[0] >> sa[1] >> sa[2];
    sort(sa,sa+3);
    
    int ans=(sa[1]-sa[0])/2+1;
    if((sa[1]-sa[0])%2==0){
        ans--;
    }else{
        ans++;
    }
    ans+=sa[2]-sa[1];
    cout << ans << endl;
    //ここまで
    //cout << "ans" << endl;改行含む
    //printf("%.0f\n",ans);//小数点以下表示なし
    //printf("%.7f\n",p);
    
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/*-------------ここまで---------------------------------------------*/

//C++(GCC9.2.1)

signed main() {
    //宣言
    string S;
    cin >> S;
    int ans = 0;
    int A = S.size();
    for (int i = 0; i < (A / 2); i++) {
        if (S.at(i) != S.at(A - i - 1)) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
int W,H,k,tmp,R;
ll ans,sum;
int gcd(int x,int y) {
	if (!x||!y) return x+y;
	return gcd(y,x%y);
}
int up(int x,int y) {
	if (x%y==0) return x/y;
	return x/y+1;
}
int down(int x,int y) { return x/y; }
void solve() {
	tmp=2*k-2+W;
	for (int s=0;s<H&&s<=tmp;s++)
	for (int x=1;x<W&&x*s<=tmp;x++) {
		R=2*k-2-s*x+gcd(W,s);
		if (R/W>=H-s-1) sum=H-s-1;
		else {
			sum=R/W;
			for (int y=R/W+1;y<=(R+W)/W;y++) {
				if ((ll)W*y-gcd(x,y)-gcd(W-x,y+s)<=R) sum++;
			}
		}
		if (!s) ans+=sum;
		else ans+=sum*2;
		
	}
}
int main() {
	//freopen("1.txt","r",stdin);
	read(W); read(H); read(k);
	solve();
	swap(W,H);
	solve();
	printf("%lld\n",ans*2);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 3760
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>

using namespace std;


const long MAX = 100002;
const long NIL = -1;
struct Node{int p,l,r;};
Node T[MAX];
int n,D[MAX];

void print(int u){
    int i,c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";
    if(T[u].p == NIL){
        cout << "root, ";
    }else if(T[u].l == NIL){
        cout << "leaf, ";
    }else{
        cout << "internal node, ";
    }
    cout << "[";
    for (i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
        if(i){
            cout << ", ";
        }
        cout << c;
    }
    cout << "]" << endl;
}

int rec(int u, int p){
    D[u] = p;
    if(T[u].r != NIL){
        rec(T[u].r,p);
    }
    if(T[u].l != NIL){
        rec(T[u].l, p+1);
    }
}

int main() {
    
    int i,j,d,v,c,l,r;
    cin >> n;
    for(i=0;i<n;i++){
        T[i].p = T[i].l = T[i].r = NIL;
    }
    for(i=0;i<n;i++){
        cin >> v >> d;
        for(j=0;j<d;j++){
            cin >> c;
            if(j==0){
                T[v].l = c;
            }else{
                T[l].r = c;
            }
            l = c;
            T[c].p = v;
        }
    }
    for (i=0;i<n;i++){
        if (T[i].p == NIL){
            r = i;
        }
    }

    rec(r,0);
    for(i=0;i<n;i++){
        print(i);
    }
}


Measured memory_bytes: 7704
#include <stdio.h>

int main(void)
{
	int a, b, c, i, x = 0;
	scanf("%d %d %d", &a, &b, &c);
	for (i = a; i <= b; i++)
	{
		if (c%i == 0)
		{
			x++;
		}
	}
	printf("%d\n", x);
		
	return 0;
}

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

void fnInput(vector<int> &rvnSort)
{
  int nMaxSiz;
  
  cin >> nMaxSiz;
  rvnSort.resize(nMaxSiz);

  for (int i = 0; i < nMaxSiz; i++)
    cin >> rvnSort[i];
}

void fnBubbleSort(vector<int> &rvnSort, int &rnSortCnt)
{
  int nSorting = 0;
  bool bSorting = true;

  while (bSorting)
  {
    bSorting = false;
    for (int i = rvnSort.size() - 1; i > nSorting; i--)
    {
      if (rvnSort[i] < rvnSort[i - 1])
      {
        bSorting = true;
        swap(rvnSort[i], rvnSort[i - 1]);
        rnSortCnt++;
      }
    }
    nSorting++;
  }
}

void fnOutput(const vector<int> &cnrvnSort, int nSortCnt)
{
  for (int i = 0; i < cnrvnSort.size(); i++)
  {
    if (i) cout << " ";
    cout << cnrvnSort[i];
  }
  cout << endl;
  cout << nSortCnt << endl;
}
    
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int nSortCnt = 0;
  vector<int> vnSort;

  fnInput(vnSort);
  fnBubbleSort(vnSort, nSortCnt);
  fnOutput(vnSort, nSortCnt);

  return 0;
}

Measured memory_bytes: 3116
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;
 
ll getXor(ll n) {
    if (n % 4 == 0) return n;
    else if (n % 4 == 1) return 1;
    else if (n % 4 == 2) return 1 ^ n;
    else return 0;
}

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

    ll ans = getXor(a - 1) ^ getXor(b);

    cout << ans << endl;
}


Measured memory_bytes: 256
n, k = list(map(int, input().split()))
l = list(range(1, n + 1))

count = 0
for i in range(len(l)):
    if l[i] < k:
        while True:
            l[i] = l[i] * 2
            count += 1
            if l[i] >= k:
                l[i] = (1 / n) * (0.5 ** count)
                count = 0
                break
    else:
        l[i] = (1 / n)
print(sum(l))


Measured memory_bytes: 6900
N = int(input())
H = list(map(int, input().split()))
dp = [0] * N
dp[1] = abs(H[1] - H[0])

for i in range(2, N):
    dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]), dp[i-2] + abs(H[i] - H[i-2]))

print(dp[N-1])

Measured memory_bytes: 85072
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 2000000000
#define MOD 1000000007
#define N 5005
#define MAX 10000006
#define LOG 30
#define KOK 200
using namespace std;

int n,x,y;
int dp[N][N],f[N],aux[N],sub[N];
vector<int> v[N];

void dfs(int node,int ata) {

	sub[node]=dp[node][1]=1;

	for(int i:v[node]) {

		if(i==ata) continue ;

		dfs(i,node);

		for(int j=0;j<=sub[node];j++) {

			for(int k=0;k<=sub[i];k++) {

				aux[j+k]=(aux[j+k]+1ll*dp[node][j]*dp[i][k]%MOD)%MOD;

			}

		}

		sub[node]+=sub[i];

		for(int j=0;j<=sub[node];j++) {

			dp[node][j]=aux[j];

			aux[j]=0;

		}

	}

	for(int i=2;i<=sub[node];i+=2) {

		dp[node][0]=(dp[node][0]-1ll*f[i]*dp[node][i]%MOD+MOD)%MOD;

	}

}

void cal_f() {

	f[2]=1;

	for(int i=4;i<N;i+=2) {

		f[i]=1ll*f[i-2]*(i-1)%MOD;

	}

}

int main() {

//	freopen("input.txt","r",stdin);

	scanf("%d",&n);

	for(int i=1;i<n;i++) {

		scanf("%d %d",&x,&y);

		v[x].pb(y);
		v[y].pb(x);

	}

	cal_f();

	dfs(1,0);

	printf("%d",MOD-dp[1][0]);

}

Measured memory_bytes: 97664
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <pair <ll,ll> ,ll> &a,const pair <pair <ll,ll> ,ll> &b){
    if(a.first.first==b.first.first && a.first.second==b.first.second) return a.second>b.second;
    else if(a.first.second==b.first.second) return a.first.first>b.first.first;
    return a.first.second<b.first.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}


int main(){
    IOS;
    make2(string,s1,s2);
    ll n=s1.length();
    ll m=s2.length();
    vector <vector <ll> >dp(n+1,vector <ll>(m+1));
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=m;j++){
            if(i==0 || j==0) dp[i][j]=0;
            else if(s1[i-1]==s2[j-1]) dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
   // cout<<dp[n][m]<<endl;
    string t="";
    ll i=n; ll j=m;
    while(true){
        if(dp[i][j]==0) break;
        else{
            if(s1[i-1]==s2[j-1]) {t=s1[i-1]+t; i--; j--;}
            else{
                if(dp[i-1][j]>dp[i][j-1]) i--;
                else j--;
            }
        }
    }
    cout<<t<<endl;


}


Measured memory_bytes: 73988
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#define pb push_back
#define mp make_pair
#define pie 3.141592653589793238
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
/////////////////////////////////////////////////////////////////////
const ll mod = 1e9 + 7;
const int N = 1e6 + 9;
ll a[N];
vector <ll> v[105];
vector <ll> num;
ll modexp(ll a, ll n)
{
    ll r = 1;
    while(n){
        if(n & 1)
            r = (r * a) % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return r;
}
bool cmp(const pair<double, ll> &a, const pair<double, int> &b)
{
    if(a.first == b.first){
        return a.second < b.second;
    }
    else return a.first > b.first;
}
int main()
{
    fast;
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(a - b) <= d && abs(b - c) <= d){
        cout << "Yes";
        return 0;
    }
    else if(abs(a - c) <= d){
        cout << "Yes";
        return 0;
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    for(int i=1;i<=n;i++){
        ll a = i;
        ll b = n-i;
        if(a!=b){
            ans++;
        }
    }
    ans/=2;
    cout<<ans<<endl;
}
    



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

int main() {
  int n, k;
  cin >> n >> k;
  double ans = 0;
  for(int i = 1; i <= n; i++) {
    int count = 0;
    int a = i;
    while(a<k) {
      a *= 2;
      count++;
    }
    ans += (pow(0.5, count) / n);
  }
  cout << fixed << setprecision(12) << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int L;
  cin >> L;
  double x = double(L) / 3.0;
  cout << setprecision(10) << x * x * x << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1e9

signed main()
{
    int n, m;
    cin >> n >> m;
    int h[n];

    for (int i = 0; i < n; i++)
        cin >> h[i];

    int ans[n];

    for (int i = 0; i < n; i++)
        ans[i] = 1;

    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;

        if (h[a - 1] > h[b - 1])
            ans[b - 1] = 0;
        else if (h[a - 1] < h[b - 1])
            ans[a - 1] = 0;
        else
            ans[a - 1] = ans[b - 1] = 0;
    }

    int a = 0;

    for (int i = 0; i < n; i++)
        a += ans[i];
    cout << a << endl;
}

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

int main() {
  string S;
  cin >> S;
  string ans;
  if (S == "Sunny") ans = "Cloudy";
  else if (S == "Cloudy") ans = "Rainy";
  else if (S == "Rainy") ans = "Sunny";
  cout << ans << endl;
}

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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int a[4];
	repp(i,0,4) cin >> a[i];
	sort(a,a+4);
	cout << (a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9?"YES":"NO") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  string X;
  int N=0,T=0,S=0,f=0,t=0,num=0,sum[200000];
  
  cin >> X;
  REP(i,X.size()){
    if(i==0)
      sum[0] = X[0] == 'S' ? 1 : 0;
    else
      sum[i] = sum[i-1] + (X[i] == 'S' ? 1 : 0);
  }
  REP(i,X.size()){
    if(X[i] == 'T'){
      if(sum[i]-f > 0){
        num++;
        f++;
      }
    }else{
    }
  }
  
  cout << (X.size() - 2*num) << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 1412
// A Dynamic Programming based 
// C# program to find minimum 
// number operations to 
// convert str1 to str2 
using System;
using System.Collections.Generic;
using System.Linq;
class GFG
{
    static int k = 0;
    static List<int> ans = new List<int>();
    public static void Main()
    {
        var input = Console.ReadLine();

        Cubes(input);

    }

    static void Cubes(string s)
    {
        var ss = s.ToCharArray().ToList();
        int count = 0;
        for (int i = 0; i < ss.Count - 1;)
        {
            if (i < 0)
                i = 0;
            if (ss[i] == '0' && ss[i + 1] == '1')
            {
                ss.RemoveAt(i);
                ss.RemoveAt(i);
                count++;
                i = i - 2;
            }
            else if (ss[i] == '1' && ss[i + 1] == '0')
            {
                ss.RemoveAt(i);
                ss.RemoveAt(i);
                count++;
                i = i - 2;
            }
            i++;
        }

        Console.Write(count*2);
    }





}



Measured memory_bytes: 13236
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int64_t mod = 1000000007;
const int64_t tmpMod = 998244353;

int main() {
 
  int64_t N,a=0,b=0,c=0,d=0;
  cin>>N;
  //vector<int64_t> A(N);
  for(int i=0; i<N; i++){
    string tmp;
    cin>>tmp;
  if(tmp == "AC") a++;
  if(tmp == "WA") b++;
  if(tmp == "TLE") c++;
  if(tmp == "RE") d++;
  }
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  cout << "AC x "<< a << endl;
  cout << "WA x "<< b << endl;
  cout << "TLE x "<< c << endl;
  cout << "RE x "<< d << endl;

}

Measured memory_bytes: 3596
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ a, b, x ] <- readInts
	putStrLn $ which "YES" "NO" $ a <= x && x <= a + b

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

int n;

int main() {
	scanf("%d", &n);
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		int a, b; scanf("%d%d", &a, &b);
		if (a == b) {
			++cnt;
			if (cnt == 3) {
				puts("Yes");
				return 0;
			}
		}
		else
			cnt = 0;
	}
	puts("No");
	return 0;
}



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

int main() {
  int N, K, ans;
  cin >> N >> K;
  ans=0;
  vector<int> l(N);
  for (int i=0; i<N; i++) {
    cin >> l[i];
  }
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  for (int j=0; j<K; j++) {
    ans=ans+l[j];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3580
#include <stdio.h>
#include <string.h>
int main(void){
	char w[201],t[201];
	int m,h,l,i;
	while(1){
		scanf("%s",w);
		if(strcmp(w,"-")==0)
			break;
		l=strlen(w);
		scanf("%d",&m);
		while(m--){
			scanf("%d",&h);
			for(i=0;i<l;i++){
				t[i]=w[(i+h)%l];
			}
			t[l]='\0';
			strcpy(w,t);
		}
		printf("%s\n",t);
	}
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int A,B,M;
  cin >> A >> B >> M;
  
  vector<int>a(A);
  vector<int>b(B);
  
  for(int i=0;i<A;i++){
    cin >> a[i];
  }
  for(int i=0;i<B;i++){
    cin >> b[i];
  }
  
  vector<vector<int>>p(M,vector<int>(3));
  for(int i=0;i<M;i++){
    for(int j=0;j<3;j++){
      cin >> p[i][j];
    }
  }
  
  int ans = 999999999;
  int amin = 999999;
  int bmin = 999999;
  for(int i=0;i<A;i++){
      if(a[i] < amin)amin = a[i];
  }
  for(int i=0;i<B;i++){
      if(b[i] < bmin)bmin = b[i];
  }
  
  if(amin + bmin < ans) ans = amin + bmin;
  
  for(int i=0;i<M;i++){
    if(a[p[i][0]-1] + b[p[i][1]-1] - p[i][2] < ans){
      ans = a[p[i][0]-1] + b[p[i][1]-1] - p[i][2];
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

  

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

ll l1[51][51];
ll dir[8][2]={{1,0},{0,1},{0,-1},{-1,0},{-1,1},{-1,-1},{1,-1},{1,1}};

int main()
{
    ll n,k,m;
    cin>>n>>m;ll x,s=0,a,b;
    string s1[51];
    for(int i=0;i<n;i++){
        cin>>s1[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(s1[i][j]=='#'){
                for(int k=0;k<8;k++){
                    //for(int l=0;l<2;l++){
                        ll c=i+dir[k][0];
                        ll d=j+dir[k][1];
                        if(c>=0&&c<n&&d>=0&&d<m&&s1[c][d]=='.')l1[c][d]++;
                    //}
                }
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(s1[i][j]!='#')cout<<l1[i][j];
            else cout<<s1[i][j];
        }cout<<endl;
    }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.next();
		int i, j, flag = 0;
		for(i = 0; i < w.length(); i++){
			int cnt = 0;
			for(j = 0; j < w.length(); j++){
				if(w.charAt(i) == w.charAt(j)){
					cnt++;
				}
			}
			if(cnt%2 != 0){
				flag = 1;
				System.out.println("No");
				break;
			}
		}
		if(flag == 0)System.out.println("Yes");
	}
}

Measured memory_bytes: 21972
function factorization(num){
    var dividor=2;
    var workbench=num;
    var ret=[];
    while(workbench>1){
        if(workbench%dividor===0){
            workbench/=dividor;
            ret.push(dividor);
        }else{
            dividor++;
        }
        if(dividor**2>workbench){
            ret.push(workbench);
            break;
        }
    }
    return ret;
}

function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0].split(' ')[0]-0;
  var max;
  for(var i=1;i**2<=N;i++){
    if(N%i===0){
      max=i;
    }
  }
  console.log(max+N/max-2);


}




//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define out(S) cout<<(S)<<endl;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define beginend(v) v.begin(),v.end()
#define Foreach(item,collection) for(auto item : collection)

using pii=pair<int,int>;
using vb=vector<bool>;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vvc=vector<vector<char>>;
using ti3=tuple<int,int,int>;
using ulong=unsigned long;
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
#define OCB(c) (c&1)|(c&2)<<2|(c&4)<<4|(c&8)<<6|(c&16)<<8|(c&32)<<10|(c&64)<<12|(c&128)<<14

int main(){
    int x;
    cin >> x;
    int ans=1;
    for(int i=2;i<x;++i){
        int b=i*i;
        while(b<=x){
            ans=max(ans,b);
            b*=i;
        }
    }
    out(ans)
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";

#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);ios_base::sync_with_stdio(0);cin.tie(0);

int main(){
	long long int m, n, sum = 0;
	cin >> m >> n;
	long long int arr[n];
	rarr(arr, n);
	for(int i = 0; i < n; i++){
		sum += arr[i];
	}
	if(sum > m){
		cout << -1;
	}
	else{
		cout << m - sum;
	}
} 

Measured memory_bytes: 3668
#include <cstdio>
#include <vector>
#include <cmath>

int main(int argc, char const *argv[]) {
  int N;
  scanf("%d", &N);
  int inic[5] = {0};
  char ini[5];
  ini[0] = 'M';
  ini[1] = 'A';
  ini[2] = 'R';
  ini[3] = 'C';
  ini[4] = 'H';
  int nz = 0;
  for (int i = 0; i < N; i ++) {
    char name[11];
    scanf("%s", name);
    for (int i = 0; i < 5; i++) {
      if (name[0] == ini[i]) {
        inic[i]++;
        if (inic[i] == 1) {
          nz++;
        }
      }
    }
  }
  if (nz < 3) {
    printf("0\n");
    return 0;
  }
  std::vector<int> v;
  for (int i = 0; i < 5; i++) {
    if (inic[i] != 0) {
      v.push_back(inic[i]);
    }
  }
  long result = 0;
  int bits = (int)std::pow(2, nz);
  for (int i = 0; i < bits; i++) {
    int count = 0;
    for (int j = 0; j < nz; j++) {
      if (i >> j & 1) count++;
    }
    if (count == 3) {
      long r = 1;
      // printf("%d\n", i);
      for (int k = 0; k < nz; k++) {
        if (i >> k & 1) {
          r *=v[k];
        }
      }
      result += r;
    }
  }
  printf("%ld\n", result);
  return 0;
}


Measured memory_bytes: 384
/* -------------------------------- */
/* Name: MD. Khairul Basar          */
/* Institute: HSTU                  */
/* Dept: CSE                        */
/* Email: khairul.basar93@gmail.com */
/* -------------------------------- */

#include <bits/stdc++.h>
/* all header files */

#define fs            first
#define sc            second
#define sp            printf(" ")
#define nl            printf("\n")
#define pb(a)         push_back(a)

#define setzero(a)    memset(a,0,sizeof(a))
#define setneg(a)     memset(a,-1,sizeof(a))
#define setinf(a)     memset(a,126,sizeof(a))

#define tc1(x)        printf("Case %d: ",x)
#define tc2(x)        printf("Case #%d: ",x)
#define tc3(x)        printf("Case %d:\n",x)
#define tc4(x)        printf("Case #%d:\n",x)

#define iin(x)        scanf("%d",&x)
#define din(x)        scanf("%lf",&x)
#define lin(x)        scanf("%lld",&x)
#define clin(x)       scanf("%I64d",&x)

#define pr1(x)        cout<<x<<"\n"
#define pr2(x,y)      cout<<x<<" "<<y<<"\n"
#define pr3(x,y,z)    cout<<x<<" "<<y<<" "<<z<<"\n"
#define pr4(w,x,y,z)  cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n"
#define fast          ios::sync_with_stdio(0)
#define read          freopen("input.txt","r",stdin)
#define write         freopen("output.txt","w",stdout)
#define prflag1(flag) printf("%s\n",(flag)?"YES":"NO")
#define prflag2(flag) printf("%s\n",(flag)?"Yes":"No")
#define prflag3(flag) printf("%s\n",(flag)?"yes":"no")
/* macro definitions */

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int>pii;
typedef pair<LL, LL>pll;
typedef vector<int>vi;
typedef vector<LL>vll;
typedef vector<pii>vpii;
typedef vector<pll>vpll;
/* type definitions */

LL MOD_EXPO(LL b, LL p, LL m)
{
    if(p==0) return 1;
    LL ret=MOD_EXPO(b,p/2,m)%m;
    ret=(ret*ret)%m;
    return ((p&1) ? (ret*b)%m : ret%m);
}
LL POWER(LL N, LL K)
{
    LL i,ans=1;
    for(i=1;i<=K;i++) ans*=N;
    return ans;
}
int SET(int N, int pos)
{
    return (N | (1<<pos));
}
int RESET(int N, int pos)
{
    return (N & !(1<<pos));
}
bool CHECK(int N, int pos)
{
    return (N & (1<<pos));
}
/* necessary functions */

int dx4[]= {1,-1,0,0};
int dy4[]= {0,0,1,-1};
int dx6[]= {0,0,1,-1,0,0};
int dy6[]= {1,-1,0,0,0,0};
int dz6[]= {0,0,0,0,1,-1};
int dx8[]= {1,-1,0,0,-1,1,-1,1};
int dy8[]= {0,0,1,-1,1,1,-1,-1};
int dkx8[]= {-1,1,-1,1,-2,-2,2,2};
int dky8[]= {2,2,-2,-2,1,-1,1,-1};
/* direction arrays */

int tc=1;
const double eps=1e-9;
const double pi=acos(-1.0);
const long long int mx=1e5;
const long long int mod=1e9+7;
/* global declarations */

int main()
{
    string str;
    int i;
    bool w,x,y,z;
    while(cin>>str)
    {
        x=y=w=z=0;
        for(i=0;i<str.size();i++)
        {
            if(str[i]=='S') y=1;
            if(str[i]=='N') z=1;
            if(str[i]=='E') w=1;
            if(str[i]=='W') x=1;
        }
        prflag2(x==w && y==z);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <stdio.h>
#include <math.h>
using namespace std;
 
#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
 
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, P> PP;
 
struct edge {
	int to, cost;
	edge(int t, int c) :to(t), cost(c) {}
};
 
int dx[] = { 1,-1,0,0 }, dy[] = { 0,0,1,-1 };
int ddx[] = { 1,1,1,0,-1,-1,-1,0 }, ddy[] = { 1,0,-1,-1,-1,0,1,1 };
 
ll mypow(ll x, ll n, ll m) {	//xのn乗をmで割った余り
	if (n == 0) return 1;
	if (n % 2 == 0) return mypow(x*x%m, n / 2, m);
	else return x*mypow(x, n - 1, m) % m;
}
 
//-----------------------------------------------------------------------------

int n;

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

	cin>>n;
	cout<<(n<1200?"ABC":"ARC")<<endl;
	
	return 0;
}


Measured memory_bytes: 256