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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader cd = new BufferedReader(new InputStreamReader(System.in));
		String[] vd = cd.readLine().split(" ");
		int a = Integer.parseInt(vd[0]);
		int b = Integer.parseInt(vd[1]);

		if(a<=b)System.out.println(a);
		if(a>b)System.out.println(a-1);


	}

}


Measured memory_bytes: 21204
#include <iostream>
#include<math.h>
using namespace std;

//Compiler version g++ 6.3.0
int prime(int n){
  if(n==2)return 1;
  if(n%2==0)return -1;
  for(int i=3;i<=sqrt(n);i=i+2){
    if(n%i==0){
      return -1;
    }
  }
  return 1;
}
int main()
{
    int n;
    cin>>n;
    if(prime(n)==1){
      cout<<n;
    }
    else{
      while(1){
        n++;
        if(prime(n)==1){
          cout<<n;break;
        }
      }
    }
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n; cin >> n;
    vector<double> p(n);
    rep(i,n) cin >> p[i];
    double dp[n+1][n+1] = {};
    dp[0][0] = 1.0;
    rep(i,n){
        rep(j,n+1){
            if(j==0) dp[i+1][j] = dp[i][j] * (1-p[i]);
            else dp[i+1][j] = dp[i][j-1] * p[i] + dp[i][j] * (1-p[i]);
        }
    }
    double sum = 0.0;
    REP(i,n/2+1,n+1){
        sum += dp[n][i];
    }
    printf("%.10f\n",sum);
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n, m;
    cin >> n >> m;
    vector<ll> cnt(n+1);
    vector<ll> l(m), r(m);
    REP(i, m) {
        cin >> l[i] >> r[i], l[i]--, r[i]--;
        cnt[l[i]]++, cnt[r[i]+1]--;
    }

    FOR(i, 1, n+1) cnt[i] += cnt[i-1];
    // cout << cnt << endl;

    ll ret = 0;
    REP(i, n) if(cnt[i]==m) ret++;
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int s[n];
	for(int i=0;i<n;i++)
		cin >> s[i];
	int q;
	cin >> q;
	int t[q];
	for(int i=0;i<q;i++)
		cin >> t[i];
	int ans=0;
	for(int i=0;i<q;i++){
		int left=0,right=n,mid;
		while(left < right){
			mid=(left + right)/2;
			if(s[mid]==t[i]){
				ans++;
				break;
			}
			if(t[i] < s[mid])
				right=mid;
			else
				left=mid+1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#include <math.h>
#include <iomanip>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int n;
   	cin>>n;
   	int c[n];
   	int s[n];
   	int f[n];
   	int ans[n];
   	int t=0;
   	for(int i=0;i<n-1;++i){
   		cin>>c[i]>>s[i]>>f[i];
   	}
   	for(int i=0;i<n-1;++i){
   		t=s[i]+c[i];
   		for(int j=i+1;j<n-1;++j){
   			for(int k=max(0,(t-s[j])/f[j]);k<200000;++k){
   			if(s[j]+f[j]*k>=t){t=s[j]+f[j]*k+c[j];break;}
   			}
   		}
   		cout<<t<<endl;
   	}
   	cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
import math

def main(b):
	if b == 0:
		return False
	for n in range(int(math.sqrt(2*b)), 0, -1):
		if 2*b % n == 0:
			a = (-n*n + n + 2 * b)/(2*n)
			if a >= 1 and a.is_integer():
				print(int(a), n)
				return True


while main(int(input())):
	pass


Measured memory_bytes: 5664
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static uint32_t powU32(const uint32_t base, const uint32_t exp) {
    uint32_t val = 1;
    
    for (size_t i = 0; i < exp; i++) {
        val *= base;
    }

    return val;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    uint32_t M, K;

    scanf("%"PRIu32" %"PRIu32, &M, &K);

    const uint32_t lim = powU32(2, M) - 1;

    if (lim < K || (M == 1 && K == 1)) {
        printf("%s", "-1");
    }
    else {
        if (K == 0) {
            for (uint32_t ofs = 0; ofs <= lim; ofs++) {
                const uint32_t val = lim - ofs;
                
                printf("%"PRIu32" ", val);
            }
            for (uint32_t ofs = 0; ofs <= lim; ofs++) {
                const uint32_t val = ofs;

                printf("%"PRIu32, val);
                if (ofs < lim) {
                    putchar(' ');
                }
            }
        }
        else {
            for (uint32_t ofs = 0; ofs <= lim; ofs++) {
                const uint32_t val = lim - ofs;
                if (val != K) {
                    printf("%"PRIu32" ", val);
                }
            }
            printf("%"PRIu32" ", K);
            for (uint32_t ofs = 0; ofs <= lim; ofs++) {
                const uint32_t val = ofs;
                if (val != K) {
                    printf("%"PRIu32" ", val);
                }
            }
            printf("%"PRIu32, K);
        }
    }

    return 0;
}

Measured memory_bytes: 1792
import numpy as np
inputs = open(0).readlines()

h, w, k = map(int, inputs[0].split())
cake, count, coords = np.zeros((h, w), dtype=np.uint), 0, {}
for i, s in enumerate(inputs[1:]):
    for j, c in enumerate(s):
        if c == '#':
            count += 1
            cake[i, j] = count
            coords[count] = (j, i)
empty_rows = {i for i, rows in enumerate(cake) if not np.any(rows)}

for i in range(1, count+1):
    x, y = coords[i]
    x0, y0 = x-1, y-1
    x1, y1 = x+1, y+1
    while 0 <= x0 and cake[y, x0] == 0:
        cake[y, x0] = i
        x0 -= 1
    x0 += 1
    while x1 < w and cake[y, x1] == 0:
        cake[y, x1] = i
        x1 += 1
    while y0 in empty_rows:
        cake[y0, x0:x1] = i
        y0 -= 1
    while y1 in empty_rows:
        cake[y1, x0:x1] = i
        y1 += 1

for rows in cake:
    print(*rows)

Measured memory_bytes: 30856
n, p = map(int, input().split())
s = input()

if p == 2 or p == 5:
    ans = 0
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += i + 1
else:
    s2 = s[::-1]
    rems = [0]
    tmp = 0
    tmp2 = 1
    for i in range(n):
        tmp += int(s2[i]) * tmp2
        tmp %= p
        tmp2 *= 10
        tmp2 %= p
        rems.append(tmp)

    from collections import Counter
    counter = Counter(rems)
    ans = 0
    for key in counter.keys():
        v = counter[key]
        ans += v * (v - 1) // 2
print(ans)


Measured memory_bytes: 51516
#include <stdio.h>

int main()
{
	int num[3] = {};
	int fiveCount = 0;
	int sevenCount = 0;
	char* result = "";

	scanf("%d %d %d", &num[0], &num[1], &num[2]);

	for (int i = 0; i < 3; i++)
	{
		if (num[i] == 5) fiveCount++;
		if (num[i] == 7) sevenCount++;
	}

	result = (fiveCount == 2 && sevenCount == 1) ? "YES" : "NO";
	printf("%s", result);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            {for(ll i=0;i<size;i++) cout<<w[i]<<" ";cout<<"\n";}
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a,ll m=MOD){if(m==1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}

int main()
{
	fastIO
	ll h;
	cin>>h;
	ll val=1,ans=0;
	while(h>1)
	{
		h/=2;
		ans+=val;
		val*=2;
	}
	
	cout<<ans+(val);
	
	return 0;
}




Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<string>
// #include<fstream>

using namespace std;

struct Node {
	int key;
	Node *parent, *left, *right;
};

Node * root = NULL;

void insert(int v) {
 	Node * newNode = (Node *)malloc(sizeof(Node));
 	newNode->key = v;
 	newNode->left = newNode->right = NULL;

 	Node * p = NULL;
 	Node * cur = root;

    while (cur != NULL) {
 		p = cur;
 		if (v > cur->key)
 			cur = cur->right;
 		else
 			cur = cur->left;
 	}

 	newNode->parent = p;

 	if (root == NULL) // if tree is empty
 		root = newNode;
 	else if (v > p->key)
 		p->right = newNode;
 	else
 		p->left = newNode;
}

Node* find(Node* curNode, int v) {
	while(curNode != NULL && curNode->key != v) {
		if (v > curNode->key)
			curNode = curNode->right;
		else
			curNode = curNode->left;
	}
	return curNode;
}

Node* getSuccessor(Node* node) {
	node = node->right;
	while(node->left != NULL)
		node = node->left;
	return node;
}


void deleteNode(int v) {
	Node* delCmdNode = find(root, v);
	Node* actualDelNode = NULL;
	Node* childOfDelNode = NULL;

	// 0 or 1 child node
	if (delCmdNode->left == NULL || delCmdNode->right == NULL)
		actualDelNode = delCmdNode;
	else // 2 child nodes
		actualDelNode = getSuccessor(delCmdNode);

	if (actualDelNode->left != NULL)
		childOfDelNode = actualDelNode->left;
	else
		childOfDelNode = actualDelNode->right;

	if (actualDelNode->parent == NULL)
		root = childOfDelNode;
	else if (actualDelNode->parent->left == actualDelNode){
		actualDelNode->parent->left = childOfDelNode;
	}
	else
		actualDelNode->parent->right = childOfDelNode;

	if (childOfDelNode != NULL)
		childOfDelNode->parent = actualDelNode->parent;

	if (actualDelNode != delCmdNode)
		delCmdNode->key = actualDelNode->key;
}



void preOrder(Node* node) {
	if (node == NULL)
		return;
	printf(" %d", node->key);
	preOrder(node->left);
	preOrder(node->right);
} 

void inOrder(Node* node) {
	if (node == NULL)
		return;
	inOrder(node->left);
	printf(" %d", node->key);
	inOrder(node->right);
}


int main() {
	int i, n, value;
	string command;
	Node * foundNode = NULL;

	// ifstream input;
	// input.open("input.txt");

	scanf("%d", &n);
	// input >> n;
	for (i = 0; i < n; i++) {
		// input >> command;
		cin >> command;
		if (command == "insert"){
			// input >> value;
			scanf("%d",&value);
			insert(value);
		}else if (command == "delete"){
			// input >> value;
			scanf("%d", &value);
			deleteNode(value);
		}else if (command == "find"){
			// input >> value;
			scanf("%d",&value);
			foundNode = find(root, value);
			if (foundNode == NULL)
				printf("no\n");
			else
				printf("yes\n");
		}else{
			inOrder(root);
			printf("\n");
			preOrder(root);
			printf("\n");
		}
	}

	// input.close();

	return 0;
}

Measured memory_bytes: 22032
#require "pry-byebug"

N,M = gets.split.map(&:to_i)
ary = []
M.times do |m|
  s,c = gets.split.map(&:to_i)
  ary << {s:s, c:c}
end
0.upto(1000) do |num|
  # N桁になっていない
  str = num.to_s
  digits = str.length
  next if digits != N
  found = true
  ary.each do |elm|
    s = elm[:s]
    c = elm[:c]
    #binding.pry if num == 702
    if digits < s
      found = false
      break
    end
    if str[s-1].to_i != c
      found = false
      break
    end
  end
  if found
    puts str
    exit
  end
end
puts "-1"

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

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

    int i,n,x,ans=0,mn=INT_MAX;
    cin >> n;
    for(i=1;i<=n;i++)
    {
        cin >> x;
        if(x < mn)++ans;
        mn=min(mn,x);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Mod=924844033;
const int G=5;

struct Road{
	int e,next;
}r[410000];int R[210000],num;

void addr(int x,int y){
	r[++num]=(Road){y,R[x]};
	R[x]=num;
}

int sz[210000],fac[210000],ifac[210000];
int g[1048580],A[1048580],B[1048580],wn[1048580],iwn[1048580],rev[1048580];
int n,N,L;

int pow(int x,int l){
	if(l==0)return 1;
	int t=pow(x,l/2);
	t=(ll)t*t%Mod;
	if(l&1)t=(ll)t*x%Mod;
	return t;
}

void dfs(int u,int fa){
	sz[u]=1;
	for(int i=R[u];i;i=r[i].next){
		int v=r[i].e;
		if(v==fa)continue;
		dfs(v,u);
		sz[u]+=sz[v];
	}
}

void dfs_1(int u,int fa){
	g[N]++;
	if(u!=1)g[N-sz[u]]--;
	for(int i=R[u];i;i=r[i].next){
		int v=r[i].e;
		if(v==fa)continue;
		g[sz[v]]--;
		dfs_1(v,u);
	}
}

void NTT(int *a,int tag){
	for(int i=0;i<n;i++){if(rev[i]>i)swap(a[i],a[rev[i]]);}
	for(int i=1;i<n;i<<=1){
		int bot=(tag==1?wn[i<<1]:iwn[i<<1]);
		for(int j=0;j<n;j+=(i<<1)){
			for(int k=0,w=1;k<i;k++,w=(ll)w*bot%Mod){
				int x=a[j+k],y=(ll)w*a[i+j+k]%Mod;
				a[j+k]=(x+y)%Mod;a[i+j+k]=(x-y+Mod)%Mod;
			}
		}
	}if(tag==-1){
		int w=pow(n,Mod-2);
		for(int i=0;i<n;i++){
			a[i]=(ll)a[i]*w%Mod;
		}
	}
}

int main(){
	int x,y;
	fac[0]=1;for(int i=1;i<=200000;i++)fac[i]=(ll)fac[i-1]*i%Mod;
	ifac[200000]=pow(fac[200000],Mod-2);for(int i=199999;i>=0;i--)ifac[i]=(ll)ifac[i+1]*(i+1)%Mod;
	scanf("%d",&N);
	for(int i=1;i<N;i++){
		scanf("%d %d",&x,&y);
		addr(x,y);addr(y,x);
	}dfs(1,0);
	dfs_1(1,0);
	for(int i=1;i<=N;i++){
		g[i]=(g[i]+Mod)%Mod;
		A[i]=(ll)g[i]*fac[i]%Mod;
		B[i]=ifac[N-i];
	}N<<=1;
	for(n=1;n<=N;n<<=1)L++;
	for(int i=0;i<n;i++)rev[i]=(rev[i>>1]>>1)|((i&1)<<(L-1));
	for(int i=0;i<=L;i++){
		wn[1<<i]=pow(G,(Mod-1)>>i);
		iwn[1<<i]=pow(wn[1<<i],Mod-2);
	}NTT(A,1);NTT(B,1);
	for(int i=0;i<n;i++){
		A[i]=(ll)A[i]*B[i]%Mod;
	}NTT(A,-1);
	N>>=1;
	for(int i=N+1;i<=N<<1;i++){
		printf("%d\n",(ll)A[i]*ifac[i-N]%Mod);
	}return 0;
}

Measured memory_bytes: 39040
#pragma GCC optimize("O3")
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define FOR(i,l,r) for(int i = l ; i <= r ;++i )
#define ALL(T)  T.begin(),T.end()
#define lson(i)     i<<1
#define rson(i)     (i<<1|1)
#define ll long long 
#define pu push
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define is insert
#define se second
#define sz(x) ((int)(x).size())
#define len(x) ((int)(x).length())
#define debug(x) cout << "[" << #x << ": " << (x) << "]" << endl
#define endl "\n"
#define in inline
using namespace std;
typedef pair<int,int> pii;
const int N = 1e3+10;
int a[N][N],ci[N],ls[N];
int n;
struct node{
    int u,v,w;
    node(int u=0,int v=0,int w=0):u(u),v(v),w(w){}
};
int main(){
    cin >> n;
    for(int i=1;i<=n;++i){
        for(int j=1;j<n;++j){
            cin >> a[i][j];
        }
        ci[i] = 1;  ls[i] = 0;
    }
    int sign = 0;
    int r =0;
    queue<node> q;
    node cur;
    for(int i=1;i<=n;++i){
        if(ls[i]==1)    continue;
        int  to = a[i][1];
        if(a[to][1]==i){
            ls[to] = 1; ls[i] = 1;
            q.push({i,to,1});
        }
    }
    while(!q.empty()){
        cur = q.front();    q.pop();    r = cur.w;
// cout << cur.u << ' ' << cur.v << ' ' << cur.w << endl;
        ci[cur.u]++; ci[cur.v]++;
        int to = a[cur.u][ci[cur.u]];
        if(a[to][ci[to]]==cur.u && ls[to]<=cur.w){
            ls[to] = cur.w+1;   ls[cur.u] = cur.w+1;
            q.push(node{cur.u,to,cur.w+1}); 
        }
        to = a[cur.v][ci[cur.v]];
        if(a[to][ci[to]]==cur.v && ls[to]<=cur.w){
            ls[to] = cur.w+1;   ls[cur.v] = cur.w+1;
            q.push(node{cur.v,to,cur.w+1});
        }
    }
    for(int i=1;i<=n;++i){
        if(ci[i]!=n){
            sign = 1;break;
        }
    }
    if(sign)   cout << -1 << endl;
    else cout << r << endl;
    return 0;
}

Measured memory_bytes: 4224
#include<iostream>
#include<bits/stdc++.h>
#include<array>
using namespace std;
#define int long long
#define fast_cin ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define endl "\n"
#define with_tests int t; cin >> t; while(t--){ solve(); cout << endl; }
#define without_tests solve(); cout << endl;
#define CEIL(x, y) (ll)ceil((long double)(x)/(long double)(y))
#define epsilon 1e-9 
typedef long long ll;
const int mod = 1e9+7;
const int N = 2e5+1;

vector<int> adj[N];
int n, m, u, v;

int c = 0;
int vis[N];

void dfs(int u){
    c++;
    vis[u] = 1;
    for(int v: adj[u]){
        if(vis[v] == 0)
            dfs(v);
    }
}


void solve(){
    
    cin >> n >> m;
    for(int i=0; i<m; i++){
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int ans = 0;
    for(int i=1; i<=n; i++){
        if(vis[i] == 0){
            c = 0;
            dfs(i);
            ans = max(ans, c);
        }
    }
    cout << ans;
    

}

int32_t main(){

    fast_cin;
    // with_tests;
    without_tests;

    return 0;
}


Measured memory_bytes: 22296
import java.util.*;
 
class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        System.out.println(Math.max(a+b, Math.max(a-b, a*b)));
   }
}

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;

int main(){
  int n,at;
  vector<int> a;
  cin >> n;
  REP(c, n){
      cin >> at;
      a.pb(at);
    }
    sort(a.begin(), a.end());
    int s = a.size() - 1;
    cout << (a[s] - a[0]) << endl;
}


Measured memory_bytes: 256
def read_input():
    n = int(input())

    points = [[0, 0, 0]]
    for i in range(n):
        points.append(list(map(int, input().split())))

    return n, points


def check_transition(point1, point2):
    t_diff = point2[0] - point1[0]
    x_diff = point2[1] - point1[1]
    y_diff = point2[2] - point1[2]

    x_diff = abs(x_diff)
    y_diff = abs(y_diff)

    distance = x_diff + y_diff

    if t_diff >= distance:
        if t_diff % 2 == distance % 2:
            return True

    return False


def check_all_transition():
    n, points = read_input()
    for p1, p2 in zip(points, points[1:]):
        if not check_transition(p1, p2):
            return False
    return True


if check_all_transition():
    print('Yes')
else:
    print('No')

Measured memory_bytes: 28092
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func splitInt(str string, sep string) (nums []int) {
	sp := strings.Split(str, sep)
	nums = make([]int, len(sp))
	for i, s := range sp {
		n, _ := strconv.Atoi(s)
		nums[i] = n
	}
	return
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()

	nm := splitInt(sc.Text(), " ")

	cities := make(map[int]int, nm[0])

	for i := 1; i <= nm[1]; i++ {
		sc.Scan()
		for _, city := range splitInt(sc.Text(), " ") {
			if cnt, ok := cities[city]; ok {
				cnt++
				cities[city] = cnt
			} else {
				cities[city] = 1
			}
		}
	}

	for i := 1; i <= nm[0]; i++ {
		fmt.Println(cities[i])
	}
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
    int D, N; cin >> D >> N;
    if (N == 100){
        cout << setprecision(10) << 101  * pow(100, D) << endl;

    }else {
        cout << setprecision(10) << N * pow(100, D) << endl;
    }
    return 0;
}

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

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

  if (a == b){
    cout << c << endl;
  }else if (b == c){
    cout << a << endl;
  }
  else {
    cout << b<< endl;
  }
}

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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int n;
    cin >> n;
    vector<int> v[2];
    rep(i, n)
    {
        int tmp;
        cin >> tmp;
        v[i%2].push_back(tmp);
    }

    if(n==2)
    {
        if(v[0][0]==v[1][0])
        {
            cout << 1 << endl;
        }
        else
        {
            cout << 0 << endl;
        }
        
    }

    int tab0[100010];
    FILL0(tab0); 
    rep(i, v[0].size())
    {
        tab0[v[0][i]]++;
    }

    vector<P> freq0;

    rep(i, 100001)
    {
        if(tab0[i]!=0)
        {
            freq0.push_back(P(tab0[i], i));
        }
    }

    int tab1[100010];
    FILL0(tab1); 
    rep(i, v[1].size())
    {
        tab1[v[1][i]]++;
    }


    vector<P> freq1;

    rep(i, 100001)
    {
        if(tab1[i]!=0)
        {
            freq1.push_back(P(tab1[i], i));
        }
    }

    sort(freq0.begin(), freq0.end());
    reverse(freq0.begin(), freq0.end());

    sort(freq1.begin(), freq1.end());
    reverse(freq1.begin(), freq1.end());
    

    if(freq0[0].second==freq1[0].second)
    {
        if(freq0[0].first-freq0[1].first>freq1[0].first-freq1[1].first)
        {
            cout << n-(freq0[0].first+freq1[1].first) << endl; 
        }
        else
        {
            cout << n-(freq1[0].first+freq0[1].first) << endl;     
        }
        
    }
    else
    {
        cout << n-(freq0[0].first+freq1[0].first) << endl;
    }




    return 0;
}



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

int main(){
        int d,n;
        cin >> d >> n;
        int ans=1;
        while(d>0){
                ans*=100;
                d--;
        }

        if(n==100)ans*=101;
        else ans*=n;

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApp8
{
    class Program
    {
        static void Main(string[] args)
        {
            string i = Console.ReadLine();
            int second = int.Parse(i);
            Console.WriteLine("{0}:{1}:{2}",second/3600,(second%3600)/60,((second%3600)%60));
            Console.ReadKey();
        }
    }
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define ld long double
#define mem(x,y) memset(x,y,sizeof x)

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
/*
 * Be careful of overflow
 * Array bounds
 * Assert a!=0 when performing x/a
 * Check base condition for recursion
 * Iterator -> O(1), Element -> O(log n) while using erase
 * 1LL<<x when x>32
 * Be sure of what you are going to code (exception dp)
 * Don't try fancy tricks during contest
 * You can always make a bad round to a good enough round
 */ 
int c[5009];
int p[5009];
ll pref[5009];
//bool vis[5009];
void solve()
{
	int n,k,i;
	cin>>n>>k;
	for(i=1;i<=n;i++)
	cin>>p[i];
	for(i=1;i<=n;i++)
	cin>>c[i];
	ll ans=-infl;
	for(i=1;i<=n;i++)
	{
		int len=1,cur=i;
		while(1)
		{
			pref[len]=pref[len-1]+c[p[cur]];
			cur=p[cur];
			if(cur==i) break;
			len++;
		}
		for(int j=1;j<=len && j<=k;j++)ans=max(ans,pref[j]);
		if(k>len)
		{
			ll temp=0;
			int rem=k%len;
			if(rem==0) rem=len;
			for(int j=1;j<=rem;j++) temp=max(temp,pref[j]);
			if(rem!=len)
			ans=max(ans,pref[len]*(k/len) + temp);
			else
			ans=max(ans,pref[len]*(k/len-1)+temp);
		}
		//memset(vis,0,sizeof vis);
	}
	cout<<ans<<'\n';
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


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


int main() {
  int N, M;
  cin >> N >> M;
  int a[M], b[M];

for (int i=0; i < M; i++) cin >> a[i] >> b[i];

int num[100]={0};
for (int i=0; i < M; i++){
  num[a[i]-1]+= 1;
  num[b[i]-1]+= 1;
}

for (int i=0; i < N; i++) cout << num[i] << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int c1,c5,c10,c50,c100,c500;
	scanf("%d %d %d %d %d %d ",&c1,&c5,&c10,&c50,&c100,&c500);
	if(c1*1+c5*5+c10*10+c50*50+c100*100+c500*500>=1000){
		printf("%d\n",1);
	}
	else{
		printf("%d\n",0);
	}
	return 0;
}


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

using namespace std;

typedef long long ll;
#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;


void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  LCIN(D, N);

  ll ans = 0;
  ll tmp = 100;
  FOR(i, 1, D) {
    tmp *= 100;
  }
  if (D == 0){
    REP(i, N) {
      ans++;
      if ((i + 1) % tmp == 0) {
	ans++;
      }
    }
  } else {
    // 愚直にたす
    REP(i, N) {
      ans += tmp;
      if ((ans / tmp) % 100 == 0) {
	ans += tmp;
      }
    }
  }

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



Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n = 0;
	scanf("%d", &n);

	int min = 9999999;
	int max = -9999999;
	long sum = 0;
	int x = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		sum += x;
		if (x < min) { min = x; }
		if (max < x) { max = x; }
	}

	printf("%d %d %ld\n", min, max, sum);

	return 0;
}

Measured memory_bytes: 1772
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    (v).begin(), (v).end()
#define in        ([]{int n; cin>>n; return n;}())
using namespace std;
using lint = int64_t;

int gcd( const int a, const int b ) {
	if( b == 0 ) {
		return a;
	} else {
		return gcd( b, a%b );
	}
}


int main() { cin.tie(0); ios::sync_with_stdio(false);
    int N = in;
    vector<lint> A(N);
    rep( i, N ) A[i] = in;

    vector<int> left(N), right(N);
    left[0] = A[0];
    right[N-1] = A[N-1];
    rep( i, N-1 ) {
        left[i+1] = gcd(left[i], A[i+1]);
        right[N-i-2] = gcd(right[N-i-1], A[N-i-2]);
    }

    int ans = max( left[N-2], right[1] );
    for( int i=1; i<N-1; i++ ) {
        ans = max( ans, gcd(left[i-1],right[i+1]) );
    }

    cout << ans << "\n";
}


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

int main() {
    int N; cin >> N;
    long long sum = 0;
    vector<int> A(N+1);
    vector<int> B(N);
    for (int i = 0; i < N+1; i++) cin >> A.at(i);
    for (int i = 0; i < N; i++) cin >> B.at(i);
    
    for (int i = 0; i < N; i++) {
        if (A.at(i) > B.at(i)) {
            sum += B.at(i);
        } else {
            sum += A.at(i);
            if (A.at(i+1) > B.at(i) - A.at(i)) {
                A.at(i+1) = A.at(i+1) - B.at(i) + A.at(i);
                sum += B.at(i) - A.at(i);
            } else {
                sum += A.at(i+1);
                A.at(i+1) = 0;
            }
        }
    }
    cout << sum << endl;
}

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

int main(void) {
	int h, w, i, j;
	while (1) {
		cin >> h >> w;
		if (!h && !w)
			break;
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				if ((i + j) % 2 == 0)
					cout << '#';
				else
					cout << '.';
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
N, A, B = [int(_) for _ in input().split()]
MOD = 10 ** 9 + 7
var1 = pow(2, N, MOD) - 1


def f(x):
    f1 = 1
    for i in range(N - x + 1, N + 1):
        f1 = (f1 * i) % MOD

    # 逆元
    f2 = 1
    for i in range(2, x + 1):
        f2 = (f2*i)%MOD
    f2 = pow(f2, MOD - 2, MOD)
    return (f1 * f2) % MOD


ans = var1 - f(A) - f(B)
print(ans % MOD)


Measured memory_bytes: 9216
n, m = map(int, input().split())

G = [[] for _ in range(n)]
for _ in range(m):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append(v)
    G[v].append(u)

ans = [-1] * n

from collections import deque

q = deque([0])

while q:
    _q = q.popleft()
    for x in G[_q]:
        if ans[x] == -1:
            ans[x] = _q + 1
            q.append(x)

if -1 in ans:
    print('No')
else:
    ans[0] = 'Yes'
    for _ans in ans:
        print(_ans)


Measured memory_bytes: 98032
#include <iostream>
#include <bits/stdc++.h>
#include <iomanip>
typedef long long int lli;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define JUGAD freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pb push_back
#define pf push_front
#define mp make_pair
#define ff first
#define ss second
using namespace std;

const int m=1e9+7;

lli solve(lli n,lli b){
    lli ans=1;
    while(n--){
        ans*=b;
        ans%=m;
    }
    return ans;
}

int main(){
    FAST;
    lli n;
    cin>>n;
    if(n==1){cout<<0<<endl;}
    else{
        lli x=solve(n,10)-2*solve(n,9)+solve(n,8);
        while(x<0){x+=m;}
        x%=m;
        cout<<x<<endl;
    }
}



Measured memory_bytes: 3636
m, n, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
asum = [0]
bsum = [0]
for i in range(m):
  asum.append(asum[i]+a[i])
for i in range(n):
  bsum.append(bsum[i]+b[i])
j = n
max = 0
for i in range(m+1):
    if asum[i] > k:
        break
    while asum[i] + bsum[j] > k:
        j-=1
    if i+j > max:
        max = i+j
print(max)

Measured memory_bytes: 47364
#include <stdio.h>
#include <stdlib.h>

#define MAX_N (100)

int main(int argc, char *argv[]) {
  // read inputs
  int N, bs[MAX_N];
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &bs[i]);
  }

  // solve greedy
  int is_possible = 1, anss[MAX_N];
  for (int i = N; i > 0; i--) {
    // check for impossible 1
    for (int j = 1; j <= i; j++) {
      if (bs[j - 1] > j) {
        is_possible = 0;
        break;
      }
    }
    if (!is_possible) {
      break;
    }

    // check for impossible 2, choose last match
    int ans = -1;
    is_possible = 0;
    for (int j = i; j > 0; j--) {
      if (bs[j - 1] == j) {
        ans = j;
        is_possible = 1;
        break;
      }
    }

    if (is_possible) {
      anss[i - 1] = ans;
      // remove the ans th element
      for (int j = ans; j < i; j++) {
        bs[j - 1] = bs[j];
      }
    } else {
      break;
    }
  }

  if (is_possible) {
    for (int i = 0; i < N; i++) {
      printf("%d\n", anss[i]);
    }
  } else {
    printf("%d\n", -1);
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans = 0;
    for(int i=1; i<n-1;i++){
        if(((a[i] < a[i+1]) && (a[i] > a[i-1]) )||((a[i] > a[i+1]) && a[i] < a[i-1])) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int a,j=1,i,N,sum=0;

int main()
{
    cin>>a;
    while(j<10){
    for(i=1;i<=9;i++){
    N=i*j;    
    if(a==N){
        sum=1;
    }
    }
    j++;
    }
    if(sum==1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;

// tourist set
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << '\n'; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// tourist set end

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<'\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define p_yes() p("YES")
#define p_no() p("NO")
#define SZ(x) ((int)(x).size())
#define SORT(A) sort(ALL(A))
#define RSORT(A) sort(ALL(A), greater<ll>())

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

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

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

    // input
    ll N; 
    cin >> N;

    ll mi = inf;
    for(ll i=1; i*i<=N; i++){
      if(N%i==0){
        ll a = i;
        ll b = N/i;
        ll num = (a-1) + (b-1);
        chmin(mi, num);
      }
    }
    
    p(mi);
    return 0;
}

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

using namespace std;

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

  int64_t a, b, x;
  cin >> a >> b >> x;

  bool bo = false;
  if (a == 0) {
    bo = true;
  }
  a = (a - 1 + bo) / x;
  b = b / x + bo;
  b -= a;

  cout << b << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
const double pi = 3.141592653589793;
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    deque<char> d;
    int k=0;
    rep(i,n){
        if(s[i]=='('){
            k++;
        }
        else{
            k--;
        }
        d.push_back(s[i]);
        if(k<0){
            d.push_front('(');
            k++;
        }
    }
    while(k>0){
        d.push_back(')');
        k--;
    }
    int ds = d.size();
    rep(i,ds){
        cout<<d[i];
    }
  cout<<endl;
}

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

int operation(int x , int y , int z)
{
    int v = (x*x)+(y*y)+(z*z)+(x*y)+(y*z)+(x*z);
    return v;
}
int main()
{
    int n;
    cin >>n;
    int counter=0;
    for(int j =1; j<=n; j++)
    {
        for(int x=1; x<100; x++)
        {
            for(int y=1; y<100; y++)
            {
                for(int z=1; z<100; z++)
                {
                    if(j == operation(x,y,z))
                    {
                        counter++;
                    }
                    else if(j < operation(x,y,z))
                        break;

                }
            }
        }

        cout<<counter<<endl;
        counter=0;
    }

    return 0;
}

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

long long gcd( long long m, long long n ){

  if ( n == 0) return m;
  return gcd(n,m%n);
}//gcd

long long lcm( long long m, long long n ){
  // 引数に０がある場合は０を返す
  if ( ( 0 == m ) || ( 0 == n ) ) return 0;

  return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

int main(){
  int n;
  cin >> n;
  VLL a(n);
  rep(i,n){
    cin >> a[i];
  }
  ll ans = a[0];
  rep(i,n){
    ans = gcd(a[i],ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
// import java.util.Arrays;
// import java.util.StringTokenizer;

import java.util.Stack;

public class Main {
    public static void main(String[] args) throws IOException {

        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        // StringTokenizer st = new StringTokenizer(f.readLine());
        // int N = Integer.parseInt(st.nextToken());
        // int W = Integer.parseInt(st.nextToken());

        String s = f.readLine();
        String t = f.readLine();

        int sLen = s.length();
        int tLen = t.length();

        int[][] dp = new int[sLen + 1][tLen + 1]; // default init to 0

        // int maxSubseqLen = 0;
        // String longest = "";

        for (int _i = 1; _i < sLen + 1; _i++) {
            for (int _j = 1; _j < tLen + 1; _j++) {
                int i = _i - 1;
                int j = _j - 1;


                if (s.charAt(i) == t.charAt(j)) {

                    dp[_i][_j] = dp[_i-1][_j-1] + 1;
                    /* if (dp[_i][_j] > maxSubseqLen) {
                        System.out.print(String.valueOf(_i) + " " + String.valueOf(_j) + " ");
                        System.out.println(dp[_i][_j]);
                        maxSubseqLen = dp[_i][_j];
                        longest += s.charAt(i);
                    } won't work */

                }
                else {
                    dp[_i][_j] = Math.max(dp[_i-1][_j], dp[_i][_j-1]);
                }
            }
        }

        /* for (int[] i : dp){
            for (int j : i) {
                System.out.print(String.valueOf(j) + " ");;
            }
            System.out.println();
        } */

        // System.out.println(maxSubseqLen);
        // System.out.println(longest);

        int _i = sLen;
        int _j = tLen;

        Stack<Character> stak = new Stack<>();

        while (_i > 0 && _j > 0) {
            if (_i > 0 && dp[_i][_j] == dp[_i-1][_j]) {
                _i -= 1;
            }
            else if (_j > 0 && dp[_i][_j] == dp[_i][_j-1]) {
                _j -= 1;
            }
            /* letters at the end of both strings currently being
            compared are the same */
            else {
                stak.push(s.charAt(_i - 1));
                _i -= 1;
                _j -= 1;
            }
        }

        while (!stak.isEmpty()) {
            System.out.print(stak.pop());
        }

        System.out.println();
    }
}

Measured memory_bytes: 82692
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    cout << n*(n-1)/2 <<endl;
    return 0;
}


Measured memory_bytes: 256