akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define d long double

#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define dscf(n) scanf("%Lf",&n)
#define pri(n) printf("%d ",(int)n)
#define lpri(n) printf("%lld ",n)
#define dpri(n) printf("%Lf ",n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define dprin(n) printf("%Lf\n",n)

#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define all(x) x.begin(),x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define bitcount(n) __builtin_popcount(n)
#define tc   int tt; scf(tt); while(tt--)
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265358979323846264

const ll M =1e9+7;
const int N = 1e6+7;


int main()
{
    int n;
    scf(n);
    int a[n];
    rep(i,0,n)
    scf(a[i]);
    map<int,int>m;
    vector<int>v;
    rep(i,0,n)
    {
        m[a[i]]++;
        if(m[a[i]]==1)
        v.pb(a[i]);
    }
    sort(all(v));
//    cout<<v.size()<<endl;
    int ans=0;
    rep(i,0,v.size())
    {
        rep(j,i+1,v.size())
        {
            rep(k,j+1,v.size())
            {
                if(v[i]+v[j]>v[k]){
              //  cout<<v[i]<<" "<<m[v[i]]<<" "<<v[j]<<" "<<m[v[j]]<<" "<<v[k]<<" "<<m[v[k]]<<endl;
                ans+=(m[v[i]]*m[v[j]]*m[v[k]]); }
            }
        }
    }
    pri(ans);
return 0;
}

Measured memory_bytes: 3768
def resolve():
    '''
    code here
    '''
    N = int(input())
    task = [[int(item) for item in input().split()] for _ in range(N)]

    task.sort(key=lambda x:x[1] ,reverse=True)


    res = task[0][1]
    for time, lim in task:
        if res > lim:
            res = lim
            
        res -= time

    print('Yes') if res >= 0 else print('No')

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 44076
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpl;
typedef vector<tuple<int, int, int>> vti;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int a, b;
    cin >> a >> b;
    int ans = b;
    if (a <= 5) ans = 0;
    else if (a <= 12) ans = b / 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
typedef		vector<ll>      vll;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef       pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
ll ar[1000000];
int main()
{
 //O_O ;
   ll t,count=0,a,ans=LLONG_MAX,temp;
   cin>>t;
  for(ll i=0;i<t;i++)
   {
       cin>>ar[i];
    }
     for(ll i=0;i<t;i++)
   {
       temp=ar[i];
       if(temp<ans){
       ans=min(ans,temp);
       count++;
       }
    }
   cout<<count<<nn;


    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
inline void write(int x)
{
	if(x<0)
	putchar('-'),x=-x;
	if(x>9)
	write(x/10);
	putchar(x%10+'0');
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	long long x,a,b,c,ans=0;
    a=read();
    b=read();
    c=read();
    x=read();
    for(int i=0;i<=a;i++)
        for(int j=0;j<=b;j++)
            for(int z=0;z<=c;z++){
                int k=i*500+j*100+z*50;
                if(k==x)
                   ans++;
                if(k>x)
                   break;
            }
    write(ans);
    return 0;
	return 0;
}
/*
*/
/*
*/
/*
*/


Measured memory_bytes: 256
s = input()

l = len(s)
start = 2 if l % 2 == 0 else 1

isFound = False
for i in range(start, len(s), 2):
    m = int((l-i)/2)
    if s[0:m] == s[m:(l-i)]:
        isFound = True
        print(l-i)
        break

if not isFound:
    print(-1)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;

int main(){
    int n;
    cin >> n;
    cout << (double)(n-n/2)/(double)n << endl;
}


Measured memory_bytes: 256
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("-1"),0;
#define N 500055
//#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,fa[N],in1[N],ans,x,y;
int nedge,head[N*2],to[N*2],Next[N*2];
#define V to[i]
void add(int a,int b){
   Next[++nedge]=head[a];head[a]=nedge;to[nedge]=b;
}
int dfs(int x,int fa){
	int flag=0,p=0,sum=0;
	go(i,x){
		if (fa==V) continue;
		p=dfs(V,x);
		if (p==0&&flag==1) sum++;
		if (p==0&&flag==0) flag=1;
		sum+=p;
	}
	return sum;
} 
signed main(){
	n=read();
	F(i,1,n-1){
		x=read();y=read();
		add(x,y);add(y,x);in1[x]++;in1[y]++;
	}
	int pd=0;
	F(i,0,n-1){
		if (in1[i]>=3){
			ans=dfs(i,-1);pd=1;
			break;
		} 
	}
	if (!pd){
		wrn(1);return 0;
	}
//	ans=max(ans,1);
	wrn(ans);
	return 0;
}

Measured memory_bytes: 14720
#include <stdio.h>
#define MAX 100000
int Partition(int[],int,int);
int Partition(int A[],int p,int r){
        int x=A[r];
        int i=p-1,j,k;
        for(j=p; j<r; j++) {
                if(A[j]<=x) {
                        i++;
                        k=A[i];
                        A[i]=A[j];
                        A[j]=k;

                }
        }
        k=A[i+1];
        A[i+1]=A[r];
        A[r]=k;
        return i+1;
}
int main(){
        int A[MAX];
        int n,i,q;
        scanf("%d",&n);
        for(i=0; i<n; i++) {
                scanf("%d",&A[i]);
        }
        q=Partition(A,0,n-1);
        for(i=0; i<n; i++) {
                if(i) printf(" ");
                if(i==q) {
                        printf("[");

                }
                printf("%d",A[i]);
                if(i==q) {

                        printf("]");
                }

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



Measured memory_bytes: 2248
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	rep(i, n) {
		int base[3];
		int cnt = 0;
		int out = 0;
		rep(i123, 3) { base[i123] = 0; }
		while (true) {
			string thistime;
			cin >> thistime;
			if (thistime == "HIT") {
				cnt += base[2];
				base[2] = base[1];
				base[1] = base[0];
				base[0]=1;
			}
			else if (thistime == "OUT") {
				out++;
				if (out == 3) { break; }
			}
			else {
				cnt += base[2] + base[1] + base[0] + 1;
				base[2] = base[1] = base[0] = 0;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
#include<iostream>
using namespace std;
int main(){
int a,b;
cin >> a >>b;
if (a<b){
cout <<"a < b"<<endl;
}else if (a>b){
cout <<"a > b"<<endl;
}else if (a==b){
cout <<"a == b"<<endl;
}
return 0;
}



Measured memory_bytes: 3076
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>

using namespace std;

long long int n, a[100000];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a + n);
	
	long long int x = 0,y = 0;
	for(int i = n-1; i > 0; i--){
		if(a[i] == a[i-1]){
			if(x == 0){
				x = a[i];
				i--;
			}
			else{
				y = a[i];
				break;
			}
		}
	}
	cout << x * y << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	ll N, M;
	cin >> N >> M;

	ll sum = N * M;
	if (N == 1LL && M == 1LL)
		cout << 1 << endl;
	else if (N == 1LL || M == 1LL)
		cout << sum - 2 << endl;
	else
		cout << sum - ((N-1) + (M-1)) * 2 << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */


/** Problem1335 : Equal Sum Sets **/
int N, K, S;
int dp[21][11][151];
int solve(int n, int k, int s)
{
	//cerr << n << " " << k << " " << s << endl;
	if (k == K)
		return S==s;
	if (n>N)
		return 0;
	if (dp[n][k][s]>=0) return dp[n][k][s];
	
	int res=0;
	res += solve(n+1, k, s);
	res += solve(n+1, k+1, s+n);
	return dp[n][k][s] = res;
}

int main()
{
	while (cin>>N>>K>>S, N) {
		memset(dp, -1, sizeof(dp));
		cout << solve(1, 0, 0) << endl;
	}
}

Measured memory_bytes: 1304
from collections import deque

n = int(input())
orders = [deque([x - 1 for x in list(map(int, input().split()))] + [-1]) for _ in range(n)]

nxt = [orders[i].popleft() for i in range(n)]
days = [0 for _ in range(n)]

q = deque([i for i in range(n)])
while q:
	a = q.popleft()
	b = nxt[a]
	if nxt[nxt[a]] == a:
		days[a], days[b] = [max(days[a], days[b]) + 1 for _ in range(2)]
		nxt[a] = orders[a].popleft()
		nxt[b] = orders[b].popleft()
		q.append(a)
		q.append(b)

if sum(nxt) == -n:
	print(max(days))
else:
	print(-1)


Measured memory_bytes: 37980
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

N = int(input())
ans = 0

for i in range(1, N):
    ans += math.floor((N-1)/i)

ans = ans
print(ans)


Measured memory_bytes: 68964
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

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

int main()
{
        int N, M;
        cin >> N;
        map<string, int> sma, tma;

        vector<string> s(N + 1);
        rep(i, N) cin >> s[i];
        cin >> M;
        vector<string> t(M + 1);
        rep(i, M) cin >> t[i];
        int ans = 0;

        rep(i, N)
        {
                int cnt = 0;
                rep(j, N) if (s[i] == s[j]) cnt++;
                rep(j, M) if (s[i] == t[j]) cnt--;

                ans = max(ans, cnt);
        }

        cout << ans << endl;

        return 0;
}


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

using namespace std;

int main() {
  int N, Ai;
  cin >> N;
  
  vector<int> A(N);

  for(int i=2; i<=N; ++i) {
    cin >> Ai;
    ++A[Ai-1];
  }

  for(int i=0; i<N; ++i) {
    cout << A[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    string s, t, x;
    int a, b;
    cin >> s >> t >> a >> b >> x;
    if (x == s) a--;
    else b--;
    cout << a << " " << b << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=8e18;
const int32_t LOG=21;
const int MOD=MOD1;


vector<pair<int,pii>> v[55][2555];
bool check[55][2555];
int dist[55][2555];
int c[55];
int d[55];

vector<pair<int,pii>> v1[55];

void dj(pii source)
{
    rep(i,0,55)rep(j,0,2551)
    {
        dist[i][j]=INF;
    }
    
    priority_queue<pair<int,pii>> pq;
    pq.push({0,source});

    while(!pq.empty())
    {
         pair<int,pii> p=pq.top();
         pq.pop();
         int ver1=p.s.f,ver2=p.s.s;
         int val=-p.f;
         if(check[ver1][ver2])continue;
         check[ver1][ver2]=true;
         for(auto it:v[ver1][ver2])
         {
              if(dist[it.s.f][it.s.s]==-1 || dist[it.s.f][it.s.s]>val+it.f)
              {
                dist[it.s.f][it.s.s]=val+it.f;
                pq.push({-(val+it.f),it.s});
              }  
         }
    }

}

int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      {
           int n,m,cur_coins;
           cin>>n>>m>>cur_coins;
           cur_coins=min(cur_coins,2500LL);
            rep(i,0,m)
            {
                int u,v,a,b;
                cin>>u>>v>>a>>b;
                v1[u].push_back({v,{a,b}});
                v1[v].push_back({u,{a,b}});
            }
            rep(i,1,n+1)
            {
                cin>>c[i]>>d[i];
            }

            rep(i,1,n+1)
            {
                 rep(j,0,2501)
                 {
                       v[i][j].push_back({d[i],{i,min(c[i]+j,2500LL)}});
                       for(auto it:v1[i])
                       {
                           int ver=it.f;
                           if(j>=it.s.f)
                           v[i][j].push_back({it.s.s,{ver,j-it.s.f}});          
                       }
                 }
            }

            dj({1,cur_coins});
            rep(i,2,n+1)
            {
                int ans=INF;
                rep(j,0,2501)
                if(dist[i][j]!=-1)
                ans=min(ans,dist[i][j]);
                cout<<ans<<endl;
            }
    
      }     
      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 31496
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int po=sc.nextInt();
        int po2=sc.nextInt();
        System.out.println(Math.max(Math.max(po+po-1,po+po2),po2+po2-1));
    }
}


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

using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;

int main()
{
	std::ios_base::sync_with_stdio(0);
	
	u32 a, b;

	std::cin >> a >> b;

	if(a>9 || b>9)
	{
		std::cout << "-1\n";
	}
	else
	{
		std::cout << a*b << "\n";
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int bag[5005],ans,a[5005],n,k;
void bs(int l,int r,int num) {
	int mid=l+r>>1;
	bag[0]=num;
	for(int i=1;i<=n;++i) {
		if(i==mid) continue;
		for(int j=k-1;j>=0;--j) if(bag[j]==num&&j+a[i]<k) bag[j+a[i]]=num;
	}bool flag=true;
	for(int j=max(0,k-a[mid]);j!=k;++j) if(bag[j]==num) {flag=false;break;}
	if(!flag) ans=mid;if(l==r) return;
	if(!flag) bs(l,mid,num+1);
	else bs(mid+1,r,num+1);
}
int main(){
	scanf("%d%d",&n,&k);ans=n+1;
	for(int i=n;i;--i) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	bs(1,n,1);
	printf("%d",ans-1);
	return 0;
}

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

int main(void){

    int n = 0;
    double ave;
    int p = 0;
    int sum = 0;

    scanf("%d", &n);

    int x[n];

    for (int i = 0; i < n; i++){

        scanf("%d", &x[i]);
        ave = ave + (double)x[i];
    }
    //printf("%lf\n", ave);
    ave = ave / (double)n;
    //printf("%lf\n", ave);
    p = (int)round(ave);
    //printf("%d\n", p);

    for (int j = 0; j < n; j++){

        sum = sum + (x[j] - p) * (x[j] - p);
    }

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

    return 0;
}

Measured memory_bytes: 128
a = int(input())
b = int(input())
c = int(input())
result = 0
x = int(input())
for i in range(a+1):
  for j in range(b + 1):
    for m in range(c+1):
      if 500 * i + 100 * j + 50*m == x:
        result+= 1
print(result)
      

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v) cerr << #v << ":"; rep(i, v.size()) cerr << " " << v[i]; cerr << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n;
    cin >> n;
    n %= 10;
    string ans;
    if(n == 3) {
        ans = "bon";
    } else if (n == 0 || n == 1 || n == 6 || n == 8) {
        ans = "pon";
    } else {
        ans = "hon";
    }
    cout << ans << endl;
}


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


int main(){
	int N , A , B ;
	scanf("%d%d%d",&N,&A,&B);
	if( A+ B <= N ){
		printf("%d %d\n",min(A,B),0);
	}
	else{
		printf("%d %d\n",min(A,B),A+B-N);
	}
	return 0 ;
}

Measured memory_bytes: 256
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7


n, k = map(int, input().split())
s = input()

s = list(s)
s[k-1] = s[k-1].lower()
ans_s = ""
for i in s:
    ans_s += i
print(ans_s)

Measured memory_bytes: 13604
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;

typedef long long ll;

const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int INF = 1e9;
const double PI = acos(-1.0);

int t, n, k, a[N], dp[N];

int main() {
    cin >> n;
//    cin >> k;
    k = 2;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        int mn = INF;
        for (int j = max(1, i - k); j < i; ++j) {
            mn = min(mn, dp[j] + abs(a[i] - a[j]));
        }
        if (mn == INF)
            mn = 0;
        dp[i] += mn;
    }
    cout << dp[n];
}


Measured memory_bytes: 1024
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    X, K, D = map(int, input().split())

    X = abs(X)
    div, mod = X // D, X % D
    if K <= div:
        print(X - K * D)
    else:
        print(abs(mod - D * ((K - div) % 2 == 1)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9116
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define PER(i,a,b) for(int i=(a);i>=(b);i--)
#define RVC(i,S) for(int i=0;i<(S).size();i++)
#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
     
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
/*============ Header Template ============*/

int f[5005][5005];
int g[5005];
int ai[5005];

int main() {
    int n,m;
    read(n);read(m);
    REP(i,1,n) read(ai[i]),ai[i]=min(ai[i],m);
    f[1][0]=1;
    REP(i,2,n) {
        memcpy(f[i],f[i-1],sizeof(f[i-1]));
        REP(j,ai[i-1],m) f[i][j]|=f[i-1][j-ai[i-1]]; 
    } 
    g[0]=1;int cnt=0;
    PER(i,n,1) {
        if(i<n) {
            PER(j,m,ai[i+1]) g[j]|=g[j-ai[i+1]];
        }
        int ps=m-1,fl=0;
        REP(j,0,m-1) if(f[i][j]) {
            while(ps && (!g[ps] || j+ps>=m)) ps--;
            if(ps>=0 && g[ps] && j+ps<m && j+ps>=m-ai[i]) fl=1;
        } cnt+=fl;
    } printf("%d\n",n-cnt);
    return 0;
}

Measured memory_bytes: 98048
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

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

    cout << pow(n, 3);
}

Measured memory_bytes: 4196
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

int main()
{
    std::string line;
    std::getline(std::cin, line);

    for (int i = 0; i < line.length(); ++i) {
        char c = line[i];
        if ('a' <= c && c <= 'z') {
            c += ('Z' - 'z');
        } else if ('A' <= c && c <= 'Z') {
            c -= ('Z' - 'z');
        }
        std::cout << c;
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <string>
#include <sstream>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int n, m, l, k, a, h;
int imp[100];
int d[100][100],dis[100][100],dist[100];
bool used[100];

void dijkstra(int s,int V){
	fill(dist, dist+V, INF);
	fill(used, used+V, false);
	dist[s] = 0;
	
	while(true){
		int v = -1;
		
		for(int u = 0; u < V; u++){
			if(!used[u] && (v == -1 || dist[u] < dist[v])) v = u;
		}
		
		if(v == -1) break;
		used[v] = true;
		
		for(int u = 0; u < V; u++){
			dist[u] = min(dist[u], dist[v] + dis[v][u]);
		}
	}
}

void solve(){
	rep(i,100) rep(j,100){
		d[i][j] = INF;
		dis[i][j] = INF;
	}
	rep(i,100) d[i][i] = 0;
	rep(i,100) dis[i][i] = 0;
	imp[0] = a;
	rep(i,l) scanf("%d", &imp[i+1]);
	imp[l+1] = h;
	rep(i,k){
		int x, y, t;
		scanf("%d%d%d", &x, &y, &t);
		d[x][y] = t;
		d[y][x] = t;
	}
	rep(u,n) rep(i,n) rep(j,n) d[i][j] = min(d[i][j],d[i][u]+d[u][j]);
	rep(i,l+2){
		rep(j,l+2){
			if(d[imp[i]][imp[j]] <= m) dis[i][j] = d[imp[i]][imp[j]];
		}
	}
	dijkstra(0, l+2);
	if(dist[l+1] == INF) printf("Help!\n");
	else if(dist[l+1] < m) printf("%d\n", dist[l+1]);
	else printf("%d\n", dist[l+1]*2-m);
}

int main(){
	while(scanf("%d%d%d%d%d%d",&n,&m,&l,&k,&a,&h),n||m||l||k||a||h) solve();
}

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

int main() {
    ll a, b, k;
    cin >> a >> b >> k;
	 ll aa = a;
	 a = max(a-k, 0ll);
	 k -= min(aa, k);
	 
	 b = max(b-k, 0ll);
	
	 cout << a << " " << b;
}


Measured memory_bytes: 256
n = int(input())
t=[0]
x=[0]
y=[0]
for i in range(n):
    _t, _x, _y = map(int, input().split())
    t.append(_t)
    x.append(_x)
    y.append(_y)

for i in range(1,n+1):
    dt = t[i] - t[i-1]
    dx = x[i] - x[i-1]
    dy = y[i] - y[i-1]
    if abs(dx) + abs(dy) > dt or (dx+dy) % 2 != 0 and dt % 2 == 0 or (dx+dy) % 2 == 0 and dt % 2 != 0:
        break

else:
    print("Yes")
    exit()
print("No")
    

Measured memory_bytes: 11812
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.ReadLine();
        }

        public void Solve(ConsoleInput cin)
        {
            int N = cin.ReadInt;
            int[] t = new int[110000], x = new int[110000], y = new int[110000];

            t[0] = x[0] = y[0] = 0;
            for(int i = 0; i < N; i++)
            {
                string s = cin.ReadLine;
                t[i+1] = int.Parse(s.Split(' ')[0]);
                x[i+1] = int.Parse(s.Split(' ')[1]);
                y[i+1] = int.Parse(s.Split(' ')[2]);
            }

            bool can = true;
            for(int i = 0; i < N; i++)
            {
                int dt = t[i + 1] - t[i];
                int dist = Abs(x[i + 1] - x[i]) + Abs(y[i + 1] - y[i]);

                if (dt < dist) can = false;
                if (dt % 2 != dist % 2) can = false;
                if (can == false) break;
            }
            Console.WriteLine(can ? "Yes" : "No");
        }


    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long num) { var ret = new string[num]; for (long i = 0; i < num; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long num) { var ret = new int[num]; for (long i = 0; i < num; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long num) { var ret = new long[num]; for (long i = 0; i < num; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 16472
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    vector<int> A(N+1);
    vector<int> B(N);

    for (int i = 0; i < N+1; ++i) {
        cin >> A[i];
    }

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

    ll ans = 0;

    for (int i = 0; i < N; ++i) {
        int kill_i = min(A[i], B[i]);
        A[i] -= kill_i;
        B[i] -= kill_i;
        
        int kill_ii = min(A[i+1], B[i]);
        A[i+1] -= kill_ii;
        B[i] -= kill_ii;

        ans += kill_i + kill_ii;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main(){
  long long int n,m;
  cin>>n>>m;
  vector<vector<long long int>>x(n,vector<long long int>(2));
  for(long long int i=0;i<n;i++){
    for(long long int j=0;j<2;j++){
      cin>>x[i][j];
    }
  }
  sort(x.begin(),x.end());
  
  long long int c=0,a;
  for(long long int i=0;i<n;i++){
    if(c<m){  
      c+=x[i][1];
      a=i;
    }
  }
  long long int r=0;
  for(long long int i=0;i<=a;i++){
    r+=x[i][0]*x[i][1];
  }
  r-=x[a][0]*(c-m);
  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 5760
S = input()

for i in range(len(S) - 1):
    if S[i] == S[i + 1]:
        print("{} {}".format(i + 1, i + 2))
        exit()

for i in range(len(S) - 2):
    if S[i] == S[i + 2]:
        print("{} {}".format(i + 1, i + 3))
        exit()

print("-1 -1")


Measured memory_bytes: 3188
import java.util.*;
import static java.lang.System.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		C(sc);
	}
	
	public static void A(Scanner sc) {
		int a = sc.nextInt();
		int b = sc.nextInt();
		if((a*b)%2==1) out.println("Odd");
		else out.println("Even");
	}
	
	public static void B(Scanner sc) {
		String s1 = sc.next();
		String s2 = sc.next();
		int x = Integer.parseInt(s1+s2);
		for(int i=0;Math.pow(i,2)<=x;i++) {
			if(Math.pow(i, 2)==x) {
				out.println("Yes");
				return;
			}
		}
		out.println("No");
	}
	
	public static void C(Scanner sc) {
		int N = sc.nextInt();
		Point[] lis = new Point[N+1];
		lis[0] = new Point(0,0,0);
		for(int i=1;i<=N;i++) lis[i]=new Point(sc.nextInt(),sc.nextInt(),sc.nextInt());
		Arrays.sort(lis, new Comparator<Point>() {
			public int compare(Point d1, Point d2) {
				return d1.t-d2.t;
			}
		});
		for(int i=0;i<N;i++) {
			if((lis[i+1].t-lis[i].t-Math.abs(lis[i].x-lis[i+1].x)-Math.abs(lis[i].y-lis[i+1].y))%2==1 ||
					(lis[i+1].t-lis[i].t-Math.abs(lis[i].x-lis[i+1].x)-Math.abs(lis[i].y-lis[i+1].y))<0) {
				out.println("No");
				return;
			}
		}
		out.println("Yes");
	}
	
	public static class Point{
		int t;
		int x;
		int y;
		public Point(int t, int x, int y) {
			this.t = t;
			this.x = x;
			this.y = y;
		}
	}
}


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

int main(){
  ll K,N;
  cin>>K>>N;
  vll A(N);
  rep(i,N){
    cin>>A.at(i);
  }
  ll l=0;
  sort(all(A));
  rep(i,N-1){
    l=max(l,A.at(i+1)-A.at(i));
  }
  l=max(l,K-A.at(N-1)+A.at(0));
  cout<<K-l<<endl;
}


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

class Program
{
    public static void Main( )
    {

        var input = Console.ReadLine( ).Split( ).Select( int.Parse ).ToArray( );
        int N = input[ 0 ];
        int M = input[ 1 ];


        for ( int gcd = M / N; gcd >= 2; gcd-- )
        {
            // その数を最大公約数としてa1~anを構成できるか
            if ( M % gcd == 0 )
            {
                Console.WriteLine( gcd );
                return;
            }
        }
        Console.WriteLine(1);
    }




}

Measured memory_bytes: 28312
#include<iostream>
#include<string>

using namespace std;

int N, M;
string A[50], B[50];

bool match(int x, int y) {
	for (int sx = 0; sx < M; sx++) {
		for (int sy = 0; sy < M; sy++) {
			if (A[sx + x][sy + y] != B[sx][sy])return false;
		}
	}
	return true;
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++)cin >> A[i];
	for (int i = 0; i < M; i++)cin >> B[i];

	for (int i = 0; i <= N - M; i++) {
		for (int j = 0; j <= N - M; j++) {
			if (match(i, j)) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll n,m;
	cin>>n>>m;
	ll a[n+1],d[n+1];
	for(ll k=1;k<=n;k++)
	    cin>>a[k];
	fill(d,d+n+1,1e18);
	d[1]=0;
	d[2]=abs(a[2]-a[1]);
	for(ll k=3;k<=n;k++){
		ll v=k-m;
		if(m>k-1)v=1;
		for(int i=k-1;i>=v;i--){
			d[k]=min(d[i]+abs(a[k]-a[i]),d[k]);
		}
	}    
	cout<<d[n];
	return 0;
}

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define DBG 1
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define loop(n) rep(loop,(0),(n))
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

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

  string s; cin >> s;
  s[3]='8';
  cout<<s<<endl;

    return 0;
}


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

int main(void){
	string s;
	cin>>s;
	int ans=0,cnt=0;
	rep(i,s.length()){
		if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T')cnt++;
		else cnt=0;
		if(ans < cnt)ans=cnt;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

D = i()
c = l()
s = [l() for _ in range(D)]
t = [i() for _ in range(D)]
last = [0]*26
ans = 0
for i in range(D):
    last[t[i]-1] = i+1
    ans += s[i][t[i]-1]
    for j in range(26):
        ans -= c[j]*(i+1-last[j])
    print(ans)

Measured memory_bytes: 79756
#include <bits/stdc++.h>
#if 1
#define int long long
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#else
#define MAX INT_MAX
#define MIN INT_MIN
#endif
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second
const int NIL = -1;
const int MOD = 1000000007;
#define REP(i,n) for (int i=0; i < (n); ++i)
#define FOR(i,a,b) for (int i=(a); i < (b); ++i)
using namespace std;

int get_gcd(int a, int b){while(1){if (a < b) swap(a, b); if (b == 0) return a; a %= b;}}
int get_lcm(int a, int b){return a * b / get_gcd(a, b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int bs[51];

// n次元バーガーの下からx枚に含まれるパティの枚数
// n>=0, x>=1
int get_patty_num(const int& n, const int& x){

  if (n==0) {
    return 1;
  }
  else if (x <= 1) {
    return 0;
  }
  else if (x <= 1 + bs[n-1]) {
    return get_patty_num(n-1, x-1);
  }
  else if (x <= 2 + bs[n-1]) {
    return get_patty_num(n-1, bs[n-1]) + 1;
  }
  else if (x <= 2 + 2*bs[n-1]) {
    return get_patty_num(n-1, bs[n-1]) + 1 + get_patty_num(n-1, x - 2 - bs[n-1]);
  }
  else {
    return 2 * get_patty_num(n-1, bs[n-1]) + 1;
  }
};

signed main () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  bs[0] = 1;
  for (int i =1; i<=50; i++) {
    bs[i] = 3 + 2*bs[i-1];
  }

  int n, x;
  cin >> n >> x;

  cout << get_patty_num(n, x) << endl;

  return 0;
}


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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = (l);x<=(u);x++)
#define RREP(x,l,u) for(ll x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,m,TOT;

int G[16][16];

int f[(1<<15)+5][16];

int All[(1<<15)+5];

void Work(){
	REP(sta,0,(1<<n)-1)REP(i,1,n)f[sta][i]=-1000000000;f[1][1]=0;
	REP(sta,0,(1<<n)-1)
		REP(i,1,n)if((sta>>i-1)&1){
			REP(j,1,n)if(j!=i&&((sta>>j-1)&1)&&G[i][j])f[sta][i]=max(f[sta][i],f[sta^(1<<i-1)][j]+G[i][j]);
			for(int s=sta;s;s=(s-1)&sta)if(!((s>>i-1)&1))f[sta][i]=max(f[sta][i],f[sta^s][i]+All[s^(1<<i-1)]);
		}
	iout(TOT-f[(1<<n)-1][n]);
}

void Init(){
	read(n,m);
	REP(i,1,m){
		int u,v,w;
		read(u,v,w);
		G[u][v]=G[v][u]=w;
		TOT+=w;
	}
	REP(sta,0,(1<<n)-1){
		REP(i,1,n)if((sta>>i-1)&1)
			REP(j,i+1,n)if((sta>>j-1)&1)All[sta]+=G[i][j];
	}
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}
int main() {
	int n;cin >> n;
	cout << 800*n - 200*(n/15) << endl;
}

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

int main() {
  string S;
  int X,Y,Z,A,B,C,ans,a,b;
  cin >>S;
  if(S[3]==S[2]&&S[5]==S[4]){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int ac =0,wa =0,tle =0,re =0;
  string k;
  cin>>n;
  //n++;
  while(n>=0){
    n--;
    getline(cin,k);
    if(k=="AC"){ac++;}
    else if(k =="WA"){wa++;}
    else if(k=="TLE"){tle++;}
    else if(k =="RE"){re++;}
  }
  cout<<"AC"<<" x "<<ac<<endl;
  cout<<"WA"<<" x "<<wa<<endl;
  cout<<"TLE"<<" x "<<tle<<endl;
  cout<<"RE"<<" x "<<re<<endl;

  return 0;
}


Measured memory_bytes: 3628
import numpy as np

N = int(input())
A = np.array(input().split(),dtype=np.int64)

xor = np.bitwise_xor.reduce(A)
A = np.concatenate([np.array([1<<i for i in range(60) if xor&(1<<i)],np.int64),A])

for k in range(60,-1,-1):
    bit = 1<<k
    one = (A&bit != 0)
    i = np.where(one & (A < (1<<(k+1))))[0]
    if len(i) == 0:
        continue
    i = i[0]
    x = A[i]
    A[one] ^= x
    A[i] = x

red = np.bitwise_xor.reduce(A)
blue = red^xor
answer = red + blue
print(answer)


Measured memory_bytes: 28996
import os
import sys

import numpy as np


def solve(inp):
    UNIONFIND_TABLE = []

    def unionfind_init(n):
        UNIONFIND_TABLE.append(np.full(n, -1, dtype=np.int64))
        return len(UNIONFIND_TABLE) - 1

    def unionfind_getroot(ins, x):
        table = UNIONFIND_TABLE[ins]
        stack = []
        while table[x] >= 0:
            stack.append(x)
            x = table[x]
        for y in stack:
            table[y] = x
        return x

    def unionfind_unite(ins, x, y):
        table = UNIONFIND_TABLE[ins]
        r1 = unionfind_getroot(ins, x)
        r2 = unionfind_getroot(ins, y)
        if r1 == r2:
            return
        d1 = table[r1]
        d2 = table[r2]
        if d1 <= d2:
            table[r2] = r1
            table[r1] += d2
        else:
            table[r1] = r2
            table[r2] += d1

    def unionfind_find(ins, x, y):
        return unionfind_getroot(ins, x) == unionfind_getroot(ins, y)

    def unionfind_getsize(ins, x):
        table = UNIONFIND_TABLE[ins]
        return -table[unionfind_getroot(ins, x)]

    n = inp[0]
    q = inp[1]
    ttt = inp[2::3]
    uuu = inp[3::3]
    vvv = inp[4::3]
    ins = unionfind_init(n)
    ans = []
    for i in range(q):
        if ttt[i] == 0:
            unionfind_unite(ins, uuu[i], vvv[i])
        else:
            ans.append(int(unionfind_find(ins, uuu[i], vvv[i])))
    return ans


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8[:],)')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    # noinspection PyUnresolvedReferences
    from my_module import solve
else:
    from numba import njit

    solve = njit('(i8[:],)', cache=True)(solve)
    print('compiled', file=sys.stderr)

inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
ans = solve(inp)
print('\n'.join(map(str, ans)))


Measured memory_bytes: 41192
#include<iostream>
const long long MOD= 1000000007;
using namespace std;
long long Kurikaeshi(long long a, long long N, long long p){
  if( N == 0) return 1;
  long long rt;
  if(N % 2 == 0){
    rt = Kurikaeshi(a, N / 2, p);
    rt = rt * rt % p;
    return rt;
  }
  if(N % 2 == 1){
    rt = Kurikaeshi(a, N - 1, p);
    rt = a * rt % p;
    return rt;
  }
}
int main(){
  long long n, ans = 1,tmp,Ax,Bx,Ay,By, NF = 1;int a, b;
  cin >> n >> a >> b;
  ans = Kurikaeshi(2,n,MOD);
  ans--;
  Ax = 1; Ay = 1; Bx = 1; By = 1;
  for(int i = 1; i <= a; i++){
    Ax *= (n + 1 - i);
    Ax = Ax % MOD;
    Ay *= i;
    Ay = Ay % MOD;
  }
  Bx = Ax; By = Ay;
  for(int i = a + 1; i <= b; i++){
    Bx *= (n + 1 - i);
    Bx = Bx % MOD;
    By *= i;
    By = By % MOD;
  }
  /*
  for(int i = 0; i < MOD - 2; i++){
    Ax *= Ay;
    Bx *= By;
    Ax = Ax % MOD;
    Bx = Bx % MOD;
  }
  */
  Ax *= Kurikaeshi(Ay,MOD-2,MOD);
  Bx *= Kurikaeshi(By,MOD-2,MOD);
  Ax = Ax % MOD;
  Bx = Bx % MOD;
  ans = ans - Ax - Bx + 4 * MOD;
  ans = ans % MOD;
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
import Data.List

solve :: String -> String
solve s = solve' s ['a'..'z']

solve' :: String -> String -> String
solve' s t
  | t == "" = "None"
  | otherwise = if elem x s then solve' s xs else [x]
    where
      x = head t
      xs = tail t

main = do
  s <- getLine
  putStrLn $ solve s


Measured memory_bytes: 10128
#include <iostream>

using namespace std;

int main() {
  int fives = 0;
  int sevens = 0;
  int num;
  while (cin >> num) {
    if (num == 5) fives++;
    if (num == 7) sevens++;
  }
  cout << (fives == 2 && sevens == 1 ? "YES" : "NO") << endl;
  
  return 0; 
}

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

int main(){
  int a, b;
  string s;
  cin >> a >> b >> s;

  for(int i = 0; i < a; i++){
    if(!isdigit(s[0])){
      puts("No");
      return 0;
    }
  }
  
  if(s[a]!='-'){
    puts("No");
    return 0;
  }
  
  for(int i = a+1; i < s.size(); i++){
    if(!isdigit(s[i])){
      puts("No");
      return 0;
    }
  }
  
  puts("Yes");
}


Measured memory_bytes: 256