akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 200005;
 

typedef long long ll;

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
	ll n;
	cin >> n;
	n %= 10;
	if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9) cout << "hon" <<endl;
	else if(n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
	else if(n == 3) cout << "bon" <<endl;
  return 0;
}

/*
         ,--"""",--.__,---[],-------._         
       ,"   __,'            \         \--""""""==;-
     ," _,-"  "/---.___     \       ___\   ,-'',"
    /,-'      / ;. ,.--'-.__\  _,-"" ,| `,'   /
   /``""""-._/,-|:\       []\,' ```-/:;-. `. /
             `  ;:::      ||       /:,;  `-.\
                =.,'__,---||-.____',.=
                =(:\_     ||__    ):)=
               ,"::::`----||::`--':::"._
             ,':::::::::::||::::::::::::'.
    .__     ;:::.-.:::::__||___:::::.-.:::\     __,
       """-;:::( O )::::>_|| _<::::( O )::::-"""
   =======;:::::`-`:::::::||':::::::`-`:::::\=======
    ,--"";:::_____________||______________::::""----.          , ,
         ; ::`._(    |    |||     |   )_,'::::\_,,,,,,,,,,____/,'_,
       ,;    :::`--._|____[]|_____|_.-'::::::::::::::::::::::::);_
      ;/ /      :::::::::,||,:::::::::::::::::::::::::::::::::::/
     /; ``''''----------/,'/,__,,,,,____:::::::::::::::::::::,"
     ;/                :);/|_;| ,--.. . ```-.:::::::::::::_,"
    /;                :::):__,'//""\\. ,--.. \:::,:::::_,"
   ;/              :::::/ . . . . . . //""\\. \::":__,"
   ;/          :::::::,' . . . . . . . . . . .:`::\
   ';      :::::::__,'. ,--.. . .,--. . . . . .:`::`
   ';   __,..--'''-. . //""\\. .//""\\ . ,--.. :`:::`
   ;    /  \\ .//""\\ . . . . . . . . . //""\\. :`::`
   ;   /       . . . . . . . . . . . . . . . . .:`::`
   ;   (          . . . . . . . . . . . . . . . ;:::`
   ,:  ;,            . . . . . . . . . . . . . ;':::`
   ,:  ;,             . . . . . . . . . . . . .;`:::
   ,:   ;,             . . . . . . . . . . . . ;`::;`
    ,:  ;             . . . . . . . . . . . . ;':::;`
     :   ;             . . . . . . . . . . . ,':::;
      :   '.          . . . . . . . .. . . .,':::;`
       :    `.       . . . . . . . . . . . ;::::;`
        '.    `-.   . . . . . . . . . . ,-'::::;
          `:_    ``--..___________..--'':::::;'`
             `._::,.:,.:,:_ctr_:,:,.::,.:_;'`
________________`"\/"\/\/'""""`\/"\/""\/"____________________________
 
*/


Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}

double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}

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


/////////////////////////////////////////////////////////////////////////////////////

int N, M, Q;
int A[11];
int a[50], b[50], c[50], d[50];

int ans = 0;

void dfs(int n){
    if (n == N){
        int sum = 0;
        for (int i = 0;i < Q;i++){
            if (A[b[i]] - A[a[i]] == c[i]){
                sum += d[i];
            }
        }

        ans = max(ans, sum);
        return;
    }

    for (int i = min(A[n], M);i <= M;i++){
        A[n+1] = i;
        dfs(n+1);
    }
}

int main(){
    cin >> N >> M >> Q;
    for (int i = 0;i < Q;i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    A[0] = 1;
    dfs(0);
    cout << ans << endl;
    return 0;
}

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

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

int vec_gcd(vector<int> values){
    int ans = values[0];
    for(int i = 0; i < values.size(); i++){
        ans = gcd(ans, values[i]);
    }

    return ans;

}

int main(){
    int n;
    cin >> n;
    vector<int> values(n);

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

    int max_divide = vec_gcd(values);

    int count = 0;
    while(max_divide > 0){
        if(max_divide % 2 == 0){
            count++;
        } 
        max_divide /= 2;
    }

    cout << count << endl;

}

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

using namespace std;
typedef long long ll;

int main() {
  string s;
  cin>>s;
  map<char,int> mp;
  for (int i = 0; i < s.size(); i++) {
    mp[s[i]]++;
  }
  if (mp.size() != 2) cout<<"No"<<endl;
  else {
    bool ok = true;
    for (auto p : mp) {
      if (p.second != 2) ok = false;
    }
    if (ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> v(h);
  
  string enclosure = "";
  for (int i = 0; i < w + 2; i++) {
  	enclosure += "#";
  }
  cout << enclosure << endl;
  
  for (int i = 0; i < h; i++) {
    cin >> v[i];
    cout << "#" << v[i] << "#" << endl;
  }
  
  cout << enclosure << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
 string a,b;
  cin>>a>>b;
  string c=a+b;
  int num = stoi(c);
  bool A=false;
  for(int i=1;i<317;i++){
  if( num == i * i){A=true;break;}
  }
  if(A) cout<<"Yes"<<endl;
  else cout <<"No" <<endl;
  
}

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

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

Measured memory_bytes: 256
from collections import defaultdict
H, W = map(int, input().split())
A = [list(input()) for i in range(H)]

D = defaultdict(int)
for i in range(H):
    for j in range(W):
        D[A[i][j]] += 1

Mod4 = [0, 0, 0, 0]
for d in D:
    Mod4[D[d] % 4] += 1

if H%2 == W%2 == 0:
    if Mod4[1] == Mod4[2] == Mod4[3] == 0: print("Yes")
    else: print("No")
elif H%2 == 0:
    if Mod4[2] <= H//2 and Mod4[1] == Mod4[3] == 0: print("Yes")
    else: print("No")
elif W%2 == 0:
    if Mod4[2] <= W//2 and Mod4[1] == Mod4[3] == 0: print("Yes")
    else: print("No")
else:
    if Mod4[1] == 1 and Mod4[3] == 0 and Mod4[2] <= (H+W-1)//2: print("Yes")
    elif Mod4[1] == 0 and Mod4[3] == 1 and Mod4[2] <= (H+W-3)//2: print("Yes")
    else: print("No")

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define ll long long

using namespace std;

long long mod = 1e9 + 7;

long long powerr(long long x, long long y)  
{  
    long long res = 1; 
  
    x = x % mod;
   
    if (x == 0) 
        return 0;
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % mod;  
        y = y>>1; 
        x = (x*x) % mod;  
    }  
    return res;  
}  

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int N;
    cin >> N;
    
    long long ret = powerr(10, N);

    long long tmp = powerr(9, N);
    ret = (ret - tmp) % mod;
    if(ret < 0)
        ret += mod;

    ret = (ret - tmp) % mod;
    if(ret < 0)
        ret += mod;

    ret = (ret + powerr(8, N)) % mod;

    cout << ret << endl;

    return 0;
}




Measured memory_bytes: 3608
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type box struct {
	balls int
	red   int
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, m := nextInt(), nextInt()

	boxes := make([]box, n+1)
	for i := range boxes {
		boxes[i].balls = 1
	}
	boxes[1].red = 1

	for j := 0; j < m; j++ {
		x, y := nextInt(), nextInt()
		boxes[y].balls++
		if boxes[x].red == 1 {
			boxes[y].red = 1
		}
		boxes[x].balls--
		if boxes[x].balls == 0 {
			boxes[x].red = 0
		}
	}

	ans := 0
	for _, b := range boxes[1:] {
		ans += b.red
	}
	fmt.Println(ans)
}


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

typedef long long i64;

i64 a, b, c;

void Solve()
{
  // √a + √b > √c
  // a + 2√ab + b > c
  // 2√ab > (c - a - b)
  // 4ab > (c - a - b) ^ 2

  i64 left = 4 * a * b;
  i64 cab = c - a - b;
  i64 right = cab * cab;

  if (cab < 0){
    puts("No");
    return;
  }
  
  if (left < right)
    puts("Yes");
  else
    puts("No");
}

void Init()
{
  cin >> a >> b >> c;
}

void Clean(){}

int main(){ Init(); Solve(); Clean(); return 0; }


Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int inf = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

pii b[N];

signed main(){
    IOS;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
    	int a;
    	cin >> a;
    	b[i].fi = a; b[i].se = i + 1;
    }
    sort(b, b + n);
    for (int i = 0; i < n; i++)
    	cout << b[i].se << " ";
    return 0;
}

Measured memory_bytes: 2432
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cmath>
#include<algorithm>
#include<functional>
typedef long long ll;
#define INF 99999999

int main() {
	int n = 0, num = 0, find = 0;
	int ar[100000] = {};
	int ans = 0, count = 0;
	std::vector<int> num_t;
	std::map<int, int> m;
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> num;
		ar[i] = num;
		if (m[num] == 0) {
			num_t.emplace_back(num);
		}
		m[num]++;
	}
	for (int i = 0; i < num_t.size(); i++) {
		find = num_t[i];
		count = m[find + 1] + m[find - 1] + m[find];
		ans = std::max(count, ans);
		count = 0;
	}
	std::cout << ans << std::endl;
}

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

int main(){
		int A,B,C,X; cin>>A>>B>>C>>X;
		int ans=0;
		for(int i=0;i<=A;++i){
				for(int j=0;j<=B;++j){
						for(int k=0;k<=C;++k){
								if(500*i+100*j+50*k==X) ++ans;
						}
				}
		}
		cout<<ans<<endl;
		return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const double pi=acos(-1);
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<MOD>;

mint calc(long long N, long long K) {
    mint res = 1;
    for (long long n = 0; n < K; ++n) {
        res *= (N - n);
        res /= (n + 1);
    }
    return res;
}
int main() {
//cout << fixed << setprecision(12);
ll n,k;
cin>>n>>k;
ll r;
priority_queue<ll> a;
rep(i,n){
cin>>r;
a.push(r);}
rep(i,k){
ll q = a.top();
a.pop();
q/=2;
a.push(q);}
ll ca=0;
rep(i,n){
r=a.top();
ca+=r;
a.pop();}
cout << ca << endl;}


Measured memory_bytes: 4320
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
signed main()
{
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	int cnt = 0;
	for (int i = 1; i <= b - a; i++) {
		cnt += i;
	}
	cout << cnt - b;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    readLine()!!
            .fold(' ' to 0) { acc, c ->
                if (acc.first != c) {
                    c to acc.second + 1
                } else {
                    acc
                }
            }
            .let { print(it.second) }
}


Measured memory_bytes: 36952
x1,y1,x2,y2=map(int,input().split())
dx,dy=x2-x1,y2-y1
ans=""
x3,y3=x2-dy,y2+dx

ans+=str(x3)+" "
ans+=str(y3)+" "
dx,dy=x3-x2,y3-y2
x4,y4=x3-dy,y3+dx
ans+=str(x4)+" "
ans+=str(y4)+" "
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <cassert>
#include <sstream>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)
#define rrep(i, a) RREP(i, a, 0)
#define RREP(i, a, b) for(int i = a; i >= b; --i)
#define repll(i, a) REPLL(i, 0, a)
#define REPLL(i, a, b) for(ll i = a; i < b; ++i)
#define rrepll(i, a) RREPLL(i, a, 0)
#define RREPLL(i, a, b) for(ll i = a; i >= b; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<int, P> PP;
const double PI = 3.14159265358979323846;
const double eps = 1e-9;
const int infi = (int)1e+9 + 7;
const ll infll = (ll)1e+17 + 7;

const int size = 100005;

std::string s;
int f[4];

int main() {
	std::cin >> s;

	rep(i, s.size()) {
		if (s[i] == 'N')f[0] = 1;
		if (s[i] == 'W')f[1] = 1;
		if (s[i] == 'S')f[2] = 1;
		if (s[i] == 'E')f[3] = 1;
	}


	if ((f[0] + f[1] + f[2] + f[3]) % 2 == 0 && ((f[0] && f[1] && f[2] && f[3]) || (f[0] && f[2]) || (f[1] && f[3])))std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;

	return 0;
}

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

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  if (A.back() == B.front() && B.back() == C.front()) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int H,W;
vector<string> A;
void input(){
    fast_io();
    cin >> H >> W;
    for (int i = 0; i < H; i++)
    {
        string s; cin >> s;
        A.push_back(s);
    }
}

bool solve(){
    map<char,int> cnt;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cnt[A[i][j]]++;
        }
    }
    int four = 0, two = 0, one = 0;
    for (char c = 'a'; c <= 'z'; c++)
    {
        four+= cnt[c]/4;
        two += (cnt[c]%4)/2;
        one += (cnt[c]%4)%2;
    }
    
    if(H%2==0 && W%2==0){
        four -= (H/2)*(W/2);
        if(one!=0 || two!=0 || four!=0) return false;
    }
    else if(H%2!=0 && W%2==0){
        // 全部2の倍数
        two -= W/2;
        four -= (H/2)*(W/2);
        if(two<0) {four += two/2; two = 0;}
        if(one!=0 || two!=0 || four!=0) return false;
    }
    else if(H%2==0 && W%2!=0){
        // 全部2の倍数
        two -= H/2;
        four -= (H/2)*(W/2);
        if(two<0) {four += two/2; two = 0;}
        if(one!=0 || two!=0 || four!=0) return false;
    }
    else{
        one--;
        two -= (H/2)+(W/2);
        four -= (H/2)*(W/2);
        if(two<0) {four += two/2; two = 0;}
        if(one!=0 || two!=0 || four!=0) return false;
    }
    return true;
}   

int main()
{
    input();
    cout << (solve()?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

int main(){
    string S;
    cin >> S;
    int s=S.size();
    if (S[0]!=S[s-1]){
        if (s%2==0){
            cout << "Second" << endl;
        }
        else {
            cout << "First" << endl;
        }
    }
    else {
        if (s%2==0){
            cout << "First" << endl;
        }
        else {
            cout << "Second" << endl;
        }
    }
}

Measured memory_bytes: 512
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let a: usize = it.next().unwrap().parse().unwrap();
    let b: usize = it.next().unwrap().parse().unwrap();
    let mut ans = String::new();
    if a <= b {
        for _ in 0..b {
            ans.push_str(&format!("{}", a));
        }
    } else {
        for _ in 0..a {
            ans.push_str(&format!("{}", b));
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 4352
/*Arnab's Code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define vii vector<int>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define take(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define takes(a,n,st) for(ll i=st;i<n+st;i++)cin>>a[i]
ll a[1017];
ll sum(ll a[],ll n,ll s){ for(ll i=0;i<n;i++)s+=a[i]; return s;}
#define mod 1000000009
ll power(ll x, ll y, ll p)  {  
    ll res = 1;  
    x = x % p;   
    if (x == 0) return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
void solve(){
	ll n,k;
	cin>>n>>k;
	take(a,n);
	sort(a,a+n);
	cout<<sum(a,k,0);
	return;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ll t,T;
//	cin>>T;
	T=1;
	for(t=1;t<=T;t++){
//		cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
template <typename T> T read() { T a; cin >> a; return a; }

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  auto s = read<string>();
  for (auto c : s) cout << (c == '?' ? 'D' : c);
  return 0;
}


Measured memory_bytes: 3772
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;


int main()
{
	double a, b, x;
	cin >> a >> b >> x;

	auto result = 0.0;
	if (a * a * b >= x * 2)
	{
		auto h = x * 2 / b / a;
		result = 90.0 - atan2(h, b) * 180 / M_PI;
	}
	else
	{
		auto r = a * a * b - x;
		auto h = r * 2 / a / a;
		result = atan2(h, a) * 180 / M_PI;
	}

	cout << setprecision(10) << result << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, w; cin >> n >> w;
    VI wei(n); VL val(n);
    FOR(i, 0, n)cin >> wei[i] >> val[i];

    auto dp = vec<ll>(n + 1, w + 1);
    FOR(i, 0, n)eFOR(j, 0, w) {
        chmax(dp[i + 1][j], dp[i][j]);
        if (w < j + wei[i])continue;
        chmax(dp[i + 1][j + wei[i]], dp[i][j] + val[i]);
    }

    cout << dp[n][w] << "\n";
}


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

int main() {
  int a, b;
  
  cin >> a >> b ;
  
  if ( a * b % 2 == 1 ) {
    cout << "Odd" << endl;
  }
  else if ( a * b % 2 == 0 ) {
    cout << "Even" << endl;
  }
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(int i=a; i<b; i++)
#define loopb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
// use to avoid collision
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);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli power(lli x, lli y, lli p){
    lli 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 main(){
	fastio;
	lli n;
	cin>>n;
	string s;
	cin>>s;
	s.push_back('.');
	lli count = 0;
	loop(i, 0, n){
		if(s[i] == s[i+1])
			continue;
		else
			count++;
	}
	cout<<count<<"\n";
}


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

using namespace std;

#define MOD 1000000007
#define deb(x) cout << #x << " = " << x << endl
#define deb2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.1415926535897932384626

typedef long long ll;

void solve()
{
    
}

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int moves=0;
    while(b<=a)b*=2,moves++;
    while(c<=b)c*=2,moves++;

    if(moves<=k)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3660
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int len = Integer.parseInt(sc.nextLine());
		int[] price = Stream.of(sc.nextLine().split(" ", 0)).mapToInt(Integer::parseInt).toArray();

		long money = 1000;
		long stocks = 0;

		for (int i = 1; i < len; i++) {
			if (price[i] > price[i - 1]) {
				stocks = money / price[i - 1];
				money =  money % price[i - 1] + stocks * price[i];
			}
		}

		System.out.println(money);
	}

}

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

int main() {
    ll x;
    cin >> x;

    ll a = x / 500;
    ll b = (x-a*500) / 5;

    cout << a*1000 + b*5 << endl;

    return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
bool test = 0;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5

int main() {
	ll i, j, k, l;
	int N;
	cin >> N;
	int sum = 0;
	rep(i, N) {
		sum += i+1;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int ans;
  int zero=0,one=0;
  string s;
  cin>>s;
  rep(i,s.size() ){
    if(s[i]=='0') zero++;
    else one++;
  }
  cout<<min(one,zero)*2<<endl;

  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>


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

	std::cin >> a >> b >> c;

	int ans = std::max(0, c - (a - b));

	std::cout << ans;

	return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char *argv[])
{
	string s;
	cin >> s;
	map<char,int> mp;
	for (auto c : s) {
		mp[c]++;
	}
	for (auto i : mp) {
		if (i.second > 1) {
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
	return 0;
}


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

using namespace std;

int main(){
	int A, B;
  	cin >> A >> B;
  	int sum = A;
  	int count = 1;
  	if(B == 1) count = 0;
  	else {
      while(sum < B){
          sum += A-1;
          count++;
      }
    }
  	cout << count << endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

struct S{
  ll x;
  ll v;
};


const int MAX_N = 112345;
struct RMQStatic {
  ll *a;
  ll dp_max[20][MAX_N];

  int log2(int b) {return 31 - __builtin_clz(b);}

  // O(NlogN)
  void build(ll* a, int N) {
    this->a = a;
    int M = log2(N) + 1;
    REP(i, N) dp_max[0][i] = i;
    for (int i = 1, len = 1; i < M; i++, len <<= 1) {
      for (int j = 0; j + len < N; j++) {
        {
          ll s = dp_max[i - 1][j];
          ll t = dp_max[i - 1][j + len];
          dp_max[i][j] = a[s] >= a[t] ? s : t;
        }
      }
    }
  }

  ll get_max(int from, int to) {
    int k = log2(to - from + 1);
    ll s = dp_max[k][from];
    ll t = dp_max[k][to - (1 << k) + 1];
    return a[s] >= a[t] ? s : t;
  }

};


ll A[MAX_N];
ll B[MAX_N];
RMQStatic rmqA, rmqB;

ll solve(vector<S> ss, ll C) {
  const int N = ss.size();

  {
    A[0] = 0;
    ll got = 0;
    REP(i, N) {
      got += ss[i].v;
      A[i+1] = got - ss[i].x;
    }
  }
  {
    B[N] = 0;
    ll got = 0;
    for (int i = N - 1; i >= 0; i--) {
      got += ss[i].v;
      B[i] = got - 2LL*(C - ss[i].x);
    }
  }

  rmqA.build(A, N+1);
  rmqB.build(B, N+1);

  ll ans = 0;
  for (int i = 0; i <= N; i++) {
    ll p = A[ rmqA.get_max(0, i) ];
    ll q = B[ rmqB.get_max(i, N) ];
    chmax(ans, p + q);
  }
  return ans;
}

int main2() {
  int N = nextInt();
  ll C = nextLong();
  vector<S> ss(N);
  REP(i, N) {
    ss[i].x = nextLong();
    ss[i].v = nextLong();
  }
  ll ans1 = solve(ss, C);
  REP(i, N) ss[i].x = C - ss[i].x;
  sort(ALL(ss), [](const S&a, const S&b) -> bool {
    return a.x < b.x;
  });
  ll ans2 = solve(ss, C);
  ll ans = 0;
  chmax(ans, ans1);
  chmax(ans, ans2);
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 38016
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
void solve()
{
    int n;
    cin>>n;
    pair<int,int> arr[n];
    for(int i=0;i<n;i++)
    {
    cin>>arr[i].ff>>arr[i].ss;
    }
    int maxi=INT_MIN,mini=INT_MAX;
    sort(arr,arr+n);
    int i=0;
    int prev=arr[0].ff;
    int ans=0;
    while(i<n)
    {
        int j=i;
        int cm=INT_MIN,cmi=INT_MAX;
        while(i<n&&arr[i].ff==arr[j].ff)
        {
            cm=max(arr[i].ss,cm);
            cmi=min(cmi,arr[i].ss);
            i++;
        }
        maxi=max(maxi+arr[j].ff-prev,cm);
        mini=min(mini-arr[j].ff+prev,cmi);
       ans=max(ans,max(abs(mini-cm),maxi-cmi));
       prev=arr[j].ff;
    }
    cout<<ans<<endl;













}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
 solve();
    return 0;
}



Measured memory_bytes: 6688
#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;

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

int n;
set<int> s;


int main(){
  cin >> n;
  for(int i=0; i<n; i++){
    int d;
    cin >> d;
    s.insert(d);
  }
  cout << s.size() << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    int h,w,d;
    cin>>h>>w>>d;
    vector<vector<int>> a(h,vector<int>(w));
    map<int,pair<int,int>> m;
    map<pair<int,int>,int> m2;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin>>a[i][j];
            a[i][j]--;
            m[a[i][j]]=make_pair(i,j);
        }
    }

    int q;
    cin>>q;
    vector<int> l(q),r(q);
    for(int i=0; i<q; i++){
        cin>>l[i]>>r[i];
        l[i]--;
        r[i]--;
    }
    vector<vector<ll>> sums(d,vector<ll>((h*w/d)+1));
    vector<bool> visit(h*w,false);
    for(int i=0; i<d; i++){
        if(visit[i]) continue;
        for(int j=0; i+(j+1)*d<h*w; j++){
            //cout<<i+(j+1)*d<<" ";
            pair<int,int> now=m[i+j*d];
            pair<int,int> next=m[i+(j+1)*d];
            sums[i%d][j+1]=(sums[i%d][j]+(abs(now.first-next.first)+abs(now.second-next.second)));
        }
    }
    for(int i=0; i<q; i++){
        //cout<<sums[r[i]%d][(r[i]/d)]<<endl;
        ll tmp=sums[r[i]%d][(r[i]/d)]-sums[r[i]%d][(l[i]/d)];
        cout<<tmp<<endl;
    }

}

Measured memory_bytes: 12160
package main

import (
	"fmt"
)

func main() {
	var S, T string
	fmt.Scan(&S, &T)

	index := -1
	for i := range S {
		var j int
		for ; j < len(T); j++ {
			if i+j < len(S) && (S[i+j] == '?' || S[i+j] == T[j]) {
			} else {
				break
			}
		}

		if j == len(T) {
			index = i
		}
	}

	if index == -1 {
		fmt.Println("UNRESTORABLE")
	} else {
		s := S[:index] + T + S[index+len(T):]
		for i := range s {
			if s[i] == '?' {
				fmt.Print("a")
			} else {
				fmt.Print(string(s[i]))
			}
		}
		fmt.Println()
	}

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std; 
typedef long long lli;
#define mod 1000000007
const int INF = 1e6;
const int MAX = 1e5+10;
#define fori(n) for(int i=0;i<n;i++)
#define forj(n) for(int j=0;j<n;j++)
#define forli(n) for(lli i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define vi vector<int>
#define vli vector<lli>
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define print(a) cout<<a<<endl
#define print2(a,b) cout<<a<<" "<<b<<endl
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define sortvec(a) sort(a.begin(),a.end())
#define pdd pair<lli,lli>
 
//FUNCTONS
lli llipower(lli x, lli y){lli res = 1;x = x % mod; while (y > 0){if (y & 1) res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
lli gcd(lli a, lli b){ if (!a) return b; return gcd(b%a,a);}
lli binarySearch(vector<int> arr, int l, int r, int x){ 
	if (r >= l) { 
		lli mid = l + (r - l) / 2; 
		if (arr[mid] == x) return mid; 
		if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x); 
		return binarySearch(arr, mid + 1, r, x); 
	} 
	return -1;
}

template <typename T>
void printvec(vector<T> inp){
	for(int i=0;i<inp.size();i++){
		cout<<inp[i]<<" ";
	}
	cout<<endl;
}
template <typename T>
T ceildiv(T x, T y){
	return 1 + ((x - 1) / y);
}

int main(){
	int n,k;

	cin>>n>>k;
	int ans=0;
	lli div=1;
	while(n/div>0){
		ans++;
		div*=k;
	}
	cout<<ans<<endl;

}
 
 

Measured memory_bytes: 256
#include<stdio.h>
int main(){
           int a,b,c,x,y,z;
           scanf("%d %d %d",&a,&b,&c);
           if(a<b){
                   x=a;
                   y=b;
           }else{
                 x=b;
                 y=a;
           }
           if(y<c){
                   z=c;
           }else{
                 z=y;
                 y=c;
           }
           if(x<y){
                   printf("%d %d %d\n",x,y,z);
           }else{
                 printf("%d %d %d\n",y,x,z);
           }
           return 0;
}

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

#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 1e9+7;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    while(cin >> s){
        ll dp[15][2] = {};
        dp[0][0] = 1;
        reverse(s.begin(),s.end());
        int mul = 1;
        for(auto i:s){
            if(i=='?'){
                fr(j,0,10){
                    int num = j * mul % 13;
                    f(13){
                        dp[(i+num)%13][1] += dp[i][0];
                    }
                }
            }
            else{
                int num = (i-'0') * mul % 13;
                f(13){
                    dp[(i+num)%13][1] += dp[i][0];
                }
            }
            f(13){
                dp[i][0] = dp[i][1]%mod;
                dp[i][1] = 0;
            }
            mul *= 10;
            mul %= 13;
        }
        cout<<dp[5][0]<<endl;
    }

}

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

int main(){
//srandom((unsigned long)time(NULL));

long long a,b,c,x,y;
cin>>a>>b>>c>>x>>y;
if(a+b<=2*c){
    cout<<a*x+b*y<<endl;
    return 0;
}
long long ans;
long long a1,a2,a3,a4;
if(x>=y){
    a1=c*y*2+(x-y)*a;
    a2=c*2*x;
    ans=min(a1,a2);
}else{
    a3=c*x*2+(y-x)*b;
    a4=c*2*y;
    ans=min(a3,a4);
}
cout<<ans<<endl;




return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
long long x,ans,lst;
int main()
{
	cin>>x;
	if((x*2)%11==0) 
	{
		cout<<(x*2)/11;
		return 0;
	}
	ans=x/11;
	ans=ans*2;
	lst=x%11;
	if(lst<7) ans++;
	else ans+=2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;

bool enough(long T, long h[], long A, long B, long N) {
	
	long time = 0;

	for (int i = 1; i <= N; i++) {
        if (h[i] <= B * T) continue;
		time += max((long)0, ((h[i] - B * T) - 1) / (A - B) + 1);
	}

	if (time <= T) return true; else return false;

}

void bi_search(long bigin, long end,long h[], long A, long B, long N) {

	if (end == bigin) { cout << end << endl; return; }


	long mid = (bigin + end) / 2;

    if (!enough(mid, h, A, B, N)) bi_search(mid + 1, end, h, A, B, N);
	else bi_search(bigin, mid, h, A, B, N);

}

int main() {

	long N, A, B; cin >> N >> A >> B;

	long h[100009]; for (int i = 1; i <= N; i++) cin >> h[i];

	sort(h + 1, h + N + 1);

	bi_search(1, h[N], h, A, B, N);
    
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
dp = [0]*(K+1)
for i in range(1, K+1):
    flag = 0
    for ai in a:
        if i-ai<0:
            break
        if dp[i-ai] == 0:
            flag = 1
    dp[i] = flag
if dp[-1] == 1:
    print('First')
else:
    print('Second')



    

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

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

    ll sum = 0;
    rep(i, n) {
        ll tmp = n/(i+1);
        sum += tmp*(tmp+1)*(i+1)/2;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3600
package main

import "fmt"

func main() {
	var N, M, C, B, A int
	fmt.Scan(&N, &M, &C)

	slice := []int{}
	sum := 0
	count := 0

	for i := 0; i < M; i++ {
		fmt.Scan(&B)
		slice = append(slice, B)
	}

	for j := 0; j < N; j++ {
		for i := 0; i < M; i++ {
			fmt.Scan(&A)
			sum = sum + (slice[i] * A)
		}
		if sum+C > 0 {
			count = count + 1
			sum = 0
		}
		sum = 0
	}

	fmt.Println(count)

}


Measured memory_bytes: 512
#include <stdio.h>
int main()
{
	int a;
	int c=0,m=0;
	scanf("%d",&a);
	if(a<105)
		printf("0\n");
	else {
		for(int i = 105; i<=a; i++){
			c=0;
			for(int j = 1; j<=a/2;j+=2){
				if(i%j==0){
					c++;
				if(c==7)
					m++;
			}
			}
		}
		printf("%d\n",m);
		}
	//	printf("%d\n",m);


	}


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

using namespace std;

const long long INF = 1e18;

long long dp[200005][4];
//long long dp[100][4];

//dp[i][j] : i個目まで見てj個余分なｘ（バツ）を入れたときのMAX

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

    //K: 何個余分のバツを入れれる？奇数は2で偶数は1
    int K = 1 + N%2;

    for(int i=0; i< N+1; ++i){
        for(int j=0; j<K+1; ++j){
            dp[i][j] = -INF;
        }
    }

    dp[0][0] = 0;
    for(int i=0; i<N; ++i){
        for(int j=0; j<K+1; ++j){
            //バツを一個挿入（今見てる数をスキップ）
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]);
            //次の数を当てはめる,0からなので割り切れたらそれはカウント
            long long now = dp[i][j];
            if( (i+j)%2 == 0 ) now += a[i];
            dp[i+1][j] = max(dp[i+1][j], now);            
        }
    }

    long long ans = dp[N][K];
    cout << ans << endl;

}

Measured memory_bytes: 11152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,A,B;
    cin >>N>>A>>B;
    vector<ll>X(N);
    rep(i,N){
        cin>>X[i];
    }
    ll ans=0;
    rep(i,N-1){
        ans+=min((X[i+1]-X[i])*A,B);
    }
    
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3988
#include <iostream>
#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <list>
#include <stack>
#include <climits>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#define m7 1000000007
#define m9 1000000009
#define ll long long
#define pii pair<int,int>
#define F first
#define S second

using namespace std;

int main()
{
	int n;
	vector<double> V(3000);
	vector<vector<double>> dp(3000,vector<double> (3000,0.0));

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> V[i];
	}
	dp[0][1] = V[0]*1.00000000000000;
	dp[0][0] = 1.00000000000000000 - V[0]*1.0000000000000;
	for (int i = 1; i < n; i++) {
		dp[i][0] = dp[i - 1][0] * (1 - V[i]) * 1.00000000000000;
		for (int j = 1; j <= i; j++) {
			dp[i][j] = dp[i - 1][j - 1] * V[i]*1.000000000000000 + dp[i - 1][j] * (1.00000000000 - V[i])*1.0000000000000;
		}
		dp[i][i + 1] = dp[i - 1][i] * V[i]*1.000000000000000;
	}
	double ans = 0.00000000000000;
	for (int i = n / 2 + 1; i <= n; i++) {
		ans += dp[n - 1][i]*1.00000000000;
	}
	cout <<setprecision(15)<< ans;
	return 0;
}

Measured memory_bytes: 70784