akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;cin >> n >> m;
    int ans = 0;
    for(int i = 0;i < n;i++)
    {
        for(int j = i+1;j<n;j++)ans++;
    }
    for(int i = 0;i < m;i++)
    {
        for(int j = i+1;j<m;j++)ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N,K;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>K;
    
    priority_queue<ll> kind[N];
    rep(i,N){
        int t;
        ll d;
        cin>>t>>d;
        kind[t-1].push(d);
    }
    
    priority_queue<ll> best, noBest;
    rep(i,N){
        if(!kind[i].empty()){
            best.push(kind[i].top());
            kind[i].pop();
            while(!kind[i].empty()){
                noBest.push(kind[i].top());
                kind[i].pop();
            }
        }
    }
    
    vector<ll> bestSum={0};
    while(!best.empty()){
        bestSum.push_back(bestSum.back()+best.top());
        best.pop();
    }
    
    vector<ll> noBestSum={0};
    while(!noBest.empty()){
        noBestSum.push_back(noBestSum.back()+noBest.top());
        noBest.pop();
    }
    
    ll ans=0;
    rep1(x,K){
        if(x>=bestSum.size()) break;
        if(K-x>=noBestSum.size()) continue;
        chmax(ans,bestSum[x]+noBestSum[K-x] + (ll)x*x);
    }
    cout1(ans)
}

Measured memory_bytes: 8820
def combination(n, x, mod=10**9+7):
    # nCx
    # 組み合わせ
    # ex) combination(5, 2) = 10
    factorial = [1] * (n+1)
    t = 1
    for i in range(1, n+1):
        t = (t * i) % mod
        factorial[i] = t
    tmp = factorial[n]
    tmp = (tmp * pow(factorial[x], mod-2, mod)) % mod
    tmp = (tmp * pow(factorial[n-x], mod-2, mod)) % mod
    return tmp

N,M=map(int,input().split())
ans=0
if N>1:
  ans+=combination(N,2)
if M>1:
  ans+=combination(M,2)
print(int(ans))

Measured memory_bytes: 3064
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let vec: Vec<&str> = buf.split_whitespace().collect();
    let num: i32 = vec[0].parse().unwrap();
    let mut flw: i32 = vec[1].parse().unwrap();
    let mut ans = 0;

    let mut min = 1000;
    for _ in 0..num{
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).ok();
        let vec: Vec<&str> = buf.split_whitespace().collect();
        let cost: i32 = vec[0].parse().unwrap();
        flw = flw - cost;
        ans = ans + 1;
        min = if min > cost {cost} else {min};
    }

    while flw >= 0 {
        ans = ans + 1;
        flw = flw - min;
    }

    ans = ans - 1;

    println!("{:?}", ans);

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define AC 0
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int d,t,s;
	cin>>d>>t>>s;
	if(d>t*s) cout<<"No\n";
	else cout<<"Yes\n";
	return AC;
}


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

//メイン関数
int main(void){
  int n, a;
  int min, max;
  long int sum;
  scanf("%d", &n);

  sum =  0;
  min =  1000000;
  max = -1000000;
  for(int i=0; i<n; i++){
    scanf("%d", &a);
    sum = sum + a;
    if(min > a) min = a;
    if(max < a) max = a;
  }

  printf("%d %d %ld\n", min, max, sum);
  return 0;
}



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

using db = double;
using ll = long long;
using vi = vector <int>;
#define op operator
#define pb push_back

int main() {
	cout << fixed << setprecision(9);
	ios :: sync_with_stdio(0);

	int ans = 0;
	for(string s; cin >> s; )
		if(equal(s.begin(), s.end(), s.rbegin()))
			ans ++;
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 3168
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def print_ans(B):
    for b in B:
        b.sort(key=lambda l: int(l))
        print(" ".join(b))



def main():
    A, B, C, K = read_values()
    
    if K <= A:
        print(K)
    elif K <= A + B:
        print(A)
    else:
        print(2 * A + B - K)


if __name__ == "__main__":
    main()



Measured memory_bytes: 9812
from collections import defaultdict

n=int(input())
a=list(map(int,input().split()))

d=defaultdict(int)
MIN=10**10
MAX=0
for i in range(n):
    d[a[i]]+=1
    MIN=min(MIN,a[i])
    MAX=max(MAX,a[i])

ans=0
for g in range(MIN,MAX+1):
    ans=max(d[g-1]+d[g]+d[g+1],ans)
print(ans)

Measured memory_bytes: 19424
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main(){ 
  vector<int> v{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int n; cin >> n; n--;
  cout << v[n] << ln;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;
 
pair<pair<int, int>, pair<int, int> > a[303030];
 
signed main()
{
	int idx = 0;
	for (int h=1; h<=150; h++) {
		for (int w=h+1; w<=150; w++) {
			a[idx++] = make_pair(make_pair(h * h + w * w, h), make_pair(h, w));
		}
	}

	sort(a, a + idx);

	int h, w;
	while (true) {
		cin >> h >> w;
		if (h == 0 && w == 0) break;
		pair<pair<int, int>, pair<int, int> > *it = lower_bound(a, a + idx, make_pair(make_pair(h * h + w * w, h), make_pair(-1, -1)));
		it++;
		cout << it->second.first << " " << it->second.second << endl;
	}
}

Measured memory_bytes: 7712
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10**7)

ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

n = ni()
a = na()

x = 0
for i in range(n):
    x ^= a[i]

ans = []
for i in range(n):
    ans.append(x ^ a[i])

print(*ans)

Measured memory_bytes: 31516
fun main(args: Array<String>) {
  val sc = java.util.Scanner(System.`in`)
  val A = sc.nextInt()
  val B = sc.nextInt()
  val C = sc.nextInt()
  val abc = intArrayOf(A, B, C)
  val max = abc.max()!!
  val d = abc.map { max - it }.sum()
  if (d % 2 == 0) {
    println(d / 2)
  } else {
    println(d / 2 + 2)
  }
}


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

long long int recursion(long long int val){
	if(val == 1){
		return 1;
	}
	else {
		return 1 + 2*recursion(val/2);
	}
}

int main() {
	long long int h;
	cin >> h;
	cout << recursion(h);
	return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
      
N, M = map(int,input().split())
XYZ = [list(map(int,input().split())) for _ in range(M)]
uf = UnionFind(N)
for i in range(M):
  uf.union(XYZ[i][0]-1,XYZ[i][1]-1)
#print(uf.parents)
#print(uf)
print(uf.group_count())

Measured memory_bytes: 80472
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstdlib>
using namespace std;int main(){typedef pair<int,int> pii;vector<pii>::iterator it;int n, m, k, x, d, h, i, j;for(; cin >> n >> m, n; ){vector<pii> st[151];for( i = 1; i <= n; i++ ){for( cin >> k; k--; ){cin >> x >> d;st[i].push_back( pii( x, d ) );}}int dp[158][151][10];fill( **dp, *dp[158], 1e9 );for( i = st[1].size(); i--; ){dp[m][1][i] = 0;}for( i = st[2].size(); i--; ){dp[m-1][2][i] = 0;}for( h = 2; h <= n; h++ ){for( i = m; i >= 0; i-- ){for( j = st[h].size(); j--; ){for( k = st[h-1].size(); k--; ){x = dp[i][h-1][k]  + ( st[h][j].second + st[h-1][k].second )  * abs( st[h][j].first - st[h-1][k].first );dp[i][h][j] = min( dp[i][h][j], x );}for( k = st[h-2].size(); k--; ){x = dp[i+1][h-2][k]  + ( st[h][j].second + st[h-2][k].second )  * abs( st[h][j].first - st[h-2][k].first );dp[i][h][j] = min( dp[i][h][j], x );}}}}x = 1e9;for( i = m; i >= 0; i-- ){for( j = st[n].size(); j--; ){x = min( x, dp[i][n][j] );}}for( i = m; i > 0; i-- ){for( j = st[n-1].size(); j--; ){x = min( x, dp[i][n-1][j] );}}cout << x << endl;}}

Measured memory_bytes: 1864
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <string>
#include <cstring>

using namespace std;

int main()
{
    string x;
    std::cin >> x;
    int i = 0;
    for(i=0;i < x.size();i++){
        if(x[i] == '7'){
            cout<< "Yes";
            return 0;
        }
    
    }

        cout << "No";
    


    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <complex>
#include <cmath>
#include <iomanip>

using Comp = std::complex<double>;

int main() {
	int n;
	std::cin >> n;
	
	std::vector<Comp> ps(n);
	for (auto&& p : ps) {
		int x, y;
		std::cin >> x >> y;

		p = Comp(x, y);
	}

	auto contains = [&](const Comp& c, double r, int a) {
		return std::abs(ps[a] - c) <= r;
	};

	auto check = [&](double r) -> bool{
		for (int a = 0; a < n; ++a) {
			for (int b = 0; b < n; ++b) {
				if (a == b)
					continue;

				const Comp v = ps[a] - ps[b];
				const Comp w(v.imag(), -v.real());
				const double l = std::abs(v);
				
				if (r/l < 0.5)
					continue;

				const double k = std::sqrt(r/l*r/l - 0.25);

				const Comp center = ps[b] + 0.5 * v + k * w;
				
				bool isOK = true;
				for (int i = 0; i < n; ++i) {
					if (i == a || i == b)
						continue;

					if (!contains(center, r, i)) {
						isOK = false;
						break;
					}
				}

				if (isOK)
					return true;
			}
		}

		return false;
	};

	double l = 0, r = 1000;
	for (int i = 0; i < 35; ++i) {
		double mid = (l + r) / 2;
		if (check(mid))
			r = mid;
		else
			l = mid;
	}

	std::cout << std::fixed << std::setprecision(7) << l << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using lint=long long;
std::vector<lint>p;
lint find(lint x){return p.at(x)<0?x:p.at(x)=find(p.at(x));}
void unite(lint x, lint y){x=find(x),y=find(y);if(x!=y)p.at(x)=y;}
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,m;std::cin>>n>>m;
    std::vector<lint>a(n);
    for(lint i=0;i<n;i++){
        std::cin>>a.at(i);
        a.at(i)--;
    }
    p.resize(n,-1);
    while(m--){
        lint u,v;std::cin>>u>>v;
        u--,v--;
        unite(u,v);
    }
    lint ans=0;
    for(lint i=0;i<n;i++){
        ans+=find(i)==find(a.at(i));
    }
    std::cout<<ans<<'\n';
}


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

using namespace std;

int main() {
  int numDays;
  cin >> numDays;
  vector<vector<int>> tasks;
  for (int i = 0; i < numDays; ++i) {
    vector<int> t;
    for (int j = 0; j < 3; ++j) {
      int h;
      cin >> h;
      t.push_back(h);
    }
    tasks.push_back(move(t));
  }
  // happiness[i][1] = max(happiness[i - 1][0], happiness[i - 1][2]) + tasks[1]
  vector<vector<int>> happiness;
  // Make it the same dimensions as days.
  happiness.resize(tasks.size());
  for (auto &h : happiness)
    h.resize(3);
  for (int i = 0; i < happiness.size(); ++i) {
    auto &h = happiness[i];
    for (int j = 0; j < h.size(); ++j) {
      int val = 0;
      for (int k = 0; i != 0 && k < h.size(); ++k) {
        // Can't do twice in a row.
        if (j == k)
          continue;
        val = max(val, happiness[i - 1][k]);
      }
      h[j] = val + tasks[i][j];
    }
  }
  cout << max(max(happiness.back()[0], happiness.back()[1]),
              happiness.back()[2])
       << endl;
  return 0;
}


Measured memory_bytes: 11568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> P;

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

	cin >> a >> b >> c;
	if ((a == b && a != c) ||
	    (a == c && a != b) || 
		(b == c && a != b)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input().rstrip())
Hs = list(map(int, input().rstrip().split()))

# print(Hs)

count = 0
ret_count = 0
prev_val = Hs[-1]

for H in Hs[:-1][::-1]:
    # print('prev_val: ' + str(prev_val))
    # print('H: ' + str(H))
    # print('ret_count: ' + str(ret_count))
    if prev_val <= H:
        count += 1
    else:
        if ret_count < count:
            ret_count = count
        count = 0
    prev_val = H

if ret_count < count:
    ret_count = count

print(ret_count)

Measured memory_bytes: 14224
#include <stdio.h>

int main(void) {
   int E,Y,BASE;
   BASE=1867;
   scanf("%d %d",&E,&Y);
   switch(E){
   case 4:BASE+=63;
   case 3:BASE+=14;
   case 2:BASE+=44;
   case 1:printf("%d\n",BASE+Y);
	   return 0;
   }
   if(Y<=1911){printf("M%d\n",Y-BASE);}
   else if(Y<=1925){printf("T%d\n",Y-1911);}
   else if(Y<=1988){printf("S%d\n",Y-1925);}
   else {printf("H%d\n",Y-1988);}
   return 0;
}



Measured memory_bytes: 2104
#include <numeric>
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define int long long
#define inf  1000000007
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
//*//signed main(){
//    int n,s;cin>>n>>s;
//    for(int i=2;i*i<=n;i++){
//        int count=0;
//        int t=n;
//        while(t){
//            count+=t%i;
//            t/=i;
//        }
//        if(count==s){
//            cout<<i<<endl;
//            return 0;
//        }
//    }
//    for(int i=1;i*i<=n;i++){
//        int h=(n-s)/i+1;
//        int count=0;
//        int t=h;
//        while(t){
//            count+=t%h;
//            t/=h;
//        }
//        if(count==s){
//            cout<<h<<endl;
//            return 0;
//        }
//    }
//    cout<<-1<<endl;
//    return 0;
//            }
signed main(){
    int a,b;cin>>a>>b;
    if(a<=8&&b<=8)cout<<"Yay!"<<endl;
    else cout<<":("<<endl;
    return 0;
}

Measured memory_bytes: 256
import collections
import sys
n=int(input())
a=list(map(int,input().split()))
b=collections.Counter(a)
c=list(b.items())

if len(set(a))==len(a):
  for i in range(n):
    print(0)
  sys.exit()
  
cnt=0
for i in range(len(c)):
  if c[i][1]>1:
    cnt+=(c[i][1]*(c[i][1]-1))//2
  else:
    cnt=cnt
for i in range(n):
  d=b[a[i]]
  if d<2:
    print(cnt)
  else:
    print(cnt-(d*(d-1)//2)+((d-1)*(d-2))//2)

Measured memory_bytes: 93768
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    rep(i,n) cin>>h[i];
    sort(etob(h));
    int che=h[0]-h[k-1], ans=che;
    rep(i,(n-k)){
        che-=h[i];
        che+=h[i+1];
        che+=h[k-1+i];
        che-=h[k+i];
        ans=min(ans,che);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
import sys
import os

def file_input():
    f = open('AGC009/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    N=int(input())
    A=[]
    B=[]
    for i in range(N):
        tmp=list(map(int, input().split()))
        A.append(tmp[0])
        B.append(tmp[1])

    cnt=0
    for j in range(N):
        # while (A[N-1-j]+cnt)%B[N-1-j]!=0:
        # cnt+=1
        tmp=A[N-1-j]+cnt
        if not tmp==0:
            # cnt=B[N-1-j]
            if tmp<B[N-1-j]:
                cnt+=B[N-1-j]-tmp
            elif tmp%B[N-1-j]!=0:
                cnt+=B[N-1-j]-tmp%B[N-1-j]

    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 11112
import sys
from bisect import bisect_left

N = int(input())
inf = float("inf")
dp = [inf]*N

for n in map(int, sys.stdin.readlines()):
    dp[bisect_left(dp, n)] = n

for i, num in zip(range(N, 0, -1), dp[::-1]):
    if num < inf:
        print(i)
        break

Measured memory_bytes: 18732
import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		String s [] = S.split("");
		Stack <String> stack = new Stack <>();
		
		for (int i=0; i<S.length(); i++){
			if (s[i].equals("B")){
				if (stack.isEmpty()!=true)
					stack.pop();
			}
			
			else
				stack.push(s[i]);
				
		}
		String ans = "";
		for (int i=0; i<stack.size(); i++){
			ans+=stack.get(i);
		}
		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 21844
n,m=map(int,input().split())
s=[[]]*m
for i in range(m):
  s[i]=list(map(int,input().split()))
  del s[i][0]
p=list(map(int,input().split()))

ans=0
for bit in range(1<<n):
  x=0
  for i in range(m):
    y=0
    for j in s[i]:
      if bit&(1<<(j-1)):
        y+=1
    if y%2==p[i]%2:
      x+=1
  if x==m:
    ans+=1

print(ans)


Measured memory_bytes: 3064
#include <cstdio>

int main()
{
	int prev = 0;
	int curr;
	int sum = 0;

	int n;
	scanf("%d", &n);
	int i;
	for (i = 0; i < n; i++) {
		scanf("%d", &curr);
		if (curr - prev > 0)
			sum += curr - prev;
		prev = curr;
	}
	printf("%d\n", sum);
	return 0;
}

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

typedef long long int ll;
//ll arr[1000000];

int main()
{
	ll a,b,n;
	scanf("%lld %lld %lld",&a,&b,&n);
	ll max=0,ans=0;
/*	for(ll i=b;i>=n-b;i--)
	{
		ans=(a*i)/b - a*(i/b);
		if(max<ans)
			max=ans;
	}
	printf("%lld\n",max);*/
	if(n>=b)
		printf("%lld\n",(a*(b-1))/b);
	else
		printf("%lld\n",(a*n)/b);
}


Measured memory_bytes: 3832
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = 1 << 29;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const int MAX_V = 500;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
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; }




void solve() {
    ll n;
    cin>>n;
    if(n<2){
        cout<<0<<endl;
        return;
    }
    ll sum = 1;
    rep(i,n){
        sum *= 10;
        sum %= MOD;
    }
    ll sum18 = 1;
    rep(i,n){
        sum18 *= 8;
        sum18 %= MOD;
    }
    ll sum9 = 1;
    rep(i,n){
        sum9 *= 9;
        sum9 %= MOD;
    }
    sum += sum18;
    sum %= MOD;
    sum += MOD*2;
    sum -= 2*sum9;
    sum%=MOD;
    cout<<sum<<endl;





}




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


    ll t=1;
    
    // cin>>t;

    rep(i,t){
        solve(); 
    }

    return 0;
}


Measured memory_bytes: 3648
N = int(input())

def powmod(x, y):
    ret = 1
    for _ in range(1, y+1):
        ret = ret * x % (10**9+7)
    return ret
ans = powmod(10, N) - powmod(9, N)*2 + powmod(8, N)
print(ans % (10**9+7))

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

using namespace std;

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
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 long long INF = 1LL << 60;

int n;
long long h[100010];

long long dp[100010];


int main(){

	cin >> n;
	string ans = "Yes";

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

	for(int i = n-2; i >= 0; i--){
		if(h[i+1] >= h[i]){
		}else if(h[i+1] == h[i] - 1){
			h[i] -= 1;
		}else{
			ans = "No";
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

int main(void) {
    string s, t;
    cin >> s >> t;
    cout << t + s << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++)
    cin >> a.at(i);
  reverse(a.begin(),a.end());
  for(int i=0; i<n-1; i++){
    if(a.at(i+1)-a.at(i) > 1){
      cout << "No";
      break;
    }
    else if(a.at(i+1)-a.at(i) == 1)
      a.at(i+1) --;
    if(i == n-2)
      cout << "Yes";
  }
  if(n == 1)
    cout << "Yes";
  
}
    
    

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

int main()
{
  vector<int> a{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k - 1] << endl;
}
  

Measured memory_bytes: 256
import sys
from bisect import *

def main():
	input = sys.stdin.readline

	N = int(input())
	S = input().strip()
	M = 998244353

	ri = []
	gi = []
	bi = []

	for i, c in enumerate(S):
		if c=='R':
			ri.append(i)
		elif c=='G':
			gi.append(i)
		else:
			bi.append(i)

	si = []
	mi = []
	li = []
	for i, tt in enumerate(zip(ri,gi,bi)):
		s, m, l = sorted(tt)
		si.append(s)
		mi.append(m)
		li.append(l)

	ans = 1
	for i, mm in enumerate(mi):
		st = bisect(si,mm)
		lt = bisect(li,mm)
		ans = ans*(st-i)*(i+1-lt)*(i+1)
		ans = ans%M

	print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 58440
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    ll n,m;
    cin>>n>>m;
    cout << abs(n * m - (n + m) * 2 + 4) << endl;





    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    static long[] dist;
    static ArrayList<HashMap<Integer,Long>> root;
    static boolean[] arrived;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        root = new ArrayList<>();
        for(int i = 0; i < n; i++){
            root.add(new HashMap<Integer,Long>());
        }
        for(int i = 0; i < n-1; i++){
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            long c = sc.nextLong();
            root.get(a).put(b,c);
            root.get(b).put(a,c);
        }
        int q = sc.nextInt();
        int k = sc.nextInt()-1;
        arrived = new boolean[n];
        dist = new long[n];
        dfs(k,0L);
        for(int i = 0; i < q; i++){
            System.out.println(dist[sc.nextInt()-1] + dist[sc.nextInt()-1]);
        }
    }
    
    public static void dfs(int now, long d){
        arrived[now] = true;
        dist[now] = d;
        for(Map.Entry<Integer,Long> e : root.get(now).entrySet()){
            int k = e.getKey();
            long v = e.getValue();
            if(!arrived[k]){
                dfs(k,d+v);
            }
        }
        return;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }
    
    public void close() throws Exception{
        this.reader.close();
        return;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

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

int main() {
    int n;cin>>n;
    long long int x,a[n],tmp,ans=0;cin>>x;
    
    for(int i=0;i<n;++i){
        cin>>a[i];
    }

    for(int i=0;i<n-1;++i){
        if(a[i]+a[i+1]>x){
            tmp = (a[i]+a[i+1]) - x;
            ans+=tmp;
            if(a[i+1]>=tmp)a[i+1]-=tmp;
            else {
                a[i]-=(tmp-a[i+1]);
                a[i+1]=0;
            }
        }
    }
    cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1024
N = int(input())
ps = list(map(float, input().split()))

dp = [[0] * (N * 2 + 3) for _ in range(2)]
def pos(i):
    return i + N + 1
dp[0][pos(0)] = 1
for i in range(1, len(ps) + 1):
    d = i % 2
    dm = (i - 1) % 2
    for j in range(-i, i + 1):
        dp[d][pos(j)] = dp[dm][pos(j-1)] * ps[i-1] + dp[dm][pos(j+1)] * (1.0 - ps[i-1])

s = 0
for i in range(1, N+1):
    s += dp[N%2][pos(i)]
print(s)

Measured memory_bytes: 46044
/*
ID: Nipun Paul
LANG: C++
PROB: God knows
*/

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

int main()
{
    ll a,b,c;
    cin>>a>>b;
    c=max(a,b)-min(a,b);
    c=c/2;
    if(abs(max(a,b)-c)==abs(min(a,b)+c))
    {
        cout<<min(a,b)+c<<endl;
    }
    else
    {
        cout<<"IMPOSSIBLE"<<endl;
    }
}



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

int main()
{
    int n,a,b,c,i;
    cin >> n >> a >> b >> c;
    vector<int> l(n);
    for(i = 0;i < n;++i){
        cin >> l.at(i);
    }
    int beki = 1;
    for(i = 0;i < n;++i){
        beki *= 4;
    }
    int bit;
    int ans = abs(l.at(0)-a)+abs(l.at(1)-b)+abs(l.at(2)-c);
    vector<int> bunkai(n);
    int temp;
    for(bit = 0;bit < beki;++bit){
        int anstemp = 0;
        vector<long long> bo(3,0);
        temp = bit;
        for(i = 0;i < n;++i){
            bunkai.at(i) = temp%4;
            temp -= bunkai.at(i);
            temp /= 4;
        }
        for(i = 0;i < n;++i){
            if(bunkai.at(i) == 1){
                if(bo.at(0) != 0){
                    anstemp += 10;
                }
                bo.at(0) += l.at(i);
            }else if(bunkai.at(i) == 2){
                if(bo.at(1) != 0){
                    anstemp += 10;
                }
                bo.at(1) += l.at(i);
            }else if(bunkai.at(i) == 3){
                if(bo.at(2) != 0){
                    anstemp += 10;
                }
                bo.at(2) += l.at(i);
            }else if(bunkai.at(i) == 0){
                continue;
            }
        }
        if(bo.at(0)*bo.at(1)*bo.at(2) == 0){
            continue;
        }else{
            anstemp += abs(bo.at(0)-a)+abs(bo.at(1)-b)+abs(bo.at(2)-c);
        }
        if(anstemp < ans){
            ans = anstemp;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	ll n,d;
	cin >> n >> d;
	ll count = 0;
	rep(i,n){
		ll p,q;
		cin >> p >> q;
		if(d >= sqrt(p*p+q*q)){
			count++;
		}
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3648
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#define ll long long
using namespace std;



int main(){
  ll A,B;
  ll ANS;
  cin>>A>>B;
  if(A<B*2) ANS=0;
  else ANS=A-B*2;
  cout<<ANS<<endl;
  return 0;
}



Measured memory_bytes: 256
A[1000][1000],I[1000],u[999];i,j;d;F=2;main(N){for(scanf("%d",&N);i<N;++i)for(j=0;j<N-1;)scanf("%d",A[j++]+i);for(;F&2;i=N)for(++d,F=1;i--;)u[i]<d&&(j=A[I[i]][i])&&u[F&=2,--j]<d&A[I[j]][j]==i+1&&++I[u[i]=u[j]=d,++I[i],F=2,j];printf("%d",F*d-1);}

Measured memory_bytes: 4096
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main() {
	int N, M;
	cin >> N >> M;
	int a[M], b[M];
	vector<P> p(M);
	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i];
		p[i].first = a[i];
		p[i].second = b[i];
	}
	sort(p.begin(), p.end());
	P now;
	now.second = INT_MIN;
	now.first = INT_MIN;
	int ans = 0;

	for (P pair : p) {
		if (now.second <= pair.first) {
			ans++;
			now.first = pair.first;
			now.second = pair.second;
		}
		else if (now.first<=pair.first&&now.second>=pair.second) {
			now.first = pair.first;
			now.second = pair.second;
		}
		

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


Measured memory_bytes: 1792
function Main(input) {
    var result;
    const A = parseInt(input[0])
    const B = parseInt(input[1])
    const T = parseInt(input[2])

    console.log(Math.floor(T / A) * B);
}

// 1行入力の場合
// Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

// 改行で分割
// Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n/));

// 改行・空白で分割
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

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

void main_()
{
    ll N;
    cin >> N;
    vector<pair<ll, ll>> ABs;
    rep(i, N)
    {
        ll A, B;
        cin >> A >> B;
        ABs.emplace_back(A, B);
    }

    sort(begin(ABs), end(ABs),
        [](auto&& a, auto&& b) {
            return a.first + a.second > b.first + b.second;
        });

    ll takahashi = 0;
    ll aoki = 0;
    rep(i, N)
    {
        if (i % 2 == 0) {
            takahashi += ABs[i].first;
        } else {
            aoki += ABs[i].second;
        }
    }
    cout << takahashi - aoki << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
string s;

int main(){
	while(cin >> s){
		int N = atoi(s.c_str());
		int sum = 0;
		for(int i=0;i<s.size();i++){
			char si = s[i];
			int n = atoi(&si);
			//cout << n << endl;
			sum += n;
		}
		//cout << sum << endl;
		if(N % sum == 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    ll n,k;
    cin>>n>>k;
    vector<int>a(n),memo(n),used(n);
    rep(i,n){
        cin>>a[i];
        a[i]--;
    }
    int cnt=0,now=0;
    int ans=0;
    while(k>0){
        k--;
        
        now=a[now];
        if(k==0){
            ans=now+1;
            break;
        }
        cnt++;
        if(used[now]==0){
            memo[now]=cnt;
            used[now]=1;
            continue;
        }
        k%=(cnt-memo[now]);
        if(k==0)ans=now+1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5636
/* AtCoder Regular Contest 080. Task , by Abreto<m@abreto.net>. */
#include <cstdio>
#include <vector>
#include <utility>
#include <functional>
#include <algorithm>
#include <queue>

using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> pipii;
#define mp(a,b) make_pair(a,b)

#define MAXN    200001

int bp[MAXN];
int p[MAXN];
int ap[MAXN];
struct node_t
{
    int l, r;
    int m[2];
};
node_t nodes[MAXN<<2];
int mymin(int a, int b)
{
    return (p[a]<p[b])?a:b;
}
node_t merge(node_t a, node_t b)
{
    node_t ans;
    ans.l = a.l; ans.r = b.r;
    ans.m[0] = mymin(a.m[0], b.m[0]);
    ans.m[1] = mymin(a.m[1], b.m[1]);
    return ans;
}

int N;
int q[MAXN];
int nq;

void build(int o, int l, int r)
{
    if(0 == r-l)
    {
        nodes[o].l = l; nodes[o].r = r;
        nodes[o].m[l&1] = l; nodes[o].m[1-(l&1)] = -1;
    } else {
        int mid = ((l+r)>>1);
        build(o<<1, l, mid);
        build(o<<1|1, mid+1, r);
        nodes[o] = merge(nodes[o<<1], nodes[o<<1|1]);
    }
}

node_t query(int L, int R, int o, int l, int r)
{
    if(L <= l && r <= R)
        return nodes[o];
    else
    {
        int mid = ((l+r)>>1);
        if(R <= mid) return query(L,R,o<<1,l,mid);
        else if(L > mid) return query(L,R,o<<1|1,mid+1,r);
        else return merge(query(L,R,o<<1,l,mid),query(L,R,o<<1|1,mid+1,r));
    }
}
int qmin(int L, int R, int re)
{
    return query(L, R, 1,1,N).m[re];
}

struct interval
{
    int l, r, re;
    interval(){}
    interval(int ll, int rr, int rree):l(ll),r(rr),re(rree){}
    bool operator>(const interval &b) const
    {
        return p[qmin(l,r,re)] > p[qmin(b.l,b.r,b.re)];
    }
};
typedef interval piin;
void solve()
{
    priority_queue< piin, vector<piin>, greater<piin> > pq;
    pq.push(interval(1,N,1));
    while(!pq.empty())
    {
        interval handle = pq.top();
        int L = handle.l, R = handle.r, re = handle.re;
        pq.pop();
        if(1 == handle.r - handle.l) {
            q[nq++] = p[handle.l];
            q[nq++] = p[handle.r];
        } else {
            int i = 0;
            node_t lm = query(handle.l, handle.r, 1,1,N);
            int fi = lm.m[handle.re];
            node_t rm = query(fi+1, handle.r, 1,1,N);
            int si = rm.m[!handle.re];
            q[nq++] = p[fi]; q[nq++] = p[si];
            int pro[3][3] = {{L,fi-1,re},{fi+1,si-1,!re},{si+1,R,re}};
            for(i = 0;i < 3;++i)
                if(pro[i][1] > pro[i][0])
                    pq.push(interval(pro[i][0],pro[i][1],pro[i][2]));
        }
    }
}

int main(void)
{
    int i = 0;
    p[-1] = MAXN;
    scanf("%d", &N);
    for(i = 1;i <= N;++i)
        scanf("%d", p+i);
    build(1, 1, N);
    solve();
    printf("%d", q[0]);
    for(i = 1;i < N;++i)
        printf(" %d", q[i]);
    puts("");
    return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N;
pii X[200010];
int ans[200010];

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

	cin >> N;
	rep(i, 0, N)
	{
		cin >> X[i].first;
		X[i].second = i;
	}

	sort(X, X + N);

	rep(i, 0, N)
	{
		if (i < N / 2)
		{
			ans[X[i].second] = X[N / 2].first;
		}
		else
		{
			ans[X[i].second] = X[N / 2 - 1].first;
		}
	}

	rep(i, 0, N)
	{
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 6912
a, b, c = list(map(int, input().split()))
m = [a, b, c]
maxvalue = 0
for i in range(len(m)):
    if m[i] > maxvalue:
        maxvalue = m[i]
if a + b + c - maxvalue == maxvalue:
    print("Yes")
else:
    print("No")

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

using ll = long long;
const int INF = 1e9+100;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin>>n;
	vector<int> upVals(n);
	vector<int> downVals(n);
	for (int i = 0; i < n; i++){
		int x, y;
		cin>>x>>y;
		upVals[i] = y-x;
		downVals[i] = y+x;
	}
	sort(upVals.begin(), upVals.end());
	sort(downVals.begin(), downVals.end());
	cout<<max(upVals[n-1]-upVals[0], downVals[n-1]-downVals[0])<<'\n';
	return 0;
}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
#include "unistd.h"
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream&o,const pair<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
template<typename T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
//V<ll>fac,rfac;void setFac(int n,int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

void RE(){cout<<1/0;}
void TLE(){sleep(100);}
void WA(){cout<<char(0);exit(0);}

const int N = 1e5;
int n, m;
V<int> v[N];
priority_queue<int> q;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  FOR(_, 0, n){
    int a, b;
    cin >> a >> b;
    v[a-1].pb(b);
  }
  int ans = 0;
  FOR(i, 0, m){
    for(int a:v[i]) q.push(a);
    if(!q.empty()){
      int a = q.top(); q.pop();
      ans += a;
    }
  }
  cout << ans << endl;
}

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

typedef long long ll;

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

    ll a[n], b[n], c[n], d[n];
    for(int i = 0; i < n; i++)  cin >> a[i];
    for(int i = 0; i < n; i++)  cin >> b[i];
    for(int i = 0; i < n; i++)  cin >> c[i];
    for(int i = 0; i < n; i++)  cin >> d[i];

    vector<ll> x, y;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            x.push_back(a[i]+b[j]);
            y.push_back(c[i]+d[j]);
        }
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    ll cnt = 0;
    for(int i = 0; i < n*n; i++){
        ll res = v - x[i];
        if(res < y[0] || y[n*n-1] < res) continue;

        cnt += (upper_bound(y.begin(), y.end(), res) - lower_bound(y.begin(), y.end(), res));
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 18872