akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
int a[10],i,n,s;
int max[10]={9,26,50,80,115,154,196,240,285,330};
int min[10]={0,1,4,10,20,35,56,84,120,165};
int summing(int n,int s){
    int ans=0,i,m;
    if(n==1){if(s<10 && a[s]==1)return 1; else return 0;}
    else{
        if(s<min[n-1] || max[n-1]<s)return 0;
        for(i=0;i<10;i++){
            if(a[i]==1 && n*i<=s){
                if(n==2){
                    m=s-i*2;
                    if(m>=0 && m<10 && i!=m && a[m]==1)ans++;
                }
                else{
                    a[i]=0;
                    ans+=summing(n-1,s-n*i);
                    a[i]=1;
                }
            }
        }
        return ans;
    }
}
int main(void){
    for(i=0;i<10;i++)a[i]=1;
    while(scanf("%d %d",&n,&s)!=EOF){printf("%d\n",summing(n,s));}
    return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
#define LL long long

int main(){
	// sengen
	int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	// nyuryoku
	cin >> k;
	// keisan
	cout << a[k-1];
	// syutsuryoku
}

Measured memory_bytes: 3644
#include <stdio.h>
int main(void)
{
  int x,y;
  
  scanf("%d %d",&x,&y);
  
  for(int i=0; i<=x; i++){
    if(2*(x+i) == y){
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

void solve()
{
	int num;
	double weight, height;
	vector<int> Vec;
	while(scanf("%d,%lf,%lf", &num, &weight, &height) != EOF)
	{
		if(weight / height / height >= 25)
		{
			Vec.push_back(num);
		}
	}
	if(Vec.size())
	{
		for(int i = 0; i < Vec.size(); ++i)
		{
			cout << Vec[i] << endl;
		}
	}
	else
	{
		cout << "該当なし" << endl;
	}
}

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

Measured memory_bytes: 1252
#include<bits/stdc++.h>
#define mod 1000000007

/*long long power(long long a,int k)
{
	long long ans=1,y=a;
	while(k!=0)
	{
		if(k%2!=0)
			ans=ans*y%mod;
		y=y*y%mod;
		k=k/2;
	}
	return ans;
}
*/
long long fun[1000005],ans=1;

long long power(long long a,int k)
{
	long long ans=1,y=a;
	while(k!=0)
	{
		if(k%2==1)
		    ans=ans*y%mod;
		y=y*y%mod;
		k/=2;
	}
	return ans;
}
int main()
{
	long long n,m;
	scanf("%lld%lld",&n,&m);
	fun[0]=1;
	for(int i=1; i<1000000; i++)
		fun[i]=fun[i-1]*i%mod;
	for(int i=2; i*i<=m; i++)
		if(m%i==0)
		{
			long long s=0;
			while (m%i==0)
			{
				m=m/i;
				s++;
			}
			ans=ans*fun[n+s-1]%mod*power(fun[n-1], mod-2)%mod*power(fun[s], mod-2)%mod;
		}
	if(m>1)
		ans=ans*n%mod;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 8064
package main

import "fmt"

func main() {
	var a, b, c, k int
	fmt.Scan(&a, &b, &c, &k)

	var dfs func(i, a, b, c int) bool
	dfs = func(i, a, b, c int) bool {
		if i > k {
			return false
		}

		if a < b && b < c {
			return true
		}

		res := false
		res = res || dfs(i+1, a*2, b, c)
		res = res || dfs(i+1, a, b*2, c)
		res = res || dfs(i+1, a, b, c*2)

		return res
	}

	if dfs(0, a, b, c) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1832
n,*ab = map(int,open(0).read().split())
a = ab[::2]
b = ab[1::2]
a.sort()
b.sort(reverse=True)

if n%2 == 1:
    med_min = a[(n-1)//2]
    med_max = b[(n-1)//2]
    ans = med_max - med_min + 1
else:
    med_min = (a[n//2-1] + a[n//2] ) /2
    med_max = (b[n//2-1] + b[n//2] ) /2
    ans = (med_max - med_min)*2 + 1

print(int(ans))

Measured memory_bytes: 55044
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

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

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
int in(){int a;scanf("%d",&a);return a;}
ll lin(){ll a;scanf("%lld",&a);return a;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

vector<ll> sum[40 / 2 + 1];

int main()
{
    ll N = lin(), K = lin(), L = lin(), R = lin();

    vector<ll> A(N);

    rep(i, N) {
        A[i] = lin();
    }

    int sz1 = N / 2;
    rep(bit, 1 << sz1) {
        int cnt = 0;
        ll s = 0;

        rep(i, sz1) {
            if (bit >> i & 1) {
                cnt++;
                s += A[i];
            }
        }

        sum[cnt].PB(s);
    }

    rep(i, sz1 + 1) sort(all(sum[i]));

    ll ans = 0;

    int sz2 = N - N / 2;
    rep(bit, 1 << sz2) {
        int cnt = 0;
        ll s = 0;

        rep(i, sz2) {
            if (bit >> i & 1) {
                cnt++;
                s += A[i + sz1];
            }
        }

        if (K - cnt < 0 || K - cnt > sz1) continue;

        int pos1 = upper_bound(all(sum[K - cnt]), R - s) - begin(sum[K - cnt]) - 1;
        int pos2 = lower_bound(all(sum[K - cnt]), L - s) - begin(sum[K - cnt]);

        if (sum[K - cnt][pos1] < sum[K - cnt][pos2]) continue;

        ans += max(pos1 - pos2 + 1, 0);
    }

    printf("%lld\n", ans);
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int A, P;
signed main() {
    cin >> A >> P;
    cout << (A * 3 + P) / 2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define D 1000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"

int main() 
{
    FAST;
    ll a,b,h,m;
    cin>>a>>b>>h>>m;
    ll t=(60*h)+m;
    double dh=t/2.0,dm=t*6,fd=(dh-dm);
    //cout<<dh<<' '<<dm<<' '<<fd<<'\n';
    long double ans=(a*a)+(b*b)-(2*a*b*cos(fd*PI/180.0));
    ans=sqrt(ans);
    cout<<fixed<<setprecision(22)<<ans;
    subt;
    return 0;
}

Measured memory_bytes: 4208
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        int m = n - i;
        if (m != i && i < m)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int n; cin>>n;
    vector<int> a(n+2,0);
    rep(i,0,n) cin>>a[i+1];
    ll sum=0;
    rep(i,0,n+1){
        sum+=abs(a[i]-a[i+1]);
    }
    rep(i,1,n+1){
        if((a[i-1]<=a[i] && a[i]<=a[i+1]) || (a[i+1]<=a[i] && a[i]<=a[i-1])){
            cout<<sum<<endl;
        }else{
            cout<<sum-2*min(abs(a[i+1]-a[i]),abs(a[i-1]-a[i]))<<endl;
        }
    }
}

Measured memory_bytes: 1664
#include <stdio.h>

int main() {
    int R, G, B, N, s, c=0;

    scanf("%d %d %d %d", &R, &G, &B, &N);
    int i = 0;
    while(1) {
        s = R * i;
        if (s >= N) {
            if (s == N) c++;
            break;
        }

        int j = 0;
        while(1) {
            s = R*i + G*j;
            if (s >= N) {
                if (s == N) c++;
                break;
            }

            int k = 0;
            while(1) {
                s = R*i + G*j + B*k;
                if (s >= N) {
                    if (s == N) c++;
                break;
                }
                k++;
            }
            j++;
        }
        i++;
    }
    printf("%d", c);
    return 0;
}

Measured memory_bytes: 128
from itertools import permutations
def main():
    a=[int(input()) for _ in range(5)]
    ans=[]
    for x in permutations(a):
        t = 0
        for y in x:
            if t % 10 != 0:
                t = (t//10 + 1) * 10
            t += y
        ans.append(t)
    print(min(ans))
            
    
if __name__ == "__main__":
    main()

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

int main(){
	int N;
	cin >> N;
	map<string,int> mp;
	string s;
	rep(i,N)
	{
		cin >> s;
		sort(s.begin(),s.end());
		mp[s]++;
	}
	ll ans(0);
	for(auto& p : mp)
	{
		ans += (ll)p.second * (p.second-1) / 2;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 11136
#include <cstring>
#include <algorithm>
#include <cstdio>

using namespace std;
const int MAXN = 100010;
int nowarn;

int n, k, a[MAXN];

int gcd( int a, int b ) {
	int c;
	while( b )
		c = a % b, a = b, b = c;
	return a;
}

int main() {
	nowarn = scanf( "%d%d", &n, &k );
	for( int i = 0; i < n; ++i )
		nowarn = scanf( "%d", a+i );
	int g = a[0];
	for( int i = 1; i < n; ++i ) {
		g = gcd(g, a[i]);
		// printf( "i = %d, g = %d\n", i, g );
	}
	int x = *max_element(a, a+n);
	if( k > x || k < g ) {
		puts("IMPOSSIBLE");
		return 0;
	}
	puts( (k % g) ? "IMPOSSIBLE" : "POSSIBLE" );
	return 0;
}


Measured memory_bytes: 512
/**
       **********    ************
	  Author : Avi J Patel
	  University : DAIICT
       **********    ************
**/
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define N 200001
#define large 1844674407370955161
#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define min_heap priority_queue<int, vector<int>, greater<int>>
#define max_heap priority_queue<int>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define pp pair<pair<ll,ll>,pair<ll,ll>>
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> 

bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    if(a.ss < b.ss) return true; 
	else return false;
}
bool sortbyboth(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.ff>b.ff) return true;
	else if(a.ff==b.ff) return a.ss<b.ss;
	else return false;
} 
bool sortff_resortss(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.ff<b.ff) return true;
	else if(a.ff==b.ff) return a.ss>b.ss;
	else return false;
}
bool sortbystring(const string &a, const string &b)
{
	string c=a+b;
	string d=b+a;
	if(c>=d) return true;
	else return false;
}

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

ll modi(ll a, ll m) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) 
      return 0; 
    while (a > 1) 
    { 
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
    return x; 
} 
ll Logn(ll  n, ll r) 
{ 
    return (n > r - 1) ? 1 + Logn(n / r, r) : 0; 
} 

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 

ll modinv(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 

int main()
{
	FAST
	int t=1;
//	cin>>t;
	while(t--)
	{
		int k;
		cin>>k;
		string s;
		cin>>s;
		if(s.size()<=k)
		{
			cout<<s;
		}
		else
		{
			cout<<s.substr(0,k)+"...";
		}
	}
	return 0;
}
















Measured memory_bytes: 3616
import re
import numpy as np
N, K = [int(item) for item in re.split(r"\s", input())]
S = [int(item) for item in list(input())]

if sum(S) == len(S) or sum(S) == 0:
    print(len(S))
else:
    S = S + [2]

    index = [-1]
    for i in range(N):
        if S[i] != S[i + 1]:
            index.append(i)

    count = np.diff(np.array(index)).tolist()

    if S[0] == 0:
        count = [0] + count
    if S[-2] == 0:
        count = count + [0]

    # print(index)
    #print("count", count)

    cumsum = [0] + np.cumsum(count).tolist()
    c_len = len(cumsum)
    win = min(2 * K + 1, c_len - 1)
    # print(cumsum)
    # print(win)

    print(max([cumsum[i + win] - cumsum[i] for i in range(0, c_len - win, 2)]))


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

#define gc getchar 
#define pc putchar
#define fRead	freopen("input.txt","r",stdin) 
#define fWrite	freopen ("output.txt","w",stdout)
#define LL              long long
#define PI              acos(-1.0)
#define pb              push_back
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define f              	first
#define s              	second
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define vi              vector <int>
#define vL              vector <LL>

using namespace std;
#define scani2(a,b) scani(a) , scani(b)
#define scani3(a,b,c) scani(a), scani(b), scani(c)
#define scani4(a,b,c,d) scani(a), scani(b), scani(c), scani(d)
#define scani5(a,b,c,d,e) scani(a), scani(b), scani(c), scani(d) , scani(e)
template <typename T> T scani(T &n){n = 0;bool negative = false;char c = gc();while( c < '0' || c > '9'){if(c == '-') negative = true;c = gc();}while(c >= '0' && c <= '9'){n = n*10 + c-48;c = gc();}if(negative) n = ~(n-1);return n;}
template <typename T> void write(T n,int type = true){if(n<0) {pc('-');n = -n;}if(!n) {pc('0');if(type==32) pc(' '); else if(type) pc('\n'); return;}char buff[22];int len = 0;while(n) buff[len++] = n%10+48,n/=10;for(int i=len-1;i>=0;i--) pc(buff[i]);if(type==32) pc(' '); else if(type) pc('\n');}
int scans(char *a){int i=0;char c = 0;while(c < 33) c = gc();while(c > 33){a[i++] = c;c = gc();}a[i] = 0;return i;}
const int MOD = 1e9 + 7;

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

LL lcm(LL a, LL b) {
	if(a==b) return a;
	LL g = gcd(a,b);
	return (a/g)*b;
}

int main() {
	int n; scani(n);
	LL LCM = 1;
	for(int i = 0; i < n; i++) {
		LL in; scani(in);
		LCM = lcm(LCM,in);
	}
	write(LCM);
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main{

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

		for(int i=0 ; i<10 ;i++){
			values[i] = Integer.parseInt(br.readLine());
		}
		Arrays.sort(values);
		for(int i=9 ; i>6; i--){
			System.out.println(values[i]);
		}
	}
}

Measured memory_bytes: 16864
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      FastIO
      lld n, m;
      cin >> n;
      cin >> m;
      if (m == n)
      	cout << "Yes";
      else
      	cout <<  "No";
      return 0;
}

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

int main(void){
	int n;
	string s = "";
	cin >> n;
	if(n==0){
		cout << 0 << endl;
		return 0;
	}
	int i=0;
	while(n!=0){
		if(n%2==0) s = '0' + s;
		else s = '1' + s;
		if(i%2==0) n -= (n/abs(n))*(n%2);
		if(i%2!=0) n += (n/abs(n))*(n%2);
		n /= 2;
		i = (i+1)%2;
	}
	cout << s << endl;
}

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

//const ll mod = 1000000007;
const ll INF = 1e9;
int N, M;
string S;

void solve() {
    //cout.precision(10);

    //N:no of squares
    //M:total roulette number
    //S:string of 0 and 1s

    cin >> N >> M >> S;

    //2 vector dist and MostLeft
    vector<int> dist(N + 1, INF);
    vector<int> MostLeft(N + 1, INF);
    dist[N] = 0;
    MostLeft[0] = N;

    int Next = N-1;
    int Left = N;

    int timer = 0;

    while(Next >= 0) {
        timer++;
        int newLeft = Left;

        while(Next >= Left - M && Next >= 0) {
            if(S[Next] == '0') {
                dist[Next] = timer;
                //why do this?
                newLeft = Next;
            }
            Next--;


        }

        //
        if(newLeft == Left) {
            cout << -1 << endl;
            return;
        }


        Left = newLeft;
        MostLeft[timer] = Left;

    }
    //end of while loop

    timer = dist[0];

    //what is this for
    for(int i = 0; i <= N; i++) {
        cerr << dist[i] << endl;
    }

    vector<int> ans;
    int now = 0;
    while(timer >= 1) {
        timer--;
        ans.push_back(MostLeft[timer] - now);
        now = MostLeft[timer];
    }

    //print out ans
    for(int i = 0; i < ans.size(); i++) {
        cout << ans[i];
        if(i + 1 != ans.size()) cout << " ";
    }
    cout << endl;
    return;
}

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



Measured memory_bytes: 1864
n,m,X,Y=map(int,input().split())
x_List=list(map(int,input().split()))
y_List=list(map(int,input().split()))
x_List.append(X)
y_List.append(Y)
ans=''
if max(x_List)<min(y_List):
  ans='No War'
else:
  ans='War'
print(ans)

Measured memory_bytes: 3064
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))

INF = 10**6

def min_primes(n):
  ret = [i for i in range(n+1)]
  for i in range(2, int(n**0.5)+1):
    if ret[i] < i:
      continue
    for j in range(i, n+1, i):
      ret[j] = min(i, ret[j])
  return ret

D = min_primes(INF)
Ps = defaultdict(int)

def fact(x):
  Ps[D[x]] += 1
  pre = x
  x //= D[x]
  while x > 1:
    if D[x] > D[pre]:
      Ps[D[x]] += 1
    pre = x
    x //= D[x]

for a in A:
  fact(a)

Ps[1] = 1
ans = max(Ps.values())

if ans == N:
  print("not coprime")
elif ans == 1:
  print("pairwise coprime")
else:
  print("setwise coprime")

Measured memory_bytes: 224772
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 1; i < n; i++) {
        int now = 0;
        set<char> a;
        rep(j,i) a.insert(s[j]);
        for (int k = i; k < n; k++) {
            if (a.count(s[k])) {
                now++;
                a.erase(s[k]);
            }
        }
        ans = max(ans, now);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define int long long

using namespace std;

const int maxN = 1e6 + 10;
const int maxM = 1e6 + 10;
const int inf = 1e9;

typedef pair<int,int> ii;

int dp[maxM];
int wei[maxN], val[maxN];
int n, m, total;

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("CARIBE.inp", "r", stdin);
    //freopen("CARIBE.out", "w", stdout);

	cin >> n >> m;
	for(int i = 1; i <= n; ++i)
	{
		cin >> wei[i] >> val[i];
		total += val[i];
	}

	for(int i = 1; i <= total; ++i)
		dp[i] = inf;

	dp[0] = 0;

	for(int i = 1; i <= n; ++i){
		int w = wei[i], v = val[i];
		for(int j = total; j >= v; --j){
			dp[j] = min(dp[j], dp[j - v] + w);
		}
	}

 	for(int i = total; total >= 0; --i){
 		if(dp[i] <= m){
 			cout << i << "\n";
 			return 0;
 		}
 	}
}


Measured memory_bytes: 4428
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=1e5+10;
vector<int> g[maxn];
int n,m;
int u,v,col[maxn],sum[maxn],up[maxn];
void dfs(int x,int fa)
{
	col[x]=-col[fa];
	for(int i=0;i<g[x].size();i++)
	{
		int to=g[x][i];
		if(to==fa)continue;
		if(col[to])
		{
			u=x,v=to;
			continue;
		}
		dfs(to,x);
	}
}
void dp(int x,int fa)
{
	up[x]=fa;
	sum[x]=col[x];
	for(int i=0;i<g[x].size();i++)
	{
		int to=g[x][i];
		if(to==fa)continue;
		if((to==u&&x==v)||(to==v&&x==u))continue;
		dp(to,x);
		sum[x]+=sum[to];
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	if(n&1)
	{
		printf("-1\n");
		return 0;
	}
	col[0]=-1;
	dfs(1,0);
	if(m==n-1)
	{
		dp(1,0);
		if(sum[1])
		{
			printf("-1\n");
			return 0;
		}
		int ans=0;
		for(int i=1;i<=n;i++)ans+=abs(sum[i]);
		printf("%d\n",ans);
		return 0;
	}
	dp(u,0);
	if(col[u]==col[v])
	{
		int ans=abs(sum[u])/2;
		col[v]-=sum[u]/2;
		col[u]-=sum[u]/2;
		dp(u,0);
		if(sum[u])
		{
			printf("-1\n");
			return 0;
		}
		for(int i=1;i<=n;i++)ans+=abs(sum[i]);
		printf("%d\n",ans);
		return 0;
	}
	if(sum[u])
	{
		printf("-1\n");
		return 0;
	}
	vector<int> all;
	all.clear();
	all.push_back(0);
	for(int i=v;i!=u;i=up[i])
	{
		all.push_back(sum[i]);
		sum[i]=0;
	}
	sort(all.begin(),all.end());
	int x=all[all.size()/2];
	int ans=0;
	for(int i=0;i<all.size();i++)
	{
	//	cout<<i<<" "<<all[i]<<" "<<x<<endl;
		ans+=abs(all[i]-x);
	}
	for(int i=1;i<=n;i++)
		ans+=abs(sum[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 15356
n, m, x, y = list(map(int, input().split()))

xlst = list(map(int, input().split()))
ylst = list(map(int, input().split()))

t = 0

for i in range(x+1, y+1):
  #print(i)
  xmax = max(xlst)
  ymin = min(ylst)
  if i > xmax and i <= ymin:
    print("No War")
    t = 1
    break
  else:
    continue


if t ==0:
  print("War")

Measured memory_bytes: 3064
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,m,x=parseMap(split(readline()))
    a=parseMap(split(readline()))
    res1,res2=0,0
    for i in a
        if x<i
            res2+=1
        else
            res1+=1
        end
    end
    println(min(res1,res2))
end
main()

Measured memory_bytes: 165836
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

int main()
{ 
    ll m,d,c,ans=0;
    cin>>m;

    vector<ll> v;

    for(ll i=0;i<m;i++)
    {
    	cin>>d>>c;
    	ans+=(c-1);

    	if(d==0)
    		v.pb(0);
    		else
    		{
    			ll x=c*d;
    			ll y=x%9;
    			if(y==0)
    				y=9;
    			v.pb(y);
    			ans=ans+((x-1)/9);
    		}

    }
    ans+=(v.size()-1);
   		ll cur=0;
   		for(ll i=0;i<v.size();i++)
   		{
   			cur+=v[i];
   			if(cur>9)
   			{
   				cur-=9;
   				ans++;
   			}
   		}
   		cout<<ans<<endl;
   }

Measured memory_bytes: 2420
N = int(input())
A = [int(i) for i in input().split()]
count = 10**9

def cal(num):
    sum = 0
    while True:
        if num % 2 == 0:
            sum += 1
            num /= 2
        else:
            break
    return sum

for i in range(N):
    count = min(cal(A[i]), count)
print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define sz(a) int((a).size()) 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define ld(a) while(a--)
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define tcf(v,i) for(auto i : v)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define repd(i,start,lim) for(long long (i)=(start);i>=(lim);i--)
#define present(c,x) (find(all(c),x) != (c).end())
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator
#define INF 		0x3f3f3f3f
#define LLINF       1000111000111000111LL
#define PI 			3.14159265358979323
#define endl '\n'
#ifdef WIN32
#define getchar_unlocked getchar
#endif
#define gc getchar
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define N 1000006
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long int ll;
typedef vector<long long int> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<ii,vii,greater<ii> > spq;
const ll MOD=1000000007LL;
template<typename T> T sqr(T x){return x*x;}
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename T>void read(T &x) { register T c = gc(); x = 0; int t = 0; if (c == '-') t = 1, c = gc(); for (; (c < 48 || c>57); c = gc()); for (; c > 47 && c < 58; c = gc()) { x = (x << 1) + (x << 3) + c - 48; }if (t) x = -x; }
template<typename T> T pow(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y%2==1) ans=(ans*x)%m;y/=2;x=(x*x)%m;}return ans%m;} //using this instead of inbuilt pow due to precision issues in that
template<typename T> ll roundp(T x){ll ans=x;if(x-floor(x)<=0.001) ans=floor(x);else if(ceil(x)-x<=0.001) ans=ceil(x);return ans;}
int main(){
	int a,b; cin>>a>>b;
	if(a==b){
		cout<<"Draw"; return 0;
	}
	if((b!=1 && a>b) || a==1){
		cout<<"Alice";
	}
	else cout<<"Bob";
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {

	public class Permutaiton {
		List<String> list;
		int N, M;

		public Permutaiton(int n, int m) {
			list = new ArrayList<String>();
			this.N = n;
			this.M = m;
		}

		public void generate() {
			StringBuilder sb = new StringBuilder(":");
			for (int i = 0 ; i < N ; i++) {
				sb.append(i).append(" ");
			}
			int m = this.M;
			rec_gen(sb.toString().trim(), m);
		}

		private void rec_gen(String s, int num) {
			String[] ss = s.split(":");
			String target = ss[0];

			if (num == 0) {
				list.add(target);
				return;
			}

			if (s.endsWith(":")) return;

			String[] remains = ss[1].split(" ");
			int R = remains.length;
			for (int i = 0 ; i < R ; i++) {
				StringBuilder sb = new StringBuilder(target);
				sb.append(" ").append(remains[i]).append(":");
				for (int j = 0 ; j < R ; j++) {
					if (Integer.parseInt(remains[j]) > Integer.parseInt(remains[i])) { sb.append(remains[j]).append(" "); }
				}
				rec_gen(sb.toString().trim(), num-1);
			}
		}
	}

	public long factorial(long n) {
        if (n == 1) return 1;
        else return n*factorial(n-1);
    }

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);

		Main x = new Main();

		while (sc.hasNext()) {
			int n = sc.nextInt(), s = sc.nextInt();

			if (n==0&&s==0) break;

			Permutaiton p = x.new Permutaiton(10, n);
			p.generate();

			//for (String ss : p.list) System.out.println(ss);

			int m = 0;
			for (String str : p.list) {
				String[] strs = str.split("\\s");
				int sum = 0;
				for (int i = 0 ; i < strs.length ; i++) {
					sum += Integer.parseInt(strs[i]);
				}
				if (sum == s) { m++; }
			}
			System.out.println(m);
		}

	}
}

Measured memory_bytes: 67552
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define PER(i,b,a) for(ll i=b;i>a;i--)
#define forit(it,x) for(auto it=(x).begin();it!=(x).end();++it)
#define ull unsigned long long int
#define ld long double
#define prec(n) fixed<<setprecision(n)
#define test ll t; cin>>t; while(t--)
#define re return 0
#define pb push_back
#define PI 3.1415926535897932384626
#define MOD (ll)1000000007
#define fi first
#define se second
#define eb emplace_back
#define vll vector<ll>
#define vi  vector<int>
#define mpll map<ll,ll>
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)
const ll MAXI = (ll)1e9+7;
int main(){
    IOS;
//    test{
        string str;
        cin>>str;
        string str1;
        cin>>str1;
        int p=0;
        for(int i=0;i<str.size();i++){
            if(str[i]!=str1[i]){
                p++;
            }
        }
        cout<<p<<"\n";
//    }
re;
}


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

#include <math.h>
#include <stdlib.h>


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



int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int x, y ,z;
    cin >> x >> y >> z;
    printf("%d %d %d\n", z, x, y);

    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (l) < (x) && (x) < (r)

int main() {
    string S;
    cin >> S;
    cout << S.substr(0,3) << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;




int main() {
    string s;
    int x, y;
    cin >> s >> x >> y;
    bool turn = 0, chk = 1;
    int xcnt = 0, ycnt = 0, tcnt = 0, nx = 0;
    vector<int> vecx, vecy;
    REP2(i, 0, s.size()) {
        if (s[i] == 'F') {
            if (turn) {
                ycnt++;
            } else {
                xcnt++;
            }
        } else {
            if (turn) {
                turn = 0;
                vecy.push_back(ycnt);
                ycnt = 0;
            } else {
                turn = 1;
                vecx.push_back(xcnt);
                xcnt = 0;
            }
            tcnt++;
        }
    }
    if (xcnt) vecx.push_back(xcnt);
    if (ycnt) vecy.push_back(ycnt);
    x -= vecx[0];
    vecx.erase(vecx.begin());

    sort(vecx.begin(), vecx.end(), greater<int>());
    sort(vecy.begin(), vecy.end(), greater<int>());
    for (int nx : vecx) {
        if (x >= 0) {
            x -= nx;
        } else {
            x += nx;
        }
    }
    for (int ny : vecy) {
        if (y >= 0) {
            y -= ny;
        } else {
            y += ny;
        }
    }
    if (y == 0 && x == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No"  << endl;
    }
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define p pair<int, int>
using namespace std;

int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

int main(){
  int h, w;
  cin >> h >> w;
  char grid[h+1][w+1];
  int dist[h+1][w+1];
  int black = 0, white = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> grid[i][j];
      if(grid[i][j] == '.') white++;
      dist[i][j] = -1;
    }
  }
  queue<p> que;
  int gx = w-1, gy = h-1;
  que.push(p(0, 0));
  dist[0][0] = 0;
  while(!que.empty()){
    p cur = que.front(); que.pop();
    for(int i = 0; i < 4; i++){
      int nx = cur.second + dx[i];
      int ny = cur.first + dy[i];
      if(nx < 0 || nx >= w) continue;
      if(ny < 0 || ny >= h) continue;
      if(grid[ny][nx] != '#' && dist[ny][nx] == -1){
        dist[ny][nx] = dist[cur.first][cur.second] + 1;
        que.push(p(ny, nx));
      }
    }
  }
  if(dist[gy][gx] == -1) cout << -1 << endl;
  else cout << white - dist[gy][gx] - 1 << endl;
  return 0;
}


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

n = int(input())
S = list(map(int, input().split()))
SENTINEL = 1000000005
merge_count = 0


def main():
    mergeSort(S, 0, len(S))
    print(' '.join(map(str, S)))
    print(merge_count)


def merge(A, left, mid, right):
    # print("---merge start---")
    # print("A is {}".format(A))
    # print("left:{0}, mid:{1}, right{2}".format(left, mid, right))
    global merge_count

    L = A[left:mid] + [SENTINEL]
    R = A[mid:right] + [SENTINEL]

    # print("L:{}".format(L))
    # print("R:{}".format(R))

    i, j = 0, 0
    for k in range(left, right, 1):
        merge_count += 1
        # print("k:{0}".format(k))
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

    # print("A is {}".format(A))
    # print("----merge end----".format(A))


def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        # print("------mergeSort start--------")
        # print("left:{0}, mid:{1}, right:{2}".format(left, mid, right))
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)


if __name__ == '__main__':
    main()



Measured memory_bytes: 66580
#include<bits/stdc++.h>
using namespace std;
#pragma region atcoder
//using mint = modint998244353;
//These are for segment tree
/*int op(int a, int b){return max(a, b);}
int e(){return -1;}
bool f(int v){ return v < target;}
*/
#pragma endregion
#pragma region macros
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vl = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n - 1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
template<class T>bool chmax(T &a, const T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T b) { if (b<a) { a=b; return 1; } return 0; }
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 / gcd(a, b) * b;}
#pragma endregion
#pragma region debug for var, v, vv
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){cout << endl;int cnt = 0;for(const auto& v : vv){cout << cnt << "th : "; view(v); cnt++;} cout << endl;}
#pragma endregion
const ll mod = 1000000007;
const int inf = 1001001001;
const ll INF = 1001001001001001001;
const int MAX = 2000005;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, T; cin >> n >> T;
    vi a(n);
    rep(i,n) cin >> a[i];
    vi mn(n, inf), mx(n, -inf);
    mn[0] = a[0], mx[n - 1] = a[n - 1];
    for(int i = 1; i < n; i++){
        mn[i] = min(mn[i - 1], a[i]);
    }
    for(int i = n - 2; i >= 0; i--){
        mx[i] = max(mx[i + 1], a[i]);
    }
    int tmp = 0;
    for(int i = 0; i < n; i++){
        tmp = max(tmp, mx[i] - mn[i]);
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(tmp == mx[i] - mn[i]){
            if(a[i] == mn[i]) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4500
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>

using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll head[5] = {
	'M','A','R','C','H'
};
ll co[5] = {
	0,0,0,0,0
};

int main() {
	ll N;
	cin >> N;
	for (ll n = 0; n < N; n++) {
		string S;
		cin >> S;
		for (ll h = 0; h < 5; h++) {
			if (S[0] == head[h])co[h]++;
		}
	}
	ll ans = 0;
	ans += co[0] * co[1] * co[2];
	ans += co[0] * co[1] * co[3];
	ans += co[0] * co[1] * co[4];
	ans += co[0] * co[2] * co[3];
	ans += co[0] * co[2] * co[4];
	ans += co[0] * co[3] * co[4];
	ans += co[1] * co[2] * co[3];
	ans += co[1] * co[2] * co[4];
	ans += co[1] * co[3] * co[4];
	ans += co[2] * co[3] * co[4];
	cout << ans << endl;
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    
    string ans="Yes";
    int n;
    n = s.length();
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n/2+i+1]){
            ans = "No";
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("-ffloat-store")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define endl "\n"
#define f(i,a,b) for(int i=a;i<b;i++)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define mod 1000000007
#define inf  1e18
#define ps(x,y)   fixed<<setprecision(y)<<x
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define inp(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main() 
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
    FIO;
    int t;
    cin>>t;
    if(t==0){
        cout<<"1";
    }
    else
    {
        cout<<"0";
    }
    
return 0;   
}

Measured memory_bytes: 3628
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<vector>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
#define rep(i, n) for (i32 i = 0; i < (i32)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i32 n;
cin >> n;
vector<i64> a(n);
rep(i,n) cin >> a[i];
i64 cnt = 0;
for(i32 i = 1; i < n; i++){
    i64 tmp = a[i] - a[i - 1];
    if(tmp < 0){
        cnt -= tmp;
        a[i] -= tmp;
    }
}
cout << cnt << endl;
}

Measured memory_bytes: 4764
from collections import deque

n, m = map(int, input().split())

ab = [set() for _ in range(n+1)]
for _ in range(m):
    a, b = map(int, input().split())
    ab[a].add(b)
    ab[b].add(a)

def bfs(p):
    ans = [0 for _ in range(n + 1)]
    v = {1}
    q = deque([p])
    while q:
        p = q.popleft()
        c = ab[p] - v
        if len(c) == 0:
            continue
        for pp in c:
            ans[pp] = p
            v.add(pp)
            q.append(pp)
    return ans


ans = bfs(1)
ans = ans[2:]

for an in ans:
    if an == 0:
        print('No')
        exit(0)
print('Yes')
for an in ans:
    print(an)


Measured memory_bytes: 68624
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
l=lnii()
l.sort()

if n<=2:
  print(0)
  exit()

ans=0
for i in range(n-2):
  for j in range(n-1):
    for k in range(n):
      if l[i]<l[j]<l[k] and l[i]+l[j]>l[k]:
        ans+=1

print(ans)

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

using namespace std;

long long dfs_0(string, int, int, int, vector<vector<long long>>&, vector<vector<long long>>&);
long long dfs_1(string, int, int, int, vector<vector<long long>>&, vector<vector<long long>>&);

long long dfs_0(string n, int k, int i, int cnz,
        vector<vector<long long>>& dp0, vector<vector<long long>>& dp1) {
    if (i == static_cast<int>(n.size())) {
        if (cnz == k) {
            return 1;
        } else {
            return 0;
        }
    } else if (cnz > k) {
        return 0;
    }

    if (dp0[i][cnz] >= 0) {
        return dp0[i][cnz];
    }

    long long r = 0;
    if (n[i] == '0') {
        r += dfs_0(n, k, i + 1, cnz, dp0, dp1);
    } else if (n[i] == '1') {
        r += dfs_1(n, k, i + 1, cnz, dp0, dp1);
        r += dfs_0(n, k, i + 1, cnz + 1, dp0, dp1);
    } else if (n[i] > '1') {
        r += dfs_1(n, k, i + 1, cnz, dp0, dp1);
        r += (n[i] - '1') * dfs_1(n, k, i + 1, cnz + 1, dp0, dp1);
        r += dfs_0(n, k, i + 1, cnz + 1, dp0, dp1);
    }

    dp0[i][cnz] = r;
    return r;
}

long long dfs_1(string n, int k, int i, int cnz,
        vector<vector<long long>>& dp0, vector<vector<long long>>& dp1) {
    if (i == static_cast<int>(n.size())) {
        if (cnz == k) {
            return 1;
        } else {
            return 0;
        }
    } else if (cnz > k) {
        return 0;
    }

    if (dp1[i][cnz] >= 0) {
        return dp1[i][cnz];
    }

    long long r = 0;
    r += dfs_1(n, k, i + 1, cnz, dp0, dp1);
    r += 9 * dfs_1(n, k, i + 1, cnz + 1, dp0, dp1);

    dp1[i][cnz] = r;
    return r;
}

long long dfs(string n, int k) {
    vector<vector<long long>> dp0(n.size(), vector<long long>(k + 1, -1));
    vector<vector<long long>> dp1(n.size(), vector<long long>(k + 1, -1));
    return dfs_0(n, k, 0, 0, dp0, dp1);
}

int main() {
    string n;
    int k;
    cin >> n >> k;
    cout << dfs(n, k) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

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

ll lcm(ll a,ll b){
	ll g=gcd(a,b);
	return a/g*b;
}




int main() {

	int n;
	cin>>n;
	ll x=1;

	rep(i,n){
		ll t;
		cin>>t;
		x=lcm(x,t);
	}

	cout<<x<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  int N; cin >> N;
  vector<float> A(N);
  rep(i, N) cin >> A[i];
  float sum;
  rep(i, N) {
    sum += 1/A[i];
  }
  printf("%.10f\n", 1/sum);
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define long long int
#define endl "\n"
using namespace std;
//vector <int> v(n);

int32_t main()
{	IOS;
	int n, k,q,x;
	vector <int> freq(n);
	vector <bool> ans(n);
	cin>>n>>k>>q;
	for(int i=0;i<n;i++){
		
		freq[i]=0;
	}
	for(int i=0;i<q;i++){
		cin>>x;
		freq[x-1]+=1;
	}
	
	for(int i=0;i<n;i++){
		if((k-(q-freq[i]))>0)	ans[i]=true;
		else ans[i]=false;
		if(ans[i])	cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}


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


int main() {
	string s;
	cin >> s;
	
	if(s[2] == s[3] and s[4] == s[5])
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;		
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int va, vb, vc, x ,y;
  cin >> va >> vb >> vc >> x >> y;
 
  int sum = INT_MAX;
 
  for (int i = 0; i < 100001; i++) {
    int su = i * 2 * vc + max(0, x-i) * va + max(0, y-i) * vb;
    if (sum > su) {
      sum = su;
    }
  } 
  cout << sum << endl;
}

Measured memory_bytes: 3604