akhauriyash/Code-Regression huggingface dataset:
//ABC148 C

#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = s; i < (int)(n); i++)
const lint mod = 1000000007;


lint ans = 0;
lint a,b;


//最大公約数
lint gcd(lint a, lint b){
  if (a%b == 0){
      return(b);
  }
  else{
      return(gcd(b, a%b));
  }
}
//最小公倍数
lint lcm(lint a, lint b){
   return ((a * b) / gcd(a, b));
}

int main() {
  cin >> a >> b;
  
  ans = lcm(a,b);
  printf("%lld\n",ans);
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

const int INF=1001001001001001001ll;

int par[20][111111];
int A[111111];

int N;
vint G[111111];

int dep[111111];
int latte[111111];
int dp[20][111111];
vint lis[111111];
void dfs(int v,int p,int d){
    dep[v]=d;
    par[0][v]=p;
    latte[v]=A[v];
    lis[v].pb(0);
    lis[v].pb(0);
    for(auto u:G[v]){
        if(u==p)continue;
        dfs(u,v,d+1);
        latte[v]+=latte[u];
        lis[v].pb(latte[u]);
    }
}

int lca(int a,int b){
    if(dep[a]<dep[b])swap(a,b);
    rep(i,20)if((dep[a]-dep[b])>>i&1)a=par[i][a];
    if(a==b)return a;
    for(int i=19;i>=0;i--)if(par[i][a]!=par[i][b])a=par[i][a],b=par[i][b];
    return par[0][a];
}

signed main(){
    cin>>N;
    rep(i,N)cin>>A[i];
    rep(i,N-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);G[b].pb(a);
    }

    dfs(0,-1,0);

    rep(i,N){
        sort(all(lis[i]));
        reverse(all(lis[i]));
    }
    for(int i=1;i<N;i++){
        int p=par[0][i];
        if(lis[p][0]==latte[i]){
            dp[0][i]=lis[p][1];
        }
        else{
            dp[0][i]=lis[p][0];
        }
    }


    rep(i,19){
        rep(j,N){
            if(par[i][j]==-1){
                par[i+1][j]=-1;
                dp[i+1][j]=dp[i][j];
            }
            else{
                par[i+1][j]=par[i][par[i][j]];
                dp[i+1][j]=max(dp[i][par[i][j]],dp[i][j]);
            }
        }
    }


    int sumall=accumulate(A,A+N,0ll);


    int Q;cin>>Q;
    while(Q--){
        int a,b;
        cin>>a>>b;a--;b--;
        int p=lca(a,b);
        int ans=0;
        rep(lattemalta,2){
            swap(a,b);
            int x=a;
            if(a==p)continue;
            chmax(ans,lis[a][0]);
            int d=dep[x]-dep[p]-1;
            rep(i,20){
                if(d>>i&1){
                    chmax(ans,dp[i][x]);
                    x=par[i][x];
                }
            }
            a=x;



        }

        {
            bool flaga=false,flagb=false;
            for(auto x:lis[p]){
                if(!flaga&&x==latte[a]){
                    flaga=true;
                    continue;
                }
                if(!flagb&&x==latte[b]){
                    flagb=true;
                    continue;
                }
                chmax(ans,x);
                break;
            }
        }
        chmax(ans,sumall-latte[p]);
        cout<<ans<<endl;
    }
    return 0;
}



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

int main()
{
  int N;
  int a[110];
  int res=0;
  cin >> N;
  rep(i,N) cin >> a[i];

  sort(a,a+N);

  res = a[N-1] -a [0];

  cout << res << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1e9+7, MAX = 1e9, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
long long sum = 0;

typedef pair<int, int> Pa;
typedef long long ll;

int main() {
    cin >> N;
    int a[50];
    rep(i, N){
        cin >> a[i];
    }
    sum = 0;
    rep(i, N){
        for(int j=i+1;j<N;j++){
            sum += a[i]*a[j];
        }
    }
    cout << sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 10000000
using namespace std;
int main()
{
	int n, m;
	cin >> n >> m;
	int A[m + 1];
	for(int i = 0; i < m; i++)
	{
		cin >> A[i];
	}
	cout << n - m - 1 << endl;
	return 0;
}


Measured memory_bytes: 3100
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input().rstrip()))
def inlt():
    return(list(map(int,input().rstrip().split())))
def insr():
    s = input().rstrip()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().rstrip().split()))
################################################################
k = inp()
a,b = invr()

for i in range(a,b + 1):
    if i%k == 0:
        has = True
        break
else:
    has = False
if has:
    print('OK')
else:
    print('NG')
#print('Yes' if '7' in n else 'No')
#print('No')
#print()


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

int main(){
  int h,w,k;
  cin >> h >> w >> k;
  vector<vector<char>> c(h, vector<char>(w));
  rep(i,h){
    rep(j,w){
      cin >> c.at(i).at(j);
    }
  }
  vector<vector<int>> y(10000,vector<int>(10000));
  rep(i,1<<h){
    rep(l,1<<w){
      int t=0;
      rep(j,h){
      // rep(m,w){
          rep(m,w){
            if(i>>j&1 && l>>m&1){
              if(c.at(j).at(m)=='#')++t;
            }
          }
      }
    y.at(i).at(l)=t;
    }
  }
  int z=0;
  rep(i,10000){
    rep(j,10000){
    if(y.at(i).at(j)==k)++z;
    }
  }
  cout << z << endl;
}

Measured memory_bytes: 394172
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
struct edge
{
    ll p,d;
};
bool operator<(const edge &l, const edge &r) {
  if(l.d != r.d) return l.d > r.d;
  return l.p > r.p;
}
const ll MOD = 1000000007;
const ll n_max = 1e5 + 10,INF = 1e16;
vector<edge> G[n_max];
ll d[n_max];
priority_queue<edge> que;
void dijkstra()
{
    for(ll i = 0;i < n_max;i++)
    {
        d[i] = INF;
    }
    d[0] = 0;
    que.push(edge{0,0});
    while(!que.empty())
    {
        edge now = que.top();
        que.pop();
        for(ll i = 0;i < G[now.p].size();i++)
        {
            edge nextp = now;
            nextp.d += G[now.p][i].d;
            nextp.p = G[now.p][i].p;
            if(nextp.d < d[nextp.p])
            {
                d[nextp.p] = nextp.d;
                que.push(nextp);
            }
        }
    }
}

int main()
{
    ll n;
    cin >> n;
    for(ll i = 0;i < n - 1;i++)
    {
        ll u,v,w;
        cin >> u >> v >> w;
        if(w % 2 == 0)
        {
            w = 0;
        }
        else
        {
            w = 1;
        }
        u--;
        v--;
        G[u].push_back(edge{v,w});
        G[v].push_back(edge{u,w});
    }
    dijkstra();
    for(ll i = 0;i < n;i++)
    {
        cout << d[i] % 2 << "\n";
    }

    return 0;
}

Measured memory_bytes: 8704
x=int(input())
a=0
b=0
set5 = set([i**5 for i in range(1000)])
set5 = set5 | set([-i**5 for i in range(1000)])
while True:
    a += 1
    #calc = a**5 - b**5
    #if calc == x:
    #    print(str(a)+" "+str(b))
    #    break
    #else:
    #    if
    temp = (a**5-x)
    if temp in set5:
        if a**5-x < 0:
            b = -int((-temp)**(1/5)+0.01)
        else:
            b = int(temp**(1/5)+0.01)
        print(str(a)+" "+str(b))
        break

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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n, m;
int p[N], SIZE[N];
PII bri[N];
vector<LL> res;

int find(int x)
{
	if (x != p[x]) p[x] = find(p[x]);
	return p[x];
}

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i ++ ) scanf("%d%d", &bri[i].F, &bri[i].S);
	for (int i = 0; i <= n; i ++ ) p[i] = i, SIZE[i] = 1;
	
	LL tot = (LL)n * (n - 1) / 2LL;
	for (int i = m - 1; i >= 0; i -- )
	{
		res.PB(tot);
		int pa = find(bri[i].F), pb = find(bri[i].S);
		
		if (pa != pb)
		{
			tot -= (LL)SIZE[pa] * SIZE[pb];
			SIZE[pb] += SIZE[pa];
			p[pa] = pb;
		}
	}
	
	reverse(res.begin(), res.end());
	for (auto u : res) printf("%lld\n", u);
    return 0;
}

Measured memory_bytes: 6528
"use strict"
const Main = (input) =>{
  	let xs = input.trim().split(" ").map(v=>parseInt(v,10));
    let list1 =[1,3,5,7,8,10,12];
    let list2 =[4,6,9,11];
    let list3 =[2];
    
    if(list1.indexOf(xs[0]) != -1 && list1.indexOf(xs[1]) != -1 || list2.indexOf(xs[0]) != -1 && list2.indexOf(xs[1]) != -1 || list3.indexOf(xs[0]) != -1 && list3.indexOf(xs[1]) != -1){
      console.log('Yes');
      }else{
      console.log('No');
      }
    }
Main(require("fs").readFileSync("/dev/stdin","utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int i, n;
  cin>>n;
  int h[n];
  for(i=0;i<n;i++)
    cin>>h[i];
  int cost[n];
  cost[0] = 0;
  cost[1] = fabs(h[1] - h[0]);
  for(i=2;i<n;i++)
  {
    cost[i] = min((cost[i-1] + fabs(h[i]-h[i-1])), (cost[i-2] + fabs(h[i]-h[i-2])));
  }
  cout<<cost[n-1]<<"\n";
}

Measured memory_bytes: 1024
// https://atcoder.jp/contests/abc145/tasks/abc145_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

const int MOD = 1e9 + 7;
const int SZ = 1e6;

template <int N, int M> struct Fact {
    int mod[N + 1];
    int inv_mod[N + 1];
    constexpr Fact() : mod(), inv_mod() {
        mod[0] = 1;
        for (int i = 0; i < N; ++i) {
            mod[i + 1] = (mod[i] * (i + 1)) % M;
        }
        inv_mod[N] = power(mod[N], M - 2);
        for (int i = N - 1; i >= 0; --i) {
            inv_mod[i] = (inv_mod[i + 1] * (i + 1)) % M;
        }
    }

    // aのb乗
    constexpr int power(int a, int b) {
        int r = 1;
        while (b > 0) {
            if ((b & 1) != 0)
                r = (r * a) % M;
            a = (a * a) % M;
            b >>= 1;
        }
        return r;
    }

    // 組み合わせ n C r
    constexpr int comb(int n, int r) {
        return (((mod[n] * inv_mod[r]) % M) * inv_mod[n - r]) % M;
    }

    // 重複組み合わせ n H r
    constexpr int homo(int n, int r) { return comb(n + r - 1, n - 1); }
};
Fact<SZ, MOD> facmod;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X, Y;
    cin >> X >> Y;
    int x = X, y = Y;
    if ((x + y) % 3 != 0) {
        cout << "0\n";
        return 0;
    }
    int n = (x + y) / 3;
    x -= n;
    y -= n;
    if (x < 0 || y < 0) {
        cout << "0\n";
        return 0;
    }
    cout << facmod.comb(n, x) << endl;
    return 0;
}


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

#define MOD 1000000007

typedef unsigned long long ull;

int min(int val_t,int val_a);

int main(void){
	int n,i,*list_t,*list_a,*flg;
	int wrong=0;
	ull pat=1;
	
	
	scanf("%d",&n);
	list_t=(int *)calloc(n,sizeof(int));
	list_a=(int *)calloc(n,sizeof(int));
	flg=(int *)calloc(n,sizeof(int));
	
	for(i=0;i<n;i++) scanf("%d",&list_t[i]);
	for(i=0;i<n;i++) scanf("%d",&list_a[i]);
	
	for(i=0;i<n;i++){
		if(i==0 || (i>0 && list_t[i]-list_t[i-1]>0)){
			if(i<n-1){
				if(list_a[i]-list_a[i+1]>0){
					if(list_t[i]==list_a[i]){
						flg[i]=1;
					}else{
						/*
						puts("WrongIdea!!");
						printf("Mt.%d, T_ReloadFlg:%d, T:%d, A:%d\n",i,flg[i],list_t[i],list_a[i]);
						//*/
						wrong=1;
						break;
					}
				}else{
					if(list_t[i]<=list_a[i]){
						flg[i]=1;
					}else{
						/*
						puts("WrongIdea!!");
						printf("Mt.%d, T_ReloadFlg:%d, T:%d, A:%d\n",i,flg[i],list_t[i],list_a[i]);
						//*/
						wrong=1;
						break;
					}
				}
			}else{
				if(list_t[i]==list_a[i]){
					flg[i]=1;
				}else{
					/*
					puts("WrongIdea!!");
					printf("Mt.%d, T_ReloadFlg:%d, T:%d, A:%d\n",i,flg[i],list_t[i],list_a[i]);
					//*/
					wrong=1;
					break;
				}
			}
		}
	}
	/*
	putchar('\n');
	for(i=0;i<n;i++){
		printf("%d%c",flg[i],(i==n-1)?'\n':' ');
	}//*/
	
	for(i=n-1;i>=0;i--){
		if(i==n-1 || (i<n-1 && list_a[i]-list_a[i+1]>0)){
			if(i>0){
				if(flg[i]){
					if(list_a[i]!=list_t[i]){
						/*
						puts("WrongIdea!!");
						printf("Mt.%d, T_ReloadFlg:%d, T:%d, A:%d\n",i,flg[i],list_t[i],list_a[i]);
						//*/
						wrong=1;
						break;
					}
				}else{
					if(list_a[i]<=list_t[i]){
						flg[i]=1;
					}else{
						/*
						puts("WrongIdea!!");
						printf("Mt.%d, T_ReloadFlg:%d, T:%d, A:%d\n",i,flg[i],list_t[i],list_a[i]);
						//*/
						wrong=1;
						break;
					}
				}
			}else{
				if(list_a[i]!=list_t[i]){
					/*
					puts("WrongIdea!!");
					printf("Mt.%d, A_ReloadFlg:%d, T:%d, A:%d\n",i,flg[i],list_t[i],list_a[i]);
					//*/
					wrong=1;
					break;
				}
			}
		}
	}
	/*
	putchar('\n');
	for(i=0;i<n;i++){
		printf("%d%c",flg[i],(i==n-1)?'\n':' ');
	}
	putchar('\n');
	//*/
	if(!wrong){
		for(i=0;i<n;i++){
			pat*=(flg[i])?1:min(list_t[i],list_a[i]);
			//printf("%llu\n",pat);
			pat%=MOD;
		}
		printf("%llu\n",pat);
	}else{
		printf("%d\n",0);
	}
	
	free(list_t);
	free(list_a);
	free(flg);
	return 0;
}

int min(int val_t,int val_a){
	return (val_t<val_a)?val_t:val_a;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
    int n, k, q;
    cin >> n >> k >> q;

    int a[100000];

    for (int i = 0; i < q; ++i) cin >> a[i];

    int win[100000] = {0};

    for (int i = 0; i < q; ++i) {
        win[a[i] - 1] += 1;
    }
    
    for (int j = 0; j < n; ++j) {
        if (win[j] > q - k) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll aa , bb;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->aa - ((fr*)q)->aa;}

int main(void){
    char s[200005];  
    ll n,ans=0;
    scanf("%lld%s",&n,s);
    ll bw[n],black;
    bw[n-1]=0;
    rrep(i,n-2,0){
        bw[i]=bw[i+1];
        if(s[i+1]=='#') bw[i]++;
    }
    // rep(i,0,n) printf("%lld ",bw[i]);
    black=bw[0];
    if(s[0]=='#') black++;

    // if(s[0]=='#'){
        ans=(n-1)-bw[0];
    // }else{
        // ans=(n-1)-(bw[0]+1);
    // }
    rep(i,1,n){
        // ans=min2(ans, (black-b[]) )
        if(s[i]=='.'){
            ans=min2(ans, (black-bw[i])+(n-1-i)-bw[i] );
        }else{
            ans=min2(ans, (black-bw[i]-1)+(n-1-i)-bw[i] );
        }
    }
    ans=min2(ans,black);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main() {
    ll N; cin >> N;
    ll ans = 1;
    for (int i = 1; i <= N; i++) {
        ans *= i;
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3572
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
matrix = []
for i in range(M):
    matrix.append(list(map(int, input().split())))

ans = min(a) + min(b)
for i in range(M):
    if a[matrix[i][0]-1] + b[matrix[i][1]-1] - matrix[i][2] < ans:
        ans = a[matrix[i][0]-1] + b[matrix[i][1]-1] - matrix[i][2]
print(ans)

Measured memory_bytes: 82028
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  int q; cin >> q;
  deque<char> que;
  for(char c: s) que.push_back(c);
  int flag = 0;
  while(q--) {
    int t; cin >> t;
    if(t == 1) {
      flag ^= 1;
    } else {
      int f; cin >> f;
      char c; cin >> c;
      if((f-1)^flag) {
        que.push_back(c);
      } else {
        que.push_front(c);
      }
    }
  }
  if(flag) {
    while(!que.empty()) {
      cout << que.back();
      que.pop_back();
    }
  } else {
    while(!que.empty()) {
      cout << que.front();
      que.pop_front();
    }
  }
  cout << endk;
  return 0;
}


Measured memory_bytes: 4072
while True:
    n,x=map(int,input().split())
    if n+x==0:
        break
    counts=0
    for a in range(1,n+1):
        for b in range(a+1,n+1):
            for c in range(b+1,n+1):
                if a+b+c==x:
                    counts+=1
    print(counts)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin>>s;
  int w=0,l=0;
  for(int i=0;i<s.length();++i) {
    if(s[i]=='o')
      w++;
    else l++;
  }
  if(w+15-s.length()>=8)
    cout<<"YES";
    else cout<<"NO";
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
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; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int N, D[13];

int main() {
  N = in();
  for (int i = 0; i < N; ++i) {
    ++D[in()];
  }
  ++N;
  ++D[0];

  if (N >= 25) {
    puts("0");
    return 0;
  }
  if (*max_element(D, D + 13) >= 3 || D[0] >= 2) {
    puts("0");
    return 0;
  }

  int res = 0;
  for (int u = 0; u < (1<<13); ++u) {
    int b = 0;
    for (int d = 0; d <= 12; ++d) {
      if (D[d] == 2) {
        b |= 1<<d;
        b |= 1<<((24-d)%24);
      } else if (D[d] == 1) {
        if (u & (1 << d)) {
          b |= 1<<d;
        } else {
          b |= 1<<((24-d)%24);
        }
      }
    }
    int pre = 0, mindif = 30;
    for (int t = 1; t < 24; ++t) {
      if (b & (1 << t)) {
        chmin(mindif, t - pre);
        pre = t;
      }
    }
    chmin(mindif, 24 - pre);
    chmax(res, mindif);
  }

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

  return 0;
}


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


long long N,M,X;
long long ans = 9999999999;
bool cant=true;
vector<vector<long long>> dataa(12, vector<long long>(12+1));
int rec(long long i, vector<long long> wa, long long nedan) {
    if (i==N) {
        bool isOK=true;
        for (int i=0; i<M; i++) {
            if (wa.at(i)<X) isOK=false;
        }

        if (isOK) {
            cant = false;
            ans = min(ans,nedan);
        }
        return 0;
    }
    rec(i+1, wa, nedan);
    for (int j=0; j<M; j++) wa.at(j)+=dataa.at(i).at(j+1);
    nedan+=dataa.at(i).at(0);
    rec(i+1, wa, nedan);
    return 0;
}

int main() {
    cin >> N >> M >> X;
    //long long wa[M];
    vector <long long> wa(M);
    for (int i=0; i<M; i++) wa[i]=0;
    for (int i=0; i<N; i++) {
        for (int j=0; j<M+1; j++) {
            cin >> dataa.at(i).at(j);
        }
    }
    long long nedan=0;
    rec(0, wa, nedan);
    if (cant) cout << "-1";
    else cout << ans;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

int ans = 0, N, M, Q;
vi A, B, C, D, num;

int checkReq(vi tmp){
    int res = 0;

    rep(i, Q){
        if(tmp[B[i]] - tmp[A[i]] == C[i]) res += D[i];
    }

    return res;
}


void dfs(vi tmp){
    int n = tmp.size();

    if(n==N+1){
        // rep(i, N)
        //     cout << tmp[i+1] << " ";
        // cout << endl;
        ans = max(ans, checkReq(tmp));
    } else {
        tmp.push_back(tmp[n-1]);
        while(tmp[n] <= M){
            dfs(tmp);
            tmp[n]++;
        }
    }
}

void solve(){
    num.push_back(1);

    dfs(num);

    cout << ans << endl;
}

int main(){
    cin >> N >> M >> Q;
    A.resize(Q);
    B.resize(Q);
    C.resize(Q);
    D.resize(Q);

    rep(i, Q) cin >> A[i] >> B[i] >> C[i] >> D[i];
    
    solve();
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
 
#define deb(x) {x}
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------

int n,arr[500005];

map<string,int> M;

void solve()
{
	string a;
	cin>>n;
	rep(i,0,n)cin>>a,sort(all(a)),M[a]++;
	
	int ans=0;
	for (auto x:M)
	{
		if (x.ss<2)continue;
		ans+=x.ss*(x.ss-1)/2;
	}
	cout<<ans<<"\n";
	
	
}
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
 	
 	#ifdef local
    //freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    clock_t qwertyuiop = clock();
    #endif
 
 	int t=1;
    ///cin>>t;
    
    
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
	}
	
    #ifdef local
    {qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}



Measured memory_bytes: 11264
#include<iostream>

using namespace std;

int main()
{
    char letter;

    cin >> letter;

    if(letter == 'a' || letter == 'e' || letter == 'i' || letter == 'o' || letter == 'u')
    {
        cout << "vowel" << endl;
    }
    else {
       cout << "consonant" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int H, W;
  int i, j;
  while (1) {
    scanf("%d %d", &H, &W);
    if (H == 0 && W == 0) break;
    for (i = 0; i < H; i++) {
      for (j = 0; j < W; j++) {
        if (i >= 1 && i <= H-2 && j >= 1 && j <= W-2) {
          putchar('.');
        } else {
          putchar('#');
        }
      }
      putchar('\n');
    }
    putchar('\n');
  }

  return 0;
}



Measured memory_bytes: 2040
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#define rep(i,j,n) for(i=j;i<(n);i++)

using namespace std;

int main(){
    int n,a,sum=0,cost=0;
    int i;
    vector<int> pos;
    double ave;
    cin>>n;
    rep(i,0,n){
        cin>>a;
        pos.push_back(a);
        sum+=a;
    }
    ave=(double)sum/(double)n;
    if(ave-floor(ave)<0.5){
        ave=floor(ave);
    }
    else{
        ave=floor(ave)+1;
    }
    rep(i,0,n){
        cost+=pow((pos[i]-ave),2);
    }
    cout<<cost<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0L;i--)
#define prep(i,n) for(int64_t i=1;i <= (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  fspcnt = 0;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int a,b;
  cin >> a >> b;
  if(a>b){
    cout << a+a-1;
  }else if(a<b){
    cout << b+b-1;
  }else{
    cout << a+b;
  }
    
    
}

Measured memory_bytes: 256
module Main where

import           Data.Char (isLower)
import Text.ParserCombinators.ReadP (ReadP, char, satisfy, many, eof, readP_to_S, many1)

parser :: ReadP ()
-- parser = char 'A' *> lowerChar *> many lowerChar *> char 'C' *> many lowerChar *> lowerChar *> eof
parser = char 'A' *> many1 lowerChar *> char 'C' *> many1 lowerChar *> eof

lowerChar :: ReadP Char
lowerChar = satisfy isLower

f :: String -> Result
f s = if not . null . readP_to_S parser $ s then AC else WA

main :: IO ()
-- main = interact $ show . f
main = print . f =<< getLine

data Result
  = AC
  | WA
  deriving (Show, Eq)

tests :: [Bool]
tests =
  [ test1
  , test2
  , test3
  , test4
  , test5
  ]

test1, test2, test3, test4, test5 :: Bool
test1 = f "AtCoder" == AC
test2 = f "ACoder" == WA
test3 = f "AcycliC" == WA
test4 = f "AtCoCo" == WA
test5 = f "Atcoder" == WA


Measured memory_bytes: 380
#include<cstdio>
#include<vector>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e6+6;
const int MOD=998244353;
const double EPS=1e-12;
template <class T>
bool sf(T &ret){ //Faster Input
    char c; int sgn; T bit=0.1;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&c!='.'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    if(c==' '||c=='\n'){ ret*=sgn; return 1; }
    while(c=getchar(),c>='0'&&c<='9') ret+=(c-'0')*bit,bit/=10;
    ret*=sgn;
    return 1;
}

int main(void){
    ll a,b;
    cin >>a>>b;
    ll ans=a*b-(a+b-1);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    cin>>str;
    if((str[0]==str[1]&&str[1]==str[2]&&str[0]==str[2])||(str[1]==str[2]&&str[2]==str[3]&&str[1]==str[3])) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <climits>
using namespace std;
 
typedef long long ll;

#define MAX_V 1000

ll cap[MAX_V][MAX_V];
bool used[MAX_V];
ll n;

ll dfs(ll v, ll t, ll f){
  if(v==t) return f;
  used[v] = true;

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

    ll c = cap[v][i];
    if(!used[i] && c > 0){
      ll d = dfs(i , t , min(f, c));
      if(d > 0){
        cap[v][i] -= d;
        cap[i][v] += d;
        return d;
      }
    }
  }
  return 0;
}

ll mf(ll s, ll t){
  ll flow = 0;
  for(;;){
    memset(used , 0 , sizeof(used));
    ll f = dfs(s,t,100000000000LL);
    if(f == 0) return flow;
    flow += f;
  }
}

void add_edge(ll from, ll to, ll c){
  cap[from][to] = c;
  cap[to][from] = 0;
}

int main(){
  ll w;
  map<string,int> week;
 
  week["Sunday"] = 0;
  week["Monday"] = 1;
  week["Tuesday"] = 2;
  week["Wednesday"] = 3;
  week["Thursday"] = 4;
  week["Friday"] = 5;
  week["Saturday"] = 6;
 
  while(cin >> n >> w, n || w){
    memset(cap, -1, sizeof(cap));

    for(ll i = 0; i < 7; i++){
      add_edge(0, i + 1, w);
    }
 
    ll sum = 0;
 
    for(ll i = 0; i < n; i++){
      ll tn, cn;
      cin >> tn >> cn;
      add_edge(i + 8, n + 8, tn);
      sum += tn;
 
      for(ll j = 0; j < cn; j++){
        string s;
        cin >> s;
        ll from = week[s] + 1;
        add_edge(from, i + 8, w);
      }
    }

    n = n + 9;

    ll flow = mf(0, n - 1);

    if(flow == sum){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 9036
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <math.h>
#include <limits>
#include <stdio.h>

template <typename T>
void vc(T t) {
    std::cout << t << " ";
}

template<typename T, typename... Args>
void vc(T t, Args... args) {
// recursive variadic function
    std::cout << t << " ";
    vc(args...) ;
}

long long dp[102][100008];
void once() {
  int n, k;
  std::cin >> n >> k;
  std::vector<int> vi(n + 1);
  std::vector<int> si(n + 1, 0);
  for (int i = 1; i <= n; ++i) {
    std::cin >> vi[i];
    si[i] += vi[i] + si[i - 1];
  }

  dp[0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= k; ++j) {
      dp[i - 1][j] += dp[i - 1][j - 1];
      dp[i - 1][j] %= 1000000007LL;
    }
    dp[i][0] = 1;
    for (int j = 1; j <= k; ++j) {
      auto x = std::min(j, vi[i]);
      // vc("x", i, j, x, "\n");
      if (j - x != 0) {
        dp[i][j] += dp[i - 1][j] + 1000000007LL - dp[i - 1][j - x - 1];
      } else {
        dp[i][j] += dp[i - 1][j];
      }
      dp[i][j] %= 1000000007LL;
    }
  }
  std::cout << dp[n][k] << std::endl;
}

int
main() {
  int n = 1;
  std::ios::sync_with_stdio(false);
  // std::cin >> n;
  while (n--) {
    once();
  }
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <string.h>

using namespace std;

typedef long long int lli;

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;}

#ifdef LOCAL
	#define eprintf(...) printf(__VA_ARGS__)
#else 
	#define eprintf(...) 1
#endif

#define ROUNDUP(a, b) 		( ((a) + ((b) - 1) ) / b)
#define SET_ZERO(a)	 		( memset((a), 0, sizeof(a)))
#define SET_NUM_ARRAY(a,b)	( memset((a), b, sizeof(a)))

int main() {
	lli X, Y;
	scanf("%lld %lld", &X, &Y);

	lli ans = 0L;
	for (; X <= Y ; X *=2) {
		ans++;
	}
	printf("%lld\n", ans);
}


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

using namespace std;

int n;
const int size=3010;
double coins[size];
double prob[size][size];
bool vis[size][size];

int main(){

  scanf("%d",&n);
  for(int i=0;i<n;i++)
    scanf("%lf",coins+i);

  double ans=0;

  prob[0][0]=1;
  for(int i=1;i<=n;i++){
    prob[i][0]=prob[i-1][0]*(1-coins[i-1]);
    for(int j=1;j<=i;j++){
      prob[i][j]=coins[i-1]*prob[i-1][j-1]+(1.0-coins[i-1])*prob[i-1][j];
    }
  }
  for(int i=n/2+1;i<=n;i++){
    ans+=prob[n][i];
  }
  printf("%.10lf\n",ans);


  return 0;
}


Measured memory_bytes: 71424
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b; cin >> a >> b;
  for(float i = 1; i <= 200000; i++){
   // cout << floor(i * 0.08) << " " << floor(i * 0.1) << endl; 
    if(floor(i * 0.08) == a and floor(i * 0.1) == b){
      cout << i;
      return 0;
    }
  }
  cout <<  -1;
}

Measured memory_bytes: 3764
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    int n, kk; cin >> n >> kk;
    vector<int> xx, yy;
    vector<pii> v; rep(i, n) {int x, y; cin >> x >> y; v.push_back({x, y}); xx.push_back(x); yy.push_back(y);}
    //sort(v.begin(), v.end());
    sort(xx.begin(), xx.end()); sort(yy.begin(), yy.end());
    ll ans = 4 * 1e18;
    rep(i, n) { //x left
        rrep(j, i + 1, n) { //x right
            rep(k, n) { //y left
                rrep(l, k + 1, n) { //y right
                    int c = 0;
                    rep(m, n) { //how many spots
                        if (xx[i] <= v[m].first && v[m].first <= xx[j]
                            && yy[k] <= v[m].second && v[m].second <= yy[l]) {
                            c++;
                        }
                    }
                    //cout << c << endl;
                    if (c >= kk) {
                        ans = min(ans, (ll)(xx[j] - xx[i]) * (yy[l] - yy[k]));
                    }
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
# abc 158
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

S = readline().strip().decode('utf-8')

if len(set(list(S))) == 1:
    print('No')
else:
    print('Yes')



Measured memory_bytes: 2940
/* ex3_3
   tamayama */

#include<stdio.h>
 int main (void){
 
    int N,K;
    int input_K;
    int digit=1;
    scanf("%d %d",&N,&K);
    input_K = K;

    while(K <= N){  /*Nを超えないように何回KをK倍したかを求める*/
    K = input_K*K;  /*もとのKの値をInput_KとおいてKと区別*/
    digit++;
    }
    printf("%d\n",digit);

   return 0;
}


Measured memory_bytes: 128
a,b=map(int, input().split(" "))
wh="."
bl="#"
print(100,100)
for i in range(100):
    out=""
    if i%2==0:
        for k in range(50):
            out+=bl
        for k in range(50):
            out+=wh
    else:
        for i in range(25):
            if a > 1:
                out+=wh
                a-=1
            else:
                out+=bl
            out+=bl

        for i in range (25):
            out+=wh
            if b > 1:
                out+=bl
                b-=1
            else:
                out+=wh

    print(out)


Measured memory_bytes: 3188
#include <iostream>
#include <cmath>

using namespace std;

int main() {

   double a{}, b{}, c{}, q{};

   cin >> a >> b >> q;
   q *= M_PI / 180;
   c = sqrt(a * a + b * b - 2 * a * b * cos(q));

   double S{}, L{}, h{};

   h = b * sin(q);
   S = a * h / 2;
   L = a + b + c;

   cout << fixed << S << endl;
   cout << fixed << L << endl;
   cout << fixed << h << endl;

   return 0;

}

Measured memory_bytes: 3508
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B; cin >> A >> B;

    int ans = A + B;
    if(ans < A - B){
        ans = A - B;
    }
    if(ans < A * B){
        ans = A * B;
    }

    cout << ans << endl;
    return 0;
}

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

int main(){
	int A1, A2, A3;
	cin >> A1 >> A2 >> A3;
	int answer = A1 + A2 + A3;
	if(answer >= 22) cout << "bust" << endl;
	else	cout << "win" << endl;
	return 0;
}

Measured memory_bytes: 256
def main() :
    lst = input().split()
    stack = []
    for i in lst :
        if i == '+' :
            x = stack.pop()
            y = stack.pop()
            stack.append(x + y)

        elif i == '-':
            x = stack.pop()
            y = stack.pop()
            stack.append(y - x)

        elif i == '*' :
            x = stack.pop()
            y = stack.pop()
            stack.append(x * y)

        else :
            stack.append(int(i))

    print(stack.pop())

if __name__ == '__main__' :
    main()

Measured memory_bytes: 5596
H, W = map(int,input().split())
ans = float('inf')
for i in range(1, H):
    a = i*W
    if H-i == 1:
        d = 1*(W//2)
        e = H*W-a-d
        small = min(a,d,e)
        large = max(a,d,e)
        ans = min(ans, large-small)
    else:
        b = ((H-i)//2) * W
        c = H*W-a-b
        d = (H-i) * (W//2)
        e = H*W-a-d
        small1 = min(a,b,c)
        large1 = max(a,b,c)
        small2 = min(a,d,e)
        large2 = max(a,d,e)
        ans = min(ans, large1-small1, large2-small2)
for j in range(1, W):
    a = j*H
    if W-j == 1:
        d = 1*(H//2)
        e = H*W-a-d
        small = min(a,d,e)
        large = max(a,d,e)
        ans = min(ans, large-small)
    else:
        b = ((W-j)//2) * H
        c = H*W-a-b
        d = (W-j) * (H//2)
        e = H*W-a-d
        small1 = min(a,b,c)
        large1 = max(a,b,c)
        small2 = min(a,d,e)
        large2 = max(a,d,e)
        ans = min(ans, large1-small2, large2-small2)
print(ans)


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	int n,a; scanf("%d%d",&n,&a);
	int x[50];
	rep(i,n) scanf("%d",&x[i]);

	lint dp[51][2501]={};
	dp[0][0]=1;
	rep(k,n){
		for(int i=n;i>0;i--) for(int w=2500;w>=x[k];w--) dp[i][w]+=dp[i-1][w-x[k]];
	}

	lint ans=0;
	rep(i,n) ans+=dp[i+1][(i+1)*a];
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 1280
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>
#define long long

using namespace std;

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	cout<<(a+b)*c/2;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{
  string s;
  cin>>s;
  ll sum=700;
  rep(i,3){
    if(s[i]=='o')sum+=100;
  }

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


Measured memory_bytes: 3528
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int h=0, w=0;
    cin >> h >> w;
    vector<string> in(h);
    for (int i=0; i<h; i++) {
        cin >> in.at(i);
    }
    int check1[] = {-1, 0, 0, 1};
    int check2[] = {0, 1, -1, 0};
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (in.at(i).at(j) == '.') continue;
            bool flag = false;
            for (int k=0; k<4; k++) {
                int bufx = j+check1[k];
                int bufy = i+check2[k];
                if (bufx < 0 || bufx >= w) continue;
                if (bufy < 0 || bufy >= h) continue;
                if (in.at(bufy).at(bufx) == '#') {
                    flag = true;
                    break;
                }
            }
            if (!flag) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>

int main()
{
    int a, b, j, k, l, m, cnt = 0;;
    std::cin >> a >> b;

    for(int i = a;i <= b;i++){
        j = i / 10000; k = i % 10;
        l = i / 1000 - j * 10; m = (i % 100 - k) / 10;
        if(j == k && l == m){
            cnt++;
        } 
    }
    std::cout << cnt;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define all(x) (x).begin(), (x).end()
#define pb push_back

typedef pair<int, int>    PII;
typedef vector<int>       VI;
typedef vector<VI>        VII;
typedef vector<long long> VL;
typedef long long         ll;
typedef long long         integer;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    char b;
    cin >> b;

    // 処理
	if (b=='A'){cout << "T" << endl;	}
	if (b=='C'){cout << "G" << endl;	}
	if (b=='G'){cout << "C" << endl;	}
	if (b=='T'){cout << "A" << endl;	}


    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 5)

color = []
graph = []

def dfs(v, p, c):
    color[v] = c
    for e in graph[v]:
        if e[0] == p: continue
        if e[1] % 2: dfs(e[0], v, 1-c)
        else: dfs(e[0], v, c)


def main():
    n = int(input())
    color.extend(-1 for _ in range(n))
    graph.extend([] for _ in range(n))
    for i in range(n-1):
        u, v, w = [int(x) for x in input().split()]
        u, v = u - 1, v - 1
        graph[u].append((v, w))
        graph[v].append((u, w))

    dfs(0, -1, 1)
    for i in range(n):
        print(color[i])

if __name__ == '__main__':
    main()

Measured memory_bytes: 79328
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, k;
	cin>>n>>k;
	vector<int> vec(n, 0);
	int res = 0;
	for(int i = 0; i < n; ++i)cin>>vec[i];
	for(int i = 0; i < n; ++i)if(vec[i] >= k)res++;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main(void){
	int a,b,c,d,e,f;
	double x,y;
	
	while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)!=EOF){
		y=(double)(d*c-a*f)/(d*b-a*e);
		x=(c-b*y)/a;
		printf("%.3lf %.3lf\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 636
package main


import (
	"fmt"
)

func main() {
	var a int
	var c float64
	var b []float64
	fmt.Scan(&a)
	for i := 0; i < a ; i++ {
		fmt.Scan(&c)
		b = append(b, 1/c)
	}

	var d float64
	for _,v := range b {
		d += v
	}
	fmt.Println(1/d)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int D;
  cin>>D;
  vector<int> c(26);
  for(int &i:c)
    cin>>i;
  vector<vector<int>> s(D,vector<int>(26));
  for(vector<int> &v:s)
    for(int &i:v)
      cin>>i;
  vector<int> A(26,0);
  int mzint=0;
  for(int i=0;i<D;i++){
    int mzi=mzint,mzin=0,k;
    for(int j=0;j<26;j++)
      mzi-=(i+1-A[j])*c[j];
    for(int j=0;j<26;j++){
      int l=mzi+s[i][j]-(i+1-A[j])*c[j];
      if(l>mzin){
        k=j;
        mzin=l;
      }
    }
    A[k]=i+1;
    mzint=mzin;
    cout<<k+1<<endl;
  }
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define FINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N,K;
pii p[100010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> N >> K;
  REP(i,N) cin >> p[i].first >> p[i].second;
  sort(p,p+N);
  REP(i,N) {
    K -= p[i].second;
    if (K <= 0) {
      cout << p[i].first << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
a.sort()
c = [0] * 9
for i in range(N):
  if a[i] // 400 > 8:
    c[8] += 1
  else:
    c[a[i] // 400] += 1
res = 0
for i in range(8):
  res += c[i] > 0
print(max(res, 1), res + c[8])

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

typedef long long ll;
int mod = 1e9 + 7;

int main() {
	string s1, s2;
	cin >> s1 >> s2;
	int n = (int)s1.size();
	int m = (int)s2.size();
	int i = 0; 
	int j = 0;
	string ans = "";
	while (i < n || j < m) {
		if (i == n) {
			for (int k = j; k < m; ++k) {
				ans += s2[k];
			}
			break;
		}
		if (j == m) {
			for (int k = i; k < n; ++k) {
				ans += s1[k];
			}
			break;
		}
		ans += s1[i];
		ans += s2[j];
		++i;
		++j;
	}
	cout << ans;
}



















Measured memory_bytes: 256
#include <iostream>
#define llint long long

using namespace std;

llint n;
llint a[200005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	llint mn = n+1, ans = 0;
	for(int i = 1; i <= n; i++){
		if(mn > a[i]) ans++, mn = a[i];
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1792