akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <utility>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int func(int n){
    if(n%2==0){
        return n/2;
    }else{
        return 3*n+1;
    }
}

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b < c){
         cout<< 2*b+a+1 <<endl;
    }else{
        cout<<b+c<<endl;
    }
   
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
// #include <bits/stdc++.h>
#include <vector>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <iostream>
#include <random>
#include <queue>
#include <algorithm>
#include <climits>
#include <map>
#include <set>
#include <stack>
#include <sstream>
#include <cstring>
#include <deque>

 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;
typedef vector<cd> vcd;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vl> vvl;


#define FOR(i,a,b) for (int i=a; i<b; i++)
#define F0R(i,a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = b; i > a; i--)
#define F0Rd(i,a) for (int i = a; i > -1; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define pob pop_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define que queue
#define pa pair
#define ex(m,i) m.find(i)!=m.end()
#define nex(m,i) m.find(i)==m.end()


#define uniq(x) x.resize(unique(all(x))-x.begin())
 
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
const double epsilon = 1e-12;
const int ds[4][2] = {
    {-1,0},
    {1,0},
    {0,-1},
    {0,1}
};
 

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

    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    
    string s1, t1; cin >> s1 >> t1;

    int cmax = 0;
    int ci = 0;
    do{
        int t = 0;
        for(int i = ci; i < ci + sz(t1); i++){
            if(s1[i]==t1[i-ci]) t++;
        }
        cmax = max(cmax,t);
        // printf("%d\n",t);
        if(ci+sz(t1)>=sz(s1)) break;
        ci++;
    }
    while(1);

    printf("%d\n",sz(t1)-cmax);

    return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3296
import java.io.*;
import java.util.*;

/**
 * Created by Ayushi on 13 Sep 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        StringTokenizer st;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(br.readLine());

        if (t == 0) System.out.println(1);
        else System.out.println(0);
        br.close();
    }
}


Measured memory_bytes: 32596
#include <bits/stdc++.h>
#define MAX_PRIME 100003
//#define DBG
using namespace std;

using ll = long long;

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

  double maxpr_sq = sqrt((double) MAX_PRIME);
  ll maxpr_sq_ll = ((ll) maxpr_sq) + 1;

  bool is_prime = true;
  ll max_j;
  for(ll i = x; i < MAX_PRIME; i++){
    is_prime = true;
    max_j = (maxpr_sq_ll < i - 1) ? maxpr_sq_ll : i - 1;
    #ifdef DBG
    printf("i:%lld max_j:%lld maxpr_sq_ll:%lld\n", i, max_j, maxpr_sq_ll);
    #endif
    for(ll j = 2; j <= max_j; j++){
      if(i % j == 0){
        is_prime = false;
    #ifdef DBG
        printf("i is not prime i:%lld j:%lld max_j:%lld maxpr_sq_ll:%lld\n", i, j, max_j, maxpr_sq_ll);
    #endif
        break;
      }
    }
    if(is_prime == true){
      cout << i << endl;
      return 0;
    }
  }

  // 全部falseで抜けた場合(10000が来たときとか)は10007
  
  cout << (MAX_PRIME) << endl;
  return 0;
}


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

int main(){
    int64_t n;
    cin >> n;
    int64_t a[100100];
    for(int64_t i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a, a+n, std::greater<>());
    int64_t h = 0;
    int64_t w = 0;
    for(int64_t i=0; i<n-1; i++){
        if(a[i]==a[i+1]){
            if(h==0){
                h = a[i];
                i++;
            }else if(w==0){
                w = a[i];
                i++;
            }
        }
        if(h!=0 && w!=0) break;
    }
    cout << h*w << endl;
    return 0;
}

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

using namespace std;

#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)

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

int main(){
	cin.sync_with_stdio(false);
	string str;
	cin>>str;
	str[3] = '8';
	cout<<str<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int X,Y,c=0;
  scanf("%d %d",&X,&Y);
  for(int i=2*X;i<=4*X;i+=2){
    if(Y==i) c=1;
  }
  if(c==1) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 1648
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n; cin>>n;
	set<int> s;
	s.insert(n);
	int ans=0,t=n,cnt=1;
	while(true){
		int c;
		if(t%2==0) c=t/2;
		else c=(3*t)+1;
		if(s.count(c)){
			ans=cnt+1;
			break;
		}
		else {
			s.insert(c);
			t=c;
		}
		//cout<<c<<endl;
		cnt++;
	}
	//--ans;
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int a, b, c; cin >> a >> b >> c;
  cout << min({
    a + b,
    b + c,
    c + a,
  }) << endl;
}


Measured memory_bytes: 256
arr = []
while n = gets.to_i
  break if n == 0
  arr << n
end

count_hash = {}
1.upto(100){ |i| count_hash[i] = 0 }

max = 0
arr.each do |i|
  count_hash[i] += 1
  max = count_hash[i] if count_hash[i] > max
end

puts count_hash.select { |key, value| value == max }.keys

Measured memory_bytes: 8592
import math
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def pop2(li):
	c=1
	i=li.pop(0)
	while 1:
		j=li.pop(0)
		if j==i:
			c+=1
		else:
			break
	return i,c,[j]+li

n = readInt()
a = readInts()

li = []
ri = []

d1 = defaultdict(int)
d2 = defaultdict(int)

for i in range(n):
	d1[i+a[i]]+=1
	d2[i-a[i]]+=1

ans = 0

for key in d1:
	ans+=d1[key]*d2[key]

print(ans)

Measured memory_bytes: 73844
#include <iostream>

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

using namespace std;

int main()
{
	int h,w;
	while(cin >> h >> w)
	{
		if(h == 0 && w == 0) break;

		rep(i,h)
		{
			rep(j,w)
			{
				if(i == 0 || i == h-1 || j == 0 || j == w-1)
				{
					cout << "#";
				}
				else
				{
					cout << ".";
				}
			}
			cout << endl;
		}
		cout  << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define maxn 1003
#define INF 100000000000000000ll
using namespace std;
long long x[maxn],y[maxn],p[36];
int n,cnt,dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
char s[4]={'R','U','L','D'};
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld%lld",x+i,y+i);
	for(int i=2;i<=n;i++)if(((x[i-1]+y[i-1]+INF)&1)^((x[i]+y[i]+INF)&1)){puts("-1");return 0;}
	cnt=((x[1]+y[1]+INF)&1?34:35);
	for(int i=33;i>=0;i--)p[34-i]=(1ll<<i);
	if(cnt==35)p[cnt]=1;
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++)printf("%lld ",p[i]);puts("");
	for(int j=1;j<=n;j++){
		long long X=0,Y=0,mi,tmp;
		int mii;
		for(int step=1;step<=cnt;step++){
			mi=INF;
			for(int i=0;i<4;i++){
				tmp=abs(X+p[step]*dx[i]-x[j])+abs(Y+p[step]*dy[i]-y[j]);
				if(tmp<mi)mi=tmp,mii=i;
			}
			X+=p[step]*dx[mii],Y+=p[step]*dy[mii];
			putchar(s[mii]);
		}
		puts("");
	}
	return 0;
}

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


string to_s(int n){
	string s;
	while(n){
		s+=n%10+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
string FizzBuzz(int n){
	if(n%3==0&&n%5==0)return "FizzBuzz";
	if(n%3==0)return "Fizz";
	if(n%5==0)return "Buzz";
	return to_s(n);
}

int main(){
	int m,n;
	bool f[1000];
	while(cin>>m>>n,m|n){
		fill_n(f,m,true);
		string s;
		int rest=m;
		int num=1,a=0;
		for(int i=0;i<n;i++){
			cin>>s;
			if(rest==1)continue;		
			while(!f[a]){
				a=(a+1)%m;
			}
			if(s!=FizzBuzz(num)){
				f[a]=false;
				rest--;
			}
			a=(a+1)%m;
			num++;
		}
		bool first=true;
		for(int i=0;i<m;i++){
			if(!f[i])continue;
			if(!first)cout<<' ';
			first=false;
			cout<<i+1;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
vector<vector<int>> to;
vector<int> aoki, taka;
vector<int> ran;

void aokidfs(int now, int from) {
	rep(i, to[now].size()) {
		if (to[now][i] == from) continue;
        aoki[to[now][i]] = aoki[now] + 1;
		aokidfs(to[now][i], now);
	}
}
void takadfs(int now, int from) {
	rep(i, to[now].size()) {
		if (to[now][i] == from) continue;
        taka[to[now][i]] = taka[now] + 1;
		takadfs(to[now][i], now);
	}
}

int main() {
	int n, u, v;
	cin >> n >> u >> v;
	u--; v--;
	to.resize(n);
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	aoki.resize(n);
	taka.resize(n);
	aoki[v] = 0;
	taka[u] = 0;
	aokidfs(v, -1);
	takadfs(u, -1);
	int ans = 0;
	rep(i, n) {
		if (taka[i] < aoki[i]) ans = max(ans, aoki[i]-1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 10368
import java.io.*;
import java.util.StringTokenizer;

public class Main {
  private static PrintWriter out;

  public static void main(String[] args) {
    Main main = new Main();
    Runtime.getRuntime().addShutdownHook(new Thread(() -> out.close()));
    try {
      main.run(args);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  private void run(String[] arguments) throws Exception {
    MyScanner sc = new MyScanner();
    out = new PrintWriter(new BufferedOutputStream(System.out));

    int K = sc.nextInt(), A = sc.nextInt(), B = sc.nextInt();

    String ans = "NG";
    for (int i = A; i <= B; i++) {
      if (i%K==0){
        ans="OK";
        break;
      }
    }

    out.println(ans);
    out.close();
  }

  /*          
   * Form: http://codeforces.com/blog/entry/7018
   */
  private class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    MyScanner() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

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

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

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


Measured memory_bytes: 33820
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

vector<vector<int>> G;
int dp[1010101];
bool seen[1010101];
bool ok = true;
int dfs(int v) {
    if (dp[v] > -1) return dp[v];
    seen[v] = true;
    int ret = 0;
    for (auto nv : G[v]) {
        if (dp[nv] == -1 && seen[nv]) {
            ok = false;
            continue;
        }
        chmax(ret,dfs(nv)+1);
    } 
    return dp[v] = ret;
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<vector<int>> A(N, vector<int>(N-1));
    rep(i,N) {
        rep(j,N-1) {
            cin >> A[i][j];
            --A[i][j];
        }
    }

    map<pii, int> dic;
    int cur = 0;
    rep(i,N) {
        for (int j = i+1; j < N; ++j) {
            dic.emplace(make_pair(i,j),cur);
            cur++;
        }
    }
    G.resize(cur);
    rep(i,N) {
        rep(j,N-2) {
            pair<int, int> p = minmax(A[i][j],i);
            pair<int, int> q = minmax(A[i][j+1],i);
            G[dic[p]].emplace_back(dic[q]);
        }
    }
    rep(i,cur) dp[i] = -1;
    int ans = 0;
    rep(i,cur) {
        if (seen[i]) continue;
        chmax(ans,dfs(i));
    }

    cout << (ok ? ans+1 : -1) << ln;
}

Measured memory_bytes: 66432
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
int N;
string S[111111];
 
 
int en(string s){
    int ret=0;
    rep(i,s.size())ret=ret*26+s[i]-'a';
 
    int t=26;
    for(int i=1;i<s.size();i++){
        ret+=t;
        t*=26;
    }
    return ret;
}
 
const int MAX=26*26*26*26;
bool ex[MAX*4];
 
string smin(string &a,string &b){
    if(a.size()<b.size())return a;
    if(a.size()>b.size())return b;
    return min(a,b);
}
 
signed main(){
    cin>>N;
    rep(i,N)cin>>S[i];
 
    rep(i,N){
        rep(j,S[i].size()){
            for(int len=1;len<=4&&j+len<=S[i].size();len++){
                int tmp=en(S[i].substr(j,len));
                ex[tmp]=1;
            }
        }
    }
 
    string ans="zzzzzzz";
    for(char a='a';a<='z';a++){
        string s=string(1,a);
        if(!ex[en(s)])ans=smin(ans,s);
        for(char b='a';b<='z';b++){
            string t=s+string(1,b);
            if(!ex[en(t)])ans=smin(ans,t);
            for(char c='a';c<='z';c++){
                string u=t+string(1,c);
                if(!ex[en(u)])ans=smin(ans,u);
                for(char d='a';d<='z';d++){
                    string v=u+string(1,d);
                    if(!ex[en(v)])ans=smin(ans,v);
                }
            }
        }
    }
    cout<<ans<<endl;
 
    return 0;
}

Measured memory_bytes: 8720
import java.util.Scanner;
public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        String S = sc.next();
        if (S.contains("7"))
        {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

typedef long long ll;
int vis[100000];

int main()
{
  ios::sync_with_stdio(false);
  int s;
  cin >> s;
  memset(vis, 0, sizeof(vis));
  for(int i = 1; i < 1000000; ++ i) {
    if(vis[s]) { cout << i << endl; return 0; }
    vis[s] = 1;
    if(s&1) s=s*3+1;
    else s=s/2;
  }
  return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a,x,b) (a<=x && x<=b)
#define WS std::cout<<" ";
#define NL std::cout<<"\n"
#define OUT(dist) std::cout<<(dist);
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;



int main(){
    INIT;
    int N; cin >> N;
    V<int> p(N), v(N); 
    REP(i,N) { cin >> p[i]; v[i] = p[i]; }
    sort(ALL(v));
    int cnt = 0;
    REP(i,N) {
        if(p[i] != v[i]) cnt++;
    }
    if(cnt <= 2) cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int K = int.Parse(s[1]);

            s = Console.ReadLine().Split(' ');
            int R = int.Parse(s[0]);
            int S = int.Parse(s[1]);
            int P = int.Parse(s[2]);

            string T = Console.ReadLine();
            Char[] t = new Char[T.Length];

            int ans = 0;
            for (int i = 0; i < T.Length; i++)
            {
                if (i >= K)
                {
                    if(T[i] == t[i-K])
                    {
                        t[i] = '*';
                        continue;
                    }
                }


                switch(T[i])
                {
                    case 'r':
                        t[i] = 'r';
                        ans += P;
                        break;

                    case 's':
                        t[i] = 's';
                        ans += R;
                        break;

                    case 'p':
                        t[i] = 'p';
                        ans += S;
                        break;
                }
            }

            Console.WriteLine("{0}", ans);
            return;
        }
    }
}



Measured memory_bytes: 13536
s = input()
t = input()

# 還元して同じならいいんじゃないか
d = {"A":1, "B":-1}
def make(s):
    ss = [0]
    for i in s:
        if ss[-1] == 0:
            ss.append(d[i])
        else:
            if ss[-1] == d[i]:
                ss.append(ss[-1]*-1)
            else:
                ss.append(0)
    return ss

sl = make(s)
tl = make(t)

def convert(a,b):
    if a == 0:
        return b
    if a == 1:
        c = b-a
        if c == -2:
            c = 1
        return c
    if a == -1:
        c = b-a
        if c == 2:
            c = -1
        return c

q = int(input())
ans = []
for i in range(q):
    a,b,c,d = map(int, input().split())
    sleft = sl[a-1]
    sright = sl[b]
    tleft = tl[c-1]
    tright = tl[d]
    if convert(sleft, sright) == convert(tleft, tright):
        ans.append("YES")
    else:
        ans.append("NO")
print(*ans, sep="\n")

Measured memory_bytes: 8084
#include <bits/stdc++.h>
using namespace std;
using pi = pair <int, int>;
using ll = long long;
const ll mod = 1e9 + 7;
const int N = 2e5 + 10;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    string s, t;
    cin >> n >> s >> t;
    for (int i = 0; i < n; ++i)
		cout << s[i] << t[i];
}


Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Main {

    private static final long MOD = 1_000_000_000 + 7;

    static long pow(long a, long x){
        long res = 1L;
        long t = a;

        while(x > 0){
            if((x & 1) == 1){
                res *= t;
                res %= MOD;
            }
            t *= t;
            t %= MOD;

            x /= 2;
        }

        return res;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        int n = Integer.parseInt(br.readLine());
        List<Long> a = Arrays.stream(br.readLine().split(" "))
                .mapToLong(Long::parseLong)
                .boxed()
                .collect(Collectors.toList());

        List<Long> fact = new ArrayList<>();
        fact.add(1L);
        fact.add(1L);
        for(int i = 2; i <= n + 1; i++){
            Long next = (fact.get(i - 1) * i) % MOD;
            fact.add(next);
        }

        List<Long> ans = new ArrayList<>();
        for(int i = 1; i <= n + 1; i++){
            long v = (fact.get(n + 1) * pow(fact.get(i), MOD - 2)) % MOD;
            v = (v * pow(fact.get(n + 1 - i), MOD - 2)) % MOD;
            ans.add(v);
        }

        Long sum = 0L;
        for(Long v : a){
            sum += v;
        }

        long twoVal = sum - (long)n * (1 + n) / 2;
        int pre = a.indexOf(twoVal);
        int post = n - a.lastIndexOf(twoVal);

        ans.set(0, ans.get(0) - 1);
        for(int i = 1; i <= pre + post; i++){

            long v = (fact.get(pre + post) * pow(fact.get(i), MOD - 2)) % MOD;
            v = (v * pow(fact.get(pre + post - i), MOD - 2)) % MOD;
            ans.set(i, (ans.get(i) - v + MOD) % MOD);
        }

        for(Long v : ans){
            bw.write(String.format("%d\n", v));
        }
        bw.flush();

    }
}

Measured memory_bytes: 82316
#include <stdio.h>

int main()
{
    int i, j, n;
    char str[10000];

    scanf("%d ", &n);
    gets(str);

    for( i=0; i<strlen(str); i++ )
    {
        j = str[i] + n;

        if( j>90 )
        {
            j = j - 90 + 64;
        }

        str[i] = j ;
    }

    printf("%s",str);

    return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int N=2e5+5;
int a[N],num[N];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        num[a[i]]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
        ans+=(1LL*num[i]*(num[i]-1)/2);//cout<<"ans="<<ans<<endl;
    for(int i=1;i<=n;i++)
    {
        ll t=1LL*num[a[i]]*(num[a[i]]-1)/2;
        ll x=1LL*(num[a[i]]-1)*(num[a[i]]-2)/2;
        printf("%lld\n",ans-t+x);
    }
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
using namespace std;
 
int main() {
  int a, b, c, d;

  cin >> a >> b >> c >> d;
  int left = a + b;
  int right = c + d;
    if (left > right) {
        cout << "Left" << endl;
    } else if (left == right) {
        cout << "Balanced" << endl;
    } else if (left < right) {
        cout << "Right" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int pre[100005];
int main()
{
   	int s;
  	cin >> s;
  	set< int > st;
  	st.insert(s);
  	for(int i = 2 ; i <= 1000001 ; i++){
		if(s % 2 == 0)
          s /= 2;
      else
          s = 3 * s + 1;
      if(st.count(s)){
		cout << i << endl;
        return 0;
      }
   	  st.insert(s);
    } 
 	return 0; 
}

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

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

    string s="n";
    for(int i=0;i<=n-m;i++){
        for(int j=0;j<=n-m;j++){
            bool ok=true;
            for(int k=0;k<m;k++){
                for(int l=0;l<m;l++){
                    if(a[i+k][j+l]!=b[k][l]){
                        ok=false;
                    }
                }
            }
            if(ok){s="y";break;}
        }
    }

    if(s=="y"){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] nineCosts = new int[n + 1];
        int[] sixCosts = new int[n + 1];
        for (int i = 0; i <= n; i++) {
            nineCosts[i] = getCost(i, 9);
            sixCosts[i] = getCost(i, 6);
        }
        int best = Integer.MAX_VALUE;
        for (int i = 0; i < nineCosts.length; i++) {
            best = Math.min(best, nineCosts[i] + sixCosts[n - i]);
        }
        System.out.println(best);
        sc.close();
    }

    private static int getCost(int x, int base) {
        int cost = 0;
        while (x != 0) {
            cost += x % base;
            x /= base;
        }
        return cost;
    }
}


Measured memory_bytes: 22868
#include<stdio.h>

int main() {
	int a, b;
	while (1) {
		scanf("%d %d",&a,&b);
		if ((!a)&&(!b)) break;
		if (a < b) printf("%d %d\n", a, b);
		else printf("%d %d\n", b, a);
	}
	return 0;
}


Measured memory_bytes: 2680
#include<bits/stdc++.h>
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define getI(a) scanf("%d",&a)
int main(){
    int n;
    while(~getI(n)){
        F(i,n,1000){
            int num=i;
            int fi=num%10;
            num/=10;
            int se=num%10;
            num/=10;
            int th=num%10;
            if(fi==se&&se==th){
                printf("%d\n",i);
                break;
            }
        }
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int N;
	long[] A;

	Main(BufferedReader in) throws IOException {
		N = Integer.parseInt(in.readLine());
		A = new long[N];
		String[] tokens = in.readLine().split(" ");
		for (int i = 0; i < N; ++i) {
			A[i] = Long.parseLong(tokens[i]);
		}
		Arrays.sort(A);
		long[] newA = new long[N];
		for (int i = N - 1; i >= 0; --i) {
			newA[i] = A[N - 1 - i];
		}
		A = newA;

	}

	void calc() {
		long result = 0;
		for (int i = 1; i < N; ++i) {
			result += A[i / 2];
		}
		System.out.println(result);
	}

	void showResult() {
	}
}


Measured memory_bytes: 66084
#pragma GCC optimize("O3")
    #pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize("unroll-loops")
     
    #include <algorithm>
    #include <bitset>
    #include <cassert>
    #include <chrono>
    #include <cmath>
    #include <complex>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <ctime>
    #include <deque>
    #include <functional>
    #include <iomanip>
    #include <iostream>
    #include <iterator>
    #include <limits>
    #include <climits>
    #include <list>
    #include <map>
    #include <numeric>
    #include <queue>
    #include <random>
    #include <ratio>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <string>
    #include <unordered_map>
    #include <unordered_set>
    #include <utility>
    #include <vector>
    using namespace std;
     
    typedef long long ll;
    typedef long double LD;
    #define int ll
    #define double LD
    #define pb push_back
    #define mp make_pair
    #define REP(i,n) for (int i = 0; i < n; i++)
    #define loop(i,n) for (int i = 0; i < n; i++)
    #define FOR(i,a,b) for (int i = a; i < b; i++)
    #define REPD(i,n) for (int i = n-1; i >= 0; i--)
    #define FORD(i,a,b) for (int i = a; i >= b; i--)
    #define remax(a,b) a = max(a,b)
    #define remin(a,b) a = min(a,b)
    #define mem(a, b) memset(a, b, sizeof a)
    #define append push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define print(x) cout << (x) << endl
    #define PRECISION(x) cout << fixed << setprecision(x)
    #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
     
    const double PI=acos(-1);
    const int MOD = 1000000007;
    const int FMOD = 998244353;
    const double eps = 1e-9;
     
    mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
    string s;
    int dp[1000010][2];
    int solve(int idx,int c)
    {
    	if(idx==s.size())
    	{
    		return c;
		}
    	if(dp[idx][c]!=-1)
    	{
    		return dp[idx][c];
		}
    	int val=s[idx]-'0'+c;
    	int ans=1e9;
    	if(val<10)
    	{
    		ans=min(ans,solve(idx+1,0)+val);
		}
		ans=min(ans,solve(idx+1,1)+10-val);
		return dp[idx][c]=ans;
	}
    
    signed main()
    {
    	cin>>s;
    	
    	reverse(s.begin(),s.end());
    	memset(dp,-1,sizeof(dp));
    	cout<<solve(0,0);
	}

Measured memory_bytes: 95108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

ll mod(ll a) {
	return ((a%=MOD) > 0 ? a : a+MOD);
}

ll fact_[200005];

ll fact(ll n) {
	if(n == 0) fact_[0] = 1;
	if(n == 1) fact_[1] = 1;
	if(fact_[n] != 0) return fact_[n];
	return fact_[n] = (fact(n-1) * n) % MOD;
}
/*
ll fact(ll n) {
	ll res = 1;
	for(ll i=1;i<=n;i++) {
		res *= i;
		res %= MOD;
		if(res==0) res = MOD;
	}
	return res;
}
*/
//aのb乗
ll modPow(ll a, ll b) {
	ll res = 1;
	while(b > 0) {
		if(b & 1) res = res * a % MOD;
		if(res==0) res = MOD;
		a = a * a % MOD;
		if(a==0) a = MOD;
		b >>= 1;
	}
	return res;
}

ll comb(ll a, ll b){
	if(a==b || b==0) return 1;
	return (((fact(a)*modPow(fact(b),MOD-2))%MOD)*modPow(fact(a-b),MOD-2))%MOD;
}

int main(){
	ll n, k;
	cin >> n >> k;
	ll ans = 0;
	for(ll i=0;i<min(n,k+1);i++) {
		// 0人となる部屋がi個である場合の数
		// 0人となる部屋の選び方 -> nCi
		// i人がn-iの部屋のどこかへ移動 -> {n-1}C{i}
		(ans += comb(n,i) * comb(n-1, i) % MOD) %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int n, p;
    cin >> n >> p;
    int ans = 0;
    for (int i = 1; i * i <= p; i++)
    {
        if (p % i != 0)
            continue;
        int q = p, x = p / i;
        bool f = true;
        rep(j, n - 1)
        {
            if (i == 1)
                break;
            q /= i;
            if (q % i != 0)
            {
                f = false;
                break;
            }
        }
        if (f)
            ans = max(ans, i);
        q = p;
        f = true;
        rep(j, n - 1)
        {
            q /= x;
            if (q % x != 0)
            {
                f = false;
                break;
            }
        }
        if (f)
            ans = max(ans, x);
    }
    cout << ans << endl;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(a) cerr << #a << ": " << a << endl
#define endl '\n'
#define int long long

const int N = 1e5+5;

int  n, k;
int a[N];
int cache[N];

int dp(int curr)
{
      int &res = cache[curr];
      if(res != -1) return res;

      res =0;
      for(int i=1; i<=n; i++)
      {
            int rem = curr - a[i];
            if(rem<0) break;
            res |= (dp(rem)==0);
      }
      return res;
}


int32_t main()
{
      IOS;

      cin>>n>>k;
      for(int i=1; i<=n; i++) cin>>a[i];

      memset(cache, -1, sizeof cache);

      if(dp(k)) cout<<"First"<<endl;
      else cout<<"Second"<<endl;

      return 0;
}




Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int gcd(int a, int b) {
	while (b > 0) {
		int t = b;
		b = a % b;
		a = t;
	}
	return a;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		res = gcd(res, A[i]);
	}

	cout << res << endl;
}

Measured memory_bytes: 1024
X, K, D = map(int,input().split())
XX = abs(X)
if K > XX // D:
    if (K - (XX // D)) % 2 == 0:
        ans = XX - (XX // D) * D
        print(abs(ans))
    else:
        ans = (XX - (XX // D) * D) - D
        print(abs(ans))
else:
    ans = XX - D * K
    print(abs(ans))

Measured memory_bytes: 9180
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) std::cin>>(P)
#define IN2(P1,P2) std::cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) std::cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) std::cin>>V[I]
#define OUT(P) std::cout<<P<<std::endl
#define OUT2(P1,P2) std::cout<<P1<<" "<<P2<<std::endl
#define OUT3(P1,P2,P3) std::cout<<P1<<" "<<P2<<" "<<P3<<std::endl
#define OUTS(I,N,V) REP(I,N) std::cout<<V[i]<<std::endl
#define ALL(C) (C).begin(),(C).end()
using namespace std;
using namespace __gnu_pbds;
int A,B,C;
inline void solve(){
  IN3(A,B,C);
  OUT(A*B/2);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> edge(n + 1);
    REP(i, m)
    {
        int a, b;
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    queue<int> Q; //from
    Q.push(1);
    vector<bool> visited(n + 1, false);
    visited[1] = true;
    vector<int> ans(n + 1);
    while (!Q.empty()) {
        int q = Q.front();
        Q.pop();
        REP(i, edge[q].size())
        {
            if (!visited[edge[q][i]]) {
                visited[edge[q][i]] = true;
                Q.push(edge[q][i]);
                ans[edge[q][i]] = q;
            }
        }
    }
    cout << "Yes" << endl;
    FOR(i, 2, n + 1)
    {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 10144
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(void)
{
    char c[10];
    int d,i,j,k,l,m=754,n;
    gets(c); l=strlen(c);
    for(i=0;i<l-2;i++)
    {
       k=((c[i]-48)*100)+((c[i+1]-48)*10)+(c[i+2]-48);
       d=abs(753-k);
       if(d<m)
            m=d;
    }
    printf("%d",m);
    return 0;
}


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

int main() {
    int K;
    cin >> K;
    string S;
    cin >> S;
    if (S.size()<=K) {
        cout << S << endl;
    }
    else {
        for (int i=0; i<K; i++) {
            cout << S.at(i);
        }
        cout << "..." << endl;
    }
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N; cin >> N;
  int sum[2][111];
  rep(k, 2) rep(i, N) {
    cin >> sum[k][i];
    if (i > 0) sum[k][i] += sum[k][i - 1];
  }

  int ans = 0;
  rep(i, N) {
    ans = max(ans, sum[0][i] + sum[1][N - 1] - (i > 0 ? sum[1][i - 1] : 0));
  }

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

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

string toUpper(string s){
    string t = s;
    for(int i = 0; i < s.size(); i++){
        t[i] = toupper(s[i]);
    }
    return t;
}

int main(){
    string str1, str2;
    int n = 0, taro_s=0, hana_s=0;
    cin >>n;
    for(int i =0; i<n; i++){
        cin >>str1 >>str2;
        //cout << str1 << " " << str2 << endl;;
        if(str1 > str2) taro_s += 3;
        else if(str1 < str2) hana_s += 3;
        else if(str1 == str2){
            taro_s++;
            hana_s++;
        }
    }
    cout << taro_s << " " << hana_s << endl;
    return 0;
}


Measured memory_bytes: 3172
x = gets.to_s.chomp
n = x.size

i = 0
ans = n

t = 0
x.each_char do |i|
  
  if x[i] == "S"
    t += 1
  else
    if t > 0
      ans -= 2
      t -= 1
    end
  end
end

puts ans

Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';

vector <int> bor[50];

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20); 
    #endif

    const int INF = 1e18;

    int n, a;
    cin >> n >> a;
   
    for (int sz = 2; sz <= 40; ++sz) {
        vector <int> a(sz, 1);
        bor[sz].app(1);
        int tot = 1;
        for (int i = 0; tot < n; ++i) {
            int to = i % sz;
            tot /= a[to];
            a[to]++;
            tot *= a[to];
            bor[sz].app(tot);
        }   
    }   

    function <int(int, int)> dv = [&] (int a, int b) {
        return (a + b - 1) / b;
    };

    function <int(int, int)> mul = [&] (int a, int b) {
        if (a == 0 || b == 0)
            return 0ll;
        if (b > INF/a)
            return INF;
        else
            return min(INF, a * b);
    };  

    function <int(int)> solve = [&] (int w) {
        if (w == 1)
            return 0ll;

        int ans = w + a;
        for (int sz = 2; sz <= 40; ++sz) {
            int p = lower_bound(all(bor[sz]), w) - bor[sz].begin();
            ans = min(ans, a * sz + sz + p);
        }   
        return ans;
    };  

    int ptr = 1;
    int ans = INF;
    int cnt = 0;
    while (ptr <= n) {
        int cur = dv(n, ptr);
        ans = min(ans, solve(ptr) + cur);
        if (cur == 1)
            break;
        ptr = dv(n, cur - 1);        
    }   
    cout << ans << endl;

    #ifdef HOME
    cout << Time << endl;
    #endif
}


Measured memory_bytes: 19724
package main

import (
	"fmt"
)

func main() {
	var a, b, fee int
	fmt.Scan(&a, &b)

	if a >= 13 {
		fee = b
	} else if a >= 6 {
		fee = b / 2
	} else {
		fee = 0
	}

	fmt.Println(fee)
}


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

using namespace std;
typedef long long int ll;
#define all(x) x.begin(),x.end()

int main()
{
	ll n;
	cin >> n;
	ll m = 3*n;
	vector<ll> a(m);
	for(ll i = 0; i < m; i++){
		cin >> a[i];
	}

	sort(all(a));
	reverse(all(a));

	ll ans = 0;
	for(ll i = 1; i <= n; i++){
		ans += a[i*2-1];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2560
# coding: utf-8
# Your code here!
N,x=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)

count=0
while len(A)>1:
    temp=A.pop(-1)
    if temp>x:
        break
    else:
        count+=1
        x-=temp

temp=A.pop(-1)

if x==temp:
    print(count+1)
else:
    print(count)

Measured memory_bytes: 3060
#include<stdio.h>
#include<vector>
#include<iostream>
#include<algorithm>
#include<iterator>
#include<queue>
#include<set>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

class Graph{
    public:
    typedef struct Edge{
        ll from, to, cost;
        Edge(ll f, ll t, ll c): from(f),to(t),cost(c){}
    } Edge;

    bool isDirected;
    ll INF = 1LL << 62;
    ll v; // 頂点数
    std::vector<Edge> edges;  // 辺のリスト
    std::vector<std::vector<std::pair<ll,ll>>> list;  // 隣接リスト
    //std::vector<std::vector<ll>> matrix; // 隣接行列
    
    Graph() : isDirected(false){ init(0); }
    Graph(ll n, bool isDirected=false) : isDirected(isDirected) { init(n); }
    void init(ll n){
        v=n;
        edges.clear();
        list.assign(n, std::vector<std::pair<ll,ll>>());
        //matrix.assign(n, std::vector<ll>(n, INF));
    }
    void connect(ll from, ll to){
        con(from, to, 1);
        if(!isDirected) con(to, from, 1);
    }
    void connect(ll from, ll to, ll cost){
        con(from, to, cost);
        if(!isDirected) con(to, from, cost);
    }
    void con(ll from, ll to, ll cost){
        edges.push_back(Edge(from,to,cost));
        list[from].push_back(std::make_pair(to, cost));
        //matrix[from][to] = cost;
    }
};

class HopcroftKarp{
    public:
    Graph G;
    ll setx, sety;
    std::vector<ll> dist, match;
    std::vector<bool> visited, vv;

    HopcroftKarp(Graph G, ll x) : G(G), setx(x),sety(G.v-setx), dist(setx,-1), match(sety,-1), visited(setx, false){}

    void bfs(){
        dist.assign(setx, -1);
        std::queue<ll> que;
        for(ll i=0; i<setx; i++)if(!visited[i]){
            que.push(i);
            dist[i]=0;
        }
        while(!que.empty()){
            ll a = que.front(); que.pop();
            for(ll i=0; i<G.list[a].size(); i++){
                ll c = match[G.list[a][i].first - setx];
                if(c>=0 && dist[c]==-1){
                    dist[c] = dist[a] + 1;
                    que.push(c);
                }
            }
        }
    }
    bool dfs(ll a){
        vv[a] = true;
        for(ll i=0; i<G.list[a].size(); i++){
            ll c = match[G.list[a][i].first - setx];
            if(c<0 || (!vv[c] && dist[c]==dist[a]+1 && dfs(c))){
                match[G.list[a][i].first - setx] = a;
                visited[a] = true;
                return true;
            }
        }
        return false;
    }
    ll Bipartite_Matching(){
        ll ret = 0;
        while(true){
            bfs();
            vv.assign(setx, false);
            ll fl = 0;
            for(ll i=0; i<setx; i++){
                if(!visited[i] && dfs(i)) fl++;
            }
            if(fl==0) return ret;
            ret += fl;
        }
    }
};


int main(){
    ll xs,ys,e,x,y;
    cin >> xs >> ys >> e;
    Graph G(xs+ys, true);
    REP(i,e){
        cin >> x >> y;
        G.connect(x,xs+y,1); // 0, ... ,xs-1, 0(xs), ... ,ys-1(xs+ys-1)
    }
    HopcroftKarp hk(G, xs);
    cout << hk.Bipartite_Matching() << endl;
}


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

#include <vector>

using namespace std;
using ll = long long;

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

    int N = S.length() + 1;
    vector<int> a(N, -1);
    for (int i = 0; i < N; i++) {
        if (i == 0 && S[0] == '<') {
            a[0] = 0;
            int j = i + 1;
            while (j < N) {
                if (S[j - 1] == '<') {
                    a[j] = max(a[j - 1] + 1, a[j]);
                }
                if (S[j - 1] == '>') break;
                j++;
            }
        } else if (i == N - 1 && S[N - 2] == '>') {
            a[N - 1] = 0;
            int j = i;
            while (j >= 0) {
                if (S[j] == '>') {
                    a[j] = max(a[j + 1] + 1, a[j]);
                }
                if (S[j] == '<') break;
                j--;
            }
        }
        if (S[i] == '>' && S[i + 1] == '<') {
            a[i + 1] = 0;
            int j = i;
            while (j >= 0) {
                // if (a[j] != -1) break;
                if (S[j] == '>') {
                    a[j] = max(a[j + 1] + 1, a[j]);
                }
                if (S[j] == '<') break;
                j--;
            }
            j = i + 2;
            while (j < N) {
                // if (a[j] != -1) break;
                if (S[j - 1] == '<') {
                    a[j] = max(a[j - 1] + 1, a[j]);
                }
                if (S[j - 1] == '>') break;
                j++;
            }
        }
    }

    // cout << a[0];
    ll output = a[0];
    for (int i = 1; i < N; i++) {
        output += a[i];
        // cout << " " << S[i - 1] << " " << a[i];
    }
    // cout << endl;
    cout << output << endl;

    return 0;
}


Measured memory_bytes: 5800