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

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

int main(){
	int a, b, c;

	cin >> a >> b >> c;

	if(a + b + c >= 22){
		cout << "bust" << endl;
	}else{
		cout << "win" << endl;
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#include<string>
#include<iostream>

#define maxn 200005
#define INF 0x3f3f3f3f

using namespace std;

inline long long getint()
{
    long long num=0,flag=1;char c;
    while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;
    while(c>='0'&&c<='9')num=num*10+c-48,c=getchar();
    return num*flag;
}

long long A,B,K;

int main()
{
	A=getint(),B=getint(),K=getint();
	if(K<A)A-=K,K=0;
	else K-=A,A=0;
	B-=min(B,K);
	printf("%lld %lld\n",A,B);
}

Measured memory_bytes: 256
import sys
n=int(input())
a=list(map(int,input().split()))

a_set=list(set(a))
a_set.sort()


#コーナーケース　aが全部0なら必ずyes
if len(a_set)==1 and a_set[0]==0:
    print("Yes")
    sys.exit(0)

#上記の場合を除き、nが３の倍数でないと成立しない
if n%3!=0:
    print("No")
    sys.exit(0)


if len(a_set)==2 and a_set[0]==0:
    if a.count(0)==int(n/3) and a.count(a_set[1])==int(n/3)*2:
        print("Yes")
    else:
        print("No")
elif len(a_set)==3:
    if a_set[0]^a_set[1]==a_set[2] and a.count(a_set[0])==a.count(a_set[1])==a.count(a_set[2]):
        
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 14116
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;//998244353
int add(int a, int b){ a+=b;return a>=mod?a-mod:a;}
void ckadd(int &a, int b){ a=add(a,b);}
int sub(int a, int b){ a-=b;return a<0?a+mod:a;}
void cksub(int &a, int b){ a=sub(a,b);}
int mul(int a, int b){ return (ll)a*b%mod;}
void ckmul(int &a, int b){ a=mul(a,b);}
int powmod(int x, int k){ int ans=1;for(;k;k>>=1,ckmul(x,x)) if(k&1) ckmul(ans,x);return ans;}
int inv(int x){ return powmod(x,mod-2);}

const int N=1000050;
int F[N],I[N];
int binom(int n, int k){ return mul(F[n],mul(I[k],I[n-k]));}
void calc()
{
	F[0]=1;
	for(int i=1;i<N;i++) F[i]=mul(F[i-1],i);
	I[N-1]=inv(F[N-1]);
	for(int i=N-2;~i;i--) I[i]=mul(I[i+1],i+1);
}

int sum[N];
int main()
{
	int n;
	scanf("%i",&n);
	vector<int> x(n);
	calc();
	for(int i=0;i<n;i++) scanf("%i",&x[i]);
	int ans=0;
	for(int i=0;i<n-1;i++)
	{
		cksub(ans,mul(x[i],F[n-1]));
	}
	for(int i=0;i<=n-2;i++) sum[i]=mul(inv(i+1),inv(i+2));
	for(int i=1;i<=n-2;i++) ckadd(sum[i],sum[i-1]);
	for(int i=1;i<n-1;i++)
	{
		ckadd(ans,mul(mul(x[i],F[n-1]),sum[i-1]));
	}
	for(int i=0;i<n-1;i++)
	{
		for(int j=n-1;j<n;j++)
		{
			int k=j-i-1;
			//if(j!=n-1) ckadd(ans,mul(x[j],mul(mul(F[k],F[n-k-3]),binom(n-1,k+2))));
			//else
			ckadd(ans,mul(x[j],mul(mul(F[k],F[n-k-2]),binom(n-1,k+1))));
			//if(j!=n-1) printf("%i %i %i\n",i,j,mul(mul(F[k],F[n-k-3]),binom(n-1,k+2)));
			//else printf("%i %i %i\n",i,j,mul(mul(F[k],F[n-k-2]),binom(n-1,k+1)));
		}
	}
	printf("%i\n",ans);
	return 0;
}

Measured memory_bytes: 10752
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
const ll MOD=100000007;
#define rep(i,a,b) for(ll i=a;i<b;i++)
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
inline constexpr int modf(ll n){
    ll ans=1;
    rep(i,0,n) {ans=ans*(n-i)%MOD;}
    return ans;
}
int main(){
    ll a,b;
    cin>>a>>b;
    ll ans=0;
    rep(i,0,2){if(a>b){
        ans+=a;
        a-=1;
    }
    else {
        ans+=b;
        b-=1;
    }}
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iterator>
#include <vector>
#include <string>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  copy_n(istream_iterator<string>(cin), N, S.begin());
  int64_t m[256] = {0};
  for (auto& item : S) {
    ++(m[static_cast<string::size_type>(item[0])]);
  }

  int64_t result = 0;
  result += (m['M'] * m['A'] * m['R']                  );
  result += (m['M'] * m['A']          * m['C']         );
  result += (m['M'] * m['A']                   * m['H']);
  result += (m['M']          * m['R'] * m['C']         );
  result += (m['M']          * m['R']          * m['H']);
  result += (m['M']                   * m['C'] * m['H']);
  result += (         m['A'] * m['R'] * m['C']         );
  result += (         m['A'] * m['R']          * m['H']);
  result += (         m['A']          * m['C'] * m['H']);
  result += (                  m['R'] * m['C'] * m['H']);
  cout << result << endl;
  return 0;
}


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

const long long INFF = 1e18;

const int MAX_N = 11000;
using TYPE = long long; // ?????¢???????????\??????
vector<pair<int, TYPE> > G[MAX_N];

vector<TYPE> A_star(int start){
	vector<TYPE> dist(MAX_N, INFF);
	dist[start] = 0;//dist[i] :=???start->i?????§??????????????¢
	priority_queue<pair<TYPE, int>, vector<pair<TYPE, int> >, greater<pair<TYPE, int> > >  que;
	que.push(make_pair(1, start));
	while(!que.empty()){
		TYPE cost; int u;//????????§???????????£????????? ?????¨?????????
		cost = que.top().first, u = que.top().second;
		que.pop();
		// if(dist[u] < cost) continue;
		for (auto tmp : G[u]){
			int v = tmp.first; TYPE time = tmp.second;//??£??\???????????? ?????????????????§????????????
			if(dist[v] > dist[u] + time){//u->v
				dist[v] = dist[u] + time;
				TYPE h = 1; // ??´???????????§?????¨??????
				// printf("%f\n", h);
				que.push(make_pair(dist[v] + 1e9, v));
			}
		}
	}
	return dist;
}

int main(void) {
	int n; cin >> n;
	rep(q, n) {
		int u, k; cin >> u >> k;
		vector<int> v(k); vector<long long> c(k);
		rep(i, k) cin >> v[i] >> c[i];
		rep(i, k) G[u].push_back(make_pair(v[i], c[i]));
	}
	auto dist = A_star(0);
	rep(i, n) printf("%d %d\n", i, dist[i]);
	return 0;
}

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

signed main(){
  
  int N, K;
  cin>>N>>K;
  
  vector<int> V(N);
  
  for(int i=0;i<N;i++) cin>>V[i];
  
  int ans = 0;
  
  for(int L=0;L<=N;L++){
    
    for(int R=0;R<=N;R++){
      
      if( L + R > N || L + R > K ) continue;
      
      vector<int> S;
            
      for(int i=0;i<L;i++) S.push_back(V[i]);
      
      for(int i=0;i<R;i++) S.push_back(V[N-i-1]);
      
      sort( S.begin(), S.end() );
      
      int sum = 0;
      
      for(int i=0;i<S.size();i++) sum += S[i];
      
      int cnt = K - ( L + R );
      
      for(int i=0;i<S.size();i++){
	
	if( S[i] >= 0 ) break;
	
	if( cnt ){
	  cnt--;
	  sum -= S[i];
	}
	
      }
      
      ans = max( ans, sum );
      
    }
    
  }
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
<?php
  list($s) = explode(" ", trim(fgets(STDIN)));
  $len = strlen($s);

  $R = [];
  $L = [];
  $ans = [];

  $l_count = 0;
  for($i=0; $i<$len; $i++){
    $ans[$i] = 0;
    if($s[$i]=='L'){
      $L[$i] = $l_count;
      $l_count++;
    }else{
      $l_count = 0;
    }
  }

  
  $r_count = 0;
  for($i=$len-1; $i>=0; $i--){
    if($s[$i]=='R'){
      $R[$i] = $r_count;
      $r_count++;
    }else{
      $r_count = 0;
    }    
  }

  foreach($R as $key => $value){
    if($value % 2 == 0){
      $ans[$key + $value]++;
    }else{
      $ans[$key + $value + 1]++;
    }
  }

  foreach($L as $key => $value){
    if($value % 2 == 0){
      $ans[$key - $value]++;
    }else{
      $ans[$key - $value - 1]++;
    }
  }

  for($i=0; $i<$len; $i++){
    echo $ans[$i]." ";
  }

Measured memory_bytes: 17140
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    n = II()
    aa = MII()
    dp = [[0]*(2) for _ in range(n)]
    dp[0][0] = aa[0]
    dp[0][1] = -aa[0]
    for i in range(1, n):
        dp[i][0] = max(dp[i-1][0]+aa[i], dp[i-1][1]-aa[i])
        dp[i][1] = max(dp[i-1][0]-aa[i], dp[i-1][1]+aa[i])
    print(max(dp[n-2][0]+aa[-1], dp[n-2][1]-aa[-1]))

if __name__ == '__main__':
    main()


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

#define A 0
#define B 1
#define C 2
#define AB 3	// ABÌ_
#define BC 4	// BCÌ_
#define CIRCLE 5
#define N 6

int main(void) {
	int n;
	double x[N], y[N], r;
	double a, b, c, d, e, f;
	int i, j;

	scanf("%d", &n);
	for(i = 0; i < n; i++) {
		for(j = 0; j < 3; j++) {
			scanf("%lf", &x[j]);
			scanf("%lf", &y[j]);
		}
		// ABÌ¼ñªü ax + by = c ðßé
		x[AB] = (x[A]+x[B])/2.0;
		y[AB] = (y[A]+y[B])/2.0;
		a = x[B]-x[A];
		b = y[B]-y[A];
		c = x[AB]*(x[B]-x[A]) + y[AB]*(y[B]-y[A]);
		// BCÌ_ÆAðÊé¼ü dx + ey = f ðßé
		x[BC] = (x[B]+x[C])/2.0;
		y[BC] = (y[B]+y[C])/2.0;
		d = x[C]-x[B];
		e = y[C]-y[B];
		f = x[BC]*(x[C]-x[B]) + y[BC]*(y[C]-y[B]);
		// ñ¼üÌððßé
		x[CIRCLE] = (c*e-b*f)/(a*e-b*d);
		y[CIRCLE] = (a*f-c*d)/(a*e-b*d);
		x[CIRCLE] += 0.0;	// ******** -0.0Æ¢¤\¦ðñð·é½ßÉüêé ********
		y[CIRCLE] += 0.0;	//
		// ¼aðßé
		r = sqrt( (x[CIRCLE]-x[A])*(x[CIRCLE]-x[A])+(y[CIRCLE]-y[A])*(y[CIRCLE]-y[A]) );
		// \¦
		printf("%.3f %.3f %.3f\n", x[CIRCLE], y[CIRCLE], r);
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;

#pragma warning (disable:4996)

#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 114514

int x[1000][1000];
int color[10000];
int MIN[10000];
int sum;
int sum_min = INF;

int main() {
	while (true) {
		sum_min = INF;
		sum = 0;
		memset(x, 0, sizeof(x));
		memset(color, 0, sizeof(color));
		memset(MIN, 0, sizeof(MIN));
		int n, a, b, c, m, e, f, g;
		cin >> n;
		if (n == 0) { break; }
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				x[i][j] = -1;
			}
		}
		cin >> m;
		for (int i = 0; i < m; i++) {
			scanf("%d,%d,%d", &e, &f, &g);
			x[e][f] = g / 100 - 1;
			x[f][e] = g / 100 - 1;
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				MIN[j] = INF;
				color[j] = WHITE;
			}
			b = INF;
			a = n;
			color[i] = GRAY;
			MIN[i] = 0;
			while (a != 0) {
				b = INF;
				for (int j = 0; j < n; j++) {
					if (color[j] == GRAY) {
						if (b > MIN[j]) {
							b = MIN[j];
							c = j;
						}
					}
				}
				color[c] = BLACK;
				a -= 1;
				for (int k = 0; k < n; k++) {
					if (color[k] != BLACK && x[c][k] != -1) {
						color[k] = GRAY;
						MIN[k] = min(x[c][k], MIN[k]);
					}
				}
			}
			sum = 0;
			for (int j = 0; j < n; j++) {
				sum += MIN[j];
			}
			sum_min = min(sum_min, sum);
		}
		cout << sum_min << endl;
	}
	return 0;
}

Measured memory_bytes: 5236
n,m=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)
r=0;ccum=a.map{|x|r=(r+x)%m}

h=ccum.each_with_object(Hash.new(0)){|v,o| o[v]+=1}

p h[0] + h.values.inject(0){|res,v|res+=v*(v-1)/2}

Measured memory_bytes: 13444
from heapq import heappush, heappop
from collections import deque
import re
import math
import functools

def sRaw():
    return input().rstrip("\r")

def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29


def make1d_arr(n, val=INF):
    return [val for i in range(n)]


def make2d_arr(h, w, val=INF):
    return [[val for i in range(w)]for i in range(h)]


def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)


def BFord(n,es):
    v_cost = [INF]*n
    v_cost[0] = 0
    for v in range(n*2):
        for e in es:
            frm = e[0]
            to = e[1]
            if v_cost[to] > v_cost[frm]+e[2]:
                v_cost[to] = v_cost[frm]+e[2]
                if v >= n:
                    v_cost[to] = -INF
        if v == n-1:
            prev = v_cost[:]
    v_cost = [-INF if prev[idx]!=v_cost[idx] else v_cost[idx] for idx in range(n)]
    return v_cost
    
def ZAlgo(s):
    l = len(s)
    A = [0]*l
    i =1
    j =0
    A[0]=l
    while i<l:
        while i+j<l and s[j] == s[i+j]:
            j+=1
        if j==0:
            i+=1
            continue
        A[i]=j
        k=1
        while (i+k<l) and (k+A[k]<j):
            A[i+k] =A[k]
            k+=1
        i+=k
        j-=k
    return A


def main():
    a,b,x = isRaw()
    half_theta = math.atan2(b,a)
    if x >= a*a*b/2:
        res = a*a*b-x
        return math.degrees(math.atan2(2*res,a*a*a))
    else:
        return math.degrees(math.atan2(a*b*b, 2*x))

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 38512
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<algorithm>
#include<queue>
#include<functional>
#include<numeric>
#include<sstream>
#include<math.h>
#include <iomanip>
#define ll long long
#define PLL pair<ll,ll>
#define VS vector<string>
#define VL vector<ll>
#define rep(i,a) for (ll i=0;i<a;i++)
#define nrep(i,n,a) for (ll i=n;i<a;i++)
#define mrep(i,a) for(ll i=a;i>=0;i--)
#define INF 1145141919810
#define VMIN(vec) *std::max_element(vec.begin(),vec.end())
#define VMIN(vec) *std::max_element(vec.begin(),vec.end())
#define VSUM(vec) std::accumulate(vec.begin(),vec.end(),0LL)
#define LTS(n) to_string(n)
#define STL(str) stoll(str);

using namespace std;

int main() {
	ll n, m;
	cin >> n >> m;
	m -= n * 2;
	if (m <= 0) cout << (m+n*2) / 2 << endl;
	else cout << n + m / 4 << endl;

	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    a,b=SI().split()
    a=int(a)
    b1,b0=map(int,b.split("."))
    print(a*(b1*100+b0)//100)

main()

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
int n,x,a[2][205];
int main(){
	scanf("%d",&n);
	for (int j=0;j<2;++j)
	for (int i=1;i<=n;++i) scanf("%d",&a[j][i]);
	for (int i=1;i<=n;++i) a[0][i]=a[0][i-1]+a[0][i];
	for (int i=n;i;--i) a[1][i]+=a[1][i+1];
	for (int i=1;i<=n;++i) x=max(a[0][i]+a[1][i],x);
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        int n = sc.nextInt();
        String str = sc.next();
        boolean[] s = new boolean[n];

        for(int i = 0; i < n; i++){
            s[i] = str.charAt(i) == 'o';
        }

        next:
        for(int i = 0; i < 4; i++){
            boolean[] t = new boolean[n];
            switch(i){
                case 0:
                    t[0] = true;
                    t[1] = true;
                    break;
                case 1:
                    t[0] = true;
                    t[1] = false;
                    break;
                case 2:
                    t[0] = false;
                    t[1] = true;
                    break;
                case 3:
                    t[0] = false;
                    t[1] = false;
                    break;
            }

            for(int j = 2; j < n; j++){
                t[j] = (t[j - 1] == s[j - 1]) == t[j - 2];
            }

            StringBuilder sb = new StringBuilder();
            
            if((s[0] == t[0]) != (t[n - 1] == t[1])){
                continue next;
            }
            sb.append(t[0] ? "S" : "W");
            for(int j = 1; j < n - 1; j++){
                if((s[j] == t[j]) != (t[j - 1] == t[j + 1])){
                    continue next;
                }
                sb.append(t[j] ? "S" : "W");
            }
            if((s[n - 1] == t[n - 1]) != (t[n - 2] == t[0])){
                continue next;
            }
            sb.append(t[n -1] ? "S" : "W");
            
            System.out.println(sb.toString());
            return;
        }
        System.out.println(-1);

    }
}


Measured memory_bytes: 29852
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000


ll gcm(ll a,ll b);
ll lcm(ll a,ll b);
ll fac(ll a);

int main(){
  ll n,time;
  cin >> n >> time;
  ll ans = 0;
  ll now = 0;
  rep(i,n){
    int touch;
    cin >> touch;
    if(touch < now){
      int pre = now;
      now = touch + time;
      ans += now - pre;
    }
    else{
      now = touch + time;
      ans += time;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/************************************************
*Author        :  xzj213
*Created Time  :  2018.12.29 20:33
*Mail          :  xzj213@qq.com
*Problem       :  agc030_a.cpp
************************************************/
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int read() {
    int x=0,f=1;
    char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int main() {
	scanf("%d%d%d",&a,&b,&c);
	printf("%d\n",min(a+b+1,c)+b);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll A, B;
    cin >> A >> B;
    if (abs(A-B) % 2 == 0) {
        cout << (A+B) / 2 << "\n";
    } else {
        cout << "IMPOSSIBLE\n";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); i++)
int num_n(int a, int b, int c){
    int i=0;
  	int ans=0;
    while (c>0){
        c -= a;
      	i++;
      	if (i && i%7 ==0) c-=b;
      	ans++;
    }
    return ans;
}
int main(){
    int a, b, c; cin >> a >> b >> c;
    int n=num_n(a, b, c);
    cout << n << endl;
}


Measured memory_bytes: 3112
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	H = int(input())
	W = int(input())
	N = int(input())
	ans = H + W
	for i in range(H + 1):
		for j in range(W + 1):
			if H * W - i * j >= N:
				ans = min(ans, H - i + W - j)

	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 39884
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import connected_components

"""
点(x,y) を、辺x-yと見て二部グラフとみなす
"""

N = int(readline())
XY = np.array(read().split(),np.int32)

U = 10**5 + 100
X = XY[::2]; Y = XY[1::2]
graph = csr_matrix((np.ones(N),(X,Y+U)),(U+U,U+U))
Ncomp,comp = connected_components(graph)

comp_x=np.bincount(comp[:U],minlength=Ncomp) # 連結成分に含まれるx座標の個数
comp_y=np.bincount(comp[U:],minlength=Ncomp) # 連結成分に含まれるx座標の個数
comp_E=np.bincount(comp[X],minlength=Ncomp) # 連結成分に含まれる辺の個数

answer = (comp_x * comp_y - comp_E).sum()
print(answer)

Measured memory_bytes: 25800
#![allow(unused_imports)]
#![allow(non_snake_case)]
 
use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
 
/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}
 
/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}
 
/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
 
    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

use std::ascii::AsciiExt;
 
fn main() {
    let (A, B) = read!(usize, usize);
    if A > 12 {
        println!("{}",B);
    }
    else if A > 5{
        println!("{}",B / 2);
    }
    else{
        println!("{}",0);
    }
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>
#include <math.h>
int main ()
{
    int n, a, b;
    scanf ("%d %d %d", &n, &a, &b);
    if ((a+b)%2==0) printf ("Alice");
    else printf ("Borys");
    return 0;
}


Measured memory_bytes: 1704
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
  string a, b, c;
  cin >> a >> b >> c;
  if(a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0])
    cout << "YES";
  else
    cout << "NO";
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <functional>
#include <utility>

using namespace std;

//  E[i]: vertexes which can be reased from i
//  W[i]: their weight
template<class T>
vector<T> dijkstra(vector<vector<int>> E, vector<vector<T>> W, int s, T inf)
{
    int n = (int)E.size();

    vector<T> D(n, inf);
    typedef pair<T,int> P;
    priority_queue<P,vector<P>,greater<P>> Q;

    D[s] = T();
    Q.push(make_pair(D[s], s));

    while (!Q.empty())
    {
        int d = Q.top().first;
        int p = Q.top().second;
        Q.pop();
        if (d > D[p])
            continue;
        for (int i=0; i<(int)E[p].size(); i++)
        {
            int t = E[p][i];
            if (d+W[p][i] < D[t])
                D[t] = d+W[p][i],
                Q.push(make_pair(D[t], t));
        }
    }
    return D;
}

#include <iostream>

int main()
{
    int N, X, Y;
    cin>>N>>X>>Y;
    X--;
    Y--;

    vector<vector<int>> E(N), W(N);
    for (int i=0; i<N-1; i++)
    {
        E[i].push_back(i+1);
        E[i+1].push_back(i);
        W[i].push_back(1);
        W[i+1].push_back(1);
    }
    E[X].push_back(Y);
    E[Y].push_back(X);
    W[X].push_back(1);
    W[Y].push_back(1);

    vector<int> ans(N);
    for (int i=0; i<N; i++)
    {
        vector<int> D = dijkstra(E, W, i, N);
        for (int j=0; j<i; j++)
            ans[D[j]]++;
    }
    for (int i=1; i<N; i++)
        cout<<ans[i]<<endl;
}


Measured memory_bytes: 888
#include<stdio.h>
int main(void)
{
	int a,b,c,n,i,j,x[1001][5],r,flg[1001],cnt;
	while(1){
		scanf("%d%d%d",&a,&b,&c);
		if(a==0&&b==0&&c==0) break;
		scanf("%d",&n);
		for(i=1;i<=a+b+c;i++) flg[i]=0; 
		for(i=1;i<=n;i++){
			for(j=1;j<=3;j++) scanf("%d",&x[i][j]);
			scanf("%d",&r);
			if(r==1){
				for(j=1;j<=3;j++) flg[x[i][j]]=1;
			}
		}
		for(i=1;i<=n;i++){
			cnt=0;
			for(j=1;j<=3;j++) if(flg[x[i][j]]==1) cnt++;
			if(cnt==2){
				for(j=1;j<=3;j++){
					if(flg[x[i][j]]==0) flg[x[i][j]]=2;
				}
				//for(j=1;j<=a+b+c;j++) printf("flg[%d]=%d\n",j,flg[j]);
			}
		}
		for(i=1;i<=a+b+c;i++){
			if(flg[i]==2) printf("0\n");
			else if(flg[i]==0) printf("2\n");
			else printf("1\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1740
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  int a, b, c;
  cin>>a>>b>>c;
  int ans=min(a+b,min(b+c,a+c));
  cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
if n <= 599:
    print(8)
elif n <= 799:
    print(7)
elif n <= 999:
    print(6)
elif n <= 1199:
    print(5)
elif n <= 1399:
    print(4)
elif n <= 1599:
    print(3)
elif n <= 1799:
    print(2)
elif n <= 1999:
    print(1)

Measured memory_bytes: 9176
def comp(a,b):
    s = 0
    for i,j in zip(a,b):
        if not i == j:
            s += 1
    return s
 
s = input()
t = input()
ans = len(t)
 
for i in range(len(s) - len(t) + 1):
    score = comp(s[i:i+len(t)],t)
    if score == 0:
        ans = score
        break
    if ans > score:
        ans = score
 
print(ans)

Measured memory_bytes: 9072
// -> limitless <- //
#include<bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define f(i, x, n) for (int i = x; i < (int)(n); ++i)
#define lp(i, n) for (int i = 0; i < (int)(n); ++i)
#define read(n) scanf ("%d", &n)
using namespace std;
typedef unsigned long long ll;
    const int N = 1e4 + 2;
    const int mod = 1e9 + 7;

int main()
{
    string str;
    cin >> str;
    int o = 0, z = 0;
    lp(i, str.size())if(str[i] == '+')o++;else z++;
    printf("%d", o-z);
	return 0;
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: Vec<char> = iterator.next().unwrap().chars().collect();

    if n[0] == '7' || n[1] == '7' || n[2] == '7' {
        return "Yes".to_string();
    }

    return "No".to_string();
}


Measured memory_bytes: 2132
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int X;
    int N;
    List<Integer> p = new ArrayList<Integer>();;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.X = sc.nextInt();
        this.N = sc.nextInt();
        for (int i = 0; i< N; i++) {
        	p.add(sc.nextInt());
        }
    }
    
    //解答処理
    private int solve() {
        int answer = 0;
        
        for (int i = 0; i<= 100; i++) {
        	if (!p.contains(X - i)) {
        		answer = X - i;
        		break;
        	} else if (!p.contains(X + i)) {
        		answer = X + i;
        		break;
        	}
        }
        
        return answer;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 36136
#include<stdio.h>

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

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

  int min = a[0], max = a[0];
  long long int sum = 0;
  for ( i = 0; i < n; i++){
    if ( a[i] < min ){
      min = a[i];
    }else if ( a[i] > max ){
      max = a[i];
    }
    sum += a[i];
  }

  printf("%d %d %lld\n",min,max,sum);

  return 0;
}

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

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

    ll n, k, mod = 1e9 + 7;
    cin >> n >> k;
    ll rootn = sqrt(n);

    vector<vector<ll>> dp(k, vector<ll>(2 * rootn)),
        sdp(k, vector<ll>(2 * rootn));

    rep(i, 0, rootn) {
        dp[0][i] = 1;
        sdp[0][i] = (dp[0][i] + (i != 0 ? sdp[0][i - 1] : 0)) % mod;
    }
    ll m = 2 * rootn - 1;
    if (n / (rootn) != rootn) {
        m = 2 * rootn;
    }
    rep(i, rootn, m) {
        dp[0][i] = (n / (m - i) - n / (m - i + 1)) % mod;
        sdp[0][i] = (dp[0][i] + sdp[0][i - 1]) % mod;
    }

    rep(i, 1, k) {
        rep(j, 0, m) {
            dp[i][j] = dp[0][j] * sdp[i - 1][m - 1 - j] % mod;
            sdp[i][j] = (dp[i][j] + (j != 0 ? sdp[i][j - 1] : 0)) % mod;
        }
    }
    ll ans = 0;
    rep(i, 0, m) ans = (ans + dp[k - 1][i]) % mod;
    cout << ans << endl;
    /*
    rep(i, 0, k) rep(j, 0, 2 * rootn - 1) {
        cout << dp[i][j] << ((j != 2 * rootn - 1 - 1) ? ' ' : '\n');
    }*/
    return 0;
}

Measured memory_bytes: 99728
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, string> P;
typedef tuple<int, string, string> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int a, b;

int solve() {
    return a * b;
}

void input() {
    cin >> a >> b;
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3160
A, B, C, D = map(int, input().split())
count = 0
while True:
    if count % 2 == 0: #Takahashi Turn
        C -= B
    else: #Aoki Turn
        A -= D
    if C <= 0:
        ret = 'Yes'
        break
    if A <= 0:
        ret = 'No'
        break
    count += 1
print(ret)

Measured memory_bytes: 9112
H, W = map(int, input().split())
c = [0] * 26
for _ in range(H):
	for i in input():
		c[ord(i) - ord('a')] += 1
a = 0
b = 0
for i in c:
	a += i % 4 // 2
	b += i % 2
if (H % 2) * (W % 2) < b:
	print("No")
elif (H % 2) * (W // 2) + (H // 2) * (W % 2) < a:
	print("No")
else:
	print("Yes")

Measured memory_bytes: 38896
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define MAX_N 128;

bool is_good_set(int, int, int);
bool is_same_number(int, int, int);
bool is_sequence(int, int, int);
bool is_all_good_set();
int win();

int T, card[16];

bool is_good_set(int a, int b, int c)
{
    return is_same_number(a, b, c) || is_sequence(a, b, c);
}

bool is_same_number(int a, int b, int c)
{
    return a == b && b == c && c == a;
}

bool is_sequence(int a, int b, int c)
{
    return (a+2) == (b+1) && (b+1) == c && c==(a+2);
}

bool is_all_good_set()
{
    return
    (
        is_good_set(card[0], card[1], card[2])
        && is_good_set(card[3], card[4], card[5])
        && is_good_set(card[6], card[7], card[8])
    );
}

int win()
{
    do
    {

    } while (next_permutation(card,card+9));
    
    
    do
    {
        
        if(is_all_good_set()) { return 1; }
        
    } while (next_permutation(card, card+9));

    return 0;
}

int main()
{
    cin >> T;
    for (int t=0; t<T; ++t)
    {
        for (int i=0; i<9; ++i)
        {
            cin >> card[i];
            //cout << card[i];
        }
        //cout << endl;
        
        string color;
        for (int i=0; i<9; ++i)
        {
            cin >> color;
            if (color == "G") { card[i] += 10; }
            else if (color == "B") { card[i] += 20; }
            //cout << card[i] << " ";
        }
        //cout << endl;
        
        int ans = win();
        cout << ans << endl;
    }
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define R cin>>
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

P p[100001];
int r[100001];
void init() {
  for(int i=0; i<100001; i++) {
    p[i]=P(i,0);
    r[i]=0;
  }
}
P find(int x) {
  if(p[x].F==x) return p[x];
  else {
    P q=find(p[x].F);
    p[x]=P(q.F,p[x].S+q.S);
    return p[x];
  }
}
void unite(int xx,int yy, int w) {
  P x=find(xx);
  P y=find(yy);
  if(x.F==y.F) return;
  
  if(r[x.F]<r[y.F]) p[x.F]=P(y.F,y.S-x.S+w);
  else {
    p[y.F]=P(x.F,x.S-y.S-w);
    if(r[x.F]==r[y.F]) r[x.F]++;
  }
}

int main() {
  int n,m;
  while(cin >> n >> m && n) {
    init();
    while(m--) {
      char c;
      cin >> c;
      if(c=='?') {
	int x,y;
	cin >> x >> y;
	P xx=find(x),yy=find(y);
	if(xx.F==yy.F) pr(xx.S-yy.S);
	else pr("UNKNOWN");
      } else {
	int x,y,w;
	cin >> x >> y >> w;
	unite(x,y,w);
      }
    }
  }
  return 0;
}


Measured memory_bytes: 2336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N, A;
vector<int> x;
ll dp[55][55][2510];

int main() {
    cin >> N >> A; x.resize(N);
    for (int i = 0; i < N; i++) scanf("%d", &x[i]);

    dp[0][0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= i; j++) {
            for (int k = 0; k < 2510; k++) {
                dp[i+1][j][k] += dp[i][j][k];
                dp[i+1][j+1][k+x[i]] += dp[i][j][k];
            }
        }
    }
    ll sum = 0;
    for (int i = 1; i <= N; i++) sum += dp[N][i][i*A];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 53504
import java.util.*;

public class Main {
    static String str;
    static char[] c;
    static boolean ok;
    
    public static void main(String[] args) throws Exception {
        // Your code here! 
        Scanner sc = new Scanner(System.in);
        str = sc.next();
        c = str.toCharArray();
        
        dfs(0);
        
        if (ok) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
    
    public static void dfs(int i) {
        // 終了条件: 最大のルンルン数は10桁なので11桁以上は不要
        if (i == c.length) {
            ok = true;
            return;
        }
        
        // System.out.println(i);
        
        boolean ok5 = false;
        boolean ok7 = false;
        boolean ok6 = false;
        
        if (i+4 < c.length && c[i] == 'd' && c[i+1] == 'r' && c[i+2] == 'e' && c[i+3] == 'a' && c[i+4] == 'm') ok5 = true;
        if (i+4 < c.length && c[i] == 'e' && c[i+1] == 'r' && c[i+2] == 'a' && c[i+3] == 's' && c[i+4] == 'e') ok5 = true;
        if (i+6 < c.length && c[i] == 'd' && c[i+1] == 'r' && c[i+2] == 'e' && c[i+3] == 'a' && c[i+4] == 'm' && c[i+5] == 'e' && c[i+6] == 'r') ok7 = true;
        if (i+5 < c.length && c[i] == 'e' && c[i+1] == 'r' && c[i+2] == 'a' && c[i+3] == 's' && c[i+4] == 'e' && c[i+5] == 'r') ok6 = true;
        
        
        // 次の桁はlast-1, last+0, last+1のパターン
        if (ok5) {
            dfs(i + 5);
        }
        if (ok7) {
            dfs(i + 7);
        }
        if (ok6) {
            dfs(i + 6);
        }
    }
}

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


int main() {
    int H, W;
    cin >> H >> W;
    int a[510][510]={0};
  
    int odd = 0;
  
    for (int i = 0; i < H; ++i) 
      for (int j = 0; j < W; ++j) {
        cin >> a[i][j];
      
        if (a[i][j] & 1) ++odd;
    }
    
    vector<pair<pair<int,int>,pair<int,int>>> res;
  
    int num = 0;
  
    int x = 0, y = 0;
    for (int i = 0; i < W*H; ++i) {
      //一筆書き
        if (a[x][y] & 1) ++num;
            
        int ax = x, ay = y;
      
        if (x % 2 == 0) {
          
            if (ay == W-1) ++ax;
            else ++ay;
        }
        else {
            if (ay == 0) ++ax;
            else --ay;
        }
      
        if (num & 1) if (num < odd) res.push_back(pair<pair<int,int>,pair<int,int>>(pair<int,int>(x, y), pair<int,int>(ax, ay)));
        x = ax, y = ay;
    }
        
    cout << res.size() << endl;
    for (auto p : res) {
        cout << p.first.first+1 << " " << p.first.second+1 << " " << p.second.first+1 << " " << p.second.second+1 << endl;
    }
}


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

int main()
{
    ll N;
    cin >> N;
    
    ll A[N-1];
    ll ans[N+1] = {0};

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

    for(ll i = 1; i <= N; i++)
    {
        cout << ans[i] << endl;
    }

    
}

Measured memory_bytes: 6732
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         UNIQUE(v)                   v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;
//int dx[]={0,0,1,-1,1,1,-1,-1};
//int dy[]={1,-1,0,0,1,-1,1,-1};

#define lim 200000+5

ll MAP[lim],a[lim];

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);   
    ll n;
    sfl(n);
    for(ll i=1;i<=n;i++){
        sfl(a[i]);
        MAP[a[i]]++;
    }
    ll sum=0,x,val;
    for(ll i=0;i<=n;i++){
        x = MAP[i];
        sum += (x*(x-1))/2;
    }
    for(ll i=1;i<=n;i++){
        x = MAP[a[i]];
        val = sum;
        val -= (x*(x-1))/2;
        x--;
        val += (x*(x-1))/2;
        pfl(val);
    }
    return 0;
}


Measured memory_bytes: 6848
n=gets.to_i; a=gets.chomp.chars
min=now=a.count('E')+(a[0]=='E' ? -1:0)
for i in 1...n do
  now+=(a[i-1]=='W' ? 1:0)+(a[i]=='E' ? -1:0)
  min>now&&min=now
end
puts min


Measured memory_bytes: 27420
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $max = 0;
  $max2 = 0;
  $x = [];
  for ($i=0; $i<$n; $i++) {
    list($a) = explode(" ", trim(fgets(STDIN)));
    $x[] = $a;
    if($a > $max){
      $max2 = $max;
      $max = $a;
    }else if($a > $max2){
      $max2 = $a;
    }
  }

  for ($i=0; $i<$n; $i++) {
    if($x[$i] == $max){
      echo $max2;
    }else{
      echo $max;
    }
    echo PHP_EOL;
  }

  

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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define ABS(x, y) ((x) > (y) ? ((x) - (y)) : ((y) - (x)))
#define MOD(x, y) ((x) % (y))
#define DIVCEIL(x, y) (((x) + ((y) - 1)) / (y))
#define DIVFLOOR(x, y) ((x) / (y))
#define DIVROUND(x, y) (MOD(x, y) * 2 >= (y) ? DIVCEIL(x, y) : DIVFLOOR(x, y))

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

  for (int x{}; x <= N; ++x) {
    for (int y{}; y <= N - x; ++y) {
      int z = (Y - x * 10000 - y * 5000) / 1000;
      if (x + y + z == N) {
        cout << x << ' ' << y << ' ' << z << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int minus = 0;
  vector<ll> A(N);
  ll mini = big;
  for(int i=0;i<N;++i) {
    cin>>A[i];
    mini = min(mini, abs(A[i]));
    if(A[i]<0) minus++;
  }
  ll ans = 0;
  for(int i=0;i<N;++i) ans += abs(A[i]);
  if(minus%2!=0) {
    ans -= 2*mini;
  }
  cout<<ans<<endl;
}



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

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

    int n;
    string s,t;
    cin >> n >> s >> t;

    string ans;
    
    for(int i = 0; i < n; i++){
        ans.push_back(s[i]);
        ans.push_back(t[i]);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int count;
  char sa[120];
  int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;
  scanf("%s",&sa);
for(count=0;sa[count]!='\0';count++){
  if(sa[count]=='a'){a++;}
    if(sa[count]=='b'){b++;}
    if(sa[count]=='c'){c++;}
    if(sa[count]=='d'){d++;}
    if(sa[count]=='e'){e++;}
    if(sa[count]=='f'){f++;}
    if(sa[count]=='g'){g++;}
    if(sa[count]=='h'){h++;}
    if(sa[count]=='i'){i++;}
    if(sa[count]=='j'){j++;}
    if(sa[count]=='k'){k++;}
    if(sa[count]=='l'){l++;}
    if(sa[count]=='m'){m++;}
    if(sa[count]=='n'){n++;}
    if(sa[count]=='o'){o++;}
    if(sa[count]=='p'){p++;}
    if(sa[count]=='q'){q++;}
    if(sa[count]=='r'){r++;}
    if(sa[count]=='s'){s++;}
    if(sa[count]=='t'){t++;}
    if(sa[count]=='u'){u++;}
    if(sa[count]=='v'){v++;}
    if(sa[count]=='w'){w++;}
    if(sa[count]=='x'){x++;}
    if(sa[count]=='y'){y++;}
    if(sa[count]=='z'){z++;}
}
if (count%2==1){printf("No\n"); return 0;}
if(a%2==0&&b%2==0&&c%2==0&&d%2==0&&e%2==0&&f%2==0&&g%2==0&&h%2==0&&i%2==0&&j%2==0&&k%2==0&&l%2==0&&m%2==0&&n%2==0&&o%2==0&&p%2==0&&q%2==0&&r%2==0&&s%2==0&&t%2==0&&u%2==0&&v%2==0&&w%2==0&&x%2==0&&y%2==0&&z%2==0)
{printf("Yes\n"); return 0;}
  else{printf("No\n"); return 0;}
}

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

int main(){
 int A, B, C, D, L, a, b, c, d;
 scanf("%d", &L);
 scanf("%d", &A);
 scanf("%d", &B);
 scanf("%d", &C);
 scanf("%d", &D);
 a = ceil((double)A / C);
 b = ceil((double)B / D);
 if(a < b)c = b;
 if(b < a)c = a;
 d = L - c;
 printf("%d\n", d);
 return 0;
}
 
 
 

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;

typedef pair<ll, ll> P;


int merge(vector<ll> &a, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    vector<ll> l(n1 + 1, 0);
    vector<ll> r(n2 + 1, 0);

    for (int i = 0; i < n1; i++) {
        l[i] = a[left + i];
    }
    for (int i = 0; i < n2; i++) {
        r[i] = a[mid + i];
    }

    l[n1] = INF;
    r[n2] = INF;

    int i = 0, j = 0;
    int compare = 0;
    for (int k = left; k < right; k++) {
        compare++;
        if (l[i] <= r[j]) {
            a[k] = l[i];
            i++;
        } else {
            a[k] = r[j];
            j++;
        }
    }
    return compare;
}

int merge_sort(vector<ll> &a, int left, int right) {
    int compare = 0;
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        compare += merge_sort(a, left, mid);
        compare += merge_sort(a, mid, right);
        compare += merge(a, left, mid, right);
    }
    return compare;
}

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);

    rep(i, n) cin >> a[i];

    int compare = merge_sort(a, 0, n);
    print_line(a);

    cout << compare << endl;
}



Measured memory_bytes: 10544
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int64_t w, h; cin >> w >> h;
    int64_t x, y; cin >> x >> y;
    
    int n_ans = (2 * x == w && 2 * y == h ? 1 : 0);
    
    cout << w * h / 2.0 << ' ' << n_ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
/*input
4
3 4 3 2
*/

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

#define mx 100005
#define ll long long
#define MOD 1000000007
#define fs first
#define sc second


int main()
{
	int n;
	scanf("%d", &n);
	ll ara[n];
	for(int i = 0; i<n; i++)
		scanf("%lld", &ara[i]);
	ll l = 2, r = 2, f = 0;
	if(ara[n-1] > 2) f = 1;
	for(int i = n-1; i>=0; i--)
	{
		ll a = (l + ara[i] - 1)/ara[i] * ara[i];
		ll b = r/ara[i] * ara[i];
		if(!(l <= a && a <= r && l <=b && b <= r && a <= b)) f = 1;
		l = a;
		r = b + ara[i] - 1;
	}
	if(f) printf("-1\n");
	else printf("%lld %lld\n", l, r);
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int n;
		double[] b = new double[1111];
		double av;
		double sum;
		while(true)
		{
			n = input.nextInt();
			if(n == 0)
				break;
			else 
			{
				sum = 0;
				av = 0;
				for(int i = 0; i < n; i++)
				{
					b[i]=input.nextDouble();
					av += b[i];
				}
				av /=n;
				for(int i = 0; i < n; i++)
				{
					sum += (b[i] - av)*(b[i] - av)/n;
				}
				System.out.println( Math.sqrt(sum));
			}
		}
		input.close();
	}
}

Measured memory_bytes: 38412