akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

string s;
char s_[111111];
int k;

struct SA {
  string s;
  vector<int> sa, pos;
  int gap;
  
  void build(const string& s_) {
    s = s_;
    sa.resize(s.size());
    pos.resize(s.size());
    auto comp = [&](int a, int b) {
      if (pos[a] != pos[b]) return pos[a] < pos[b];
      a += gap;
      b += gap;
      return (a < int(s.size()) &&
              b < int(s.size())) ? pos[a] < pos[b] : a > b;
    };
    for (size_t i = 0; i < s.size(); i++) {
      sa[i] = i;
      pos[i] = s[i];
    }
    vector<int> t(s.size());
    for (gap = 1;; gap *= 2) {
      sort(sa.begin(), sa.end(), comp);
      for (size_t i = 0; i+1 < s.size(); i++) {
        t[i+1] = t[i] + (comp(sa[i], sa[i+1]) ? 1 : 0);
      }
      for (size_t i = 0; i < s.size(); i++) {
        pos[sa[i]] = t[i];
      }
      if (t.back() == int(s.size())-1) break;
    }
  }
};

SA sa;
vector<int> vs;
int l;

bool test(int j) {
  int c = 0;
  // printf("%s\n", s.substr(j, l).c_str());
  for (size_t i = 0; i+l <= s.size();) {
    // printf("%zd: %d\n", i, c);
    // printf("%zd: %s %d\n", i, buf.c_str(), c);
    if (l == 1) {
      if (s[i] > s[j]) return false;
    }
    if (strncmp(s.c_str()+j, s.c_str()+i, l) >= 0) {
      i += l;
      if (i != s.size()) ++c;
    } else {
      i += l-1;
      ++c;
    }
    /*
    if (((buf.size()+1 == t.size() && buf+s[i] > t) || buf.size()+1 > t.size())) {
      buf = s[i];
      ++c;
    } else {
      buf += s[i];
    }
    */
  }
  return c <= k;
}

int main(void) {
  scanf("%d%s", &k, s_); s = s_;
  sa.build(s);
  l = (s.size()+k)/(k+1);
  for (int i = 0; i < int(sa.sa.size()); i++) {
    if (sa.sa[i]+l <= int(s.size())) {
      vs.push_back(sa.sa[i]);
    }
  }

  int lb = -1;
  int rb = vs.size()-1;
  while (rb-lb > 1) {
    int mb = (lb+rb)/2;
    if (test(vs[mb])) {
      rb = mb;
    } else {
      lb = mb;
    }
  }
  printf("%s\n", s.substr(vs[rb], l).c_str());
  return 0;
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
const int maxn=507;
const int mod=1e9+7;
vi G[maxn];
int dfn[maxn], low[maxn];
int n, m;
int ti, scc; //时间戳与联通分量计数
set<int> nG[maxn];
stack<int> st;
void dfs(int u, int fa)
{
    dfn[u] = low[u] = ++ti;
    for (auto v:G[u])
    {
        if (v == fa)
            continue;
        if (!dfn[v])
        {
    		st.push(v);
            dfs(v, u);
            low[u] = min(low[u], low[v]);
			if(low[v]>=dfn[u])
			{
				scc++;
				while(1)
				{
					int t=st.top();
					st.pop();
					nG[scc].insert(t);
					if(t==v) break;
				}
				nG[scc].insert(u);
			}
        }
        else low[u] = min(low[u], dfn[v]);
    }
}
void DCC()
{
    for (int i = 1; i <= n; i++)
        if (!dfn[i])
        {
			dfs(i, -1);
			st.push(i);
		}
}
ll quick(ll a,ll b)
{
	ll ret=1;
	while(b)
	{
		if(b&1) ret=ret*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ret;
}
ll inv(ll a){return quick(a,mod-2);}
ll fac[maxn];
int cnt[maxn];
ll C(int n,int m)
{
	return fac[n]*inv(fac[m])%mod*inv(fac[n-m])%mod;
}
struct Edge{
	int u,v;
}edges[maxn];
int k;
int fa[maxn];
void init()
{
	for(int i=0;i<=n;i++) fa[i]=i;
}
int Find(int x)
{
	return x==fa[x]?x:fa[x]=Find(fa[x]);
}
void Union(int x,int y)
{
	x=Find(x),y=Find(y);
	fa[y]=x;
}
bool solve(int x)
{
	init();
	int cc=0;
	for(auto u:nG[x])
	{
		for(auto v:G[u])
		{
			if(nG[x].count(v)&&v<u)
			{
				cnt[x]++;
				if(Find(u)==Find(v)) cc++;
				else Union(u,v);
			}
		}
	}
	return cc<=1;
}
int main()
{
	fac[0]=1;
	for(int i=1;i<maxn;i++) fac[i]=fac[i-1]*i%mod;
	cin>>n>>m>>k;
	for(int i=0,u,v;i<m;i++)
	{
		cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u);
		edges[i]={u,v};
	}
	DCC();
	//for(int i=1;i<=n;i++) dbg(i,bel[i]);
	ll ans=1;
	for(int i=1;i<=scc;i++)
	{
		//dbg(nG[i]);
		int tp=solve(i);
		if(tp==1)
		{
			ll tmp=0;
			for(int j=0;j<cnt[i];j++)
			{
				int g=__gcd(j,cnt[i]);
				tmp=(quick(k,g)+tmp)%mod;
			}
			tmp=tmp*inv(cnt[i])%mod;
			ans=(ans*tmp)%mod;
		}
		else{
			ans=ans*C(cnt[i]+k-1,k-1)%mod;
		}
		//dbg(ans);
	}
	cout<<ans<<endl;
}


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

using namespace std;

#define debug(x) cout << #x << "==" << x << endl;
const int INF = 1e+9 + 7;
typedef long long ll;

//入力
#define MAX_N 10000
#define MAX_K 10000
int N, K;

int memo[MAX_N+1];
bool checked[MAX_N+1];


int rec(int n) {

  if(n == 1) { return K; }

  if(checked[n]) { return memo[n]; }
  checked[n] = true;

  return memo[n] = rec(n - 1) * (K - 1);

}


int main() {
  ios::sync_with_stdio(false);

  cin >> N >> K;

  cout << rec(N) << "\n";

  return 0;
}


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

int main() {

    int n,i,x;
    cin >> n;
    
    for(i = 1; i <= n; i++){
        int x=i;
        if(i % 3 == 0){
            cout << " " << i;
            continue;
        }
        while(x){
            if(x%10==3){
	            cout << " " << i;
	            break;
            }
            x/=10;
        }
    }
    cout << endl;
}


Measured memory_bytes: 3092
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char const *argv[])
{
    char buf[4*6+1];int n, a, b, c, d;
    if(fgets(buf, 4 * 6, stdin)!=NULL){
    //fputs(buf, stdout);
    
    n = atoi(strtok(buf, " "));
    a = atoi(strtok(NULL, " "));
    b = atoi(strtok(NULL, " "));
    c = atoi(strtok(NULL, " "));
    d = atoi(strtok(NULL, " "));
    }else{
        printf("baya\n");exit(1);
    }
    int x_min, y_min;
    x_min = (n % a > 0)? (n/a + 1) * b: (n/a * b);
    y_min = (n % c > 0)? (n/c + 1) * d: (n/c * d);
    printf("%d\n", x_min > y_min ? y_min:x_min);
    return 0;
}



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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  vector<int> ans(n);
  rep(i, n) ans[i] = 1;
  rep(i, m) {
    int u, v;
    cin >> u >> v;
    --u; --v;
    if(h[u] < h[v]) ans[u] = 0;
    else if (h[u] > h[v]) ans[v] = 0;
    else {
      ans[u] = 0;
      ans[v] = 0;
    }
  }
  int count = 0;
  rep(i, n) {
    if(ans[i] == 1) ++count;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = 100000000000;
const long long int Mod = 1000000007;
using ll = long long int; //long long int は64bit
using vi = vector<int>; using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(long long int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
typedef pair<ll,ll> Pair;
bool p_compare(const Pair& firstP, const Pair& secondP){ 
    if(firstP.first==secondP.first)return firstP.second < secondP.second;
    else return firstP.first < secondP.first; 
}//sort(all(v),p_compare)で昇順ソート
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////
//Snipet -> Caps Lock

ll n;
vector<Pair> v,vb;

bool pcomp(const Pair& fst,const Pair& sec){
    return !p_compare(fst,sec);
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n;ll aaa,bbb;
    rep(i,n){
        cin>>aaa>>bbb;
        v.pb(mp(aaa,bbb));
    }//input
    rep(i,n){
        cin>>aaa>>bbb;
        vb.pb(mp(aaa,bbb));
    }//input
    sort(all(v),pcomp);
    sort(all(vb),p_compare);
    ll ans = 0;
    ll tmp = 0;
    rep(i,vb.size()){
        tmp = -1;
        rep(j,v.size()){
            if(vb[i].first>v[j].first && vb[i].second > v[j].second){
                if(tmp>=0){
                    if(v[tmp].second<v[j].second)tmp = j;
                }else{
                    tmp = j;
                }
            }
        }
        if(tmp!=-1){
            ans++;
            vb.erase(vb.begin()+i);
            v.erase(v.begin()+tmp);
            i--;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N,K,S = map(int,input().split())
ans = [0 for i in range(N)]
for i in range(N):
	if i < K:
		ans[i] = S
	else:
		if S == 10**9:
			ans[i] = S-1
		else:
			ans[i] = S+1
print(" ".join(list(map(str, ans))))

Measured memory_bytes: 15128
n = int(input())
if n <= 111:
    print(111)
elif n <= 222:
    print(222)
elif n <= 333:
    print(333)
elif n <= 444:
    print(444)
elif n <= 555:
    print(555)
elif n <= 666:
    print(666)
elif n <= 777:
    print(777)
elif n <= 888:
    print(888)
elif n <= 999:
    print(999)
else:
    print(1111)

Measured memory_bytes: 3060
//I read the news today, oh boy
//About a lucky man who made the grade
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) int((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(int i = int(a); i < int(b); ++i)
#define roF(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int N=2e5+5;

ll k;
ll A[N], B[N];
int n;

bool check(ll x){
	ll acum=0;
	For(i,0,n){
		if((A[i]*B[i])>x){
			acum += (A[i]*B[i]-x)/B[i];
			if((A[i]*B[i]-x)%B[i]>0) acum++;	
		}
	}
	return acum<=k;
}

int main(){
	fastio;
	cin>>n>>k;
	For(i,0,n) cin>>A[i];
	For(i,0,n) cin>>B[i];
	sort(A,A+n);
	sort(B,B+n);
	reverse(B,B+n);
	ll lo=-1, hi=1e12+5;
	while(lo+1!=hi){
		ll mid = (lo+hi)>>1;
		if(check(mid)) hi=mid;
		else lo=mid;
	}
	cout<<hi<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;
int main()
{
	vector<int> vec;
#if 1
	int n;
	cin >> n;
	vec.resize(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> vec[i];
	}
#else
	/*
	vec.push_back(27);
	vec.push_back(23);
	vec.push_back(2);
	vec.push_back(76);
	vec.push_back(3);
	vec.push_back(5);
	vec.push_back(62);
	vec.push_back(52);
	*/
	vec.push_back(2);
	vec.push_back(3);
	vec.push_back(1);
#endif

	int sum = std::accumulate(vec.begin(), vec.end(), 0);
	int sumHalf = sum / 2;
	int s = 0;
	int s2 = 0;
	
	bool bAnsed = false;
	for (int i = 0; i < vec.size()-1; ++ i )
	{
		s += vec[i];
		if (s >= sumHalf)
		{
			int ansA = abs(s - (sum-s));
			int ansB = abs(s2 - (sum - s2));
			int ans = min(ansA, ansB);
			cout << ans << endl;
			bAnsed = true;
			break;
		}
		s2 += vec[i];
	}

	if (!bAnsed)
	{
		int ans = abs(vec[vec.size() - 1] - (sum - vec[vec.size() - 1]));
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll n, m;
  cin >> n >> m;
  
  vector<string> a(n);
  vector<string> b(m);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  for (int j = 0; j < m; j++){
    cin >> b[j];
  }

  bool ok = 0;
  for (int i = 0; i <= n - m; i++){
    for (int j = 0; j <= n - m; j++){
      ok = 1;
      for (int k = 0; k < m; k++){
        for (int l = 0; l < m; l++){
          if (a[i + k][j + l] != b[k][l])
            ok = 0;
        }
      }
      if (ok)
        break;
    }
    if (ok)
      break;
  }

  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;



  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
char in[1100000];

int main(){
	int a;scanf("%d",&a);
	if(a<=999)printf("ABC\n");
	else printf("ABD\n");
}

Measured memory_bytes: 128
import math

def is_prime(n):
    return 1 if n==2 or all([n%i != 0 for i in range(2, math.ceil(math.sqrt(n))+1)]) else 0

x = int(input())
while(1):
    if is_prime(x):
        print(x)
        break
    x += 1

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b, ans;
    cin >> a>>b;
    if(b==1)
    {
        cout << '0'<<endl;
    }
    else
    {
    int count = 0, c=0;
    while(count<b)
    {
        count+=a;
        if(count<b)
        {
        count--;
        }
        c++;
    }
    cout << c <<endl;
    }
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    int arr[n];
    int dp[n]; 
    for(auto i = 0; i < n; ++i){
        int x;
        cin >> x;
        arr[i] = x;
    }
    dp[0] = 0; 
    dp[1] = abs(arr[1] - arr[0]); 
    for(auto i = 2; i < n; ++i){
        dp[i] = min(dp[i-1] + abs(arr[i] - arr[i-1]), dp[i-2] + abs(arr[i] - arr[i-2]));
    }
    
    cout << dp[n-1] << endl;


}


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

int main(int argc,char* argv[]){
  long long int shine[4000];
  char shine_check[4000];

  for(;;){
    int n,i;
    int count = 0;
    scanf("%d",&n);
    if(n == 0){break;}
    
    memset(shine,0,sizeof(shine));
    memset(shine_check,0,sizeof(shine_check));

    for(i = 0;i < n; i++){
      int s,tan,num;
      scanf("%d %d %d",&s,&tan,&num);
      shine[s-1] += (long long int)(tan) * num;
      if(shine[s-1] >= 1000000 && shine_check[s-1] == 0){
	printf("%d\n",s);
	count++;
	shine_check[s-1] = 1;
      }
    }

    if(count == 0){
      printf("NA\n");
    }

  }
  
  return 0;
  
}

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

int main(void)
{
	int n,i;
	scanf("%d",&n);
	int s[n],c[n];
	for(i=0;i<=n-1;i++)
		{
		scanf("%d",&s[i]);
		c[i]=0;
		}
			
	int btn=1,count=0;
	while(btn!=2)
		{
		if(c[btn-1]==1){count=-1;break;}
		c[btn-1]++;
		btn=s[btn-1];
		count++;
		}
	printf("%d",count);
	


	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int N,M;
  cin>>N>>M;
  vector<int> A(N);
  rep(i,N) cin>>A[i];

  sort(A.rbegin(),A.rend());

  int sum=0;
  rep(i,N) sum+=A[i];

  if(A[M-1]*4*M>=sum) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
  sl := getall()
  in := toi(sl[0])
  A,B,T := in[0],in[1],in[2]
  ans := T/A * B
  pp(ans)
}

// すべての行を読み込み、スライス文字列として返す
func getall() []string {
  var s string
  scanner := bufio.NewScanner(os.Stdin)
  for scanner.Scan() {
    s = s + scanner.Text() + "\n"
  }
  return strings.Split(s,"\n")
}
// 標準出力
func pp(s ...interface{}) {
  fmt.Println(s...)
}
// 空白区切りの文字列をすべて数値に変換してスライスとして返す
func toi(s string) []int {
  nums := []int{}
  sl := strings.Split(s," ")
  for _,v := range sl {
    nums = append(nums,i(v))
  }
  return nums
}
// 文字を数値に変換して返す
func i(s string) int {
  num,_ := strconv.Atoi(s)
  return num
}
// 空白区切りの文字列をスライスとして返す
func tos(s string) []string {
  sl := strings.Split(s," ")
  return sl
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>

using namespace std;


int main() {
    int w, h;

    while (1) {
        cin >> h >> w;
        if (!w && !h) {
            break;
        }
        stringstream ss1, ss2;
        bool b = true;
        while (w) {
            ss1 << (b ? '#' : '.');
            ss2 << (b ? '.' : '#');
            --w;
            b = !b;
        }
        string str1 = ss1.str(), str2 = ss2.str();
        b = true;
        while (h) {
            cout << (b ? str1 : str2) << endl;
            --h;
            b = !b;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1220
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int N;

int main() {
  cin >> N;

  int i = 1;
  while (i * i <= N)
    i++;

  cout << (i - 1) * (i - 1) << endl;

  return 0;
}


Measured memory_bytes: 3572
import java.util.Scanner;
 
class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
     
    int n,s;
    boolean is;
     
    while(sc.hasNextInt()){
        n = sc.nextInt();
        if(n == 0)break;
        s = 0;
         
        for(int i = 2; n != 0; i++){
            is = true;
             
            for(int j = 2; j <= Math.sqrt(i); j++)
                if(i % j == 0){
                	is = false;
                	break;
                }
             
            if(is){
                n--;
                s += i;
            }
        }
        System.out.println(s);
    }
    sc.close();
  }
}

Measured memory_bytes: 18968
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const ll mod = 998244353;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
int n;
void dfs(string s,char c){
	if(s.size() == n){
		cout << s << endl;
		return;
	}
	for(char i = 'a';i <= c;i++)
		dfs(s + i,i == c?(char)(c + 1):c);
}
int main(){
// 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
    dfs("",'a');
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define EM 100000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
using vint = vector<int>;
using vLL = vector<LL>;

int main(){
    LL n, m;
    cin >> n >> m;
    vector<LL> x(n), y(m);
    for(int i = 0; i < n;i++)   cin >> x[i];
    for(int i = 0; i < m;i++)   cin >> y[i];
    LL mod = 1e9+7;
    LL ans1 = 0;
    for(int i = 0;i < n;i++){
        ans1 += i*x[i]-(n-i-1)*x[i];
        ans1 %= mod;
    }
    LL ans2 = 0;
    for(int i = 0;i < m;i++){
        ans2 += i*y[i]-(m-i-1)*y[i];
        ans2 %= mod;
    }
    LL ans = ans1*ans2%mod;
    cout << ans << endl;
}

Measured memory_bytes: 1792
N = int(input())
XY = [[] for _ in range(N)]

for i in range(N):
    A = int(input())
    for _ in range(A):
        x, y = map(int, input().split())
        XY[i].append((x-1, y))

ans = 0

for i in range(1, 2**N):
    flag = 0
    for j in range(N):
        if (i>>j)&1 == 1:
            for x, y in XY[j]:
                if (i>>x)&1 != y:
                    flag = 1
                    break
    if flag == 0:
        ans = max(ans, bin(i)[2:].count('1'))

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int A[100001];
    cin>>n;
    for(int i=0;i<n;i++) cin>>A[i];
    int dp[100001];
    dp[0]=0;
    dp[1]=abs(A[0]-A[1]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(A[i]-A[i-1]),dp[i-2]+abs(A[i]-A[i-2]));
    }
    cout<<dp[n-1]<<endl;
    
    return 0;
    
}


Measured memory_bytes: 1024
import sys
import numpy as np
import math
from collections import deque 
from functools import reduce
import collections

# input = sys.stdin.readline

n = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
prime_list = prime_factorize(n) 
c = collections.Counter(prime_list)
total = 0
for prime, cnt in c.items():
    i = 1
    while True:
        if cnt - i >= 0:
            total += 1
            cnt -= i
            i += 1
        else :
            break
print(total)

Measured memory_bytes: 27180
import sys
readline = sys.stdin.readline

# 常に金額で持ち、明日のほうが上がるときのみ、必ず買って売るを繰り返す

N = int(readline())
A = list(map(int,readline().split()))

money = 1000
for i in range(N - 1):
  if A[i] < A[i + 1]:
    kabu = money // A[i]
    money %= A[i]
    money += kabu * A[i + 1]
    
print(money)

Measured memory_bytes: 8936
#include <stdio.h>

int main(void) {
  int a, b, c, count1, count2;
  while (scanf("%d,%d,%d", &a, &b, &c) != EOF) {
    if (a * a + b * b == c * c) count1++;
    if (a == b) count2++;
  }
  printf("%d\n", count1);
  printf("%d\n", count2);

  return 0;
}

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

#define ll long long

ll arr[1005][1005] = {};

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	
	string in[2000];
	for(int i = 0; i < n; i++) {
		cin >> in[i];
	}
	
	arr[0][1] = 1;
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			if(in[i-1][j-1] == '.') {
				arr[i][j] = arr[i-1][j] + arr[i][j-1];
				arr[i][j] %= 1000000007;
			}
		}
	}
	
	printf("%lld\n", arr[n][m]);
}

Measured memory_bytes: 9216
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.util.Set;
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
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        int A;
        int B;
        int C;
        int D;
        int E;
        int F;

        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            A = in.Int();
            B = in.Int();
            C = in.Int();
            D = in.Int();
            E = in.Int();
            F = in.Int();

            Set<Integer> water = new HashSet<>();
            Set<Integer> sugar = new HashSet<>();
            for (int i = 0; i <= 30; i++) {
                for (int j = 0; j <= 30; j++) {
                    int w = A * i + B * j;
                    if (w <= F) {
                        water.add(w);
                    }
                }
            }
            int m = E * F / 100 + 1;
            for (int i = 0; i <= m; i++) {
                for (int j = 0; j <= m; j++) {
                    int s = C * i + D * j;
                    if (s <= m) {
                        sugar.add(s);
                    }
                }
            }


            int[] ans = new int[2];
            double p = -1;
            for (int w : water) {
                for (int s : sugar) {
                    if (w * 100 + s <= F && s <= w * E) {
                        double tmp = 100.0 * s / (w * 100.0 + s);
                        if (p - tmp < 0) {
                            p = tmp;
                            ans[0] = w * 100 + s;
                            ans[1] = s;
                        }
                    }
                }
            }
            out.println(ans[0] + " " + ans[1]);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 41540
from math import floor, ceil

inp = input()
A, B = [int(x) for x in inp.split(" ")]

min1 = ceil(A / 0.08)
max1 = floor((A+0.999) / 0.08)
min2 = ceil(B / 0.1)
max2 = floor((B+0.999) / 0.1)

if min1 >= min2 and min1 <= max2:
    print(min1)
elif min2 >= min1 and min2 <= max1:
    print(min2)
else:
    print(-1)


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

int main() {
  int N;
  cin >> N;
  
  vector<int> T(N);
  for(int i=0;i<N;i++)
  {
    cin >> T.at(i);
  }
  
  int M;
  cin >> M;
  
  vector<int> P(M),X(M);
  for(int i=0;i<M;i++)
  {
    cin >> P.at(i) >> X.at(i);
  }
  
  int sum=0;
  
  for(int i=0;i<N;i++)
  {
      sum += T.at(i);
  }
  
  for(int i=0;i<M;i++)
  {
      cout << sum-T.at(P.at(i)-1)+X.at(i) <<endl;
  }
    

  
}


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

int main(){
  long long x,y;
  cin>>x>>y;
  vector<long long>z((y-x+1)%2019);
  if(y-x+1<673){
  if(y-x+1>=3){
  for(long long i=0;i<(y-x+1)%2019;i++){
  if((x+i)%673==0){
  cout<<0<<endl;
  return 0;
  }
  z.at(i)=(x+i)%2019;
  }
  vector<long long>t;
  for(long long j=z.at(0);j<=z.at((y-x+1)%2019-2);j++){
  for(long long k=j+1;k<=z.at((y-x+1)%2019-1);k++){
  t.push_back(j*k%2019);
  }
  }
  sort(t.begin(),t.end());
  cout<<t.at(0)<<endl;
  }
  else{
  cout<<(y*x)%2019<<endl;
  }
  }
  else{
  cout<<0<<endl;
  }
}


Measured memory_bytes: 1404
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int N;
	string S;

	cin>>N>>S;

	vint a(26, 0);

	for (int i = 0; i < N; i++) {
		a[S[i] - 'a']++;
	}

	int ans = 1;

	for (int i = 0; i < 26; i++) {
		ans *= a[i] + 1;
		ans %= MOD;
	}

	cout << ans - 1 << endl;

	return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    long[] a = new long[n+1];
    for(int i=0;i<n;i++)a[i]=sc.nextLong();
    long[] s = new long[n+1];
    long ans = 0;
    Map<Long,Long> map = new HashMap<Long,Long>();
    for(int i=0;i<n;i++)s[i+1]=(s[i]+a[i]-1)%k;
    int j=0;
    for(int i=0;i<=n;i++){
      if(i-j==k){
        map.put(s[j],map.get(s[j])-1);
        j++;
      }
      if(map.containsKey(s[i])){
        ans+=map.get(s[i]);
        map.put(s[i],map.get(s[i])+1);
      }else{
        map.put(s[i],1L);
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 95424
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        M: usize,
        A: [[usize]; N],
    }
    let mut cnt = vec![0; M];
    for i in 0..N{
        for a in A[i].iter(){
            cnt[a-1] += 1;
        }
    }
    let mut ans = 0;
    for i in 0..M{
        if cnt[i]==N{
            ans += 1;
        }
    }
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
int judge(int ,int ,int );
int judge(int a,int b,int c)
{
    if(b-a==c-b)
    {
        return 1;
    }
    return 0;
}
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    printf((judge(a,b,c)==1)?"YES\n":"NO\n");
    return 0;
}

Measured memory_bytes: 128
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto nx = readln.split.to!(int[]);
    auto N = nx[0];
    auto x = nx[1];
    if (x == 1 || x == N*2-1) {
        writeln("No");
        return;
    }
    writeln("Yes");

    if (N == 2) {
        writeln("1\n2\n3");
        return;
    }

    auto res = new int[](N*2-1);
    auto fs = new bool[](N*2);
    res[N-1] = x;
    fs[x] = true;
    res[N-2] = x-1;
    fs[x-1] = true;
    res[N] = x+1;
    fs[x+1] = true;
    if (x == 2) {
        res[N-3] = x+2;
        fs[x+2] = true;
    } else {
        res[N+1] = x-2;
        fs[x-2] = true;
    }
    int n = 1;
    foreach (ref r; res) if (r == 0) {
        while (fs[n]) ++n;
        r = n++;
    }
    foreach (ref r; res) writeln(r);
}

Measured memory_bytes: 3592
s=input()

if s=="SUN":
    print("7")
elif s=="MON":
    print("6")
elif s=="TUE":
    print("5")
elif s=="WED":
    print("4")
elif s=="THU":
    print("3")
elif s=="FRI":
    print("2")
elif s=="SAT":
    print("1")
else:
    print()


Measured memory_bytes: 2940
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

#[allow(unused_macros)]
macro_rules! echo {
    ($($e:expr),+) => ( { $(println!("{}", $e))+ } );
}

fn main() {
    input! {
        n: usize,
        m: usize,
        ms: [(Usize1, Usize1); m],
    }

    let mut gs = vec![vec![]; n];
    let mut results = vec![(0, 0); n];

    for e in ms {
        gs[e.0].push(e.1);
        gs[e.1].push(e.0);
    }

    let mut dp = vec![std::u64::MAX; n];
    let mut bh = std::collections::BinaryHeap::new();
    dp[0] = 0;
    bh.push(std::cmp::Reverse((0, 0)));

    while let Some(tup) = bh.pop() {
        let std::cmp::Reverse((cost, node)) = tup;
        if dp[node] < cost {
            continue;
        }

        let cost = cost + 1;
        for &g in &gs[node] {
            if dp[g] > cost {
                dp[g] = cost;
                bh.push(std::cmp::Reverse((cost, g)));
                results[g] = (node + 1, cost); // 出力する node 番号は 1-index
            }
        }
    }

    for (i, (node, cost)) in results.iter().enumerate() {
        if i == 0 {
            continue;
        }
        if *node == 0 {
            echo!("No");
            return;
        }

        if results[node - 1].1 != cost - 1 {
            echo!("No");
            return;
        }
    }

    echo!("Yes");
    for (i, e) in results.iter().enumerate() {
        if i == 0 {
            continue;
        }
        echo!(e.0);
    }
}


Measured memory_bytes: 17656
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,a,b;
  cin>>n>>a>>b;
  if(a==b)
  {
    if(abs(a/n)>0)
      cout<<"OK\n";
    else
      cout<<"NG\n";
  }
   else
   {
   	if(abs((a/n)-(b/n))<=0 and a%n!=0 and b%n!=0)
      cout<<"NG\n";
      else
        cout<<"OK\n";
   }
 return 0; 
}

Measured memory_bytes: 3616
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >


int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
void solve(){
    int h,a;
    cin>>h>>a;
    cout<<((h+a-1)/a)<<endl;
}

signed main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("data.in","r",stdin);
        freopen ("data.out","w",stdout);
    #endif*/
    int t;
    t=1;
    while(t--){
        solve();
    }

     return 0;

}
///Alhamdulillah




Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main(){
	char s[11]; scanf("%s",s);
	int l=strlen(s);
	int a[11],i,j,c=(1<<(l-1));
	long long num,t;
  
	for(i=0;i<l;i++)a[i]=s[i]-'0';
	num=0;
	for(i=0;i<c;i++){
		t=a[0];
		for(j=0;j<l;j++){
			if(j==l-1||i&1<<j){
				num+=t;t=0;if(j==l-1)break;
			}
			t*=10;
			t+=a[j+1];
		}
	}
	printf("%lld",num);
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
using namespace std;

int num[100001];
/*--- クイックソート ---*/
void quick(int sum[], int left, int right){
    int pl = left;                /* 左カーソル */
    int pr = right;                /* 右カーソル */
    int x = sum[(pl + pr) / 2];    /* 枢軸は中央の要素 */
    do {
        while (sum[pl] < x) pl++;
        while (sum[pr] > x) pr--;
        if (pl <= pr) {
            swap(sum[pl],sum[pr]);
            swap(num[pl],num[pr]);
            pl++;
            pr--;
        }
    } while (pl <= pr);

    if (left < pr)  quick(sum,left, pr);
    if (pl < right) quick(sum,pl, right);
}
int main(void){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	
	long long int takahasi=0,aoki=0;
	int n,i;
	cin>>n;
	int food[n][2],sum[n];
	for(i=0;i<n;i++)num[i]=i;
	for(i=0;i<n;i++)cin>>food[i][0]>>food[i][1];
	for(i=0;i<n;i++)sum[i]=food[i][0]+food[i][1];
	quick(sum,0,n-1);
	for(i=0;i<n;i++){
		if(i%2==0){
			takahasi+=food[num[n-1-i]][0];
		}
		if(i%2==1){
			aoki+=food[num[n-1-i]][1];
		}
	}
	cout<<takahasi-aoki<<endl;
	return 0;
}


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

int main() {
  string s0;
  while(getline(cin, s0) && s0!="END OF INPUT") {
    string s = s0;
    int p = s.find(" ");
    while(p!=-1) {
      cout << p;
      s = s.substr(p+1);
      p = s.find(" ");
    }
    // if (!isalpha(s0[s0.length()-1]))
    //cout << 0<<"'";
    cout << s.length();
    cout << endl;
  }
}

Measured memory_bytes: 0
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

struct unionfind{
  vector<int> par;
  vector<int> rank;
  unionfind(int n=1){
    init(n);
  }
  void init(int n=1){
      par.resize(n); rank.resize(n);
      for(int i=0;i<n;++i) par[i]=i,rank[i]=0;
  }
  int root(int x){
    if(par[x]==x){
      return x;
    }
    else{
      int r=root(par[x]);
      return par[x]=r;
    }
  }
  bool issame(int x,int y){
    return root(x)==root(y);
  }
  bool merge(int x,int y){
    x=root(x); y=root(y);
    if(x==y) return false;
    if(rank[x]<rank[y]) swap(x,y);
    if(rank[x]==rank[y]) ++rank[x];
    par[y]=x;
    return true;
  }
};

struct edge{int u,v,cost;};

bool comp(const edge& e1,const edge& e2){
  return e1.cost<e2.cost;
}

ll kruskal(int n,int m,vector<edge>& es){
  sort(es.begin(),es.end(),comp);
  unionfind uf(n);
  ll res=0;
  rep(i,m){
    if(!uf.issame(es[i].u,es[i].v)){
      uf.merge(es[i].u,es[i].v);
      res+=es[i].cost;
    }
  }
  return res;
}

int main(){
  int n,m; cin >> n >> m;
  vector<edge> es(m);
  rep(i,m){
    int a,b,c;
    cin >> a >> b >> c;
    es[i]={a,b,c};
  }
  cout << kruskal(n,m,es) << endl;
  
}


Measured memory_bytes: 4200
main = do
    --a <- readLn
    [a, b] <- map read . words <$> getLine
    --s <- getLine
    -- putStrLn $ show $ solve a b
    putStrLn $ solve a b

solve :: Int -> Int -> String
solve a b = if even (a + b) then show (round (fromIntegral (a + b) / 2)) else "IMPOSSIBLE"


Measured memory_bytes: 508
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt
  def isPrime(p: Int) = (2 to math.sqrt(p).toInt).forall(p % _ != 0)
  var ans = Array.emptyIntArray

  for (i <- 2 to 55555) {
    if (ans.length == N) {
      println(ans.mkString(" "))
      sys.exit()
    }
    if (isPrime(i) & i % 5 == 1) {
      ans :+= i
    }
  }
}

Measured memory_bytes: 25520
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        String s1 = scan.next();
        String s2 = scan.next();
        String ans;
        if(s1.length() > s2.length()){
            ans = "GREATER";
        }else if(s1.length() < s2.length()){
            ans = "LESS";
        }else{
            ans = (s1.compareTo(s2) > 0)? "GREATER" : (s1.compareTo(s2) == 0)? "EQUAL" : "LESS";
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23252
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		System.out.println(Math.min(N*A, B));
	}
}


Measured memory_bytes: 21716
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  l, r = map(int, input().strip().split())
  x = 2019
  remains = [l%x]
  for i in range(l+1, r+1):
    remain = i % x
    if remains[0] == remain:
      break
    remains.append(remain)
    
  min = x
  for i in range(len(remains)-1):
    for j in range(i+1, len(remains)):
      remain = (remains[i] * remains[j]) % x
      if remain < min:
        min = remain
  print(min)

if __name__=='__main__':
  main()



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

struct UnionFind {
	vector<int> d;
	UnionFind(int n): d(n, -1) {}
	int root(int x) {
		if (d[x] < 0) return x;
		return d[x] = root(d[x]);
	}
	int unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (d[x] > d[y]) swap(x, y);
		d[x] += d[y];
		d[y] = x;
		return true;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int size(int x) { return -d[root(x)]; }
};

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

	UnionFind uf(N);
	REP(i, M) {
		int A, B;
		cin >> A >> B;
		--A; --B;
		uf.unite(A, B);
	}

	int ans = 0;
	REP(i, N) ans = max(ans, uf.size(i));

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

Measured memory_bytes: 3960
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = 1;
		byte[] score = new byte[1000];
		double[] calc = new double[1000];
		double[] result = new double[1000];
		long sum = 0;
		double sum2 = 0.;
		double avg = 0;
		int count = 0;
		while (n > 0){
			n = sc.nextInt();
			sum = 0;
			for (int i = 0; i < score.length; i++) {
				score[i] = 0;
				calc[i] = 0.;
			}
			if(n <= 0){
				break;
			}else{
				for (int i = 0; i < n; i++) {
					score[i] = sc.nextByte();
					sum += score[i];
				}
				avg = (double) sum / (double) n;
				sum2 = 0;
				for (int i = 0; i < n; i++) {
					calc[i] = Math.pow((double)score[i] - avg, 2);
					sum2 += calc[i];
				}
				avg = (double) sum2 / (double) n;
				result[count++] = Math.sqrt(avg);
			}
		}
		for (int i = 0; i < count; i++) {
			System.out.printf("%.16f\n", result[i]);
		}
	}
}



Measured memory_bytes: 32464
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func calcGcd(l, r int) int {
	if r > l {
		r, l = l, r
	}

	d := l % r
	for d != 0 {
		l = r
		r = d
		d = l % r
	}
	return r
}

func calcMinForNumberOfSweets(l, r int) int {
	gcd := calcGcd(l, r)
	ld := l / gcd
	rd := r / gcd
	return gcd * ld * rd
}

func main() {
	a, b := nextInt(), nextInt()
	r := calcMinForNumberOfSweets(a, b)
	fmt.Println(r)
}


Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector> 
using namespace std;
int main(){
	int n,t;
	scanf("%d%d",&n,&t);
	if(t>=n) printf("0\n");
	else printf("%d\n",n-t);
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

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

    REP(i, N)
    {
        char s;
        cin >> s;
        if (i == K - 1)
            s = s + 0x20;
        cout << s;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main(){
 long long x,y,n,d,ans;
 cin >> n >> d;
 ans =0;
 for(int i=0;i<n;i++){
  cin >> x >> y;
  if(d*d>=x*x+y*y){ans++;}
 }
 cout<<ans<<endl;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int count = 0;
    REP(i,S.size()){
        if(S.at(i)=='o')count++;
    }
    if(15-S.size()+count>=8){
        cout <<"YES"<< "\n";
    }else{
        cout <<"NO"<< "\n";
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var A = input[1];
            var B = input[2];

            Console.WriteLine(N * A < B ? N * A : B);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

const int MOD = 1e9 + 7;

signed main() {
    int n; cin >> n;
    int ans = 1;
    rep(i,n) ans = (ans * (i+1)) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 256
function Main(input) {
    var input = input.split('');
    YAKI = input[0] + input[1] + input[2] + input[3];
    if(YAKI === 'YAKI') {
        console.log('Yes');
    } else {
        console.log('No');
    }
    

    }
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372