akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,h;
int a[125252], b[125252];

int main(){
  scanf("%d%d",&n,&h);
  REP(i,n)scanf("%d%d",a+i,b+i);
  priority_queue<pii> Q;
  REP(i,n)Q.push(pii(b[i],i));
  int ans = 0;
  while(h>0){
    ans++;
    pii P = Q.top(); Q.pop();
    int id = P.second;
    h -= P.first;
    if(a[id] == P.first){
      // loop
      int x = P.first;
      ans += (h + x - 1) / x;
      h = 0;
      break;
    }
    Q.push(pii(a[id],id));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2168
#include <iostream>
#include <algorithm>
#include <typeinfo>
#include <numeric>
#include "math.h"
#include <string>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
using namespace std;



int main() {

	int x, y;
	cin >> x >> y;

	for (int i = x; i >= 0; i--) {

		
		if (y == (4 * i) + (2 * (x-i))) {
			cout << "Yes";
			return 0;
		}

		
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 3636
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
s=sum(B)
for i in range(n-1):
    if A[i+1]-A[i]==1:
        s+=C[A[i]-1]
print(s)

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

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

bool era[10000001]={false};


void makeERA(){
    for(int i=2;i<1000001;i++){
        if(era[i]==true){
            int x=10000000/i;
            for(int j=2;j<=x;j++){
                    era[i*j]=false;
            }
        }
    }
    era[2]=true;
}




int main(){
    for(int i=0;i<10000001;i++)era[i]=true;
    era[0]=false;era[1]=false;
    makeERA();
    
    int n;
    while(cin>>n){
        if(n==0)break;
        
        if(n%2==0)n--;
        for(int i=n;i>=8;i-=2){
            if(era[i-8]&&era[i-6]&&!era[i-4]&&era[i-2]&&era[i]){
                cout<<i<<endl;
                goto next;
            }
        }
        next:;
    }
    
    
    return 0;
}

Measured memory_bytes: 10924
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
const int MAX_H = 1010;
const int MAX_W = 1010;
const int dh[2] = {0, 1};
const int dw[2] = {1, 0};
const int MOD = 1e9+7;

template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a/b; a -= t*b; swap(a, b); u -= t*v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if (e%2 == 0) { p = (p*p)%mod; e /= 2; }
            else { a = (a*p)%mod; e--; }
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

using mint = ModInt<MOD>;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for (int i = 0; i < H; i++) cin >> S[i];
    auto is_wall = [&](int i, int j){ return (i < 0 || H <= i || j < 0 || W <= j); };
    
    bool seen[MAX_H][MAX_W] = {0};
    mint dp[MAX_H][MAX_W]; dp[0][0] = 1;
    queue<pair<int, int>> que;
    que.emplace(0, 0);
    while (!que.empty()) {
        int h, w; tie(h, w) = que.front(); que.pop();
        if (seen[h][w]) continue;
        seen[h][w] = true;
        for (int i = 0; i < 2; i++) {
            int nh = h + dh[i], nw = w + dw[i];
            if (is_wall(nh, nw)) continue;
            if (seen[nh][nw]) continue;
            if (S[nh][nw] == '#') continue;
            dp[nh][nw] += dp[h][w];
            que.emplace(nh, nw);
        }
    }
    
    cout << dp[H-1][W-1] << endl;
    return 0;
}

Measured memory_bytes: 6400
#include <iostream>

using namespace std;

int main() {
    int a, b;
    char operation;
    cin >> a >> operation >> b;
    
    while (operation != '?') {
        if (operation == '+')
            cout << a + b << endl;
        else if (operation == '-')
            cout << a - b << endl;
        else if (operation == '*')
            cout << a * b << endl;
        else if (operation == '/')
            cout << a / b << endl;
        cin >> a >> operation >> b;
    }
    
    return 0;
}




Measured memory_bytes: 3076
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;

typedef complex<long double> P;

template<typename D=long double,typename P=complex<long double>>
struct Geometry{
    const D EPS=1e-9;
    
    P project(P vec,P x){return vec*(x/vec).real();}
    
    P project(P p1,P p2,P x){return p1+project(p2-p1,x-p1);}
};



int main(){
    Geometry<long double,complex<long double>> G;
    P a[2];
    for(int i=0;i<2;i++){
        long double x,y;
        cin>>x>>y;
        a[i]={x,y};
    }
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        long double x,y;
        cin>>x>>y;
        P K={x,y};
        P ans=G.project(a[0],a[1],K);
        cout<<fixed<<setprecision(12)<<ans.real()<<" "<<ans.imag()<<endl;
    }
    
    
    return 0;
}



Measured memory_bytes: 3292
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import time
 
START = (int(time.time() * 1000))

import random
import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

D = int(input().strip())
C = list(map(int,input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

ans = 0
score = 0
last = [[-1] for i in range(26)]
schedule = []

for d in range(D):
  t = random.choice(range(26))
  last[t].append(d)
  score += S[d][t]
  schedule.append(t)

for i in range(26):
  last[i].append(D)
  for k in range(len(last[i])-1):
    g = last[i][k+1]-last[i][k]-1
    score -= C[i]*g*(g+1)//2


while True:
  prev = score
  d,q = random.choice(range(D)),random.choice(range(26))
  p = schedule[d]
  schedule[d] = q
  score -= S[d][p]
  score += S[d][q]
  
  pos = last[p].index(d)
  score -= C[p]*(last[p][pos]-last[p][pos-1])*(last[p][pos+1]-last[p][pos])
  last[p].remove(d)
  
  pos = bisect.bisect(last[q],d)
  score += C[q]*(d-last[q][pos-1])*(last[q][pos]-d)
  bisect.insort(last[q],d)
  t = int(time.time() * 1000)-START
  if score<prev or random.random() < ((2000-t)/2000)**2*0.5:
    score = prev
    bisect.insort(last[p],d)
    last[q].remove(d)
    schedule[d] = p
  if t>1900:
    break
    
for i in schedule:
  print(i+1)

Measured memory_bytes: 90536
A = int(input())  #500円の枚数
B = int(input())  #100円の枚数
C = int(input())  #50円の枚数
X = int(input())  #合計金額

cnt = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i + 100*j + 50*k == X:
                cnt = cnt +1
            

print(cnt)

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

using namespace std;

const int N = 505;

int n;
int dist[N][N];
int unused[N][N];
void prec() {
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			dist[i][j] = min(j, n - 1 - j);
			dist[i][j] = min(dist[i][j], i);
			dist[i][j] = min(dist[i][j], n - 1 - i);
			unused[i][j] = 1;
		}
	}
}

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

int getmn(int i, int j) {
	int mn = dist[i][j];
	for(int k = 0; k < 4; k++) {
		int x = i + dx[k], y = j + dy[k];
		if(x < 0 or x >= n or y < 0 or y >= n) {
			mn = 0;
			break;
		}
		mn = min(mn, dist[x][y] + unused[x][y]);
	}
	return mn;
}

void push(int i, int j, int val) {
	deque<pair<int, int>> q;
	dist[i][j] = val;
	q.emplace_back(i, j);
	while(!q.empty()) {
		tie(i, j) = q.front(); q.pop_front();
		for(int k = 0; k < 4; k++) {
			int x = i + dx[k], y = j + dy[k];
			if(x < 0 or x >= n) continue;
			if(y < 0 or y >= n) continue;
			if(unused[i][j]) {
				if(dist[x][y] > dist[i][j] + 1) {
					dist[x][y] = dist[i][j] + 1;
					q.emplace_back(x, y);
				}
			}
			else {
				if(dist[x][y] > dist[i][j]) {
					dist[x][y] = dist[i][j];
					q.emplace_front(x, y);
				}
			}
		}
	}
}

int solve(int u) {
	int i = u / n, j = u % n;
	int ret = dist[i][j];
	unused[i][j] = 0;
	push(i, j, getmn(i, j));
// 	printf("%d\n", ret);
	return ret;
}

int p[N*N];
int main() {

	scanf("%d", &n);

	prec();

	for(int i = 0; i < n * n; i++) scanf("%d", p+i), p[i]--;

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

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



Measured memory_bytes: 7772
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 111111;
int a[N];
int n;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    rep(i, 1, n) {
        cin >> a[i];
    }
    set<int> odd;
    for(int i = 1; i <= n; i += 2) {
        odd.insert(a[i]);
    }
    sort(a + 1, a + n + 1);
    int ans = 0;
    for(int i = 1; i <= n; i += 2) {
        ans += odd.find(a[i]) == odd.end();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2944
def move(hougaku, zahyo):
    if hougaku == "N":
        zahyo[1] += 1
    elif hougaku == "E":
        zahyo[0] += 1
    elif hougaku == "S":
        zahyo[1] -= 1
    elif hougaku == "W":
        zahyo[0] -= 1


while True:
    N = int(input())
    if N == 0:
        break
    jewelry = [list(map(int, input().split())) for _ in range(N)]
    M = int(input())
    default = [10, 10]
    for _ in range(M):
        get_jewelry = 0
        d, l = input().split()
        for i in range(int(l)):
            move(d, default)
            # with open("./log.txt", "a") as f:
            #     f.write(
            #         "default: {}, jewelry: {}, get_jewelry: {}\n".format(
            #             default, jewelry, get_jewelry
            #         )
            #     )
            if default in jewelry:
                jewelry.remove(default)
    if len(jewelry) == 0:
        # with open("./log.txt", "a") as f:
        #     f.write("----------Yes----------\n")
        print("Yes")
    else:
        # with open("./log.txt", "a") as f:
        #     f.write("----------No----------\n")
        print("No")



Measured memory_bytes: 5620
#include <iostream>

int main()
{
    std::string w;
    std::cin >> w;

    if (w.compare("Sunny") == 0) {
        std::cout << "Cloudy";
        return 0;
    }
    if (w.compare("Cloudy") == 0) {
        std::cout << "Rainy";
        return 0;
    }
    if (w.compare("Rainy") == 0) {
        std::cout << "Sunny";
        return 0;
    }

    std::cout << "";
    return 0;
}


Measured memory_bytes: 888
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int n, m;

struct unionfind {
  int parent;
  int node;
  int edge;
};
unionfind g[200001];

void init() {
  for (int i = 0; i <= n; i++) {
    g[i].parent = i;
    g[i].node = 1;
    g[i].edge = 0;
  }
}

int find(int x) {
  if (x == g[x].parent) {
    return x;
  }
  int res = find(g[x].parent);
  g[x].node = g[res].node;
  g[x].edge = g[res].edge;
  g[x].parent = res;
  return res;
}

void merge(int x, int y) {
  if (x > y) {
    x ^= y;
    y ^= x;
    x ^= y;
  }
  g[x].node += g[y].node;
  g[x].edge += g[y].edge + 1;
  g[y].parent = x;
}

int main() {
  int q, a, u, v;
  cin >> n >> q;
  init();
  for (int i = 0; i < q; i++) {
    cin >> a >> u >> v;
    u = find(u);
    v = find(v);
    if (a == 0 && u != v) {
      merge(u, v);
    } else if (a == 1) {
      cout << (u == v ? 1 : 0) << endl;
    }
  }
}

Measured memory_bytes: 5684
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
using namespace std;
#define ul unsigned long long
#define ll long long
#define rup(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define rdn(i, a, b) for(int (i) = (a); (i) > (b); (i)--)

int main() {
	int n, k;
	cin >> n;
	cin >> k;
	vector<int> x(n, 0);
	rup(i, 0, n) cin >> x[i];
	vector<int> d(n, 0);
	ll sum = 0;
	rup(i, 0, n) {
		d[i] = 2 * x[i] < 2 * abs(k - x[i]) ? 2 * x[i] : 2 * abs(k - x[i]);
		sum += d[i];
	}
	
	cout << sum << endl;
	return 0;
}





Measured memory_bytes: 256
def main():
    N = int(input())
    lst = list(map(int, input().split()))
    lst.sort()

    while len(lst) > 1:
        mi = lst[0]
        attacked = [lst[i]%mi for i in range(1, len(lst)) if lst[i]%mi != 0]
        lst = [mi] + attacked
        lst.sort()
    print(lst[0])
main()

Measured memory_bytes: 64408
import sys
input = sys.stdin.readline
#import heapq
#from fractions import gcd
#from collections import defaultdict
#sys.setrecursionlimit(10**9)
#map(int,input().split())




def main():
    h,w,D=map(int,input().split())
    li=[0]*(h*w+1)
    kyori=[0]*(h*w+1)
    for i in range(h):
        A=list(map(int,input().split()))
        for j in range(w):
            li[A[j]]=(i+1,j+1)

    for i in range(D+1,h*w+1):
        kyori[i]=kyori[i-D]+abs(li[i][0]-li[i-D][0])+abs(li[i][1]-li[i-D][1])

    Q=int(input())
    for i in range(Q):
        l,r=map(int,input().split())
        print(kyori[r]-kyori[l])


if __name__ == '__main__':
    main()

Measured memory_bytes: 57116
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#define _CRT_SECURE_NO_WARNINGS
#endif
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x) {x = 0;register bool _=0;register T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void print(T n) {register bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);pc(10);}
template<typename First, typename ... Ints>
void scan(First &arg, Ints&... rest) { scan(arg);scan(rest...); }

using namespace std;
const int MM = 1e5+2;

int N, a[MM], dp[MM];

int main(){
    
    memset(dp, 0x3f, sizeof(dp));
    
    scan(N);
    for(int i = 1; i <= N; i++){
        scan(a[i]);
    }
    
    dp[1] = 0;
    
    for(int i = 2; i <= N; i++){
        dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]), dp[i-2] + abs(a[i] - a[i-2]));
    }
    print(dp[N]);
    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	string T;
	cin >> T;
	ll an=0;
	
	rep(i, T.size()) {
		if (T.at(i ) == '?') {
			T.at(i ) = 'D';
			
		}
		
		
	}

	cout << T << endl;

}



Measured memory_bytes: 3756
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

def ketawa(x):
	return sum(map(int, list(str(x))))

N = input()

if len(N) == 1:
	print(N)

else:
	print(max(ketawa(N), int(N[0])-1 + 9*(len(N)-1)))


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

#define ll long long 

int main(){
	ll n,x,t;
	cin>>n>>x>>t;
	if(n==x||n<x)
	cout<<t<<"\n";
	else{
		ll k=0,temp=n/x;
		if(n%x)
		k=1;
		cout<<(t*(temp+k))<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3616
// Problem : D - Chat in a Circle
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
    int f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

inline LL gl()
{
    LL f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

const int INF = 0x3f3f3f3f, N = 200003, M = N << 1;

int n, m;
int a[N];

int main()
{
    //File("");
    n = gi();
    for (int i = 1; i <= n; i+=1) a[i] = gi();
    sort(a + 1, a + 1 + n); reverse(a + 1, a + 1 + n);
    LL ans = a[1], cnt = 2;
    for (int i = 2; i <= n; i+=1)
    {
    	if (cnt < n) ans += a[i], ++cnt;
    	if (cnt < n) ans += a[i], ++cnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4428
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

int main()
{
    long N,K;
    std::cin >> N >> K;
    (N%K==0)? std::cout << 0 << std::endl : std::cout << 1 << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {  

 int n,i,ai,min,max;  

 long sum;  

 sum=0;  

 min=1000000;  

 max=-1000000;  

 scanf("%d",&n);  

 for(i=1;i<=n;i++)  {   

        scanf("%d",&ai);   

        sum+=ai;   

        if(min>ai){    

                   min=ai;   

       }   

       if(max<ai){    

                   max=ai;   

       }  

 }  

    printf("%d %d %lld\n",min,max,sum);    

    return 0;

}

Measured memory_bytes: 600
#include<stdio.h>
#define MAX 20001
#include<string.h>

typedef struct idx_S{
 int idx;
 int S;
}idx_S;


void push1(int S[],int x,int *top){
 S[*top]=x;
 (*top)++;
return;
}

void push2(idx_S S[],int idx,int s,int *top){
 S[*top].idx=idx;
 S[*top].S=s;
 (*top)++;
return;
}

int pop(int S[],int *top){
 (*top)--;
 return S[*top];
}

void Union(idx_S S[],int *top){
 int i;

 for(i=(*top)-1;i>0;i--){

   if(S[i].idx < S[i-1].idx){
     (*top)--;
     S[i-1].idx=S[i].idx;
     S[i-1].S+=S[i].S;
   }
 }


return;
}

int main(){
 int i,j;
 char str[MAX];
 int idx;
 int Stack1[MAX];
 idx_S Stack2[MAX];
 int top1=0;
 int top2=0;
 int sum=0;

 scanf("%s",str);

 for(i=0;i<strlen(str);i++){

  switch(str[i]){
   case '\\':push1(Stack1,i,&top1);
             break;
   case '/' :if(top1==0)break;
             idx=pop(Stack1,&top1);
             sum+=(i-idx);
             push2(Stack2,idx,i-idx,&top2);
             Union(Stack2,&top2);
             break;
  }

 }

 printf("%d\n",sum);
 if(top2 == 0)printf("%d\n",top2);
 else {
   printf("%d ",top2);
   for(i=0;i<top2-1;i++)printf("%d ",Stack2[i].S);
   printf("%d\n",Stack2[top2-1].S);
 }

return 0;
}




Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	cin>>a;
	vector<int>ji;
	vector<int>ou;
	for(int i=1;i<=a;i++)
	if(i%2==1) ou.push_back(i);
	else ji.push_back(i);
	int our=ou.size();
	int ans=our/a;
	cout<<ans<<".";
	our%=a; 
	for(int i=1;i<=10;i++)
	{
	ans=(our*10)/a;
    cout<<ans;
    our=(our*10)%a;
	} 
	return 0;
}


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

int main(void){
    int N, X; cin >> N >> X;
    vector<int> L(N+1);
    L[0] = 0;
    int ans = 0;
    for (int i = 0; i <= N; i++){
        if (L[i] <= X){
            int l; cin >> l;
            L[i+1] = L[i] + l;
            ans ++;
        }
        else{
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
ll mod_mult(ll a, ll n, ll m) { //a*nMODm
	a %= m;
	if (a < 0) a += m;
	ll ans = 0;
	while (n >= 1) {
		if (n % 2 == 1) ans = (a + ans) % m;
		a = a * 2 % m;
		n >>= 1;
	}
	return ans;
}
ll mod_pow(ll a, ll n, ll m) {//a^n MOD m
	ll b = 1;
	while (n >= 1) {
		if (n % 2 == 1) b = mod_mult(a, b, m);
		a = mod_mult(a, a, m);
		n >>= 1;
	}
	return b;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n + 1);
	REP(i, n + 1)cin >> v[i];
	vi cnt(n, 0);
	int a, p = -1, q;
	REP(i, n + 1) {
		cnt[v[i] - 1]++;
		if (cnt[v[i] - 1] == 2) {
			a = v[i];
		}
	}
	REP(i, n + 1) {
		if (v[i] == a) {
			if (p == -1)p = i;
			else q = i;
		}
	}
	ll tmp = 1;
	vl fact(n + 2);
	fact[0] = 1;
	FOR(i, 1, n + 2) {
		tmp = (tmp*i) % MOD;
		fact[i] = tmp;
	}
	vl e(n + 2);
	e[n + 1] = mod_pow(fact[n + 1], MOD - 2, MOD);
	RREP(i, n + 1) {
		e[i] = (i + 1)*e[i + 1] % MOD;
	}
	cout << n << endl;
	FOR(i, 2, n + 2) {
		ll ans = 0;
		if (i <= n - 1)	ans += fact[n - 1] * e[i] % MOD*e[n - i - 1] % MOD;//ダブりを使わない

		if (i != n + 1) {//ダブりを1個だけ使う
			ans += 2 * fact[n - 1] % MOD * e[i - 1] % MOD*e[n - i] % MOD;
			if (p + n - q >= i - 1)ans -= fact[p + n - q] * e[i - 1] % MOD*e[p + n - q - i + 1] % MOD;
		}
		ans += fact[n - 1] * e[i - 2] % MOD*e[n - i + 1] % MOD;//ダブりを2個使う
		cout << (ans+MOD)%MOD << endl;
	}

}


Measured memory_bytes: 3584
#include <iostream>

int main(){
  int a,b,c,sum;
  int k,s=0;
  int count=0;
  std::cin >> k >> s;

  for(int i=k;i>=0;i--){
    for(int j=i;j>=0;j--){
      for(int n=j;n>=0;n--){
          a = i;
          b = j;
          c = n;
          sum = 0;
          sum = a + b + c;
          if(sum == s){
            //std::cout << a << " " << b << " " << c << std::endl;
            if((a!=b) && (b!=c) && (c!=a)){
              count += 6;
            }else if((a==b)&&(b==c)&&(c==a)){
              count += 1;
            }else{
              count += 3;
            }
          }
      }
    }
  }

  std::cout << count << std::endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
bn = list(map(int,input().split()))
ans = []

while bn:
    for i in range(len(bn))[::-1]:
        if i+1 == bn[i]:
            ans.append(bn[i])
            del bn[i]
            break
    else:
        break
if bn:
    print(-1)
else:
    [print(i) for i in ans[::-1]]


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main()
{
	char s[11],t[12];

	scanf("%s%s",s,t);

	t[strlen(t)-1]='\0';
	if(strcmp(s,t)==0)
		puts("Yes");
	else
		puts("No");
	return 0;
}

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

int main() {
  string o, e;
  cin >> o >> e;
  string result;
  int i;
  for (i = 0; i < o.length() + e.length(); i++) {
    result.push_back((i % 2 == 0 ? o.at(i / 2) : e.at(i / 2)));
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}
int n,k;
vector<int>a;
bool check(int x) {
    int cnt = 0;
    rep(i,n) {
        cnt += (a[i]-1)/x;
    }
    if(cnt > k)return false;
    return true;
}
int main() {
    cin >> n >> k;
    a.resize(n);
    rep(i,n) cin >> a[i];
    int ok = 1000000000;
    int ng = 0;
    while(ok - ng > 1) {
        int mid = (ok+ng)/2;
        if(check(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok << endl;
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();


int main(){
    int n, m, x;
    cin >> n >> m >> x;

    int c[13];
    int a[13][13];
    
    rep(i,n){
        cin >> c[i];
        rep(j,m) {
            cin >> a[i][j];
        }
    }

    int min = INF;

    for (int i = 0; i < pow(2,n); ++i) {
        int t[13] = {0};
        int sum[13] = {0};
        int y = 0;
        for (int j = 0; j < n; j++) t[j] = (i>>j) & 1;
		for (int j = 0; j < n; j++) if (t[j]) y += c[j];
		for (int j = 0; j < n; j++) {
			if (t[j]) for (int l = 0; l < m; l++) sum[l] += a[j][l];
		}
        int flag = 1;
		for (int l = 0; l < m; l++) if (sum[l] < x) flag = 0;
		if (flag == 1 && y < min) min = y;
    }

    if (min == INF) cout << -1 << endl;
	else cout << min << endl;

    return 0;
    
}

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

int main() {
  int A,B;
  cin >> A >> B;
  int count=0;
  for (int i = A; i <= B; ++i)
  {string l = to_string(i);
    if(l.at(0)==l.at(4) && l.at(1)==l.at(3))
      {count++;}
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long


int main(){
    int d;
    cin>>d;
    if(d==25){
        cout<<"Christmas"<<endl;
    }else if(d==24){
        cout<<"Christmas Eve"<<endl;
    }else if(d==23)cout<<"Christmas Eve Eve"<<endl;
    else cout<<"Christmas Eve Eve Eve"<<endl;
    return 0;


}



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

#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t k, x, y;
    cin >> k >> x >> y;

    auto d = abs(x) + abs(y);
    if (k % 2 == 0 && d % 2 > 0) {
        cout << -1 << endl;
        return 0;
    }

    int64_t dirx = (x > 0 ? 1 : -1), diry = (y > 0 ? 1 : -1);

    if (d < k && d % 2 > 0) {
        cout << 3 << endl;

        auto r = 3 * k - d;

        auto dx = r / 4;
        auto dy = (r + 3) / 4;

        cout << -dirx * dx << " " << diry * (k - dx) << endl;
        cout << dirx * (2 * k - abs(y) - dy - 2 * dx) << " " << y + diry * dy
             << endl;
        cout << x << " " << y << endl;
    } else if (abs(x) < abs(y)) {
        int64_t r = (k - d % k) % k;
        if (d / k == 0) {
            r += k;
        }
        if (r % 2 > 0) {
            r += k;
        }
        assert((d + r) % k == 0);

        cout << (d + r) / k << endl;

        int64_t cx = 0, cy = 0;
        while (abs(cx) + k < abs(x) + r / 2) {
            cx += dirx * k;
            cout << cx << " " << cy << "\n";
        }

        cy += diry * (k - (abs(x) + r / 2 - abs(cx)));
        cx = x + dirx * r / 2;
        cout << cx << " " << cy << "\n";

        if (abs(cy) < abs(y)) {
            while (abs(cy) + k < abs(y)) {
                cy += diry * k;
                cout << cx << " " << cy << "\n";
            }

            cx -= dirx * (k - (abs(y) - abs(cy)));
            cy = y;
            cout << cx << " " << cy << "\n";
        }

        while (cx != x) {
            cx -= dirx * k;
            cout << cx << " " << cy << "\n";
        }
    } else {
        int64_t r = (k - d % k) % k;
        if (d / k == 0) {
            r += k;
        }
        if (r % 2 > 0) {
            r += k;
        }
        assert((d + r) % k == 0);

        cout << (d + r) / k << endl;

        int64_t cx = 0, cy = 0;
        while (abs(cy) + k < abs(y) + r / 2) {
            cy += diry * k;
            cout << cx << " " << cy << "\n";
        }

        cx += dirx * (k - (abs(y) + r / 2 - abs(cy)));
        cy = y + diry * r / 2;
        cout << cx << " " << cy << "\n";

        if (abs(cx) < abs(x)) {
            while (abs(cx) + k < abs(x)) {
                cx += dirx * k;
                cout << cx << " " << cy << "\n";
            }

            cy -= diry * (k - (abs(x) - abs(cx)));
            cx = x;
            cout << cx << " " << cy << "\n";
        }

        while (cy != y) {
            cy -= diry * k;
            cout << cx << " " << cy << "\n";
        }
    }
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const ll INF = 1e9 + 7;
typedef pair<int,int> P;// pair型は２つの値の組を表せる

int main(){
    int N; cin >> N;
    map<string,int> P;
    vector <string> S(N);
    rep(i,N) cin >> S[i];
    sort(S.begin(),S.end()); //文字列も辞書順にソートできる！
    
    int ans=0;
    rep(i,N){
        P[S[i]]++;
        ans=max(ans,P[S[i]]);
    }
    
    rep(i,N){
        if (ans==P[S[i]]){
            cout << S[i] << endl;
            P[S[i]]=0;
        }
    }
}

Measured memory_bytes: 26752
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//priority_queue<int> pque;
//priority_queue<int, vector<int>, greater<int>> pque;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;


int main(void){
    int N;
    cin >> N;
    
    if(N % 2 == 0 && N != 4){
        cout << 2 * N << endl;
        for(int i = 1; i < N / 2; i++){
            cout << i << " " << i+1 << endl;
            cout << i << " " << N - i << endl;
            cout << N - i + 1 << " " << i+1 << endl;
            cout << N - i + 1 << " " << N - i << endl;
        }
        cout << N / 2 << " " << 1 << endl;
        cout << N / 2 << " " << N << endl;
        cout << N / 2 + 1 << " " << 1 << endl;
        cout << N / 2 + 1 << " " << N << endl;
    }else if(N % 2 == 1 && N != 3){
        cout << 2 * N - 2 << endl;
        for(int i = 1; i < N / 2; i++){
            cout << i << " " << i + 1 << endl;
            cout << i << " " << N - i - 1 << endl;
            cout << N - i << " " << i + 1 << endl;
            cout << N - i << " " << N - i - 1 << endl;
        }
        cout << N / 2 << " " << N << endl;
        cout << N / 2 + 1 << " " << N << endl;
        cout << N << " " << 1 << endl;
        cout << N << " " << N - 1 << endl;
    }else if(N == 3){
        cout << 2 << endl;
        cout << 1 << " " << 3 << endl;
        cout << 2 << " " << 3 << endl;
    }else{
        cout << 4 << endl;
        cout << 1 << " " << 2 << endl;
        cout << 2 << " " << 4 << endl;
        cout << 4 << " " << 3 << endl;
        cout << 3 << " " << 1 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 12345678901234567

const int maxn = 1e5 + 10;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here

	int s1, s2, s3; cin >> s1 >> s2 >> s3;
if(s2-s1 == s3-s2)  YES;
else NO;
	return 0;

}

Measured memory_bytes: 256
module C
  sub Main(byval args() as string)
    dim arr() as string = split(console.readline())
    dim k,n as long
    k = long.parse(arr(0))
    n = long.parse(arr(1))
    arr = split(console.readline())
    dim a_i(n) as long
    dim i as integer
    for i=0 to n-1
      a_i(i) = arr(i)
    next
    dim sa as long = 0
    for i=0 to n-2
      sa = if(sa<a_i(i+1)-a_i(i),a_i(i+1)-a_i(i),sa)
    next
    sa = if(sa<k-a_i(n-1)+a_i(0),k-a_i(n-1)+a_i(0),sa)
    console.writeline(k-sa)
  end sub
end module

Measured memory_bytes: 35676
import java.util.Scanner;

/**
 * https://abc042.contest.atcoder.jp/tasks/arc058_b
 */
public class Main {

	static final int MOD = 1000000007;
	static long[] modDp;
	static long[] modInvDp;
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();

		int N = H+W-2;
		modDp = new long[N+1];
		modInvDp = new long[N+1];
		modDp[0] = 1; 
		for (int i=1; i<=N; i++) modDp[i] = getMod(modDp[i-1]*i);
		modInvDp[N] = getInverse(modDp[N]);
		for (int i=N; i>0; i--) modInvDp[i-1] = modInvDp[i]*i % MOD;
		
		long ans = 0;
		for(int x=B+1; x<=W; x++){
			ans = (ans + getCombination((x-1)+(H-A-1),x-1)*getCombination((A-1)+(W-x),A-1))%MOD;
		}
		System.out.println(ans);
		
	}
	
	
	static long getCombination(int n, int r){
		long ans = modDp[n];
		ans = ans*modInvDp[r] % MOD;
		ans = ans*modInvDp[n-r] % MOD;
		return ans;
	}

	static long getInverse(long a) {
		return getPower(a, MOD-2);
	}
	
	static long getMod(long a){
		return a>=0 ? a%MOD : MOD + a%MOD;
	}
	
	static long getPower(long n, long m) {
		if(m==0){
			return 1;
		}else if(m%2==0){
			return getPower(getMod(n*n), m/2);
		}else{
			return getMod(n*getPower(n,m-1));
		}
	}
}


Measured memory_bytes: 26068
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

signed main()
{
  ll K;
  cin >> K;

  queue<ll> que;
  FOR(i, 1, 9)
  {
    que.push(i);
  }
  FOR(i, 1, K - 1)
  {
    ll s = que.front();
    que.pop();
    FOR(j, -1, 1)
    {
      ll add = (s % 10) + j;
      if (add >= 0 && add <= 9)
        que.push(s * 10 + add);
    }
  }

  cout << que.front() << endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <fstream>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#include <cmath>
#include <climits>

using namespace std;

int main() {
    int A; cin >> A;
    int P; cin >> P;

    int ans = (3 * A + P)/2;
    
    cout << ans << endl;

    return 0;
}

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

int main() {
    int n, m, one_try_time, ans;
    cin >> n >> m;
    one_try_time = ((n - m) * 100 + 1900 * m);
    //　確率pの事象が起こるまで試行を繰り返した場合の試行回数の期待値は1/p
    ans = one_try_time * pow(2, m);
    cout << ans << endl;
}

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

int main(){
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    int sum = 0;
    for(int i = 0; i < n; i++){
        sum += a[i];
    }

    if(h - sum > 0) cout << "No" << endl;
    else cout << "Yes" << endl;
    
   return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

const int inf = 1<<29;
int edge[22][22];

int main(){
    int i,j,k,n,m,a,b,c,d,start,end,money,hasira;

    rep(i,22) rep(j,22) edge[i][j] = inf;
    rep(i,22) edge[i][i] = 0;

    cin >> n;
    cin >> m;
    rep(i,m){
        scanf("%d,%d,%d,%d",&a,&b,&c,&d);
        a--, b--;
        edge[a][b] = c;
        edge[b][a] = d;
    }
    scanf("%d,%d,%d,%d",&start,&end,&money,&hasira);

    // worshall
    rep(k,n){
        rep(i,n){
            rep(j,n){
                edge[i][j] = min(edge[i][j], edge[i][k] + edge[k][j]);
            }
        }
    }

    printf("%d\n",money - hasira - (edge[start-1][end-1] + edge[end-1][start-1]));

    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
#define MAX 100000000

int main() {
	int n; cin >> n;
	double x;
	string u;

	double sum = 0.0;
	for (int i = 0; i < n; i++) {
		cin >> x >> u;

		if (u == "JPY") {
			sum += x;
		}
		else {
			sum += (x * 380000.0);
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int h,w,a,b,x,y,s;
	scanf("%d %d",&h,&w);
	scanf("%d %d",&a,&b);
	y=h/a;
	x=w/b;
	s=h*w-a*y*b*x;
	printf("%d\n",s);
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<vector<int>> candy(2,vector<int>(N));
  for (int i = 0; i<2;i++){
    for (int j = 0; j < N; j++){
      cin >> candy.at(i).at(j);
    }
  }
  vector<int>vec(N);
  for (int j = 0; j < N; j++){
    for (int k = 0; k<=j;k++){
      vec.at(j)+= candy.at(0).at(k);
    }
      for (int l = j;l < N;l++){
      vec.at(j) += candy.at(1).at(l);
      
    }
  }
  sort(vec.begin(),vec.end());
  cout << vec.at(N-1);
}
    
      

Measured memory_bytes: 256
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, P] = [int(input_raw[0]), int(input_raw[1])]
    input_raw = read_func().strip().split()
    E_count = 0
    O_count = 0
    for i in range(N):
        if int(input_raw[i]) % 2 == 0:
            E_count += 1
        else:
            O_count += 1

    if P == 1:
        if O_count==0:
            print 0;
            return

    if O_count > 0:
        print (2**E_count ) * (2 ** (O_count - 1))
    else:
        print (2**E_count )


if __name__ == '__main__':
    main()


Measured memory_bytes: 2932
<?php
fscanf(STDIN, "%d", $x);
$a = 1;
for ($b = 2; $b <= sqrt($x); $b++) {
	for ($p = 2; $p < 10; $p++) {
		$n = $b ** $p;
		if ($n > $a && $n <= $x) $a = $n;
	}
}
echo $a;

Measured memory_bytes: 4728
#include <iostream>
#include <cmath>

using namespace std;

long long N;

int digit(long long n) {
  int i;
  for (i = 1; pow(10, i) <= n; i++)
    ;
  return i;
}

void solve() {
  int ans = digit(N);
  for (long long i = 1; i <= sqrt(N); i++) {
    if (N % i == 0) {
      ans = min(ans, digit(max(i, N / i)));
    }
  }
  cout << ans << endl;
}

int main() {
  cin >> N;
  solve();
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main() {
	for (int t, n; cin >> t >> n, (t | n) != 0; ) {
		int m[300][300];
		memset(m, 0, sizeof(m));
		rep(i, n) {
			int x, y; cin >> x >> y;
			m[y + 100][x + 100] = -1;
		}
		int sx, sy; cin >> sx >> sy;
		queue<pair<int, pii> > q;
		q.push(mp(1, mp(sx + 100, sy + 100)));
		int ans = 0;
		while(!q.empty()) {
			int turn = q.front().fst;
			int x = q.front().snd.fst;
			int y = q.front().snd.snd;
			q.pop();
			if ( turn - 1 > t) continue;
			if (m[y][x] != 0) continue;
			ans++;
			m[y][x] = turn;
			
			int dx[] = {0, 1, -1, 1, -1, 0};
			int dy[] = {1, 1, 0, 0, -1, -1};
			rep(i, 6) {
				int tx = x + dx[i];
				int ty = y + dy[i];
				q.push(mp(turn + 1, mp(tx, ty)));
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
;; E - Change a Little Bit

(defun main ()
  (let* ((N (read))
         (C (loop repeat N collect (read))))
    (princ (solve N C))
    (fresh-line)))

(defparameter *modulus* (+ (expt 10 9) 7))

(defun solve (N C)
  (let ((expt-4 (make-array N)))
    (loop for i below N
          for e = 1 then (mod (* e 4) *modulus*)
          do (setf (aref expt-4 i) e))
    (setf C (sort C #'<))
    (mod (loop for cost in C
               for i from 0
               sum (* cost (aref expt-4 (1- N)) (- (1+ N) i)))
         *modulus*)))

(main)


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

int main(){
    int n, m;
    cin >> n >> m;
    int column[m];
    int matrix[n][m];

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

    for(int i = 0; i < m; i++)cin >> column[i];
    
    for(int i = 0; i < n; i++){
        int temp = 0;
        for(int j = 0; j < m; j++){
            temp += column[j] * matrix[i][j];
        }
        cout << temp << endl;
    }

    return 0;
}

Measured memory_bytes: 3112