akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split())
x = []
y = []
z = []
xyz = [[] for i in range(8)]
for i in range(N):
    X, Y, Z = map(int, input().split())
    xyz[0].append(X + Y + Z)
    xyz[1].append(X + Y - Z)
    xyz[2].append(X - Y + Z)
    xyz[3].append(- X + Y + Z)
    xyz[4].append(X - Y - Z)
    xyz[5].append(- X - Y + Z)
    xyz[6].append(- X + Y - Z)
    xyz[7].append(- X - Y - Z)
ans = 0
for i in range(8):
    xyz[i] = sorted(xyz[i])[::-1]
    if ans < sum(xyz[i][:M]):
        ans = sum(xyz[i][:M])


print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
 /* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)*/
template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////




int main() {
	int r,D,X,x; cin >> r >> D >> X;
	int ans = 0;
	rep(i,10)
	{
		ans = r * X - D;
		X = ans;
	cout << ans << endl;
	}
}

Measured memory_bytes: 256
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <assert.h>
#include <math.h>
#include <memory.h>
#include <stdio.h>

#include <algorithm>
#include <complex>
#include <ctime>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define left asdgashgrketwjklrej
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-12
#define M_PI 3.141592653589793
#define bsize 1024

#define ldouble long double
using namespace std;

#define bs 998244353

const int N = 500031;

int a,b,c,d;
long long dp[3031][3031];

int main() {
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", sttextdout);
  ios_base::sync_with_stdio(0);
  // cin.tie(0);

  cin>>a>>b>>c>>d;

  dp[a][b]=1;
  for (int i=a;i<=c;i++){
	  for (int j=b;j<=d;j++){
		  dp[i][j]-=dp[i-1][j-1]*(i-1)%bs*(j-1)%bs;
		  if (dp[i][j]<0)
			  dp[i][j]+=bs;
		  // put above
		  dp[i+1][j]+=dp[i][j]*j%bs;
		  // put to the right
		  dp[i][j+1]+=dp[i][j]*i%bs;
		  dp[i][j+1]%=bs;
		  dp[i+1][j]%=bs;
	  }
  }

  cout<<dp[c][d]<<endl;

  cin.get(); cin.get();
  return 0;
}


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

int n, A, B, C, l[10];

int dfs(int i, int a, int b, int c) {
	int ans;
	if (i == n) {
		if (a == 0 || b == 0 || c == 0) {
			return 1e9;
		}
		else {
			return abs(a - A) + abs(b - B) + abs(c - C);
		}
	}
	//l[i]を
	//使わない
	ans = dfs(i + 1, a, b, c);
	//aに使う
	if (a == 0) {
		ans = min(ans, dfs(i + 1, a + l[i], b, c));
	}
	else {
		ans = min(ans, dfs(i + 1, a + l[i], b, c) + 10);
	}
	//bに使う
	if (b == 0) {
		ans = min(ans, dfs(i + 1, a, b + l[i], c));
	}
	else {
		ans = min(ans, dfs(i + 1, a, b + l[i], c) + 10);
	}
	//cに使う
	if (c == 0) {
		ans = min(ans, dfs(i + 1, a, b, c + l[i]));
	}
	else {
		ans = min(ans, dfs(i + 1, a, b, c + l[i]) + 10);
	}
	return ans;
}

int main() {
	cin >> n >> A >> B >> C;
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	cout << dfs(0, 0, 0, 0) << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-13 15:43:14 +0900
# LastModified: 2020-09-13 15:49:14 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from collections import deque


def main():
    N, M = map(int, input().split())
    path = [[] for _ in range(N+1)]
    for _ in range(M):
        a, b = map(int, input().split())
        path[a].append(b)
        path[b].append(a)
    Q = deque(path[1])
    flag = False
    while Q and flag is False:
        u = Q.popleft()
        for v in path[u]:
            if v == N:
                flag = True
    if flag:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


if __name__ == "__main__":
    main()


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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000

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

    ll n;
    cin >> n;

    ll a[n+1];

    rep(i,n)
    {
        cin >> a[i];
    }
    a[n] = 0;

    ll sum1[n+1];

    ll prev = 0;
    ll sum1f = 0;
    ll sum2f = 0;

    rep(i,n+1)
    {
        sum1[i] = abs(a[i]-prev);
        prev = a[i];
        sum1f = sum1f + sum1[i];
    }

    prev = 0;
    ll sum2[n+1];
    sum2[0] = 0;

    fr(i,1,n)
    {
        sum2[i] = abs(a[i]-prev);
        prev = a[i-1];
        sum2f = sum2f + sum2[i];
    }

    rep(i,n)
    {
        ll ans = 0;
        ans = sum1f;
        ans = ans-sum1[i];
        ans = ans-sum1[i+1];
        ans = ans + sum2[i+1];

        cout << ans << endl;
    }
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back

void solve(){
    ll N;
    cin >> N;
    set<ll> A;
    REP(i, N){
        ll Ai;
        cin >> Ai;
        A.insert(Ai);
    }

    //cout << A.size() << endl;
    if(A.size() == N) cout << "YES" << endl;
    else cout << "NO" << endl;

}

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

Measured memory_bytes: 9600
import math
import sys

UNDEF=-1
sys.setrecursionlimit(1000010)
N = int(input())
# print(N)
V=[[UNDEF,UNDEF,[],[] ] for _ in range(N) ]      # Vertex
E=[[] for _ in range(N-1) ]    # Edge 

for i in range(N-1):
    (xa,xb) = map(int,input().split())
    # print(xa,xb)
    E[i]=[xa,xb]
    V[xb-1][0]=xa
    V[xb-1][1]=i+1
    V[xa-1][2].append(xb)
    V[xa-1][3].append(i+1)


# print("Edge:", E)
# print("Vertex:",V)

def root_v():
    global UNDEF
    global V
    for i in range(len(V)):
        if V[i][0] == UNDEF:
            return i+1
    return UNDEF

# print("Root Node:",root_v())

def max_degree(s):
    if V[s-1][0] != UNDEF: 
        degree=len(V[s-1][2]) + 1 # Node S 's degree for non root
    else:
        degree=len(V[s-1][2])     # Node S 's degree for root 

    for c in V[s-1][2]:
        degree = max ( degree, max_degree(c) ) 
    return degree

# print("Max Degree:", max_degree(root_v()))
print(max_degree(root_v()))

# Initialize 'color list' for edges
color=[UNDEF for _ in range(N-1)]

def put_colors(s):
    # print("put_color",s)
    global color 
    pcolor=UNDEF
    if V[s-1][1] != UNDEF:
        pcolor = color[V[s-1][1]-1]
    ic = 1
    for i in range(len(V[s-1][3])):
        if ic == pcolor:
            ic = ic + 1
        # print("put_color",s,i,V[s-1][3][i], ic )
        color[V[s-1][3][i]-1] = ic 
        put_colors(V[s-1][2][i])
        ic = ic + 1
    
put_colors(root_v())
for i in range(N-1):
    print(color[i])


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

#define ll long long
#define pll pair<ll,ll>
#define MAX 10005
#define MOD 1073741824

int main()
{
	ll r,d,xx;
	cin >> r >> d >> xx;

	ll a[MAX];

	a[2001]=r*xx - d;

	for(ll i=2002;i<=2010;i++)
	{
		a[i]=r*a[i-1]-d;
	}

	for(ll i=2001;i<=2010;i++)
	{
		cout << a[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>){
    val (w, h, n) = readLine()!!.split(" ").map { it.toInt() }
    val list = Array(n){
        readLine()!!.split(" ").map { it.toInt() }.let { Triple(it[0], it[1], it[2]) }
    }

    val xMin = list.filter { it.third == 1 }.map { it.first }.max() ?: 0
    val xMax = list.filter { it.third == 2 }.map { it.first }.min() ?: w
    val yMin = list.filter { it.third == 3 }.map { it.second }.max() ?: 0
    val yMax = list.filter { it.third == 4 }.map { it.second }.min() ?: h
    println(
        if(xMax < xMin || yMax < yMin){
            0
        }else{
            (xMax - xMin) * (yMax - yMin)
        }
    )
}

Measured memory_bytes: 37728
#include<stdio.h>
#include<string.h>
int main(void){
        int size;
        scanf("%d",&size);
        int a[size][3];
        int i;
        for(i=0;i<size;i++){
                scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]);
        }
        int j;
        char out[4]="NO";
        for(i=0;i<size;i++){
                for(j=0;j<3;j++){
                        if(a[i][j%3]*a[i][j%3]==a[i][(j+1)%3]*a[i][(j+1)%3]+a[i][(j+2)%3]*a[i][(j+2)%3]){
                                strcpy(out,"YES");
                        }
                }
                printf("%s\n",out);
                strcpy(out,"NO");
        }
        return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#include<math.h>
#include<vector>
#include <iostream>
#include <algorithm>
using namespace std;
int N;
long long costs[210][210];
//long long ecost[210][210];
void warshall(){
	/*if(r==goal){
		if(costs[r]==-1){
			costs[r] = nowcost;
		}else{
			costs[r] = min(nowcost,costs[r]);
		}
		return;
	}
	if(costs[r]<=nowcost && costs[r]!=-1){
		return;
	}
	costs[r] = nowcost;
	for(auto &e:V[r]){
		diikstra(e.to,e.cost+nowcost);
	}*/
	int i,j,k;
	//cout <<"ddd" <<N<< endl;
	for(k=0;k<N;k++){
				//cout << "renew12" << endl;
		for(i=0;i<N;i++){
				//cout << "renew" << endl;
			for(j=i;j<N;j++){
				//cout << "renew3" << endl;
				if(costs[i][j]>costs[i][k]+costs[k][j]){
					costs[i][j] = costs[i][k]+costs[k][j];

				}
				//cout << "renew" << endl;
				costs[j][i] = costs[i][j];
			}
		}
	}
	return;
}
int main(void){
	int i,j,Q,W,K,M,R;
	cin >> N >> M >> R;
	int r[R],a,b;
	long long c;
	for(i=0;i<R;i++){
		cin >> r[i];
		r[i]-=1;
	}
	
	/*for(i=0;i<N;i++){
		for(j=i;j<N;j++){
			ecost[i][j] = 1000000;
			ecost[j][i] = 1000000;
			if(i==j){
				ecost[i][j] = 0;
		}
		}
	}*/
	for(i=0;i<N;i++){
		for(j=i;j<N;j++){
			costs[i][j] = 100000000;
			costs[j][i] = 100000000;
			if(i==j){
				costs[i][j] = 0;
		}

		}
	}
	for(i=0;i<M;i++){
		cin >> a >> b >> c;
		a-=1;
		b-=1;
		//ecost[a][b] = c;
		//ecost[b][a] = c;
		costs[a][b] = c;
		costs[b][a] = c;
	}
	long long cost = 0;
	long long sumcost = 100000000;
	warshall();
	vector<int> order(0);
	for(i=0;i<R;i++){
		order.push_back(i);
	}
		/*for(j=0;j<R;j++){
			cout << order[j] << endl;;
		}
		cout << endl;*/
	/*for(i=0;i<6;i++){
		for(j=0;j<R;j++){
			cout << order[j] << endl;
		}
		cout << endl;
		cost = 0;
		for(int x=0;x<R;x++){
			cost += costs[order[x]][order[x+1]];
		}
		sumcost =min(cost,sumcost);
		next_permutation(order.begin(),order.end());
	}
	cout << sumcost;*/
	do{
		/*for(i=0;i<R;i++){
			cout << order[i] << " ";
		}
		cout << endl;*/
		cost = 0;
		for(int x=0;x<R-1;x++){
			cost += costs[r[order[x]]][r[order[x+1]]];
			//cout << costs[order[x]][order[x+1]] << endl;

		}
		//cout << sumcost<<endl;
		sumcost =min(cost,sumcost);
	}while(next_permutation(order.begin(),order.end()));
	cout << sumcost;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <numeric>
using namespace std;

int main(){
    int R,G,B,N;
    cin >> R >> G >> B >> N;

    int count = 0;

    for(int i = 0; i<=N/R;i++){
        for(int j = 0; j<=N/G;j++){
            if((N - i*R - j*G) % B == 0 && (N - i*R - j*G) >= 0){
                count = count + 1;
            }
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, '%d %d %d', $a, $b, $C);

//三角関数で使えるように度をラジアンに変換する
$rad = deg2rad($C);

//面積を求める
$S = $a * $b / 2 * sin($rad);

//残りの１辺の長さを求める
$c = sqrt(pow($a, 2) + pow($b, 2) - 2 * $a * $b * cos($rad));

//3辺の合計
$L = $a + $b + $c;

//高さを求める
$h = $S / $a * 2;

printf("%f\n%f\n%f\n", $S, $L, $h);



Measured memory_bytes: 9260
#include <bits/stdc++.h>
#include <iostream>
#define ll long long
#define mem(f, x) memset(f, x, sizeof(f))
#define INF 0x3f3f3f3f
using namespace std;
const int M = 15;
const int N = 10005;
ll n;

int main( ){
    while( scanf( "%lld", &n ) != EOF ){
        int ret = n%10;
        if( ret == 2 || ret == 4 || ret == 5 || ret == 7 || ret == 9 )
            cout << "hon\n";
        if( ret == 0 || ret == 1 || ret == 6 || ret == 8 )
            cout << "pon\n";
        if( ret == 3 )
            cout << "bon\n";
    }
    return 0;
}


Measured memory_bytes: 3764
#include<stdio.h>
#define N 500000

int n,x[N];
void maxHeapify(int i){
  int l,r,largest,swap;
  l=2*i;
  r=2*i+1;
  if(l<=n && x[l]>x[i]){
    largest=l;
  }
  else largest=i;
  if(r<=n && x[r]>x[largest]){
    largest=r;
  }
  if(largest!=i){
    swap=x[i];
    x[i]=x[largest];
    x[largest]=swap;
    maxHeapify(largest);
      }
}

int main(){
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&x[i]);
  }
  for(i=n/2;i>=1;i--){
    maxHeapify(i);
  }
  for(i=1;i<=n;i++){
    printf(" %d",x[i]);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 3692
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;

//typedef modint998244353 mint;

const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const ll MAX = 1e9 + 5;

int main() {
	int k, t;
	cin >> k >> t;
	vector<int> a(t);
	for (int i = 0; i < t; i++) {
		cin >> a[i];
	}

	sort(a.begin(), a.end(),greater<int>());


	int ans = 2 * a[0] - k - 1;

	if (ans <0) {
		ans = 0;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 3604
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College

'''
from os import path
import sys
from heapq import heappush,heappop
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input().rstrip()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
mod=1000000007
# mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')

def ceil(a,b):
    return (a+b-1)//b
file=1

def f():
    sys.stdout.flush()





def solve():

    # for _ in range(ii()):
   
        
    n = ii()
    a =  []
    for i in range(n):
        a.append(li())

    for i in range(n-2):
        if a[i][0]==a[i][1] and a[i+1][0]==a[i+1][1] and a[i+2][0]==a[i+2][1]:
            print('Yes')
            exit(0)
    print('No')










        
if __name__ =="__main__":

   
    if path.exists('input.txt'):
        sys.stdin=open('input.txt', 'r')
        sys.stdout=open('output.txt','w')
    else:
        input=sys.stdin.readline
    solve()
    

Measured memory_bytes: 70288
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    string s;
    int n=0;
    cin>>s;
    REP(i,4){
        if(s[i]=='+')n++;
        else n--;
    }
    cout<<n<<endl;
}

Measured memory_bytes: 256
from itertools import combinations
_=list(map(int,input().split()))
a=list(combinations([i for i in range(_[0],_[1]+1)],2) if _[1]-_[0]<2019 else combinations([i for i in range(_[0],_[0]+2020)],2))
print(min([i[0]*i[1]%2019 for i in list(a)]))

Measured memory_bytes: 238736
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
def f(n):
  for i in range(50,-1,-1):
    if n>=(i*(i+1)//2):
      return i
      break
n=int(input())
cnt=0
alist=factorization(n)
for i in range(len(alist)):
  cnt+=f(alist[i][1])
if n==1:
  cnt=0
print(cnt)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

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

	ll N;
	ll ans = 0;

	cin >> N;

	vector<pair<pair<string, ll>, ll>> rating(N);

	string name;
	ll score;
	rep(i, N) {
		cin >> name >> score;
		rating[i] = make_pair(make_pair(name, -score), i + 1);
	}

	sort(ALL(rating));

	rep(i, N) {
		cout << rating[i].second << "\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  size_t sz=s.size();
  sort(s.begin(),s.end());
  s.erase(unique(s.begin(),s.end()),end(s));
  sz==s.size()?cout<<"yes":cout<<"no",cout<<endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int main() {
    string s;
    cin >> s;
    LL ans = 0;
    int cnt = 0;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'B')
        {
            cnt++;
        }
        else
        {
            ans += cnt;
        }
    }
    cout << ans;
    return 0;
}

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

using namespace std;
vector <pair<int,int>> tab;
bool comp( pair <int,int> a , pair < int,int> b){
return (a.first < b.first);
}
int main () {
int n;
cin >> n;
int a;
for( int i = 1 ; i <= n ; i++){
    cin >> a;
    tab.push_back(make_pair(a,i));
}
sort(tab.begin(),tab.end(),comp);
int rez[200001];
for ( int i = 0 ; i < n ; i++){
    if( i < n/2){
        rez[tab[i].second]=tab[n/2].first;
    }else{
        rez[tab[i].second]=tab[(n-2)/2].first;
    }
}
for ( int i = 1 ; i <= n ; i++){
    cout << rez[i] << endl;
}
return 0;
}


Measured memory_bytes: 4720
n = int(input())

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

divs1 = make_divisors(n - 1)
divs2 = make_divisors(n)
ans = set(divs1[1:])

for kk in divs2[1:]:
    A = n
    while True:
        if A % kk == 0:
            A //= kk
        else:
            break

    if (A - 1) % kk == 0:
        ans.add(kk)

ans.add(n)
print(len(ans))


Measured memory_bytes: 65924
#include <stdio.h>
int main(void){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(x+r>W||x-r<0||y+r>H||y-r<0)printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 584
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <queue>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int gcd(int a, int b){
   int tmp;
   while(a%b==0){
      tmp=a%b;
      a=b;
      b=tmp;
   }
}

int lcm(int a,int b){
   return a*b/gcd(a,b);
}

bool prime_number(int n){
   vector<bool> i;
   if(n < 2){
      return false;
   }
   else if(n == 2){
      return true;
   }
   if(n % 2 == 0){
      return false;
   }
   for(int i=3;i<=n/i;i+=2){
      if(n % i == 0) return false;
      return true;
   }
}

int main(){
   vector<double> a;
   double b;
   
   while(cin >> b){
      a.PB(b);
   }
   cout << *max_element(a.begin(), a.end())
   - *min_element(a.begin(), a.end()) << endl;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, ss, ee) for (ll i = ss; i < ee; ++i)

ll N, X, M;
void input() { cin >> N >> X >> M; }

void solve() {
  ll sum = 0;
  ll len = 0;
  vector<ll> v;
  vector<ll> id(M, -1);

  while (id[X] == -1) {
    id[X] = len;
    v.emplace_back(X);
    sum += X;
    len++;
    // cout << X << " " << len << " " << sum << endl;
    X = (X * X) % M;
  }

  ll c = len - id[X];
  ll sum_c = 0;
  rep(i, id[X], len) { sum_c += v[i]; }
  // cout << "cycle" << c << " sum_c" << sum_c << endl << endl;

  ll ans = 0;
  if (N <= len) {
    // Nが周期以下
    rep(i, 0, N) { ans += v[i]; }

  } else {
    //周期に入るまで
    ans += sum;

    //周期合計ｘ周期回数
    N -= len;
    ans += sum_c * (N / c);

    // 周期終わった後の残り
    N %= c;
    rep(i, 0, N) ans += v[id[X] + i];
  }
  cout << ans << endl;
}

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

// 10000000000 10 99959
// 492443256176507

Measured memory_bytes: 4656
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	string s,a;
	cin>>s;a=s;
	reverse(s.begin(),s.end());
	
	for(int i=0;i<s.length();i++){
		if(s[i]=='b') s[i]='d';
		else if(s[i]=='d') s[i]='b';
		else if(s[i]=='p') s[i]='q';
		else if(s[i]=='q') s[i]='p';
	}
	if(s==a) cout<<"Yes\n";
	else cout<<"No\n";
}

Measured memory_bytes: 512
S = raw_input()
if S.startswith('k') and S.endswith('eyence'):
    print('YES')
elif S.startswith('ke') and S.endswith('yence'):
    print('YES')
elif S.startswith('key') and S.endswith('ence'):
    print('YES')
elif S.startswith('keye') and S.endswith('nce'):
    print('YES')
elif S.startswith('keyen') and S.endswith('ce'):
    print('YES')
elif S.startswith('keyenc') and S.endswith('e'):
    print('YES')
elif S == 'keyence':
    print('YES')
else:
    print('NO')

Measured memory_bytes: 2568
#include<bits/stdc++.h>
#include<numeric>
#define int long long
#define rep(i,j,n) for(int i=j;i<n;i++)
const int inf=1e9+5;
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    int dp[3]={0};
    // dp[i] - the total cost such that we did activity i on the last considered day
        for(int day=0;day<n;day++){
            int new_dp[3]={0};
            int c[3];
            for(int j=0;j<3;j++)cin>>c[j];
            for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                if(i!=j)new_dp[j]=max(new_dp[j],dp[i]+c[j]);
            }
            }
            for(int i=0;i<3;i++){dp[i]=new_dp[i];}
            
}
        
    
        
 cout<<max({dp[0], dp[1], dp[2]});                
                                
        
        
        
    }

    


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pi pair<int ,int >
#define pl pair<ll ,ll >
#define pb push_back
#define vl vector <long long int >
#define vi vector <int >
#define mod 1000000007
#define eps 1e-9
#define fi first
#define se second
#define _ <<" "<<
#define forn(x,	n) for(int x = 0; x < n ;++ x) 
#define forn1(x,n) for(int x = 1; x <= n ;++ x)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
void scan(){}
template<typename F, typename... R> void scan(F &f,R&... r){cin>>f;scan(r...);}
int di_; string dnms_, co_ = ",";
void debug_(){cout<<endl;}
template<typename F, typename... R> void debug_(F &f, R&... r){while(dnms_[di_] != ',')cout<<dnms_[di_++];di_++;cout<<": "<<f<<",";debug_(r...);}
#define debug(...) dnms_=#__VA_ARGS__+co_,di_=0,debug_(__VA_ARGS__)

template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}

int grundy[(int)(1e5+1)];
vi v;
int mine;

int get_Mex(unordered_set<int>& s)
{
	int mex =0;
	while(s.find(mex)!=s.end())
		mex++;
	return mex;
}
int grundy_no(int k)
{
	if(grundy[k]!=-1)
		return grundy[k];
	if(k<mine)
	{
		grundy[k]=0;
		return 0;
	}
	unordered_set<int> s;
	for(auto& x:v)
	{
		if(k-x>=0)
		{
			grundy[k-x]= grundy_no(k-x);
			s.insert(grundy[k-x]);
		}
	}

	grundy[k] = get_Mex(s);

	return grundy[k];

}
int main(){
	IOS

	int n,k;
	cin>>n>>k;
	v.resize(n);
	cin>>v;
	mine = *min_element(v.begin(),v.end());
	
	memset(grundy,-1,sizeof(grundy));

	cout<<((grundy_no(k)==0)?"Second":"First");
 
	return 0;	
}

Measured memory_bytes: 14720
#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 pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define int               long long
#define fr                first
#define sc                second
#define vc                vector
#define endl              '\n'
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define LSB(i)            ((i)&-(i))

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve()
{
    int n;
    cin >> n;
    set<int>check;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        check.insert(a);
    }
    if (check.size() == n)
        cout << "YES" << endl;
    else
        cout << "NO";
}
signed main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin>>t;
    while (t--) solve();
    return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N; cin >> N;
    if(N==1){
        cout << "Hello World" << endl;
    }else{
        int A,B; cin >> A >> B;
        cout << A+B << endl;
    }
    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    if(N==1){
        cout << "Hello World" << endl;
        return 0;
    }
    else{
        ll A, B;
        cin >> A;
        cin >> B;

        cout << A+B << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define show(x) cout<<x<<'\n'
#define showh(x) cout<<x<<' '
#define end      cout<<endl
#define go(i,a,n) for(ll i=a;i<n;i++)
#define gor(i,a,n) for(ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
bool prime[100001];
bool ispoweroftwo(ll x)
{
    return x && !(x & (x-1));
}
ll xorcal(ll n)
{
    if(n%4==0)
        return n;
    if(n%4==1)
        return 1;
    if(n%4==2)
        return n+1;
    if(n%4==3)
        return 0;
}
void sieve(ll n)
{
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(ll i=2;i*i<=n;i++)
    {
        if(prime[i]==true)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                prime[j]=false;
            }
        }
    }
    show(prime[89]);
}
bool isprime(ll n)
{
    if (n<=1) return false;
    if (n<=3) return true;

    if(n%2==0 or n%3==0) return false;

    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0 or n%(i+2)==0) return false;
    }
    return true;
}

ll modinverse(ll a,ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m; a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
       x += m0;

    return x;
}

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

ll power(ll A, ll B)
{
    if (A == 0)
        return 0;
    if (B == 0)
        return 1;

    ll y;
    if (B % 2 == 0) {
        y = power(A, B / 2);
        y = (y * y) % mod;
    }

    else {
        y = A % mod;
        y = (y * power(A, B - 1) % mod) % mod;
    }

    return (ll)((y + mod) % mod);
}

int main()
{
    ios_base::sync_with_stdio(false);
    ll a[5];
    go(i,0,5)
    {
        cin>>a[i];
    }
    ll k;
    cin>>k;
    go(i,0,4)
    {
        go(j,i+1,5)
        {
            if(abs(a[j]-a[i])>k)
            {
                show(":(");
                exit(0);
            }
        }
    }
    show("Yay!");
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <unordered_map>
#include <cmath>
#include <queue>
using namespace std;
 
int main(){
    double n, k;
    cin >> n >> k;
    cout << (n == 1 ? 1 : ceil(log(n)/log(k))) << '\n';
}

Measured memory_bytes: 512
/* Written by Filip Hlasek 2017 */
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <iostream>

#define FOR(i, a, b)   for (int i = (a); i <= (b); i++)
#define FORD(i, a, b)  for (int i = (a); i >= (b); i--)
#define REP(i, b)      for (int i =  0 ; i <  (b); i++)

using namespace std;

#define MAXN 111111
int N;
int p[MAXN];

int main(int argc, char *argv[]) {
  scanf("%d", &N);
  REP(i, N) { scanf("%d", p + i); p[i]--; }
  int ans = 0;
  REP(i, N) {
    if (p[i] == i) {
      swap(p[i], p[i + 1]);
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
    int n, k; cin >> n >> k;
    auto c = [k](long p)
    {
        if(p >= k) return 0;
        for(int i = 1;;)
        {
            p *= 2;
            if(p >= k) return i;
            ++i;            
            
        }
    };
    double re = 0;
    cout << std::setprecision(12);
    for(int i = 1; i <= n; ++i)
    {
        re += 1.0/n * pow(0.5, c(i));                
    }
    cout << re;
    
    
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;




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

	int cnt = 0;
	int l = 0;
	int r = n - 1;
	while (l < r) {
		while (l < n && c[l] != 'W') {
			l++;
		}

		while (r >=0 && c[r] != 'R') {
			r--;
		}

		if (l < r) {
			cnt++;
			l++;
			r--;
		}
	}

	cout << cnt << endl;
}


Measured memory_bytes: 3724
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<string>
#include<bits/stdc++.h>
using namespace std;

/*define*/
#define rep(i, n) for(int i=0; i<n; ++i)
#define endl "\n"
typedef long long ll;
//typedef pair<int, int> P;
//vector<long long> a(max_n);
//map<int, int> m;
static const int max_n = 1e7+2, max_m = 102;
static const ll  INF = 1000000000;
const long long mod = 1e18;
int ci;

ll f(ll r){return r*(r+1)/2;}
int main(){
    ll n;
    vector<ll> d(max_n);
    cin >> n;
    ll ans=0;
    for(ll i=1; i<=n; ++i){
        ll r = n/i;
        ans += f(r)*i;
//        for(int j=i; j<=n; j+=i) d[j++];
    }
    cout << ans << endl;
//    for(int i=0; i<=n; ++i){
//        ans += d[i]*i;
//    }

}

Measured memory_bytes: 81172
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;		typedef vector<int> vi;
typedef vector<vl> vvl;	  	typedef vector<vi> vvi;
typedef pair<ll, ll> pll;	typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF	ll(1e18)
#ifdef SHUBHAM107
#include "../code-pieces/trace.h"
#else
#define trace(args...)
#endif

ll modpow(ll a, ll b, ll m = MOD) {
	a %= m; ll res = 1; while (b) {if (b & 1)res = res * a % m; a = a * a % m; b >>= 1;}
	return res;
}
ll bpow(ll a, ll b) {ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a) {return modpow(a, MOD - 2, MOD);}
void graph(vvi &adj, int m) {int x, y; forn(i, m) {cin >> x >> y; adj[x - 1].pb(y - 1); adj[y - 1].pb(x - 1);}}

const int mxN = 2e5 + 5;
bool can(ll x, vl &arr, ll k){
	ll cnt = 0, n = sz(arr);
	forn(i, n){
		if(arr[i] < 0){
			ll y;
			if(x < 0){
				y = (-x - arr[i]-1)/-arr[i];
			}else y = x/arr[i];
			cnt += n - (lower_bound(all(arr), y) - arr.begin());
		}else if(arr[i] == 0){
			if(x >=0) cnt += n;
		}else{
			ll y;
			if(x >= 0){
				y = x/arr[i];
			}else{
				y = -(-x + arr[i] - 1)/arr[i];
			}
			cnt += (upper_bound(all(arr), y)) - arr.begin();
		}
	}
	forn(i, n) if(arr[i]*arr[i] <= x) cnt--;
	assert(cnt%2 == 0);
	cnt /= 2;
	return (cnt >= k);
}

void solve() {
	ll n, k;
	cin >> n >> k;
	vl arr(n);
	forn(i, n) cin >> arr[i];
	sort(all(arr));
	ll start = -INF-1, end = INF, mid;
	while(start+1 < end){
		trace(start, end);
		mid = (start + end)/2;
		if(can(mid, arr, k)) end = mid;
		else start = mid;
	}
	cout << end;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef SHUBHAM107
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 1792
n,k=map(int,input().split())
r,s,p=map(int,input().split())
T=input()
ret=0

for i in range(k):
  ST = T[i::k]
  l = len(ST)
  dp = [[0 for i in range(3)] for j in range(l+1)]
  for j in range(1,l+1):
    dp[j][0] = max(dp[j-1][1]+r,dp[j-1][2]+r) if ST[j-1] == 's' else max(dp[j-1][1],dp[j-1][2])
    dp[j][1] = max(dp[j-1][0]+s,dp[j-1][2]+s) if ST[j-1] == 'p' else max(dp[j-1][0],dp[j-1][2])
    dp[j][2] = max(dp[j-1][0]+p,dp[j-1][1]+p) if ST[j-1] == 'r' else max(dp[j-1][0],dp[j-1][1])
  ret+=max(dp[-1])
print(ret)

Measured memory_bytes: 17864
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << x << endl;
#else 
    #define dbg(x)
#endif

#define int long long
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


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

    int n, k;
    cin >> n >> k;
    set<int> have;
    fi(0, k) {
        int sz;
        cin >> sz;
        fi(0, sz) {
            int x;
            cin >> x;
            have.insert(x);
        }
    }
    cout << n - have.size();
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x=0;char ch=gc();bool positive=1;
	for(;!isdigit(ch);ch=gc())if(ch=='-')positive=0;
	for(;isdigit(ch);ch=gc())x=x*10+ch-'0';
	return positive?x:-x;
}

inline void write(int x){
	if(x<0)x=-x,putchar('-');
	if(x>9)write(x/10);putchar(x%10+'0');
}

inline void writeln(int x){
	write(x);puts("");
}
#define Max 100005
int a[Max],n,sum;

int main(){
	n=read();
	a[0]=0;
	for(int i=1;i<=n;i++){
		a[i]=read();
		sum+=abs(a[i-1]-a[i]);
	}
	sum+=abs(a[n]);
	for(int i=1;i<=n;i++){
		writeln(sum+abs(a[i-1]-a[i+1])-abs(a[i]-a[i-1])-abs(a[i]-a[i+1]));
	}
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>

int main(){
    int r,g,b,n,i,count=0,x;
    scanf("%d %d %d %d",&r,&g,&b,&n);
    for(i=0;i<=n/r;i++){
        for(int j=0;j<=n/g;j++){
            x = n-(i*r+j*g);
            if(x % b != 0)continue;
            if(x < 0)break;
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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=-1e15;

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll even_sum=0;
    ll odd_sum=0;
    rep(i,n){
        cin >> a[i];
        if(i%2==0){
            even_sum+=a[i];
        }
        else{
            odd_sum+=a[i];
        }
    }
    ll k=n/2; //選べる数字の数
    ll ex=(n%2)+2;
    
    vector<vector<ll>> dp(k+1,vector<ll>(ex,INF));
    rep(i,ex){
        dp[1][i]=a[i];
    }
    for(ll i=2;i<=k;i++){
        rep(j,ex){
            ll M=INF;
            rep(m,ex){
                if(j>=m){
                    if(dp[i-1][m]==INF) continue;
                    M=max(M,dp[i-1][m]);
                }
            }
            
            dp[i][j]=M+a[2*i+j-2];
        }
    }
    ll ans=INF;
    rep(i,ex){
        ans=max(dp[k][i],ans);
        //cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
} 


Measured memory_bytes: 10344
#include <stdio.h>
#define N 100
#define INF 1000000
#define NIL -2
#define WHITE -1
#define BLACK 0
int prim(int G[N][N]);
int G[N][N];
int n;

int main(){
  int i,j,ans;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&G[i][j]);
      if(G[i][j] == -1)
	G[i][j] = INF;
    }
  }
 ans = prim(G);
 printf("%d\n",ans);
 
  return 0;
}

int prim(int G[N][N]){
  int i,u,v,mincost,sum=0,d[N],pi[N],color[N];
  for(u=0;u<n;u++){
    d[u] = INF;
    pi[u] = NIL;
    color[u] = WHITE;
  }
  d[0] = 0;
  
  while(1){
    mincost = INF;
    u = -1;
    for(i=0;i<n;i++){
      if(d[i] < mincost && color[i] != BLACK){
	u = i;
	mincost = d[i];
      }
    }
    if(mincost == INF) break;
    color[u] = BLACK;
    for(v=0;v<n;v++){
      if(color[v] != BLACK && G[u][v] != INF){
	if(d[v] > G[u][v]){
	  pi[v] = u;
	  d[v] = G[u][v];
	}
      }
    }
  }
  for(i=0;i<n;i++){
    if(pi[i] != -1) sum += G[i][pi[i]];
  }
  return sum;
}




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

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i=0; i<N; i++) {
        cin >> d.at(i);
    }

    sort(d.begin(),d.end(),greater<int>());

    int count = 1;
    for (int i=0; i<N-1; i++) {
        if (d.at(i) > d.at(i+1)) {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long
const int Maxn=0;
#define mod 0x3f3f3f3f
using namespace std;
int a[100003],b[100003];
int aa[100003],bb[100003];
int s[100003];

int main()
{  int n;
cin>>n;
int su,su1;su=su1=0;
int sum=0;
for(int i=1;i<=n;i++)
    { cin>>s[i];
       if(s[i]<0)a[++su]=s[i];
       else  b[++su1]=s[i];}
       sort(s+1,s+1+n);
       if(n==2)
       {
           cout<<s[2]-s[1]<<endl;
           cout<<s[2]<<" "<<s[1]<<endl;
           return 0;
       }
       sort(a+1,a+su+1);
       sort(b+1,b+1+su1);
       if(su1==0)
       {
           aa[++sum]=a[su];
           bb[sum]=a[su-1];
           int m=aa[sum]-bb[sum];
           for(int i=su-2;i>=1;i--)
           {
               aa[++sum]=m;
               bb[sum]=a[i];
               m-=a[i];
           }
       }
       else if(su==0)
       {
           aa[++sum]=b[1];
           bb[sum]=b[2];
           int m=b[1]-b[2];
           for(int i=3;i<su1;i++)
           {
               aa[++sum]=m;
               bb[sum]=b[i];
               m=m-b[i];
           }
           aa[++sum]=b[su1];
           bb[sum]=m;
       }
       else {
        for(int i=1;i<su1;i++)
               aa[++sum]=a[1],bb[sum]=b[i],a[1]=a[1]-b[i];
       aa[++sum]=b[su1];
       bb[sum]=a[1];
        int m=b[su1]-a[1];
        for(int i=2;i<=su;i++)
            {
                aa[++sum]=m;
                bb[sum]=a[i];
                m-=a[i];
            }
       }
   cout<<aa[sum]-bb[sum]<<endl;
   for(int i=1;i<=sum;i++)
    cout<<aa[i]<<" "<<bb[i]<<endl;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int N,M,x,y,c,d;
 	cin >> N>>M>>x>>y;
 	vector<int>a(N);
 	vector<int>b(M);
 	for (int i = 0; i < N; i++) {
 		cin >> a.at(i);}
 	for (int i = 0; i < M; i++) { 
 		cin >> b.at(i);}
 	sort(a.begin(), a.end());
 	sort(b.begin(), b.end());
 	if(a.at(N-1)>x){
 	c=a.at(N-1);
 	}else{
 	c=x;
 	}
 	if(b.at(0)<y){
 	d=b.at(0);
 	}else{
 	d=y;
 	}
 	if(c<d){
 		cout << "No War" << endl;
 	}else{
 		cout << "War" << endl;}
 }

Measured memory_bytes: 256