akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

int main() {
    int N;
    cin >> N;
    int draw[] = {
        6,
        36,
        216,
        1296,
        7776,
        46656,
        9,
        81,
        729,
        6561,
        59049
    };

    int dp[100009] = {};
    for (int i = 1; i <= N; i++) {
        int min_x = dp[i-1] + 1;
        for (int j = 0; j < 11; j++) {
            if (i - draw[j] >= 0) {
                min_x = min(dp[i - draw[j]] + 1, min_x);
            }
        }
        dp[i] = min_x;
    }
    cout << dp[N] << endl;
}


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

int main() {
  string S;
  cin >> S;
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

using namespace std;

const int MAX_N = 1e5 + 5;
const long long M = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;

long long mod(long long x){
        return ((x%M + M)%M);
    }
long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }


int solve(vector <int> arr, int n) {
    vector <ll> pref(n+1);
    for(int i=n-1;i>=0;i--){
        pref[i]=pref[i+1]+arr[i];
    }

    ll ans=0;
    for(int i=0;i<n;i++){
        ans=add(ans,mul(arr[i],pref[i+1]));
    }
    return ans;
   
    
}

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

    #ifndef ONLINE_JUDGE
        freopen("inputcpp.txt", "r", stdin);
        freopen("outputcpp.txt", "w", stdout);
    #endif

    int n;
    cin>>n;
    vector <int> arr(n);
    for (int i=0;i<n;i++){
        cin>>arr[i];
    }
    cout<<solve(arr,n)<<endl;
    
    
}

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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read() 	        freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n) 	        scanf("%d",&n)
#define sfc(n)          scanf(" %c",&n)
#define sfd(n)          scanf("%lf",&n)
#define sfl(n) 	        scanf("%lld", &n)
#define ll              long long
#define endll           pf("\n")
#define pf              printf
#define inf 1999999999
#define mod 1000000007
#define var    int n,ii=1,i,j,k,m,z=0,c=0,t,x,y,l,r,mid

int main()
{
    var;
    cin>>n;z=INT_MAX;
    for(i=1;i<n;i++)
    {
        x=i,y=n-i;
        c=0;
        while(x)
        {
            c+=(x%10);
            x/=10;
        }
        while(y)
        {
            c+=(y%10);
            y/=10;
        }
        z=min(z,c);
    }
    cout<<z<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define E 1e-6;
void open()
{
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
}

int main()
{
    int x,n;
    while(~scanf("%d",&n))
    {
        int num_4=0,num_2=0,num_1=0;
        rep(i,0,n){
            scanf("%d",&x);
            if(x%4==0)
            {
                num_4++;
                continue;
            }
            if(x%2==0)
            {
                num_2++;
                continue;
            }
            num_1++;
        }
        if(2*num_4+1>=n)
        {
            puts("Yes");
            continue;
        }
        if(num_1>num_4)
        {
            puts("No");
            continue;
        }
        puts("Yes");
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    ll n,m,k; cin >> n >> m >> k;

    vector<vector<ll>> fr(n,vector<ll>(0));
    vector<vector<ll>> bl(n,vector<ll>(0));

    rep(i,m){
        //fr
        ll a,b; cin >> a >> b;
        a--; b--;
        fr.at(a).push_back(b);
        fr.at(b).push_back(a);
    }

    rep(i,k){
        //bl
        ll c,d; cin >> c >> d;
        c--; d--;
        bl.at(c).push_back(d);
        bl.at(d).push_back(c);     
    }

    vector<ll> cls(n,-1);

    vector<ll> ans(n,0);
    ll groupnum = 0;
    for(int i=0;i<n;i++){
        if(cls.at(i)!=-1) continue;        
        queue<ll> q;
        vector<ll> s2(0);
        cls.at(i) = groupnum;
        s2.push_back(i);
        q.push(i);
        while(q.size()){
            ll x = q.front();
            q.pop();
            for(auto y:fr.at(x)){
                if(cls.at(y)!=-1) continue;
                s2.push_back(y);
                q.push(y);
                cls.at(y) = groupnum;
            }
        }
      
        
        //for(auto y:s2) cout << y << " "; cout << endl;
        
        for(auto y:s2){
            ll count = 0;
            ll ygroup = cls.at(y);
            for(auto ff:fr.at(y)){
                if(cls.at(ff)==ygroup) count++;
            }
            for(auto bb:bl.at(y)){
                if(cls.at(bb)==ygroup) count++;
            }
            ans.at(y) = (ll)s2.size() - 1 - count;            
        }
        groupnum++;
    }

    rep(i,n){
        cout << ans.at(i) << endl;
    }
}


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

int main()
{
    string s, t;
    cin >> s >> t;
    vector<int> tiv;
    bool found = false;
    for(int i=0; i<s.size(); i++){
        if(s[i] == t[0] || s[i] == '?'){
            int ci = i;
            int cj = 0;
            while(s[ci] == t[cj] || s[ci] == '?'){
                if(cj == t.size()-1){
                    tiv.push_back(i);
                    found = true;
                    break;
                }
                if(ci == s.size()-1){
                    break;
                }
                ci++;
                cj++;
            }
        }
    }
    
    if(found){
        for(auto &c: s){
            if(c == '?') c = 'a';
        }
        vector<string> v;
        for(auto ti: tiv){
            v.push_back(s.substr(0, ti) + t + s.substr(ti+t.size()) );
        }
        sort(v.begin(), v.end());
        cout << v[0] << endl;
    }else{
        cout << " UNRESTORABLE" << endl;
    }  
    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
import std.concurrency;
void times(alias fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}
// fold was added in D 2.071.0.
template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
        static if (S.length < 2) {
            return reduce!fun(seed, r);
        } else {
            return reduce!fun(tuple(seed), r);
        }
    }
}

long INF = long.max/3;
void main() {
    int N, T;
    readf("%d %d\n", &N, &T);

    (new std.concurrency.Generator!long({
        long[] A = readln.split.to!(long[]);
        long m = INF;
        foreach(i; 0..N) {
            (A[i]-m).yield;
            m = min(m, A[i]);
        }
    })).take(N).array.pipe!(ary =>
        ary.count(ary.reduce!max)
    ).writeln;

}


Measured memory_bytes: 4404
from math import cos, pi

A,B,H,M = map(int, input().split())

total_time = H * 60 + M

theta = float(abs(total_time / 2 - M * 6) * pi / 180)

c = pow(A ** 2 + B ** 2 - 2 * A * B * cos(theta), 1/2)

print(c)

Measured memory_bytes: 9396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i, n) for(int i=((int)(n));i>0;i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	int N;
	cin >> N;
	set<int> M;
	rep(i, N){
		int D;
		cin >> D;
		M.insert(D);
	}
	cout << M.size() << endl;
}

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

int main(void){
  int n;
  cin >> n;
  int buf[n];
  for(int i = 0;i < n; i++)
    scanf("%d", &buf[i]);

  
  int height = buf[0];
  int num = 1;
  for(int i=1;i<n;i++){
    if(height <= buf[i]){
      height = buf[i];
      num +=1;
    }   
  }
  cout << num <<endl;
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define inf (ll)1e15
#define maxn 200005
using namespace std;
typedef long long ll;
int n,a[maxn];
ll sum[maxn],ans = inf;
ll getsum(int l,int r){
	if(l > r) return 0;
	return sum[r] - sum[l-1];
}
int check(int l,int r){
	int lb = l,rb = r-1;
	while(lb < rb){
		int mid = (lb + rb + 1) >> 1;
		if(getsum(l,mid) < getsum(mid+1,r)) lb = mid;
		else rb = mid - 1;
	}
	if(lb == r-1) return lb;
	ll res1 = abs(getsum(l,lb) - getsum(lb+1,r));
	ll res2 = abs(getsum(l,lb+1) - getsum(lb+2,r));
	if(res1 < res2) return lb;
	else return lb+1;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sum[i] = sum[i-1] + a[i];
	}
	for(int mid = 2;mid <= n-2;mid++){
		ll suml = sum[mid],sumr = sum[n] - sum[mid];
		int fir = check(1,mid),thi = check(mid+1,n);
		ll maxi = max(max(getsum(1,fir),getsum(fir+1,mid)),max(getsum(mid+1,thi),getsum(thi+1,n)));
		ll mini = min(min(getsum(1,fir),getsum(fir+1,mid)),min(getsum(mid+1,thi),getsum(thi+1,n)));
		ans = min(ans,maxi - mini);
	}
	printf("%lld\n",ans);
	return 0;
}


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


int main(){
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	if (c - e<0 || c + e>a || d - e<0 || d + e>b) {
		cout << "No" << endl;
		return 0;
	}
	else {
		cout << "Yes" << endl;
		return 0;
	}
}


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

#define MAX_INPUT_SIZE  1024

int
main(int argc, char* argv[])
{
    char input[MAX_INPUT_SIZE];

    int n = atoi(fgets(input, sizeof(input), stdin));
    int ret = n * n * n;

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

    return 0;
}

Measured memory_bytes: 956
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,t,i;
  cin >> a >> b >> c;
  for(i=1;i<=b;i++){
    t=a*i%b;
    if(t==c){
      cout << "YES" << endl;
      return 0;
    }
    if(t==0)
      break;
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3608
# coding: utf-8
# Your code here!

while True:
    H, W = map(int,input().split())
    if H == 0 and W == 0 :
        break
    
    for i in range(H):
        for j in range(W):
            if i==0 or i==H-1 or j==0 or j==W-1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


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

int main()
{
	int tanku[5] = { 5,7,5,7,7 };

	while (true) {
		int n;
		cin >> n;

		if (n == 0) {
			break;
		}

		vector<string> strings(n);

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

		int ans;

		for (int i = 0; i < n; i++) {
			bool flag = true;
			int cur = 0;
			int size = 0;

			for (int j = i; j < n; j++) {
				size += strings[j].size();

				if (size > tanku[cur]) {
					flag = false;
					break;
				}

				if (size == tanku[cur]) {
					cur++;
					size = 0;
					if (cur == 5) {
						break;
					}
				}
			}

			if (flag == true) {
				ans = i + 1;
				break;
			}
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3080
n = int(input())
A = list(map(int, input().split()))

def func():
    for a in A:
        if a % 2 == 0:
            if a % 3 == 0 or a % 5 == 0:
                continue
            else:
                return False
    
    return True

if func():
    print('APPROVED')
else:
    print('DENIED')
    

Measured memory_bytes: 2940
/*
				   _ooOoo_
				  o8888888o
				  88" . "88
				  (| -_- |)
				  O\  =  /O
			   ____/`---'\____
			 .'  \\|     |//  `.
		    /  \\|||  :  |||//  \
		   /  _||||| -:- |||||-  \
		   |   | \\\  -  /// |   |
		   | \_|  ''\---/''  |   |
		   \  .-\__  `-`  ___/-. /
		 ___`. .'  /--.--\  `. . __
	  ."" '<  `.___\_<|>_/___.'  >'"".
	 | | :  `- \`.;`\ _ /`;.`/ - ` : | |
	 \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
				   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
		fozubaoyou    pass System Test!
		quoted from "https://codeforces.com/contest/472/submission/7996840"
*/
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


int main(void){
	
	int n;
	cin>>n;
	vvi f(n,vi(10));
	vvi p(n,vi(11));
	rep(i,n)rep(j,10)cin>>f[i][j];
	rep(i,n)rep(j,11)cin>>p[i][j];

	int bit=1;
	ll ans=-INF;
	while(bit<pow(2,10)){
		ll tmpans=0;
		int t=bit;
		vi open(10,0);
		int pos=0;
		while(t>0){
			open[pos]=t%2;
			t/=2;
			pos++;
		}
		for(int i=0;i<n;i++){//全ての店を舐める
			int match=0;
			for(int j=0;j<10;j++){
				if(f[i][j]==open[j]&&f[i][j]==1){
					match++;
				}
			}
			tmpans+=p[i][match];
		}

		ans=max(ans,tmpans);
		bit++;
	}

	fin(ans);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e2+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, a[N];

int main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i];
	double ans = 0.0;
	for(int i=0; i<n; i++){
		ans += 1.0/a[i];
	}
	ans = 1.0/ans;
	cout << fixed << setprecision(9);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
col1 = []
col2 = []
for i in a:
    if i//400<8:
        col1.append(i//400)
    else:
        col2.append(i//400)
min = len(set(col1))
if min == 0:
    min = 1
max = len(set(col1))+len(col2)

print(min, max)


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

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int main(){

    int a;
    cin >> a;

    cout << a + a * a + a * a * a << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

struct Graph {
    int V, E;
    static const int MAX_V = 100100;//書き換え!
    vector<pii> G[MAX_V];
    int x[MAX_V];
    bool left[MAX_V];
    bool used[MAX_V];

    Graph(int V, int E) : V(V), E(E) {
        rep(i, MAX_V) {
            x[i] = -1;
            left[i] = true;
            used[i] = false;
        }
    }

    Graph() {}

    void init(int v, int e) {
        V = v, E = e;
        rep(i, MAX_V) {
            x[i] = -1;
            left[i] = true;
            used[i] = false;
        }
    }

    //a->b有向(コストc)
    void addEdge(int a, int b, int c) {
        G[a].emplace_back(b, c);
        left[b] = false;
    }

    bool check(int v, int prev, int d) {
        used[v] = true;
        if (x[v] == -1) {
            x[v] = x[prev] + d;
            rep(i, G[v].size()) {
                int to = G[v][i].first;
                int d2 = G[v][i].second;
                if (!check(to, v, d2))return false;
            }
            return true;
        } else {
            if (x[v] != x[prev] + d)return false;
            else return true;
        }
    }

    bool check(int v) {
        if (!left[v])return true;
        if (used[v])return true;
        used[v] = true;
        x[v] = 5000000000000000000;
        rep(i, G[v].size()) {
            int to = G[v][i].first;
            int d = G[v][i].second;
            if (!check(to, v, d))return false;
        }
        return true;
    }

    //checkが全て終わった後に検査されていない頂点がある
    bool hasLoop() {
        rep(i, V) {
            if (!used[i])return true;
        }
        return false;
    }
};

Graph g;

signed main() {
    int N, M;
    cin >> N >> M;
    g.init(N, M);
    rep(i, M) {
        int l, r, d;
        cin >> l >> r >> d;
        --l, --r;
        g.addEdge(l, r, d);
    }
    rep(i, N) {
        if (!g.check(i)) {
            cout << "No" << endl;
            return 0;
        }
    }
    if (g.hasLoop())cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 10496
// Vicfred
// https://atcoder.jp/contests/abc051/tasks/abc051_c
// implementation, math
import std.stdio;

void main() {
    int sx, sy, tx, ty;
    readf("%d %d %d %d", &sx, &sy, &tx, &ty);

    int dx = tx - sx;
    int dy = ty - sy;

    foreach(_; 0..dy)
        "U".write;
    foreach(_; 0..dx)
        "R".write;
    foreach(_; 0..dy)
        "D".write;
    foreach(_; 0..dx)
        "L".write;

    "L".write;

    dx += 1;
    dy += 1;

    foreach(_; 0..dy)
        "U".write;
    foreach(_; 0..dx)
        "R".write;

    "D".write;
    "R".write;

    foreach(_; 0..dy)
        "D".write;
    foreach(_; 0..dx)
        "L".write;

    "U".writeln;
}



Measured memory_bytes: 2772
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

void DFS(int V,vector<vector<int> >&GRAPH,vector<int>&dist,int depth)
{
  dist[V] = depth;
  for (int i = 0; i < GRAPH[V].size(); i++)
  {
    if(dist[GRAPH[V][i]] == -1)
    {
      DFS(GRAPH[V][i],GRAPH,dist,depth+1);
    }
  }
  return;
}
void solve(void)
{
  int N;
  cin>>N;
  vector<vector<int> >GRAPH(N);
  for (int i = 0; i < N-1; i++)
  {
    int A,B;
    cin>>A>>B;
    A--;B--;
    GRAPH[A].push_back(B);
    GRAPH[B].push_back(A);
  }
  vector<int> dist0(N,-1);
  vector<int> distN(N,-1);

  DFS(0,GRAPH,dist0,0);
  dist0[0] = 0;
  distN[N-1] = 0;
  DFS(N-1,GRAPH,distN,0);

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

  if(count*2 > N)
  {
    cout<<"Fennec"<<endl;
  }
  else
  {
    cout<<"Snuke"<<endl;
  }
  
  
  
  
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 12032
#include <stdio.h>
int main(void){
  int N,A,B,i,sum1,sum2,a,b,c,d,e;
  sum1=0;
  sum2=0;
  scanf("%d %d %d",&N,&A,&B);
  for(i=0;i<N+1;i++){
    a=i/10000;
    b=(i-a*10000)/1000;
    c=(i-a*10000-b*1000)/100;
    d=(i-a*10000-b*1000-c*100)/10;
    e=i-a*10000-b*1000-c*100-d*10;
    sum1=a+b+c+d+e;
   if(A<=sum1&&sum1<=B)
     sum2+=i;
  }
  printf("%d\n",sum2);
  
 return 0; 
}

Measured memory_bytes: 1692
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var t = new Test();
            var input = t.ReadInputOneLine();

            var middle = (input / 10) % 10;
            if(input % 10 == 7 || middle == 7 || input /100 == 7)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            
        }

 
        public int ReadInputOneLine()
        {
            return int.Parse(Console.ReadLine());
        }

        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public List<int> ParseIntList(string[] x)
        {
            var convertedList = new List<int>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(int.Parse(x[i]));
            }

            return convertedList;
        }


        public List<double> ParseDoubleList(string[] x)
        {
            var convertedList = new List<double>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(double.Parse(x[i]));
            }

            return convertedList;
        }

        public List<long> ParseLongList(string[] x)
        {
            var convertedList = new List<long>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(long.Parse(x[i]));
            }

            return convertedList;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

Measured memory_bytes: 17608
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3") 
#pragma GCC optimization ("unroll-loops")
 
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;
 
#define ll  long long
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define ppi pair<pii,ll>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)
 
#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)
 
#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount
#define die() return 0;
// #define size() 


 
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define MD          1000000007
#define M 			100011
#define LN             14
#define fftmod      998244353
#define EPS         (double)1e-10
 
long long  md=MD;
ll inf=1e18;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
 
inline ll exp(ll a,ll b){if(a==0&&b==0)return 1ll;if(a==0)return 0ll;ll r=1LL;while(b>0){if(b&1){r=(r%md)*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}
 
using cd=complex<double>;
const double PI=acos(-1);
 
inline ll rand(ll l,ll r){
    return l+rng()%(r-l+1);
 
}

vii g[M];
ll v[M];
ll go(ll u,ll p){
	v[u]=1;
	for(auto va:g[u]){
		if(va==p)continue;
		if(v[va]==0)
			go(va,u);
	}
}
int main(){
 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
 
   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p;string s1,s2;ll q;ll x,y;
    cin>>n>>m;
    lp(1,m){
    	cin>>x>>y>>z;
    	g[x].pb(y);g[y].pb(x);
    }
    p=0;
    lp(1,n){
    	if(v[i]==0)++p,go(i,0);
    }
    cout<<p<<"\n";


}



Measured memory_bytes: 11264
#include <stdio.h>
int main()
{
    int a,b,c;
    scanf(" %d%d%d",&a,&b,&c);
    if((-100<=a&&a<=100)&&(-100<=b&&b<=100)&&(-100<=c&&c<=100)){

        if(c>=a&&c<=b){printf("Yes");}
        else {printf("No");}
    }

    return 0;
}

Measured memory_bytes: 128
N = int(input())

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

fac = num2alpha(N)
print(fac.lower())

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
int n,m,s,t,sum,ans,a[55],b[55],c[55],d[55];
vector<int> g[55];
void dfs(int x,int y){
	b[x]=1;
	for(int i=0;i<g[x].size();i++){
		if(x==s and g[x][i]==t)continue;
		if(x==t and g[x][i]==s)continue;
		if(g[x][i]!=y and !b[g[x][i]])
			dfs(g[x][i],x);
	}
}
int main(){
	n=read(),m=read();
	for(int i=0;i<m;i++){
		c[i]=read(),d[i]=read();
		g[c[i]].push_back(d[i]);
		g[d[i]].push_back(c[i]);
	}
	for(int i=0;i<m;i++){
		s=c[i],t=d[i],sum=0;
		memset(b,0,sizeof(b));
		dfs(1,-1);
		for(int j=1;j<=n;j++)
			if(b[j])sum++;
		if(sum<n)ans++;
	}
	cout << ans;
	return 0;
}

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

int main(){
  string s, t;
  cin >> s >> t;
  s = " " + s;
  t = " " + t;
  int dp[3010][3010] = {0};
  for(int y=0; y < (int)s.size(); y++){
    for(int x=0; x < (int)t.size(); x++){
      if(y == 0 || x == 0) continue;
      if(s[y] == t[x]){
        dp[y][x] = dp[y-1][x-1]+1;
      }
      else{
        dp[y][x] = max(dp[y-1][x], dp[y][x-1]);
      }
    }
  }
  int length=dp[(int)s.size()-1][(int)t.size()-1];
  string ans="";
  int itrx=(int)t.size()-1, itry = (int)s.size()-1;
  while(length){
    if(s[itry] == t[itrx]){
      ans += s[itry];
      length--;
      itry--;
      itrx--;
    }
    else if(dp[itry][itrx] == dp[itry-1][itrx]){
      itry--;
    }
    else if(dp[itry][itrx] == dp[itry][itrx-1]){
      itrx--;
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}


Measured memory_bytes: 36220
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
//################################################################
const int N=100009;
int n,a[N],b[N],c[N];
int mem[N][4];
int solve(int ind ,int lastInd){
    if(ind==n)return 0;
    int  ret=INT_MIN;
    if(mem[ind][lastInd]!=-1)return mem[ind][lastInd];
    if(lastInd!=0){

        ret=max(ret,a[ind]+solve(ind+1,0));
    }
    if(lastInd!=1){

        ret=max(ret,b[ind]+solve(ind+1,1));
    }
    if(lastInd!=2){

        ret=max(ret,c[ind]+solve(ind+1,2));
    }
    return mem[ind][lastInd]=ret;

}
int main() {
    n=D();
    for(int i=0;i<n;i++){
        a[i]=D(),b[i]=D(),c[i]=D();
    }
    memset(mem,-1, sizeof(mem));
    printf("%d",solve(0,3));


}

Measured memory_bytes: 9216
#include<iostream>
#include<string>
#include<iomanip>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
typedef long long ll;


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

    vector<double> dp(n+1);
    dp[0] = 1;

    for(int coin = 1; coin <= n; coin++)
    {
        double p_head ;
        cin>>p_head;

        for(int i = coin; i>=0; i--)
        {
            dp[i] = (i>0 ? dp[i-1]*p_head : 0) + dp[i]*(1-p_head);
        }
    }

    double ans = 0;
    for(int head = 0; head <= n;head++)
    {
        int tail = n - head;
        if(head > tail)
            ans+=dp[head];
    }
    cout<<setprecision(12)<<ans<<"\n";
    
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>

#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

using namespace std;

struct rect {
    int h, w;
};

int main(){
    vector<rect> dic;
    dic.reserve(150 * 75);
    for (int h = 1; h <= 150; h++){
        for (int w = h + 1; w <= 150; w++){
            rect r = { h, w };
            dic.push_back(r);
        }
    }

    auto f = [](const rect & a, const rect & b){
        int sa = a.w*a.w + a.h*a.h;
        int sb = b.w*b.w + b.h*b.h;
        if (sa != sb) return sa < sb;
        return a.h < b.h;
    };

    sort(dic.begin(), dic.end(), f);
    int h, w;
    while (cin >> h >> w, h || w){
        rect r = { h, w };
        auto it = upper_bound(dic.begin(), dic.end(), r, f);
        cout << (it->h) << " " << (it->w) << endl;
    }
}

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x * y / GCD(x, y);
}


int main() {
	ll a, b; cin >> a >> b;
	if((a+b) % 2 == 0) cout << (a+b) / 2 << endl;
	else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 256
#include<stack>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int R, C, N;
int get_pos(int x, int y) {
    if (y == 0) return x;
    else if (x == R) return 1e8 + y;
    else if (y == C) return 3e8 - x;
    else return 4e8 - y;
}
bool in[100011];

void MAIN() {
    scanf("%d%d%d", &R, &C, &N);
    vector<pair<int, int> > H;
    REP (i, N) {
	int x0, y0, x1, y1;
	scanf("%d%d%d%d", &x0, &y0, &x1, &y1);

	if (x0 == 0 || x0 == R || y0 == 0 || y0 == C) if (x1 == 0 || x1 == R || y1 == 0 || y1 == C) {
	    H.emplace_back(get_pos(x0, y0), i);
	    H.emplace_back(get_pos(x1, y1), i);
	}
    }

    stack<int> st;
    bool yes = true;
    sort(H.begin(), H.end());
    EACH (e, H) {
	int i = e->second;
	if (in[i]) {
	    if (st.top() != i) {
		yes = false;
		break;
	    }
	    st.pop();
	    in[i] = false;
	} else {
	    in[i] = true;
	    st.push(i);
	}
    }


    puts(yes? "YES": "NO");
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

#define each(i, c) for (auto& i : c)

typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9+7;

int main() {
  ll h, w;
  cin >> h >> w;
  
  ll n;
  cin >> n;

  ll ans = 0;
  ll a = max(h, w);
  ll b = min(h, w);

  for (ll i = 0; i < b; ++i) {
    ++ans;
    n -= a;
    if (n <= 0) break;
  }

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

  for (ll i = 0; i < a; ++i) {
    ++ans;
    n -= b;
    if (n <= 0) break;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <stdio.h>


using namespace std;

int main(int argc, char *argv[]){

  string str;

  cin >> str;
  if(str.length() < 4){
    cout << "No" << endl;
  }else{
    // ４文字以上
    if('Y' == str[0] && 'A' == str[1] && 'K' == str[2] && 'I' == str[3])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;

  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int A, B;
  cin >> A >> B;
  int sum = 0;
  for(int i = 0; i < 2; ++i){
    if(A >= B){
      sum += A;
      --A;
    }
    else{
      sum += B;
      --B;
    }
  }
  cout << sum << endl;
}


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

typedef long long LL;

int popcnt[1 << 20];

int solve(int n, int m){
	vector<vector<int> > as(n, vector<int>(m));
	for(int i = 0; i < n; ++i)
	for(int j = 0; j < m; ++j){
		cin >> as[i][j];
	}

	vector<LL> ok(m);
	vector<pair<int,int> > ps(n);
	vector<int> secs(n);
	for(int i = 0; i < m; ++i)
	for(int j = 0; j < m; ++j){
		for(int k = 0; k < n; ++k){
			ps[k] = make_pair(as[k][i], as[k][j]);
		}
		sort(ps.begin(), ps.end());
		for(int k = 0; k < n; ++k){
			secs[k] = ps[k].second;
		}
		if(is_sorted(secs.begin(), secs.end())){
			ok[i] |= 1LL << j;
		}
	}

	int half = m / 2;
	vector<int> dp(1LL << half);
	for(LL S = 1; S < (1LL << half); ++S){
		LL T = (1LL << m) - 1;
		for(int i = 0; i < half; ++i){
			if(S >> i & 1){
				T &= ok[i];
				dp[S] = max(dp[S], dp[S ^ (1LL << i)]);
			}
		}
		if((T & S) == S){ dp[S] = max(dp[S], popcnt[S]); }
	}

	int ans = 0;
	for(LL S = 0; S < (1LL << m); S += 1LL << half){
		LL T = (1LL << m) - 1;
		for(int i = half; i < m; ++i){
			if(S >> i & 1){
				T &= ok[i];
				if((T & S) != S){ break; }
			}
		}
		if((T & S) == S){
			ans = max(ans, dp[T & ((1LL << half) - 1)] + popcnt[S >> half]);
		}
	}
	return ans;
}

int main(){
	popcnt[0] = 0;
	for(int i = 1; i < (1 << 20); ++i){
		popcnt[i] = popcnt[i & (i - 1)] + 1;
	}

	int n, m;
	while(cin >> n >> m && n){
		cout << solve(n, m) << endl;
	}
}


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

using namespace std;

int D, G;

struct Problem {
  int score;
  int number;
  int bonus;
  
  int score_at(int n) {
    if (n >= number) {
      return score * number + bonus;
    } else {
      return score * n;
    }
  }
};
  
int main() {
  cin >> D >> G;
  
  vector<Problem> problems(D);
  
  for (int i = 0; i < D; i++) {
    int n, b;
    cin >> n >> b;
    Problem p = { (i + 1) * 100, n, b };
    problems.at(i) = p;
  }
  
  vector<vector<int>> memo(D, vector<int>(1001, 0));
  
  for (int number = 1; number <= 1000; number++) {
    for (int i = 0; i < D; i++) {
      // 1行目の初期化
      if (i == 0) {
        memo.at(0).at(number) = problems.at(0).score_at(number);
      } else {
        int max_score = 0;
        for (int j = 0; j <= number; j++) {
          int x = memo.at(i - 1).at(number - j) + problems.at(i).score_at(j);
          max_score = max(max_score, x);
        }
        memo.at(i).at(number) = max_score;
      }
    }
    if (memo.at(D - 1).at(number) >= G) {
      cout << number << endl;
      return 0;
    }
  }  
}


Measured memory_bytes: 256
N =int(input())

# N//m = N % mであるm……つまり、
# N = m * a + a = (m + 1) * aであるa,mの組を探す(ただしm > a)
# m > aの制限があるので、aの候補は√N未満→10^6 ゴリ押し可能。

ans = 0
debuglist = []

for a in range(1, 10**6 + 2):
    m = (N // a) - 1
    if (N % a) == 0 and m > a :
        debuglist.append(m)
        ans += m

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
long long int i,n,ar[100005][3],dp[100005][3],x;
int main(){
	cin>>n;
	for(i=1;i<=n;i++){
		for(x=0;x<3;x++)cin>>ar[i][x];
	}
	for(i=1;i<=n;i++){
		dp[i][0]=max(ar[i][0]+dp[i-1][1],ar[i][0]+dp[i-1][2]);
		dp[i][1]=max(ar[i][1]+dp[i-1][0],ar[i][1]+dp[i-1][2]);
		dp[i][2]=max(ar[i][2]+dp[i-1][1],ar[i][2]+dp[i-1][0]);
	}
	long long int anss=max(dp[n][0],dp[n][1]);
	cout<<max(anss,dp[n][2]);
}

Measured memory_bytes: 4992
N, M=gets.split.map(&:to_i)
res=?**N
M.times{
    s, c=gets.split
    s=s.to_i-1
    (p -1; exit) if res[s]!=c && res[s]!=?*
    res[s]=c
}
res[0]=?1 if res[0]==?* && N>1
res.tr! ?*, ?0
puts (N>1 && res[0]==?0 ? -1 : res)


Measured memory_bytes: 1788
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

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

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

    vector<pair<int, int>> task(n, make_pair(0, 0));
    for (int i = 0; i < n; i++) {
        cin >> task[i].first >> task[i].second;
    }

    sort(task.begin(), task.end(), task_comp);

    bool flag = true;
    for (int i = 0, time = 0; i < n && flag; i++) {
        time += task[i].first;
        if (time > task[i].second) {
            flag = false;
        }
    }

    cout << (flag ? "Yes" : "No") << endl;
}


Measured memory_bytes: 1792
import java.io.*;
import java.math.*;

class Main{


    public static void main(String args[])throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    int t = Integer.parseInt(br.readLine());
    String s = "";
    for(int i=0;i<t;i++) s += "ACL";

    System.out.println(s);
  }
}

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

typedef long long ll;

ll n,m;
ll ans;
ll a,b;
pair<ll,ll> x[500005];
bool used[500005];

bool solve(){
	cin >> n >> m;
	ans = 0;
	if(n == 0)return false;
	for(int i=0;i<n;i++){
		cin >> a >> b;
		x[i].first = a;
		x[i].second = b;
	}
	for(int i=1;i<=m;i++){
		used[i] = false;
	}
	sort(x,x+n);
	reverse(x,x+n);
	for(int i=0;i<n;i++){
		ll dif = x[i].first;
		ll v = x[i].second;
		if(used[dif]){
			continue;
		}else{
			ans += v;
			used[dif] = true;
		}
	}
	cout << ans << endl;
	return true;

}

int main(){
	while(solve()){}
	return 0;
}


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

typedef long long lint;

lint dat[100010],Ans[100010],n,m;
pair<int,int> edge[100010];

int root(int x){
	return dat[x]<0?x:dat[x]=root(dat[x]);
}

void unite(int a,int b){
	a=root(a),b=root(b);
	if(a==b) return;
	dat[a]+=dat[b];
	dat[b]=a;
	return;
}

int main(){
	cin>>n>>m;
	memset(dat,-1,sizeof(dat));
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		edge[i].first=a;
		edge[i].second=b;
	}
	lint total=(lint)n*(n-1)/2;
	for(int i=m-1;i>=0;i--){
		Ans[i]=total;
		int a=edge[i].first;
		int b=edge[i].second;
		int ra=root(a);
		int rb=root(b);
		if(ra!=rb){
			total-=(lint)dat[ra]*dat[rb];
			unite(a,b);
		}
	}
	for(int i=0;i<m;i++) printf("%lld\n",Ans[i]);
	return 0;
}

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

using namespace std;

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    vector<int> l(n + 1, 0), r(n + 1, 0);
    for (int i = 0; i < n; i++) l[i + 1] = gcd(l[i], a[i]);
    for (int i = n - 1; i >= 0; i--) r[i] = gcd(r[i + 1], a[i]);

    int ans = 0;

    for (int i = 0; i < n; i++) {
        int left = l[i];
        int right = r[i + 1];

        ans = max(ans, gcd(left, right));
    }
    cout << ans << endl;

    return 0;
} 


Measured memory_bytes: 1408
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
ans=0
for i in range(n-1):
  for k in range(i+1,n):
    ans+=((l[i][0]-l[k][0])**2+(l[i][1]-l[k][1])**2)**0.5
print(ans*2/n)

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

int main(){
	int n,k; cin>>n>>k;
	vector<int> v(n);
	rep(i,n){
		int a; cin>>a; v[a-1]++;
	}
	sort(all(v));
	v.erase(remove(v.begin(),v.end(),0),v.end());
	int r=v.size();
	if(r<=k) cout<<0<<endl;
	else{
		int j=r-k, ans=0;
		rep(i,j) ans+=v[i];
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 4032
#include<map>
#include<cstdio>

using namespace std;

int main()
{
	int a[12],n;
	for(;scanf("%d",&n),n;){
		for(int i=0;i<n;i++)	scanf("%d",a+i);

		int k;
		for(k=0;;k++){
			map<int,int> cnt;
			for(int i=0;i<n;i++)	cnt[a[i]]++;

			bool b=true;
			for(int i=0;i<n;i++){
				if(a[i]!=cnt[a[i]])	b=false;
				a[i]=cnt[a[i]];
			}
			if(b)	break;
		}

		printf("%d\n",k);
		for(int i=0;i<n;i++)	printf("%s%d",i?" ":"",a[i]);
		puts("");
	}

	return 0;
}

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

int main() {
    int N;
    cin >> N;
    set<string> st;
    for (int i = 0; i < N; ++i) {
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 19256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<string, int> mp;
#define ll long long

int main() {
    string s;
    cin >> s;
    int n = s.size();
    ll ans = 0;
    ll cb=0;
    rep(i, n) {
        if (s[i] == 'B')cb++;
        else if (s[i] == 'W'&&cb > 0) {
            ans+=cb;
        }
    }
    cout << ans << endl;

    
    return 0;
}

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


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

    int N;
    cin >> N;

    std::unordered_map<int, int> values;
    for(int x = 1; x <= 100; x++)
    {
        for(int y = 1; y <= 100; y++)
        {
            for(int z = 1; z <= 100; z++)
            {
                int val = (x*x) + (y*y) + (z*z) + (x*y) + (y*z) + (z*x);
                if(val > N) break;

                values[val]++;
            }
        }
    }

    for(int i = 1; i <= N; i++)
    {
        if(values.find(i) == values.end())
            std::cout << 0 << "\n";
        else
            std::cout << values[i] << std::endl;
    }

    return 0;
}


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

using namespace std;

string a, b;

int main()
{
    cin >> a;
    b = a;
    reverse(b.begin(), b.end());
    
    int n = b.size();
    for (int i = 0; i < n; ++i)
    {
        if (b[i] == 'b') b[i] = 'd';
        else if (b[i] == 'd') b[i] = 'b';
        else if (b[i] == 'p') b[i] = 'q';
        else b[i] = 'p';
    }
    if (a == b) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		Map<Integer, Integer> Gmap = new HashMap<>();
		Map<Integer, Integer> Kmap = new HashMap<>();
		Set<Integer>set=new HashSet<>();
		for (int i = 0; i < n; i++) {
			int key = scanner.nextInt();
			if (i % 2 == 0) {
				if (Gmap.containsKey(key)) {
					Gmap.put(key, Gmap.get(key) + 1);
				} else {
					Gmap.put(key, 1);
				}
			} else {
				if (Kmap.containsKey(key)) {
					Kmap.put(key, Kmap.get(key) + 1);
				} else {
					Kmap.put(key, 1);
				}
			}
			set.add(key);
		}
		
		if(set.size()==1) {
			System.out.println(n/2);
			return;
		}

		List<Entry<Integer, Integer>> GList = new ArrayList<Entry<Integer, Integer>>(Gmap.entrySet());
        Collections.sort(GList, new Comparator<Entry<Integer, Integer>>() {
            public int compare(Entry<Integer, Integer> obj1, Entry<Integer, Integer> obj2) {
                return obj2.getValue().compareTo(obj1.getValue());
            }
        });
        
        List<Entry<Integer, Integer>> KList = new ArrayList<Entry<Integer, Integer>>(Kmap.entrySet());
        Collections.sort(KList, new Comparator<Entry<Integer, Integer>>() {
            public int compare(Entry<Integer, Integer> obj1, Entry<Integer, Integer> obj2) {
                return obj2.getValue().compareTo(obj1.getValue());
            }
        });
        
        int ans=0;
        if(!GList.get(0).getKey().equals(KList.get(0).getKey())&&Gmap.size()!=1&&Kmap.size()!=1) {
        	ans=n-GList.get(0).getValue()-KList.get(0).getValue();
        }
        else if(!GList.get(0).getKey().equals(KList.get(0).getKey())&&Gmap.size()!=1) {
        	ans=n/2-GList.get(0).getValue();
        }
        else if(!GList.get(0).getKey().equals(KList.get(0).getKey())&&Kmap.size()!=1) {
        	ans=n/2-KList.get(0).getValue();
        }
        else if(GList.get(0).getKey().equals(KList.get(0).getKey())&&Gmap.size()!=1&&Kmap.size()!=1) {
        	ans=n-Math.max(GList.get(0).getValue()+KList.get(1).getValue(), GList.get(1).getValue()+KList.get(0).getValue());
        }
        else if(GList.get(0).getKey().equals(KList.get(0).getKey())&&Gmap.size()!=1) {
        	ans=n/2-GList.get(1).getValue();
        }
        else if(GList.get(0).getKey().equals(KList.get(0).getKey())&&Kmap.size()!=1) {
        	ans=n/2-KList.get(1).getValue();
        }
        
        System.out.println(ans);
        
	}
}

Measured memory_bytes: 65588