akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
using namespace std;
int main(){
	
	int n;
	
	while(cin>>n,n!=0){
	int A=0,B=0;
	vector<int>a(n);
	vector<int>b(n);
	
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
		if(a[i]>b[i])
			A+=a[i]+b[i];
		else if(b[i]>a[i])
			B+=a[i]+b[i];
		else{
			A+=a[i];
			B+=b[i];
		}
	}
	cout<<A<<" "<<B<<endl;
	}
}

Measured memory_bytes: 1272
import math

a, b, x = map(float, input().split(' '))

if x >= a**2*b/2:
    y = 2*b-(2*x/a**2)
    print(math.degrees(math.atan(y/a)))
else:
    y = 2*x/(a*b)
    print(math.degrees(math.atan(b/y)))

Measured memory_bytes: 3060
# input()はint型で直接入力できないのか？
height, width = input().split()
# print(height, width)

# boardに各行の要素を代入する
# boardの初期化
board = []
# boardに各行の文字列をリスト化したリストを代入する
for i in range(int(height)):
    s = list(input())
    board.append(s)

# タプルはイミュータブルなので変更できない
# x軸y軸方向の座標　右下左上斜め右上斜め右下斜め左下斜め左上
dx = (1, 0, -1, 0, 1, -1, -1, 1)
dy = (0, 1, 0, -1, 1, 1, -1, -1)

for i in range(int(height)):
    for j in range(int(width)):
        if board[i][j] == '#':
            continue

        num = 0
        # dx,dyをfor文で回して'.'周りの爆弾の個数を調べる
        for d in range(8):
            ni = i + dy[d]
            nj = j + dx[d]
            # 大事な分岐
            if ni < 0 or int(height) <= ni:
                continue
            if nj < 0 or int(width) <= nj:
                continue
            if board[ni][nj] == '#':
                num += 1

        board[i][j] = str(num)

for i in range(int(height)):
    print(''.join(board[i]))


Measured memory_bytes: 3188
"use strict";

process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    const s = input[0].split('');
    const w = parseInt(input[1], 10);

    let ans = '';
    for (let i = 0; i < s.length; i += w) {
        ans = ans + s[i];
    }

    console.log(ans);

    return 0;
}


Measured memory_bytes: 21192
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

/*全てのライブラリをインクルード*/
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    ll n;
    cin>>n;
    cout<<n*(n+1)/2<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
	int main(){
		int n;
		
		scanf("%d",&n);
		char str[n];
		
		scanf("%s",str);
		int counter =0;
		int max = 0;
		for(int j =0 ; j<n ;j++){

			if(str[j]=='I'){
				counter++;
				if(counter>= max){
				max=counter;
				}
			}
			else {
				counter--;
			}
		}
		printf("%d",max);
	
	return 0;
}

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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 2e5 + 10, MOD = 1e9 + 7;

int N, pow2[MAX_N];
vector<int> Ed[MAX_N];

void add(int &a, ll b) {
	b %= MOD;
	if((a+=b) >= MOD) a -= MOD;
}
struct INFO{
	int nr[3];
	INFO() {for(int k=0; k<3; k++) nr[k] = 0;}
	INFO(int a, int b, int c) {nr[0] = a, nr[1] = b, nr[2] = c;}
	void merge(INFO &o) {
		INFO res;
		for(int i=0; i<3; i++) for(int j=0; j<3; j++) add(res.nr[min(2, i+j)], 1ll * nr[i] * o.nr[j]);
		for(int k=0; k<3; k++) nr[k] = res.nr[k];
	}
};
deque<INFO> Dy[MAX_N];
int DyIx[MAX_N], Dep[MAX_N], Cnt[MAX_N];
void getDy(int v, int p) {
	Cnt[Dep[v] = Dep[p] + 1]++;
	for(int w : Ed[v]) if(w != p) getDy(w, v);

	DyIx[v] = v;
	int maxL = 0;
	for(int w : Ed[v]) if(w != p) {
		int fr = DyIx[v], to = DyIx[w];
		if(fr != 0) {
			if(SZ(Dy[fr]) > SZ(Dy[to])) swap(fr, to);
			maxL = max(maxL, SZ(Dy[fr]));
			for(int k=0; k<SZ(Dy[fr]); k++) Dy[to][k].merge(Dy[fr][k]);
			deque<INFO> temp; Dy[fr].swap(temp);
		}
		DyIx[v] = to;
	}
	Dy[DyIx[v]].emplace_front(1, 1, 0);
	for(int i=0; i<maxL+1; i++) add(Dy[DyIx[v]][i].nr[0], Dy[DyIx[v]][i].nr[2]), Dy[DyIx[v]][i].nr[2] = 0;
	//for(int w : Ed[v]) if(w != p) printf("[%d] ", w); puts("");
	//printf("%d :", v); for(auto &val : Dy[DyIx[v]]) printf(" [%d %d %d]", val.nr[0], val.nr[1], val.nr[2]); puts("");
}

int main() {
	cin >> N;
	N++;
	pow2[0] = 1; for(int i=1; i<=N; i++) pow2[i] = pow2[i-1] * 2 % MOD;
	for(int i=2; i<=N; i++) {
		int x; scanf("%d", &x); x++;
		Ed[x].push_back(i);
		Ed[i].push_back(x);
	}

	Dep[0] = -1; getDy(1, 0);
	int ans = 0;
	for(int d=0; d<SZ(Dy[DyIx[1]]); d++) add(ans, 1ll * Dy[DyIx[1]][d].nr[1] * pow2[N - Cnt[d]]);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 245620
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string S; cin >> S;

	sort(ALL(S));

	cout << (S == "abc" ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int N, M; cin >> N >> M;
	vector<int> H(N);
	rep(i, N) cin >> H[i];
	vector<vector<int> > v(N);
	rep(i, M){
		int a, b; cin >> a >> b;
		a--; b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}

	int ans = 0;
	rep(i, N){
		int nowH = H[i];
		bool ok = true;
		for(int u : v[i]){
			if(nowH <= H[u]) ok = false;
		}
		if(ok) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 8800
#include "bits/stdc++.h"
#define rep(i,N) for (int (i) = 0; (i) < (N); (i)++)

int main() {

	std::cin.tie(nullptr); std::ios::sync_with_stdio(false);
	
	int A, B, C, D; std::cin >> A >> B >> C >> D;

	if (A + B == C + D)std::cout << "Balanced";
	else if (A + B > C + D)std::cout << "Left";
	else std::cout << "Right";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORR(x, arr) for(auto& x:arr)
#define ITR(x, c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

int n, z, w, a[2005], dp[2005];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> z >> w;
	int ma = 0;
	FOR(i, n) {
		cin >> a[i];
	}
	if (n==1) ma = abs(a[n-1]-w);
	else ma = max(abs(a[n-1]-w), abs(a[n-2]-a[n-1]));
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readlines

def main():
    lines = input()

    n = int(lines[0].strip())
    a = list(map(int, lines[1].split()))

    a = sorted(a)
    c = a[n//2 - 1] ; d = a[n//2]

    print(d-c)

main()

Measured memory_bytes: 20568
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO.Pipes;
using System.Runtime;

namespace Csharponly
{
    class Program
    {
        static public void Main()
        {
            int[] SW = Arrayint();

            string ans = "unsafe";
            if(SW[0] > SW[1])
            {
                ans = "safe";
            }

            Console.WriteLine(ans);

        }


　　　　//一つの文字列を受け渡す
        static string Onestring()
        {
            return Console.ReadLine();
        }

        //複数の文字列を配列で受け渡す
        //文字列と文字列の間は" "で区切る
        static string[] Arraystring()
        {
            return Console.ReadLine().Split(' ');
        }

        //一つの数字を受け渡す
        static int Oneint()
        {
            return int.Parse(Console.ReadLine());
        }

        //複数の数字を配列で受け渡す
        //数字と数字の間は" "で区切る
        static int[] Arrayint()
        {
            String[] input_line = Console.ReadLine().Split(' ');
            int[] input_num = new int[input_line.Length];
            for (int i = 0; i < input_line.Length; i++)
            {
                input_num[i] = int.Parse(input_line[i]);
            }
            return input_num;
        }
    }
}

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> g[n];
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	vector<bool> used(n, false);
	deque<int> que;
	que.push_back(0);
	que.push_back(g[0][0]);
	
	int f = 0, b = g[0][0];
	used[f] = used[b] = true;
	
	while (true) {
		int next_v = -1;
		for (int &u : g[b]) {
			if (not used[u]) {
				next_v = u; break;
			}
		}
		if (next_v == -1) {
			break;
		} else {
			b = next_v;
			que.push_back(b);
			used[b] = true;
		}
	}
	
	while (true) {
		int next_v = -1;
		for (int &u : g[f]) {
			if (not used[u]) {
				next_v = u; break;
			}
		}
		if (next_v == -1) {
			break;
		} else {
			f = next_v;
			que.push_front(f);
			used[f] = true;
		}
	}
	
	cout << que.size() << '\n';
	for (int &u : que) cout << ++u << ' ';
	
	return 0;
}

Measured memory_bytes: 6656
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#define INF 100000
using namespace std;
int main(){
	long int n,a[INF],m1=0,m2=0,m3=0,m4=0,check=0,count=0;
	bool mfirst=true,msecond=true;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=n-1;0<=i;i--){
		if(a[i]==a[i-1] && mfirst==true){
			m1=a[i];
			m2=a[i];
			check=a[i];
			mfirst=false;
			i--;
			continue;
		}
		else if(mfirst==false && a[i]==a[i-1] && msecond==true){
			m3=a[i];
			m4=a[i];
			msecond=false;
		}
	}
	for(int i=0;i<n;i++){
		if(a[i]==check){
			count++;
		}
	}
	if(count>=4 && msecond==true){
		m3=check;
		m4=check;
	}
	cout<<m1*m4<<endl;
	return 0;
}

Measured memory_bytes: 1024
#pragma region include
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
#define MOD (int)(1e9+7)
#define INF (int)(1e9)
#define LLINF (int)(4e18)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion

struct Edge {
    int to, cost;
};

vector<vector<Edge>> G;
vector<ll> dist;

void dfs(int v, int p = -1, ll c = 0) {
    dist[v] = c;
    for (Edge e : G[v]) {
        if (e.to == p) continue;
        dfs(e.to, v, c + e.cost);
    }
}

int main() {
    int N; input(N);
    G.resize(N);
    dist.resize(N);
    REP(i, N - 1) {
        int a, b, c; input(a, b, c);
        a--; b--;
        G[a].push_back({b,c});
        G[b].push_back({a,c});
    }
    int Q, K; input(Q, K);
    K--;
    dfs(K);
    REP(i, Q) {
        int x, y; input(x,y);
        x--; y--;
        cout << dist[x] + dist[y] << endl;
    }
    getchar(); getchar();
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define ins insert
#define sz(x) (long long)x.size()
typedef long long ll;
typedef long double ld;
const int N = 1e5 + 5;
const ld pi = 3.141592653;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;
const ll INF = __LONG_LONG_MAX__;

using namespace std;

int dx[9]={1, -1, 0, 0, 1, 1, -1, -1, 0};
int dy[9]={0, 0, 1, -1, 1, -1, 1, -1, 0};

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int T = 1;
        //cin>>T;
        while(T--)
        {
                string s, t;
                cin>>s>>t;
                int i, j, ans = sz(s);
                for(i=0; i<=sz(s) - sz(t); i++){
                        j = i;
                        int cnt = 0;
                        while(j < i + sz(t) && j < sz(s)){
                                if(s[j]!=t[j-i]) cnt++;
                                j++;
                        }
                        ans = min(ans, cnt);
                }
                cout<<ans;
        }
        return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int x) {
    S[++top] = x;
}

int pop() {
    top--;
    return S[top+1];
}

int main() {
    int a, b;
    top = 0;
    char s[100];
    
    while (scanf("%s", s) != EOF) {
        if(s[0] == '+') {
            a = pop();
            b = pop();
            push(a + b);
        } else if (s[0] == '-') {
            b = pop();
            a = pop();
            push(a - b);
        } else if (s[0] == '*') {
            a = pop();
            b = pop();
            push(a * b);
        } else {
            push(atoi(s));
        }
    }
    
    printf("%d\n", pop());
    
    return 0;
}

Measured memory_bytes: 548
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

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

	int N, K;
	string S;

	cin >> N;
	cin >> S;
	cin >> K;

	for(int i=0; i<S.size(); i++){
		if(S[i] != S[K-1]){
			printf("*");
		}
		else{
			printf("%c", S[i]);
		}
	}
	printf("\n");
	return 0;

}

Measured memory_bytes: 3624
import java.util.Scanner;




public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);
    	String S=sc.next();

    	int first=S.indexOf("A");
    	int last=S.lastIndexOf("Z");

    	int result=last-first;

    	System.out.println(result+1);
    }

}



Measured memory_bytes: 26416
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
  string N;
  cin>>N;
  int A[4];
  rep(i,4) A[i]=N[i]-'0';
  if(A[0]+A[1]+A[2]+A[3]==7) cout<<A[0]<<"+"<<A[1]<<"+"<<A[2]<<"+"<<A[3]<<"=7"<<endl;
  else if(A[0]-A[1]+A[2]+A[3]==7) cout<<A[0]<<"-"<<A[1]<<"+"<<A[2]<<"+"<<A[3]<<"=7"<<endl;
  else if(A[0]+A[1]-A[2]+A[3]==7) cout<<A[0]<<"+"<<A[1]<<"-"<<A[2]<<"+"<<A[3]<<"=7"<<endl;
  else if(A[0]+A[1]+A[2]-A[3]==7) cout<<A[0]<<"+"<<A[1]<<"+"<<A[2]<<"-"<<A[3]<<"=7"<<endl;
  else if(A[0]-A[1]-A[2]+A[3]==7) cout<<A[0]<<"-"<<A[1]<<"-"<<A[2]<<"+"<<A[3]<<"=7"<<endl;
  else if(A[0]+A[1]-A[2]-A[3]==7) cout<<A[0]<<"+"<<A[1]<<"-"<<A[2]<<"-"<<A[3]<<"=7"<<endl;
  else if(A[0]-A[1]+A[2]-A[3]==7) cout<<A[0]<<"-"<<A[1]<<"+"<<A[2]<<"-"<<A[3]<<"=7"<<endl;
  else if(A[0]-A[1]-A[2]-A[3]==7) cout<<A[0]<<"-"<<A[1]<<"-"<<A[2]<<"-"<<A[3]<<"=7"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

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

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

ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}

ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}

ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}

	int s = sum(n - 1);
	return s + n;
}

bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	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;
}

// ===============================================================

int main() {
	string a; cin >> a;
	if (a == "ABC") {
		cout << "ARC" << endl;
	}
	else cout << "ABC" << endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{

    	int N;
    	cin>>N;
    	std::set<std::string> str;
    	string str1;
    	for(int i=0;i<N;i++)
    	{
    		cin>>str1;
    		str.insert(str1);
		}
		cout<<str.size();
	}

Measured memory_bytes: 19200
#import numpy
import math
import sys

def main():
    n = int(input())
    a = sorted(input_list())
    max_n = 10 ** 18
    ans = 1
    for v in a:
        ans *= v
        if ans > max_n:
            ans = -1
            break
        if ans == 0:
            break
    print(ans)


def yogen(a, b, angle):
    coss = math.cos((angle/180)*math.pi)
    return math.sqrt(a**2 + b**2 - 2*a*b*coss)


def get_angle(hour, minute):
    h = (hour * 360) / 12 + (minute * 360) / (12 * 60)
    m = (minute * 360) / 60
    angle = abs(h-m)
    return min(angle, 360-angle)

def has(v, l):
    for vl in l:
        if v == vl:
            return True
    return False

def input_list():
    return list(map(int, sys.stdin.readline().split()))


if __name__ == '__main__':
    main()


Measured memory_bytes: 83560
using System;
using System.Linq;

namespace Aizu {
    public class OnlineJudge {
        static void Main() {
            Console.ReadLine();
            var array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 0, j = -1; i < array.Length; j = i++) {
                var v = array[i];
                for (; j >= 0 && array[j] > v; array[j + 1] = array[j--]);
                array[j + 1] = v;

                Console.WriteLine(string.Join(" ", array.Select(q => q.ToString()).ToArray()));
            }
        }
    }
}



Measured memory_bytes: 9716
N = int(input())
N100 = N // 100
N10 = (N - N100 * 100) // 10
N1 = (N - (N100 * 100 + N10 * 10))

if N100 == 7 or N10 == 7 or N1 == 7:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9176
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

bool check(char a, char b) {
	return a > b;
}

int kuraiwa(int n) {
	int ans = 0;
	while (n > 0) {
		ans += n % 10;
		n /= 10;
	}
	return ans;
}

bool kaibun(int n) {
	int a[5];
	for (int i = 0;i < 5;i++) {
		a[i] = n % 10;
		n /= 10;
	}
	if (a[0] == a[4] && a[1] == a[3]) {
		return true;
	}
	else {
		return false;
	}
}

int main() {
	int n, m, x;
	cin >> n >> m >> x;
	int y;
	int cnt = 0;
	rep(i, m) {
		cin >> y;
		if (y < x) {
			cnt++;
		}
	}
	if (cnt < m / 2) {
		cout << cnt << endl;
	}
	else {
		cout << m - cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

        
	string s1,s2;
	cin>>s1>>s2;

	int a,b;
	cin>>a>>b;

	string t;
	cin>>t;
	if(s1 == t) a--;
	else b--;
	cout<<a<<" "<<b;
        
        












    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
    return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
signed main(){
    puts("-nan");
    return 0;
}



Measured memory_bytes: 3096
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		double n = scan.nextDouble();
		double k = scan.nextDouble();
		
		double value = Math.log(n) / Math.log(k);
		int ans = (int)value;
		
		System.out.println(ans+1);
	}
}




Measured memory_bytes: 22996
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

void func(int N)
{
    vi a(N), b(N);
    rep(i, N) cin >> a[i];
    rep(i, N) cin >> b[i];
    
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    
    int c = 0;
    rep(k, N-1){
        if(b[c] >= a[k]){
            ++c;
        }
        if(k+1 > 2*c){
            cout << k+1 << endl;
            return;
        }
    }
    
    cout << "NA" << endl;
}

int main()
{
    int N;
    while(cin >> N, N){
        func(N);
    }
}

Measured memory_bytes: 1436
#include<bits/stdc++.h>
using namespace std;
int main()
{
	double n,sum=0,ans;
	cin >> n;
	for(int i=1;i<=n;i++){
		if(i%2==1){
			sum++;
		}
	}
	ans=sum/n;
	printf("%.10f\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
 
using namespace std;
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 
 
vector <set <int> > g;

 

int main()
{
    
    int n;
    cin>>n;
    string s;
    cin>>s;
    int q;
    cin>>q;
    vector <set <int> > v(26);
    for(int i=0;i<n;i++)
    {
        v[s[i]-97].insert(i+1);
    }
    while(q--)
    {//cout<<"came here\n";
        int x;
        cin>>x;
        if(x==1)
        {int y;
            char z;
            cin>>y;cin>>z;
            //cout<<x<<" "<<y<<" "<<z<<" "<<s[y-1]-97<<endl;
            v[s[y-1]-97].erase(y);
            s[y-1]=z;
            v[z-97].insert(y);
        }
        else
        {int y,z;
            cin>>y>>z;
            int test=0;
            for(int i=0;i<26;i++)
                if(v[i].lower_bound(y)!=v[i].end()&&*(v[i].lower_bound(y))<=z)
                    test++;
            cout<<test<<endl;
        }
    }
    return 0;   
}
 
 


Measured memory_bytes: 24196
fn main() {
    let x: i32 = read();
    let a: i32 = read();
    let b: i32 = read();

    let ans = (x - a) % b;
    println!("{}", ans)
}


fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

//fn read_vec<T: std::str::FromStr>() -> Vec<T> {
//    let mut s = String::new();
//    std::io::stdin().read_line(&mut s).ok();
//    s.trim().split_whitespace()
//        .map(|e| e.parse().ok().unwrap()).collect()
//}

//fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
//    let mut v2 = Vec::new();
//    for _ in 0..n {
//        let mut s = String::new();
//        std::io::stdin().read_line(&mut s).ok();
//        let v = s.trim().split_whitespace()
//            .map(|e| e.parse().ok().unwrap()).collect();
//        v2.push(v);
//    }
//    v2
//}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
ll dp[100005][3];ll a[100005][3];
int n;
int main(){
    ios::sync_with_stdio(false);
    cin>>n;
    for (int i=1;i<=n;++i) cin>>a[i][0]>>a[i][1]>>a[i][2];
    for (int i=1;i<=n;++i){
    	dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
    	dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
    	dp[i][2]=max(dp[i-1][0],dp[i-1][1])+a[i][2];
	}
	ll ans=dp[n][0];ans=max(ans,dp[n][1]);ans=max(ans,dp[n][2]);
	cout<<ans;
    return 0; 
}

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

int main() {
    int N, A, B, p1;
    cin >> N >> A >> B;

    p1 = A * N;

    if(p1 < B) {
        cout << p1 << endl;
    } else {
        cout << B << endl;
    }
}


Measured memory_bytes: 3568
#include <iostream>
using namespace std;
int main(void){
    int N,counter=-1;
    cin >> N;
    int A[N];
    bool flag = false;
    for(int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    while(!flag)
    {
        for(int i = 0; i < N; i++)
        {
            if(A[i]%2==1)
            {
                flag=true;
            }
            else
            {
                A[i]=(A[i]/2);
            }
        }
        counter++;
    }
    cout << counter << endl;
}


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

int main() {
  int N, W;
  cin >> N >> W;
  vector<long> DP(W + 1);
  for (int w, v; cin >> w >> v;) {
    for (int i = W; i - w >= 0; i--) {
      DP.at(i) = max(DP.at(i), DP.at(i - w) + v);
    }
  }
  cout << DP.at(W) << "\n";
}

Measured memory_bytes: 1024
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n,x;
vi s,prim;
int ret;
int facto[201];

ll powll(ll base,ll power){
    ll ans = 1;
    while (power){
        if (power&1) ans = (base*ans)%mod;
        base = (base*base)%mod;
        power >>= 1;
    }
    return ans;
}
int invs[201];

int dp[201][100010];

signed main(){
    facto[0] = 1;
    REPS(i,200) facto[i] = (facto[i-1] * i) % mod;
    REPS(i,200) invs[i] = powll(i,mod-2);

    I(n); I(x);
    s.resize(n);
    REP(i,n) I(s[i]);
    sort(all(s), greater<int>());

    dp[0][x] = 1;
    REP(i,n){
        REP(j,x+1){
            int prob = invs[n-i];
            dp[i+1][j] = (dp[i+1][j] + dp[i][j] * (1 + mod - prob)) % mod; 
            dp[i+1][j % s[i]] = (dp[i+1][j % s[i]] + dp[i][j] * prob) % mod; 
        }
    }
    int ret = 0;
    REP(j,s[n-1]) ret = ((dp[n][j] * j) + ret) % mod;
    cout << (ret * facto[n]) % mod << endl;
}

Measured memory_bytes: 156544
#!/usr/bin/env python3


def solve(n, m, a, b, ds):
    is_waste = [False for _ in range(n)]
    for i in range(n):
        if ds[i] >= a:
            is_waste[i] = True
        else:
            break
    if sum(is_waste) > n - m:
        for i in range(n)[::-1]:
            if is_waste[i]:
                if ds[i] <= b:
                    is_waste[i] = False
                else:
                    break
    return sum(is_waste)


def main():
    n, m, a, b = map(int, input().split())
    ds = list(map(int, input().split()))
    print(solve(n, m, a, b, ds))


if __name__ == '__main__':
    main()

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

int main(){
    int n;
    cin >>n;
    int x[150]={0};

    for (int i=0;i<n;i++){
        cin >>x[i];
    }
    int best=1;
    int tmp=0;
    int flag=x[0];
    for (int j=1;j<n;j++){
        if (x[j]>=flag){
            flag=x[j];
            best++;
        }

    }
    cout <<best <<endl;




    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  int A[100100], B[100100]; 
  rep(i, N) {
    cin >> A[i];
    B[i] = A[i];
  }
  sort(B, B + N);
  map<int, int> mp;
  rep(i, N) {
      mp[B[i]] = i + 1;
  }
  rep(i, N) {
      A[i] = mp[A[i]];
  }
  int ans = 0;
  for(int i = 0; i < N; i += 2) {
      if(A[i] % 2 != 1) ans ++;
  }
  cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 5760
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String[]  s = sc.next().split("");
        if(s[2].equals(s[3]) && s[4].equals(s[5])){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
package main

import "fmt"

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a >= b {
		return b
	}
	return a
}

func main() {
	var n int
	fmt.Scan(&n)
	p := make([]int, n)
	for i := range p {
		fmt.Scan(&p[i])
	}
	cnt := 0
	for i := 1; i < len(p)-1; i++ {
		sp := p[i-1 : i+2]
		pmax := max(sp[0], max(sp[1], sp[2]))
		pmin := min(sp[0], min(sp[1], sp[2]))
		if sp[1] != pmin && sp[1] != pmax {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int l = a + b;
	int r = c + d;
	string ans;
	if (l == r) {
		ans = "Balanced";
	} else if (l < r) {
		ans = "Right";
	} else {
		ans = "Left";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll; 
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
// IO
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define sc(n) scanf("%d", &n) 
#define sca(a, n) fo(i, n) sc(a[i])
#define pd(a) printf("%d ", a)
#define pld(a) printf("%d\n", a)
#define pda(a, n) fo(i, n) pd(a[i])
#define pl printf("\n")
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b) 
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
// math
const ll mod = 1e9+7;
template<typename T> T gcf(T a, T b) {return (b == 0) ? a : gcf(b, a%b);} 
template<typename T> T lcm(T a, T b) {return (a*b)/gcf(a, b);}
template<typename T> T sumTo(T x) {return x * (x+1) / 2;}
template<typename T> T sumSquaresTo(T x) {return x * (x+1) * (2*x+1) / 6;}
template<typename T> T ceilDiv(T n, T d) {return (n+d-1)/d;}

void solve() {
    int n, k; cin>>n>>k;
    int p[n]; sca(p, n);
    sort(p, p+n);
    int ans = 0;
    fo(i, k) ans+=p[i];
    cout << ans;
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3756
from itertools import combinations_with_replacement, permutations

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

def main():
    K = int(input())
    ans = 0
    for i in range(K):
        for j in range(K):
            for k in range(K):
                temp = gcd(i+1, j+1)
                temp = gcd(temp, k+1)
                ans += temp
    print(ans)
if __name__ == "__main__":
    main()

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

int N, K;
const int MAX_N = 1.0e5 + 100;
int A[MAX_N];

int gcd(int a, int b) {
    int large = max(a, b);
    int small = min(a, b);
    if (small == 0) return large;
    else return gcd(small, large % small);
}

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

    sort(A, A+N);

    int m = A[N-1];
    int g = A[0];
    for (int i = 1; i < N; i++) {
        g = gcd(g, A[i]);
    }
 
    if (g <= K && K <= m && K % g == 0) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;    

    return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

char *demangle(const char *demangle)
{
    int status;
    return abi::__cxa_demangle(demangle, 0, 0, &status);
}

int main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    rep(i, n) cin >> A[i];
    bool ok = true;
    rep(i, n)
    {
        if (A[i] % 2 == 0 && (A[i] % 3 != 0 && A[i] % 5 != 0))
        {
            ok = false;
        }
    }
    puts(ok ? "APPROVED" : "DENIED");

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define br break
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace2(a,b) cerr <<"a is " << a << " b is " << b << el;
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;
int main()
{
    ios;
    ll n ;
    cin >> n ;
    ll foo = n ;
    foo = foo / 100 ;
    ll res = foo *100 ;
    ll rem = n - res ;
    ll left = foo;
    ll right = rem ;
    if(left ==0 and right == 0 ){
        cout << "NA\n" ;
        ro ;
    }
    if(left == 0 and right > 12 or (left > 12  and right == 0 )){
        cout << "NA\n" ;
        ro ;
    }
    if(left == 0 and right <= 12){
        cout << "YYMM\n" ;
        ro ;
    }
    if(left <=12 and right == 0 ){
        cout << "MMYY\n";
        ro ;
    }
    if(left <= 12 and right <= 12){
        cout << "AMBIGUOUS\n" ;
        ro ;
    }
    if(left > 12 and right <= 12){
        cout << "YYMM\n" ;
        ro ;
    }
    if(right > 12 and left <=12 ){
        cout << "MMYY\n" ;
        ro ;
    }
    if(right > 12 and left > 12 ){
        cout << "NA\n" ;
        ro ;
    }
    ro ;

}
















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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
const int N = 2e3+5;

ll n , dp[N][N];
pair<ll,ll> a[N];

ll solve(int l , int r)
{
    if (l > r) return 0;

    if (dp[l][r] != -1)
        return dp[l][r];
    
    ll ans , idx = n-r+l;
    ans = abs(a[idx].s - l)*a[idx].f + solve(l+1 , r);
    ans = max(ans , abs(a[idx].s - r)*a[idx].f + solve(l , r-1));

    return dp[l][r] = ans;
}

int main()
{

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    memset(dp , -1 , sizeof(dp));
    
    cin >> n;
    for(int i=1; i<=n; i++)
    {
        cin >> a[i].f;
        a[i].s = i;
    }

    sort(a+1 , a+n+1 , greater< pair<ll,ll> >());

    cout << solve(1,n) << '\n';

    return 0;
}

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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

int main()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

    LL h, w;
    cin >> h >> w;

    string s[110];

    for(LL i = 0; i < h; i++)
        cin >> s[i];

    for(LL i = 0; i <= w + 1; i++)
        cout << '#';
    cout << '\n';

    for(LL i = 0; i < h; i++){
        cout << '#';
        cout << s[i];
        cout << "#\n";
    }

    for(LL i = 0; i <= w + 1; i++)
        cout << '#';
    cout << '\n';
    return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	nextReader = newScanner()

	n := nextInt()
	d := nextInts(n)

	sort.Ints(d)
	mid := n / 2
	fmt.Println(d[mid] - d[mid-1])
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}


Measured memory_bytes: 2048