akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>

int main(void){
	int i, str_len;
	char str[100];

	while(gets(str) != NULL){
		str_len = strlen(str);
		for(i = 0; i < str_len; i++){
			if(str[i] >= 'a' && str[i]<= 'z'){
				str[i] = str[i] - 32;
			}
		}
		printf("%s\n", str);
	}

	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    string s;
    cin>>s;
    ll k;
    cin>>k;

    vector<string> a(k * s.size());
    for(ll i=0;i<s.size();++i){
        for(ll j=0;j<k;++j){
            a[k*i+j] = s.substr(i, j+1);
        }
    }
    sort(a.begin(), a.end());
    unique(a.begin(), a.end());
    string ans = a[k-1];
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
signed main() {
	ll n, a, cnt = 0, ans = 0; cin >> n;
	vector<ll> v(n), cost(n);
	for (int h = 0; h < n; h++) {
		cin >> v[h];
	}
	for (int h = n - 1; h >= 0; h -= 2) {
		if (h == n - 1) { cout << v[h]; }
		else { cout << ' ' << v[h]; }
	}
	if (n % 2 == 0) {
		for (int h = 0; h < n; h += 2) {
			cout << ' ' << v[h];
		}
	}
	else {
		for (int h = 1; h < n; h += 2) {
			cout << ' ' << v[h];
		}
	}
	cout << endl;
	cin >> n; return 0;
}

Measured memory_bytes: 5248
N = int(input())
S_s = [input() for _ in range(N)]
AC = len(list(filter(lambda x:x=='AC', S_s)))
WA = len(list(filter(lambda x:x=='WA', S_s)))
TLE = len(list(filter(lambda x:x=='TLE', S_s)))
RE = len(list(filter(lambda x:x=='RE', S_s)))
print('AC x',AC)
print('WA x',WA)
print('TLE x',TLE)
print('RE x',RE)

Measured memory_bytes: 82148
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string S;
  cin >>S;
  if(S[5]=='0'){
    if(S[6]=='1'||S[6]=='2'||S[6]=='3'||S[6]=='4')puts("Heisei");
    else puts("TBD");
    return 0;
  }
  else if(S[5]=='1') puts("TBD");
  return 0;
    
  
}


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

int main(){
    
    int N;
    cin>>N;
    vector<int> S(N),T(N);
    for(int i=0;i<N;i++){
        cin>>S.at(i);
        T.at(i)=S.at(i);
    }
    sort(S.begin(),S.end());
    int A=S.at(N/2-1),B=S.at(N/2);
    for(int i=0;i<N;i++){
        if(T.at(i)<=A) cout<<B<<endl;
        else cout<<A<<endl;
    }
}


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

int main(){
  
  int N, i, Num=0;
  string S;
  cin>>N>>S;
  for(i=0; i<N; i++)if(S[i]=='E')Num++;
  int mn=Num;
  
  for(i=0; i<N; i++){
    if(S[i]=='E')Num--;
    if(S[i]=='W')Num++;
    mn=min(mn, Num);
  }
  cout<<mn<<endl;
  return 0;
}

Measured memory_bytes: 3896
from collections import Counter
N=int(input())
A=list(map(int,input().split()))
d=dict(Counter(A))
sum=0
s=[]
s.append(0)
for i in range(1,2*10**5+1):
    s.append(s[i-1]+i-1)
for value in d.values():
    sum+=s[value]
for x in A:
    print(sum-(d[x]-1))




Measured memory_bytes: 102092
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
// scanf("%d %d %d %d",&w,&b,&d,&s); %lld
// printf("%d\n" ,points);
// const double PI=acos(-1);

const int MAX = 1e5+4;
ll dp[102][MAX];

int main(){
    fastIO;
    int n, w;
    cin >> n >> w;
    int weights[n], values[n];
    for(int i = 0; i < n; i++){
        cin >> weights[i] >> values[i];
    }

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= w; j++){
            dp[i][j] = dp[i-1][j];
            if(j-weights[i-1] > -1){
                dp[i][j] = max(dp[i][j], dp[i-1][j-weights[i-1]]+values[i-1]);
            }
        }
    }
    cout << dp[n][w] << endl;
    return 0;
}


Measured memory_bytes: 81760
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

const ll mod = 1000000007;
int CC[200001];
set<int> Colors[200001];
ll Cases[200001];

// 処理後の石の列の0個目〜n個目までの場合の数
// メモ化再帰
ll CalcCases(int n){
	if(n == 0){
		return 1;
	}
	if(Cases[n] > 0){
		return Cases[n];
	}
	ll value = 0;
	value = CalcCases(n-1) % mod;
	auto lower = Colors[CC[n]].lower_bound(n);
	if(lower != Colors[CC[n]].begin()){
		auto p = prev(Colors[CC[n]].lower_bound(n));
		value += CalcCases(*p);
		value %= mod;
	}
	Cases[n] = value;
	return value;
}

int main()
{
	int N;
	cin >> N;
	int C[200001];
	for(int i = 0; i < N; i++){
		cin >> C[i];
	}
	fill(Cases, Cases+N, 0);
	
	// 同じ色が連続している場所は、１つの石とみなしてもよい
	int before = 0;
	int count = 0;
	for(int i = 0; i < N; i++){
		if(before != C[i]){
			CC[count] = C[i];
			count++;
		}
		before = C[i];
	}
	
	// 各色の場所を記憶
	for(int i = 0; i < count; i++){
		Colors[CC[i]].insert(i);
	}
	
	cout << CalcCases(count-1) << endl;
	
	return 0;
}

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

int main(){
    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        int s[n];
        int sum = 0;
        rep(i,n){
            cin >> s[i];
            sum += s[i];
        }
        double m = 1.0 * sum / n;
        double v = 0.0;
        rep(i,n){
            v += pow(s[i]-m, 2);
        }
        v /= n;
        printf("%.7f\n", sqrt(v));
    }
    return 0;
}



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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(ll size) {
        size = max((int) sqrt(size) + 1, 101010);
        prime.resize(size, 1);
        prime[0] = 0;
        prime[1] = 0;
        for (size_t i = 2; i * i <= size; ++i)
            if (prime[i]) {
                for (size_t j = 2; i * j <= size; ++j)prime[i * j] = false;
            }
    }
};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};


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

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll t1, t2, a1, a2, b1, b2;
string s;

int main() {
    cin >> s;
    ll res = 0;
    string t = "";
    REP(i, s.size()) {
        if (s[i] == 'B' && s[i + 1] == 'C')t += 'X', i++;
        else t += s[i];
    }
    reverse(t.begin(), t.end());
    int i = 0, x = 0;
    while (i < t.size()) {
        if (x > 0 && t[i] == 'A')res+=x;
        else if(t[i]=='X')x++;
        else x=0;
        i++;
    }
    cout << res << endl;

    return 0;
}


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

int main(){
    int H, W;
    while(1){
    cin >> H >> W;
    if( H == 0 && W == 0){
        break;
    }
    else{
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            cout << '#';
        }
        cout << endl;
    }
    }
    printf("\n");
    }
    return 0;
}


Measured memory_bytes: 3104
n = int(input())
a = list(map(int, input().split()))
d = [0] * (10**5 + 2)
neg_count = 0
for i in range(len(a)):
  d[a[i] - 1] += 1
  d[a[i]] += 1
  d[a[i] + 1] += 1
ans = max(d)
print(ans)

Measured memory_bytes: 20696
#include <bits/stdc++.h>
#define EPS 0.00000000001
#define pi 3.141592653589793238
using namespace std;
double a,b,x,tem,l,r,mid;
int main(){
	//a=pi;
	//cout<<a<<endl;
	//printf("%.2f",a);
	cin>>a>>b>>x;
	if(x==a*a*b)
	{
		cout<<0<<endl;
		return 0; 
	}
	if(x*2<=a*a*b)
	{
		tem=b*b*a/x/2;
		l=0;
		r=90;
		while(l+EPS<=r)
		{
			mid=(l+r)/2;
			if(tan(mid*pi/180)<=tem)
			{
				l=mid;
			}
			else
			{
				r=mid;
			}
		}
		printf("%.10lf\n",l);
	}
	else
	{
		x=a*a*b-x;
		tem=a*a*a/x/2;
		l=0;
		r=90;
		while(l+EPS<=r)
		{
			mid=(l+r)/2;
			if(tan(mid*pi/180)<=tem)
			{
				l=mid;
			}
			else
			{
				r=mid;
			}
		}
		printf("%.10lf\n",90-l);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b==c)
    cout <<'1';
  else if(a!=b&&b!=c&&c!=a)
    cout <<'3';
  else
    cout <<'2';
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <string>
#include <sstream>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    int A, B, K;

    cin >> A >> B >> K;

    int ans = 0;
    for (int i = 100; i > 0; --i) {
        if (A % i == 0 && B % i == 0) {
            --K;
            if (K == 0) {
                ans = i;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
typedef long long int ll;
typedef vector<int> vint;
typedef vector<float> vfloat;
typedef vector<string> vstr;
typedef vector<vint> vvint;
const ll LINF = 9000000000000000000ll;
const int INF = 2000000000;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vfloat v(n);
    rep(i, n) cin >> v[i];
    sort(all(v));
    while(1) {
        if (v[1] == INF) break;
        v.push_back((v[0] + v[1]) / 2);
        v[0] = INF;
        v[1] = INF;
        sort(all(v));
    }
    cout << v[0] << endl;
    return 0;
}

Measured memory_bytes: 256
n,i;
ea[2<<17],eb[2<<17],next[2<<17],first[1<<17];
long M,dp1[1<<17],dp2[1<<17],L[2<<17],R[2<<17]={1};
dfs1(u,p,id)
{
	dp1[u]=1;
	id=first[u];
	while(id)
	{
		if(eb[id]!=p)
		{
			dfs1(eb[id],u);
			dp1[u]=dp1[u]*-~dp1[eb[id]]%M;
		}
		id=next[id];
	}
}
make();
dfs2(u,p,x,id)
{
	dp2[u]=dp1[u]*x%M;
	make(first[u],p,x);
	id=first[u];
	while(id)
	{
		if(eb[id]!=p)
		{
			dfs2(eb[id],u,L[id]*R[next[id]]%M+1);
		}
		id=next[id];
	}
}
make(i,p,x,t)
{
	if(i)
	{
		L[i]=x;
		t=eb[i]!=p?-~dp1[eb[i]]:1;
		make(next[i],p,t%M*x%M);
		R[i]=R[next[i]]*t%M;
	}
}
main(u,v)
{
	/*for(scanf("%d%d",&n,&M);~scanf("%d%d",&u,&v);)
	{
		i++;
		ea[i]=u;
		eb[i]=v;
		i++;
		ea[i]=v;
		eb[i]=u;
	}*/
	//for(;~scanf("%d%d",&u,&v);)i++?ea[i]=eb[i+1]=u,ea[i+1]=eb[i]=v,i++:(n=u,M=v);
	for(;~scanf("%d%d",&u,&v);i++)i++?ea[i]=eb[i+1]=u,ea[i+1]=eb[i]=v:(n=u,M=v);
	for(;i;i--)
	{
		next[i]=first[ea[i]];
		first[ea[i]]=i;
	}
	dfs1(1,0);
	dfs2(1,0,1);
	for(i=1;i<=n;i++)printf("%d\n",dp2[i]);
}

Measured memory_bytes: 13056
#include<bits/stdc++.h>
#define int long long int
const int mod=1e9+7;
#define fastinout     ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int imod(int a, int m)
{
    return power(a, m - 2, m);
}

void myfun()
{
	int n,i,a,b,c,ans=0;
	cin>>n;
	for(a=1;a<=n;a++)
	{
	  	b=n/a;
	  	c=n%a;
	  	if(b>0)
	    {
	    if(c>0)
		ans=ans+b;
		if(c==0)
		ans=ans+b-1;
		}
	    
	}
	cout<<ans;
}

signed main()
{
	 fastinout;
	int t=1;
	//cin>>t;
	while(t--)
	myfun();
	return 0;
}

Measured memory_bytes: 3648
package main

import "fmt"

func main() {
	var a, b, c, x, ans int
	fmt.Scan(&a, &b, &c, &x)
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if i*500+j*100+k*50 == x {
					ans++
				}
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define MAX 1000000

int main(){
	bool p[MAX+1];
	int num,answer;

	while( scanf("%d" , &num) != EOF ){	
		// ツ陛渉青板づ個渉可甘コツ可サ
		p[0] = false;
		p[1] = false;
		for(int i=2 ; i<=MAX ; i++){
			p[i] = true;
		}
		answer = 0;

		//ツエツδ可トツスツテツネツスツづ個づ督づゥツつ「
		for(int i=2 ; i<=sqrt(MAX)+1 ; i++){
			if(p[i]==1){
				for(int j=i*2; j<=MAX; j=j+i){
					p[j] = false;
				}
			}
		}

		// Output
		for(int i=0; i<=num; i++){
			if(p[i]){
				answer++;
			}
		}
		printf("%d\n", answer);
	}
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define ifaxb(a, x, b) if (a < x && x < b)
#define toInt(x) (x - '0')
#define vi vector<int>
#define vs vector<string>
#define all(x) x.begin(), x.end()
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

// X < Z <= Y を満たすか調べる
// XがZ以上、YがZより小さい場合にフラグをfalseにする
bool is_war(const vi &x, const vi &y) {
  FOR(Z, -100, 101) {
    bool is_ok = true;
    rep(i, x.size()) {
      if (x[i] >= Z) is_ok = false;
    }
    rep(i, y.size()) {
      if (y[i] < Z) is_ok = false;
    }
    if (is_ok) return false;
  }
  return true;
}

int main() {
  int N, M;
  cin >> N >> M;
  vi x(N + 1), y(M + 1);
  cin >> x[0] >> y[0];
  rep(i, N) { cin >> x[i + 1]; }
  rep(i, M) { cin >> y[i + 1]; }
  if (is_war(x, y)) {
    cout << "War" << endl;
  } else {
    cout << "No War" << endl;
  }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func lib_PowInt(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int
	scanner.Scan()
	N, _ = strconv.Atoi(scanner.Text())
	fmt.Println(solve(N))
}
func solve(N int) (name string) {
	alphabets := []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
	getDigits := func(N int) int {
		max := 0
		for i := 1; i < 12; i++ {
			max += lib_PowInt(26, i)
			if N <= max {
				return i
			}
		}
		panic("unexpected value")
	}
	digits := getDigits(N)
	n := N
	for i := 1; i < digits; i++ {
		n -= lib_PowInt(26, i)
	}
	if n == 0 {
		return strings.Repeat("z", digits)
	}
	n--
	for i := 0; i < digits; i++ {
		name = alphabets[n%26] + name
		n /= 26
	}
	return name
	return name
}


Measured memory_bytes: 1776
#include<bits/stdc++.h>
#define N 20010
using namespace std;
int p[N],od[N];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&p[i]);
		od[p[i]-1]=i;
	}
	for(int i=0;i<n;i++){
		printf("%d ",(i+1)*n);
	}
	puts("");
	for(int i=0;i<n;i++){
		printf("%d ",(n-i)*n+od[i]);
	}
	puts("");
	return 0;
}

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

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

    int n;
    cin>>n;
    set<string> s;
    string last;
    cin>>last;
    s.insert(last);
    bool flag = true;
    for(int i = 1;i < n;i++) {
        string x;
        cin>>x;
        if(s.find(x) == s.end() && last[last.size()-1] == x[0]) {s.insert(x); last = x;}
        else {flag = false;}
    }
    if(flag) cout<<"Yes";
    else cout<<"No";
}

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



int main() {

//変数の宣言

	int nom=0,n,x,i,j,k,l;


/////メイン処理/////

	while(cin>>x){
		
		for(i=0;i<10;i++){
			for(j=0;j<10;j++){
				for(k=0;k<10;k++){
					for(l=0;l<10;l++){
						if (i+j+k+l==x){
							nom++;
							break;
						}
					}
				}
			}
		}
		
		//出力
		cout << nom << endl;
		nom = 0;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void)
{
	int i,x,y,total,small;
	int data[10];
	total=0;small=101;
	for(i=0;i<6;i++){
		scanf("%d",&data[i]);
		total+=data[i];
	}
	for(i=0;i<4;i++){
		if(data[i]<small){
			small=data[i];
		}
	}
	total-=small;
	if(data[4]<=data[5]){
		total-=data[4];
	}else{
		total-=data[5];
	}
	printf("%d\n",total);
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<stdio.h>
using namespace std;

int main() {
    bool card[4][14];
    char ch, mark;
    int x, n;
    
    for (int s = 0; s < 4; s++)
        for (int r = 1; r <= 13; r++)
            card[s][r] = 0;
            
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> ch >> x;
        if (ch == 'S') { card[0][x] = 1;}
        else if (ch == 'H') { card[1][x] = 1;} 
        else if (ch == 'C') { card[2][x] = 1;} 
        else if (ch == 'D') { card[3][x] = 1;}
    }
    for (int s = 0; s < 4; s++){
        for (int r = 1; r <= 13; r++){
            if (card[s][r]) continue;
            if (s == 0)  mark = 'S';
            else if (s == 1) mark = 'H';
            else if (s == 2) mark = 'C';
            else if (s == 3) mark = 'D';
            cout << mark << " " << r << endl;
        }
    }
    return 0;
}




Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <vector>

using namespace std;

void solve()
{
	int N;
	scanf("%d\n", &N);
	while(N--)
	{
		string s;
		getline(cin, s);
		string sbuf = s;
		sbuf += ' ';
		int n = sbuf.size();
		int start = 0;
		int end = 0;
		vector<string> Vec;
		string temp;
		for(int i = 0; i < n; ++i)
		{
			if(sbuf[i] == ' ')
			{
				if(end - start == 4)
				{
					Vec.push_back(temp);
				}
				start = end = i + 1;
				temp.clear();
				continue;
			}
			temp += sbuf[i];
			++end;
		}
		int a = 0;
		int b = 0;
		for(int i = 0; i < Vec.size(); ++i)
		{
			for(int j = 0; j < 4; ++j)
			{
				Vec[i][j] %= 26;
			}
		}
		for(int i = 0; i < 26; ++i)
		{
			for(int j = 0; j < 27; ++j)
			{
				for(int k = 0; k < Vec.size(); ++k)
				{
					string check = "asdf";
					for(int l = 0; l < 4; ++l)
					{
						check[l] = (i * Vec[k][l] + j) % 26 + 'a';
					}
					if(check == "this" || check == "that")
					{
						a = i;
						b = j;
						goto END;
					}
				}
			}
		}
END:
		n = s.size();
		for(int i = 0; i < n; ++i)
		{
			if(s[i] == ' ')
			{
				cout << s[i];
				continue;
			}
			s[i] = (a * (s[i] % 26) + b) % 26 + 'a';
			cout << s[i];
		}
		cout << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

int n, a, x[50];
long long dp[51][2501] = {};
int main(void)
{
  cin >> n >> a;
  for(int i = 0; i != n; i++){
    cin >> x[i];
    x[i] -= a;
  }
  for(int i = 0; i <= n; i++){
    for(int j = 0; j <= 2500; j++){
      if(i == 0 && j == 0){
        dp[i][j] = 1;
      }else if(i == 0){
        dp[i][j] = 0;
      }else if(j - a < 0 && j - x[i - 1] - a < 0){
        dp[i][j] = 0;
      }else if(x[i - 1] < 0 && j - a < 0){
        dp[i][j] = dp[i - 1][j - x[i - 1] - a];
      }else if(x[i - 1] > 0 && j - x[i - 1] - a < 0){
        dp[i][j] = dp[i - 1][j - a];
      }else{
        dp[i][j] = dp[i - 1][j - a] + dp[i - 1][j - x[i - 1] - a];
      }
    }
  }
  cout << dp[n][n * a] - 1 << endl;
  return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int k = sc.nextInt();

			int a = 1;

			for (int i = 1; i <= n; i++) {
				if (a < k) {
					a = a + a;
				} else {
					a = a + k;
				}
			}
			System.out.println(a);
		}
	}
}

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/e.in", "r", stdin);
//  freopen("../IO/e.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

constexpr int P = 1000'000'007;

int64_t gcd(int64_t a, int64_t b) {
  while (b != 0) {
    tie(a, b) = make_pair(b, a % b);
  }
  return a;
}

void solve(std::istream &in, std::ostream &out) {
  int n;
  in >> n;
  int z = 0;
  map<pair<int64_t, int64_t>, int> m1, m2;
  for (int i = 0; i < n; ++i) {
    int64_t x, y;
    in >> x >> y;
    if (x == 0 && y == 0) {
      ++z;
      continue;
    }
    if (y < 0) {
      x = -x;
      y = -y;
    }
    int64_t g = gcd(abs(x), abs(y));
    x /= g;
    y /= g;
    m1[{x, y}]++;
    if (x >= 0) {
      m2[{-y, x}]++;
    } else {
      m2[{y, -x}]++;
    }
  }
  vector<int> p2(1, 1);
  while (p2.size() < n + 100) {
    p2.push_back(p2.back() * 2 % P);
  }
  int64_t res = 1;
  for (auto &[x, y] : m1) {
    auto [a, b] = x;
    int64_t a1 = -b, b1 = a;
    if (b1 <= 0) {
      a1 = -a1;
      b1 = -b1;
    }
//    cout << a << ' ' << b << ": ";
    res *= (p2[y] + p2[m1[{a1, b1}]] - 1);
    res %= P;
    m1[{a1, b1}] = 0;
    m1[{a, b}] = 0;
  }
  out << (z + res + P - 1) % P << '\n';
}


Measured memory_bytes: 41304
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

lli gcd(lli a,lli b){
    if(b>a){
        swap(a,b);
    }
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
    }
}

int main(){
    lli n,k,a,b;
    vector<lli> vec,big;
    lli i,j;
    cin>>n>>k;
    rep(i,0,n){
        cin>>a;
        if(a>=k){
            big.push_back(a-k);
        }
        vec.push_back(a);
        if(i==0){
            b=a;
        }
        b=gcd(a,b);
    }
    if(big.size()==0){
        cout<<"IMPOSSIBLE"<<endl;
    }
    else{
        rep(i,0,big.size()){
            if(big[i]%b==0){
                cout<<"POSSIBLE"<<endl;
                break;
            }
            else if(i==big.size()-1){
                cout<<"IMPOSSIBLE"<<endl;
            }
        }
    }
}


Measured memory_bytes: 2036
c, flag = 0, 0
for _ in range(int(input())):
  d1, d2 = map(int, input().split())
  if d1 == d2:
    c += 1
  else:
    c = 0
  if c >= 3:
    flag = 1
if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9184
import sys
def input(): return sys.stdin.readline().rstrip()

def solve(l, r):
    lv = abs(l)
    rv = abs(r)
    if (l < 0) ^ (r < 0):
        return lv + rv + min(lv, rv)
    else:
        return max(lv, rv)

def main():
    N, K = map(int, input().split())
    x = tuple(map(int, input().split()))

    ans = 10 ** 9
    for i in range(N - K + 1):
        tmp_ans = solve(x[i], x[i + K - 1])
        if tmp_ans < ans:
            ans = tmp_ans

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15028
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

int N, a[10000];

void solve();

int main() {
	int i;
	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%d", &a[i]);
	solve();
	return 0;
}

void solve() {
	int cnt = 0, temp_cnt, i, j;
	for (i = 0; i < N; i++) {
		temp_cnt = 0;
		while (a[i] % 2 == 0) {
			temp_cnt++;
			a[i] /= 2;
		}
		cnt += temp_cnt;
	}
	printf("%d", cnt);
}

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

int N;

int main(){
    int N, C;
    cin >> N >> C;
    int** D = new int*[C];
    for(int i = 0; i < C; i ++){
        D[i] = new int[C];
        for(int n = 0; n < C; n ++){
            cin >> D[i][n];
        }
    }
    int ** c = new int*[N];
    for(int i = 0; i < N; i ++){
        c[i] = new int[N];
        for(int n = 0; n < N; n ++){
            cin >> c[i][n];
        }
    }

    int** iwakan = new int*[3];
    for(int i = 0; i < 3; i ++){
        iwakan[i] = new int[C];
        for(int n = 0; n < C; n ++){
            iwakan[i][n] = 0;
        }
        for(int currentC = 0; currentC < C; currentC ++){
            int keisuu = 0; 
            while(keisuu * 3 + i <= N * 2){
                for(int x = 1; x < keisuu * 3 + i; x ++){
                    if(x > N){
                        continue;
                    }
                    int y = keisuu * 3 + i - x;
                    if(y > N || y < 1){
                        continue;
                    }
                    iwakan[i][currentC] += D[c[x - 1][y - 1] - 1][currentC];
                }
                keisuu ++;
            }
        }
    }
    
    
    
    long result = 500*500*1000;

    for(int c0 = 0; c0 < C; c0++){
        for(int c1 = 0; c1 < C; c1++){
            if(c1 == c0){
                continue;
            }
            for(int c2 = 0; c2 < C; c2++){
                if(c2 == c1 || c2 == c0){
                    continue;
                }
                int currentIwakan = iwakan[0][c0] + iwakan[1][c1] + iwakan[2][c2];
                if(currentIwakan < result){
                    result = currentIwakan;
                }
            }
        }
    }
    
    cout << result << endl;  

    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,n;
	cin >> n >> a;
	if(n>=500){
		n = n%500;
		if(a>=n)cout << "Yes";
		else cout << "No";
	}
	else if(a>=n)cout << "Yes";
	else cout << "No" ;
	return 0;

}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()
#define ADD(a, b) a = (a + b) % MOD

int main()
{
  int N;
  cin >> N;
  ll dp[101][4][4][4] = {};
  dp[0][0][0][0] = 1;      // 初期状態の直近3文字をTTTとみなす
  int A = 1, C = 2, G = 3; // T = 0
  REP(i, N)
  REP(a, 4)
  REP(b, 4)
  REP(c, 4)
  REP(d, 4)
  {
    // NGパターンを除外
    if (b == A && c == C && d == G) // ...ACG
      continue;
    if (b == A && c == G && d == C) // ...AGC
      continue;
    if (b == G && c == A && d == C) // ...GAC
      continue;
    if (a == A && c == G && d == C) // ...A?GC
      continue;
    if (a == A && b == G && d == C) // ...AG?C
      continue;
    ADD(dp[i + 1][b][c][d], dp[i][a][b][c]);
  }
  ll ans = 0;
  REP(i, 4)
  REP(j, 4)
  REP(k, 4)
  ADD(ans, dp[N][i][j][k]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
W, H, N = map(int, input().split())
ARR = []
for i in range(N):
    ARR.append(list(map(int, input().split())))


def calculate(w, h, n, arr):
    minX = 0
    minY = 0
    maxX = w
    maxY = h

    for i in range(n):
        x = arr[i][0]
        y = arr[i][1]
        type = arr[i][2]

        if type == 1:
            minX = max(minX, x)
            continue

        if type == 2:
            maxX = min(maxX, x)
            continue

        if type == 3:
            minY = max(minY, y)
            continue

        if type == 4:
            maxY = min(maxY, y)
            continue

    s1 = max(0, maxX - minX)
    s2 = max(0, maxY - minY)

    print(s1 * s2)


calculate(W, H, N, ARR)


Measured memory_bytes: 9236
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+1000;
const ll INF=1e9+7;
inline ll read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
ll n,m;
map<string,int>mp;
map<int,string>re;
void restart()
{
    mp["Sunny"]=1;
    mp["Cloudy"]=2;
    mp["Rainy"]=0;
    re[0]="Rainy";
    re[1]="Sunny";
    re[2]="Cloudy";
}
int main()
{
    restart();
    string s;
    cin>>s;
    if(s=="Sunny") cout<<"Cloudy"<<endl;
    if(s=="Cloudy") cout<<"Rainy"<<endl;
    if(s=="Rainy") cout<<"Sunny"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=998244353;
#define INF 1e9+7
#define N 310000
#define MAX_V 400010
#define vec vector<int>
using namespace std;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<ll,int,custom_hash>
struct pair_hash
{
    template<class T1,class T2>
    size_t operator() (const pair<T1,T2> &p)const{
        return hash<T1>()(p.first)^hash<T2>()(p.second);
    }
};
main(){
    int n;
    cin>>n;
    if(n==1){cout<<"Yes\n";
             cout<<"2\n";
             cout<<"1 1\n";
             cout<<"1 1\n";
             return 0;
            }
    int t=-1;
    for(ll i=1;i<=n;i++){
        if(i*(i-1)/2==n){
            t=i;break;
        }
    }
    if(t==-1){cout<<"No";return 0;}
    cout<<"Yes\n";
    vector<int> v[N];
    int now=1;
    rep(i,n){
        bool flag=false;
        rep2(j,i+1,t-1){
            v[i].pb(now);
            v[j].pb(now);
            now++;
            if(now>n)flag=true;
        }
        if(flag) break;
    }
    cout<<t<<endl;
    rep(i,t){
        cout<<v[i].size()<<" ";
        rep(j,v[i].size()){
            cout<<v[i][j]<<" ";
        }
        cout<<endl;
    }
    
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#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;

int a, b, h;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> a >> b >> h;
	cout << (a+b)*h/2 << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, w int
	fmt.Scan(&N)
	m := map[int]int{}
	var a []int
	for i := 0; i < N; i++ {
		fmt.Scan(&w)
		m[w]++
	}
	for k, v := range m {
		if v >= 2 {
			for i := 0; i < v/2; i++ {
				a = append(a, k)
			}
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	if len(a) > 1 {
		fmt.Println(a[0] * a[1])
	} else {
		fmt.Println(0)
	}
}

Measured memory_bytes: 8624
n, k = [int(i) for i in input().split(' ')]
P = [int(i) for i in input().split(' ')]

temp = sum(P[:k])
res = temp
for i in range(n- k):
  temp -= P[i]
  temp += P[i+k]
  res = max(res, temp)
  
ans = (res + k) * 0.5

print(ans)


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

int p, cr[10], cc[10], cs[10], sp[10];
vector<int> v;

bool check(int r, int c, int s){
	for(int i = 0; i < p; ++i){
		if(cr[i] * r + cc[i] * c + cs[i] * s != sp[i])
			return false;
	}
	return true;
}

void count(const string &t, int &r, int &c, int &s){
	for(int i = 0; i < t.size(); ++i){
		switch(t[i]){
		case '(': ++r; break;
		case ')': --r; break;
		case '{': ++c; break;
		case '}': --c; break;
		case '[': ++s; break;
		case ']': --s; break;
		default: break;
		}
	}
}

int ans(int r, int c, int s){
//cout<<"r: "<<r<<"\tc: "<<c<<"\ts: "<<s<<'\n';
	int a = -1;
	for(int i = 0; i < v.size(); ++i){
		int b = r * (v[i] & 31) + c * (v[i] >> 5 & 31) + s * (v[i] >> 10);
		if(a == -1) a = b;
		else if(a != b) return -1;
	}
	return a;
}

int main(){
	int q;
	string t;
	while(cin >> p >> q, p){
		int r = 0, c = 0, s = 0;
		for(int i = 0; i < p; ++i){
			cin >> t;
			sp[i] = t.find_first_not_of(".");
			cr[i] = r;
			cc[i] = c;
			cs[i] = s;
			count(t, r, c, s);
		}
		
		v.clear();
		for(r = 1; r <= 20; ++r)
		for(c = 1; c <= 20; ++c)
		for(s = 1; s <= 20; ++s){
			if(check(r, c, s)){
				v.push_back(r | c << 5 | s << 10);
			}
		}
		
		r = c = s = 0;
		for(int i = 0; i < q; ++i){
			if(i != 0) cout << ' ';
			cout << ans(r, c, s);
			cin >> t;
			count(t, r, c, s);
		}
		cout << '\n';
	}
}

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

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>> R(H, vector<char>(W));

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> R.at(i).at(j);
		}
	}

	int k;
	for (int i = 0; i < H; i++) {
		k = 0;
		for (int j = 0; j < W; j++) {
			if (R.at(i).at(j) == '.') {
				k++;
			}
			else {
				break;
			}
		}
		if (k == W) {
			R.erase(R.begin() + i);
			H--;
			i--;
		}
	}


	for (int i = 0; i < W; i++) {
		int k = 0;
		for (int j = 0; j < H; j++) {
			if (R.at(j).at(i) == '.') {
				k++;
			}
			else {
				break;
			}
		}
		if (k == H) {
			for (int j = 0; j < H; j++) {
				R.at(j).erase(R.at(j).begin() + i);
			}
			W--;
			i--;
		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << R.at(i).at(j);
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;
typedef long long ll;

int main(){
  int H, W;


  while(cin>>H>>W && H!=0 && W!=0){
    for(int i=0; i<H; i++){
      for(int j=0; j<W; j++){
        if(i!=0 && i!=H-1 && j!=0 && j!=W-1){
          cout<<".";
        }else{
          cout<<"#";
        }

        }
        cout<<endl;
      }
      cout<<endl;
    }
}

Measured memory_bytes: 3004
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
#define pb push_back
#define eb emplace_back
const  int MAX=1000000;
ll m[MAX+10];

int main()
{
     ll n;

     cin>>n;

     ll a[n+2];

     for(ll i=0;i<n;i++)cin>>a[i];

     sort(a,a+n);

     for(ll i=0;i<n;i++)
     {
         if(i>0 && a[i]==a[i-1])
         {
             m[a[i]]++;
             continue;
         }

         for(ll j=a[i];j<=MAX;j+=a[i])
         {
             m[j]++;
         }
     }

     ll cnt=0;

     for(ll i=0;i<n;i++)
     {
         if(m[a[i]]==1)cnt++;
     }

     cout<<cnt<<endl;

}




Measured memory_bytes: 12880
#include<bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define lli long long int
#define pb push_back
#define pob pop_back
#define rep(i,a,b) for(lli i=a;i<b;i++)
#define repv(a,b) for(int i=a;i>=b;i--)
#define itr vector<lli> :: iterator
#define maximum(a,b,c)  max(a,max(b,c))
#define minimum(a,b,c) min(a,min(b,c))
#define tim clock_t
#define fs first
#define sc second
inline void fast()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

void solve()
{
	lli n,k,ctr=0,m=0,x,y;
    cin>>x>>y;
    if(x>=1 && x<=9 && y>=1 && y<=9)
    	cout<<x*y;
       else
       	cout<<"-1";
}

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

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, k: usize,
        mut p: [i64; n]
    }
    p.sort();
    let ans = p.iter().take(k).sum::<i64>();
    println!("{}", ans);
}


Measured memory_bytes: 2188
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int a,k=0;
  cin >> a;
  int p=10,q=1;
  for(int i=0; i<9; i++){
    k += (a%p - a%q)/q;
    p *= 10; q *= 10;
  }
  if(a%k==0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define mem(x,y)		(x*)malloc(sizeof(x)*(y))

int int_sort(const void* a,const void* b)
{
	if(*(int *)a < *(int *)b)
	{
		return -1;
	}
	else if(*(int *)a == *(int *)b)
	{
		return 0;
	}
	return 1;
}

int* search(int point,int* list,int len,int max)
{
	double i = len/2.0;
	double size = len/2.0;
	int maxp = 0;
	int* data = mem(int,2);
	while(1)
	{
		const int pt = point+list[(int)i];
		if(pt > max)
		{
			if(size < 0.5)
			{
				break;
			}
			else
			{
				size/=2.0;
				i-=size;
			}
		}
		else
		{
			if(maxp < pt)
				maxp = pt;
			if(size < 0.5)
			{
				break;
			}
			else
			{
				size/=2.0;
				i+=size;
			}
		}
	}
	data[0] = maxp;
	data[1] = (int)i;
	return data;
}

int main()
{
	int n,m;
	int* data;
	int* list;
	int i,j,k;
	while(scanf("%d %d",&n,&m),n,m)
	{
		int list_len = (n+1)*(n+1);
		data = mem(int,n+1);
		list = mem(int,list_len);
		data[0] = 0;
		for(i = 1;i <= n;i++)
		{
			scanf("%d",&data[i]);
		}
		for(k = i = 0;i <= n;i++)
		{
			for(j = 0;j <= i;j++,k++)
			{
				list[k] = data[i]+data[j];
			}
		}
		list_len = k+1;
		qsort(list,list_len,sizeof(int),int_sort);
		int max = 0;
		int ll_tmp = list_len;
		for(i = 0;i<ll_tmp;i++)
		{
			int* val = search(list[i],list,ll_tmp,m);
			if(val[0] > max)
			{
				max = val[0];
			}
			ll_tmp = val[1]+1;
		}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 0
package main

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

func main() {
	t := nextIntArray()
	sx, sy, tx, ty := t[0], t[1], t[2], t[3]
	dx := tx - sx
	dy := ty - sy
	route := ""
	route += strings.Repeat("U", dy)
	route += strings.Repeat("R", dx)
	route += strings.Repeat("D", dy)
	route += strings.Repeat("L", dx)
	route += "L"
	route += strings.Repeat("U", dy+1)
	route += strings.Repeat("R", dx+1)
	route += "D"
	route += "R"
	route += strings.Repeat("D", dy+1)
	route += strings.Repeat("L", dx+1)
	route += "U"
	fmt.Println(route)
}

const size = 1000000

var reader = bufio.NewReaderSize(os.Stdin, size)

func nextLine() string {
	var line, buffer []byte
	isPrefix := true
	var err error
	for isPrefix {
		line, isPrefix, err = reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
	}
	return string(buffer)
}
func nextStringArray() []string {
	return strings.Split(nextLine(), " ")
}
func nextInt() int {
	n, _ := strconv.Atoi(nextLine())
	return n
}
func nextIntArray() []int {
	s := strings.Split(nextLine(), " ")
	n := len(s)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}

func min(i, j int) int {
	if i > j {
		return j
	}
	return i
}


Measured memory_bytes: 896
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v), std::end(v)
#define REP(i, k) for (decltype(k) i = 0; i < k; i++)
#define LOOP(k) REP (ngtkana_is_a_genius, k)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/
auto cmn = [](auto& x, auto y){ if (x>y) { x=y; return true; } return false; };
int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    usize n; i64 E, T; std::cin >> n >> E >> T;
    vec<i64> a(n+1);
    for (usize i=1; i<=n; i++) std::cin >> a.at(i);

    i64 inf = numr<i64>::max();
    i64 min = inf;
    vec<i64> dp(n+1, inf);
    dp.at(0) = 0;
    for (usize l=0, j=1; j<=n; j++) {
        for (; T < 2 * (a.at(j) - a.at(l+1)); l++) {
            cmn(min, dp.at(l) - 2 * a.at(l + 1));
        }
        if (l) cmn(dp.at(j), min + 2 * a.at(j));
        cmn(dp.at(j), dp.at(l) + T);
    }

    i64 ans = dp.at(n) + E;
    std::cout << ans << '\n';
}


Measured memory_bytes: 1920
#include<stdio.h>

int main(){
    int a, b, total, i, digits=0;

    while(scanf(" %d %d", &a, &b) != EOF){
        total = a + b;

        for(i=1; i<=total; i*=10){
            digits++;
        }
        printf("%d\n", digits);

        digits = 0;
    }

    return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
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++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    ll ma = a.back();
    a.pop_back();
    rep(i, n-1){
        a[i] *= 2;
    }
    ll res = INF;
    rep(i, n-1){
        if(abs(ma-a[i]) < abs(ma-res)){
            res = a[i];
        }
    }

    cout << ma << " " << res/2 << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 5120
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<sstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int>PII;
typedef pair<ll,ll>PLL;
#define make_pair mkp;

const int maxn=1e5+10;

int main(){
	priority_queue<ll>a,b,c;
	int x,y,A,B,C;
	cin>>x>>y>>A>>B>>C;
	for(int i=0;i<A;i++){
		ll num;
		cin>>num;
		a.push(num);
	}
	for(int i=0;i<B;i++){
		ll num;
		cin>>num;
		b.push(num);
	}
	for(int i=0;i<C;i++){
		ll num;
		cin>>num;
		c.push(num);
	}
	int cnt;
	if(a.size()<x){
		while(!a.empty()){
			ll v=a.top();
			a.pop();
			c.push(v);
		}
	}else{
		cnt=0;
		while(cnt<x){
			ll v=a.top();
			a.pop();
			c.push(v);
			cnt++;
		}
	}
	if(b.size()<y){
		while(!b.empty()){
			ll v=b.top();
			b.pop();
			c.push(v);
		}
	}else{
		cnt=0;
		while(cnt<y){
			ll v=b.top();
			b.pop();
			c.push(v);
			cnt++;
		}
	}
	ll res=0;
	cnt=0;
	while(cnt<x+y){
		ll v=c.top();
		c.pop();
		cnt++;
		res+=v;
	}
	cout<<res<<endl;
	return 0;

}

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

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

    int a, b;
    cin >> a >> b;
    cout << a * b << endl;

    return 0;
}

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

typedef long long ll;

using namespace std;
int main() {
	string S;
	cin >> S;
	if (S[6] > '4' || S[5] == '1') {
		cout << "TBD" << endl;
	}
	else {
		cout << "Heisei" << endl;
	}
}

Measured memory_bytes: 256