akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;i++)

int main(){
  int n,k,ans=1;
  cin>>n>>k;
  
  rep(i,0,n){
    if((ans*2-ans)<k){ans=ans*2;}
    else{ans+=k;}
  }
  
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.readline

n = int(input())
a = deque([int(i) for i in input().split()])
b = deque()

if n % 2 == 0:
    for i,x in enumerate(a):
        if i % 2 == 0:
            b.append(x)
        else:
            b.appendleft(x)
else:
    for i,x in enumerate(a):
        if i % 2 == 0:
            b.appendleft(x)
        else:
            b.append(x)

print(*b)

Measured memory_bytes: 25424
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <string>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;


int main(){
    int x;
    cin>>x;
    cout<<(x ^ 1)<<endl;
    return 0;
}


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

int main() {
  int n;
  cin >>n;
  vector<int>d(n);
  for(int i=0;i<n;i++){
    cin>>d.at(i);
  }
  sort(d.begin(),d.end());
  if(d.at((n-1)/2)==d.at(n/2)){
    cout<<0<<endl;
    return 0;
  }else{
    cout<<d.at(n/2)-d.at((n-1)/2)<<endl;
  }  
  return 0;
}

Measured memory_bytes: 640
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        n:i64,
    }
    let mut ans = 0i64;
    for i in 1..=n {
        ans += (i + i * (n / i)) * (n / i) / 2;
    }
    println!("{}", ans);
}


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

const int N = 200010;

int p[N], inv[N];
int max[N];

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i){
        scanf("%d", &p[i]);
        inv[p[i]] = i;
    }
    int ans = 0;
    for (int i = n; i >= 1; -- i){
        if (inv[i + 1] > inv[i]){
            max[i] = max[i + 1] + 1;
        }
        else{
            max[i] = 1;
        }
        ans = std::max(ans, max[i]);
    }
    printf("%d\n", n - ans);
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF=(1LL<<60);
const int mod=1000000007;

int main(){
    int N; cin >> N;
    int Max=0;
    int Sum=0;
    for(int i=0; i<N; i++){
        int p; cin >> p;
        Max=max(Max,p);
        Sum+=p;
    }

    cout << Sum-Max/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int n;
vi xs, ys;

const int M = 10000;
inline void f(int& sx, int& sy){
    assert(sx != 0 or sy != 0);

    if(sx == 0){
        sy = M;
    }
    else if(sy == 0){
        sx = M;
    }
    else {
        int g = __gcd(abs(sx), abs(sy));
        sx /= g;
        sy /= g;
    }
}

vi used;
using P = tuple<int, int>;
using A = tuple<int, int>;

set<A> s;
map<A, int> dic;

inline int comb(int x){
    if(x <= 1) return 0;
    return x * (x - 1) / 2;
}

int dfs(int d){
    if(d == n){
        int cur = 0;
        for(auto& e : s){
            cur += comb(dic[e]);
        }
        return cur;
    }

    if(used[d]) return dfs(d + 1);
    used[d] = true;

    int ret = 0;
    rep(nd, d + 1, n){
        if(used[nd]) continue;
        used[nd] = true;
        int sx = xs[nd] - xs[d];
        int sy = ys[nd] - ys[d];
        f(sx, sy);
        A a = A(sx, sy);
        s.insert(a);
        dic[a]++;

        chmax(ret, dfs(d + 1));

        used[nd] = false;
        if(--dic[a] == 0){
            s.erase(a);
        }
    }
    used[d] = false;

    return ret;
}

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

    cin >> n;
    vector<P> in(n);
    rep(i, n){
        int x, y; cin >> x >> y;
        in[i] = P(x, y);
    }
    sort(_all(in));

    xs = ys = vi(n);
    rep(i, n){
        int x, y; tie(x, y) = in[i];
        xs[i] = x, ys[i] = y;
    }

    used = vi(n);
    cout << dfs(0) << endl;

    return 0;
}

Measured memory_bytes: 3244
n,m = map(int, input().split())
dic = {}
for _ in range(m):
  s,c = input().split()
  if s in dic and dic[s] != c:
    print(-1)
    break
  dic[s] = c
else:
  if '1' in dic and n > 1 and dic['1'] == '0':
    print(-1)
  else:
    if '1' not in dic:
      if n == 1:
        dic['1'] = '0'
      else:
        dic['1'] = '1'

    ans = ""
    for i in range(1,n+1):
      if str(i) in dic:
        ans += dic[str(i)]
      else:
        ans += '0'
    print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main()
{
    int a,b,c,d,e,k,r,i;
    k=0;
    i=0;
    scanf("%d\n%d\n%d\n%d\n%d",&a,&b,&c,&d,&e);
    if (a%10!=0){
         k=a%10;
         a=((int)(a/10))*10+10;
         i++;
    }

    if (b%10!=0){
        if (k>(b%10))
        k=b%10;
        b=b/10;
        b=b*10+10;
        i++;
    }
    if (c%10!=0){
    if (k>(c%10))
        k=c%10;
    c=((int)(c/10))*10+10;
    i++;
    }
    if (d%10!=0){
    if (k>(d%10))
        k=d%10;
    d=((int)(d/10))*10+10;
    i++;
    }
    if (e%10!=0){
        if (k>(e%10))
        k=e%10;
        e=((int)(e/10))*10+10;
        i++;
    }
    if(i==0 || i==1)
    	r=a+b+c+d+e+k;
    else
    	r=a+b+c+d+e+k-10;
    printf("%d",r);
    return 0;
}


Measured memory_bytes: 128
// E - Red and Green Apples
#include <bits/stdc++.h>
using namespace std;
#define allr(x) (x).rbegin(),(x).rend()

int main(){
	int X, Y, A, B, C; cin>>X>>Y>>A>>B>>C;
	vector<int> E(A);
	while(A--) cin>>E[A];
	sort(allr(E));
	E.resize(X+B);
	while(B--) cin>>E[X+B];
	sort(E.begin()+X, E.end());
	reverse(E.begin()+X, E.end());
	E.resize(X+Y+C);
	while(C--) cin>>E[X+Y+C];
	sort(allr(E));
	cout<< accumulate(E.begin(), E.begin()+X+Y, 0LL) <<endl;
}

Measured memory_bytes: 2040
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k, ans = 0;
	cin >> n;
	vector<int> a(n);
	for (i = 0; i < n; i++) cin >> a[i];
	for (i = 1; i < n - 1; i++) {
		if ((a[i] > a[i - 1]) && (a[i] < a[i + 1])) ans++;
		if ((a[i] < a[i - 1]) && (a[i] > a[i + 1])) ans++;
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int,int>;
const int INF = 1e18;
#define put(n) cout<<(n)<<endl
#define rep(i,N) for(int(i)=0;(i)<(N);++(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define pb(n) push_back(n)

signed main(){
    int N,Q;
    cin >> N >> Q;
    string S;
    cin >> S;

    vector<int> ans(N,0);
    for(int i=1;i<N;i++){
        if(S[i] == 'C' && S[i-1] == 'A') ans[i]++;
    }
    for(int i=1;i<N;i++) ans[i] += ans[i-1];
    rep(i,Q){
        int l,r;
        cin >> l >> r;
        l--,r--;
        put(ans[r]-ans[l]);
    }
}


Measured memory_bytes: 1792
n = int(input())
MX = 10**18
a = list(map(int, input().split()))
for x in a:
  if x == 0:
    print(0)
    exit(0)
ans = 1
for x in a:
  ans *= x
  if ans > MX:
    print(-1)
    exit(0)
print(ans)

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
int main()
{
    cout << fixed << setprecision(15);

    ll N;
    cin >> N;

    vector<ll> A = divisor(N-1);
    vector<ll> B = divisor(N);

    ll a = A.size() - 1;

    ll count = 0;
    for(auto K: B){
        if(K == 1) continue;
        ll n = N;
        while(1){
            if(n%K == 1){
                count++;
                break;
            }
            if(n%K == 0){
                n = n/K;
            }
            else{
                break;
            }
        }
    }
    // cout << a << endl;
    // cout << count << endl;
    cout << a + count << endl;
    return 0;
}

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

using ll = long long;
using namespace std;

const int INF = 1e9;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, w;
  cin >> n >> w;
  vector<int> weights(n), values(n);
  for (int i = 0; i < n; ++i)
    cin >> weights[i] >> values[i];
  int v = 0;
  for (auto x : values)
    v += x;
  vector<int> dp(v + 1, INF);
  dp[0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = v; j > 0; --j) {
      if (j - values[i] < 0)
        break;
      dp[j] = min(dp[j], dp[j - values[i]] + weights[i]);
    }
  }
  for (int ans = v; ans >= 0; --ans) {
    if (dp[ans] <= w) {
      cout << ans << '\n';
      return 0;
    }
  }
  return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/22  Problem: ABC 053 B / Link: http://abc053.contest.atcoder.jp/tasks/abc053_b  ----- */


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

	string s; cin >> s;
	
	LL ans = s.rfind('Z')-s.find('A')+1;
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 720
#include <iostream>
using namespace std;
int p[15], c[15], s[15];
int solve(int point, int d){
    int ans=10000, now;
    for(int i=1; i<=d; ++i){
        if(s[i]){
            --s[i];
            if(i*100*(p[i]-1)>=point) now=(point+i*100-1)/(i*100);
            else if(i*100*p[i]+c[i]>=point) now=p[i];
            else now=p[i]+solve(point-(i*100*p[i]+c[i]), d);
            ans=min(ans, now);
            ++s[i];
        }
    }
    return ans;
}
int main() {
	int D, G; cin >> D >> G;
	for(int i=1; i<=D; ++i){
	    cin >> p[i] >> c[i];
	    s[i]=1;
	}
	cout << solve(G, D) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int k;
int main(){
	cin>>k;
	int r=0;
	for(int i=1;i<=k;i++){
		r=(r*10+7)%k;
		if(r==0){
			cout<<i;
			return 0;
		} 
	}
	cout<<-1;
	return 0;
}


Measured memory_bytes: 3616
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
vector<int> sieve(int n) {
    vector<int> primes;

    vector<bool> prime_table(n+1, true);
    prime_table[0] = prime_table[1] = false;

    for (int i = 2; i <= n; i++) {
        if (prime_table[i]) {
            primes.push_back(i);
            for (int j = 2 * i; j <= n; j += i) prime_table[j] = false;
        }
    }

    return move(primes);
}

signed main() {
    vector<int> primes = sieve(55555);

    int N;
    cin >> N;

    vector<int> ret;

    for (int prime : primes) {
        if (prime % 5 == 1) {
            ret.push_back(prime);
        }

        if (ret.size() == N) break;
    }

    for (int elem : ret) {
        cout << elem << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 384
nm=list(map(int, input().split()))
a=list(map(int, input().split()))
n=nm[0]
m=nm[1]
suma=sum(a)
standard=suma/(4*m)
answer=sum(1 for i in a if i>=standard)
if answer>=m:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 3060
data = [ [ [ 0 for r in range(10)] for f in range(3)] for b in range(4)]

n = int( input())
for _ in range( n):
    (b, f, r, v) = [int(i) for i in input().split()]
    data[b-1][f-1][r-1] += v

for b in range(4):
    for f in range(3):
        for r in range(10):
            print( '', data[b][f][r], end='')
        print()
    if b < 3:
        print( '#' * 20)

Measured memory_bytes: 6720
#include <iostream>
#include <algorithm>
#include <string>
#define endl '\n'
#define ll unsigned long long
using namespace std;

string N;

string Solution(string N) {

	for (auto x : N) if (x == '7') return "Yes";
	return "No";
}

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

	cin >> N;
	string s = Solution(N);
	cout << s << endl;
	
	system("pause");
	return 0;
}

Measured memory_bytes: 3720
#include "iostream"
using namespace std;
int main() {
	char a;
	cin >> a;
	if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
		cout << "vowel" << endl;
	else cout << "consonant" << endl;
	return 0;
}

Measured memory_bytes: 256
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()

primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)

a = [0]*len(primes)
for i in range(len(primes)):
    for j in range(1, n+1):
        tmp = j
        while tmp % primes[i] == 0:
            tmp = tmp // primes[i]
            a[i] += 1

ans = 1
for x in a:
    ans = ans * (x + 1) % (10**9+7)
print(ans)          

Measured memory_bytes: 10264
#include <stdio.h>
int search(int A[],int kazu,int suji);
int main()
{
int i,kazu,suji,A[10000+1],flag,sum=0;
scanf("%d",&kazu);
 for(i=0;i<kazu;i++){
   scanf("%d",&A[i]);
 }
 scanf("%d",&suji);
 for(i=0;i<suji;i++){
   scanf("%d",&flag);
   if(search(A,kazu,flag)) sum++;
 }
printf("%d\n",sum);

return 0;
}

 int search(int A[],int kazu,int flag)
 {
int a=0;
A[kazu]=flag;
while(A[a]!=flag)a++;
return a!=kazu;
 }



Measured memory_bytes: 2108
N = int(input())
# 数値→アルファベット
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
      
print(num2alpha(N).lower())

Measured memory_bytes: 9092
#include <bits/stdc++.h>
#include<map>
#include<vector>
#include<set>
#define ll long long
#define se second
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll t,a,b,c,d=0,n,m,k=0,sum=0,i,j;
   
    cin>>n;
    string str="ACL";
    for(i=1;i<=n;i++)cout<<str;
    
    
  return 0;
}


Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 * ??\????????????????????????H cm ?????? W cm ???????????????????????°?????????????????????????????????

##########
#........#
#........#
#........#
#........#
##########
?????????????????? 6 cm ?????? 10 cm ???????????¨??????????????????

 * @author wsKmatsuda
 *
 */
public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	public void run(){

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String inputData;
        List<Square> squareList = new ArrayList<Square>();
        try {
        	//??\???
	        while(true){
				inputData = reader.readLine();
	            if("0 0".equals(inputData)){
	            	break;
	            }else{
					String[] strNumber = inputData.split(" ");
					int h = Integer.parseInt(strNumber[0]);
					int w = Integer.parseInt(strNumber[1]);
					squareList.add(new Square(h,w));
	            }
	        }

	        //??????
	        for(Square square : squareList){
				outputSquare(square.h , square.w);
				System.out.println();
	        }

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	/**
	 * ????????¢?????????
	 * @param h
	 * @param w
	 */
	private void outputSquare(int h, int w) {
		StringBuilder sbLine = new StringBuilder();
		StringBuilder sbLineFastLast = new StringBuilder();
		for(int i=0;i < w ;i++){
			sbLineFastLast.append("#");
			if(i == 0 || i == w - 1){
				sbLine.append("#");
			}
			else
			{
				sbLine.append(".");
			}
		}
		for(int i=0;i < h;i++){
			if(i==0 || i == h-1){
				System.out.println(sbLineFastLast.toString());
			}else{
				System.out.println(sbLine.toString());
			}
		}
	}

	/**
	 * ????§???¢?????????
	 * h,w???????????????
	 * ??????Inner??????????????????????????§????????????????????§?????????
	 *   ?????????????????????????????§?????¬????????????????????????????????¨?????????
	 *   AOJ??????Main??????????????????submit???????????????
	 *   ?????????????????£????????§Inner?????????????????????????????????
	 */
	class Square{

		public int h;
		public int w;

		Square(int _h ,int _w){
			h = _h;
			w = _w;
		}
	}

}

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

int main()
{
  int64_t n, x, m;
  cin >> n >> x >> m;
  vector<int64_t> A(m, -1), S(m + 1, 0);
  int64_t ai = x;
  for (int i = 1; i <= m; i++)
  {
    if (A.at(ai) == -1)
    {
      A.at(ai) = i;
      S.at(i) = S.at(i - 1) + ai;
      ai = ai * ai % m;
      if (ai == 0 || i == n)
      {
        cout << S.at(i) << endl;
        return 0;
      }
    }
    else
    {
      int64_t ans = 0;
      ans += S.at(A.at(ai) - 1); // ループに入るまで
      n -= A.at(ai) - 1;
      ans += (S.at(i - 1) - S.at(A.at(ai) - 1)) * (n / (i - A.at(ai)));
      n %= (i - A.at(ai));
      ans += S.at(A.at(ai) - 1 + n) - S.at(A.at(ai) - 1);
      cout << ans << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 4840
using System;
using static System.Console;
using System.Collections.Generic;

namespace AtCoder_ABC_A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            //String strLine = Console.ReadLine();        //入力を受けとりString型に代入
            //String[] strSplited = strLine.Split(' ');       //Stringを数字ごとに分割しString配列に代入
            int s1 = 0;
            int s2 = 0;
            int ans = 1000000000;
            int borderNumT; 
            int n = int.Parse(Console.ReadLine());
            
            int[] inputNums = new int[n];                        
            inputNums = inputAndSetNumsToArray(n);       ////IF YOU WANT TO USE ARRAY, CHOOSE THIS

            //int n = int.Parse(Console.ReadLine());　
            //List<int> intNumsList = new List<int>();          //リストintNumsを初期化
            //int[] intNumsArray = new int[n];                        //配列intNumsを初期化

            //intNumsList = inputAndSetNumsToList(n);             //IF YOU WANT TO USE LIST, CHOOSE THIS
            //intNumsArray = inputAndSetNumsToArray(n);       ////IF YOU WANT TO USE ARRAY, CHOOSE THIS

            for (int i = 0; i < n; i++)
            {
                borderNumT = i;
                for (int j = 0; j < borderNumT; j++)
                {
                    s1 += inputNums[j];
                }
                for (int k = borderNumT; k < n; k++)
                {
                    s2 += inputNums[k];
                }
                

                if(ans > Math.Abs(s1 - s2))
                {
                    ans = Math.Abs(s1 - s2);
                }
                s1 = 0;
                s2 = 0;
            }

            Console.WriteLine(ans);
        }



        
        public static  List<int> inputAndSetNumsToList(int n)
        {
            List<int> getIntNums = new List<int>();     //リストgetIntNumsを初期化
            
            String strLine = Console.ReadLine();        //入力を受けとりString型に代入
            String[] strSplited = strLine.Split(' ');       //Stringを数字ごとに分割しString配列に代入

            for (int i = 0; i < n; i++)
            {
                getIntNums.Add(int.Parse(strSplited[i]));   //リストintNumsにString配列の中身を代入
            }
            return getIntNums;
        }

        

        public static int[] inputAndSetNumsToArray(int n)
        {
            int[] getIntNums = new int[n];      //配列getIntNumsを初期化

            String strLine = Console.ReadLine();        //入力を受けとりString型に代入
            String[] strSplited = strLine.Split(' ');       //Stringを数字ごとに分割しString配列に代入

            for (int i = 0; i < n; i++)
            {
                getIntNums[i] = int.Parse(strSplited[i]);   //リストintNumsにString配列の中身を代入
            }
            return getIntNums;
        }

    }
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;

int main(){
    int N; cin>>N;
    vector<double> p(N); rep(i,N)cin>>p[i];
    vector<vector<double>> dp(N+1,vector<double>(N+1,0.0));
    dp[0][0] = 1.0;
    rep(n,N){
        rep(j,n+1){
            dp[n+1][j+1] += dp[n][j]*p[n];
            dp[n+1][j] += dp[n][j]*(1-p[n]);
        }
    }
    double res = 0.0;
    for(int i = N/2+1; i<=N; i++) res += dp[N][i];
    cout << fixed << setprecision(10) << res << endl;
}

Measured memory_bytes: 73772
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const ll INF = ll(1e16);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
} 
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r; 
}
template<typename T_vector> // neal
void output_vector(const T_vector &v, bool add_one = false, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = int(v.size());
 
    for (int i = start; i < end; i++)
        cout << v[i] + (add_one ? 1 : 0) << (i < end - 1 ? ' ' : '\n');
}
int get(char c){
	if(c >= 'A') c = tolower(c);
	return c;
}
void solve()
{ 
	string s;
	cin >> s;
	cout << s;
	if(s.back() == 's') cout << 'e';
	cout << 's';
}
	


int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    // Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    i64 N;
    string S;
    cin >> N >> S;

    vector<i64> d,m,c;
    rep(i,0,S.size()){
        if(S[i]=='D') d.push_back(i);
        else if(S[i]=='M') m.push_back(i);
        else if(S[i]=='C') c.push_back(i);
    }

    vector<i64> s(S.size());
    rep(i,0,m.size()) ++s[m[i]];
    rep(i,1,S.size()) s[i]+=s[i-1];

    vector<i64> t(c.size());
    t[0]=s[c[0]];
    rep(i,1,c.size()) t[i]=t[i-1]+s[c[i]];


    i64 Q;
    cin >> Q;
    rep(_,0,Q) {
        i64 x;
        cin >> x;

        i64 ans=0, i = 0,l=0,r=0;
        while (i < d.size() and l < c.size()) {
            while(l < c.size() and c[l]<=d[i]) ++l;
            if(l==c.size()) break;
            if(c[l]-d[i]>=x){
                ++i;
                continue;
            }
            while(r+1<c.size() and c[r+1]-d[i]<x) ++r;
            ans+=(t[r]-(l==0?0:t[l-1]))-(r-l+1)*s[d[i]];
            ++i;

        }

        cout << ans << endl;
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

bool tentou(ll i , vector<ll> a , vector<ll> b ){
    ll count = 0 ;
    for(auto p : a ){
        for(auto q : b ){
            if( p == q )count++ ;
        }
    }
    if( count % 2 == i )return true ;
    else return false ;
}

int main(){
    ll n , m ;
    cin >> n >> m ;
    vector<ll> S[m] ;
    vector<ll> P(m) ;
    rep(i,m){
        ll k ;
        cin >> k ;
        rep(j,k){
            ll l ;
            cin >> l ;
            S[i].push_back(l) ;
        }
    }
    ll ans = 0 ;
    rep(i,m) cin >> P.at(i) ;
    rep(i,1<<n){
        vector<ll> T ;
        rep(j,n) if( i & ( 1 << j ) ){
            T.push_back(j+1) ;
        }
        ll tem = 0 ;
        rep(j,m) if( tentou( P.at(j), S[j] , T ) )tem++ ;
        // cout << tem << endl ;
        if(tem == m)ans++ ;
    }
    cout << ans << endl ;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());

	int alice = 0;
	int bob = 0;
	for (int i = 0; i < n; i++)
	{
		if (i % 2 == 0)
		{
			alice += a.at(i);
		}
		else
		{
			bob += a.at(i);
		}
	}
	cout << alice - bob;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
#include <iostream>

using namespace std;

int main() {
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  double pi = 3.141592653589793;
  double d = (30 * H + 0.5 * M - M * 6 ) / 180 * pi;

  double t = A * A + B * B - 2 * A * B * cos(d);

  double c = sqrt(t);
  cout << fixed << setprecision(20);
  cout << c << endl;
}

Measured memory_bytes: 4096
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <iomanip>



int main()
{
	long long n;

	std::cin >> n;

	long long ans = 0;
	for (size_t i = 0; i < n; i++) {
		long long r, l;

		std::cin >> l >> r;

		ans += r - l + 1;
	}

	std::cout << ans << std::endl;





	

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
  public class Main {
    public static void main(String[] args) {
     
        //sec--1 (definition)
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int T = sc.nextInt();
        int ans = 0;
        
        while(N>0) {
          ans += T;
          N=N-X;
        }

        System.out.println(ans);
    }
  }

Measured memory_bytes: 35636
n=int(input())
h=list(map(int,input().split()))
zeros=[]
prev=0
for i in  range(n):
  if h[i]==0:
    if i==0:
      prev=i+1
    else:
      if prev<=i-1:
        zeros.append((prev,i-1))
      prev=i+1
if prev<=n-1:
  zeros.append((prev,n-1))
cnt=0
while zeros:
  l,r=zeros.pop()
  m=min(h[l:r+1])
  cnt+=m
  prev=l
  for i in range(l,r+1):
    h[i]-=m
    if h[i]==0:
      if i==l:
        prev=i+1
      else:
        if prev<=i-1:
          zeros.append((prev,i-1))
        prev=i+1
  if prev<=r:
    zeros.append((prev,r))
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
int main(){
  typedef long long int ll;
int A, B, C;
cin >> A >> B >> C;
int ans = 0;
if(C >= A)ans++;
if(C <= B)ans++;
if(ans == 2)cout << "Yes" << endl;
else cout << "No" << endl;
        return 0;
}

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

using P = pair<int, char>;

int main()
{
    ll A, B, C;
    cin >> A >> B >> C;
    ll d = C - A - B;

    if (d > 0 && d * d > 4 * A * B)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

int main() {
    int N, H[100], maxh=0, ans=0;
    bool h_stage;
    cin >> N;
    for (int i=0; i<N; i++) scanf("%d", &H[i]), maxh = max(maxh, H[i]);

    for (int h=1; h<=maxh; h++) {
        h_stage = false;
        for (int i=0; i<N; i++) {
            if ((!h_stage) && (H[i]>=h)) {
                h_stage = true;
                ans++;
            } else if ((h_stage) && (H[i]<h)) {
                h_stage = false;
            }
        }
    }

    cout << ans << endl;

    return 0;

}


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

int main() {
	ll a,b,n;
	cin>>a>>b>>n;
	
	ll x;
	if(b-1<=n)x=b-1;
	else x=n;
	ll f1=a*x/b;
	ll f2=x/b;
	ll ans=f1-a*f2;
	cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

int main() {

    string S;
    cin >> S;
    if (S[0] != 'A') {
        cout << "WA" << endl;
        return 0;
    }
    int Ccount = 0;
    for (int i = 1; i < S.length(); ++i) {
        if (2 <= i && i <= S.length() - 2 && S[i] == 'C') {
            Ccount++;
        } else {
            if (!((S[i] >= 'a') && (S[i] <= 'z'))) {
                cout << "WA" << endl;
                return 0;
            }
        }
    }
    if(Ccount == 1){
        cout << "AC" << endl;
    } else{
        cout << "WA" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <random>
#include <complex>

#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define reset(x, y) memset(x, y, sizeof(x))
#define BUG(x) cerr << #x << " = " << (x) << endl
#define BUGP(x) cout << #x << " = " << (x)._1 << ", " << (x)._2 << endl
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};
// Head

const int N = 112345;

LL a[N];
int n;

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

    cin >> n;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if (x & 1) {
            cout << "first\n";
            return 0;
        }
    }

    cout << "second\n";
    return 0;
}

Measured memory_bytes: 256
char = ['', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
flag = False
def Base10ToN(x, n):
    if(x == 26): return char[26]
    if(int(x/n) != 0):
        if(int(x%n) != 0):
            return Base10ToN(int(x/n), n) + char[x%n]
        return Base10ToN(int(x/n) - 1, n) + char[26]
    else:
        if(int(x%n) != 0):
            return char[x%n]
        #return char[0]

n = int(input())
print(Base10ToN(n, 26))


Measured memory_bytes: 9228
package main

import "fmt"

func main() {
    var A, B, C int
    fmt.Scan(&A, &B, &C)
    if A >= B && A >= C {
        fmt.Println(A * 10 + B + C)
    } else if B >= A && B >= C{
        fmt.Println(B * 10 + A + C)
    } else {
        fmt.Println(C * 10 + A + B)
    }
}


Measured memory_bytes: 512
h,w,m=map(int,input().split())
H=[0 for i in range(h)]
W=[0 for i in range(w)]
s=set()
for i in range(m):
    a,b=map(int,input().split())
    H[a-1]+=1
    W[b-1]+=1
    s.add((a,b))
hma=max(H)
wma=max(W)
h_index=[x for x, v in enumerate(H) if v==hma]
w_index=[y for y, v in enumerate(W) if v==wma]
val=-1
for p in h_index:
    for q in w_index:
        if not (p+1,q+1) in s:
            val=0
            break
print(hma+wma+val)


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

int main(){
  int R,G,B,N,ans=0;
  cin>>R>>G>>B>>N;
  int a,b,c;
  a=max(R,max(B,G));
  c=min(R,min(B,G));
  b=R+G+B-a-c;
  for(int i=0; i<=N/a; ++i){
    for(int j=0; j<=(N-a*i)/b; ++j){
      if((N-a*i-b*j)%c==0) ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import bisect
N = int(input())
A = [int(input()) for _ in range(N)]
first = [-1 for _ in range(N)]
for a in A:
    i = bisect.bisect_left(first,a)
    first[i-1] = a
ctr = N
for f in first:
    if f == -1:
        ctr -= 1
print(ctr)

Measured memory_bytes: 56152
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int H=gi(),M=gi(),t1,t2;
	t1=H*60+M;
	H=gi(),M=gi(),t2=H*60+M;
	printf("%d\n",t2-t1-gi());
	return 0;
}


Measured memory_bytes: 3716
import java.util.Scanner;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long A[] = new long[N];
        long array[] = new long[N];
        long yoko = 0, tate = 0;
        int l = 0;
        long tmp = 0;
        for (int i = 0; N > i; i++) {
            A[i] = sc.nextLong();
        }
        Arrays.sort(A);
        for (int j = N-1; 0 <= j; j--) {
            if (tmp != A[j]) {
                tmp = A[j];
            } else {
                yoko = A[j];
                l = j;
                break;
            }
        }
        tmp = 0;
        for (int k = l - 1; 0 <= k; k--) {
            if (tmp != A[k]) {
                tmp = A[k];
            } else {
                tate = A[k];
                break;
            }
        }
        System.out.println(yoko * tate);
    }
}


Measured memory_bytes: 50128
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1e9

struct edge{int to, dist, enem;};

int main() {
    int n, m, l;
    while (cin >> n >> m >> l && n){
        vector<vector<edge> > es(n);
        while (m--){
            int a, b, d, e;
            scanf("%d %d %d %d", &a, &b, &d, &e);
            a--;
            b--;
            edge eg;
            eg.to = b;
            eg.dist = d;
            eg.enem = e;
            es[a].push_back(eg);
            eg.to = a;
            es[b].push_back(eg);
        }
        VVI d(n,VI(l+1,INF));
        d[0][l] = 0;
        priority_queue<pair<int,P>, vector<pair<int,P> >, greater<pair<int,P> > > q;
        q.push(make_pair(0, P(0, l)));
        while (!q.empty()){
            pair<int,P> a = q.top();
            q.pop();
            int now = a.second.first, mon = a.second.second;
            if(d[now][mon] < a.first) continue;
            REP(i,es[now].size()){
                edge e = es[now][i];
                int next = e.to, dist = e.dist;
                if (mon >= dist && d[next][mon-dist] > d[now][mon]){
                    d[next][mon-dist] = d[now][mon];
                    q.push(make_pair(d[next][mon-dist], P(next, mon-dist)));
                }
                if (d[next][mon] > d[now][mon] + e.enem){
                    d[next][mon] = d[now][mon] + e.enem;
                    q.push(make_pair(d[next][mon], P(next, mon)));
                }
            }
        }
        int ans = INF;
        REP(i,l+1) ans = min(ans, d[n-1][i]);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3480
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>

using namespace std;
int main() {

    int A,B,C;
    cin>>A>>B>>C;

    if(A*B>C){

        cout<<C<<endl;

    }
    else{

        cout<<A*B<<endl;
    }

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int H, W;
    cin >> H >> W;
    string dummy(W+2, '0');
    vector<string> vec(H+2,dummy);
    for (int i=1; i <= H; i++){
        string c;
        cin >> c;
        vec[i] = '0' + c + '0';
    }
    for (int i = 1; i <= H; i++){
        for (int j = 1; j <= W; j++){
            if (vec[i][j] != '#'){
                int num = 0;
                for (int k = i-1; k <= i+1; k++){
                    for (int l = j-1; l <= j+1; l++){
                        if (vec[k][l] == '#'){
                            num ++;
                        }
                    }
                }
                vec[i][j] = '0' + num;
            }
        }
    }
    for (int i = 1; i <= H; i++){
        for (int j = 1; j <= W; j++){
            cout << vec[i][j];
        }    
           cout << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    char name[20];
    for(int i=0;i<9;i++){
        cin >> name >> a >> b;
        cout << name << " " << a+b << " " << a*200+b*300 << endl;
    }
    return 0;
}



Measured memory_bytes: 3088
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

nn = inputs[0][0]
bs = inputs[1]


# body
if $debugFlag
  p nn
  p bs
end

ans = 0
nn.times do |i|
  if i == 0
    ans += bs[0]
  elsif i == nn - 1
    ans += bs[-1]
  else
    ans += [bs[i], bs[i-1]].min
  end
end

puts ans


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

bool solve(int x){
  string s = to_string(x);
  ll n = s.size();
  for(int i = 0; n-1-i>=i; i++){
    if(s[i] != s[n-1-i])
      return false;
  }
  return true;  
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll a, b;
  cin >> a >> b;
   ll ans = 0;
  for(ll i = a; i <= b; i++){
    if(solve(i))
      ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int h,w,k;
	cin >> h >> w >> k;
	string m[h];
	int sum = 0;
	for(int i=0; i < h; i++ ){
	    cin >> m[i];
	    for(int j = 0; j < w; j++){
	        if(m[i][j] == '#'){
	            sum++;
	        }
	    }
	}
	int row = (int)pow(2, h);
	int column = (int)pow(2, w);
	
	int res = 0;
    int count;
    bool flag;
	for(int i = 0; i < row; i++){
	    for(int j = 0; j < column; j++){
	        
	        count = sum;
	        flag = true;
	        
	        for(int r = 0; r < h; r++){
	            for(int c = 0; c < w; c++){
	
	               if( ((i >> r) & 1) || ((j >> c) & 1) ){
	                   if(m[r][c] != '#'){
	                       continue;
	                   }
	                    count--;
	                    if(count < k){
	                        flag = false;
	                        break;
	                    }
	               }
	            }
	            if(flag == false){
	                break;
	            }
	        }
	        
	        if(count == k){
	            res++;
	        }
 
	    }
	    
	}
	
	cout << res << endl;;
	
    
}

Measured memory_bytes: 4056
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

bool testcase_ends() {
    size_t H, W;
    if (scanf("%zu %zu", &H, &W) == EOF)
        return 1;

    for (size_t i=1; i<=H; ++i)
        for (size_t j=0; j<W; ++j) {
            char buf[8];
            scanf("%s", buf);
            string S(buf);
            if (S == "snuke")
                return !printf("%c%d\n", 'A'+j, i);
        }

    return 0;
}

int main() {
    bool solved=false;
    while (!testcase_ends())
        solved |= 1;

    return !solved;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<sstream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=100000+10;
int a[N],b,c;
int main()
{
    while(~scanf("%d%d",&b,&c)){
        printf("%.0lf\n",ceil((b+c)/2.0));
    }


    return 0;
}




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

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


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,ans=0;
    cin>>n;
    vector<int> d(n);
    for (int i = 0; i < n; i++)
    {
        cin>>d[i];
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < i; j++)
        {
            ans+=d[i]*d[j];
        }
        
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256