akhauriyash/Code-Regression huggingface dataset:
# include "iostream"
# include "cstdio"
# include "cstring" 

using namespace std;

const int maxm=100000+10;
int f[maxm],n;
int thing[maxm],tot; 

int main(){
	thing[++tot]=1;
	register int i,j;
	memset(f,0x3f,sizeof(f)); 
	scanf("%d",&n); 
	i=6; 
	while(i<=n){
		thing[++tot]=i;
		i*=6; 
	}
	i=9; 
	while(i<=n){
		thing[++tot]=i;
		i*=9; 
	}
	f[0]=0; 
	for(i=1;i<=tot;i++){
		for(j=thing[i];j<=n;j++){
			f[j]=min(f[j],f[j-thing[i]]+1); 
		} 
	}
	printf("%d",f[n]); 
	return 0; 
} 

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int,P> P3;
typedef pair<double, P3> P4;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int n, m, dmin[MAX_N],dmax[MAX_N];
vector<vector<P> > g;

int dijkstra(){
    fill(dmax, dmax+n, -1);
    fill(dmin, dmin+n, IINF);
    priority_queue<P, vector<P>, greater<P> > que;
    que.push({0,0});
    while(!que.empty()){
        P p = que.top();
        que.pop();
        int t = p.first, v = p.second;
        if(dmin[v] < t)continue;
        for(auto &e : g[v]){
            int u = e.first, c = e.second;
            if(c < t)continue;
            if(dmin[u] > c){
                dmin[u] = c;
                que.push({c,u});
            }
            dmax[u] = max(dmax[u],c);
        }
    }
}

int main() {
    cin >> n >> m;
    g.resize(n);
    REP(i,m){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        g[a].push_back({b,c});
    }
    dijkstra();
    if(dmin[n-1]==IINF){
        cout << -1 << endl;
    }
    else{
        cout << dmax[n-1] << endl;
    }
    return 0;
}



Measured memory_bytes: 8920
# 2019/04/30
# AtCoder Beginner Contest 085 - B

# Input
n = int(input())
d = list()
for i in range(n):
    d.append(int(input()))

d.sort()

# Count kind of value
cnt = 0
sav_val = -1
for i in range(n):
    if d[i] != sav_val:
        cnt += 1
        sav_val = d[i]

# Output
print(cnt)


Measured memory_bytes: 3060
(defvar N (read))
(defvar dummy -1)
(defvar m (/ N 2))

(defun read-revlist (&optional (N (read)))
  (do ((i (/ N 2) (1- i))
       (l1 nil (cons (read) l1))
       (l2 nil (cons (read) l2)) )
      ((= i 0) (values l1 l2)) ))

(defun hash-table-alist (table)
  (let ((alist nil))
    (maphash (lambda (k v)
               (push (cons k v) alist))
             table)
    alist))

(defun common (l)
  (let ((ht (make-hash-table :test #'equal)))
    (setf (gethash dummy ht) m)
    (dolist (x l)
      (setf (gethash x ht)
	    (1- (or (gethash x ht) m)) ))
    (subseq (sort (hash-table-alist ht) #'< :key #'cdr) 0 2) ))

(defun solve (l1 l2)
  (let ((c1 (common l1))
	(c2 (common l2)) )
    (if (= (caar c1) (caar c2))
        (min (+ (cdar c1) (cdadr c2))
             (+ (cdadr c1) (cdar c2)) )
        (+ (cdar c1) (cdar c2)) )))

(multiple-value-bind (l1 l2) (read-revlist N)
  (princ (solve l1 l2)) )

Measured memory_bytes: 76384
// G++ MACRO.CPP -STD=C++17
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair



int main(){
  LCIN(n,k);
  VC2(n,a,b);
  M m;
  REP(i,n)
    m[a[i]]+=b[i];

  ll cou = 0;
  FOREACH(xx,m){
    cou+=xx.second;
    if(cou>=k){
      COUT(xx.first);
      break;
    }
  }



  return 0;
}

Measured memory_bytes: 5760
//  s.at(0) = toupper(s.at(0));//小文字なら大文字へ//大文字の場合はそのまま
//  s.at(i) = tolower(s.at(i));//大文字なら小文字へ//小文字の場合はそのまま
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n;
  cin >> n;
  vector<int>p(n),q(n);
  rep(i,n) cin>>p.at(i);
  rep(i,n) cin>>q.at(i);
  vector<int>a(n);
  rep(i,n)a.at(i)=i+1;
  map<vector<int>,int>mp;
  int count = 1;
  do{
//    mp[a] = mp.size();
    mp[a] = count;
    count ++;
  }
  while(next_permutation(a.begin(),a.end()));
  
  int ans = abs(mp[p] - mp[q]);
  cout << ans << endl;
  return 0;
}
        
  

  /*int main(){
   int n; 
   cin >> n;
   vector<int>p(n),q(n);
   rep(i,n)cin >> p[i];
   rep(i,n)cin >> q[i];
   vector<int>a(n);
   rep(i,n) a[i] = i+1;

   map<vector<int>,int>mp;
   do{
       mp[a] = mp.size();
   }while(next_permutation(a.begin(),a.end()));
   
   int ans = abs(mp[p] - mp[q]);
   cout << ans << endl;
   return 0;
}
*/

Measured memory_bytes: 8620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int dp[100001],color[100001];
vector<int> e[100001];

void paint(int v,int d,int c){
	if(!color[v]) color[v]=c;
	if(dp[v]>=d || d==0)return;
	dp[v]=d;
	for(auto u:e[v]) paint(u,d-1,c);
}
 
int main(){
	int N,M,Q,a,b;
	cin>>N>>M;
	rep(i,M){
		cin>>a>>b;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	cin>>Q;
	int v[Q],d[Q],c[Q];
	rep(i,Q)cin>>v[i]>>d[i]>>c[i];
	for(int i=Q-1;i>=0;i--)paint(v[i],d[i],c[i]);
	rep(i,N)cout<<color[i+1]<<endl;
}

Measured memory_bytes: 8440
#include <stdio.h>

int main(void){
  int n;
  char a[100];
  char b[100];
  char c[100];
  scanf("%d%s%s%s",&n,&a,&b,&c);
  int count1 = 0;

  int i =0;
  int count = 0;
  int flag = 0;
  int min;
  for(i = 0; i <n; i++){
    flag = 0;
    if(a[i]==b[i])flag++;
    if(a[i]==c[i])flag++;
    if(b[i]==c[i])flag++;
    if(flag!=3)count +=2-flag;
  }
  printf("%d",count);
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int r,d,i;
  int x[2011]={0};
  scanf("%d%d%d",&r,&d,&x[2000]);
  for(i=2000;i<2010;i++){
    x[i+1]=r*x[i]-d;
    printf("%d\n",x[i+1]);
  }
  return 0;}


Measured memory_bytes: 128
#include<iostream>
#include<iomanip>

using namespace std;

int main()
{
    int a,b;

    cin>>a>>b;

    int d,r;
    double f;

    d = a / b;
    r = a % b;
    f = (double) a / b;

    cout<<d<<' '<<r<<' '<<fixed<<setprecision(6)<<f<<'\n';
}


Measured memory_bytes: 3240
#include<stdio.h>

int main(){
  long long a,b,c,w;
  scanf("%lld%lld%lld",&a,&b,&c);
  w=c-a-b;
  if(w<=0){printf("No\n");return 0;}
  if(4*a*b<w*w){printf("Yes\n");return 0;}
  else{printf("No\n");}
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main{
public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String str = scan.next();
    
    scan.close();
    if ('A' <= str.charAt(0) && str.charAt(0) <= 'Z') {
        System.out.println("A");
    } else {
        System.out.println("a");
    }
}
}


Measured memory_bytes: 35768
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        r: u32,
        g: u32,
        b: u32,
    };
    println!("{}", if (g * 10 + b) % 4 == 0 {"YES"} else {"NO"});
}


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

int main(){
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;

    if(s.size() != a + b + 1){
        cout << "No" << endl;
        return 0;
    }
    if(s[a] != '-'){
        cout << "No" << endl;
        return 0;
    }
    for(int i = 0; i < s.size(); i++){
        if(i == a){
            continue;
        }
        int p = s[i] - '0';
        //cout << p << endl;
        if(p < 0 || p > 9){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

}

Measured memory_bytes: 256
P = [1 for _ in range(10**6)]
P[0]=0
P[1]=0
for i in range(2,10**3):
    for j in range(i*i,10**6,i):
        P[j] = 0
Q = []
for i in range(10**6):
    if P[i]==1:
        Q.append(i)
N = int(input())
C = {}
for q in Q:
    if N%q==0:
        cnt = 0
        while N%q==0:
            N = N//q
            cnt += 1
        C[q] = cnt
if N>1:
    C[N] = 1
cnt = 0
for q in C:
    n = C[q]
    k = 1
    while n>=(k*(k+1))//2:
        k += 1
    cnt += k-1
print(cnt)

Measured memory_bytes: 148808
def read_int():
    return int(input())

def read_int_map():
    return map(int,input().split(' '))

def read_int_list():
    return list(map(int,input().split(' ')))

def read_s_list_loop(n):
    return [input() for _ in range(n)]

N = read_int()
Sn =  {input() for _ in range(N)}
print(len(Sn))

Measured memory_bytes: 94416
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 0) os << std::endl; }
  return os;
}
template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N;
  std::string S;
  std::cin >> N >> S;

  std::map<char, ll> ma;
  std::map<char, ll> mb;
  for (auto c : S) {
    ma[c]++;
  }

  ll ans = 0;
  for (ll i = 0; i < N; i++) {
    ll cnt = 0LL;
    for (char c = 'a'; c <= 'z'; c++) {
      cnt += std::min(ma[c] * mb[c], 1LL);
    }
    ans = std::max(ans, cnt);
    ma[S[i]]--;
    mb[S[i]]++;
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 256
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    N,K=map(int,input().split())
    val=K
    for i in range(2,N+1):
        val*=(K-1)
    print(val)

resolve()

Measured memory_bytes: 2940
#include <iostream>

using namespace std;

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

	for (int i = 1; i <= 9; ++i) {
		for (int j = 1; j <= 9; ++j) {
			if (N == i * j) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <stdlib.h>
int main()
{
  int n;
  int a,w,t,r;
  a=w=t=r=0;
  scanf("%d",&n);
  char word[n][3];
  for(int i=0;i<n;i++)
  {
      scanf("%s",word[i]);
  }
  for(int i=0;i<n;i++)
  {
      if(word[i][0]=='A') a++;
      else if(word[i][0]=='W') w++;
      else if(word[i][0]=='T') t++;
      else if(word[i][0]=='R') r++;
  }
  printf("AC x %d\n",a);
  printf("WA x %d\n",w);
  printf("TLE x %d\n",t);
  printf("RE x %d\n",r);
}

Measured memory_bytes: 2444
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld double 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX1 100006
#define f first
#define s second
#define pi 2*acos(0.0)
void solve()
{
    double W,H,x,y;  cin>>W>>H>>x>>y;
    cout<<fixed<<setprecision(10)<<(W*H)/2<<" "<<(2*x==W and 2*y==H);
}
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt","r",stdin);
    //for getting error from error.txt
    freopen("error.txt", "w", stderr);
    // for writing output to output.txt
    freopen("output.txt","w",stdout);
    #endif
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<"\n";
    cerr<<"My CLOCKS_PER_SEC= "<<CLOCKS_PER_SEC<<"\n";
    return 0;
}


Measured memory_bytes: 3752
n = int(input())
h = list(map(int,input().split()))
f = 0

for i in range(1,n):
    a = h[i-1] - h[i]
    if a > 1:
        break
    elif a == 1:
        if f == 1:
            break
        f = 1
    elif a == 0:
        pass
    else:
        f = 0

    if i == n - 1:
        f = 2

if f == 2 or n == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define ll long long
#define MOD 998244353LL

using namespace std;

int main() {
  int n, s;
  ll o = 0;
  scanf("%d %d", &n, &s);
  vector<vector<ll>> dp(n + 1, vector<ll>(s + 1));
  vector<int> a(n);
  for(int i = 0; i < n; i++) scanf("%d", &a[i]);
  dp[0][0] = 1;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j <= s; j++) {
      dp[i + 1][j] += dp[i][j];
      if(j - a[i] >= 0) dp[i + 1][j] = (dp[i + 1][j] + dp[i][j - a[i]]) % MOD;
    }
    dp[i + 1][0]++;
    o = (o + dp[i + 1][s]) % MOD;
  }
  printf("%lld\n", o);
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, M;
	cin >> N >> M;
	int A[10] = {};
	rep(i, M) {
		int a;
		cin >> a;
		A[a] = 1;
	}
	int K[10] = { 0,2,5,5,4,5,6,3,7,6 };

	tuple<int, int, int, int, int, int, int, int, int, int> dp[10][10001] = {};
	tuple<int, int, int, int, int, int, int, int, int, int> kara = make_tuple(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

	rep1(i, 9) {
		rep(j, 10001) dp[i][j] = dp[i - 1][j];
		if (A[i]) {

			for(int j = 10000; j >= 0; j--) {
				if (dp[i - 1][j] != kara) {

					int saidai = (N - j) / K[i];
					for (int k = saidai; k > 0; k--) {
						if (get<0>(dp[i][j + k * K[i]]) <= get<0>(dp[i - 1][j]) + k) {
							tuple<int, int, int, int, int, int, int, int, int, int> kari = dp[i - 1][j];
							get<0>(kari) += k;
							if (i == 1) get<1>(kari) = k;
							if (i == 2) get<2>(kari) = k;
							if (i == 3) get<3>(kari) = k;
							if (i == 4) get<4>(kari) = k;
							if (i == 5) get<5>(kari) = k;
							if (i == 6) get<6>(kari) = k;
							if (i == 7) get<7>(kari) = k;
							if (i == 8) get<8>(kari) = k;
							if (i == 9) get<9>(kari) = k;
							dp[i][j + k * K[i]] = kari;
						}
					}
				}
			}

			int saidai = N / K[i];
			for (int k = saidai; k > 0; k--) {
				if (get<0>(dp[i][k * K[i]]) <= k) {
					tuple<int, int, int, int, int, int, int, int, int, int> kari = kara;
					get<0>(kari) += k;
					if (i == 1) get<1>(kari) = k;
					if (i == 2) get<2>(kari) = k;
					if (i == 3) get<3>(kari) = k;
					if (i == 4) get<4>(kari) = k;
					if (i == 5) get<5>(kari) = k;
					if (i == 6) get<6>(kari) = k;
					if (i == 7) get<7>(kari) = k;
					if (i == 8) get<8>(kari) = k;
					if (i == 9) get<9>(kari) = k;
					dp[i][k * K[i]] = kari;
				}
			}
		}
	}

	int B[10];
	B[1] = get<1>(dp[9][N]);
	B[2] = get<2>(dp[9][N]);
	B[3] = get<3>(dp[9][N]);
	B[4] = get<4>(dp[9][N]);
	B[5] = get<5>(dp[9][N]);
	B[6] = get<6>(dp[9][N]);
	B[7] = get<7>(dp[9][N]);
	B[8] = get<8>(dp[9][N]);
	B[9] = get<9>(dp[9][N]);

	vector<char> kotae;

	rep1(i, 9) {
		rep(j, B[10 - i]) cout << 10 - i;
	}
	cout << endl;

	Would you please return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
#define MAX 10000000
using namespace std;

bool isPrime[MAX+1];

void sieve() {
  fill(&isPrime[0], &isPrime[MAX+1], true);
  isPrime[0] = isPrime[1] = false;
  for(int i = 2; i <= MAX; i++) {
    if(isPrime[i]) {
      for(int j = 2*i; j <= MAX; j += i) isPrime[j] = false;
    }
  }
}

int main() {
  sieve();
  while(1) {
    int n;
    cin >> n;
    if(n == 0) break;

    int ans = 0;
    for(int i = n; i-8 >= 0; i--) {
      if(isPrime[i] && isPrime[i-2] && isPrime[i-6] && isPrime[i-8]) {
	ans = i;
	break;
      }
    }

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

Measured memory_bytes: 10000
N  = int(input())
A=[0] * N

for i in range(N):
    A[i] = int(input())

right = [0]
left =[0]

for a in A:
    left.append(max(a,left[-1]))
    
for a in reversed(A):
    right.append(max(a,right[-1]))

    
for i in range(N):
    ans = max(left[i], right[N-i-1] )
    print(ans)


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

using namespace std;

int main(void) {
  int n, k;
  cin >> n >> k;

  int ans = 1;
  for (int i = 0; i < n; i++) {
    ans = min(ans * 2, ans + k);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
a= list(str(input()))


for i in range(2**3):
    x = ["+","+","+"]
    for j in range(len(a)):
        if (i >> j) & 1 == 1:
            x[j] = "-"
    if eval(a[0]+x[0]+a[1]+x[1]+a[2]+x[2]+a[3]) == 7:
        print(a[0]+x[0]+a[1]+x[1]+a[2]+x[2]+a[3]+"=7")
        break 


Measured memory_bytes: 3064
#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ar array

const int INF = 1e18;

void solve(){
	int n, S;
	cin >> n >> S;
	vector<int> w(n), v(n);
	vector<int> dp(S+1,0);
	for(int i = 0;i < n; ++i){
		cin >> w[i] >> v[i];
		for(int j = S; j >= w[i]; --j){
			dp[j] = max(dp[j],dp[j-w[i]]+v[i]);
		}
	}
	cout << dp[S] << "\n";
} 

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int TC = 1;
    while(TC--)
        solve();

    return 0;
}



Measured memory_bytes: 3976
n, x = map(int, input().split())
ans = 0

hambargers = [1]
patties = [1]

for i in range(1, n+1):
    num = hambargers[i-1] * 2 + 3
    patty_num = patties[i-1] * 2 + 1
    hambargers.append(num)
    patties.append(patty_num)

def cal(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + hambargers[N-1]:
        return cal(N-1, X-1)
    else:
        return patties[N-1] + 1 + cal(N-1, X-2-hambargers[N-1])

print(cal(n, x))

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

int main(){
    int N;cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }
    for (int x = 0; x < N; x++){
            if (x == N-1) cout << A.at(x) << endl;
            else cout << A.at(x) << " ";
        }
    
    for (int i = 1; i < N; i++)
    {   int v = A.at(i);int j = i-1;
        while (j >= 0 and A.at(j) > v)
        {
            A.at(j+1) = A.at(j);
            j--;
        }
        A.at(j+1) = v;
        for (int x = 0; x < N; x++)
        {
            if (x == N-1) cout << A.at(x) << endl;
            else cout << A.at(x) << " ";
        }
        
    }
    
}


Measured memory_bytes: 3092
#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)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    vector<string> word = {{"maerd"}, {"remaerd"}, {"resare"}, {"esare"}};
    string s;
    cin >> s;
    int len = s.size();
    reverse(s.begin(), s.end());
    int ans = 0;
    bool can = true;
    for (int i = 0; i < s.size();i++){
        string tmp="";
        rep(j,5)tmp += s[i+j];
        i += 4;
        if(tmp==word[0]||tmp==word[3]){
            continue;
        }
        i++;
        tmp += s[i];
        if(tmp==word[2])
            continue;
        i++;
        tmp += s[i];
        if(tmp==word[1])
            continue;
        can = false;
        break;
    }
    if(can){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String input = in.nextLine();

		int result = 0;

		for (int i = 0; i < input.length(); ++i) {
			if (input.charAt(i) == '+') {
				result++;
			} else {
				result--;
			}
		}
		System.out.println(result);
		in.close();
	}

}

Measured memory_bytes: 21716
import java.util.Scanner;


public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] dish = new int[n];
        int[] gain = new int[n];
        int[] bonus = new int[n-1];
        for(int i=0;i<n;i++){
            dish[i] = Integer.parseInt(sc.next());
        }
        for(int i=0;i<n;i++){
            gain[i] = Integer.parseInt(sc.next());
        }
        for(int i=0;i<n-1;i++){
            bonus[i] = Integer.parseInt(sc.next());
        }

        int sum = 0;
        int prev = n+1;
        for(int i=0;i<n;i++){
            sum += gain[dish[i]-1];
            if(dish[i]==(prev+1)){
                sum += bonus[prev-1];
            }
            prev = dish[i];
        }
        System.out.println(sum);
    }
}

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

#define N 1000

void replace(char s[],int a,int b,char t[]){
	int n=(b-a);

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

void reverse(char s[],int a,int b){
	char t[N];
	int n=(b-a+1);
	for(int i=0;i<n;i++){
		t[i]=s[a+i];
	}
	for(int i=0;i<n;i++){
		s[a+i]=t[n-1-i];
	}
}

void print(char s[],int a,int b){
	int n=(b-a+1);
	for(int i=0;i<n;i++){
		printf("%c",s[a+i]);
	}
	printf("\n");
}

int main(void){
	char s[N],t[N];
	int n,a,b;

	scanf("%s",s);
	scanf("%d",&n);
	
	for(int i=0;i<n;i++){
		scanf("%s",t);
		if(strcmp(t,"replace")==0){
			scanf("%d %d %s",&a,&b,t);
			replace(s,a,b,t);
		}else if(strcmp(t,"reverse")==0){
			scanf("%d %d",&a,&b);
			reverse(s,a,b);
		}else if(strcmp(t,"print")==0){
			scanf("%d %d",&a,&b);
			print(s,a,b);
		}
	}
}


Measured memory_bytes: 2096
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val s = List.fill(n)(sc.next())
  val res = List("AC", "WA", "TLE", "RE")
  for(r <- res) {
    println(s"$r x ${s.count(_ == r)}")
  }
}

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


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


   int n;
   cin>>n;


   int total{};

   for(int i=1;i<n;i++){
     if(n%i==0){
          total+=(n/i)-1;

     }
     else{
          total+=(n/i);
     }
   }

   cout<<total;


return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
    int x, i, j, t;
    x = A[r];
    i = p - 1;
    for ( j = p; j < r; j++ ) {
	if ( A[j] <= x ) {
	    i++;
	    t = A[i]; A[i] = A[j]; A[j] = t;
	}
    }
    t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
    return i + 1;
}

int main() {
    int i, q;

    scanf("%d", &n);
    for ( i = 0; i < n; i++) scanf("%d", &A[i]);

    q = partition(0, n- 1);

    for (i = 0; i < n; i++ ) {
	if ( i ) printf(" ");
	if ( i == q ) printf("[");
	printf("%d", A[i]);
	if ( i == q ) printf("]");
    }
    printf("\n");

    return 0;
}



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

int main() {

    int n;

    cin >> n;

    int candies[2][n];

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

    int ans = -1;

    for(int k=0; k<n; k++) {
        int candidate = 0;
        for (int i = 0; i <= k; i++) {
            candidate += candies[0][i];
        }

        for(int i=k; i<n; i++){
            candidate += candies[1][i];
        }
        ans = max(ans,candidate);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int a[55],k,n,sum;
bool cmp(int x,int y){return x>y;}
int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n,cmp);
	for (int i=1;i<=k;i++) sum+=a[i];
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
def resolve():
	a, b, k = map(int, input().split())
	if (b - a + 1) < k:
		for i in range(a, b+1):
			print(i)
		return
	for i in range(a, min(a+k, b-k+1)):
		print(i)
	for i in range(b-k+1, b+1):
		print(i)
resolve()

Measured memory_bytes: 38256
#include<stdio.h>

#define MAX 100
#define INFTY 200000

int main(){
  int min,c,n,u,k,v,i,j,d[MAX];
  int G[MAX][MAX];
  int vis[MAX] = {}; //訪れたかどうか

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++)
      G[i][j] = INFTY;
  }
  
  for(i = 0; i < n; i++){
    scanf("%d %d",&u,&k);
    for(j = 0; j < k; j++){
      scanf("%d %d",&v ,&c);
      G[u][v] = c;
    }
  }

  for(i = 0; i < n; i++){
    d[i] = INFTY;
  }
  d[0] = 0;

  while(1){
    min = INFTY;
    j = -1;
    for(i = 0; i < n; i++){
      if(min > d[i] && !vis[i]){
	j = i;
	min = d[i];
      }
    }
    if(j == -1) break;
    vis[j] = 1;
    
    for(i = 0; i < n; i++){
      if(!vis[i] && G[j][i] != INFTY){
	if(d[i] > d[j] + G[j][i]){
	d[i] = d[j] + G[j][i];
	}
      }
    }
  }

  for(i = 0; i < n; i++)
    printf("%d %d\n",i,d[i]);
  
  return 0;
}



Measured memory_bytes: 2108
N = int(input())
S = input()
numE = [0] * N
numW = [0] * N
for i in range(N):
    if S[i] == 'E':
        numE[i] += 1
    else:
        numW[i] += 1
    if 0 < i:
        numE[i] += numE[i - 1]
        numW[i] += numW[i - 1]
ans = N
for i in range(N):
    if i == 0:
        val = numE[-1] - numE[i]
    elif i == N - 1:
        val = numW[i - 1]
    else:
        val = numE[-1] - numE[i] + numW[i - 1]
    ans = min(ans, val)
print(ans)

Measured memory_bytes: 32888
// Problem : D - Knapsack 1
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define maxn 100000
ll w[101]; ll v[101]; ll dp[101][maxn+1];
ll n=0,wt=0;

ll fun(){
	ll ans=0;
	for(ll i=0;i<=wt;i++) dp[0][i]=0;
	for(ll i=0;i<=n;i++) dp[i][0]=0;
	// i is size (i-1)th is the curr element
	for(ll i=1;i<=n;i++){
		for(ll j=0;j<=wt;j++){
			dp[i][j]=dp[i-1][j];   //excluding
			if(w[i-1]<=j){
				dp[i][j]=max(dp[i][j],v[i-1]+dp[i-1][j-w[i-1]]);
			}
		}
	}
	//for(ll i=0;i<=n;i++){
	//	for(ll j=0;j<=wt;j++) cout<<dp[i][j]<<" ";
	//	cout<<endl;
	//}
	return dp[n][wt];
}

int main(){
	fast
	cin>>n>>wt;
	for(ll i=0;i<n;i++) cin>>w[i]>>v[i];
	
	memset(dp,-1,sizeof(dp));
	cout<<fun();
	return 0;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int H, W;
    cin >> H >> W;
    vector<string> A(H);
    rep(i, H) cin >> A[i];

    cout << string(W+2, '#') << endl;
    for (auto s : A) cout << "#" + s + "#" << endl;
    cout << string(W+2, '#') << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,a;
	scanf("%d",&n);
	a=n*800;
	while(1){
	    if(n>=15){
		    a=a-200;
			n=n-15;
		}
		if(n<15)break;
	}
	printf("%d\n",a);
	return 0;
}

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

int main(){
    int x,a,b;
    cin >> x >> a >> b;
    if((b-a)<=0) cout << "delicious" << endl;
    else if((b-a)<=x) cout << "safe" << endl;
    else cout << "dangerous" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,c1,c2;
    vector<int>v;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>c1;
        if(c1==0){
           cin>>c2;
           v.push_back(c2);
        }
        else if(c1==2){
            v.pop_back();
        }
        else if(c1==1){
            cin>>c2;
            cout<<v[c2]<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3788
#include<bits/stdc++.h>
#define ld long double
#define ll long long
#define st first
#define nd second
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define pb push_back
using namespace std;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	vector<int> ans(n+1);
	for(int x=1; x<=100; ++x) {
		for(int y=1; y<=100; ++y) {
			for(int z=1; z<=100; ++z) {
				int val = x*x + y*y + z*z + x*y + x*z + y*z;
				if(val <= n) {
					ans[val]++;
				}
			}
		}
	}
	for(int i=1; i<=n; ++i) {
		cout<<ans[i]<<'\n';
	}
}


Measured memory_bytes: 3652
#include <stdio.h>
int main (void){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d" ,&W,&H,&x,&y,&r);
  if (x <0 || W< x )
  printf("No\n");
  else if (y < 0 || H < y)
  printf("No\n");
  else if (x-r <0 || W < x+r )
  printf("No\n");
  else if (y-r < 0 || H < y+r )
  printf ("No\n");
  else
  printf("Yes\n");

  return 0;

}



Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


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

ll N, A, B;

void solve() {
	if (A + B > N + 1||A*B<N) {
		cout << -1; return;
	}
	
	vector<ll> s(B,0);

	s[0] = A;

	rep(i,N-A){
		s[i % (B - 1) + 1]++;
	}

	ll sum = 0;

	rep(i, B) {
		sum += s[i];

		repn(j, s[i]) {
			cout << N - sum + j << " ";
		}
	}





}


int main() {

	cin >> N >> A >> B;

	solve();


	system("PAUSE");

}





Measured memory_bytes: 3456
import sys
from collections import Counter
import random
import numpy as np
import time

n=int(input())
a=list(map(int,input().split()))
S=[0]
for i in range(n):
    S.append(S[i]+a[i])
    
S.sort()
c=0
ch=0
for i in range(len(S)-1):
    if(S[i]!=S[i+1]):
        ch+=1
        c+=(ch*(ch-1))//2
        ch=0
    else:ch+=1
if(ch!=0):
    ch+=1
    c+=(ch*(ch-1))//2
print(c)

Measured memory_bytes: 34948
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int A[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
  int B[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
  int C[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};
  int N;
  ll ans=0;
  int D[5] = {0};
  cin >> N;
  rep(i, N){
    string S;
    cin >> S;
    if(S[0] == 'M') D[0]++;
    if(S[0] == 'A') D[1]++;
    if(S[0] == 'R') D[2]++;
    if(S[0] == 'C') D[3]++;
    if(S[0] == 'H') D[4]++;
  }
  rep(i, 10){
    ans += (ll) D[A[i]] * D[B[i]] * D[C[i]];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using static System.Console;
class Program {
        static void Main(string[] args) {
            var o = ReadLine();
            var e = ReadLine();
            var sum = o.Length + e.Length;
            string result = "";
            for (int i = 0; i < sum; i++) {
                if (i % 2 == 0 || i == 0) {
                    result += o[i / 2];
                }
                else {
                    result += e[(int)Math.Ceiling((double)(i / 2))];
                }
            }
            WriteLine(result);
            ReadKey();
        }
    }

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

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

    int n;
    cin >> n;
    vector<int> A(n);
    REP(i, n) cin >> A[i];

    int c = 0, ans = 1;
    REP(i, n - 1){
        if(c == 0){
            if(A[i] < A[i + 1]) c = 1;
            else if(A[i] > A[i + 1]) c = -1;
        }else if(c == 1){
            if(A[i] <= A[i + 1]);
            else{
                ans++;
                c = 0;
            }
        }else if(c == -1){
            if(A[i] >= A[i + 1]);
            else{
                ans++;
                c = 0;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>	// 入出力
#include<stdio.h>	// printf()が使える 小数は%fで
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;

using ll = long long;


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

	vector<int> vec;

	for (int i = 0; i < N; ++i)
	{

		int A; cin >> A;

		vec.emplace_back(A);

	}

	sort(vec.begin(), vec.end());
	

	int key = -1;

	ll first = -1;
	ll second = -1;


	for (int i = vec.size() - 1; i >= 0; --i)
	{

		if (first != -1 && second != -1) { break; }

		if (key == -1)
		{
			key = vec[i];
			continue;
		}


		if (key == vec[i])
		{
			if (first == -1) { first = vec[i]; }
			else { second = vec[i]; }

			key = -1;

			continue;
		}

		key = vec[i];

	}


	if (first == -1 || second == -1)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << first*second << endl;
	}

	return 0;
}

Measured memory_bytes: 892
#include<stdio.h>

#include<algorithm>
#include<vector>

using namespace std ;


#define END 150
#define KURONO 14106

#define OK puts( "OK" )
#define NG puts( "NG" )


int main( void )
{
	int N ;
	while( 1 )
	{
		scanf( "%d" ,&N ) ;

		if( N == 0 )
		{	return 0 ;	} ;

		char judge = 0 ;

		vector< int > weight ;
		int m[ 100 ] ;
		int a[ 100 ] ,b[ 100 ] ;
		
		int i ,j ;
		for( i = 0 ; i < N ; ++i )
		{
			scanf( "%d %d %d" ,m + i ,a + i ,b + i ) ;

			weight.push_back( a[ i ] ) ; weight.push_back( b[ i ] ) ;
		}

		sort( weight.begin() ,weight.end() ) ;

		for( i = 0 ; i < weight.size() ; ++i )
		{
			int sum = 0 ;
			for( j = 0 ; j < N ; ++j )
			{
				if( weight[ i ] >= a[ j ] && weight[ i ] < b[ j ] )
				{	sum += m[ j ] ;	}
			}

			if( sum > END )
			{	NG ; i = j = KURONO ;	}
		}

		if( j != KURONO )
		{	OK ;	}
	}
}


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

const int mxN=2e5;
int n, a[mxN], b[mxN];
priority_queue<array<int, 2>> pq;
long long ans;

void fk() {
	cout << -1;
	exit(0);
}

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

	cin >> n;
	for(int i=0; i<n; ++i)
		cin >> a[i];
	for(int i=0; i<n; ++i) {
		cin >> b[i];
		pq.push({b[i], i});
	}
	while(pq.size()) {
		int i=pq.top()[1], c=b[(i+1)%n]+b[(i+n-1)%n], t=(b[i]-a[i])/c;
		pq.pop();
		if(a[i]==b[i])
			continue;
		if(t<=0)
			fk();
		b[i]-=t*c;
		pq.push({b[i], i});
		ans+=t;
	}
	cout << ans;
}

Measured memory_bytes: 3700
/*input
8
*/
macro_rules! input_vec {
    () => {
        input!()
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };
    ($delimiter:expr) => {
        input!()
            .split($delimiter)
            .map(|x| x.parse().unwrap())
            .collect()
    };
}

macro_rules! input {
    () => {{
        let mut return_ = String::new();
        std::io::stdin().read_line(&mut return_).ok();
        return_.pop();
        return_
    }};
}

fn main() {
    let n: u32 = input!().parse().unwrap();
    print!(
        "{:032b}\n{:032b}\n{:032b}\n{:032b}\n",
        n,
        !n,
        n << 1,
        n >> 1
    );
}



Measured memory_bytes: 5012
#include<cstdio>


using namespace std;
int main(void)
{
	int a[101]= {0},kari,most = 0;
	for(int i = 0;;i++)
	{
		if(scanf("%d",&kari)==EOF) break;
		a[kari] += 1;
		if(a[kari] >= most) most = a[kari];
	}
	for(int i = 0;i < 100;i++)
	{
		if(most == a[i]) printf("%d\n",i);
	}


	return 0;
}

Measured memory_bytes: 1024
N = int(input())
S = []
s = []
for i in range(N):
    si = int(input())
    S.append(si)
    if (si % 10 != 0):
        s.append(si)

S.sort()
s.sort()
maxi = sum(S)

if (maxi % 10 != 0):
    print(maxi)
else:
    if (len(s) == 0):
        print(0)
    else:
        print(maxi-min(s))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//--<for debugging>
#define whatis(x) cout << #x << " is " << x<<" ";
#define whatisl(x) cout << #x << " is " << x<<"\n";
#define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
#define lline cout<<"\n";
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"___";}
    
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a <<" , ";
    err(++it, args...);
}
//--</for debugging> 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define testcase ll tt; cin >> tt; while(tt--)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define vars ll h,i,j,k,d,l,p,q,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;
#define vll vector<ll>
#define pll pair<ll,ll>
#define sll set<ll>
#define pint pair<int,int>
const ll INF=1e9+7;
const ll MOD=1e9+7;
int main()
{
    boost vars
    cin>>n;
    x=n;s=0;
    while(x){x/=10;s++;}
    ll arr[s]={0};
    v=10;
    p=1;
    for(i=s-1;i>=0;i--)
    {
        var=n%v;
        for(j=i+1,z=v/10,q=p/2;j<s;j++,z/=10,q/=2)
        {
            arr[i]=arr[i]+(var/z)*q+arr[j];
        }
        arr[i]+=var;
        v*=10;
        p*=2;
    }
    cout<<arr[0];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long 
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
	reus;
	ll int a,b,n,j,ans=0;
	cin>>a>>b>>n;
	j=min(b-1,n);
	ans=(floor((a*j)/b)-a*floor(j/b));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3644
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        ArrayList<ArrayList<Integer>> divisors = new ArrayList<>(k);

        for(int i = 1 ; i <= k ; i++){
            ArrayList<Integer> divs = new ArrayList<>();
            for(int j = k ; j >= 1 ; j--){
                if((i % j) == 0){
                    divs.add(j);
                }
            }
            divisors.add(divs);
        }

        long sum = 0;
        for(int i = 1 ; i <= k ; i++){
            for(int j = 1 ; j <= k ; j++){
                for(int l = 1 ; l <= k ; l++){
                    int m = Math.min(Math.min(i,j),l);
                    for(int d : divisors.get(m-1)){
                        if((i % d) == 0 && (j % d) == 0 && (l % d) == 0){
                            sum += d;
                            break;
                        }
                    }
                }
            }
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 54020
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

// (mod MOD1)
ll mod(ll n){return n%=MOD1;}

int main(void){
    // char ;
    ll n,k,ans=0;
    scanf("%lld%lld",&n,&k);
    ll a[n];
    // ll cnt[2000]={};
    // ll inv[2000]={};
    rep(i,0,n){
        scanf("%lld",&a[i]);
        // cnt[a[i]-1]++;
    }
    // ll cum[2000]={};
    // cum[1998]=cnt[1999];
    // rrep(i,1997,0){
    //     cum[i]=cum[i+1]+cnt[i+1];
    // }
    ll inv1=0,inv2=0;
    rep(i,0,n){
        rep(j,0,n){
            if(a[i]>a[j]){
                // inv[a[j]-1]++;
                if(j>i) inv1++;
                else inv2++;
            }
        }
        
    }
    // rep(i,0,maxn(n,a)){
    //     ans+= inv[i] * k +  cum[i] * mod( k*(k-1)/2 ) ;
    //     ans%=MOD1;
    // }
    ans= (inv1+inv2) * mod( k*(k-1)/2 ) + inv1*k;
    ans%=MOD1;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
n = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
res = 0
for i in range(n):
    if A[i] >= B[i]:
        res += B[i]
    else:
        res += A[i]
        B[i] -= A[i]
        if A[i+1] >= B[i]:
            A[i+1] -= B[i]
            res += B[i]
        else:
            res += A[i+1]
            A[i+1] = 0
print(res)

Measured memory_bytes: 18624