akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	string s;
	int n, k, i, j;
	cin >> n >> s >> k;
	for (i = 0; i < n; i++) {
		if (s[i] != s[k - 1]) s[i] = '*';
	}
	cout << s << "\n";

	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace tst
{
    class Program
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] In = Console.ReadLine().Split(' ');
            List<int> L = new List<int>();
            for(int i=0; i<n; i++)
            {
                int val = int.Parse(In[i]);
                if (val % 2 == 0)
                {
                    //偶数だけListに追加する
                    L.Add(val);
                }
            }
            bool flag = true;
            for(int i=0; i<L.Count; i++)
            {
                if (L[i] % 3 != 0)
                {
                    if (L[i] % 5 != 0)
                    {
                        flag = false;
                        break;
                    }
                }
            }
            if (flag)
            {
                Console.WriteLine("APPROVED");
            }
            else
            {
                Console.WriteLine("DENIED");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <queue>

using namespace std;
#define Fill(a, b) memset(a, b, sizeof(a))
#define Debug(x) cout<<#x<<"="<<(x)<<endl;
typedef pair<int, int> P;
const int inf = 0x1f1f1f1f;
const int max_n = 10010;
struct edge
{
    int from, to, cost, fee;
};
int n, ans;
//vector<int> g fee[max_n];
int d[max_n], pre[max_n];
vector<edge> G[max_n];
void dijkstra(int s);
vector<int> get_path(int t);
int main()
{
    int i = 0, j = 0, k = 0;
    int m, a, b, p, q;
    edge ei;
    while(scanf("%d %d", &n, &m)!=EOF)
    {
        if(n==0&&m==0)
            break;
        ans = 0;
        for(i = 1; i <= n; i++)
            G[i].clear();
        for(i = 0; i < m; i++)
        {
            scanf("%d %d %d %d", &a, &b, &p, &q);
            ei.from = a;
            ei.to = b;
            ei.cost = p;
            ei.fee = q;
            G[a].push_back(ei);
            ei.from = b;
            ei.to = a;
            G[b].push_back(ei);
        }
        dijkstra(1);

        printf("%d\n", ans);
        /*
        for(i = 2; i <= n; i++)
            cout << pre[i] << " ";
        cout << endl;
        */
    }

    return 0;
}
void dijkstra(int s)
{
    int i, j, u, v;
    priority_queue<P, vector<P>, greater<P> > que;
    for(i = 1; i <= n; i++)
    {
        d[i] = inf;
    }
    Fill(pre, -1);
    d[s] = 0;
    que.push(P(0, s));
    while(!que.empty())
    {
        P pa = que.top();
        que.pop();
        v = pa.second;
        if(d[v] < pa.first)
            continue;
        edge es;
        for(i = 0; i < G[v].size(); i++)
        {
            es = G[v][i];
            if(d[es.to] > d[es.from]+es.cost)
            {
                if(d[es.to]!=inf)
                    ans -= pre[es.to];
                d[es.to] = d[es.from]+es.cost;
                ans += es.fee;
                pre[es.to] = es.fee;
                que.push(P(d[es.to], es.to));
            }
            else if((d[es.to]==d[es.from]+es.cost)&&(pre[es.to]>es.fee))
            {
                ans = ans - pre[es.to] + es.fee;
                pre[es.to] = es.fee;
            }
        }
    }
}

Measured memory_bytes: 5636
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    int c;
    cin >> c;
    vector<int> S(n);
    vector<int> T(n);
    vector<int> C(n);
    for (int i = 0; i < n; ++i) {
        cin >> S[i] >> T[i] >> C[i];
    }

    vector<pair<pair<int,int>,int>> P;
    for (int i = 0; i < n; ++i) {
        P.emplace_back(make_pair(S[i], T[i]), C[i]);
    }
    sort(P.begin(), P.end());

    vector<pair<int,int>> que;
    for (auto& p : P) {
        int s = p.first.first, t = p.first.second, x = p.second;

        int best = -1;
        for (int i = 0; i < que.size(); ++i) {
            int y = que[i].first;
            int tt = que[i].second;
            if (y == x) {
                if (tt <= s) {
                    best = max(best, tt);
                }
            } else {
                if (tt < s) {
                    best = max(best, tt);
                }
            }
        }
        if (best == -1) {
            que.emplace_back(x, t);
        } else {
            int idx = -1;
            for (int i = 0; i < que.size(); ++i) {
                int y = que[i].first;
                int tt = que[i].second;
                if (y == x) {
                    if (tt == best) {
                        idx = i;
                        break;
                    }
                } else {
                    if (tt == best) {
                        idx = i;
                    }
                }
            }
            assert(idx >= 0);
            que[idx] = make_pair(x, t);
        }
    }


    int res = que.size();

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 6108
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >>n;
    int q = 0;
    rep(i,n){
        int m;
        cin >> m;
        if(q<m){
            q = m-1;
        }
        else{
            if(q==m){
                continue;
            }
            else{
                cout <<"No";
                return 0;
            }
        }
    }
    cout << "Yes";

    return 0;
}

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

int main() {
  int N, K; cin >> N >> K;
  vector<int> h(N);
  rep(i, N) cin >> h[i];
  
  sort(h.begin(), h.end());
  
  int ans = pow(10, 9);
  rep(i, N-K+1) {
    if(h[i+K-1] - h[i] < ans) ans = h[i+K-1] - h[i];
  }
  cout << ans << endl;
  
  
}

Measured memory_bytes: 640
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

P = read_int()
P.sort()
def solve():
    return P[0] + P[1]

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

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

typedef long long lint;
typedef pair<int, int> pii;

const int INF = 2e9;
const int MOD = 1e9+7;
const int MAX = 1e5+10;
const lint LNF = 2e18;

int n, k, A[MAX], ans;

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

	cin>>n>>k;
	for(int i=1; i<=n; i++) cin>>A[i];

	for(int l=1; l<=n; l++){
		for(int r=l-1; r<=n; r++){
			vector<int> V; int cnt=0, sum=0;
			for(int i=1; i<=n; i++)
				if(i<l || r<i){ V.push_back(A[i]); cnt++; sum+=A[i]; }
			if(cnt>k) continue;
			sort(V.begin(), V.end());
			reverse(V.begin(), V.end());
			while(cnt<k && !V.empty()){
				if(V.back()>=0) break;
				sum-=V.back(); cnt++; V.pop_back();
			}
			ans = max(ans, sum);
		}
	}
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 256
s = list(str(input()))
t = list('AKIHABARA')
s.reverse()
t.reverse()
for i in range(len(t)):
    c = t.pop()
    if s:
        if c == s[-1]:
            s.pop()
        else:
            if c == 'A':
                continue
            else:
                break
    else:
        if c != 'A':
            print('NO')
            exit()
        else:
            continue
if not s:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 61792
#include <bits/stdc++.h>
#define maxn 200005
#define MOD 1000000007
#define INF 10000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

void solve(){

    ll n;
    cin >> n;
    ll a = n/500;
    a *= 1000;
    n = n%500;
    a += (n/5)*5;
    cout << a;

}

int main()
{
    fast();
    int t= 1;
    while(t--){
        solve();
    }
}


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

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


ll int lcm(ll int x, ll int y){
	return (x*y)/gcd(x,y);
}

int main(){
	ll int n,D;
	cin>>n>>D;

	double x,y;
	double d;
	ll int count = 0;
	for(ll int i = 0; i < n; ++i){
		cin>>x>>y;
		d = sqrt(x*x + y*y);
		if(d <= D)
			count++;

	}

	cout<<count;

}

Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
  int N,K;
  cin >> N >> K;

  vector<int>bar(N,0);

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

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

  int ans = 0;
  for(int i=0;i<K;i++){
    ans += bar[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <utility>
#include <queue>
#define large 1001
// #define large 50

using namespace std;

int h,w;
char a[large][large];
int visited[large][large]={};//黒からのユークリッド距離を保有
int vecx[]={1,-1,0,0};
int vecy[]={0,0,1,-1};

queue<pair<int,int>> que;//<x,y>

void bfs(int x,int y)
{
    for(int i=0;i<4;i++)
    {
        if(!(x+vecx[i]<0||x+vecx[i]>=h||y+vecy[i]<0||y+vecy[i]>=w)&&a[x+vecx[i]][y+vecy[i]]=='.')
        {
            a[x+vecx[i]][y+vecy[i]]='#';
            visited[x+vecx[i]][y+vecy[i]]=visited[x][y]+1;
            que.push(make_pair(x+vecx[i],y+vecy[i]));
        }
    }
}

int main()
{
    scanf("%d %d",&h,&w);
    for(int i=0;i<h;i++) scanf("%s",&a[i]);

    for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
    if(a[i][j]=='#')
    {
        que.push(make_pair(i,j));
    }

    while(!que.empty())
    {
        pair<int,int>p;
        p=que.front();
        que.pop();
        // printf("bfs(%d,%d)\n",p.first,p.second);
        bfs(p.first,p.second);
    }
    int max=0;
    for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
    if(max<visited[i][j]) max=visited[i][j];
    printf("%d\n",max);

}

Measured memory_bytes: 11280
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

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

  int count = 0;
  long max = 0;
  long secondMax = 0;

  for (int i = 0; i < N; i++) {
    if (A[i] > max) {
      max = A[i];
      count = 1;
    } else if (A[i] == max) {
      count += 1;
    }
  }

  for (int i = 0; i < N; i++) {
    if (A[i] > secondMax && A[i] != max) {
      secondMax = A[i];
    }
  }

  for (int i = 0; i < N; i++) {
    if (A[i] != max) {
      cout << max << endl;
    } else {
      if (count == 1) {
        cout << secondMax << endl;
      } else {
        cout << max << endl;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
using namespace std;
struct node{
	int x,y;
}a[105],b[105];
int n,maxx,pos,ans;
bool c[105];
bool cmp(node a,node b){
	if(a.x==b.x){
		return a.y<b.y;
	}
	else return a.x<b.x;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i].x,&a[i].y);
	}
	for(int i=1;i<=n;i++){
		scanf("%d%d",&b[i].x,&b[i].y);
	}
	memset(c,true,sizeof(c));
	sort(b+1,b+1+n,cmp);
	for(int i=1;i<=n;i++){
		maxx=-1;
		pos=-1;
		for(int j=1;j<=n;j++){
			if(c[j]&&a[j].x<b[i].x&&a[j].y<b[i].y&&a[j].y>maxx){
				maxx=a[j].y;
				pos=j;
			} 
		}
		if(maxx!=-1){
			ans++;
			c[pos]=false;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
const int N = 1e9+7 ;
const int n = 2e5+7 ;
int a[n],s[n] ;
int t,x,y ;
int main(){
	cin >> t ;
	s[0] = 1 ;
	for(int i=0;i<t;i++){
		cin >> x ;
		if(x==y) continue ;
		s[x] = (s[x]+s[y]) % N ;
		y = x ;
	}
	cout << s[x] << endl ;
}



Measured memory_bytes: 1024
//#include"bits/stdc++.h"
#include<iostream>
#include<ostream>
#include<vector>
#include<string>
#include<algorithm>

#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)



using namespace std;
using ll = long long;



void solve();

int main() {

   solve();
   return 0;

}

void solve() {

	ll n=0, max=0, min=0;

	while (cin >> n >> min >> max, n) {
		vector<ll> v(n+1);
		REP(i, n) {
			cin >> v[i+1];
		}

		ll g = -1e9, ans = 0;

		FOR(i, min , max+1) {
			if (g <= (v[i] - v[i + 1])) {
				g = (v[i] - v[i + 1]);
				ans = i;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=2e5;
int arr[N+2],dp[N+2],pos[N+2],mx,n;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin>>n;
  for(int i=1;i<=n;i++)
    cin>>arr[i];
  memset(dp,0,sizeof(dp));
  for(int i=1;i<=n;i++)
    dp[arr[i]]=dp[arr[i]-1]+1;
  for(int i=1;i<=n;i++)mx=max(mx,dp[i]);
  memset(dp,0,sizeof(dp));
  for(int i=n;i>=1;i--)
    dp[arr[i]]=dp[arr[i]+1]+1;
  for(int i=1;i<=n;i++)mx=max(mx,dp[i]);
  cout<<n-mx<<endl;
  return 0;
}


Measured memory_bytes: 1792
def examA():
    N = I()
    ans = (10000 - N)%1000
    print(ans)
    return

def examB():
    T = ["AC","WA","TLE","RE"]
    N = I()
    S = [SI()for _ in range(N)]

    ans = [0]*4
    for s in S:
        for i in range(4):
            if s==T[i]:
                ans[i] += 1
                break
    for i in range(4):
        print(T[i]+" x "+str(ans[i]))
    return

def examC():
    H, W, K = LI()
    C = [[""]*W for _ in range(H)]
    for h in range(H):
        S = SI()
        for w in range(W):
            C[h][w] = S[w]
    ans = 0
    #print(C)
    for hi in range(1<<H):
        nowC = deepcopy(C)
        for h in range(H):
            if hi&(1<<h):
                for i in range(W):
                    nowC[h][i] = "R"
        for wi in range(1 << W):
            nowCC = deepcopy(nowC)
            for w in range(W):
                if wi & (1 << w):
                    for i in range(H):
                        nowCC[i][w] = "R"
            cnt = 0
            for h in range(H):
                for w in range(W):
                    if nowCC[h][w] == "#":
                        cnt += 1
            if cnt == K:
                #print(hi, wi, nowCC)
                ans += 1
    print(ans)
    return

def examD():
    N = I()
    A = LI()
    A.sort(reverse=True)
    ans = 0
    ans += A[0]
    cur = 0
    for i in range(2,N):
        if i%2==0:
            cur += 1
        ans += A[cur]
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examD()

"""
6
8 7 6 5 4 3
"""

Measured memory_bytes: 101960
import sys
sys.setrecursionlimit(10**7)

n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]

mp = [float('inf')]
def f(i, anum, alen, bnum, blen, cnum, clen):
    if i == n:
        if alen * blen * clen == 0:
            return
        mp[0] = min(mp[0], abs(anum-a)+10*(alen-1) + abs(bnum-b)+10*(blen-1) + abs(cnum-c)+10*(clen-1))
    else:
        f(i+1, anum+l[i], alen+1, bnum, blen, cnum, clen)
        f(i+1, anum, alen, bnum+l[i], blen+1, cnum, clen)
        f(i+1, anum, alen, bnum, blen, cnum+l[i], clen+1)
        f(i+1, anum, alen, bnum, blen, cnum, clen)

f(0, 0, 0, 0, 0, 0, 0)


print(mp[0])

Measured memory_bytes: 3188
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

S = sys.stdin.readline().rstrip()
dp = [False] * (len(S) + 100)
dp[0] = True
words = ['dreamer', 'dream', 'erase', 'eraser']
for i in range(len(S)):
    if dp[i]:
        for w in words:
            dp[i + len(w)] |= S.startswith(w, i)
if dp[len(S)]:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 14332
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  long long int l,h;
  l=1000000001;
  h=1;
  for (int i=0;i<N;i++){
    long long int t;
    cin>>t;
    l=min({t,l});
    h=max({t,h});
  }
  cout<<(h-l)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    string s, t, u;
    ll a, b;
    cin >> s >> t >> a >> b >> u;

    if(s == u)
        a--;
    else
        b--;
    cout << a << ' ' << b;
}


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

using namespace std;

#define ll long long

int main() {
  int n; cin >> n;
  if(n<3) {
    cout << 0 << endl;
    return 0;
  }
  vector<int> l(n);
  for(int i=0; i<n; ++i) {
    cin >> l.at(i);
  }
  int count=0;
  for(int i=0; i<n-2; ++i) {
    int a=l[i];
    for(int j=i+1; j<n-1; ++j) {
      int b=l[j];
      if(a==b) continue;
      for(int k=j+1; k<n; ++k) {
        int c=l[k];
        if(a==c || b==c) continue;
        if(a+b>c && b+c>a && c+a>b) {
          ++count;
        }
      }
    }
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 3620
def ok(l):
    # 長さlの連続部分列で重ならずに2回以上現れるものがある
    D = {}
    for i in range(n-l+1):
        try:
            if D[S[i:i+l]]+l <= i:
                return True
        except:
            D[S[i:i+l]] = i
    return False


n = int(input())
S = input()
# 二分探索でTrueになる最大のkを求める
l, r = 0, n+1
while r-l > 1:
    c = (l+r)//2
    if ok(c):
        l = c
    else:
        r = c
print(l)


Measured memory_bytes: 9508
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

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

    vector<pair<string, ll>> m;

    for (int i = 0; i < n; i++)
    {
        string s;
        ll t;
        cin >> s >> t;

        m.push_back({s, t});
    }

    string x;
    cin >> x;

    bool f = false;

    ll ans = 0;

    for (int i = 0; i < n; i++)
    {
        if (f)
        {
            ans += m[i].second;
        }

        if (m[i].first == x)
        {
            f = true;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  int a,b,c;
  cin >> a;
  cout <<"Christmas";
  for(int i=0;i<25-a;i++){
    cout <<" Eve";
  }
  cout<<endl;
  
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	int n,a,b;
	cin>>n>>a>>b;
	forn(i,a,b)
		if(i%n==0)
		{
			cout<<"OK\n";
			return 0;
		 } 
	cout<<"NG\n";
	return 0;
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d,x;
  double da,db;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> a >> b;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------
  ans = a+b;
  if(ans < a-b) ans = a-b;
  if(ans < a*b) ans = a*b;
  //else anss = "No";

  cout << ans << endl;

}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int side[3];
	int i,j;
	int n,work;
	
	scanf("%d",&n);
	while(n>0){
		n--;
		scanf("%d %d %d",&side[0],&side[1],&side[2]);
		for(i=0;i<2;i++){
			for(j=i+1;j<3;j++){
				if(side[i]<side[j]){
					work=side[i];
					side[i]=side[j];
					side[j]=work;
				}
			}
		}
		side[0]*=side[0];
		side[1]*=side[1];
		side[2]*=side[2];
		if(side[0]==side[1]+side[2])
			printf("YES\n");
		else
			printf("NO\n");
	}
	
	return 0;
}

Measured memory_bytes: 0
n=int(input())
nums=input().split()
n1=nums[::2]
n2=nums[1::2]

if len(nums)%2==0:
    ans=" ".join(n2[::-1])+" "+" ".join(n1)
else:
    ans = " ".join(n1[::-1]) + " " + " ".join(n2)

print(ans)

Measured memory_bytes: 25716
import sys
import numpy as np

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

    @cc.export('is_ok', '(u8[:],u8[:],u8,u8)')
    def is_ok(A, F, x, k):
        tmp = 0
        for a, f in zip(A, F):
            y = a * f
            if y > x:
                tmp += a - x // f
        return tmp <= k

    cc.compile()
    exit(0)

from my_module import is_ok
n, k = map(int, input().split())
A = np.array(list(map(int, input().split())))
F = np.array(list(map(int, input().split())))

A = np.sort(A)
F = np.sort(F)[::-1]

ok = 2 * (10 ** 12)
ng = -1
while ok - ng > 1:
    mid = (ok + ng) // 2
    if is_ok(A, F, mid, k):
        ok = mid
    else:
        ng = mid

print(ok)


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

int main()
{
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    s1[0] = toupper(s1[0]);
    s2[0] = toupper(s2[0]);
    s3[0] = toupper(s3[0]);

    cout << s1[0] << s2[0] << s3[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  int a[5];
  REP(i, 5) { cin >> a[i]; }
  int k;
  cin >> k;
  sort(a, a + 5);
  if (a[4] - a[0] <= k) {
    cout << "Yay!";
  } else {
    cout << ":(";
  }
  return 0;
}

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

#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end());
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct Setup {
    static constexpr int PREC = 20;
    Setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, K;
signed main() {
    cin >> N >> K;
    if (K != 1) { cout << N - K << endl; }
    else { cout << 0 << endl; }
}


Measured memory_bytes: 256
# cited the article at https://qiita.com/shinhiro/items/c652e042828ce26074e4
from heapq import heappush, heappop
def main():
    X, Y, Z, K = map(int, input().split())
    a_cake = [int(x) for x in input().split()]
    b_cake = [int(x) for x in input().split()]
    c_cake = [int(x) for x in input().split()]

    a_cake.sort(reverse = True)
    b_cake.sort(reverse = True)
    c_cake.sort(reverse = True)

    heap_queue = []
    arg_hash = {}
    score_taste = a_cake[0] + b_cake[0] + c_cake[0]
    heappush(heap_queue, (-score_taste, 0, 0, 0))

    for i in range(K):
        score, a_candle, b_candle, c_candle = heappop(heap_queue)
        print(-score)

        arg_a = (a_candle+1, b_candle, c_candle)
        arg_b = (a_candle, b_candle+1, c_candle)
        arg_c = (a_candle, b_candle, c_candle+1)

        if a_candle < X-1 and arg_a not in arg_hash:
            arg_hash[arg_a] = 1
            heappush(heap_queue, (-(a_cake[a_candle+1] + b_cake[b_candle] + c_cake[c_candle]),) + arg_a)
        if b_candle < Y -1 and arg_b not in arg_hash:
            arg_hash[arg_b] = 1
            heappush(heap_queue, (-(a_cake[a_candle] + b_cake[b_candle+1] + c_cake[c_candle]),) + arg_b)
        if c_candle < Z -1 and arg_c not in arg_hash:
            arg_hash[arg_c] = 1
            heappush(heap_queue, (-(a_cake[a_candle] + b_cake[b_candle] + c_cake[c_candle+1]),) + arg_c)

if __name__ == "__main__":
    main()


Measured memory_bytes: 4796
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    vector<int> L(N);rep(i,N)cin >> L[i];

    int ma = 0;
    rep(i,N)chmax(ma,L[i]);

    int sum = 0;
    rep(i,N)sum += L[i];
    sum -= ma;

    if(ma >= sum)cout << "No" << endl;
    else cout << "Yes" << endl;
}


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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;

vector<char> boin = {'a','i','u','e','o'};
vector<char> alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

int N;
string S;

int main(){
    cin >> N >> S;
    vector<bool> num(1000,false);
    vector<vector<int>> cnt(N,vector<int>(10,0));
    vector<vector<int>> fn(N,vector<int>(10,-1));
    vector<int> a(N);
    Rep(i,N){
        a[i] = S[i]-'0';
        
        if(i == 0){
            cnt[i][a[i]] = 1;
            fn[i][a[i]] = 0;
            continue;
        }
        for(int j = 0;j < 10;j++){
            if(j == a[i]){
                cnt[i][j] = cnt[i-1][j] + 1;
                fn[i][j] = i;
            }else{
                cnt[i][j] = cnt[i-1][j];
                fn[i][j] = fn[i-1][j];
            }
        }
    }
    For(i,1,N){
        for(int j = 0;j < 100;j++){
            int x = j;
            int f = x%10;
            x /= 10;
            int s = x%10;
            int fi = fn[i-1][f];
            if(fi >= 1 && fn[fi-1][s] >= 0){
                num[s*100 + f*10 + a[i]] = true;
            }
        }
    }
    int ans = 0;
    Rep(i,1000){
        if(num[i] == true)ans++;
    }
    cout << ans << endl;
    //cin >> N;
}

Measured memory_bytes: 4608
#include<iostream>
using namespace std;
#define size 1000
int main()
{
	int n,i,j;
	float v[size],number;
	double sum;
    cin>>n;
    for(i=0;i<n;i++)
    {
    	cin>>v[i];
    }
    for(i=0;i<n-1;i++)
    {
       j=i+1;
       number = v[j];
       while(number<v[j-1] && j>0)
       {
       	 v[j] = v[j-1];
       	 j--;
       }
       v[j]=number;
    }
    sum = v[0];
    for(i=1;i<n;i++)
    {
    	sum=(sum+v[i])/2.0;
    }
    cout<<sum;

}

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

int main () {
  int N, K, count = 0;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    if (tmp >= K) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{


    class Program
    {


        static void Main(string[] args)
        {

            string[] str = Console.ReadLine().Split(' ');
            int D = int.Parse(str[0]);
            int K = int.Parse(str[1]);

            string ans = "";           

            for(int i = 1; i <= D; i++)
            {
                ans += "00";
            }

            if (K == 100) K++;

            Console.WriteLine($"{K}" + ans);
            

        }
    }
}

Measured memory_bytes: 13140
w,h,n=map(int,input().split())
x=int(0)
y=int(0)
sx=int(w)
sy=int(h)
for i in range(n):
    X,Y,a=map(int,input().split())
    if a==1:
        if x<X:
            x=X
    elif a==2:
        if X<sx:
            sx=X
    elif a==3:
        if y<Y:
            y=Y
    else:
        if Y<sy:
            sy=Y

if sx<x or sy<y:
    print(0)

else:
    print((sx-x)*(sy-y))

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

/* macros */
#define inf 1e9
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define vi vector<int>
#define vc vector<char>
#define vb vector<bool>
#define vt vector
#define pb push_back
#define fi first
#define se second
#define pi pair<int,int>
#define tc int t;cin>>t;while (t--){solve();}
#define gtc int t;cin>>t;int TC=1;while (t--) {cout << "Case #" << TC << ": " << solve() << "\n";TC++;}
#define gvtc int t;cin>>t;int TC=1;while (t--) {cout << "Case #" << TC << ": "; vsolve(); TC++;}
#define notc solve();
#define newline cout << "\n";
#define mod 1000000007
#define ret return 0;
#define sz(x) (int)x.size();
#define rep(i,a,b) for(int i=a;i<b;i++)
#define srt(x) sort(x.begin(), x.end())
#define rsrt(x) sort(x.rbegin(), x.rend())

void solve() {
    string s;
    cin>>s;
    int n = s.size();
    if (s[n-1] == 's') {
        s += "es";
    }else {
        s += "s";
    }
    cout << s << "\n";
}

int32_t main(){
    fastio
    notc
    ret
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  int t,a;
  cin>>n>>t>>a;
  VEC<int>h(n);
  REP(i,0,n)cin>>h[i];
  VEC<double>diff(n);
  REP(i,0,n){
    diff[i]=abs(a-(t-0.006*h[i]));
  }
  int mii= 0;
  double mi = 500000;
  //DUMP(diff);
  REP(i,0,n){
    if(diff[i]<mi){
      mi=diff[i];
      mii=i;
    }
  }
  cout<<mii+1<<endl;

  

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int h,w;
  char s;
  s ='#';
  // while (1)
  // {
  //   scanf("%d",&h);
  //   scanf("%d",&w);
  //   if(w == 0 && h == 0 )break;
  //   for (int i = 0; i < h; i++)
  //   {
  //     for (int j = 0; j < w; j++)
  //     {
  //       printf("#");
  //     }
  //     printf("\n");
  //   }
  //   printf("\n");
  // }
  ///////////////////////////////////////////////////////////
    while (1)
  {
    scanf("%d",&h);
    scanf("%d",&w);
    if(w == 0 && h == 0 )break;
    for (int i = 0; i < h; i++)
    {
      for (int j = 0; j < w; j++)
      {
        if(j == 0 || j == w-1 || i == 0 || i == h-1 ) s = '#';
        else
        {
          s = '.';
        }
        
        printf("%c",s);
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <math.h>
#include <string>
#include <iomanip>
#include <locale>
#include <list>
#include <bitset>
using namespace std;
#define FORN(i,m,n) for(ll i=(m); i<ll(n); i++)
#define PRINTVEC(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PRINTMAT(m) FORN(j,0,m.size()) {PRINTVEC(m[j]);}
#define PB(x) push_back(x)
#define MP(a,b) make_pair(a,b)
typedef long long ll;

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int n; cin>>n;
  vector<int> a(n), b(n);
  FORN(i,0,n) cin>>a[i];
  FORN(i,0,n) cin>>b[i];
  int x = 0, y = 0;
  while(next_permutation(a.begin(),a.end())) x++;
  while(next_permutation(b.begin(),b.end())) y++;
  cout<<max(x,y) - min(x,y)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
int n , a[N] , b[N] , w;
long long dp[101][N] , k;
long long int calc(int i , int val){
    if(val < 0)
        return -2e12;
    if(i == n)
        return 0;
    long long int &ret = dp[i][val];
    if(ret != -1)
        return ret;
    return ret = max(calc(i + 1, val) , 1LL * calc(i + 1 , val - a[i]) + b[i]);
}
int main(){
    scanf("%d%d", &n , &w);
    for(int i = 0 ; i < n ; i++){
        scanf("%d%d", &a[i] , &b[i]);
    }
    memset(dp , -1 , sizeof dp);
    cout<<calc(0 , w);
    return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;


    ll ans = (a-c)*(b-d);
    
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int a,b,c;
    cin>>a>>b>>c;
    if(a==7&&b==5&&c==5||a==5&&b==5&&c==7||a==5&&b==7&&c==5){
        cout<<"YES";
    }else{
        cout<<"NO";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

int cnt[10][10];

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

    int n;
    cin >> n;

    rep (i, n + 1)
    {
        int u = i;
        while (u >= 10) u /= 10;
        ++cnt[u][i % 10];
    }

    int ans = 0;
    for (int i = 1; i < 10; ++i)
    {
        for (int j = 1; j < 10; ++j)
        {
            ans += cnt[i][j] * cnt[j][i];
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3616
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define MOD(x) ((x) >= mod ? (x) - mod : (x))
#define ll long long
using namespace std;
const int maxn = 4010, inf = 1e9 + 233, mod = 998244353;
int n, ans;
char s[maxn];
int f[maxn][maxn], sumr[maxn], sumb[maxn];

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

int main()
{
	scanf("%s", s + 1); n = strlen(s + 1);
	for (int i = 1; i <= n; i++)
	{
		sumr[i] = sumr[i - 1];
		sumb[i] = sumb[i - 1];

		if (s[i] == '0') sumr[i] += 2;
		else if (s[i] == '1') sumr[i]++, sumb[i]++;
		else sumb[i] += 2;
	}
	for (int i = n + 1; i <= n * 2; i++) sumr[i] = sumr[i - 1], sumb[i] = sumb[i - 1];

	f[0][0] = 1; ans = 0;
	for (int i = 1; i <= n * 2; i++)
	{
		for (int j = 0; j <= i; j++)
		{
			if (sumr[i] - j >= 0 && j) f[j][i - j] = MOD(f[j][i - j] + f[j - 1][i - j]);
			if (sumb[i] - (i - j) >= 0 && i - j) f[j][i - j] = MOD(f[j][i - j] + f[j][i - j - 1]);
			// printf("f[%d][%d]:%d %d %d %d %d\n", j, i - j, f[j][i - j], sumr[i], sumb[i], f[j - 1][i - j], f[j][i - j - 1]);

			if (i == 2 * n) ans = MOD(ans + f[j][i - j]);
		}
	}

	printf("%d\n", ans);
}

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


int main(){
    int n;
    cin >> n;
    int a=0,b=0,c=0,d=0;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        if(s=="AC"){
            a++;
        }else if(s=="WA"){
            b++;
        }else if(s=="TLE"){
            c++;
        }else{
            d++;
        }
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
}

Measured memory_bytes: 3596
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	private static Scanner sc;
	public static void main(String[] args) {
		sc = new Scanner (System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		ArrayList<Integer> input = new ArrayList<Integer>();
		for(int i=0; i<n; i++) {
			input.add(sc.nextInt());
		}
		ArrayList<Integer> sorted = quicksort(input);
		int maxlength = 0;
		for(int j=sorted.size()-1; j>sorted.size()-k-1; j--) {
			maxlength = maxlength + sorted.get(j);
		}
		System.out.println(maxlength);
	}
	
	static ArrayList<Integer> quicksort (ArrayList<Integer> l) {
		ArrayList<Integer> leftsort = new ArrayList<Integer>();
		ArrayList<Integer> rightsort = new ArrayList<Integer>();
		ArrayList<Integer> sorted = new ArrayList<Integer>();
		int pivot = l.get(0);
		if(l.size()==1) return l;
		else {
			for(int i=1; i<l.size(); i++) {
				if(pivot<l.get(i)) rightsort.add(l.get(i));
				else leftsort.add(l.get(i));
			}
			if(leftsort.size()==0) {
				ArrayList<Integer> rightsorted = quicksort(rightsort);
				sorted.add(pivot);
				for(int i=0; i<rightsorted.size(); i++) {
					sorted.add(rightsorted.get(i));
				}
			}else if(rightsort.size()==0) {
				sorted = quicksort(leftsort);
                sorted.add(pivot);
			}else {
				sorted = quicksort(leftsort);
				ArrayList<Integer> rightsorted = quicksort(rightsort);
				sorted.add(pivot);
				for(int i=0; i<rightsorted.size(); i++) {
					sorted.add(rightsorted.get(i));
				}
			}
			return sorted;
		}
	}
}

Measured memory_bytes: 23380