akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <complex>
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    ll p = 0;
    rep(i,n) p += x[i];
    p = (double)p / n + 0.5;
    ll ans = 0;
    rep(i,n){
        ans += (x[i]-p)*(x[i]-p);
    }
    cout << ans << endl;
    
    return 0;
}


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

#define mp(x, y) make_pair((x), (y))

typedef long long ll;

int n;
vector<int> nex[100005];
int par[100005];
int sz[100005];
int middle;

void dfs(int v, int f=-1, int l=0) {
	par[v]=f;
	sz[v]=1;
	if(v==n-1) {
		middle=v;
		for(int x=0; x<(l-1)/2; x++) middle=par[middle];
	}
	for(int i=0; i<nex[v].size(); i++) {
		int s=nex[v][i];
		if(s==f) continue;
		dfs(s, v, l+1);
		sz[v]+=sz[s];
	}
}

int main()
{
	scanf("%d", &n);
	for(int i=0; i<n-1; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		u--; v--;
		nex[u].push_back(v);
		nex[v].push_back(u);
	}
	dfs(0);
	int snuke=sz[middle];
	int fennec=n-sz[middle];
	if(snuke>=fennec) printf("Snuke\n");
	else printf("Fennec\n");

	return 0;
}

Measured memory_bytes: 14336
n=int(input())
h=list(map(int,input().split()))
if n==1:
  print("Yes")
else:
  l=0
  s="Yes"
  for i in range(n):
    if h[i]>=l:
      l=h[i]
    if l-h[i]>=2:
      s="No"
      break
  print(s)

Measured memory_bytes: 14224
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();
		long[] arrayInfo = new long[100000 + 1];
		for(int i =0; i < n; i++) {
			int a = sc.nextInt();
			long b = sc.nextLong();
			arrayInfo[a] += b;
		}
		for(int i = 1; i <= 100000;i++) {
			k -= arrayInfo[i];
			if(k <= 0) {
				System.out.println(i);
				return;
			}
		}
	}
}

Measured memory_bytes: 60328
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    
    int cnt = 0;
    for(int i=A; i<=B; i++){
      boolean b = true;
      String temp = String.valueOf(i);
      for(int j=0; j<temp.length()/2; j++){
        if(temp.charAt(j)!=temp.charAt(temp.length()-j-1)){
          b = false;
        }
      }
      if(b){
        cnt++;
      }
    }
    System.out.println(cnt);
  }
}
      
    
    

Measured memory_bytes: 41240
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
typedef pair<double,double>d_d;
#define inf 100000000//10^8

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




int main(){
    long long int x,y;cin>>x>>y;
    printf("%lld",(ll)log2l(y/x)+1);
    return 0;
}










Measured memory_bytes: 512
A = []

A = list(map(int, input().split()))
AA = A[0] * A[1]

if AA % 2 != 0:
    b = AA * 2
    c = AA * 3
    if b % 2 != 0 or c % 2 != 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define pb push_back
#define xx first
#define yy second
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,k,n) for(int i=k;i<n;i++)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> iv;
typedef pair<int,int> iip;
typedef map<int,int> mii;
template <typename T>
void dbg(T t){cerr<<t<<endl ;}
template<typename T, typename... Args>
void dbg(T t, Args... args) {cerr << t <<" ";dbg(args...) ;}

int verr =1;
int horr =2;
int main(){
	//ios::sync_with_stdio(0);cin.tie(0);
	int n,i,prev;
	cin>>n;
	string a,b;
	cin>>a>>b;
	ll ans;
	if(n==1){cout<<3<<endl;return 0;}
	if(a[0]==a[1]){
		ans=6;i=2;
		prev=horr;
	}
	else{
		ans=3;i=1;
		prev=verr;
	}
	for(;i<n;i++){
		if(i+1<n && a[i]==a[i+1]){
			i++;
			if(prev==horr)
			ans = (ans*3)%MOD;
			else  ans = (ans*2)%MOD;
			prev = horr;
		}
		else {
			if(prev == verr){
				ans = (ans*2)%MOD;
			}
			prev = verr	;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

bool war(const vector<int>& x,vector<int>& y){
  for(int Z = -100;Z <= 100;Z++){
    bool is_ok = true;
    for(int i=0;i<x.size();i++){
      if(x[i] >= Z)is_ok = false;
    }
    for(int i=0;i<y.size();i++){
      if(y[i] < Z)is_ok = false;
    }
    if(is_ok) return false;
  }
  return true;
}
int main(){
  int N,M;
  cin >> N >> M;
  vector<int> x(N+1),y(M+1);
  cin >> x[0] >> y[0];
  for(int i=0;i<N ;++i){
    cin >> x[i+1];
  }
  for(int i=0;i<M;++i){
    cin >> y[i+1];
  }
  if(war(x,y)){
    cout << "War" << endl;
  }
  else cout << "No War" << endl;
}

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

using namespace std;


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

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

ll paty(ll l){
    return pow(2, l+1)-1;
}
ll layer(ll l){
    return pow(2, l+2)-3;
}


ll f(ll n, ll x){

    if(n == 0){
        return x<=0 ? 0 : 1;
    }
    else if(x <= 1+layer(n-1)){
        return f(n-1, x-1);
    }
    else{
        return paty(n-1) + 1 + f(n-1, x-2-layer(n-1));
    }
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, x;
    cin >> n >> x;


    ppp(f(n, x));




    return 0;
}


Measured memory_bytes: 384
package main

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

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	// sc.Split(bufio.ScanWords)
	// n, a, b := nextInt(), nextInt(), nextInt()
	// s := nextMega()
	var n, a, b int
	var s string
	fmt.Scan(&n, &a, &b, &s)
	rank := 0
	sum := 0
	for i := 0; i < n; i++ {
		ok := false
		if s[i] == 'a' && sum < a+b {
			sum++
			ok = true
		} else if s[i] == 'b' {
			rank++
			if sum < a+b && rank <= b {
				ok = true
				sum++
			}
		}
		if ok {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll A,B,C,K; cin >> A >> B >> C >> K;
    res = (max({A,B,C})<<K) + A + B + C - max({A,B,C});
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

int main(void)
{
    int n;
    cin >> n;

    int ans = 0;
    
    for(int i = 1; i <= n; i += 2)
    {   int cnt = 0;
        for(int j = 1; j*j <= i;j++){
            if(i%j == 0) cnt++;
        }
        if(2*cnt == 8) ans++;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  int cnt[1111]={};
  cin>>n;
  for(int i=1;i<=n;i++){
    int t=i;
    for(int j=2;j<=t;j++){
      // cout<<i<<" "<<j<<endl;
      if(t%j)continue;
      while(t%j==0){
	t/=j;
	cnt[j]++;
      }
    }
   
  }
  int ans=1;
  for(int i=2;i<=n;i++){
    //cout<<cnt[i]<<endl;
    if(cnt[i]<=0)continue;
    ans*=(cnt[i]+1);
    ans%=1000000007;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main()
{
  int n;
  cin >> n;
  
  int a[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  int x[1000000] = {0};
  for(int i = 0; i < n; i++){
    x[a[i]-1]++;
    x[a[i]]++;
    x[a[i]+1]++;
  }
  
  int maxans = 0;
  for(int i = 0; i < 1000000; i++){
    if(x[i] > maxans){
      maxans = x[i];
    }
  }
  
  cout << maxans << endl;
}

Measured memory_bytes: 7812
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

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

	int N; cin >> N;
	vector<int> V;
	for (int i = 0; i < N; i++) {
		int tmp; cin >> tmp;
		V.push_back(tmp);
	}
	sort(V.begin(), V.end());
	bool flag = true;
	for (int i = 0; i < N - 1 && flag; i++) {
		if (V[i] == V[i + 1]) flag = false;
	}
	if (flag) cout << "YES" << endl;
	else cout << "NO" << endl;


	return 0;
}

Measured memory_bytes: 1400
S = input()

ans = [0] * (len(S) + 1)


prev = ""
for i in range(len(S)):
    # print(S[i])
    if S[i] == "<":
        ans[i + 1] = ans[i] + 1
        prev = "<"

    # print(ans)
ans.reverse()
for i in range(len(S)):
    # if S[len(S) - 1 - i] == ">":
    #     print("<")
    # else:
    #     print(">")
    if S[len(S)-1-i] == ">" and not ans[i] < ans[i+1]:
        ans[i + 1] = ans[i] + 1
        prev = ">"
    # print(ans)
# print()
print(sum(ans))


Measured memory_bytes: 23348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define be(v) (v).begin(), (v).end()

int main() {
	string s,t; cin >> s >> t;
	int len=t.size();
	int dif=1001;
	if(s.size()==len) {
		int count = 0;
		rep(i,len){
			if(s[i]!=t[i]) count ++;
		}
		dif=min(dif,count);
		cout << dif << endl;
		return 0;
	}
	rep(i,s.size()-len) {
		string ss=s.substr(i,i+len);
		int count  = 0;
		rep(j,len) {
			if(ss[j]!=t[j]) count ++;
		}
		dif=min(dif,count);
	}
	cout << dif << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e10;
using Graph = vector<vector<int>>;

signed main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for( int i = 0; i < N; i++ ) cin >> A[i];

  int kabu = 0;
  int kane = 1000;
  for( int i = 0; i < N-1; i++ ){
    if( i > 0 && A[i] > A[i-1] ){ //前日よりも株が高い場合、売れるだけ売っておく
      kane += kabu*A[i];
      kabu = 0;
    }
    if( A[i] < A[i+1] ){ //翌日よりも株が安い場合、買えるだけ買っておく。
      int buy = kane/A[i];
      kabu += buy;
      kane -= buy*A[i];
    }
  }
  if( kabu > 0 ){
    kane += kabu*A[N-1];
  }
  cout << kane << endl;

}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

const ll MOD=1e9+7;

ll ad(ll x,ll y=0){
  return (x+y)%MOD;
}

ll mlt(ll x,ll y=1){
  return (x*y)%MOD;
}

ll pwr(ll x,ll y){
  ll pw[32]={},w=1;
  pw[0]=x;
  fr(i,31) pw[i+1]=mlt(pw[i],pw[i]);
  fr(i,32){
    w=mlt(w,1+(y%2)*(pw[i]-1));
    y/=2;
  }
  return w;
}

ll inv(ll x){
  return pwr(x,MOD-2);
}

ll fc[200010]={1};
ll fct(ll x){
  if(fc[x]==0) fc[x]=mlt(x,fct(x-1));
  return fc[x];
}

int main(){
  ll n,x,s[210],dp[210][100010];
  cin>>n>>x;
  fr(i,n) cin>>s[i];
  sort(s,s+n);
  reverse(s,s+n);
  fr(j,x+1) dp[n][j]=j;
  ifr(i,n){
    fr(j,x+1){
      dp[i][j]=mlt(inv(n-i),dp[i+1][j%s[i]]);
      dp[i][j]=ad(dp[i][j],mlt(ad(1,MOD-inv(n-i)),dp[i+1][j]));
    }
  }
  cout<<mlt(dp[0][x],fct(n))<<endl;
}

Measured memory_bytes: 158592
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD 1000000007
using namespace std;

long long h,w,ans=0,black,white;
char temp;
int grid[404][404];
int visit[404][404];

void check(int i, int j, int iswhite){
    if(i<0 || h<=i || j<0 || w<=j);
    else if(visit[i][j]==1);
    else  if(grid[i][j]==iswhite){
        if(iswhite)white++;
        else black++;
        visit[i][j]=1;
        check(i,j+1,!iswhite);
        check(i+1,j,!iswhite);
        check(i,j-1,!iswhite);
        check(i-1,j,!iswhite);
    }
}
int main(void){
    cin >> h >> w;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> temp;
            if(temp=='#')grid[i][j]=0;
            else grid[i][j]=1;
        }
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            black=0;white=0;
            check(i,j,0);
            ans+=black*white;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13952
#include <iostream>
#include <set>

using namespace std;

int main(int argc, char* argv[]) {
  long long N;
  cin >> N;

  set<long long> s;
  for (int i = 0; i < N; ++i) {
    long long a;
    cin >> a;
    if (s.find(a) == s.end()) {
      s.insert(a);
    } else {
      s.erase(a);
    }
  }

  cout << s.size() << endl;

  return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <cstring>

using namespace std;

int main(void)
{
    string s;
    int n,l,i;
    cin>>n>>s;
    l=s.size();
    for(i=0;i<l;i++)
    {
        if(s[i]+n>'Z')
            cout<<(char)(s[i]+n-'Z'+'A'-1);
        else
            cout<<(char)(s[i]+n);
    }
    return 0;
}


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

int main(void){
  int A,B,max;
  cin >> A >> B;
  max = A+B;
  if(max < A-B){
    max = A-B;
  }
  if(max < A*B){
    max = A*B;
  }
  cout << max;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

#define LEN(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vpii = vector<pii>;

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

inline int fcmp(double x, double y)
{ return (x < y + EPS ? (x < y - EPS ? -1 : 0) : 1);}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    
    string s; cin >> s;
    if(s.back() == 's') s += "e";
    s += "s";
    cout << s << endl;
    
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define M_PI 3.14159265358979323846
#define MOD 1000000007
#define int ll
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<double, double> pdd; typedef pair<long long, long long> pll; typedef cc_hash_table<int, int, hash<int>> intHashTable;
struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } };
inline int powMod(int a, int b) { int x = 1; while (b > 0) { if (b&1) x = (x*a) % MOD; a = (a*a) % MOD; b >>= 1; } return x; }
inline int multiply(int x, int y) { return ((x % MOD) * (y % MOD)) % MOD; }
inline int divide(int x, int y) { return ((x % MOD) * powMod(y % MOD, MOD-2)) % MOD; }
inline int ceil(int a, int b) { return (a+b-1)/b; }
int gcd (int a, int b) { while (b) { a %= b; swap(a, b); } return a; }
int lcm (int a, int b) { return a / gcd(a, b) * b; }
int inverseMod(int a, int m) { a = a % m; for (ll x = 1; x < m; x++) if ((a * x) % m == 1) return x; return -1; }
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
int str_replace(string& str, const string& from, const string& to, int limit = -1) { if(from.empty()) return 0; size_t start_pos = 0; int cnt = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); cnt++; if (cnt == limit) break; } return cnt; }
template<int D, typename T> struct vec : public vector<vec<D - 1, T>> { static_assert(D >= 1, "Vector dimension must be greater than zero!");  template<typename... Args> vec(int n = 0, Args... args) : vector<vec<D - 1, T>>(n, vec<D - 1, T>(args...)) { } }; template<typename T> struct vec<1, T> : public vector<T> { vec(int n = 0, T val = T()) : vector<T>(n, val) { }};

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    double l; cin >> l;
    double x = l/3;
    cout << setprecision(10) << (x*x*x) << '\n';
    return 0;
}

Measured memory_bytes: 256
w=[]
k=[]

for i in range(10):
    w.append(int(input()))

for i in range(10):
    k.append(int(input()))

w=sorted(w, reverse=True)
k=sorted(k, reverse=True)

tenw=sum(w[:3])
tenk=sum(k[:3])

print(tenw, tenk)


Measured memory_bytes: 5600
package main

import (
  "fmt"
)

func main() {

  var num int
  fmt.Scan(&num)
  arr := make([]int, num)

  max1 := 0
  max2 := 0
  var pos int 
  
  for i := 0; i < num; i++ {
    fmt.Scan(&arr[i])
    if arr[i] > max1 {
      max1 = arr[i]
      pos = i
    } else if arr[i] <= max1 && arr[i] > max2 {
      max2 = arr[i]
    }
  }
  
  for i := 0; i < num; i++ {
    if pos == i {
      fmt.Println(max2)
    } else {
      fmt.Println(max1)
    }
  }
}


Measured memory_bytes: 6400
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	static final int MOD = 1000000007;
	static final int MAX = 200000;

	static BigInteger[] fac = new BigInteger[MAX]; // 1!,2!,...
	static BigInteger[] inv = new BigInteger[MAX]; // (1)^-1,(2)-1,...(逆元)
	static BigInteger[] finv = new BigInteger[MAX]; // (1!)^-1,(2!)-1,...(逆元)
	static BigInteger big_mod = new BigInteger(String.valueOf(MOD));

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int H = scanner.nextInt();
		int W = scanner.nextInt();
		int A = scanner.nextInt();
		int B = scanner.nextInt();

		init_nCr();

		BigInteger ans = new BigInteger(String.valueOf("0"));
		for (int i = 0 ; i < H - A ; i++) {
			ans = ans.add(nCr(B + i - 1, i).multiply(nCr(H - i + W - B - 2, H - i - 1)).mod(big_mod));
			ans = ans.mod(big_mod);
		}
		System.out.println(ans.intValue());

		scanner.close();
	}

	private static void init_nCr() {
		fac[0] = fac[1] = new BigInteger("1");
		inv[1] = new BigInteger("1");
		finv[0] = finv[1] = new BigInteger("1");

		for (int i = 2 ; i < MAX ; i++) {
	        fac[i] = (fac[i - 1].multiply(new BigInteger(String.valueOf(i)))).mod(big_mod);
	        inv[i] = big_mod.subtract(inv[MOD % i]).multiply(new BigInteger(String.valueOf(MOD / i))).mod(big_mod);
	        finv[i] = finv[i - 1].multiply(inv[i]).mod(big_mod);
		}
	}

	private static BigInteger nCr(int n, int r) {
		return fac[n].multiply(finv[r]).mod(big_mod).multiply(finv[n - r]).mod(big_mod);
	}
}


Measured memory_bytes: 203884
import sys
S = input()
N = len(S)
ss = S[:N-1]
if S[-1] == '1' or ss != ss[::-1] or S[0] == '0':
    print(-1)
    sys.exit()
tree = []
cnt = 0
for s in ss:
    if s == '1':
        tree.append(cnt)
        cnt = 0
    else:
        cnt += 1
ans = []
now = 1
for c in tree:
    for i in range(c):
        ans.append((now, now+i+1))
    ans.append((now, now+c+1))
    now = now+c+1
for a, b in ans:
    print(a, b)
        
    






    




Measured memory_bytes: 52528
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
 
#define FOR(i,vv,n) for(ll i=vv;i<n;i++)
#define FORR(i,n,vv) for(ll i=n-1;i>=vv;i--)
#define ve vector 
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007
#define precise cout.precision(18)
// #define f first
// #define s second

ll a[20][20];

ll X[]={1,-1,0,0};
ll Y[]={0,0,1,-1};

bool ok(ll a1,ll a2,ll h,ll w){
if(a1>=0&&a2>=0&&a1<h&&a2<w&&a[a1][a2]==0)
	return true;
return false;
}

int main(){
 
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	//  #endif
    FAST

ll h,w;
cin>>h>>w;
FOR(i,0,h){
string s;
cin>>s;
FOR(j,0,w){
	if(s[j]=='#')
		a[i][j]=1;
}
}
ll ans=0;

FOR(i,0,h){
	FOR(j,0,w){
		if(a[i][j]==0){
			ll vis[h][w];
			memset(vis,0,sizeof(vis));
			ll an[h][w];
			memset(an,0,sizeof(an));
			queue <pair<ll,ll> > q;
			q.push({i,j});
			vis[i][j]=1;
			while(!q.empty()){
				ll m1=q.front().first;
				ll m2=q.front().second;
				q.pop();
				FOR(k,0,4){
					ll t1=m1+X[k];
					ll t2=m2+Y[k];
					if(ok(t1,t2,h,w)&&vis[t1][t2]!=1){
						q.push({t1,t2});
						vis[t1][t2]=1;
						an[t1][t2]=an[m1][m2]+1;
						ans=max(ans,an[t1][t2]);
					}
				}
			}


		}




	}
}
cout<<ans;


return 0;
}
 

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

int main(){
	int a,b,c,x;
	int ans=0;
	scanf("%d%d%d%d",&a,&b,&c,&x);
	for(register int i=0;i<=a;i++){
		for(register int j=0;j<=b;j++){
			for(register int k=0;k<=c;k++){
				if(500*i+100*j+50*k>x)continue;
				if(500*i+100*j+50*k==x){
					ans++;
				}
			}
		}
	}
	printf("%d",ans);
	return 0;
}

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

using namespace std;


int main(){
	int n;
	while(cin >> n){
		vector<pair<int,int>> vp(n);
		for(int i=0;i<n;i++){
			cin >> vp[i].first;
			vp[i].second = i;
		}
		sort(vp.begin(), vp.end());
		int res = 0;
		for(int i=0;i<n;i++){
			if((i+vp[i].second)%2) ++res;
		}
		cout << res/2 << endl;		
	}
}


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

int main() {
	int n, k,array[100], ans=0;
	cin>>n>>k;
	for(int i=1; i<=n; i++) array[i] = 0;
	for(int i=1; i<=k; i++) {
		int t, a;
		cin>>t;
		for(int i=1; i<=t; i++) {
			cin>>a;
			array[a] = 1;
		}
	}
	for(int i=1; i<=n; i++) {
		if(array[i] == 0) ans++;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
   int n,m;
   cin>>n>>m;
   int x[n][3];
   for(int i=0;i<n;i++){
       x[i][0]=0;
       x[i][1]=0;
       x[i][2]=0;
       for(int j=0;j<m;j++){
           char a;
           scanf(" %c",&a);
           if(a=='W'){
               x[i][0]++;
           }else if(a=='B'){
               x[i][1]++;
           }else{
               x[i][2]++;
           }
       }
   }
   
   int ans=2501;
   
   for(int i=0;i<n-2;i++){
       for(int j=i+1;j<n-1;j++){
           int a=0;
           for(int k=0;k<=i;k++){
               a+=x[k][1]+x[k][2];
           }
           for(int k=i+1;k<=j;k++){
               a+=x[k][0]+x[k][2];
           }
           for(int k=j+1;k<n;k++){
               a+=x[k][0]+x[k][1];
           }
           if(a<ans){
               ans=a;
           }
       }
   }
   cout<<ans<<endl;
    
}

Measured memory_bytes: 3248
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

//prototype declaration
int getint();
long long getllint();
double getdint();
char getch();
void setstring(char *s);
void showint(int i);
void showllint(long long i);
void showdouble(double i);
void showchar(char c);
void showstring(char *s);

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int min(int a, int b) {
	return a < b ? a : b;
}

int main(void) {
	int a, b, c, i, j;
	a = getint();
	b = getint();
	c = getint();
	int ans[6];
	ans[0] = a + b;
	ans[1] = a + c;
	ans[2] = b + a;
	ans[3] = b + c;
	ans[4] = c + a;
	ans[5] = c + b;
	int min = ans[0];
	for (i = 0; i < 6; i++) {
		if (ans[i] < min) {
			min = ans[i];
		}
	}
	printf("%d\n", min);
	return 0;
}

int getint() {
	int i;
	scanf("%d", &i);
	return i;
}

long long getllint() {
	long long i;
	scanf("%lld", &i);
	return i;
}

double getdint() {
	double i;
	scanf("%lf", &i);
	return i;
}

char getch() {
	char c;
	scanf("%c", &c);
	return c;
}

void setstring(char *s) {
	scanf("%s", s);
}

void showint(int i) {
	printf("%d\n", i);
}

void showllint(long long i) {
	printf("%lld\n", i);
}

void showdouble(double i) {
	printf("%lf\n", i);
}

void showchar(char c) {
	printf("%c\n", c);
}

void showstring(char *s) {
	printf("%s\n", s);
}


Measured memory_bytes: 128
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
ll f(ll x,ll y){
    if(y==0)return x;
    return f(y,x%y);
}
int main(void){
    cin>>n;
    //cout<<f(90,360)<<endl;
    cout<<n*360/f(n,360)/n<<endl;
}


Measured memory_bytes: 3620
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <cassert>
#include <regex>
#include <random>

#define ll long long
#define ld long double
#define ull unsigned ll
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int> 
#define vi vector<int>
#define vpii vector<pii>
#define vvi vector<vector<int>>
#define forn(it,from,to) for(int (it)=from; (it)<to; (it)++)
const int  Inf = 2 * 1000 * 1000 * 1000;
ll LINF = (ll)4e18;
using namespace std;
#define M_PI       3.14159265358979323846   // pi

const int nax = 3005;

ld D[nax][nax][2];

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("sum.in", "r", stdin);
	//freopen("sum.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vector<vector<ld>>a(n, vector<ld>(2));
	for (int i = 0; i < n; i++) {
		cin >> a[i][0];
		a[i][1] = 1.0 - a[i][0];
	}

	D[0][1][0] = a[0][0];
	D[0][0][1] = a[0][1];

	for (int i = 1; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < 2; k++) {
				D[i][j][0] += D[i - 1][j][k] * a[i][1];
				D[i][j + 1][1] += D[i - 1][j][k] * a[i][0];
			}
		}
	}
	ld ans = 0.0;

	for (int j = (n + 1) / 2; j <= n; j++) ans += D[n - 1][j][0] + D[n - 1][j][1];
	cout << setprecision(10) << fixed << ans;
 	return 0;
}

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

using namespace std;

int n, m;
int l, r;

int main(){
	scanf("%d%d", &n, &m);
	l = 1, r = n;
	for(int i = 0; i < m; i++){
		int ls, rs; scanf("%d%d", &ls, &rs);
		l = max(l, ls), r = min(r, rs);
	}

	printf("%d\n", max(0, r - l + 1));
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main() {
  int N; cin >> N;
  vector<int> A(N);
  int m = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    m = m > A[i] ? m : A[i];
  }
  //cout << m << endl;
  vector<bool> B(m+1, false);
  sort(A.begin(), A.end());
  
  int result = 0;
  for (int i = 0; i < N; i++) {
    int target = A[i];
    if (B[target]) continue;
    int cnt = 1;
    while (target*cnt <= m) {
      B[target*cnt] = true;
      cnt++;
    }
    if (i < N-1 && A[i] == A[i+1]) continue;
    result++;
  }
  cout << result << endl;
  return 0;
}

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

int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    int c;
    c=a*b;
    if(c%2==0)
        printf("Even\n");
    else
        printf("Odd\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    
	long long n,i,j,count=0,ans=0,l,r,x,y,sum=0,mx=0;
	cin>>n;
	n=n*2;
    double k=3.1415;
    k=k*double(n);
    cout<<k;

	return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n,m,k;
  cin >> n >> m >> k;
  bool pos = false;
  for (int x = 0; x <= n; ++x) {
    for (int y = 0; y <= m; ++y) {
      if (m*x + n*y - 2*x*y == k) pos = true;
    }
  }
  if (pos) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    cin>>k;
    string s;
    cin>>s;
    int n=s.size();
    if(n<=k)
        cout<<s<<endl;
    else
    {
        for(int i=0;i<k;i++)
              cout<<s[i];
        cout<<"..."<<endl;
    }
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

class UnionFind{
private:
    vector<int> p,s;
    int cnt;
public:
    UnionFind(){}
    UnionFind(int N):cnt(N),s(N,1),p(N){
        iota(p.begin(),p.end(),0);
    }
    int find(int x){
        if(p[x]==x) return x;
        else return p[x] = find(p[x]);
    }
    void unite(int x,int y){
        x = find(x); y = find(y);
        if(x==y) return;
        if(s[x]>s[y]) swap(x,y);
        p[x] = y;
        s[y] += s[x];
        cnt--;
    }
    bool is_same_set(int x,int y) {return find(x)==find(y);}
    int size(int x) {return s[find(x)];}
    int compnents_number(){return cnt;}
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M,K;
    cin >> N >> M >> K;
    UnionFind f(N);
    vec<int> cnt(N);
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        cnt[--a]++; cnt[--b]++;
        f.unite(a,b);
    }
    vvec<int> g(N);
    for(int i=0;i<K;i++){
        int c,d;
        cin >> c >> d;
        c--; d--;
        g[c].push_back(d);
        g[d].push_back(c);
    }
    vec<int> ans(N);
    for(int i=0;i<N;i++){
        ans[i] = f.size(i)-cnt[i]-1;
        for(auto& x:g[i]) if(f.is_same_set(i,x)) ans[i]--;
        cout << ans[i] << (i!=N-1? " ":"\n");
    }
}

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

int N;
int A[110];

int main() {
  cin >> N;
  for (auto i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (auto i = 0; i < N; i++) {
    int v = A[i];
    int j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    for (auto i = 0; i < N; i++) {
      cout << A[i];
      if (i != N-1) {
        cout << " ";
      } else {
        cout << endl;
      }
    }
  }
}

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

//ABC 081 B-1
int main()
{
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1; i<=n; i++){
		cin>>a[i];
	}
	int x=0,f=1;
	while(f==1){
		for(int i=1; i<=n; i++){
			if(a[i]%2==0){
				a[i]/=2;
			}else{
				f=0;
				break;
			}
		}
		if(f==1){
			x++;
		}
	}
	cout<<x<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
ll mod= 1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll a[110000];
main(){
    ll x,t,n,m,k,tmp=0,ans=0;
    cin>>n;
    rep(i,1,n+1)cin>>a[i];
    ll cnt=0;
    ll pos=1;
    while(cnt<=n){
      ll st=a[pos];
      pos=st;
      ans++;
      cnt++;
      if(pos==2)break;
    }
    if(cnt==n+1)cout<<-1;
    else cout<<ans;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long LL;
const int N=1e5+5;

int n;
LL c,x[N],v[N];
LL a[N],b[N],pa[N],pb[N];

int main() {
	scanf("%d %lld",&n,&c);
	for(int i=1;i<=n;i++) {
		scanf("%lld %lld",&x[i],&v[i]);
	}
	x[n+1]=c;
	LL ans=0;
	for(int i=1;i<=n;i++) {
		a[i]=a[i-1]+v[i]-(x[i]-x[i-1]);
		ans=max(ans,a[i]);
		pa[i]=max(pa[i-1],a[i]);
	}
	for(int i=n;i>0;i--) {
		b[i]=b[i+1]+v[i]-((c-x[i])-(c-x[i+1]));
		ans=max(ans,b[i]);
		pb[i]=max(pb[i+1],b[i]);
	}
	for(int i=1;i<n;i++) {
		ans=max(ans,a[i]-x[i]+pb[i+1]);
	}
	for(int i=n;i>1;i--) {
		ans=max(ans,b[i]-(c-x[i])+pa[i-1]);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 4992
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define RREP(i,a,b) for(ll i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> p;
typedef vector<pair<ll, ll>> vpl;

bool getbool(char c){
    if(c == '0') return false;
    else return true;
}
int main(){
    string s; cin >> s;
    ll n = s.size();
    bool judge[n+1];
    judge[0] = true;
    ll cnt0 = 0, cnt1 = 0;
    rep(i,n){
        if(judge[i] != getbool(s[i])) cnt1++;
        judge[i+1] = !judge[i];
    }
    judge[0] = false;
    rep(i,n){
        if(judge[i] != getbool(s[i])) cnt0++;
        judge[i+1] = !judge[i];
    }
    cout << min(cnt0, cnt1) << "\n";
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <functional>
#include <tuple>

using namespace std;
using ll = long long;

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

using pii = pair<int,int>;
using tiii = tuple<int,int,int>;

struct Union_find{
    vector<int> par,rank;

//
    void init (int n){
        par.resize(n);
        rank.resize(n);
        rep(i,n){
            par[i] =i;
            rank[i] = 0;
        }
    }

//親を探索
    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

//併合
    void unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y) return;//両方とも親が同じ

        if(rank[x] < rank[y]) par[x] = y;//小さいものから大きいものへ辺をはる
        else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;//高さが同じ
        }
    }

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

/*
必要な辺？
頂点集合について、x,yでソートしたものを用意する。

*/

struct edge{int u,v,cost;};
const int MAX_E = 2e5+10;
edge es[MAX_E];

int main(){
    int n;
    cin >> n;//頂点数

    vector<tiii> v,sort_x,sort_y;
    int x,y;
    rep(i,n){
        cin >> x >> y;
        v.push_back(make_tuple(i,x,y));
    }

    sort(v.begin(),v.end(),[](const tiii& a,const tiii& b){return get<1>(a) < get<1>(b); });
    sort_x = v;//xについてソート
    sort(v.begin(),v.end(),[](const tiii& a,const tiii& b){return get<2>(a) < get<2>(b); });
    sort_y = v;//yについてソート

    rep(i,n-1){
        es[2*i] = {get<0>(sort_x[i]),get<0>(sort_x[i+1]),abs(get<1>(sort_x[i]) - get<1>(sort_x[i+1]))};//i->i+1へのx方向の辺
        es[2*i+1] = {get<0>(sort_y[i]),get<0>(sort_y[i+1]),abs(get<2>(sort_y[i]) - get<2>(sort_y[i+1])) };//i->i+1へのy方向の辺
    }
    sort(es,es+2*(n-1),[](const edge& e1,const edge& e2){return e1.cost < e2.cost;});
    
    Union_find uf;
    uf.init(n);
    int res = 0;

    rep(i,2*(n-1)){
        edge e = es[i];
        if(!uf.same(e.u,e.v)){
            uf.unite(e.u,e.v);
            res += e.cost;
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 6900
#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>;

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int K;
    cin >> K;
    int x = 7;
    for (int i=1; i<=1000001; ++i) {
        if (x % K == 0) {
            cout << i << endl;
            return 0;
        }
        x = (x * 10 + 7) % K;
    }
    cout << -1 << endl;
    return 0;
}

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

using namespace std;

int main(int argc, char const *argv[]) {
	string a,b;
	std::cin >> a >> b;
	a = a + b;
	double n = stod(a);
	int m = (int)(sqrt(n));
	if (n - (double)(m * m) == 0.0) {
		std::cout << "Yes" << '\n';
	}
	else {
		std::cout << "No" << '\n';
	}
	return 0;
}


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

const int BLOCK = 1e6;

lint n, s;

lint trial(lint x, lint cur = n) { // sum of digits of cur is base x
  if (cur < x) {
    return cur;
  }
  return trial(x, cur / x) + (cur % x);
}

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

  cin >> n >> s;

  if (n - s < 0) {
    cout << -1 << "\n";
    return 0;
  }

  if (n == s) {
    cout << n + 1 << "\n";
    return 0;
  }

  for (lint i = 2; i < BLOCK; i++) {
    if (trial(i) == s) {
      cout << i << "\n";
      return 0;
    }
  }

  // base-b is now at most 2 digit
  // pb + q = n
  // p + q = s
  // n - s = p(b - 1)
  // thus (b - 1) | n - s
  // iterate on divisors of n - s

  vector<lint> cand;
  for (lint b = 1; b * b <= n - s; b++) {
    if ((n - s) % b == 0) {
      lint f1 = b;
      lint f2 = (n - s) / b;
      cand.emplace_back(f1 + 1);
      cand.emplace_back(f2 + 1);
    }
  }

  sort(begin(cand), end(cand));

  for (auto &b : cand) {
    if (b < 2) continue;
    if (trial(b) == s) {
      cout << b << "\n";
      return 0;
    } 
  }

  cout << -1 << "\n";
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <string.h>
#include <cstdio>
#include <cctype>
using namespace std;

int main(){
	string str, com, p;
	int q, a, b;

	cin >> str >> q;
	for(int t=0; t<q; t++){
		cin >> com >> a >> b;
		if(com == "print"){
			cout << str.substr(a,b-a+1) << endl;
		} 
		else if(com == "reverse") {
			string tmp = str.substr(a, b-a+1);
			int n = tmp.size();
			for(int i=0; i<n; i++) str[i+a] = tmp[n-i-1];
		} 
		else if(com == "replace") {
			cin >> p; str = str.replace (a, b-a+1, p);
		}
	}

	return 0;
}


Measured memory_bytes: 3208
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1]))
  member this.Scan3 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2]))
  member this.Scan4 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2], a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = seq { for i in 1..n -> stream.ReadLine() |> f }
  member this.ScanMatrix n f  = seq { for i in 1..n do yield stream.ReadLine().Split() |> Array.map f }
  member this.ScanCharMatrix n = [| for i in 1..n -> stream.ReadLine().ToCharArray() |]
  member this.Close () = stream.Close()

let util = ABC(stdin)

let N = util.Scan1 int
let T, A = util.Scan2 float
let xs = util.ScanVecH (fun h ->
  let t = T - 0.006 * (float h)
  abs (t - A))
let ans = Array.min xs

printfn "%d" ((Array.findIndex ((=) ans)) xs + 1)


Measured memory_bytes: 14172
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}


int main() {
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  int y=*max_element(A.begin(),A.end());

  vector<bool>ok(10000000,true);

  for(int i=0;i<N;i++){
   int x=A[i];
   for(int j=x+x;j<=y;j+=x){
     ok[j]=false;
   }
   if(i<N-1&&A[i]==A[i+1]){ok[A[i]]=false;i++;continue;}
  }

  int cnt=0;
  for(int i=0;i<N;i++){
    if(ok[A[i]]){cnt++;}
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 5316
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<P> a(n);
    rep(i, n)cin >> a[i].second >> a[i].first;
    sort(all(a));
    ll now = 0;
    bool ans = true;
    rep(i, n){
        now += a[i].second;
        if(now > a[i].first)ans = false;
    }
    if(ans)cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline

#入力
N = int(input())
AB = [0] * (N + 1) #答えの色
G = [[] for _ in range(N + 1)]
for i in range(N - 1):
    a, b = map(int, input().split())
    G[a].append((b, i))
    G[b].append((a, i))

check = [[0, 0] for _ in range(N + 1)] #[[チェック、親と繋いでいる色]]
check[1][0] = 1
ans = 0
stack = [1]
while len(stack) != 0:
    tmp = stack.pop()
    color = 1
    for g, i in G[tmp]:
        if check[g][0] == 1: #すでに確認済みの時
            continue
        if color == check[tmp][1]:
            color += 1
        AB[i] = color
        check[g][0] = 1
        check[g][1] = color
        color += 1
        stack.append(g)

K = max(AB)
print (K)
print (*AB[:N - 1], sep = '\n')


Measured memory_bytes: 50612
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
string s;
int c[111111][26];
signed main(){
	cin>>s;
	int n=s.size();
	rep(i,n){
		if(s[i]==s[i+1]){
			cout<<i+1<<" "<<i+2<<endl;
			return 0;
		}
		else if(s[i]==s[i+2]){
			cout<<i+1<<" "<<i+3<<endl;
			return 0;
		}
	}
	puts("-1 -1");
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

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

  vector<int> A(M,0);
  for (int i = 0; i < N; ++i)
  {
    int K;
    cin >> K;

    for (int j = 0; j < K; ++j)
    {
      int a;
      cin >> a;
      ++A[a-1];
    }
  }

  int count = 0;
  for (int i = 0; i < M; ++i)
  {
    if (A[i] == N) ++count;
  }

  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1073741824
#define ll long long
#define PI (2*acos(0.0))
#define Hare printf("here\n")
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define x first
#define y second
#define on(val,pos) val|(1<<pos)
#define off(val,pos) val&(~(1<<pos))
#define check(val,pos) (val&(1<<pos))

//first four adjacent,second four corner
//int row[8]={0,-1,0,1,1,-1,-1,1};
//int col[8]={-1,0,1,0,-1,-1,1,1};
using namespace std;

int main(){
    int i,j,k,n,m,val,t=0,cnt,test;
    //freopen("000input.txt","r",stdin);
    cin>>n>>k;
    int arr[n+5];
    for(i=n-1;i>=0;i--)scanf("%d",&arr[i]);
    int ans[n+5];
    ans[0]=0;
    for(i=1;i<n;i++){
        ans[i]=INF;
        for(j=1;j<=k and i-j>=0;j++)
        ans[i]=min(ans[i-j]+abs(arr[i-j]-arr[i]),ans[i]);
    }
    printf("%d\n",ans[n-1]);

    //free();   //if pointer array
    return 0;
}


Measured memory_bytes: 1024
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = list(input())
t = list(input())
s.sort()
t.sort(reverse = True)
print('Yes' if s < t else 'No')

Measured memory_bytes: 72204