akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<pii,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?9e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct UnionFind{
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unionSet(int x,int y){
        x=root(x);y=root(y);
        if(x==y)return 0;
        if(data[y]<data[x])swap(x,y);
        data[x]+=data[y],data[y]=x;
        return 1;
    }
    bool findSet(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0 ? x : data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};
class KRK{//c++11
	public:
	struct edge{
		int from,to,cost;
	};
	vector<edge>G;
	int n;
	KRK(int size){
		n=size;
	}
	void add_edge(int a,int b,int c){
		edge e={a,b,c};
		G.pb(e);
	}
	int krk(){
		int sum=0;
		sort(all(G),[](edge a,edge b){
			return a.cost<b.cost;
		});
		UnionFind uf(n);
		rep(i,G.size()){
			edge e=G[i];
			if(!uf.findSet(e.from,e.to)){
				sum+=e.cost;
				uf.unionSet(e.from,e.to);
			}
		}
		return sum;
	}
};
int main(){
	int n;
	cin>>n;
	KRK krk(n);
	vip in(n);
	rep(i,n){
		int a,b;
		cin>>a>>b;
		in[i]={a,{i,b}};
//		krk.add_edge(a,b,c);
	}
	sort(all(in));
	rep(i,n-1)krk.add_edge(in[i].second.first,in[i+1].second.first,in[i+1].first-in[i].first);
	rep(i,n)swap(in[i].first,in[i].second.second);
	sort(all(in));
	rep(i,n-1)krk.add_edge(in[i].second.first,in[i+1].second.first,in[i+1].first-in[i].first);
	cout<<krk.krk()<<endl;
}











Measured memory_bytes: 7284
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
  int N;
  cin >> N;
  int W[N];
  int total = 0;
  int total2 = 0;
  for(int i = 0; i < N; i++){
    cin >> W[i];
    total += W[i];
  }
  int ans = 9999999;
  for(int i = 0; i < N; i++){
    total2 += W[i];
    ans = min(abs(total2 - (total - total2)), ans);
 
  }
  cout << ans << endl;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	cout << max({ a + b,a - b,a * b }) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define MAX 1000000007
using namespace std;
int main()
{
 	speed_up
 	ll n,ct=0;cin>>n;
 	ll a[n];for(ll i=0;i<n;i++) cin>>a[i];
 	for(ll i=0;i<n;i++)
 	{
 		
 		if(a[i]!=i+1)
		 {
		 	ll x=a[i]-1;
		 	if(a[x]!=i+1) {cout<<"NO";return 0 ;}
		 	else
		    {
			   swap(a[i],a[x]);ct++;if(ct>1) {cout<<"NO";return 0;}
		    }
		  } 
	 }
	 cout<<"YES";
	
	
	
	
	
 return 0;
}

Measured memory_bytes: 256
using System;

namespace _1_2d
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] hoge = Console.ReadLine().Split(' ');
            int W = int.Parse(hoge[0]);
            int H = int.Parse(hoge[1]);
            int x = int.Parse(hoge[2]);
            int y = int.Parse(hoge[3]);
            int r = int.Parse(hoge[4]);

            if (r <= x && x <= H - r && r <= y && y <= H - r)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }


        }
    }
}



Measured memory_bytes: 17928
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;

int main(){
  int x;
  cin >> x;
  cout << (x<1200 ? "ABC" : "ARC") << endl;
  return 0;
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input);

    let mut iter = input.split_whitespace();

    let a = iter.next().unwrap().parse::<i64>().unwrap();
    let b = iter.next().unwrap().parse::<i64>().unwrap();

    if (a - b).abs() % 2 == 1 {
        println!("IMPOSSIBLE");
    } else {
        let k = (a+b) / 2;
        println!("{}", k);
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<28));
const ll linf = (1LL<<58);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int tmp = s.size();
    string tm2 = t.substr(0,tmp);
    if(tm2 == s && t.size()==s.size()+1) cout << "Yes";
    else cout << "No";
    return 0;
}



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

#define ll long long int 

int main(){
	ll h,n;
	cin>>h>>n;
	ll health[n+1],cost[n+1];
	for(ll i=0;i<n;i++){
		cin>>health[i]>>cost[i];
	}
	ll dp[h+1];
	for(ll i=0;i<h+1;i++){
		dp[i]=1000000000;
	}
	dp[h]=0;
	for(ll i=h;i>=0;i--){
		for(ll j=0;j<n;j++){
			dp[(i-health[j]<0?0:i-health[j])]=min(dp[(i-health[j]<0?0:i-health[j])],dp[i]+cost[j]);
		}
	}
	cout<<dp[0];
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static bool Solve(string S)
        {
            int N = S.Length;
            int i = 0;
            while (i < N)
            {
                if (i + 6 <= N && S.Substring(i, 6) == "eraser")
                {
                    i += 6;
                }
                else if (i + 5 <= N && S.Substring(i, 5) == "erase")
                {
                    i += 5;
                }
                else if (i + 7 <= N && S.Substring(i, 7) == "dreamer")
                {
                    if (i + 7 < N && S[i + 7] == 'a')
                    {
                        i += 5;
                    }
                    else
                    {
                        i += 7;
                    }
                }
                else if (i + 5 <= N && S.Substring(i, 5) == "dream")
                {
                    i += 5;
                }
                else
                {
                    return false;
                }
            }
            return true;
        }
        static void Main(string[] args)
        {
            Console.WriteLine(Solve(Read()) ? "YES" : "NO");
        }
    }
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

const ll mod = 1e9+7;
//const ll mod = 998244353;
ll dp[100100][2];
int main()
{
	string s;
	cin >> s;

	dp[0][0] = 1;
	For(i,1,s.size()+1){
		// dp[i] を作っていく。
		// ＝への遷移
		if(s[i-1] == '0'){
			// 両方0 
			dp[i][0] += dp[i-1][0];
		} else {
			// どちらを1にするか
			dp[i][0] += dp[i-1][0] * 2;
		}

		// 未満への遷移
		if(s[i-1] == '1'){
			// ＝から,両方0にすることで小さくなる
			dp[i][1] += dp[i-1][0];

			dp[i][1] += dp[i-1][1] * 3;
		} else {
			// 0 0 にしても＝から未満になることはない
			dp[i][1] += dp[i-1][1] * 3;
		}
		dp[i][0] %= mod;
		dp[i][1] %= mod;
	}
	int n = s.size();
	ll ans = dp[n][0] + dp[n][1];
	ans %= mod;
	cout << ans << endl;
}


Measured memory_bytes: 5276
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i < n; i++){
    if (n%i) ans += n/i;
    else ans += n/i - 1;
  }
  cout << ans << endl;
}

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

int main() {
	int n;
	int* pT;

	cin >> n;
	pT = new int[n];

	for (int i = 0; i < n; i++) {
		cin >> pT[i];
	}

	int n1;
	n1 = n * (n - 1) / 2;
	int* pT1;

	pT1 = new int[n1];

	int l = 0;

	for (int k = 0; k < n; k++) {
		for (int j = k + 1; j < n; j++) {
			
			pT1[l] = pT[k] * pT[j];
			l++;
		}
	}

	
	int result = 0;
	for (int m = 0; m < n1; m++) {
		//cout << pT1[m] << "\n";
		result += pT1[m];
	}

	cout << result << "\n";

	delete[] pT;
	delete[] pT1;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;
const int MAX = 100010;
ll inv[MAX],fact[MAX],fi[MAX],mod = 1000000007;

void inverse(){
	int i;
	inv[1] = 1;
	for(i=2;i<MAX;i++){
		inv[i] = mod - (mod/i)*inv[mod%i]%mod;
	}
	fact[0] = fi[0] = 1;
	for(i=1;i<MAX;i++){
		fact[i] = fact[i-1]*i%mod;
		fi[i] = (fi[i-1]*inv[i])%mod;
	}
}

ll comb(int n,int k){
	if(n<0 || k<0 || n<k){
		return 0;
	}else{
		return fact[n]%mod*fi[k]%mod*fi[n-k]%mod;
	}
}

ll a[1010],dp[2][1010];
int main(){
	ll i,j,n,k,l;
	cin >> n >> k;
	for(i=0;i<k;i++){
		cin >> a[i];
	}
	inverse();
	dp[0][0] = 1;
	for(i=k - 1;i>=0;i--){
		for(j=0;j<=n;j++){
			ll s = 0;
			for(l=0;l<=j;l++){
				(s += dp[0][j - l]*comb(j,l)%mod*comb(n - l,a[i] - l)%mod) %= mod;
			}
			(dp[1][j] += s) %= mod;
		}
		for(j=0;j<=n;j++){
			dp[0][j] = dp[1][j];
			dp[1][j] = 0;
		}
	}
	cout << dp[0][n] << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n; cin >> n;
  Graph G(n, vi(2));
  rep(i,n) rep(j,2) cin >> G[i][j];

  sort(all(G));

  int a = 0, b = -1;
  int a_end;
  bool zero = false;

  rep(i,n) {
    if (b == -1) {
      if (G[a][1] < G[i][0]) {
        b = i;
        a_end = i - 1;
      }
      else if (G[i][1] <= G[a][1]) {
        a = i;
      }
    }

    else {
      if (G[i][0] > G[b][1]) {
        zero = true;
        break;
      }
      else if (G[i][1] <= G[b][1]) {
        b = i;
      }
    }
  }

  int ans = 0;
  rep(i,n) ans = max(ans, G[i][1] - G[i][0] + 1);

  if (zero) {
    cout << ans << endl;
    return 0;
  }

  if (b == -1) {
    ans += G[a][1] - G[n-1][0] + 1;
  }

  Graph rest;
  rest.push_back(G[a]);
  int last = b == -1 ? n-1 : a_end;
  int r = b == -1 ? n-1 : b;
  for (int i=a+1; i<=last; ++i) {
    if (G[i][1] < G[r][0]) rest.clear();
    if (G[i][1] <= G[r][1]) rest.push_back(G[i]);
  }

  reverse(all(rest));
  int b_right = G[r][1];
  rep(i,rest.size()) {
    ans = max(ans, (G[a][1] - rest[i][0] + 1) + (b_right - G[n-1][0] + 1));
    b_right = min(b_right, rest[i][1]);
  }

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


Measured memory_bytes: 12212
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>

using namespace std;
typedef long long ll;

ll N;

int main() {
	cin >> N;
	cout << 180 * (N - 2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 25

typedef struct{
  int l,r,par;
} node;

node N[25];

void init(int);
void Preorder(int);
void Inorder(int);
void Postorder(int);

int main(){
  int n,i,id,l,r;
  int p;
  
  scanf("%d" ,&n); 
  init(n);  

  for(i = 0 ; i < n ; i++){
    scanf("%d%d%d" ,&id ,&l ,&r);

    if(l != -1){
      N[id].l = l;
      N[l].par = id;
    }
    if(r != -1){
      N[id].r = r;
      N[r].par = id;
    }
  }

  for(i = 0 ; i < n ; i++){
    if(N[i].par == -1){
      p = i;
      break;
    }
  }
 
  puts("Preorder");
  Preorder(p);
  puts("");

  puts("Inorder");
  Inorder(p);
  puts("");

  puts("Postorder");
  Postorder(p);
  puts("");

  return 0;
}

void init(int n){
  int i;

  for(i = 0 ; i < n ; i++){
    N[i].par = N[i].l = N[i].r = -1;
  }
}

void Preorder(int p){
  if(p != -1){
    printf(" %d" ,p);
    Preorder(N[p].l);
    Preorder(N[p].r);
  }
}

void Inorder(int p){
  if(p != -1){
    Inorder(N[p].l);
    printf(" %d" ,p);
    Inorder(N[p].r);
  }
}

void Postorder(int p){
  if(p != -1){
    Postorder(N[p].l);
    Postorder(N[p].r);
    printf(" %d" ,p);
  }
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

using namespace std;


int main(){
    int n;
    cin >> n;
    
    int x;
    double sum = 0;
    rep(i,n) {
        cin >> x;
        sum += 1.0 / (double)x;
    }
    
    cout << fixed << setprecision(5) ;
    cout << 1.0 / sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(15);
vector<int> forintinput(int n) {
	vector<int> x;
	for(int i = 0;i < n;i++){
		int ia;
		cin >> ia;
		x.push_back(ia);
	}
	return x;
}
int main(){
	int a,b;
	cin >> a >> b;
	if(a <= 5){
		cout << 0 << endl;
	}else if(a <= 12){
		cout << b/2 << endl;
	}else{
		cout << b << endl;
	}
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	vector<pii> t(n);
	rep(i, n) cin >>t[i].first >>t[i].second;
	
	sort(all(t));
	ll ans = 0;
	for(auto x: t){
		ll mn = min(m, x.second);
		ans += mn * x.first;
		m -= mn;
		if(mn <= 0) break;
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>                                                 
                                                                  
int main(){                                                   
   int n, k;                                                        
                                                                  
   scanf("%d", &n);                                                
   k = n % 10;                                                    
                                                                  
   if(k == 3){                                                   
      printf("bon");                                              
   } else if(k == 0 || k == 1 || k == 6 || k == 8){              
      printf("pon");                                              
   } else {                                                       
      printf("hon");                                              
   }
   printf("\n");                                                              
}                                                                 
      


Measured memory_bytes: 1728
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

const int INF = 1 << 30;

int main()
{
  int N;
  while (cin >> N) {
    vector<vector<int> > c(N, vector<int>(N));
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j)
	cin >> c[i][j];
    }

    vector<int> p;
    for (int i = 0; i < N; ++i)
      p.push_back(i);
    priority_queue<pair<int, vector<int> >, vector<pair<int, vector<int> > >, greater<pair<int, vector<int> > > > que;
    que.push(make_pair(0, p));
    map<vector<int>, int> dp;
    dp[p] = 0;

    while (!que.empty()) {
      pair<int, vector<int> > v = que.top();
      que.pop();

      if (dp[v.second] < v.first)
	continue;
      dp[v.second] = v.first;

      for (int i = 0; i < N; ++i) {
	for (int j = i+1; j < N; ++j) {
	  swap(v.second[i], v.second[j]);
	  if (dp.find(v.second) == dp.end() ||
	      v.first+c[v.second[i]][v.second[j]] < dp[v.second]) {
	    dp[v.second] = v.first+c[v.second[i]][v.second[j]];
	    v.first += c[v.second[i]][v.second[j]];
	    que.push(v);
	    v.first -= c[v.second[i]][v.second[j]];
	  }
	  swap(v.second[j], v.second[i]);
	}
      }
    }

    int ans = 0;
    for (map<vector<int>, int>::iterator it = dp.begin(); it != dp.end(); ++it)
      ans = max(ans, it->second);
    cout << ans << endl;
  }

  return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

class Union_Find{
  public:
  Union_Find(){};
  static const ll MAX_N = 100000*2+1;
  int par[MAX_N];
  int ranks[MAX_N];
  void init(int n){
    rep(i,MAX_N){
      par[i] = i;
      ranks[i] = 0;
    }
  }
  int find(int x){
    if(par[x] == x){
      return x;
    }
    else{
      return par[x] = find(par[x]);
    }
  }
  void Unite(int a, int b){
    a = find(a);
    b = find(b);
    if(a == b) return ;
    if(ranks[a] < ranks[b]){
      par[a] = b;
    }
    else{
      par[b] = a;
      if(ranks[a] == ranks[b]) ranks[a]++;
    }
  }
  bool same(int a,int b){
    return find(a) == find(b);
  }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  Union_Find uf;
  ll n,m;
  cin >> n >> m;
  uf.init(n);
  ll s,t;
  rep(i,m){
    cin >> s >> t;
    uf.Unite(s,t);
  }
  ll q;
  cin >> q;
  rep(i,q){
    cin >> s >> t;
    if(uf.same(s,t)){
      cout << "yes" << endl;
    }
    else{
      cout << "no" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 4700
import math as m
while True:
    x=int(input())
    if x==0:
        break
    else:
        y=list(map(int,input().split()))
        m=sum(y)/x
        a=0
        for i in range(0,x):
            r=(y[i]-m)**2
            a+=r
        a=a/x
        print(f'{a**(1/2):.8f}')


Measured memory_bytes: 5728
<?php

$n = intval(fgets(STDIN));
for($i = 0; $i < $n; $i++){
	fscanf(STDIN, "%lf %lf %lf %lf %lf %lf", $xa, $ya, $ra, $xb, $yb, $rb);
	
	$r = sqrt(($xb - $xa)*($xb - $xa) + ($yb - $ya)*($yb - $ya));
	if($r + $ra < $rb){
		// A が B の中にある
		echo "-2\n";
		continue;
	}
	if($r + $rb < $ra){
		// B が A の中になる
		echo "2\n";
		continue;
	}
	
	if($r <= $ra + $rb){
		// 交わってる
		echo "1\n";
		continue;
	}
	
	// 離れてる
	echo "0\n";
}

Measured memory_bytes: 15204
a_500 = int(input())
b_100 = int(input())
c_50 = int(input())
x_total = int(input())

counter = 0
for i in range(a_500 + 1):
    for j in range(b_100 + 1):
        for k in range(c_50 + 1):
            if x_total == i*500 + j*100 + k*50:
                counter += 1
print(counter)

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
  int n,nn,sum=0;
  scanf("%d",&n);
nn=n;
  if(n<=100000000&&n>=1){
    do{
      sum+=n%10;
      n/=10;
    }while(n>0);
    if(nn%sum==0)
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))

ans = 0

for i in range(n):
	bns = sum(a1[:i+1]) + sum(a2[i:])
	if ans < bns:
		ans = bns

print(ans)

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    for(int ix=0;ix<n;ix++){
        string s1,s2;
        cin>>s1>>s2;
        reverse(s1.begin(),s1.end());
        reverse(s2.begin(),s2.end());
        if(s1.size()>80||s2.size()>80){
            printf("overflow\n");
            continue;
        }
        string res;
        int kuri=0;
        for(int i=0;i<80;i++){
            int now;
            if(i<s1.size()&&i<s2.size())now=(s1[i]-'0')+(s2[i]-'0')+kuri;
            else if(i<s1.size())now=(s1[i]-'0')+kuri;
            else if(i<s2.size())now=(s2[i]-'0')+kuri;
            else if(kuri==1)now=kuri;
            else break;
            res.append(1,(char)(now%10+'0'));
            kuri=now/10;
        }
        if(kuri==1)printf("overflow\n");
        else{
            reverse(res.begin(),res.end());
            printf("%s\n",res.c_str());
        }
    }
}

Measured memory_bytes: 0
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextInt();
    long sum = 0;
    for(int i = 1; i < n; i++){
      sum += i;
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 21844
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()
    num_list = i_list()

    ans = 0

    sum_count = sum(num_list)

    for i in range(n-1):
        sum_count -= num_list[i]
        ans += num_list[i] * sum_count
        ans %= MOD

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 108968
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

ll q(ll x){
	cout<<x<<endl;
	string s;
	cin>>s;
	if(s[0]=='M') return 1;
	if(s[0]=='F') return 2;
	return 0;
}

int main(){
	ll n;
	cin>>n;
	ll lb = 0, ub = n-1; // [lb, ub]
	ll a = q(lb);
	if(a==0) return 0;
	ll b = q(ub);
	if(b==0) return 0;
	while(true){
		ll md = (lb+ub+1)/2;
		ll t = (md-lb)%2;
		ll r = q(md);
		if(r==0) break;
		if((r==a)^t){
			lb = md;
			a = r;
		}
		else ub = md;
	}
	return 0;
}


Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,x,ct,p,q,r;
    string s,s1,s2;
    cin>>a>>b>>x;
    p=a+b+x;
    if(p>=22) cout<<"bust"<<endl;
    else cout<<"win"<<endl;
}





Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];


int main(){
  ll x;cin>>x;
  ll a,b;
  bool ok=false;
  rep(i,-120,120){
    rep(j,-120,120){
      if(pow(i,5)+pow(j,5)==x){
        a=i;b=j;
        ok=true;
        break;
      }
    }
    if(ok){break;}
  }
  cout<<a<<" "<<-b<<endl;
}






Measured memory_bytes: 4024
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <vector>
#include <string>

using ll = long long;

using namespace std;

vector<ll> factorize(ll n) {
    vector<ll> ans;
    for (ll i = 2; i * i <= n || i < 1000000; ++i) {
        ll d = 1;
        while (n % i == 0) {
            n /= i;
            d *= i;
        }
        if (d > 1) {
            ans.push_back(d);
        }
    }
    if (n > 1) {
        ans.push_back(n);
    }
    return ans;
}

ll gcd (ll a, ll b, ll & x, ll & y) {
    if (a == 0) {
        x = 0; y = 1;
        return b;
    }
    ll x1, y1;
    ll d = gcd (b%a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
 
bool find_any_solution (ll a, ll b, ll c, ll & x0, ll & y0, ll & g) {
    g = gcd (abs(a), abs(b), x0, y0);
    if (c % g != 0)
        return false;
    x0 *= c / g;
    y0 *= c / g;
    if (a < 0)   x0 *= -1;
    if (b < 0)   y0 *= -1;
    return true;
}

void solve() {
    ll n;
    cin >> n;
    auto fact = factorize(2 * n);

    ll ans = n;

    for (int mask = 0; mask < (1 << fact.size()); ++mask) {
        ll a1 = 1, a2 = 1;
        for (int j = 0; j < fact.size(); ++j) {
            if (mask & (1 << j)) {
                a1 *= fact[j];
            } else {
                a2 *= fact[j];
            }
        }
        ll x0, y0;
        ll g = 1;
        find_any_solution(a2, -a1, 1, x0, y0, g);
        while (x0 <= 0 || y0 <= 0) {
            x0 += a1;
            y0 += a2;
        }
        while (x0 - a1 > 0 && y0 - a2 > 0) {
            x0 -= a1;
            y0 -= a2;
        }
        ans = min(ans, a1 * y0);
    }
    cout << ans << '\n';
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    solve();
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
 
 
int main(void){
  int N, K;
  cin >> N >> K;
  int temp = N;
  int count = 0;
  while(temp > 0){
    temp = temp / K;
    count++;
  }
  cout << count;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
t = list(map(int,input().split()))
sum_t = sum(t)
T_all = []
for i in range(int(input())):
    T = sum_t
    p,x = map(int,input().split())
    T += (x-t[p-1])
    T_all.append(T)

for j in range(len(T_all)):
    print(T_all[j])

Measured memory_bytes: 3064
unittest
{
	assert( [ "7", "5 15", "1 10 16 2 7 20 12" ].parse.expand.solve == 2 );
	assert( [ "8", "3 8", "5 5 5 10 10 10 15 20" ].parse.expand.solve == 0 );
	assert( [ "3", "5 6", "5 6 10" ].parse.expand.solve == 1 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto ab = input.front.split.to!( long[] );
	input.popFront;
	auto ps = input.front.split.to!( long[] );
	return tuple( ab[ 0 ], ab[ 1 ], ps );
}

auto solve( long a, long b, long[] ps )
{
	auto ts = new long[ 3 ];
	
	foreach( p; ps )
	{
		if(      p <= a          ) ts[ 0 ]++;
		else if( a < p && p <= b ) ts[ 1 ]++;
		else                       ts[ 2 ]++;
	}
	
	return ts.reduce!min;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
  char s[101];
  char ss[201];
  char p[101];

  scanf("%s",s);
  scanf("%s",p);

  strcpy(ss,s);
  strcat(ss,s);

  if(strstr(ss,p)!=NULL)
    puts("Yes");
  else
    puts("No");

  return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string S;
	cin >> S;
	if (S.substr(0,4) == "YAKI") cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int h = sc.nextInt();
    int n = sc.nextInt();
    
    for (int i=0; i<n; i++) {
      int a = sc.nextInt();
      h -= a;
      if (h<=0) {
        break;
      }
    }
    
    String result;
    if (h<=0) {
      result = "Yes";
    }
    else {
      result = "No";
    }

    
    System.out.println(result);
    
  }
}

Measured memory_bytes: 48492
n=int(input())
d=["3","5","7"]
ans=[]
ans+=d
while d:
    a=d.pop(0)
    if len(a)<9:
        for i in "357":
            d+=[i+a]
            ans+=[i+a]
ans=list(map(int,ans))
ans.sort()
print(sum(i<=n for i in ans if len(set(str(i)))==3))

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

bool isPrime(ll n){
    if(n < 2) return false;
    for(ll i = 2; i*i <= n; i++) if(n % i == 0) return false;
    return true;
}

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

int main(){
    ll a, b; cin >> a >> b;
    set<ll> st;
    ll g = gcd(a,b);
    for(ll i = 1; i*i <= g; i++){
        if(g % i == 0){
            if(isPrime(i)) st.insert(i);
            if(isPrime(g/i)) st.insert(g/i);
        } 
    }
    cout << st.size() + 1 << endl;
}

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

#define rep(i, n) for(int i=0; i < (n); ++i)
#define ll long long

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

vv<ll> dp(105, v<ll>(100005));

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

    int n, W; cin >> n >> W;
    v<int> w(n), v(n); rep(i,n) cin >> w[i] >> v[i];

    rep(i,n) {
        for (int j = 0; j <= W; j++) {
            chmax(dp[i+1][j], dp[i][j]);
            if (j - w[i] < 0) continue;
            chmax(dp[i+1][j], dp[i][j-w[i]] + v[i]);
        }
    }

    cout << dp[n][W] << endl;

    return 0;
}


Measured memory_bytes: 83456
#include <limits.h>
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <functional>
#include <algorithm>

using namespace std;

int K, S;

void solve_main(void)
{
	int ans = 0;
	cin >> K >> S;

	for (int idx_x = 0; idx_x <= K; idx_x++) {
		for (int idx_y = 0; idx_y <=K; idx_y++) {
			int dif = S - idx_x - idx_y;
			if (dif <= K && dif >= 0) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}

int main()
{
#ifdef FOR_IDE

	ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
#endif

	solve_main();
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}

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

Measured memory_bytes: 640
N, M = map(int, input().split())
A = []
B = []
for _ in range(N):
    A.append(list(input()))
for _ in range(M):
    B.append(list(input()))

for i in range(N - M + 1):
    for j in range(N - M + 1):
        # match
        flag = True
        for k in range(M):
            for l in range(M):
                if A[i + k][j + l] == B[k][l]:
                    pass
                else:
                    flag = False

        if flag:
            break

    if flag:
        break

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 40176
// created_by  Rishi_Mohan

#include<bits/stdc++.h>

#define    ll           long long
#define    db1(x)       cout<<#x<<"="<<x<<'\n'
#define    db2(x,y)     cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define    db3(x,y,z)   cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

using namespace std;

void solve()
{
   int n;
   cin >> n;
   int arr[4]={0,0,0,0};
   for(int i=0;i<n;i++)
   {
      string str;
      cin >> str;
      if(str=="AC") arr[0]++;
      else if(str=="WA") arr[1]++;
      else if(str=="TLE") arr[2]++;
      else arr[3]++;
   }
   cout << "AC " << "x " << arr[0] << endl;
   cout << "WA " << "x " << arr[1] << endl;
   cout << "TLE " << "x " << arr[2] << endl;
   cout << "RE " << "x " << arr[3] << endl;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
}


Measured memory_bytes: 3656
n = int(input())
ad = [list(map(int,input().split())) for i in range(n)]

l = 0

for i in range(n):
    for j in range(n):
        l+=((ad[i][0]-ad[j][0])**2+(ad[i][1]-ad[j][1])**2)**(1/2)

ans = l / n
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	vector<int>time(n);
	vector<int>dl(n);			//deadline
	rep(i, n)cin >> time[i] >> dl[i];

	vector<pair<int, int>>x(n);
	//x.firstがdl,x.secondはtime 反対だから注意
	rep(i, n) {
		x[i].first = dl[i];
		x[i].second = time[i];
	}

	sort(x.begin(), x.end());
	
	int now = 0;
	int deadline = 0;

	bool capable = true;

	rep(i, n) {
		now += x[i].second;
		deadline = x[i].first;
		if (deadline < now) {
			capable = false;
		}
	}
	if (capable == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3456
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ff first
#define ss second
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define repr(i, a, n) for (ll i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  int n;
  cin >> n;
  cout << (((n / 10) % 111 == 0 || (n % 1000) % 111 == 0) ? "Yes" : "No");
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // CとC++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

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

int main(){
  string str;
  int counter;
  cin >> str;
  counter = 0;
  if(str[0] == '1')counter = counter +1;
  if(str[1] == '1')counter = counter +1;
  if(str[2] == '1')counter = counter +1;
  
  cout << counter << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

s = input().rstrip()
if len(s) == 2:
    if s[0] == s[1]:
        print(1, 2)
    else:
        print(-1, -1)
    exit()

for i, (a1, a2, a3) in enumerate(zip(s, s[1:], s[2:])):
    if a1 == a2:
        print(i+1, i+2)
        exit()
    if a2 == a3:
        print(i+2, i+3)
        exit()
    if a1 == a3:
        print(i+1, i+3)
        exit()
print(-1, -1)

Measured memory_bytes: 3572
#include<iostream>
#include<algorithm>
#include<string> 
#include<map>
#include<set>
#include<vector>
#include<string.h> 
#include<math.h>
#include<stdio.h>
#include<queue>
using namespace std;
int main()
{string s;cin>>s;int e=700;
for(int i=0;i<3;i++)if(s[i]=='o')e+=100;
cout<<e;
system("pause");
return 0;
}

Measured memory_bytes: 504
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/


int main(){
int A,B;
cin>>A>>B;
if((A>=1)&&(A<=9)&&(B>=1)&&(B<=9)){
    cout<<A*B<<endl;
}
else{
    cout<<-1<<endl;
}


return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String str = sc.nextLine();
    sc.close();
    if(str.endsWith("3")) {
      System.out.println("bon");
    }else if(str.endsWith("0")||str.endsWith("1")||str.endsWith("6")||str.endsWith("8")) {
      System.out.println("pon");
    }else {
      System.out.println("hon");
    }

  }

}


Measured memory_bytes: 35816
#include <iostream>

using namespace std;

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  for(int i=0;i<=B;i++){
    if((i*A)%B==C){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" <<endl;
}



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

int main()
{
    string s[3];
    for (int i=0;i<3;i++)
    {
        cin>>s[i];
    }
    cout<<s[0].substr(0,1)<<s[1].substr(0,1)<<s[2].substr(0,1)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;

int finder(const vector<vector<int> >& G, int now, int prv) {
  vector<int> bits;
  for (auto nxt : G[now]) {
    if (nxt == prv) continue;
    bits.push_back(finder(G, nxt, now));
  }
  int res = 0;
  for (int bit=20; bit>=0; bit--) {
    int cnt = 0;
    for (auto p : bits) {
      if (p&(1<<bit)) cnt ++;
    }
    if (cnt == 1) res += 1<<bit;
    else if (cnt > 1) {
      res += 1<<(bit+1);
      return res;
    }
  }
  res ++;
  return res;
}

int main()
{
  int N;
  cin >> N;
  vector<vector<int> > G(N);
  for (int i=0; i<N-1; i++) {
    int a, b;
    cin >> a >> b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }

  int res = finder(G, 0, -1);
  int ret = 0;
  while (res > 1) {
    res /= 2;
    ret ++;
  }
  printf("%d\n", ret);
}


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

#define f first
#define s second
 
using namespace std;

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

const ll N = 1e5 + 3;

ll n, m, res;
pll a[N];
 
int main() {
	cin >> n >> m;
	for (ll i = 1; i <= n; ++i) cin >> a[i].f >> a[i].s;
	
	sort(a+1, a+1 + n);

	for (ll i = 1; i <= n && m; ++i) {
		ll tmp = min(m, a[i].s);
		res += tmp * a[i].f;
		m -= tmp;
	}
	cout << res;
	
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;
import java.lang.*;

import static java.lang.StrictMath.abs;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a + b >= c){
            System.out.println(b + c);


        }else {
            System.out.println(a+2*b+1);

        }

    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
	IOS;
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++) cout<<"x";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
using vc = vector<char>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  fix20;
  int n;
  cin >> n;
  vector<pair<double,double>> d(n);
  rep(i,n) cin >> d.at(i).first >> d.at(i).second;
  double sum = 0;
  vi dic(n);
  rep(i,n) dic.at(i) = i;
  double pos = 0;
  do{
    pos += 1.0;
    rep(i,n-1){
      int v = dic.at(i);
      int nv = dic.at(i+1);
      sum += sqrt((d.at(nv).first - d.at(v).first)*(d.at(nv).first - d.at(v).first) + (d.at(nv).second - d.at(v).second)*(d.at(nv).second - d.at(v).second));
    }

  }while(next_permutation(all(dic)));
  cout << sum / pos << endl;
}

Measured memory_bytes: 256