akhauriyash/Code-Regression huggingface dataset:
n  = int(input())
ls = list(map(int, input().split()))
ls_plus1  = list(map(lambda x: x + 1, ls))
ls_minus1 = list(map(lambda x: x - 1, ls))
dic = {}
for a in (ls_minus1 + ls + ls_plus1):
    if a in dic: 
        dic[a] += 1
    else: 
        dic[a] = 1
print(sorted(dic.values())[-1])
    

Measured memory_bytes: 26596
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve(){
	int i, j, k, p, q, r, x, y, u, v, n, m;
    string s;
    cin>>s;
    n=s.length();
    if(s.substr(n-1)!="s"){
        cout<<s+"s"<<endl;
    }
    else{
        cout<<s+"es"<<endl;
    }



}

int main() {
	ios_base::sync_with_stdio(0);
	int i,t=1;
	//cin>>t;
	for(i=1;i<=t;i++){
		solve();
	}
	return 0;
}

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = ((ll)result * base) % mod;
		base = ((ll)base * base) % mod;
		exp >>= 1;
	}
	return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}




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

int main() {
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    for (int i=0; i < N; i++) {
        cout << S[i] << T[i];
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 10000000

typedef  long long ll;

using namespace std;

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return r;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}
//A  40s
//B  20min
//C
//D
 string ans;
void solve(void){
    string s;
    cin >> s;

    string ans;
    rep(i,0,s.size()){
        if(i != 0 && s[i] == 'B'){
            if(ans.size()!=0)
            ans.erase(ans.size()-1);
        }else if(s[i] == '0' || s[i] == '1')ans+=s[i];
    }
    if(ans[ans.size()-1] == 'B')ans.erase(ans.size()-1);
    cout << ans;
}

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


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
 		// 整数の入力
    int a = sc.nextInt();
    boolean f = false;
    if(a <= 81){
      for(int i = 2; i < 10; i++){
        if(a % i == 0 && a / i < 10){
          System.out.println("Yes");
          f = true;
          break;
        }
      }
    }else{
      f = true;
      System.out.println("No");
 	}
  	if(f == false)
      if(a == 1){
        System.out.println("Yes");
      }else
        System.out.println("No");
 }
}


Measured memory_bytes: 21844
n,mod=int(input()),10**9+7
dp=[{} for i in range(n+1)]
def ok(last4):
    for i in range(4):
        t=list(last4)
        if i>=1:
            t[i-1],t[i]=t[i],t[i-1]
        if ''.join(t).count('AGC')>=1:
            return 0
    return 1
def dfs(cur,last3):
    if last3 in dp[cur]:
        return dp[cur][last3]
    if cur==n:
        return 1
    ret=0
    for c in 'AGCT':
        if ok(last3+c):
            ret+=dfs(cur+1,last3[1:]+c)
            ret%=mod
    dp[cur][last3]=ret
    return ret




print(dfs(0,'TTT'))

Measured memory_bytes: 9332
import sys
if sys.platform == 'ios':
	sys.stdin = open('input.txt')
	
n,m = map(int,input().split())

#各頂点のパスはタプルで書く
path = {i+1:[] for i in range(n)}

#各頂点が、どの頂点に繋がっているかのリストを入力しながら作る。
for i in range(m):
	a,b = map(int,input().split())
	path[a].append(b)
	path[b].append(a)

#1は根なので不要。2,3,...,nのリストを作る。
chk = [i for i in range(2,n+1)]
ans = 0

import itertools

#fは辿った頂点の数
#intertools.permurationsで頂点の総並び替えを出す
for way in itertools.permutations(chk):
	#print(way)
	now = 1
	f = 0
	
	for j in way:
		if j in path[now]:
			f = f + 1
			now = j
		else:
			break
		
	if f + 1 == n: # +1するのは根の分
		ans = ans + 1

print(ans)
		
		



Measured memory_bytes: 39280
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int n;
int l[2000];
int bs(int k, int s, int r){
	while(s<=r){
		int m=(s+r)/2;
		if(l[m]>=k) r=m-1;
		else s=m+1;
	}
	return s;
}

int main(void){
	int i, j;
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", l+i);
	}
	qsort(l, n, sizeof(int), comp);
	long ans=0;
	for(i=0; i<n; i++){
		for(j=0; j<n; j++){
			if(i==j) continue;
			int a=(l[i]>l[j]?l[i]-l[j]:l[j]-l[i]);
			int b=l[i]+l[j];
			if(a+2>b) continue;
			int now=bs(b, 0, n-1)-bs(a+1, 0, n-1);
			if(a<l[i] && l[i]<b) now--;
			if(a<l[j] && l[j]<b) now--;
			//printf("%d %d %d\n", a, b, now);
			ans+=now;
		}
	}
	printf("%ld\n", ans/6);
}


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

void solve()
{
	ll n;
	cin>>n;
	ll a[n];
	ll ans = 1;
	double temp = 1;
	bool flag = false;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		temp *= (double)a[i];
		if(temp>1e18)
		{
			// cout<<-1<</endl;
			// return;
			flag = true;
		}
		if(a[i]==0)
		{
			cout<<0<<endl;
			return;
		}
		ans*=a[i];
	}
	if(ans>(ll)1e18||flag)
		cout<<-1<<endl;
	else
		cout<<ans<<endl;
}

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

Measured memory_bytes: 4360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn=1e5+5;
const int mod=1e9+7;
int vis[105];
string s,t;
vector<int>v[105];
void print(int lent){
    for(int i=0;i<lent;i++){
        int c=t[i]-'a';
        for(auto d:v[c]) printf("%d ",d);
        printf("\n");
    }
}
void test(){
    vector<int> p[105];
    for(int i=0,j=0;i<100;i++){
        for(auto c:s){
            p[c-'a'].push_back(j++);
        }
    }
    int ans=-1;
    for(auto c:t){
        int now=c-'a';
        int index=lower_bound(p[now].begin(),p[now].end(),ans+1)-p[now].begin();
        if(index>=0&&index<p[now].size()) ans=p[now][index];
        else{
            printf("-1\n");
            return;
        }
    }
    printf("%d\n",ans+1);
}
int main(){
    cin>>s;
    cin>>t;
    int lens=s.size();
    int lent=t.size();
    memset(vis,0,sizeof(vis));
    for(auto c:s){
        vis[c-'a']=1;
    }
    bool flag=true;
    for(auto c:t){
        if(!vis[c-'a']){
            flag=false;
            break;
        }
    }
    if(!flag){
        printf("-1\n");
        return 0;
    }
    for(int i=0;i<lens;i++){
        v[s[i]-'a'].push_back(i);
    }
    int ans=0,pre=-1;
    //print(lent);
    //test();
    for(int i=0;i<lent;i++){
        int c=t[i]-'a';
        int index=lower_bound(v[c].begin(),v[c].end(),pre+1)-v[c].begin();
        int len=v[c].size();
        if(index>=0&&index<len) pre=v[c][index];
        else{
            ans++;
            pre=-1;
            index=lower_bound(v[c].begin(),v[c].end(),pre+1)-v[c].begin();
            if(index>=0&&index<len) pre=v[c][index];
            else{
                flag=false;
                break;
            }
        }
    }
    if(!flag) printf("-1\n");
    else printf("%lld\n",1LL*ans*lens+pre+1);
}



Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  int n;cin >> n;
  int i;
  for(i=1;i<=n;i*=2){
  }
  cout << i/2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;


int main() {
    int a[5];
    int b[5];
    for(int i=1;i<4;++i)cin>>a[i]>>b[i];
    int c1=0;
    int c2=0;
    int c3=0;
    int c4=0;
    for(int i=1;i<4;++i){
        if(a[i]==1){
            c1+=1;
        }
        else if(a[i]==2){
            c2+=1;
        }
        else if(a[i]==3){
            c3+=1;
        }
        else{
            c4+=1;
        }
    }
    for(int i=1;i<5;++i){
        if(b[i]==1){
            c1+=1;
        }
        else if(b[i]==2){
            c2+=1;
        }
        else if(b[i]==3){
            c3+=1;
        }
        else{
            c4+=1;
        }
    }
    if(c1<=2){
        if(c2<=2){
            if(c3<=2){
                if(c4<=2){
                    cout<<"YES"<<endl;
                }
                else{
                    cout<<"NO"<<endl;
                    
                }
                
        }
            else{
                cout<<"NO"<<endl;
                
            }
        }
            else{
                cout<<"NO"<<endl;
                
            }
        
    }

        else{
            cout<<"NO"<<endl;
            
        }
                
        
    }


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Feb  9 13:24:45 2019

@author: Yamazaki Kenichi
"""

N,K = map(int,input().split())
A = list(map(int,input().split()))
a = ['{:040b}'.format(i) for i in A]
k = '{:040b}'.format(K)
res = 0
flg = False
for i in range(40):
    counta = 0
    for j in range(N):
        counta += 1 if a[j][i] == '1' else 0
        check = True if counta<N/2 else False
    if flg:
        if check:
            res += pow(2,39-i)
        continue
    if check and k[i]=='1':
        res += pow(2,39-i)
    else:
        if k[i]=='1':
            flg = True
ans =0
for elem in A:
    ans += elem^res
print(ans)


Measured memory_bytes: 19640
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
    char s[100];
    while(~scanf("%s",s))
    {
        s[3]='8';
        printf("%s\n",s);
    }
    return 0;


}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

int main() {
    string s;
    cin >> s;

    int ans = 0;
    int length = s.length();
    rep(i, length / 2) {
        if(s[i] != s[length - 1 - i]) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,x;cin >> a >> b >> x;
	if(a % x != 0) a += x - a % x;
	if(a > b) cout << 0 << endl;
	else cout << (b - a + 1 + x - 1) / x << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {


	public static void main(String[] args) {

//		long ans = 0;
//		double ans = 0.0;
		int ans = 0;
//		String ans = "";

		Scanner sc = new Scanner(System.in);
//		double waru = 1000000007;


//		long n = sc.nextLong();
//		long m = sc.nextLong();
//		long k = sc.nextLong();

		int n = sc.nextInt();
//		int m = sc.nextInt();
//		int k = sc.nextInt();
//		int v = sc.nextInt();
//		String s = sc.next();


//		String string = sc.next();
//		StringBuilder s = new StringBuilder(string);

		boolean f = false;

//		String[] s = new String[n];

		int[] a = new int[n];
//		int[] b = new int[n];
//		long[] a = new long[n];
//		long[] b = new long[n];
//		int[][] a = new int[n][m];

		for (int i = 0; i < n; i++) {
			a[i]= sc.nextInt();
		}

//		for (int i = 0; i < h; i++) {
//			for(int j = 0; j < w; j++) {
//				a[i][j] = sc.nextInt();
//			}
//		}


//		for(int i = 0; i < n; i++) {
//			f = false;
//			for(int j = 0; j < i; j++) {
//				if(a[i] <= a[j]) {
//					f = true;
////					System.err.println(a[i] +" "+ a[j]);
//				} else {
//					f = false;
//					break;
//				}
//			}
//			if(f) {
//				ans++;
//			}
//		}

		int tmp = n+1;
		for(int i = 0; i < n; i++) {
			if(i==0) {
				tmp = a[i];
				continue;
			}
			if(tmp >= a[i]) {
				tmp = a[i];
				ans++;
			}

		}

		ans++;




		System.out.println(ans);

		sc.close();
	}


}

Measured memory_bytes: 79404
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
//#define lli long long int
int gcd(int, int);
void Exgcd(int, int,int*,int*,int);
int main() {
	int a, b, c, i, j, x=1, y=0;
	scanf("%d%d", &a,&b);
	c = gcd(a, b);
	Exgcd(a, b, &x, &y, c);
	printf("%d %d\n", x, y);
	return 0;
}

int gcd(int x, int y) {
	int tmp;
	if (x < y) { tmp = x; x = y; y = tmp; }
	if (x%y == 0) return y;
	gcd(x%y, y);
}

void Exgcd(int a, int b,int *x,int *y,int c){
	int tmp,x2=0,y2=1,q;
	while (c!=b) {
		q = a / b;
		tmp = x2; x2 = *x - q*x2; *x = tmp;
		tmp = y2; y2 = *y - q*y2; *y = tmp;
		tmp = b; b = a - q*b; a = tmp;
	}
	*x = x2;
	*y = y2;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <stdlib.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
Q[tail]=x;
  if(tail == LEN)tail=0;
  else tail++;
}

P dequeue(void){

  P x;
  x = Q[head];
  if(head == LEN)head=0;
  else head++;
  return x;
  
}


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  head = 1;
  tail = n+1;
  
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }


  while(n!=0){

    //for ( i = head; i < tail; i++)
      // printf("%s\n", Q[i].name);
	
    u=dequeue();
    u.t -= q;
    
    if(u.t<=0){
      printf("%s %d\n",u.name,elaps+q+u.t);
      elaps+=q+u.t;
      n--;
      //printf("%s\n",u.name);
      //  printf("aaaa %s %d\n",u.name,elaps);
    }
    else {
      enqueue(u);
      elaps += q;
    }
  }
  
  return 0;
}



Measured memory_bytes: 11852
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<vector>
#include<map>
#include<queue>

#define N 300005
#define M 8000005

#define ls (t<<1)
#define rs ((t<<1)|1)
#define mid ((l+r)>>1)

#define mk make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

int i,j,m,n,p,k;

map<int,int>mp;

map<int,int>::iterator it;

int main()
{
		scanf("%d",&n);
		for (i=1;i<=n;++i) scanf("%d",&k),mp[k]++; 
		int Max=0,Ma=0;
		for (it=--mp.end();;--it)
		{
			while (it->se>=2)
			{
				if (!Max) Max=it->fi;
				else if (!Ma) Ma=it->fi;
				it->se-=2;
			}
			if (it==mp.begin()) break;
		}
		cout<<1ll*Max*Ma<<endl;
}


Measured memory_bytes: 4992
s=input()
for i in range(len(s)):
  if(i%2 == 0):
    if(s[i] == "R" or s[i] == "U" or s[i] == "D"):
      continue
    else:
      print("No")
      exit()
  if(i%2 == 1):
    if(s[i] == "L" or s[i] == "U" or s[i] == "D"):
      continue
    else:
      print("No")
      exit()
print("Yes")

Measured memory_bytes: 3064
N=int(input())
BTC_to_JPY=380000.0
price_sum=0

for i in range(N):
  price,currency=input().split()
  price=float(price)
  if currency == 'BTC':
    price=BTC_to_JPY*price
    
  price_sum=price_sum+price
  
print(price_sum)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
#define max(a,b) a < b ? b : a
using namespace std;
using ll = long long;



int main(){
    int N;
    cin >> N;
    vector<vector<int>> G(N);
    vector<pair<int,int>> vp;
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
        vp.emplace_back(a,b);
    }

    int K = 0;
    map<pair<int,int> ,int > I;
    vector<int> cs(N,0);

    vector<int> used(N,0);
    queue<int> que;
    used[0] = 1;
    que.emplace(0);
    while(!que.empty()){
        int v = que.front(); que.pop();
        if(K < (int)G[v].size()) K = G[v].size();
        int cur = 1;
        for(int u : G[v]){
            if(used[u]) continue;
            if(cur==cs[v]) cur++;
            cs[u] = I[make_pair(u,v)] = I[make_pair(v,u)]= cur;
            cur++;
            used[u] = 1;
            que.emplace(u);
        }
    }

    cout << K << endl;
    for(auto p : vp) cout << I[p] << endl;

    return 0;
}

Measured memory_bytes: 20084
#ifndef ___Rank_Union_Find
#define ___Rank_Union_Find

// ------ Required ------ //
#include <vector>

// ------ Class ------ //
class RankUnionFind {
private:
	std::size_t size_; std::vector<std::size_t> par, rank;
public:
	RankUnionFind() : size_(0), par(std::vector<std::size_t>()), rank(std::vector<std::size_t>()) {};
	RankUnionFind(std::size_t size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (std::size_t i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	std::size_t size() { return size_; }
	std::size_t root(std::size_t x) { return par[x] == x ? x : par[x] = root(par[x]); }
	bool same(std::size_t x, std::size_t y) { return root(x) == root(y); }
	void unite(std::size_t x, std::size_t y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const RankUnionFind &u) { return par == u.par; }
	bool operator!=(const RankUnionFind &u) { return par != u.par; }
};

#endif

#include <iostream>
#include <algorithm>
using namespace std;
struct Edge { int a, b, w; };
bool operator<(const Edge& e1, const Edge& e2) { return e1.w < e2.w; }
int N, M, a, b, w; Edge G[5000];
int main() {
	while (cin >> N >> M, N | M) {
		for (int i = 0; i < M; i++) cin >> G[i].a >> G[i].b >> G[i].w, G[i].a--, G[i].b--;
		sort(G, G + M);
		int ret = 999999999;
		for (int i = 0; i < M; i++) {
			int r = 0, c = 0;
			RankUnionFind uf(N);
			for (int j = i; j < M; j++) {
				if (!uf.same(G[j].a, G[j].b)) {
					uf.unite(G[j].a, G[j].b);
					r = G[j].w; c++;
				}
			}
			if (c == N - 1) ret = min(ret, r - G[i].w);
		}
		if (ret == 999999999) cout << -1 << endl;
		else cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
using namespace std;
/*long long divisorNum(long long);
long long kaijou(long long);*/

int main()
{
	long long n, a, b,fatique=0;
	cin >> n >> a >> b;
	vector<long long>x(n);
	for (long long& p : x)cin >> p;
	for (int i = 0; i < n-1; i++) {
		long long walkcost = a*abs(x[i + 1] - x[i]);
		if (walkcost >= b)fatique += b;
		else fatique += walkcost;
	}
	cout << fatique << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int F[305][305][305], K, n;

char ch[333];

void cmax(int &x, int y) {
    if(x < y) x = y;
}

int main() {
    scanf("%s", ch + 1);
    scanf("%d", &K);
    memset(F, 200, sizeof F);
    n = strlen(ch + 1);
    F[0][n + 1][0] = 0;
    for(int i = 0; i <= n + 1; i++)
        for(int j = n + 1; j >= 1; j--)
            for(int k = 0; k <= K; k++) {
                cmax(F[i + 1][j][k], F[i][j][k]);
                cmax(F[i][j - 1][k], F[i][j][k]);
                int tmp = ch[i + 1] != ch[j - 1];
                if(k + tmp <= K) cmax(F[i + 1][j - 1][k + tmp], F[i][j][k] + 2);
            }
    int ans = 0;
    for(int i = 2; i <= n + 1; i++)
        for(int j = 0; j <= K; j++)
            cmax(ans, F[i - 2][i][j] + 1);
    for(int i = 1; i <= n + 1; i++)
        for(int j = 0; j <= K; j++)
            cmax(ans, F[i - 1][i][j]);
    printf("%d\n", ans);
    return 0;
}

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

#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);               \
    cout.tie(NULL)
// #define int long long
#define endl '\n'

using namespace std;

const int N = 2e5 + 77;

string s;

int32_t main()
{
    long double a , b ; cin >> a >> b;
    cout << ceil((b-1)/(a-1)) << endl;
    cout << endl;
    return 0;
}

Measured memory_bytes: 3784
# https://atcoder.jp/contests/abc145/tasks/abc145_d
import math
X, Y = list(map(int, input().split()))

if (X + Y) % 3 != 0:
    print(0)
    exit()


n = int((2*X - Y) // 3)
m = int((2*Y - X) // 3)

if n < 0 or m < 0:
    print(0)
    exit()


def comb(n, k):
    c = 1
    for i in range(k):
        c *= n - i
        c %= MOD
    d = 1
    for i in range(1, k + 1):
        d *= i
        d %= MOD
    return (c * pow(d, MOD - 2, MOD)) % MOD

MOD = 10 ** 9 + 7
result = comb(n+m, n)
print(result)


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

int main() {
	double a;
	while (scanf("%lf", &a), a + 1) {
		double b = a / 2;
		for (int c = 0; c < 100; c++) {
			if (abs(b*b*b - a) < a / 100000)break;
			double d = b*b*b - a, e = b*b * 3;
			b -= d / e;
		}
		printf("%.10lf\n", b);
	}
}

Measured memory_bytes: 3236
X,Y,Z,K = (int(num) for num in input().split())
a = [int(num) for num in input().split()]
b = [int(num) for num in input().split()]
c = [int(num) for num in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

l = []
for i in range(X):
    if i+1 > K:
        break
    
    for j in range(Y):
        if (i+1) * (j+1) > K:
            break
        
        for k in range(Z):
            if (i+1) * (j+1) * (k+1) > K:
                break
            
            l.append(a[i]+b[j]+c[k])
            
            
l.sort(reverse=True)
for i in range(K):
    print(l[i])

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

#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define EPS 1e-9

typedef complex<double> P;

double x[4],y[4],xp,yp;

double cross(P a, P b){
	return imag( conj(a) * b );
}

int main(){
	while(cin>>x[0]>>y[0]>>x[1]>>y[1]>>x[2]>>y[2]>>xp>>yp){
		
		P p(xp, yp), q[4];
		rep(i,3) q[i] = P(x[i], y[i]);
		
		int posi=0, nega=0;
		rep(i,3){
			double cr = cross( q[(i+1)%3] - q[i], p - q[i]);
			if(cr > EPS) posi++;
			if(cr < EPS) nega++;
		}
		cout<<(posi==3 || nega==3 ? "YES" : "NO")<<endl;
	}
}

Measured memory_bytes: 0
#include <cstdio>

int main(void)
{
	double a, res;
	while (scanf("%lf", &a) != EOF){
		res = a;
		for (int i = 2; i <= 10; i++){
			if (i % 2 == 0){
				a *= 2.0;
			}
			else {
				a /= 3.0;
			}
			res += a;
		}
		printf("%.8lf\n", res);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n=s.size();
  long long ans=0,cnt=0;
  bool b=false;
  for(int i=0;i<n-1;i++){
    if(b){
      b=false;
      continue;
    }
    if(s[i]=='A'){
      cnt++;
    }
    if(s.substr(i,2)=="BC"){
      ans+=cnt;
      b=true;
    }
    if(s[i]!='A'&&s.substr(i,2)!="BC"){
      cnt=0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
import sys
inf = 10**18
N = int(input())
A = [int(i) for i in input().split()]
if 0 in A:
    print(0)
    sys.exit(0)
ans = 1
for i in A:
    ans *= i
    if ans>inf:
        print(-1)
        sys.exit(0)
print(ans)

Measured memory_bytes: 21712
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np
import itertools

N,M = map(int,readline().split())
XYZ = np.array(read().split(),np.int64)

X = XYZ[::3]; Y = XYZ[1::3]; Z = XYZ[2::3]

vals = []
for x,y,z in itertools.product([-1,1],repeat=3):
    x = x*X + y*Y + z*Z
    x.sort()
    vals.append(x[N-M:].sum())

answer = max(vals)
print(answer)

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

int main(){
	long long int N;
	cin >> N;
	long long int ans=0;
	for(long long int i = 1;i <= N;++i){
		if(i%3&&i%5) ans += i;
	}
	cout << ans << endl;
	return 0;



    
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define int           long long
#define pb            push_back
#define ppb           pop_back
#define si            set <int>
#define endl          '\n'
#define fr            first
#define sc            second     
#define rep(i,a,b)    for(int  i=a;i<b;i++)
#define repr(i,a,b)      for(int i=b-1;i>=a;i--)
#define trav(it,v)      for(auto it=v.begin();it!=v.end();it++)
#define all(v)        v.begin(),v.end()
#define srt(v)        sort(all(v))
#define vs            vector<string>
#define sz(x)         (int )x.size()
#define M             1000000007
#define bs            binary_search
#define sp(n)         setprecision(n)
#define spl           " "
#define arr(a,n)      rep(i,0,n) cin>>a[i]
#define mod           998244353
#define MAXN             10001

using namespace std;

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 


//int dx[4]={0,0,1,-1};
//int dy[4]={1,-1,0,0};
void solve()
{
    int n;
    cin>>n;
    int a[n];
    int b[n+1]={0};
    rep(i,0,n)
    {
        cin>>a[i];
        b[a[i]]++;
    }
    int sum=0;
    rep(i,1,n+1)
    {
        if(b[i]>=2)
        {
            sum+=(b[i]*(b[i]-1))/2;
        }
    }
    rep(i,0,n)
    {
        int k=a[i];
        int ans=sum;
        if(b[k]>=2)
        {
            ans-=(b[k]*(b[k]-1))/2;
            int j=b[k]-1;
            if(j>=2)
            {
                ans+=(j*(j-1))/2;
            }
        }
        cout<<ans<<"\n";
    }
    
    
}	
	


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

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int A,B,V,W,T,t,l,l2;
  cin >> A >> V;
  cin >> B >> W;
  cin >> T;
  if(V>W){
    l=A-B;
    if(l<0){
      l *= -1;
    }
    l2 = T*(V-W);
    if(l<=l2){
      cout << "YES" << endl;
    }
    else{
    cout << "NO" << endl;
    }
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3608
//-----by LY02------------------------------------
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define M 1000000007
//------------------------------------------------

int grp[1010][1010];
int dp[1010][1010];
//------------------------------------------------
int main() {
//------------------------------------------------
//	freopen("In.txt","r",stdin);
//	freopen("Out.txt","w",stdout);
//------------------------------------------------
	ios::sync_with_stdio(0);
	cin.tie(0);
//------------------------------------------------

int h,w;
cin>>h>>w;
string s;
for(int i=0;i<h;i++)
{
	cin>>s;
	for(int j=0;j<w;j++)
		if(s[j]=='#') grp[i][j]=-1;
}
dp[0][0]=1;
for(int i=1;i<h;i++)
	dp[i][0]=grp[i-1][0]!=-1?dp[i-1][0]:0;
for(int i=1;i<w;i++)
	dp[0][i]=grp[0][i-1]!=-1?dp[0][i-1]:0;

for(int i=1;i<h;i++)
{
	for(int j=1;j<w;j++)
	{
		if(grp[i-1][j]!=-1) dp[i][j]+=dp[i-1][j];
		if(grp[i][j-1]!=-1) dp[i][j]+=dp[i][j-1];
		dp[i][j]%=M;
	}
}
//for(int i=0;i<h;i++)
//{
//	for(int j=0;j<w;j++)
//		cout<<dp[i][j]<<" ";
//	cout<<endl;
//}

cout<<dp[h-1][w-1]<<endl;

//------------------------------------------------
	return 0;
}





//-----by LY02------------------------------------


Measured memory_bytes: 8192
import java.util.*;

public class Main{
  
  public static void main (String[] args){
  
  	Scanner scanner = new Scanner (System.in);
  
   	int N = scanner.nextInt();
    
    boolean flag = false;
    
    for (int i=0; i<N; i++){
      String a = scanner.next();
      if (a.equals("Y")){
        flag = true;
      }
    }
    if (flag == true){
      System.out.println("Four");
    } else {
      System.out.println("Three");
    }
  }
}

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

int main()
{
	int N;
	cin>>N;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
	long long ans=0;
	int MaxNum=0;
	for (int i = 0; i < N; i++)
    {
		MaxNum = max(MaxNum, A[i]);
        int Bi = MaxNum;
        ans += Bi - A[i];
    }
	cout << ans << endl;
}

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

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  if(a>=k) {
    a -= k;
    cout << a << " " << b << endl;
    return 0;
  } else {
    b -= k-a;
    if(b < 0) {
      b = 0;
    }
    cout << 0 << " " << b << endl;
  }

  return 0;
}

Measured memory_bytes: 256
n,m = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(n)]
y = [[int(i) for i in input().split()] for i in range(m)]
for i in x:
	num,answer = abs(i[0]-y[0][0])+abs(i[1]-y[0][1]),1
	for j in range(m):
		if num > abs(i[0]-y[j][0])+abs(i[1]-y[j][1]):
			answer = j+1
			num = abs(i[0]-y[j][0])+abs(i[1]-y[j][1])
	print(answer)

Measured memory_bytes: 3064
#include <stdio.h>
typedef long long ll;
ll max(ll a, ll b){return (a > b)? a : b;}

int main(void){
    // Your code here!
    int a,b,c,K;
    scanf("%d %d %d",&a,&b,&c);
    scanf("%d",&K);
    
    int max_num = max(a,max(b,c));
    int * n;
    if(a == max_num) n = &a;
    else if(b == max_num) n = &b;
    else n = &c;
    
    for(int i = 0; i < K; i++){
        *n *= 2; 
    }
    printf("%d\n",a+b+c);
}


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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

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

int main(void){

    ll n;
    cin >> n;

    ll ans = n/11 * 2;
    if(n%11 > 6) ans += 2;
    else if(n%11 > 0) ans++;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n, m = list(map(int, input().split()))
ac = [0] * n
wa = [0] * n
for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == "AC":
        ac[p] = 1
    elif not ac[p]:
        wa[p] += 1
ans = [sum(ac), sum([i * j for i, j in zip(ac, wa)])]
print("{} {}".format(ans[0], ans[1]))

Measured memory_bytes: 5528
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.AbstractCollection;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CCatSnukeAndAVoyage solver = new CCatSnukeAndAVoyage();
        solver.solve(1, in, out);
        out.close();
    }

    static class CCatSnukeAndAVoyage {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            HashSet<Integer> x = new HashSet<>();
            HashSet<Integer> y = new HashSet<>();

            for (int i = 0; i < m; i++) {
                int a = in.nextInt(), b = in.nextInt();
                if (a == 1) {
                    y.add(b);
                } else if (b == n) {
                    x.add(a);
                }
            }

            x.retainAll(y);

            boolean answer = !x.isEmpty();

            out.println(answer ? "POSSIBLE" : "IMPOSSIBLE");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 56728
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	result := make([]int, 6)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		scanner.Scan()
		h, _ := strconv.ParseFloat(scanner.Text(), 64)
		if h < 165.0 {
			result[0]++
		} else if 165.0 <= h && h < 170.0 {
			result[1]++
		} else if 170.0 <= h && h < 175.0 {
			result[2]++
		} else if 175.0 <= h && h < 180.0 {
			result[3]++
		} else if 180.0 <= h && h < 185.0 {
			result[4]++
		} else if 185.0 <= h {
			result[5]++
		}
	}
	for i := 0; i < 6; i++ {
		fmt.Printf("%d:", i+1)
		for j := 0; j < result[i]; j++ {
			fmt.Print("*")
		}
		fmt.Println()
	}
}


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

typedef long long ll;
ll const mod = 1e9+7;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

void dfs(int i,int p,vector<vector<int>>& edges,vector<vector<ll>>& dp) {
    for (int j : edges[i]) if (j != p) {
        dfs(j,i,edges,dp);
        dp[i][0] *= (dp[j][0]+dp[j][1])%mod;
        dp[i][1] *= dp[j][0];
        dp[i][0] %= mod;
        dp[i][1] %= mod;
    }
}

int main() {
    int n;
    cin >> n;
    vector<vector<int>> edges(n);
    vector<vector<ll>> dp(n,vector<ll>(2,1));
    for (int i = 0;i < n-1;++i) {
        int u,v;
        cin >> u >> v;
        u--;v--;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    dfs(0,-1,edges,dp);
    cout << (dp[0][0]+dp[0][1])%mod << endl;
    return 0;
}

Measured memory_bytes: 19584
#include<stdio.h>

int main(){
        int p[5];
        int ap=0;
        int i,j;

        for(i = 0; i < 5; i++){
                scanf("%d",&p[i]);
                
                if(p[i] < 40){
                        p[i] = 40;
                }
        }

        for(j = 0; j < 5; j++){
                ap += p[j];
        }

        ap = ap / 5;

        printf("%d\n",ap);

        return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;

double cross_product (xy_t a, xy_t b) {
    return (conj(a) * b).imag();
}

xy_t P[110];

int main() {
    int N = 0;
    double x, y;
    while (~scanf("%lf,%lf", &x, &y)) {
        P[N] = xy_t(x, y);
        N++;
    }
    double ans = 0;
    xy_t a = P[0];
    for (int i = 0; i < N - 2; i++) {
        xy_t b = P[i + 1], c = P[i + 2];
        ans += 0.5 * cross_product(b - a, c - a);
    }
    printf("%.6f\n", abs(ans));
}



Measured memory_bytes: 3192
program main

  implicit none

  integer    :: n, m, i, j
  integer(8) :: nac, nwa
  integer,allocatable :: p(:), jj(:), ac(:), wa(:)
  character(2),allocatable ::  s(:)
  
  read(*,*) n, m
  allocate( p(m) )
  allocate( s(m) )
  allocate( jj(n) ); jj = 0
  allocate( ac(n) ); ac = 0
  allocate( wa(n) ); wa = 0

  do i = 1, m 
    read(*,*) p(i), s(i)
  end do
  
  nac = 0
  nwa = 0
  do i = 1, m 
    if ( s(i) == "AC" .and. jj( p(i) ) == 0 ) then
      ac( p(i) ) = ac( p(i) ) + 1
      jj( p(i) ) = jj( p(i) ) + 1
    else if ( s(i) == "WA" .and. jj( p(i) ) == 0 ) then
      wa( p(i) ) = wa( p(i) ) + 1
    end if
  end do
  do i = 1, n 
    if( jj(i) == 0 ) wa(i) = 0 
  end do

  nac = sum( ac )
  nwa = sum( wa )
  print*, nac, nwa
  
end program main


Measured memory_bytes: 1920
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl;exit(0);}else return;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

//DigitSum
long long DigitSum(long long N, long long K) {
	long long sum = 0;
	for (; N > 0; N /= K) sum += N % K;
	return sum;
}

int main() {
	int N; cin >> N;
	V<ll> dp(1 << N, 0);
	dp[0] = 1;

	V<V<int>> a(N + 1, V<int>(N + 1, 0));
	FOR(i, 1, N + 1)FOR(j, 1, N + 1) cin >> a[i][j];
	FOR(i,1,N+1){
		REP(j,1<<N){
			if (DigitSum(j, 2) != i-1) continue;
			REP(k,N){
				if (!(j&(1 << k)) && a[i][k + 1]) (dp[j ^ (1 << k)] += dp[j]) %= MOD;
			}
		}
	}
	cout << dp[(1 << N) - 1] << endl;
	return 0;
}



Measured memory_bytes: 16640
//Reference : https://atcoder.jp/contests/abc165/submissions/12659326
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
typedef pair<int, int > Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize 
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repll(i, a, b) for(ll i=(a); i<(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(),(a).end()
const long long int mod = 1e9 + 7;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false); 
    ll a,b,n;
    cin >> a >> b >> n;
    ll x = n;
    if(b-1 <= n) x = b-1;
    ll ans = (a*x)/b - a*(x/b);
    COUT(ans);
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        String ans = "";

        if(A < B){
            for (int i = 0; i < B; i++) {
                ans += String.valueOf(A);
            }
        }else{
            for (int i = 0; i < A; i++) {
                ans += String.valueOf(B);
            }
        }


        System.out.println(ans);

    }
}



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

int main(){
  int N; cin >> N;
  vector<int> a(N);
  int mi = 101, ma = -101;
  for(int i = 0; i < N; i++){
    cin >> a[i];
    mi = min(mi, a[i]);
    ma = max(ma, a[i]);
  }
  
  int ans = (int)1e8;
  
  for(int i = mi; i <= ma; i++){
    int tmp = 0;
    for(int j = 0; j < N; j++){
      tmp += (a[j] - i) * (a[j] - i);
    }
    ans = min(ans, tmp);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<int>;

ll dp[301][301][301] = {0};

int main()
{

	int N, K;
	cin >> N >> K;

	for (int i = 0; i <= N; ++i)
	{
		for (int j = 0; j <= K; ++j)
		{
			for (int k = 0; k <= N; ++k)
			{
				dp[i][j][k] = 1e18;
			}
		}
	}

	dp[0][0][0] = 0;

	vec H(N+1,0);
	for (int i = 0; i < N; ++i)cin >> H[i+1];

	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j <= K; ++j)
		{
			for (int k = 0; k <= N; ++k)
			{
				// しない
				dp[i + 1][j][i + 1]
					= min(dp[i + 1][j][i + 1], dp[i][j][k] + max(0ll, H[i + 1] - H[k]));

				if (j == K) { continue; }

				// する
				dp[i + 1][j + 1][k]
					= min(dp[i + 1][j + 1][k], dp[i][j][k]);
			}
		}
	}

	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j <= K; ++j)
		{
			for (int k = 0; k <= N; ++k)
			{
				//printf("(%d,%d,%d) = %ld\n", i, j, k, dp[i][j][k]);
			}
		}
	}


	ll ans = 1e18;
	for (int j = 0; j <= K; ++j)
	{
		for (int k = 0; k <= N; ++k)
		{
			ans = min(ans, dp[N][j][k]);
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 213248
"use strict"

function main(input) {

    let num = Number(input)
    let n = input.length
    let tmp = num
    let ans = 0
    for (let i = 1; i <= n; i++) {
        ans += tmp % 10
        tmp = Math.floor(tmp / 10)
    }
    if (num % ans == 0) console.log('Yes')
    else console.log('No')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 9420
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int a, b, c, d, e, f;
    int t1, t2, t3;
    int ans;

    void run(){
	while(sc.hasNext()){
	    a = sc.nextInt();
	    b = sc.nextInt();
	    c = sc.nextInt();
	    d = sc.nextInt();
	    e = sc.nextInt();
	    f = sc.nextInt();
	    if(a==0 && b==0 && c==0 && d==0 && e==0 && f==0) break;
	    
	    t1 = a+d;
	    t2 = b+e;
	    t3 = c+f;
	    ans = 0;

	    for(int i=0; i<3; i++){
		if(t1-i<0 || t2-i<0 || t3-i<0) continue;
		int sum = i + (t1-i)/3 + (t2-i)/3 + (t3-i)/3;
		ans = Math.max(ans, sum);
	    }

	    System.out.println(ans);
	}
    }
}

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


int main(){
    int N, A;
    cin >> N >> A;
    vector<int> x(N);
    for (int i = 0; i < N; i++) cin >> x[i];
    vector<vector<ll>> dp(N+1, vector<ll>(2501, 0));
    dp[0][0] = 1;
    
    for (int i = 0; i < N; i++) {
        for (int j = i; j >= 0; j--) {
            for (int k = 0; k <= 2500-x[i]; k++){
                dp[j+1][k+x[i]] += dp[j][k];
            }
        }
    }
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        ans += dp[i][A*i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1280