akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = (ll)1<<32;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;
int s;
map<int, bool>mp;
int main() {
	cin >> s;
	int c = 1;
	mp[s] = true;
	int now = s;
	while (true) {
		c++;
		if (s % 2)s = 3 * s + 1;
		else s /= 2;
		if (mp[s]) {
			cout << c << endl; break;
		}
		else mp[s] = true;
	}
	return 0;
}

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

using namespace std;

typedef pair<int, int> P;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {-1, 0, 1, 0};

int W, H;
int curl[22][22];
int ans;
P s;

bool inCurl(int x, int y)
{
  return (x >= 0 && y >= 0 && x < W && y < H);
}

void dfs(int x, int y, int n)
{
  if (n >= ans)
    return;

  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];

    if (!inCurl(nx, ny))
      continue;
    if (curl[ny][nx] == 1) 
      continue;

    while (true) {
      if (curl[ny][nx] == 3) {
	ans = n;
	return;
      }
      nx += dx[i];
      ny += dy[i];
      
      if (!inCurl(nx, ny)) 
	break;

      if (curl[ny][nx] == 1) {
	curl[ny][nx] = 0;
	dfs(nx - dx[i], ny - dy[i], n + 1);
	curl[ny][nx] = 1;
	break;
      }
    }
  }
}

int main()
{
  while (cin >> W >> H, W && H) {
    // Input
    for (int y = 0; y < H; y++) 
      for (int x = 0; x < W; x++) {
	cin >> curl[y][x];
	if (curl[y][x] == 2) {
	  s.first = x;
	  s.second = y;
	  curl[y][x] = 0;
	}
      }

    ans = 11;
    dfs(s.first, s.second, 1);
    if (ans > 10)
      cout << -1 << endl;
    else
      cout << ans << endl;
  }

  return 0;
}

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

#define int long long


signed main(){
	
	int n,ans=1;
	cin>>n;
	vector<int>t;
	vector<int>a;
	vector<int>tf;
	vector<int>af;
	for(int i=0;i<n;i++){
		int tmp;
		cin>>tmp;
		t.push_back(tmp);
		tf.push_back(0);
	}
	for(int i=0;i<n;i++){
		int tmp;
		cin>>tmp;
		a.push_back(tmp);
		af.push_back(0);
	}
	for(int i=0;i<n;i++){
		if(i==0){
			tf[i]=1;
		}
		else if(t[i-1]<t[i] || t[i]==1){
			tf[i]=1;
		}
	}
	for(int i=n-1;i>=0;i--){
		if(i+1==n){
			af[i]=1;
		}
		else if(a[i]>a[i+1] || a[i]==1){
			af[i]=1;
		}
	}
	
	
	for(int i=0;i<n;i++){
		
		if(tf[i]&&af[i]&&(t[i]!=a[i])){
			cout<<0<<endl;
			return 0;
		}
		if(tf[i]&&t[i]>a[i]){
			cout<<0<<endl;
			return 0;
		}
		if(af[i]&&t[i]<a[i]){
			cout<<0<<endl;
			return 0;
		}
		
		if(tf[i]||af[i]){
			continue;
		}
		int h=min(a[i],t[i]);
		ans=ans*h%1000000007;
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}


Measured memory_bytes: 4204
#include <iostream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

vector<bool> seen(200010, false);
vector<vector<int>> tr(200010);
vector<long long> ans(200010, 0);

void dfs(int par, int cst) {
    seen[par] = true;
    ans[par] += cst;
    for (int i=0; i<tr[par].size(); i++) {
        if (seen[tr[par][i]] == false) {
            dfs(tr[par][i], ans[par]);
        }
    }
}

int main() {
    int N, Q;
    cin >> N >> Q;
    
    int a, b;
    for (int i=0; i<N-1; i++) {
        cin >> a >> b;
        a -= 1;
        b -= 1;
        tr[a].push_back(b);
        tr[b].push_back(a);
    }
    int p, x;
    for (int i=0; i<Q; i++) {
        cin >> p >> x;
        p -= 1;
        ans[p] += x;
    }
    
    dfs(0, 0);

    for (int i=0; i<N; i++) {
        cout << ans[i] << ' ';
    }

    return 0;
}

Measured memory_bytes: 24320
#include <iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  while(1){
    c -= b;
    if(c <= 0){
      cout << "Yes" << endl;
      return 0;
    }
    a -= d;
    if(a <= 0){
      cout << "No" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
#define int long long
#define EB emplace_back
#define MOD 1000000007
#define F first
#define S second
#define N 100005
#define endl "\n"
 
using namespace std; 

int dp[N+1][3];

int32_t main()
{
  
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int tt=1;

//    cin>>tt;
    
    while(tt--)
    {
      int n; cin>>n;
      int arr[n+1][3];
      
      for (int i = 0; i < n; ++i)
      {
          int a,b,c; cin>>a>>b>>c;
          arr[i][0] = a;
          arr[i][1] = b;
          arr[i][2] = c;
      }

          dp[0][0] = arr[0][0];
          dp[0][1] = arr[0][1];
          dp[0][2] = arr[0][2];

        for(int i=1;i<n;i++)
        {
            dp[i][0] = arr[i][0] + max(dp[i-1][1],dp[i-1][2]);
            dp[i][1] = arr[i][1] + max(dp[i-1][2],dp[i-1][0]);
            dp[i][2] = arr[i][2] + max(dp[i-1][0],dp[i-1][1]);
        }
        cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
       
    }
    return 0;
}







Measured memory_bytes: 4992
sa = input()
sb = input()
sc = input()

nex = sa[0]
sa = sa[1:]
    
while True:
    if nex == 'a':
        if sa != "":
            nex = sa[0]
            sa = sa[1:]
        else:
            ans = 'A'
            break
    elif nex == 'b':
        if sb != "":
            nex = sb[0]
            sb = sb[1:]
        else:
            ans = 'B'
            break
    elif nex == 'c':
        if sc != "":
            nex = sc[0]
            sc = sc[1:]
        else:
            ans = 'C'
            break
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>                                                                              
using namespace std;                                                                                  
using ll = long long;                                                                                 
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }               
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }               
                                                                                                      
int main() {                                                                                          
  int n;                                                                                              
  cin >> n;                                                                                           
  set<int> a;                                                                                         
  int v;                                                                                              
  bool ans = true;                                                                                    
  for (int i=0; i<n; i++) {                                                                           
    cin >> v;                                                                                         
    a.insert(v);                                                                                      
  }                                                                                                   
  if ((int)a.size() == n) {                                                                           
    cout << "YES" << endl;                                                                            
  } else {                                                                                            
    cout << "NO" << endl;                                                                             
  }                                                                                                   
                                                                                                      
  return 0;                                                                                           
}                                                                                                     
   

Measured memory_bytes: 9600
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

char S[200];

signed main()
{
	cin >> S;
	int len = strlen(S);
	bool is_good = true;
	for (int i = 0; i < len; i++)
	{
		if (i % 2 == 0)
		{
			if (S[i] == 'L')is_good = false;
		}
		else
		{
			if (S[i] == 'R')is_good = false;
		}
	}
	if (is_good)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}




Measured memory_bytes: 256
def getval():
    n = int(input())
    x = list(map(int,input().split()))
    return n,x 

def main(n,x):
    y = sorted(x)
    a,b = y[(n-1)//2],y[(n-1)//2+1]
    for i in x:
        if i>a:
            print(a)
        else:
            print(b)

if __name__=="__main__":
    n,x = getval()
    main(n,x)

Measured memory_bytes: 30696
int main(void){
  int i,j,n,tmp,x[100],count;

  while(1){
    scanf("%d",&n);
    if(!n) break;

    count=0;
    for(i=0;i<n;i++){
      scanf("%d",&x[i]);
    }
    for(i=n-1;i>0;i--){
      for(j=0;j<i;j++){
        if(x[j]>x[j+1]){
          count++;
          tmp = x[j];
          x[j] = x[j+1];
          x[j+1] = tmp;
        }
      }
    }
    printf("%d\n",count);
  }

  return 0;
}

Measured memory_bytes: 0
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)

i=0
arr=[]
while i<n-1:
    if a[i]==a[i+1]:
        arr.append(a[i])
        i+=2
    else:
        i+=1
    if len(arr)==2:
        print(arr[0]*arr[1])
        exit()
print(0)

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



int main() {
	int n;
    scanf("%d", &n);
    vector<int> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        a[i]--;
    }
    for (int i = 0; i < n; ++i) {
        b[a[i]] = i;
    }
    for (int i = 0; i < n; ++i)
        printf("%d ", b[i] + 1);
    printf("\n");
}


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

int main(){
    ll N; cin >> N;
    vector<string> S[5];
    for(int i = 0; i < N; i++){
        string tmps; cin >> tmps;
        if(tmps[0] == 'M') S[0].push_back(tmps);
        else if(tmps[0] == 'A') S[1].push_back(tmps);
        else if(tmps[0] == 'R') S[2].push_back(tmps);
        else if(tmps[0] == 'C') S[3].push_back(tmps);
        else if(tmps[0] == 'H') S[4].push_back(tmps);
    }
    ll num[5];
    for(int i = 0; i < 5; i++) num[i] = S[i].size();

    ll ans = 0;
    for(int i = 0; i < 5; i++){
        for(int j = i + 1; j < 5; j++){
            for(int k = j + 1; k < 5; k++){
                ans += num[i] * num[j] * num[k];
            }
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define vll vector<ll>
#define G vector<vll >
#define gg vector<int>
#define F first
#define S second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define RFOR(i,a,b) for(int i=a;i>=b;i--)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define endl '\n'
#define clr(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
#define rll read_ll();
#define gc getchar
#define pc putchar
typedef long long ll;
template<class T> inline T lcm(T a,T b){
        return a/gcd(a,b)*b;
}

template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
    out<<"[";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<",";out<<*it;}cout<<"]";
return out;}

template<typename T>
void debug(T first) {
    cout << first << "\n";
}
template<typename T, typename... Args>
void debug(T first, Args... args) {
    cout << first << " ";
    debug(args...);
}


ll read_ll(){char c=gc();while((c<'0'||c>'9')&&c!='-')c=gc();ll ret=0;int neg=0;if(c=='-')neg=1,c=gc();while(c>='0'&&c<='9'){ret=10*ret+c-48;c=gc();}return neg?-ret:ret;}


int main()
{
    ll n; cin>>n;
    multiset<ll>a;
    FOR(i,1,n) {
        ll val; cin>>val;
        a.insert(val);
    }
    ll A = *(a.rbegin());
    auto it = a.end(); it--; a.erase(it);
    vector<pll>ans;
    while(a.size() > 1) {
        multiset<ll>::iterator it = a.begin();
        ll mini = *it;
        a.erase(it);
        it = a.end(); --it;
        ll maxi = *it;
        a.erase(it);
        // if(mini < 0 && maxi > 0) swap(mini,maxi);
        if(maxi < 0 && mini < 0) {
            a.insert(maxi);
            a.insert(mini);
            break;
        }
        a.insert(mini-maxi);
        ans.pb({mini,maxi});
    }
    while(a.size()>0) {
        ans.pb({A,*(a.begin())});
        A = A-*(a.begin());
        auto it = a.begin();
        a.erase(it);
    }
    debug(A);
    for(auto v : ans) debug(v.F,v.S);

    return 0;
}

Measured memory_bytes: 8688
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)

int main(){
    int N;
    cin >> N;
    vector<int> p(N);
    int sum = 0;
    int half = 0;
    rep(i,0,N){
        cin >> p[i];
        half= max(half, p[i]);
        sum += p[i];
    }
    cout << sum - half/2 << endl;

}

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

int main(){
    ll n,k; cin >> n>> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    int left = 0, right = *max_element(a.begin(), a.end());
    while(left+1<right){
        int cut = 0;
        int m = (left+right)/2;
        //cout<< "m="<<m << endl;
        rep(i, n){
            cut += (a[i]+m-1)/m-1;
            if(cut > k) break;
        }
        //cout << "cut="<<cut << endl;
        if(cut > k) left = m;
        else right = m;
    }
    cout << right << endl;
}


Measured memory_bytes: 4808
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>

#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v){
    if(!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}
//---------


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    //CLion Standard Input for DEBUG
    //--------------------------------------------------------------------------
//    ifstream in("/Users/ryo/Dropbox/competition/CompetitivePrograming/in.txt");
//    cin.rdbuf(in.rdbuf());
    //-------------------------------------------------------------------------

    int n;
    cin >> n;
    cout << 800 * n  - 200 * (n / 15)<< endl;

}

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

int main(){
    int n; ll sum=0;
    vector<ll> a,num;
    cin >> n;
    for(int ix=0;ix<n;ix++){
        int tmp; cin >> tmp;
        a.push_back(tmp);
        sum += tmp;
        num.push_back(sum);
    }
    ll ans = 90000000000;
    for(int ix=0;ix<n-1;ix++){
        ll tmp = abs(sum - num.at(ix) - num.at(ix));
        ans = min(tmp,ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		
		int D = in.nextInt();
		
		int T = in.nextInt();
		int S = in.nextInt();
		
		if(D<= T * S) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}

	}

}


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

int main(void){
    int i, N;
    double *X, ANS=0.0;
    char U[11][5];
    scanf("%d", &N);
    if((X=malloc(sizeof(double)*N)) == NULL) exit(1);
    for(i=0; i<N; i++){
        scanf("%lf %s", X+i, U[i]);
        if(strcmp("JPY", U[i]) == 0) ANS += X[i];
        else ANS += X[i]*380000;
    }
    printf("%lf\n", ANS);
    free(X);
    return 0;
}


Measured memory_bytes: 128
//情報オリンピック2010予選問４「一年生」
#include<stdio.h>

long long c[21];
int j[100];
int n;

void ck(int);

int main(void){

	int f1;
	long long out;

	scanf("%d",&n);

	for(f1 = 0; f1 < n; f1++)
		scanf("%d",&j[f1]);

	for(f1 = 0; f1 < 21; f1++)
		c[f1] = 0;

	c[ j[0] ] = 1;

	ck(1);

	out = c[ j[n-1] ];

	printf("%lld\n",out);

	return 0;
}
void ck(int cnt){

	int fs1, wa, sa;
	long long cl2[21];

	if(cnt < n-1){

		for(fs1 = 0; fs1 < 21; fs1++)
			cl2[fs1] = 0;

		for(fs1 = 0; fs1 < 21; fs1++){
			if(c[fs1] > 0){
				wa = fs1 + j[cnt];
				sa = fs1 - j[cnt];
				if(wa <= 20)
					cl2[wa] += c[fs1];
				
				if(sa >= 0)
					cl2[sa] += c[fs1];
			}
		}

		for(fs1 = 0; fs1 < 21; fs1++)
			c[fs1] = cl2[fs1];

		ck(cnt+1);
	}
}

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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll x1 = 0;
    int code = 1;
    rep(i,n) {
        x1 += a[i] * code;
        code *= -1;
    }
    vector<ll> ans(n);
    ans[0] = x1;
    for (int i = 1; i < n; i++) {
        ans[i] = 2 * a[i-1] - ans[i-1];
    }
    rep(i,ans.size()) {
        printf("%d%c", ans[i], i+1==ans.size()?'\n':' ');
    }
    return 0;
}


Measured memory_bytes: 4704
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

struct Point {
  double x;
  double y;
};

double dot(Point a, Point b) {
  return a.x * b.x + a.y * b.y;
}

Point vector_sub(Point a, Point b) {
  Point c;
  c.x = b.x - a.x;
  c.y = b.y - a.y;
  return c;
}

double distance2(Point a, Point b) {
  return pow(a.x - b.x, 2) + pow(a.y - b.y, 2);
}

Point projection_vector(Point p0, Point p1, Point p2) {
  Point pv;
  Point v10 = vector_sub(p1, p0);
  Point v12 = vector_sub(p1, p2);
  double aNorm2 = distance2(p1, p2);
  double k = dot(v10, v12) / aNorm2;
  pv.x = k * v12.x;
  pv.y = k * v12.y;
  return pv;
}

Point reflect_vector(Point p0, Point p1, Point p2) {
  Point pv = projection_vector(p0, p1, p2);
  Point v10 = vector_sub(p1, p0);
  return vector_sub(v10, pv);
}

int main(void) {
  Point p0,p1,p2;
  Point v10;
  Point pv;
  int q;
  cin >> p1.x >> p1.y >> p2.x >> p2.y;
  cin >> q;

  for(int i = 0; i < q; i++) {
    cin >> p0.x >> p0.y;
    Point rv = reflect_vector(p0, p1, p2);
    rv.x *= 2;
    rv.y *= 2;
    //printf("%.10lf %.10lf\n", p1.x + projection_vector(p0, p1, p2).x, p1.y + projection_vector(p0, p1, p2).y);
    printf("%.10lf %.10lf\n", p0.x + rv.x, p0.y + rv.y);
  }

}


Measured memory_bytes: 3292
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>




int main()
{
	int N, a[200000],i,j;

	scanf("%d", &N);

	for (i = 0; i < N; i++) scanf("%d", &a[i]);

	int max = 0;

	for (i = 0; i < N; i++) {

		if (a[i] > max) {
			max = a[i];
			j = i;
		}
	}

	int max2 = 0;

	for (i = 0; i < N; i++) {

		if (a[i] > max2 && i!=j) {
			max2 = a[i];
			
		}
	}


	for (i = 0; i < N; i++) {

		if (i == j) {
			printf("%d\n", max2);

		}else printf("%d\n", max);
	}

}







Measured memory_bytes: 2304
#include<stdio.h>
#include<math.h>
int a(int );
int main(){
  int i,number,kai=0,x;
  scanf("%d",&number);
  for(i=0;i<number;i++){
    scanf("%d",&x);
    kai+=a(x);
  }
  printf("%d\n",kai);
}
int a(int num){
  int kai=0;
  int i;
  double sqrtNum;
  if (num < 2) return 0;
  else if (num==2)return 1;
  else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く
  sqrtNum = sqrt(num);
  for (i = 3; i <= sqrtNum; i += 2)
    {
      if (num % i == 0)
        {
	  // 素数ではない
	  return 0;
        }
    }

  // 素数である
  return 1;
}



Measured memory_bytes: 2688
import java.util.Scanner;

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

		if (N == 1) {
			System.out.println("Hello World");
		} else {
			int A = sc.nextInt();
			int B = sc.nextInt();
			sc.close();
			System.out.println(A + B);
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
const int N = 1000300;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;

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


int n;
cin>>n;
double d[n];
rep(i,0,n)
cin>>d[i];
double x=0.00;
rep(i,0,n)
{
	x+=1.0*(1/d[i]);
}
x=1.0*(1/x);
cout<<setprecision(15)<<x;
}

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

// Prime Numbers

bool isprime(int x){
    if (x == 2) return true;
    if (x < 2 || x % 2 == 0) return false;
    int i = 3;
    while(i*i <= x){
        if (x % i == 0){
            return false;
        }
        i = i + 2;
    }
    return true;
}

int main(){
    int N;
    cin >> N;
    int ans = 0;
    int t;
    REP(i,N){
        cin >> t;
        if(isprime(t)) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3092
n = int(input())
s = input().rstrip()


def check(length):
    d = set()
    for i in range(n - 2 * length + 1):
        d.add(s[i:i + length])
        if s[i + length:i + 2 * length] in d:
            return True
    return False


lo = 0
hi = n // 2 + 1
while lo + 1 < hi:
    mid = (lo + hi) // 2
    if check(mid):
        lo = mid
    else:
        hi = mid
print(lo)

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

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

inline bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
inline bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
    int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
    return x * fh;
}

void File() {
#ifdef zjp_shadow
	freopen ("E.in", "r", stdin);
	freopen ("E.out", "w", stdout);
#endif
}

const int N = 310, Mod = 1e9 + 7;

int dp[N][N][N];

inline int Add(int a, int b) {
	return ((a += b) >= Mod) ? a - Mod : a;
}

int n, m;
typedef pair<int, int> PII;
#define fir first
#define sec second
#define mp make_pair
vector<PII> V[N];

int main () {

	File();

	n = read(); m = read();

	For (i, 1, m) { int l = read(), r = read(), x = read(); V[r].push_back(mp(l, x)); }

	dp[0][0][0] = 1;
	int ans = 0;
	For (i, 0, n) For (j, 0, i) For(k, 0, i) {
		if (!dp[i][j][k]) continue ;
		for (PII lim : V[i]) {
			int l = lim.fir, x = lim.sec, times = 1;
			if (l <= j) ++ times;
			if (l <= k) ++ times;
			if (times != x) { dp[i][j][k] = 0; break; }
		}
		if (!dp[i][j][k]) continue ;
		if (i == n) { ans = Add(ans, dp[i][j][k]); continue ; }
		dp[i + 1][i][k] = Add(dp[i + 1][i][k], dp[i][j][k]);
		dp[i + 1][i][j] = Add(dp[i + 1][i][j], dp[i][j][k]);
		dp[i + 1][j][k] = Add(dp[i + 1][j][k], dp[i][j][k]);
	}
	printf ("%d\n", ans);

    return 0;
}


Measured memory_bytes: 112896
#include<bits/stdc++.h>
using namespace std;
int main(){
	int A,B,C,D,a1,a2,a;
	scanf("%d%d%d%d",&A,&B,&C,&D);
	a1=A*B;
	a2=C*D;
	if(a1==a2)
	printf("%d",a1);
	else
	printf("%d",max(a1,a2));
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif
const int N = 405;
int n;
int a[N];
int dp[N][N];
int solve(int i,int j){
    if(i == j) return 0;

    int &ans = dp[i][j];
    if(ans != -1) return ans;
    int res = 1e18;
    for(int k=i;k<j;k++){
        int x1,x2;
        x1 = 0;
        x2 = 0;
        int cur = 0;
        // partition at x;
        for(int get=i;get<=k;get++){
            x1 += a[get];
        }
        for(int get=k+1;get<=j;get++){
            x2 += a[get];
        }
        cur += x1 + x2;
        cur += solve(i,k);
        cur += solve(k+1,j);
        res = min(res,cur);
    }
    return ans = res;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,n-1)<<endl;
    
    return 0;
    
}



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

unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
int main(){
  int a, b;
  cin >> a >> b;
  for(int i = 0; i < GetDigit(b);i++)a *= 10;
  bool root = false;
  for(int i = 0; i < (a + b)/2; i++)if(i*i == a + b)root = true;
  string ans = (root == true)? "Yes": "No";
  cout << ans << endl;
}


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	rep(i, 5){
		int x;
		cin >> x;

		if(x == 0){
			cout << i + 1;
			return 0;
		}
	}
	
	return 0;
}

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


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,x;cin>>n>>x;
    ll d=0,i=1;
    while(d<=x&&i<=n){
        ll l;cin>>l;
        d+=l;
        if(d<=x)i++;
    }
    cout<<i<<endl;
    return 0;
}

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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll N, ans;
    string S;
    cin >> S;
    ans = 0;
    N = S.size();
    REP(int,i,0,N/2){
        if ( S.at(i) != S.at(N-i-1)) ans++;
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int o = 0;
  for(int i = 0; i < s.length(); i++)
    if(i)
      if(s[i - 1] != s[i])
        o++;
  cout << o << endl;
}

Measured memory_bytes: 512
n,m = map(int,input().split(" "))
a = list(map(int,input().split(" ")))
a = sorted(a)
v = []
for i in range(m):
    tmp = list(map(int,input().split(" ")))
    v.append(tmp)
v = sorted(v,key = lambda x:x[0])
v = sorted(v,key = lambda x:x[1],reverse= True)
sum = 0
j = 0
i = 0

while (i < n):
    if j < len(v) and v[j][1] > a[i] and v[j][0] > 0:
        sum += v[j][1]
        v[j][0] -= 1
        i += 1
    elif j < len(v):
        j += 1
    else:
        sum += a[i]
        i += 1

print(sum)

Measured memory_bytes: 33732
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);
    
    public static void main(String[] args) throws Exception {
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] x = new long[n];
        for(int i = 0; i < n; ++i) x[i] = sc.nextLong();
        
        long ans = Long.MAX_VALUE;
        for(int i = k - 1; i < n; ++i) {
            long lr = Math.abs(x[i - k + 1]) + Math.abs(x[i - k + 1] - x[i]);
            long rl = Math.abs(x[i]) + Math.abs(x[i - k + 1] - x[i]);
            ans = Math.min(ans, Math.min(lr, rl));
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 49800
#include <bits/stdc++.h>
#define int long long
#define rep(a,b) for(int (a)=0; (a)<(int)(b); ++(a))
#define all(a) (a).begin(),(a).end()
#define sel(a,b,c) (a).begin()+(b),(a).begin()+(b)+(c)
#define prec(a) fixed<<setprecision(a)
using namespace std;

constexpr int MOD=1000000007;
using ull=unsigned long long;
template<typename T>
using vec=vector<T>;
template<typename T>
using dvec=vector<vec<T>>;
using pint=pair<int,int>;

void print(void){cout<<"\n";}

template<class HEAD,class... TAIL>
void print(HEAD&& head,TAIL&&... tail){
  cout<<head<<" ";
  print(forward<TAIL>(tail)...);
}

template<typename T,typename U,class... TAIL>
void print(pair<T,U> p,TAIL&&... tail){
  cout<<p.first<<" "<<p.second<<" ";
  print(forward<TAIL>(tail)...);
}

signed main(void){
  ull X,Y; cin>>X>>Y;
  int mul=Y/X;
  int tmp=1,ans=0;
  while(tmp<=mul) tmp*=2,++ans;
  cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<P,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<v<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

#define MAX 200003
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void fact() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; ++i){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long comb(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll N;

vector<vector<ll>> G(200001, vector<ll>(0));

Map dp,dp2;

ll R(P par){
    if(dp2[par])return dp2[par];
    ll x=par.first;
    ll y=par.second;
    if(dp2[P(y,x)])return dp2[par]=N-dp2[P(y,x)];
    if(x==0)return 0;
    ll ret=1;
    for(auto p: G[x])if(p!=y)ret+=R(P(p,x));
    return dp2[par]=ret;
}

ll F(P par){
    if(dp[par])return dp[par];
    ll x=par.first;
    ll y=par.second;
    ll ret=1;
    ll sum=N-1-R(P(y,x));
    for(auto p: G[x]){
        if(p==y)continue;
        ll t=R(P(p,x));
        ret*=comb(sum,t);
        sum-=t;
        ret%=MOD;
    }
    for(auto p: G[x]){
        if(p==y)continue;
        ret*=F(P(p,x));
        ret%=MOD;
    }
    return dp[par]=ret;

}


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    fact();
    cin >> N;
    vector<ll> A(N-1,0);
    vector<ll> B(N-1,0);
    for(ll i=0;i<N-1;++i)cin>>A[i]>>B[i];
    for(ll i=0;i<N-1;++i){
        G[A[i]].emplace_back(B[i]);
        G[B[i]].emplace_back(A[i]);
    }
    map<ll,ll> M;
    for(ll i=1;i<=N;++i)M[G[i].size()]++;

    //ウニ対策
    if(M[N-1]){
        for(ll i=1;i<=N;++i){
            if(G[i].size()==1)prt(fac[N-2])
            else prt(fac[N-1])
        }
        return 0;
    }


    for(ll i=1;i<=N;++i)prt(F(P(i,0)))


    return 0;
}


Measured memory_bytes: 109696
import sys
input = sys.stdin.buffer.readline

N = int(input())
A, B = [], []
for i in range(N):
    _a, _b = map(int, (input().split()))
    A.append(_a); B.append(_b)
A.sort(); B.sort()

if N%2:     # 奇数
    ans = B[N//2] - A[N//2] + 1
else:       # 偶数
    ans = (B[N//2] + B[N//2-1]) - (A[N//2] + A[N//2-1]) + 1
print(ans)

Measured memory_bytes: 25604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		 //sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    int N;
    cin>>N;
    int ans = N*N*N;
    
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/







int N;
//---------------------------------------------------------------------------------------------------
int memo[101010];
int f(int cu) {
    if (cu == 0) return 0;
    if (memo[cu]) return memo[cu];

    int res = inf;
    
    // 1yen
    chmin(res, f(cu - 1) + 1);

    // 6yen
    int x = 6;
    while (x <= cu) {
        chmin(res, f(cu - x) + 1);
        x *= 6;
    }

    // 9yen
    x = 9;
    while (x <= cu) {
        chmin(res, f(cu - x) + 1);
        x *= 9;
    }

    return memo[cu] = res;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    cout << f(N) << endl;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(long long N, std::vector<std::string> S){
  set<string> h;
  for (int i = 0; i < N; i++) {
    h.insert(S[i]);
  }
  cout << (h.size() == 3?"Three":"Four") << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
}


Measured memory_bytes: 256
x, y = [int(i) for i in input().split()]
if abs(x) < abs(y):
    if x >= 0 and y > 0:
        print(y - x)
    elif x < 0 and y < 0:
        print(abs(y) - abs(x) + 2)
    else:
        print(abs(y) - abs(x) + 1)
else:
    if x < 0 and y <= 0:
        print(y - x)
    elif x > 0 and y > 0:
        print(abs(x) - abs(y) + 2)
    else:
        print(abs(x) - abs(y) + 1)


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



int next_combitantion(int sub){
    int x=sub & -sub,y= sub+x;
    return (((sub&~y)/x)>>1)|y;
    
    
}

bool bitget(int a,int b){
  return a&1<<b;
}


int main(){
    int N,K;
    cin >> N >> K;
    vector<long long> A(N);
    for(long long &i:A)cin >> i;
    
    long long minc=numeric_limits<long long>::max();
    
    //for(int i=(1<<K)-1;i<(1<<N);i=next_combitantion(i)){
    for(int i=(1<<K)-1;i<(1<<N);i++){
        long long dis=0;
        long long pre=0;
        int co=0;
        for(int j=0;j<N;j++){
            
            if(bitget(i, j)){
                co++;
                if(A[j]<=pre){
                    dis+=pre-A[j]+1;
                    pre++;
                }else{
                    pre=max(pre,A[j]);
                }
                if(co==K)break;
            }else{
                
                pre=max(pre,A[j]);
               
            }
            
            
        }
        
        if(co>=K)minc=min(minc,dis);
        
    }
    
    cout << minc << endl;
    
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  vector<long long> vec(n);
  long long sum=0;
  rep(i,n){
    cin >> vec.at(i);
    sum+=vec.at(i);
  }
  long long p=vec.at(0),ans=1e10;
  if(n==2){
    cout << abs(vec.at(n-1)-p);
    return 0;
  }
  for(int i=1;i<n-1;i++){
    long long q=sum-p;
    ans=min(ans,abs(p-q));
    p+=vec.at(i);
  }
  cout <<ans;
}

Measured memory_bytes: 1792
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion

vector<bool> toN(200101);
int n;
vector<vector<int>> v(200101);
vector<int> roadToN;

bool istoN(int now, int p)
{
	if (now == n - 1)return toN[n - 1];
	for (int next : v[now])
	{
		if (next == p)continue;
		toN[now] = (toN[now] || istoN(next, now));
	}
	if (toN[now])roadToN.push_back(now);
	return toN[now];
}

int main()
{
	cin >> n;
	rep(i, n - 1)
	{
		int a, b; cin >> a >> b;
		--a, --b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	toN[n - 1] = true;
	istoN(0, -1);
	reverse(all(roadToN));
	int midPoint = roadToN[roadToN.size() / 2];
	vector<bool> counted(n);
	counted[n - 1] = true;
	int snuke = 1;
	queue<int> q;
	q.push(n - 1);
	while (!q.empty())
	{
		int now = q.front();
		q.pop();
		for (int next : v[now])
		{
			if (counted[next] || next == midPoint)continue;
			++snuke;
			counted[next] = true;
			q.push(next);
		}
	}
	if (snuke >= n - snuke)cout << "Snuke" << endl;
	else cout << "Fennec" << endl;
}

Measured memory_bytes: 14972
import itertools
n=int(input())
towns=[list(map(int,input().split())) for i in range(n)]
ite=[i for i in range(n)]
ans=0
for i in itertools.permutations(ite):
  for j in range(n-1):
    ans+=(((towns[i[j+1]][1]-towns[i[j]][1])**2+(towns[i[j+1]][0]-towns[i[j]][0])**2)**0.5)
div=1
for i in range(1,n+1):
  div*=i
print(ans/div)

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

struct Edge{
  int to;
  long long cost;
};
struct NODE{
  int pos;
  long long cost;
};
bool operator < (const NODE &a,const NODE &b){
  return a.cost > b.cost;
}
class Prim{
  public:
  const int MAX_V = 1000000;
  vector<Edge> g[100000],rg[100000];
  //inf??§?????????
  ll mincost[100000];
  bool used[100000];
  ll V;
  Prim(){};
  Prim(ll n):V(n){};
  ll MST(){
    ll res = 0;
    for(ll i = 0; i < V; ++i){
      mincost[i] = inf;
      used[i] = false;
    }
    priority_queue<NODE> q;
    q.push({0,0});
    while(q.size()){
      auto v = q.top();q.pop();
      if(mincost[v.pos] == inf){
        mincost[v.pos] = v.cost;
        res += v.cost;
        for(auto n : g[v.pos]){
          q.push({n.to,n.cost});
        }
      }
    }
    return res;
  }
  void push(int p,int to,int c){
    g[p].push_back({to,c});
    rg[to].push_back({p,c});
  }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll v,e,a,b,c;
  cin >> v >> e;
  Prim p(v);
  rep(i,e){
    cin >> a >> b >> c;
    p.push(a,b,c);
    p.push(b,a,c);
  }
  cout << p.MST() << endl;
  return 0;
}

Measured memory_bytes: 21980
/*siddharth goyal*/
#include<bits/stdc++.h>
using namespace std;
#define   pb              push_back
#define   REP(i,n)        for(i=1;i<=n;i++)
#define   FOR(i,a,b)      for(i=a;i<=b;i++)
#define   all(v)          v.begin(),v.end()
#define   F               first
#define   S               second
#define   vl              vector<LL>
#define   itr             ::iterator it
#define   lb              lower_bound
#define   ub              upper_bound
#define   LL              long long
#define   ULL             unsigned long long
#define   ret             return 
LL n,i,j,ans = 0;
long double a[1000000] ; 
int main()
{   // Read the constraints,highlights,Time Limit,Test Cases
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n ; 
    long double sum = 0 ;
    cout<<fixed<<setprecision(15) ; 
    REP(i,n) cin>>a[i],sum+=a[i] ; 
    long double avg = sum/n ; 
    long double Max = INT_MAX;
    vector <pair<long double,LL> >v ;  
    for(i=1;i<=n;i++) 
    {   v.pb({abs(avg-a[i]),i-1}) ;    

    }
    sort(all(v))  ; 
    ans = v[0].S ; 
    //cout<<ans<<endl; 
    //for(auto i:v) 
      //cout<<i.F<<" "<<i.S<<endl;
    for(i=1;i<v.size();i++)
    {  if(v[i].F==v[0].F and v[i].S<ans)
              ans = v[i].S ; 
              
    }
    ret cout<<ans,0 ; 

}
//Check for 0,1 and other corner cases.

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

int H, W;
string f[51];
int dx[] = { 1, 1, 1, 0, -1, -1, -1, 0 };
int dy[] = { 1, 0, -1, -1, -1, 0, 1, 1 };

int main() {
    cin >> H >> W;
    rep(y, H) cin >> f[y];
    rep(y, H) {
        rep(x, W) {
            if (f[y][x] == '#') cout << '#';
            else {
                int ans = 0;
                rep(d, 8) {
                    int nx = x + dx[d], ny = y + dy[d];
                    if (0 <= nx and nx < W and 0 <= ny and ny < H) {
                        if (f[ny][nx] == '#') ans++;
                    }
                }
                cout << ans;
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll a, b;std::cin >> a;std::cin >> b;
  set<ll> s;
  s.insert(1);s.insert(2);s.insert(3);
  s.erase(a);
  s.erase(b);
  std::cout << *s.begin() << '\n';
  return 0;
}


Measured memory_bytes: 888
#include<cstdio>
#include<map>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>

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

using namespace std;

int main(){
        int a,n;cin>>n;
        vector<int> v;
        REP(i,n){
                cin >> a;v.push_back(a);
        }
        sort(v.begin(),v.end());
        int ans = v.back()-v.front();
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 256
from sys import stdin, stdout
import math,sys
from itertools import permutations, combinations
from collections import defaultdict,deque,OrderedDict
import bisect as bi
import heapq 

'''
#------------------PYPY FAst I/o--------------------------------#
 
def I():return (int(stdin.readline()))
def In():return(map(int,stdin.readline().split()))
'''
#------------------Sublime--------------------------------------#
 
#sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');
def I():return (int(input()))
def In():return(map(int,input().split()))



def main():
    try:
        a=list(input())
        b=list(input())
        temp=b.pop()
        if a==b:
            print('Yes')
        else:
            print('No')
    except:
        pass
        
M = 998244353
P = 1000000007
 
if __name__ == '__main__':
    for _ in range(1):
        main()

Measured memory_bytes: 9424
from operator import itemgetter
n=int(input())
XYH=[tuple(map(int,input().split())) for i in range(n)]
XYH.sort(key=itemgetter(2),reverse=True)
for cy in range(101):
    for cx in range(101):
        hc=XYH[0][2]+abs(cx-XYH[0][0])+abs(cy-XYH[0][1])
        for x,y,h in XYH[1:]:
            if h!=max(0,hc-abs(x-cx)-abs(y-cy)):
                break
        else:
            print(cx,cy,hc)

Measured memory_bytes: 3064