akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

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


Measured memory_bytes: 256
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265359

using namespace std;

/*ll powMod(ll a, ll y)
{
    ll ans = 1;
    
    while (y > 0) 
    { 
        if (y & 1) 
            ans = (ans*a) % MOD; 
  
        y = y>>1;
        a = (a*a) % MOD; 
    } 
    return ans;
}*/

/*ll modInv(ll a)
{
    return powMod(a, MOD-2);	
}*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string s, t;    
    cin >> s >> t;
    int ans = INT_MAX;
    for (int i = 0; i <= (int)s.length()-t.length(); i++) {
        int cur = 0;
        for (int j = 0; j < (int)t.length(); j++) {
            if (i+j < s.length() && s[i+j] != t[j]) {
                cur++;
            }
        }
        ans = min(ans, cur);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <math.h>

int main()
{
    long long int n,a,b;

    scanf("%lld %lld %lld",&n,&a,&b);


    if(a==b)
    {
        printf("1");
    }


    else if(n==1)
    {
        printf("0");
    }

    else if(b<a)
    {
        printf("0");
    }

    else
    {
       printf("%lld",((b-a)*(n-2))+1);
    }


    return 0;
}


Measured memory_bytes: 1648
#include<iostream>
#include<string>
#include <vector>

using namespace std;

int main()
{
	int flag=1;
	int  K;
	int N;
	int check;
	int result,value;
	cin >> N;
	cin >> K;
	int a[5];
	a[4] = 0;
	vector<int> D(K);
	for (int i=0; i < K; i++)
	{
		cin >> D[i];
	}

	result = N;
	
	for (;;) {
		flag = 0;
		value = result;
		check = 5;
		a[0] = (value % 10); value /=10;
		a[1] = (value % 10); value /=10;
		a[2] = (value % 10); value /=10;
		a[3] = (value % 10); value /=10;
		a[4] = (value % 10);
		if (a[4] == 0) 
		{
			check -= 1;
			if (a[3] == 0)
			{
				check -= 1;
				if (a[2] == 0)
				{
					check -= 1;
					if (a[1] == 0)
					{
						check -= 1;
					}
				}
			}
		
		}

			for (int j = 0; j < check; j++) {
				for (int i = 0; i < K; i++) {

					if (a[j] == D[i])
					{
						flag = 1;
					}
				}
			}
		

		if (flag == 0)
		{
			cout << result;
			return 0;
		}
		else {
			result+=1;
		}
	} 

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
	int h, n;
	scanf("%d%d", &h, &n);
	rep(i, n) {
		int a;
		cin >> a;
		h -= a;
		if(h <= 0) {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> prices(N);
  for (int i = 0; i < N; i++) {
    cin >> prices.at(i);
  }
  sort(prices.begin(), prices.end());
  int sum = 0;
  for (int i = 0; i < N - 1; i++) {
    sum += prices.at(i);
  }
  sum += prices.at(N - 1) / 2;
  cout << sum;
  return 0;
}


Measured memory_bytes: 256
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
using namespace std;

void test() {
    int n;
    cin >> n;
    multiset<long long> pp, pn, nn, np;
    pair<long long, long long> p[n];
    auto add = [&](int i) {
        pp.emplace(p[i].first + p[i].second);
        nn.emplace(-p[i].first - p[i].second);
        pn.emplace(p[i].first - p[i].second);
        np.emplace(-p[i].first + p[i].second);
        return;
    };
    for (int i = 0; i < n; ++i) {
        cin >> p[i].first >> p[i].second;
        add(i);
    }
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        pp.erase(pp.find(p[i].first + p[i].second));
        nn.erase(nn.find(-p[i].first - p[i].second));
        pn.erase(pn.find(p[i].first - p[i].second));
        np.erase(np.find(-p[i].first + p[i].second));
        ans = max(ans, *pp.rbegin() - p[i].first - p[i].second);
        ans = max(ans, *nn.rbegin() + p[i].first + p[i].second);
        ans = max(ans, *pn.rbegin() - p[i].first + p[i].second);
        ans = max(ans, *np.rbegin() + p[i].first - p[i].second);
        add(i);
    }
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin >> t;
    for (int i = 0; i < t; ++i) {
        test();
    }
    return 0;
}


Measured memory_bytes: 44276
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = rint, m = rint;
	Node[] nodes;
	foreach(i; 0 .. n) nodes ~= new Node(i, i + 1);
	foreach(j; 0 .. m){
		int a = rint - 1, b = rint - 1;
		nodes[a].kids ~= nodes[b];
	}
	log("kids:", nodes.map!(nd => nd.kids.map!(kid => kid.name)));
	
	foreach_reverse(nd; nodes){
		if(nd.id == n - 1) nd.value = 0.0;
		else foreach(kid; nd.kids) nd.value += (kid.value + 1.0) / nd.kids.length.to!real;
	}
	foreach(nd; nodes){
		if(nd.id == 0) nd.weight = 1.0;
		foreach(kid; nd.kids) kid.weight += nd.weight / nd.kids.length.to!real;
	}
	log("value:", nodes.map!(nd => nd.value));
	log("weight:", nodes.map!(nd => nd.weight));
	
	real bestx = 0.0;
	int bestndid, bestkidid;
	foreach(nd; nodes){
		if(nd.kids.length <= 1) continue;
		foreach(kid; nd.kids){
			real x = nd.weight * ((nd.value - (kid.value + 1.0) / nd.kids.length.to!real) 
					* nd.kids.length.to!real / (nd.kids.length - 1).to!real- (kid.value + 1.0))
					/ nd.kids.length.to!real;
			log(nd.name, "->", kid.name, ":", x);
			if(x < bestx){
				bestx = x;
				bestndid = nd.id;
				bestkidid = kid.id;
			}
		}
	}
	log("best:", bestx, bestndid, bestkidid);
	
	writefln("%10.10f", nodes[0].value + bestx);
	
}

class Node{
	int id, name;
	Node[] kids, kids2;
	real value = 0.0;
	real weight = 0.0;
	this(int id, int name){
		this.id = id, this.name = name;
	}
}


Measured memory_bytes: 12540
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    char c;
    cin >> c;
    cout << (char)(c+1) << endl;
}

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

int gcd(int a ,int b){
    if(a%b==0) return b;
    else return gcd(b,a%b);
}
ll lcm(int a, int b){
    ll ans = a;
    ans *= b;
    return ans/gcd(a,b);
}


int main(void){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    ll ans = b-a+1;
    a--;
    ans -= b/c - a/c;
    ans -= b/d - a/d;
    ans += b/lcm(c,d) - a/lcm(c,d);
    cout << ans << endl;
}

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

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


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

    // 下限は 0 (完全グラフ)
    // 上限は (N-1)(N-2)/2 (スター)
    int upper_limit = (N-1)*(N-2)/2;
    if(K > upper_limit){
        cout << -1 << endl;
        return 0;
    }

    vector<pair<int,int>> ans;
    // スターを作る (中心は N)
    REP(i, N-1) ans.push_back(make_pair(i+1, N));

    // 一旦全ての辺の候補を列挙
    vector<pair<int,int>> edge;
    REP(i, N-1){
        REP(j, i){
            edge.push_back(make_pair(i+1, j+1));
        }
    }
    // 必要な個数足す
    int add = upper_limit - K;
    REP(i, add) ans.push_back(edge[i]);

    cout << ans.size() << endl;
    REP(i, ans.size()) cout << ans[i].first << " " << ans[i].second << endl;

    return 0;
}

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

char A[15];

int n, val;

int main() {
    scanf("%d", &n);
    sprintf(A, "%d", n);
    for(int i = 0; A[i]; ++i) val += A[i] - '0';
    puts(n % val ? "No" : "Yes");
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int c[3][3];
    REP(i, 3) {
        REP(j, 3) {
            cin >> c[i][j];
        }
    }
    REP(i, 3) {
        REP(j, 3) {
            int d = c[i][0] - c[j][0];
            REP(k, 3) {
                if (d != c[i][k] - c[j][k]) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

int main(){
    string str;
    bool include7=false;
    cin >> str;
    for (int i=0;i<3;i++){
        if(str[i]=='7'){
            include7=true;
            break;
        }
    }
    if(include7){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3620
from collections import Counter
import math
n=int(input())
s=list(input() for _ in range(n))
S=[]
ans=0
for i in range(n):
    s1=sorted(s[i])
    S.append(''.join(s1))
S1=Counter(S)
for i in S1:
   if S1[i]>1:
        ans+=math.factorial(S1[i])//(math.factorial(S1[i]-2)*2)
print(ans)        


Measured memory_bytes: 26932
/*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡖⠁⠀⠀⠀⠀⠀⠀⠈⢲⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣼⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣧⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣸⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣇⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣿⣿⡇⠀⢀⣀⣤⣤⣤⣤⣀⡀⠀⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣔⢿⡿⠟⠛⠛⠻⢿⡿⣢⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣀⣤⣶⣾⣿⣿⣿⣷⣤⣀⡀⢀⣀⣤⣾⣿⣿⣿⣷⣶⣤⡀⠀⠀⠀⠀
⠀⠀⢠⣾⣿⡿⠿⠿⠿⣿⣿⣿⣿⡿⠏⠻⢿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣷⡀⠀⠀
⠀⢠⡿⠋⠁⠀⠀⢸⣿⡇⠉⠻⣿⠇⠀⠀⠸⣿⡿⠋⢰⣿⡇⠀⠀⠈⠙⢿⡄⠀
⠀⡿⠁⠀⠀⠀⠀⠘⣿⣷⡀⠀⠰⣿⣶⣶⣿⡎⠀⢀⣾⣿⠇⠀⠀⠀⠀⠈⢿⠀
⠀⡇⠀⠀⠀⠀⠀⠀⠹⣿⣷⣄⠀⣿⣿⣿⣿⠀⣠⣾⣿⠏⠀⠀⠀⠀⠀⠀⢸⠀
⠀⠁⠀⠀⠀⠀⠀⠀⠀⠈⠻⢿⢇⣿⣿⣿⣿⡸⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠈⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠐⢤⣀⣀⢀⣀⣠⣴⣿⣿⠿⠋⠙⠿⣿⣿⣦⣄⣀⠀⠀⣀⡠⠂⠀⠀⠀
⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠉⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠋⠁⠀⠀⠀
              ~ARD~
*/



#include <bits/stdc++.h>

#define ll                          long long int
#define ull                         unsigned long long int

//  LOOPS
#define loop(i,a,n)                 for(int i=a; i<n; i++)
#define loopr(i,n,a)                for(int i=n; i>=a; i--)
#define loopit(it,s)                for(auto it=s.begin(); it!=s.end(); it++)
#define CASE(t)                      cout<<"Case #"<<(t)<<": ";
//  INP_OUT
#define looparri(i,a,n,arr)          int arr[n]; for(int i=0;i<n;i++) cin>>arr[i];
#define looparro(i,a,n,arr)          for(int i=0;i<n;i++) cout<<arr[i]<<" ";
#define inp1(x)                     ll x; cin>>x;
#define inp2(x,y)                   ll x,y; cin>>x>>y;
#define inps1(str,len)              string str;cin>>str; int len; len=str.length()
#define opt(x)                      cout<<x<<endl;
#define line                        cout<<'\n';
#define mset(a,val)                 memset(a,val,sizeof(a))
//  MISC
#define ff                          first
#define ss                          second
#define pb                          push_back
#define mkp                         make_pair
#define pii                         pair<ll,ll>
#define vi                          vector<ll>
#define vs                          vector<string>
#define mii                         map<ll,ll>
#define vpp                         vector< pair <ll, ll> >
#define vv                          vector<vi>
#define xxx                         INT_MAX
#define nnn                         INT_MIN

#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)

using namespace std;
const unsigned int M = 1000000007;


void solve()
{
    inp1(d);
    inp1(t)
    inp1(s);
    int dis = s*t;
    if(dis>=d)
        cout<<"Yes"<<endl;
    else
    {
        cout<< "No" <<endl;
    }
    

    

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



 
  


Measured memory_bytes: 3612
#include<stdio.h>

int main(){
  int x,y,mod;
  scanf("%d %d",&x,&y);
  while(1){
    mod=x%y;
    if(mod==0){
      break;
    }else{
      x=y;
      y=mod;
    }
    
  }
  
  printf("%d\n",y);
  return 0;



}



Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a[5];
	for(int i=0;i<5;i++){
		cin>>a[i];
	}
	int k;
	cin>>k;
	int cha[10];
	int cnt=0;
	for(int i=0;i<5;i++){
		for(int j=i+1;j<5;j++){
			cha[cnt]=abs(a[i]-a[j]);
			cnt++;
		}
	}
	bool yn=1;
	for(int i=0;i<10;i++){
		if(cha[i]>k){
			yn=0;
		}
	}
	if(yn==0){
		cout<<":(";
	}else{
		cout<<"Yay!";
	}
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[10000],b[10000],c[10000];
    int x,y,m,n,l,i,j;
    cin>>a;
    cin>>b;
    cin>>x>>y;
    cin>>c;
    m=strlen(a);
    n=strlen(b);
    l=strlen(c);
    int cunt=0;
    if(m==l)
    {
        for(i=0; i<m; i++)
        {
            if(a[i]!=c[i])
            {
                cunt=1;
                break;
            }

        }
        if(cunt==0)x--;
    }
    cunt=0;
    if(n==l)
    {
        for(i=0; i<n; i++)
        {
            if(b[i]!=c[i])
            {
                cunt=1;
                break;
            }

        }
        if(cunt==0)y--;
    }
    cout<<x<<' '<<y<<endl;
    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))

c = []
for n, a in enumerate(A, 1):
  c += [n]*a

for i in range(H):
  if i % 2 == 0:
    print(*c[i*W:(i+1)*W])
  else:
    print(*c[(i+1)*W-1:i*W-1:-1])

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

using namespace std;
int main() {
    int n, k;
    int sum = 0;

    cin >> n >> k;

    for (int i = 0; i < n; i++) {
        int x;
        int la, lb;
        cin >> x;
        la = x;
        lb = k-x;
        sum += min(la, lb)*2;
    }

    cout << sum << endl;
    return 0;
}



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

using namespace std;

int main(){
  int ans = 0,a,b,c,max;
  cin >> a >> b >> c;
  max = a;
  if (b > max){
    max = b;
  }
  if (c > max){
    max = c;
  }
  if ((max * 3 - a - b - c) %2 == 0){
    ans = (max * 3 - a - b - c) /2;
  }else{
    ans = (max * 3 - a - b - c + 3) /2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# include <stdio.h>
# include <math.h>
long long int minvalue(long long int a,long long int b)
{
if(a<b)
return a;
else
return b;
} 
int main()
{
long long int n;
scanf("%lld",&n);
long long int a[n],b[n];
for(int i=0;i<n;i++)
scanf("%lld",&a[i]);
b[0]=0;
b[1]=fabs(a[1]-a[0]);
for(int i=2;i<n;i++)
{
//long long int a1=
b[i]=minvalue(b[i-1]+fabs(a[i]-a[i-1]),b[i-2]+fabs(a[i]-a[i-2]));
}
printf("%lld",b[n-1]);
return 0;
}



Measured memory_bytes: 1664
import math
from bisect import *
n=int(input())
a=sorted(list(map(int,input().split())))
tmp=a[0]
ans=1
aa=1
for i in range(1,n):
    if tmp*2>=a[i]:
        tmp+=a[i]
        ans+=1
    else:
        tmp+=a[i]
        ans=1
print(ans)

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

int main(){
	int sum1=0, sum2=0, min;
	string S;
	cin >> S;
	for (int i=0; i<S.size(); i++){
		if (i%2 == 0 && S[i] == '0'){
			sum1 += 1;
		}
		else if (i%2 != 0 && S[i] == '1'){
			sum1 += 1;
		}
		min = sum1;
		if (i%2 == 0 && S[i] == '1'){
			sum2 += 1;
		}
		else if (i%2 != 0 && S[i] == '0'){
			sum2 += 1;
		}
		if (min > sum2){
			min = sum2;
		}
	}
	cout << min << endl;
	return 0;
}

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

// 内部定数
#define D_ON			1										// 汎用フラグ - ON
#define D_OFF			0										// 汎用フラグ - OFF
#define D_NUM_MAX		200000									// 最大数列数

// 内部変数
static FILE *szpFpI;											// 入力
static int siSCnt;												// 段数
static int siTop;												// 最上段の値
static int si1Num[D_NUM_MAX];									// 数列
static int siNCnt;												// 数列数
static int si1Set[D_NUM_MAX + 5];								// セット済みフラグ

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
#endif

// 値 - セット
int
fSetVal(
	int piNo					// <I> セット位置 0～
	, int piVal					// <I> 値 1～
)
{
	// セット
	si1Num[piNo] = piVal;

	// セット済みフラグ
	si1Set[piVal] = D_ON;

	return 0;
}

// 判定
int
fJudge(
)
{
	int i;

	// 数列数
	siNCnt = 2 * siSCnt - 1;

	// 範囲チェック
	if (siTop == 1 || siTop == siNCnt) {
		return -1;
	}

	// 数列 - 固定値 - セット
	if (siSCnt == 2) {						// ２段
		fSetVal(0, 1);
		fSetVal(1, 2);
		fSetVal(2, 3);
	}
	else if (siTop == 2) {					// 最上段 = 2	x x x ... 3 1 2 4 x x x ...
		fSetVal(siSCnt - 3, 3);
		fSetVal(siSCnt - 2, 1);
		fSetVal(siSCnt - 1, 2);
		fSetVal(siSCnt, 4);
	}
	else {									// その他		x x x ... 小 大 Top 小 x x x ...
		fSetVal(siSCnt - 3, siTop - 1);
		fSetVal(siSCnt - 2, siTop + 1);
		fSetVal(siSCnt - 1, siTop);
		fSetVal(siSCnt, siTop - 2);
	}

	// 数列 - その他 - セット
	int liVal = 1;
	for (i = 0; i < siNCnt; i++) {
		if (si1Num[i] >= 1) {			// セット済
			continue;
		}

		// セット値
		while (si1Set[liVal] == D_ON) {
			liVal++;
		}

		// セット
		fSetVal(i, liVal);
	}

	return 0;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// データ - 初期化
	memset(si1Num, D_OFF, sizeof(si1Num));						// 数列
	memset(si1Set, D_OFF, sizeof(si1Set));						// セット済みフラグ

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 段数・最上段の値 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &siSCnt, &siTop);

	// 判定
	int liRet = fJudge();
	if (liRet == 0) {
		sprintf(lc1Out, "Yes\n");
	}
	else {
		sprintf(lc1Out, "No\n");
	}

	// 結果 - 表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// Yes - 表示
	if (liRet == 0) {
		for (i = 0; i < siNCnt; i++) {
			sprintf(lc1Out, "%d\n", si1Num[i]);
#ifdef D_TEST
			fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
			if (strcmp(lc1Buf, lc1Out)) {
				siRes = -1;
			}
#else
			printf("%s", lc1Out);
#endif
		}
	}

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 2944
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout<<fixed<<setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

ll Sarrus(const ll a[3][3])
{
	return
		a[0][0] * a[1][1] * a[2][2]
		+ a[0][2] * a[1][0] * a[2][1]
		+ a[0][1] * a[1][2] * a[2][0]
		- a[0][2] * a[1][1] * a[2][0]
		- a[0][0] * a[1][2] * a[2][1]
		- a[0][1] * a[1][0] * a[2][2];
}
bool Cremer(const ll a[3][3], const ll b[3], double x[3])
{
	ll det = Sarrus(a);
	if (det != 0) {
		ll temp[3][3]; REP(i, 3) REP(j, 3)temp[i][j] = a[i][j];
		REP(i, 3) {
			REP(j, 3) temp[j][i] = b[j];
			x[i] = (double)Sarrus(temp) / det;
			REP(j, 3)temp[j][i] = a[j][i];
		}
		return true;
	}
	return false;
}
signed main()
{
	ll
		xa = in(), ya = in(), za = in(),
		xb = in(), yb = in(), zb = in(),
		x1 = in(), y1 = in(), z1 = in(),
		x2 = in(), y2 = in(), z2 = in(),
		x3 = in(), y3 = in(), z3 = in();
	ll a[3][3] =
	{
		{x2 - x1,x3 - x1,xa - xb},
		{y2 - y1,y3 - y1,ya - yb},
		{z2 - z1,z3 - z1,za - zb}
	};
	ll b[3] =
	{
		xa - x1,
		ya - y1,
		za - z1
	};
	double x[3];
	if (!Cremer(a, b, x)) cout << "HIT" << endl;
	else cout << (
		0 <= x[0] && x[0] <= 1 &&
		0 <= x[1] && x[1] <= 1 &&
		0 <= 1 - x[0] - x[1] && 1 - x[0] - x[1] <= 1 &&
		0 <= x[2] && x[2] <= 1
		? "MISS" : "HIT") << endl;
}


Measured memory_bytes: 3092
#include <iostream>
#include <array>

void set(std::array<int, 10> &J, int num);
void print(std::array<int, 10> J);

void set(std::array<int, 10> &J, int num)
{
  int i=J.size() - 1;
  while(num>0) {
    J.at(i--) = num % 2;
    num /= 2;
  }
}

void print(std::array<int, 10> J)
{
  int size = J.size();
  for (int i=0; i<size; i++) std::cout << J[i] << ' ';
  std::cout << std::endl;
}

int main()
{
  int N;
  std::cin >> N;

  std::array<int, 10> F[N];
  for (int i=0; i<N; i++) {
    for (int j=0; j<10; j++) std::cin >> F[i][j];
  }

  std::array<int, 11> P[N];
  for (int i=0; i<N; i++) {
    for (int j=0; j<11; j++) std::cin >> P[i][j];
  }

  std::array<int, 10> J = {}; //joisino

  int ans = -1000000000;

  for (int i=1; i<1024; i++) {
    int profit = 0;
    set(J, i);
    for (int j=0; j<N; j++) {
      int same = 0;
      for (int k=0; k<10; k++) if (J[k]==1 && F[j].at(k)==1) same++;
      profit += P[j].at(same);
    }
    if (profit > ans) {
      ans = profit;
      //print(J);
    }
  }

  std::cout << ans;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
l.append(float("inf"))

ans = []
cnt = 0
pre = 0

for i in l:
  if i <= pre:
    cnt  += 1
    pre = i
  else:
    ans.append(cnt)
    cnt = 0
    pre = i
print(max(ans))


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int k,x;
    cin>>k>>x;
    for(int i=x-k+1;i<x+k-1;i++){
        cout<<i<<' ';
    }
    cout<<x+k-1<<endl;
    
    return 0;
}


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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int N;
	cin >> N;
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			int sum = 0;
			sum = 4 * j + 7 * i;
			if (sum > 100) {
				continue;
			}
			if (N == sum) {
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,C = inpl()
d = []
c = []
for i in range(C):
    d.append(inpl())
for i in range(n):
    c.append(inpl())
d0 = defaultdict(int)
d1 = defaultdict(int)
d2 = defaultdict(int)
dd = [d0,d1,d2]
for y in range(n):
    for x in range(n):
        t = (x+y+2) % 3 
        dd[t][c[x][y]] += 1
# print(dd)
res = [[] for i in range(3)]
for i in range(C):
    for j in range(3):
        tmp = 0
        for key in dd[j].keys():
            tmp += d[key-1][i] * dd[j][key]
        res[j].append([i,tmp])   
for i in range(3):
    res[i].sort(key=lambda x:x[1])
# print(res)
ans = mod
for i in range(3):
    for j in range(3):
        for k in range(3):
            if res[0][i][0] == res[1][j][0] or res[0][i][0] == res[2][k][0] or res[2][k][0] == res[1][j][0]:
                continue
            ans = min(res[0][i][1]+res[1][j][1]+res[2][k][1], ans)
print(ans)            

Measured memory_bytes: 6644
# https://atcoder.jp/contests/abc176/tasks
'''
dp[i]...次に行動するプレイヤーが勝つかどうか。石がi個あったときに。

dp[i]=True if (i-a for a \in A で一つでもFalseがあったら) else False
これは配るdpを用いて
dp[i+a] |= 1-dp[i] で書くことができる
'''

N, K = map(int, input().split())
A = list(map(int, input().split()))
dp = [0] * (K + max(A) + 1)
for i in range(K):
    for a in A:
        dp[i + a] |= 1 - dp[i]
print('First' if dp[K] else 'Second')


Measured memory_bytes: 10440
import sys
N=int(input())

def factorize(n):
  fac_dic={}
  for i in range(2,n):
    if i**2>n:
      break
      
    while(n%i==0):
      n//=i
      if i not in fac_dic:
        fac_dic[i]=1
      else:
        fac_dic[i]+=1

  if n!=1:
    fac_dic[n]=1    
  return fac_dic
        
if N==1:
  print(0)
  sys.exit()
  
fact_dic={}
for i in range(2,N+1):
  f_dic=factorize(i)
  for key in f_dic:
    if key in fact_dic:
      fact_dic[key]+=f_dic[key]
    else:
      fact_dic[key]=f_dic[key]
  
#print(fact_dic)
fact_list_n1=[]
for v in fact_dic.values():
  if v>1:
    fact_list_n1.append(v)
  
#print(fact_list_n1)
answer=0
for i in range(len(fact_list_n1)):
  if fact_list_n1[i]>=74:
    answer+=1
for i in range(len(fact_list_n1)):
  for j in range(len(fact_list_n1)):
    if i==j:
      continue      
    if fact_list_n1[i]>=14 and fact_list_n1[j]>=4:
      answer+=1
    if fact_list_n1[i]>=24 and fact_list_n1[j]>=2:
      answer+=1
for i in range(len(fact_list_n1)):
  for j in range(i+1,len(fact_list_n1)):
    for k in range(len(fact_list_n1)):
      if i==j or j==k or k==i:
        continue      
      if fact_list_n1[i]>=4 and fact_list_n1[j]>=4 and fact_list_n1[k]>=2:
        answer+=1

print(answer)

Measured memory_bytes: 3188
N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
L, R = 0, A[-1]
while R - L > 1:
    mid = L + (R - L) // 2
    if sum([(a - 1) // mid for a in A]) <= K:
        R = mid
    else:
        L = mid
print(R)


Measured memory_bytes: 169340
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		String f = sc.next();
		String b = sc.next();
		String[] c = new String[a];
		String[] d = new String[a];
		String e = "";
		for(int i = 0; i < a; i++){
			c[i] = f.substring(i, i + 1);
		} 
		for(int i = 0; i < a; i++){
			d[i] = b.substring(i, i + 1);
		}
		for(int i = 0; i < a; i++){
			e += c[i] + d[i];
		}
		System.out.println(e);
		
		
	}
}

Measured memory_bytes: 39140
#include <cstdio>
#include <cstdlib>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main() 
{
	int n;
	while(scanf("%d",&n)&&n)
	{
		pair<double,string> ans[50];
		REP(i,n)
		{
			char name[21];
			double p,a,b,c,d,e,f,s,m;
			scanf("%s%lf%lf%lf%lf%lf%lf%lf%lf%lf",name,&p,&a,&b,&c,&d,&e,&f,&s,&m);
			ans[i]=make_pair((a+b+c+m*(d+e))/(f*s*m-p),name);
		}
		sort(ans,ans+n);
		
		int mi(0);
		REP(i,n)if(ans[i].first<0)mi++;
//		reverse(ans,ans+mi);
		rotate(ans,ans+mi,ans+n);
		
		REP(i,n){printf("%s\n",ans[i].second.c_str());}
		printf("#\n");
	}
	return 0;
}

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

int main() {
  string A, B;
  cin >> A >> B;

  if(A.at(0)==B.at(2) && A.at(1)==B.at(1) && A.at(2)==B.at(0)){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }

return 0;  
}

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

const int maxn=2005;


int main()
{
	int n;
	cin>>n;
	int x,ans=0;
	for( int i=1;i<=n;i++ )
	{
		cin>>x;
		if( i%2==1 && x%2==1 ) ans++;
	}
	cout<<ans<<endl;
} 


Measured memory_bytes: 3560
/**
 * ????°????????????§??????????¨????

n ????????´??° ai(i=1,2,...n)
?????\?????????????????????????°????????????§??????????¨????????±???????????????°????????????????????????????????????

Input
??????????????´??°?????° n ???????????????????????????????????? n ????????´??° ai
????????????????????§?????????????????????

Output
????°????????????§??????????¨????????????????????????§????????????????????????????????????

Constraints
0<n???10000
???1000000???ai???1000000

Sample Input
5
10 1 5 4 17
Sample Output
1 17 37
 */

#include <algorithm>
#include <iostream>
#include <numeric>
#include <sstream>
#include <vector>

int main(int argc, char const *argv[]) {
  unsigned int n = 1;
  std::string Param;

  while (true) {

    getline(std::cin, Param);
    std::istringstream iss(Param);
    iss >> n;

    if (n < 1 || n > 10000) {
      std::cout << "Error: 1 <= n <= 10000" << std::endl;
    } else {
      break;
    }
  }

  // unsigned int Ai[n];
  std::vector<int> Ai(n, 0);
  while (true) {
    bool isValid = true;

    getline(std::cin, Param);
    std::istringstream iss(Param);
    for (size_t i = 0; i < n; i++) {
      iss >> Ai[i];
      if (Ai[i] < -1000000 || Ai[i] > 1000000) {
        std::cout << "Error: -1000000 <= Ai <= 1000000" << std::endl;
        isValid = false;
        break;
      } else {
        isValid = true;
      }
    }
    if (isValid == true) {
      break;
    }
  }
  std::cout << *(std::min_element(Ai.begin(), Ai.end())) << " "
            << *(std::max_element(Ai.begin(), Ai.end())) << " "
            << std::accumulate(Ai.begin(), Ai.end(), (long long int)0) << std::endl;

  return 0;
}

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

int main()
{
    char c;
    cin >> c;
    if( c=='a' or c=='e' or c=='i' or c=='o' or c=='u'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vi p(n);
    cin >> p;
    rep(i,n) p[i]--;
    vi a(n),b(n);
    rep(i,n) {
        a[i] = i*n;
        b[i] = (n-i)*n;
    }
    rep(i,n) a[p[i]] += i+1;
    rep(i,n) cout << a[i] << (i == n-1 ? '\n' : ' ');
    rep(i,n) cout << b[i] << (i == n-1 ? '\n' : ' ');
}


Measured memory_bytes: 3800
import java.util.Scanner;

/**
 * Created by wenzhong on 2016/8/6.
 */
public class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {//注意while处理多个case
            int num = in.nextInt();
            int[] a=new int[num];
            int max=Integer.MIN_VALUE;
            int min=Integer.MAX_VALUE;
            for(int i=0;i<num;i++){
                a[i]=in.nextInt();
                max=Math.max(max, a[i]);
                min=Math.min(min, a[i]);
            }
            int min1=Integer.MAX_VALUE;
            for(int i=min;i<=max;i++){
                int sum=0;
                for(int s:a){
                    sum+=(s-i)*(s-i);
                }
                min1=Math.min(min1, sum);
            }
            System.out.println(min1);
        }
    }
}

Measured memory_bytes: 9680
# https://atcoder.jp/contests/abc075/tasks/abc075_b

H, W = map(int, input().split())

S_list = []

for h in range(H):
    S = list(input())
    S_list.append(S)


check_list = [[-1, -1], [-1, 0], [-1, 1], [0, -1], [0,1], [1, -1], [1, 0], [1, 1]]

for i in range(H):
    for j in range(W):
        if S_list[i][j] == '.':
            count = 0
            for k in check_list:
                k_i = i - k[1]
                k_j = j - k[0]
                if k_i >= 0 and k_j >= 0 and k_i < H and k_j < W:
                    if S_list[k_i][k_j] == '#':
                        count += 1
            
            S_list[i][j] = str(count)

    print(''.join(S_list[i]))
         

Measured memory_bytes: 3188
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

const int N = 1e5;
std::vector<std::vector<int>> g;
int n;
int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int u, v;
  cin >> n;
  cin >> u >> v;
  u--, v--;
  g.resize(n);
  for(int i = 0; i < n - 1; i++) {
    int a, b; std::cin >> a >> b;
    a--; b--;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  // who, where, step
  queue<tuple<int, int, int>> q;
  q.emplace(1, u, 0); // longer
  q.emplace(2, v, 0); // shorter

  vector<int> used(n);
  vector<int> dis(n);
  int ans = 0;

  used[u] = 1;
  dis[u] = 0;

  used[v] = 2;
  dis[v] = 0;

  while(q.size()) {
    int who, where, step;
    tie(who, where, step) = q.front();
    q.pop();
    for(auto j : g[where]) {
      if(who == 1) {
        if(used[j]) continue;
      } else {
        if(used[j] == who) continue;
        if(used[j] == 1 && g[j].size() == 1) {
          if(step % 2 == dis[j] % 2) {
            ans = max(ans, step + 1 - 1);
          } else {
            ans = max(ans, step + 1 - 1);
          }
        }
      }
      q.emplace(who, j, step + 1);
      used[j] = who;
      dis[j] = step + 1;
    }
  }
  cout << ans << endl;
  return 0;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		var ss = rs().Split(',');
		Console.WriteLine(String.Join(" ",ss));
	}

	public Sol(){
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 2648
/* 
   AOJ 1173
   The Balance of the World
   2015.4.30
 */

#include<stdio.h>
#include<stdlib.h>

struct node
{
  char val;
  struct node *next;
};

struct node *head;

void init()
{
  head = NULL;
}

int empty()
{
  return head == NULL;
}

char pop()
{
  char pop_val = head->val;
  struct node *tmp = head->next;
  free(head);
  head = tmp;
  return pop_val;
}

struct node* new(char val, struct node* next)
{
  struct node* x = malloc(sizeof *x);
  x->val = val;
  x->next = next;
  return x;
}

void push(char push_val)
{
  head = new(push_val, head);
}

void traverse()
{
  struct node *p = head;
  while(p != NULL)
    {
      printf("%c", p->val);
      p = p->next;
    }
}

void balance_checker(char *input_str)
{
  int i;
  init();

  for(i = 0; input_str[i] != '.'; i++)
    {
      switch(input_str[i])
	{
	case '(':
	case '[':
	  push(input_str[i]);
	  break;
	case ')':
	  if(empty() || pop() != '(')
	    {
	      printf("no\n");
	      return ;
	    }
	  break;
	case ']':
	  if(empty() || pop() != '[')
	    {
	      printf("no\n");
	      return ;
	    }
	  break;
	}
    }

  if(!empty())
    {
      printf("no\n");
      return ;
    }

  printf("yes\n");
  return ;
}

int main(void)
{
  char input_str[101];
  while(1)
    {
      gets(input_str);
      if(input_str[0] == '.' && input_str[1] == '\0')
	{
	  break;
	}
      balance_checker(input_str);
    }
  return 0;
}

Measured memory_bytes: 588
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

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

  int result;
  while (N < 1000) {
    string str_N = to_string(N);
    set<char> S;
    for (char c : str_N) {
      S.insert(c);
    }
    if (S.size() == 1) {
      result = N;
      break;
    }
    N++;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
h=[int(i) for i in input().split()]

l=[0]+[100000000000000000000000000000 for i in range(n-1)]

for i in range(n-1):
    if i!=n-2:
        l[i+1]=min(l[i+1],abs(h[i]-h[i+1])+l[i])
        l[i+2]=min(l[i+2],abs(h[i]-h[i+2])+l[i])
    else:
        l[i+1]=min(l[i+1],abs(h[i]-h[i+1])+l[i])

print(l[-1])
        




Measured memory_bytes: 13716
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#ifdef RUBICK
#include "dbg.h"
#else
#define dbg(exp) /* nop; */
#endif

// F cin/cout
#define cin nullptr
#define cout nullptr

using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

using ll = long long;
using ld = long double;

int main() {
    int n, k;
    scanf("%d %d", &n, &k);

    int arr[n];
    for (int& e : arr)
        scanf("%d", &e);

    bool wins[k+1];
    fill(wins, wins+k+1, false);

    for (int e : arr)
        wins[e] = true;

    for (int score = 1; score <= k; score ++) {
        for (int possible : arr) {
            if (score-possible >= 0)
                wins[score] |= (!wins[score-possible]);
        }
    }

    puts(wins[k] ? "First" : "Second");

    return 0;
}



Measured memory_bytes: 384
def choise(n,s):
    k = 0
    lis = s.split()
    lis = list(map(lambda x: int(x), lis))
    while (len(lis) == int(n)):
        lis = list(filter(lambda x: x % 2 == 0, lis))
        if (len(lis) == int(n)): k += 1
        lis = list(map(lambda x: x / 2, lis))
    return k

if __name__ == "__main__":
    n = input()
    s = input()

    print(choise(n,s))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#define int long long
using namespace std;

#define fin(i,n) for (int i = 0; i < n; i++)
#define fin2(i,a,b) for (int i = a; i < b; i++)
#define ford(i,n) for (int i = n-1; i >= 0; i--)
#define ford2(i,a,b) for (int i = a-1; i >= b; i--)
 
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define mod 1000000007
#define PI 3.1415926535897932384626
#define EXP1 2.718281828459045
#define BIG 1000000000000000000

#define sl(n) scanf("%lld", &n)
#define sll(n,m) scanf("%lld %lld", &n, &m)
#define slll(n,m,k) scanf("%lld %lld %lld", &n, &m, &k)
#define sllll(n,m,k,o) scanf("%lld %lld %lld %lld", &n, &m, &k, &o)
#define sd(n) scanf("%lf", &n)
#define sdd(n,m) scanf("%lf %lf", &n, &m)
#define sddd(n,m,k) scanf("%lf %lf %lf", &n, &m, &k)
#define sc(c) scanf(" %c", &c)
#define ss(s) scanf("%s", s)
#define sal(t,n) fin(iz,n) { scanf("%lld", &t[iz]); }
#define sad(t,n) fin(iz,n) { scanf("%lf", &t[iz]); }
#define gl(t) scanf(" %[^\n]", t);

#define pc(n) printf("%c\n", n)
#define ps(s) printf("%s\n", s)
#define pss(s) printf("%s\n", s.c_str())
#define pl(n) printf("%lld\n", n)
#define pll(n,m) printf("%lld %lld\n", n, m)
#define plll(n,m,k) printf("%lld %lld %lld\n", n, m, k)
#define pd(n) printf("%lf\n", n)
#define pdd(n,m) printf("%lf %lf\n", n, m)
#define pal(t,n) fin(rz,n) { printf("%lld ", t[rz]); } printf("\n")
#define pad(t,n) fin(rz,n) { printf("%lf ", t[rz]); } printf("\n")

#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
 
#define OK ps("OK")
#define OK1 ps("OK1")
#define OK2 ps("OK2")

#define ll int
#define vl vector<ll>
#define vvl vector<vl>
#define vvvl vector<vvl>

#define dll pair<ll, ll>
#define vdll vector<dll>
#define vvdll vector<vdll>

#define vb vector<bool>
#define vvb vector<vb>
#define vd vector<double>
#define vvd vector<vd>
#define vc vector<char>
#define vvc vector<vc>

#define all(v) v.begin(), v.end()
#define vlen(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second

const int bm = (int)(1e5);
int n,m;
char tmp[bm];
string s,t;

signed main()
{
	sll(n, m);
	ss(tmp);
	s = tmp;
	ss(tmp);
	t = tmp;
	int l = n*m / __gcd(n, m);
	int x = 0;
	for (int i = 0; i < m; ++i) {
		int y = i*(l/m);
		while (x*(l/n) < y) ++x;
		if (x >= n) break;
		if (x*(l/n) == y && s[x] != t[i]) {
			ps("-1");
			return 0;
		}
	}	
	pl(l);
}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
using namespace std;
#include<algorithm>
#include<set>
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)

const int mod=1000000007;


int main(){
  int N;
cin>>N;
vector<int>A(N);
rep(i,N)cin>>A[i];
sort(A.begin(),A.end());
int ans=0;
rep(i,N){
  rep(j,i){
    rep(k,j){
      if(A[i]!=A[j]&&A[j]!=A[k]&&A[i]<A[j]+A[k])ans++;
    }
  }
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    int n;
    ll k;
    cin>>n>>k;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    
    vector<int> s;
    vector<int> ord(n+1,-1);
    int c=1,l=0,v=1;
    while(ord[v]==-1){
        ord[v]=s.size();
        s.push_back(v);
        v=a[v-1];
    }

    c=s.size()-ord[v];
    l=ord[v];
    if(l>k){
        cout<<s[k]<<endl;
    }
    else{
        k-=l;
        k%=c;
        cout<<s[l+k]<<endl;
    }

}

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int yyyy, mm, dd;
    char s1,s2;
    cin >> yyyy >> s1 >> mm >> s2 >> dd;
    cout << (mm > 4 ? "TBD":"Heisei") << endl;
}

Measured memory_bytes: 256