akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace ABC123D
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Console.SetIn(new StreamReader(args[0]));
            }

            new Program().Solve();
        }

        void Solve()
        {
            var temp = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var X = temp[0];
            var Y = temp[1];
            var Z = temp[2];
            var K = temp[3];
            var A = Console.ReadLine().Split(' ').Select(long.Parse).OrderByDescending(a => a).ToArray();
            var B = Console.ReadLine().Split(' ').Select(long.Parse).OrderByDescending(b => b).ToArray();
            var C = Console.ReadLine().Split(' ').Select(long.Parse).OrderByDescending(c => c).ToArray();
            var ansList = new List<long>();

            for (int iA = 0; iA < X; iA++)
            {
                for (int iB = 0; iB < Y; iB++)
                {
                    for (int iC = 0; iC < Z; iC++)
                    {
                        if ((iA + 1) * (iB + 1) * (iC + 1) <= K)
                        {
                            ansList.Add(A[iA] + B[iB] + C[iC]);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }

            var count = 0;

            foreach (long ans in ansList.OrderByDescending(v => v))
            {
                Console.WriteLine(ans);
                
                if (++count == K)
                {
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 17760
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {

	char S[100];
	int A, B;
	scanf("%d%d", &A, &B);
	scanf("%s", S);

	bool ans = true;

	for (int i = 0; i < strlen(S); i++) {
		if (S[i] == '-' && i != A) {
			ans = false;
			break;
		}
		else if (S[i] != '-' && i == A) {
			ans = false;
			break;
		}

	}

	if (ans) {
		printf("Yes");
	}
	else {
		printf("No");
	}









}

Measured memory_bytes: 128
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>

using std::cerr;
using std::cin;
using std::cout;

using std::abs;
using std::min;
using std::max;
using std::swap;

using std::map;
using std::pair;
using std::set;
using std::string;
using std::vector;

using ll = long long;
using uint = unsigned int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ff first
#define ss second
#define pb emplace_back
template<typename T> 
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h <<"\n"; 
}
template<typename T, typename... Ts>
void _dbg(const char* _s, T _h, Ts... _t) {
    int _b = 0;
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++; 
    cerr << " = " << _h << ","; 
    _dbg(_s+1, _t...);
}
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...) 
#endif

struct init {
    init() {
        cin.tie(0);
        std::iostream::sync_with_stdio(0);
        cout << std::fixed << std::setprecision(10);
        cerr << std::fixed << std::setprecision(5);
    }
    ~init() {
        #ifdef LOCAL
        cerr << "Time elapsed: " << (double)clock() / CLOCKS_PER_SEC << "s.\n";
        #endif
    }
} init;

const int MAXN = 2e5 + 25;
int a[MAXN], b[MAXN], v[MAXN];

int main() {
    
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    for (int i = 1; i <= n; ++i) {
        cin >> b[i];
    }

    int ans = 0;

    for (int bit = 28; bit >= 0; --bit) {
        dbg(bit);
        int pw = 1 << bit;
        ll cnt = 0;
        for (int i = 1; i <= n; ++i)
            v[i] = b[i] % (pw + pw);
        std::sort(v + 1, v + n + 1);
        for (int i = 1; i <= n; ++i)
            dbg(v[i]);
        for (int i = 1; i <= n; ++i) {
            dbg(a[i]);
            auto p1 = std::lower_bound(v + 1, v + n + 1, 1 * pw - a[i] % (pw + pw));
            auto p2 = std::prev(std::lower_bound(v + 1, v + n + 1, 2 * pw - a[i] % (pw + pw)));
            auto p3 = std::lower_bound(v + 1, v + n + 1, 3 * pw - a[i] % (pw + pw));
            auto p4 = std::prev(std::lower_bound(v + 1, v + n + 1, 4 * pw - a[i] % (pw + pw)));
            dbg(p1 - v);
            dbg(p2 - v);
            dbg(p3 - v);
            dbg(p4 - v);
            cnt += p2 - p1 + 1;
            cnt += p4 - p3 + 1;
        }
        if (cnt & 1) {
            dbg("OOOOOOOOOOOOOOOOOOOOOOOOO", pw);
            ans |= pw;
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 2560
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/input.txt"
exit $?
'''
import sys


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    a, b, c, d = _ia()
    while True:
        c -= b
        if c <= 0:
            return "Yes"
        a -= d
        if a <= 0:
            return "No"


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


Measured memory_bytes: 61680
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
ll x;
int main()
{scanf("%lld",&x);
int sum=0;
    for(int i=1;;i++)
       {sum+=i;
           if(sum>=x)
       {
           printf("%d\n",i);
          break;
       }
}
return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
 
class D
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var AList = (Console.ReadLine()).Split(' ').Select(s => long.Parse(s)).ToArray();
        var now = 1000L;
        var kabu = 0L;
        for (var i = 0; i < N - 1; i++)
        {
            if (AList[i + 1] < AList[i])
            {
                now += kabu * AList[i];
                kabu = 0;
            }
            else if (AList[i + 1] > AList[i])
            {
                var nekabu = now / AList[i];
                now -= nekabu * AList[i];
                kabu += nekabu;
            }
        }
        if (kabu != 0)
        {
            now += kabu * AList.Last();
        }
        Console.WriteLine(now);
    }
}

Measured memory_bytes: 28232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> g(n+1);
    for(int i=1;i<=n;i++){
        int p;cin >> p;
        g[p]=i;
    }
    multiset<int> ms;
    ms.insert(0);
    ms.insert(0);
    ms.insert(n+1);
    ms.insert(n+1);
    ll ans=0;
    for(ll i=n;i>=1;i--){
        ll l1,l2,r1,r2;
        auto itr=ms.lower_bound(g[i]);
        r1=*itr++;
        r2=*itr--;
        itr--;
        l2=*itr--;
        l1=*itr--;
        ans+=(g[i]-l2)*(r2-r1)*i;
        ans+=(l2-l1)*(r1-g[i])*i;
        ms.insert(g[i]);
    }
    cout << ans << endl;
}

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

#ifdef __WIN32
#define LLFORMAT "I64"
#else
#define LLFORMAT "ll"
#endif

using namespace std;

const int maxn = 550;

int n, m, a[maxn][maxn], s[maxn][maxn];
short fl[maxn][maxn][maxn], fr[maxn][maxn][maxn];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		static char str[maxn];
		scanf("%s", str + 1);
		for (int j = 1; j <= n; ++j) {
			a[i][j] = (str[j] == '#' ? 0 : str[j] - '0'), s[i][j] = s[i][j - 1] + a[i][j];
			for (int k = 1; k <= n; ++k) fl[i][j][k] = n, fr[i][j][k] = 0;
		}
	}
	long long ans = 0;
	for (int i = n; i; --i) for (int j = n; j; --j) if(a[i][j]) {
		fl[i][j][i] = fr[i][j][i] = j;
		if(a[i + 1][j]) for (int k = i + 1; k <= n; ++k) fl[i][j][k] = min(fl[i][j][k], fl[i + 1][j][k]), fr[i][j][k] = max(fr[i][j][k], fr[i + 1][j][k]);
		if(a[i][j + 1]) for (int k = i; k <= n; ++k) fl[i][j][k] = min(fl[i][j][k], fl[i][j + 1][k]), fr[i][j][k] = max(fr[i][j][k], fr[i][j + 1][k]);
		int sum = 0;
		for (int k = i; k <= n; ++k) {
			if(fl[i][j][k] > fr[i][j][k]) break;
			sum += s[k][fr[i][j][k]] - s[k][fl[i][j][k] - 1];
		}
		ans += (long long) a[i][j] * (sum - a[i][j]);

		function<void(int, int)> del = [&](int x, int y) {
			if(!a[x][y]) return;
			if(!a[x][y - 1] && !a[x - 1][y]) {
				for (int i = y; i <= n; ++i) s[x][i] -= a[x][y];
				a[x][y] = 0;
				del(x, y + 1);
				del(x + 1, y);
			}
			return;
		};
		del(i, j);
	}
	printf("%"LLFORMAT"d\n", ans);
	return 0;
}

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

int main() {
  
  int N;
  cin >> N;
  
  vector<int> H(N);
  
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  
  for (int i = N - 2; i >= 0; i--) {
    
    if (H[i] > H[i + 1] + 1) {
      cout << "No" << endl;
      return 0;
    }
    
    if (H[i] == H[i + 1] + 1) H[i]--;
  }
  
  cout << "Yes" << endl;
  return 0;
  
}

Measured memory_bytes: 640
from bisect import bisect
M = 10**7+1
p = [1]*M
p[0] = p[1] = 0
for i in range(2, int(M**.5)+1):
    if p[i]:
        p[i*i:M:i] = (0 for i in range(i*i, M, i))
B = [13]
for x in range(19, M, 10):
    if p[x-8] and p[x-6] and p[x-2] and p[x]:
        B.append(x)

while 1:
    N = int(input())
    if N == 0:
        break
    print(B[bisect(B, N)-1])



Measured memory_bytes: 163364
import qualified Data.ByteString.Char8 as B
import qualified Data.Array.IArray as A
import Control.Arrow
import Data.List

main = do
  n <- readLn
  as <- map (maybe undefined fst . B.readInteger) . B.words <$> B.getLine
  print (agc n as)

agc n =  sum . take n . unfoldr (return . (head &&& drop 2)) . drop n . sort

Measured memory_bytes: 51580
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"-----------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

#define MAX 10005

int n;
signed main(){
  while(cin>>n&&n){
    int a[MAX];
    for(int i=0; i<n; i++) cin>>a[i];
    int minl=INF;
    
    for(int i=0; i<n; i++){
      int moto=a[i];
      for(int j=1; j<=3; j++){
        a[i]=j;
        int left=i,right=i+1;
        int search=j;
        int cnt=n;
        while(1){
          search=a[left];
          int c=0;
          while(left>=0&&search==a[left]){
            left--;
            c++;
          }
          while(right<n&&search==a[right]){
            right++;
            c++;
          }
          if(c<4) break;
          else cnt-=c;
        }
        minl=min(minl,cnt);
      }
      a[i]=moto;
    }
    
    cout<<minl<<en;
  }
}



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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	auto V=vecin<ll>(N);

	out(*min_element(ALL(V)),*max_element(ALL(V)),accumulate(ALL(V),0LL));
	return 0;
}



Measured memory_bytes: 3192
def gen_range(N, Y, reverse=False):
    for i in range(N, 0 - 1, -1):
        for j in range(N - i + 1):
            if reverse:
                yield (j, i, N - i - j)
            else:
                yield (i, j, N - j - i)


def calc(N, Y):
    if 10000 * N < Y or Y < 1000 * N:
        return [-1, -1, -1]
    if Y % 10000 == 0 and Y // 10000 == N:
        return (Y // 10000, 0, 0)
    if Y % 5000 == 0 and Y // 5000 == N:
        return (0, Y // 5000, 0)
    if Y % 1000 == 0 and Y // 1000 == N:
        return (0, 0, Y // 1000)
    if (Y - 1000 * N) % 4000 == 0:
        k5 = (Y - 1000 * N) // 4000
        if k5 >= 0 and N - k5 >= 0:
            return [0, k5, N - k5]
    elif (Y - 1000 * N) % 9000 == 0:
        k10 = (Y - 1000 * N) // 9000
        if k10 >= 0 and N - k10 >= 0:
            return [k10, 0, N - k10]
    if 5000 * N < Y:
        for k10, k1, k5 in gen_range(N, Y, reverse=True):
            if k10 * 10000 + k1 * 1000 + k5 * 5000 == Y:
                return (k10, k5, k1)
    else:
        for k10, k1, k5 in gen_range(N, Y):
            if k10 * 10000 + k1 * 1000 + k5 * 5000 == Y:
                return (k10, k5, k1)

    #
    # for k1 in range(N, 0 - 1, -1):
    #     for k10 in range(N - k1 + 1):
    #         if k1 * 1000 + k10 * 10000 > Y:
    #             break
    #         for k5 in range(N - k1 - k10 + 1):
    #             print(k10, k5, k1)
    #             if k1 * 1000 + k5 * 5000 + k10 * 10000 == Y:
    #                 return [k10, k5, k1]
    return (-1, -1, -1)


def main():
    N, Y = list(map(int, input().split()))
    print(*calc(N, Y))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>

#define MAX_N (200010)
#define HALF_MAX_N ( MAX_N / 2 )
#define INF (1e9 + 10)
typedef long long int ll;
int A[MAX_N];
int C[MAX_N];
int L[HALF_MAX_N];
int R[HALF_MAX_N];

void mergeSort( int A[], int left, int right );
void merge( int A[], int left, int mid, int right );

int main()
{
    int n;
    ll ans = 0;

    scanf("%d", &n);

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

    for ( int i = 0; i < n; i++ ) {
	ans += C[i];
    }

    printf("%lld\n", ans);

    return 0;
}


void mergeSort( int A[], int left, int right )
{
    if ( right - left > 1 ) {
	int mid = ( left + right ) >> 1;
	mergeSort( A, left, mid );
	mergeSort( A, mid, right );
	merge( A, left, mid, right );
    }
}

void merge( int A[], int left, int mid, int right )
{
    int i = 0;
    int j = 0;

    for ( int k = left; k < mid; k++ ) {
	L[i] = A[k];
	i++;
    }
    for ( int k = mid; k < right; k++ ) {
	R[j] = A[k];
	j++;
    }
    
    L[i] = R[j] = INF;
    
    i = j = 0;

    for ( int k = left; k < right; k++ ) {
	if ( L[i] <= R[j] ) {
	    A[k] = L[i];
	    i++;
	}
	else {
	    A[k] = R[j];
	    C[k] += ( (mid - left) - i );
	    j++;
	}
    } 
}

Measured memory_bytes: 3368
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 double long double
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 

int n,m,k,arr[N];

void solve()
{
    string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2];
}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        solve();
        nl;
    }



    return 0;

}

//       clang++ c.cpp ; ./a.out < a.txt ;  

Measured memory_bytes: 3652
n, m = map(int, input().split())

a = []
b = []
c = []
d = []
for i in range(n):
    ax, by = map(int, input().split())
    a.append(ax)
    b.append(by)
for i in range(m):
    cx, dy = map(int, input().split())
    c.append(cx)
    d.append(dy)

for i in range(n):
    min_dis = float('inf')
    ans = 0
    for j in range(m):
        if min_dis > abs(a[i]-c[j])+abs(b[i]-d[j]):
            min_dis = abs(a[i]-c[j])+abs(b[i]-d[j])
            ans = j+1
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n;cin>>n;
  int ans=800*n-(200*(n/15));
  cout(ans);
  
  return 0;
}

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

using ll = long long;

const int N = 100005;

int n, l[N], r[N], cc;
char b[N];
ll d, a;

void f(int x, ll d){
    if(!!l[x] ^ !!r[x]) a ^= (d & -d);
    if(l[x]) f(l[x], d - 1);
    if(r[x]) f(r[x], d - 1);
}

int main(){
    scanf("%d%lld", &n, &d);
    for(; n--; ){
        scanf("%s", b);
        int c = 0;
        for(int i = 0; b[i]; i++){
            int &nx = (b[i] == '0') ? l[c] : r[c];
            if(!nx) nx = ++cc;
            c = nx;
        }
    }
    f(0, d);
    puts(a ? "Alice" : "Bob");
}

Measured memory_bytes: 2688
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 998244353;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

bool flag;
bool solve(ll mid, ll A, ll B){
    if(mid*(mid+1) < A * B){
        flag = true;
        return true;
    }
    else if(mid*mid < A * B){
        flag = false;
        return true;
    }
    else return false;
}

int main(){
    int Q;
    cin >> Q;
    vector<ll> ans(Q);
    rep(i,Q){
        ll A, B;
        cin >> A >> B;
        ll left = 0;
        ll right = 1000000000;
        while(right - left > 1){
            ll mid = (right + left) / 2;
            if(solve(mid,A,B)) left = mid;
            else right = mid;
        }
        if(flag) ans[i] =  2 * left -1;
        else ans[i] = 2 * left - 2;
        if(A == B) ans[i]++;
        if(ans[i] < 0) ans[i] = 0;
    }
    for(auto a:ans) cout << a << endl;
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define all(c) (c).begin(), (c).end()
const int INF = 1e9 + 1;
const ll LINF = 1e18 + 1;
const ll MOD = 1e9 + 7;

bool check(ll mid, vector<int>& a, ll k) {
  ll n = a.size();
  ll cnt = 0;
  for (int i = 0; i < n; ++i) {
    ll v = a[i], t;
    if (v > 0) {
      t = mid > 0 ? mid / v : (mid < 0 ? (mid + 1) / v - 1 : 0);
      auto it = upper_bound(all(a), t);
      int c = n - distance(it, a.end());
      if (distance(a.begin(), it) - 1 >= i) --c;
      cnt += max(c, 0);
    } else if (v < 0) {
      t = mid > 0 ? mid / v : (mid < 0 ? (mid + 1) / v + 1 : 0);
      auto it = lower_bound(all(a), t);
      int c = distance(it, a.end());
      if (distance(a.begin(), it) <= i) --c;
      cnt += max(c, 0);
    } else {
      if (mid >= 0) {
        cnt += n - 1;
      }
    }
    // dump(v, mid, t, cnt);
  }
  cnt /= 2;
  // dump(mid, cnt);
  return cnt >= k;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(all(a));
  ll ok = LINF, ng = -LINF;
  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if (check(mid, a, k)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  cout << ok << endl;
  return 0;
}


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

int main(){
  int N, M;
  cin>> N >> M;
  vector<int> X(N+1), Y(M+1);
  cin >> X[0] >> Y[0];
  for (int i=1; i<N+1; i++) cin >> X[i];
  for (int i=1; i<M+1; i++) cin >> Y[i];
  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());
  if (X[N] < Y[0]) cout << "No War" << endl;
  else cout << "War" << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
void swap(int *a, int *b) {
    int temp = *a;
    *a = *b;
    *b = temp;
}

int swapCount = 0;

void b_sort(int *array, int n) {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n - i - 1; j++) {
            if (array[j + 1] < array[j]) {
                swapCount++;
                swap(array[j + 1], array[j]);
            }
        }
    }
}

int main(int argc, const char * argv[]) {
    // insert code here...
    int array[100] = {0};
    
    int n = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> array[i];
    }
    
    b_sort(array, n);
    for (int i = 0; i < n; i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << array[i];
    }
    cout << endl << swapCount << endl;
    
    
    return 0;
}



Measured memory_bytes: 3108
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var x = new int[N];
            var y = new int[N];
            var h = new int[N];
            for (int i = 0; i < N; i++)
            {
                var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                x[i] = input[0];
                y[i] = input[1];
                h[i] = input[2];
            }
            var t = 0;
            for (int i = 0; i < N; i++)
            {
                if (h[i] > 0)
                {
                    t = i;
                    break;
                }
            }

            for (int cx = 0; cx <= 100; cx++)
            {
                for (int cy = 0; cy <= 100; cy++)
                {
                    var H = h[t] + Math.Abs(x[t] - cx) + Math.Abs(y[t] - cy);
                    var suc = true;
                    for (int i = 0; i < N; i++)
                    {
                        var tmp = h[i] + Math.Abs(x[i] - cx) + Math.Abs(y[i] - cy);
                        if (H - Math.Abs(x[i] - cx) - Math.Abs(y[i] - cy) < 0)
                        {
                            if (h[i] != 0)
                            {
                                suc = false;
                                break;
                            }
                        } else if (tmp != H)
                        {
                            suc = false;
                            break;
                        }
                    }
                    if (suc)
                    {
                        Console.WriteLine(cx + " " + cy + " " + H);
                        return;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 13396
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Vector.Unboxed.Mutable (IOVector, STVector)
import qualified Data.Vector.Unboxed.Mutable as VM
import Data.Set (Set)
import qualified Data.Set as S

main :: IO ()
main = do
  n <- readLn
  replicateM_ n $ do
    [gx, gy] <- f
    m <- readLn
    solve (gx, gy) <$> (S.fromList <$> replicateM m (g <$> f)) >>= putStrLn
  where
    -- f = readi B.readInt <$> B.getLine
    f = map read <$> words <$> getLine
    g [x1, y1, x2, y2] = if x1 > x2 || y1 > y2 then (x2, y2, x1, y1) else (x1, y1, x2, y2)

solve :: (Int, Int) -> Set (Int, Int, Int, Int) -> String
solve (gx, gy) st = let cnt = runST $ do
                          v <- VM.replicate ((gx + 1) * (gy + 1)) 0 :: ST s (STVector s Int)
                          forM_ [0 .. gy] $ \j -> do
                            forM_ [0 .. gx] $ \i -> do
                              ctd <- if S.notMember (i, j-1, i, j) st && j >= 1
                                        then VM.read v (toIdx (i, j-1))
                                        else return 0
                              ctl <- if S.notMember (i-1, j, i, j) st && i >= 1
                                        then VM.read v (toIdx (i-1, j))
                                        else return 0
                              VM.write v (toIdx (i, j)) (if i == 0 && j == 0 then 1 else ctd + ctl)
                          VM.read v (toIdx (gx, gy))
                    in if cnt > 0 then show cnt else "Miserable Hokusai!"
  where
    toIdx (i, j) = (gx + 1) * j + i



Measured memory_bytes: 5484
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long ll;

const int N=1e5+5,Mo=1e9+7;

int pwr(int x,int y) {
	int z=1;
	for(;y;y>>=1,x=(ll)x*x%Mo)
		if (y&1) z=(ll)z*x%Mo;
	return z;
}

int n,k,a[N],tot,ans,f[N];

int main() {
	scanf("%d%d",&n,&k);
	int m=sqrt(n);
	fo(i,1,m) 
		if (!(n%i)) {
			a[++tot]=i;
			if (i*i!=n) a[++tot]=n/i;
		}
	sort(a+1,a+tot+1);
	int inv=pwr(2,Mo-2);
	fo(i,1,tot) {
		f[i]=pwr(k,(a[i]+1)/2);
		fo(j,1,i-1) if (!(a[i]%a[j])) (f[i]+=Mo-f[j])%=Mo;
		if (a[i]&1) (ans+=(ll)f[i]*a[i]%Mo)%=Mo;
		else (ans+=(ll)f[i]*a[i]%Mo*inv%Mo)%=Mo;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100 + 5;

int n, a[maxn];

int main() {	
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    int ans = 0;
    sort(a + 1, a + n + 1);
    for(int i = 1; i <= n; ++i)
        for(int j = i + 1; j <= n; ++j)
            for(int k = j + 1; k <= n; ++k) {
                if(a[i] == a[j] || a[j] == a[k]) continue;
                ans += (a[i] + a[j] > a[k]);
            }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3652
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        
        int n = scan.nextInt();
        int[] arr = new int[n];
        
        for(int i = 0; i < n; i++) arr[i] = scan.nextInt();
        
        Arrays.sort(arr);
        
        int alice = 0;
        int bob = 0;
        for(int i = n-1; i >= 0; i -= 2) alice += arr[i];
        for(int i = n-2; i >= 0; i -= 2) bob += arr[i];
        
        System.out.println(alice - bob);
        
    }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define pb push_back
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	cout<<(n*(n-1)+m*(m-1))/2<<"\n";
	
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a_list = list(map(int,input().split()))

all_p = abs(a_list[0]) + abs(a_list[-1])
p_list = [0]*(n+1)
p_list[0] = abs(a_list[0])
p_list[-1] = abs(a_list[-1])
for i in range(len(a_list)-1):
    all_p += abs(a_list[i] - a_list[i+1])
    p_list[i+1] = abs(a_list[i] - a_list[i+1])
    
a_list.insert(0 , 0)
a_list.append(0)
for i in range(len(a_list)-2):
    print(all_p - p_list[i] -p_list[i+1] + abs(a_list[i] - a_list[i+2]))

Measured memory_bytes: 14048
#include<stdio.h>
#define MAX 2000000

int H, A[MAX+1];

void MaxHeap(int i){
  int l, r, saidai, tmp;

  l = 2*i;
  r = 2*i+1;

  if ( l <= H && A[l] > A[i] )
    saidai = l;
  else
    saidai = i;
  if ( r <= H && A[r] > A[saidai] )
    saidai = r;
  if ( saidai != i ){
    tmp = A[i];
    A[i] = A[saidai];
    A[saidai] = tmp;
    MaxHeap(saidai);
  }
}

int main(){
  scanf("%d",&H);
  
  int i;
  
  for ( i = 1; i <= H; i++ )
    scanf("%d",&A[i]);
  
  for ( i = H/2; i >= 1; i-- )
    MaxHeap(i);

  for ( i = 1; i <= H; i++ )
    printf(" %d",A[i]);

  printf("\n");
    
  return 0;
}



Measured memory_bytes: 3808
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.Delayed;
import java.util.logging.Logger;


public class Main {
	public static void main(String[] args){
		PrintWriter out = new PrintWriter(System.out);
		InputReader sc=new InputReader(System.in);
		char[] cs=sc.next().toCharArray();
		char[] cs1=sc.next().toCharArray();
		for (int i = 0; i < cs.length; i++) {
			if (cs[i]!=cs1[i]) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
	static class InputReader { 
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;
		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}
 
		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}
 
		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}
 
		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}
 
		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}
 
		public boolean hasNext() {
			skip();
			return hasNextByte();
		}
 
		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
 
		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		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;
		}
 
		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 32492
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int x = s.nextInt(),y=s.nextInt();
        while(x--!=0){
            String word = s.next();
            System.out.println(word);
            System.out.println(word);
        }
    }


}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 26496
#include <iostream>
#include <string>
#include <math.h>
#include <set>
typedef long long ll;

#define FOR(i,a,b) for(ll i = (a);i < (b);++i)
#define REP(i,n) FOR(i,0,n)

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;


int main(void){

    string str;
    int N;
    cin >> N;
    cin >> str;

    int ans = 0;

    FOR(i,1,str.size()+1){
        int a[26];
        int b[26];
        fill(a,a+26,0);
        fill(b,b+26,0);
        string st1 = str.substr(0,i);
        string st2 = str.substr(i);

        int sum = 0;
        REP(j,st1.size()) {
            char c = st1[j];
            if(a[c - 'a'] == 0){
                a[c - 'a']++;
            }
        }
        REP(k,st2.size()) {
            char c = st2[k];
            if(b[c - 'a'] == 0){
                b[c - 'a']++;
            }
        }
        REP(j,26) {
            if(a[j] == b[j] && a[j]== 1){
                sum++;
            }
        }
        ans = max(ans,sum);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i,a,b,c,d,f,p=0;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&f);
	if(a<=0){
		a=-a;
		p=a*c+d+b*f;
		printf("%d\n",p);
	}
	else{
		p=(b-a)*f;
		printf("%d\n",p);
	}
	return 0;
}

Measured memory_bytes: 1788
// weather prediction
#include <iostream>
using namespace std;

int main() {
    string weather;
    cin >> weather;

    if (weather == "Sunny") {
        cout << "Cloudy\n";
    } else if (weather == "Cloudy") {
        cout << "Rainy\n";
    } else if (weather == "Rainy") {
        cout << "Sunny\n";
    }   
    return 0;
}


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

#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;


void solve(){
	int n, s=0;
	cin>>n;
	vi v;
	rep(i,0,n){
		int tem;
		cin>>tem;
		v.pb(tem);
	}
	rep(i,1,n){
		if(v[i-1] > v[i])
			s+= v[i-1] -v[i];
	}
	cout << s+v[n-1] << endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
     t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int d;  cin >> d;
    vector<int>c(26);
    rep(i, 26)  cin >> c[i];
    vector<vector<int> >s(d, vector<int>(26));
    rep(i, d)   rep(j, 26)  cin >> s[i][j];
    /*
     * scoring
     */
    int score = 0;
    vector<int>t(d);
    vector<int>v(d);
    vector<vector<int> >last(d+1, vector<int>(27));
    rep(i, d)   cin >> t[i];
    for(int i = 1; i <= d; i++){
        int tmp = i-1;
        score += s[tmp][t[tmp]-1];
        for(int j = 1; j <= 26; j++){ last[i][j] = last[i-1][j]; }
        last[i][t[tmp]] = i;
        int dec = 0;
        rep(j, 26){
            dec += c[j]*(i-last[i][j+1]);
        }
        score -= dec;
        v[tmp] = score;
    }
    rep(i, d)   cout << v[i] << endl;
}


Measured memory_bytes: 3696
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 2000;
int N, K;
vector<vector<int>> graph;

int dfs(int v, int p, int r){
	if(r==0) return 1;
	int s = 1;
	for(int u: graph[v]){
		if(u==p) continue;
		s += dfs(u, v, r-1);
	}
	return s;
}

int main(){
	cin >> N >> K;
	graph = vector<vector<int>>(N);
	for(int i=0; i<N-1; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	int within_rad = 0;
	if(K%2){
		for(int u=0; u<N; u++){
			for(int v: graph[u]){
				within_rad = max(within_rad, dfs(u, v, K/2)+dfs(v, u, K/2));
			}
		}
	} else {
		for(int i=0; i<N; i++){
			within_rad = max(within_rad, dfs(i, -1, K/2));
		}
	}

	cout << max(0, N-within_rad) << endl;

	return 0;
}


Measured memory_bytes: 384
n, m = map(int, input().split())

cake = [list(map(int, input().split())) for i in range(n)]

box = [[[[] for i in range(2)] for j in range(2)] for k in range(2)]
ans = 0
for i in range(2):
    for j in range(2):
        for k in range(2):
            worth = 0
            for x, y, z in cake:
                if i == 1:
                    x = -x
                if j == 1:
                    y = -y
                if k == 1:
                    z = -z
                box[i][j][k].append(x+y+z)
            box[i][j][k].sort(reverse=True)
            ans = max(ans, sum(box[i][j][k][:m]))

print(ans)

Measured memory_bytes: 3572
import sys
sys.setrecursionlimit(10 ** 9)

n = int(input())
tree = [[] for _ in range(n)]
for i in range(n - 1):
    a, b, c = map(int, input().split())
    a, b, c = a - 1, b - 1, c
    tree[a].append((b, c))
    tree[b].append((a, c))

limit = 100010
depth = [0] * limit

def dfs(v, p, d): # (現在の頂点v, vの親, 現在の距離)
    depth[v] = d
    for e in tree[v]:
        if e[0] == p: continue
        dfs(e[0], v, d + e[1])

q, k = map(int, input().split())
k -= 1
dfs(k, -1, 0)
for i in range(q):
    x, y = map(int, input().split())
    x, y = x - 1, y - 1
    res = depth[x] + depth[y]
    print(res)

Measured memory_bytes: 131632
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;

int miss[55][11];
int penalty[55];
int correct[55];

bool comp(const int& a, const int& b) {
    if (correct[a] != correct[b]) return correct[a] > correct[b];
    else {
        if (penalty[a] != penalty[b]) return penalty[a] < penalty[b];
        else return a < b;
    }
}

void solve(int t, int p, int r) {
    for (int i = 0; i < t; i++) {
        penalty[i] = 0;
        correct[i] = 0;
        for (int j = 0; j < p; j++) {
            miss[i][j] = 0;
        }
    }
    int tid, pid, now_time;
    string message;
    for (int i = 0; i < r; i++) {
        cin >> tid >> pid >> now_time >> message;
        tid--, pid--;
        if (message == "WRONG") {
            miss[tid][pid]++;
        }
        else {
            correct[tid]++;
            penalty[tid] += miss[tid][pid] * 1200 + now_time;
        }
    }
    vector<int> ans(t);
    for (int i = 0; i < t; i++) ans[i] = i;
    sort(ans.begin(), ans.end(), comp);
    for (int i = 0; i < t; i++) {
        cout << ans[i] + 1 << ' ' << correct[ans[i]] << ' ' << penalty[ans[i]] << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int T, P, R;
    while (true) {
        cin >> T >> P >> R;
        if (T == 0 && P == 0 & R == 0) break;
        solve(T, P, R);
    }
    return 0;
}


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

using namespace std;

int N;
int P[4];

void input(){
  cin >> N;
  string S;
  for(int i=0;i<N;i++){
    cin >> S;
    if(S=="AC"){
      P[0]+=1;
    }
    else if(S=="WA"){
      P[1]+=1;
    }
    else if(S=="TLE"){
      P[2]+=1;
    }
    else if(S=="RE"){
      P[3]+=1;
    }
    
  }
}

int main(){
  input();  
  cout << "AC x " <<P[0] <<endl;
  cout << "WA x " <<P[1] <<endl;
  cout << "TLE x " <<P[2] <<endl;
  cout << "RE x " <<P[3] <<endl;  
  return 0;
}


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

typedef pair <long long, long long> pii;

const long long MAX_N = 1e5 + 5, inf = 1000000LL * 1000000LL * 1000000LL;
long long n, m, ans;
long long dp[MAX_N];
bool Mark[MAX_N];
vector <long long> G[MAX_N];
vector <long long> G_rev[MAX_N];
vector <long long> fn;

void dfs(long long v) {
	Mark[v] = true;
	for (long long i = 0; i < G[v].size(); i++)
		if (!Mark[G[v][i]])
			dfs(G[v][i]);

	fn.push_back(v);
}

void topo() {
	for (long long i = 0; i < n; i++)
		if (!Mark[i])
			dfs(i);
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (long long i = 0; i < m; i++) {
		long long v, u;
		cin >> v >> u;
		v--; u--;
		G[v].push_back(u);
		G_rev[u].push_back(v);
	}

	topo();
	reverse(fn.begin(), fn.end());
	
	for (long long i = 0; i < n; i++) {
		long long v = fn[i];
		dp[v] = 0;
		for (long long j = 0; j < G_rev[v].size(); j++)
			dp[v] = max(dp[v], 1 + dp[G_rev[v][j]]);

		ans = max(ans, dp[v]);
	}

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

Measured memory_bytes: 14328
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n, k;
  bool card[100001];
  vector < int > vc, res;
  while(cin >> n >> k , n){
    bool white = false;
    fill_n( card, 100001, false);
    for(int i = 0, a ; i < k ; i++ ){
      cin >> a;
      if(!a) white++;
      else card[a] = true;
    }
    int ret = 0;
    vc.clear();
    for(int i = 1 ; i <= n ; i++ ){
      if(card[i]) ret++;
      else vc.push_back(ret), ret = 0;
    }
    vc.push_back(ret);
    if(white){
      res.clear();
      for(int i = 0 ; i < vc.size() - 1 ; i++ ){
        res.push_back(vc[i]+vc[i+1]);
      }
      cout << *max_element(res.begin(),res.end()) + 1 << endl;
    }else cout << *max_element(vc.begin(),vc.end()) << endl;
  }
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;


int main() {
  int n ,temp, ans = 0;
  cin >> n ;
  for(int i = 0 ;i<n ;i++){
    cin >> temp ;
    ans+=(--temp) ;
  }

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

Measured memory_bytes: 256
from itertools import permutations as p
l = [int(input()) for _ in range(5)]

ans = 1000
for i in p(range(5)):
    v = 0
    for j,k in enumerate(i):
        if j!=4:
            if l[k]%10:
                v += (l[k] - l[k]%10 + 10)
            else:
                v += l[k]
        else:
            v += l[k]
    ans = min(ans, v)

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int a,b,c;
        set<int>s;
        cin>>a>>b>>c;
        s.insert(a);
        s.insert(b);
        s.insert(c);
        if(s.size()==2)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }

Measured memory_bytes: 256