akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x>>y>>z;
std::vector<int> v(y);
rep(i,y)std::cin >> v[i];
rep(i,y){
  if(v[i]<z)n+=1;
}
if(y-n>n)std::cout << n << '\n';
else std::cout << y-n << '\n';
}


Measured memory_bytes: 256
//
//  main.cpp
//  zero
//
//  Created by 叶金炜 on 2019/4/2.
//  Copyright © 2019 okstal. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int main() {
    int w,h,x,y,r;
    cin>>w>>h>>x>>y>>r;
    if(x-r>=0&&x+r<=w&&y-r>=0&&y+r<=h)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 3108
n, m, r = gets.chomp.split(" ").map(&:to_i)
rr = gets.chomp.split(" ").map(&:to_i)
MAX_C = 2 << 31
g = Array.new(n+1){Array.new(n+1, MAX_C)}
(n+1).times do |i|
  g[i][i] = 0
end
m.times do
  a, b, c = gets.chomp.split(" ").map(&:to_i)
  g[a][b] = c
  g[b][a] = c
end

# Warshall floyd

1.upto(n) do |k|
  1.upto(n) do |i|
    1.upto(n) do |j|
      g[i][j] = g[i][k] + g[k][j] if g[i][k] + g[k][j] < g[i][j]
    end
  end
end

ans = []

rr.permutation do |x|
  dist = 0
  (r-1).times do |i|
    dist += g[x[i]][x[i+1]]
  end
  ans << dist
end

puts ans.min

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i,0,N)cin >> A[i];
    rep(i,0,INF){
        if(i * (K - 1) + 1 >= N){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 768
H, W, ch, cw, dh, dw, *S = open(0).read().split()
H, W, ch, cw, dh, dw = [int(_) for _ in [H, W, ch, cw, dh, dw]]
ch -= 1
cw -= 1
dh -= 1
dw -= 1

stack = [[ch, cw]]
dist = [[None] * W for _ in range(H)]
d = 0
while True:
    stack2 = []
    warp = set()
    while stack:
        x, y = stack.pop()
        if (x, y) == (dh, dw):
            print(d)
            exit()
        if dist[x][y] is not None:
            continue
        dist[x][y] = d
        for dx, dy in [[-1, 0], [1, 0], [0, 1], [0, -1]]:
            nx, ny = x + dx, y + dy
            if 0 <= nx < H and 0 <= ny < W and dist[nx][ny] is None:
                if S[nx][ny] == '.':
                    stack += [[nx, ny]]
                else:
                    warp.add((x, y))
    for x, y in warp:
        for dx in range(-2, 3):
            for dy in range(-2, 3):
                nx, ny = x + dx, y + dy
                if 0 <= nx < H and 0 <= ny < W and dist[nx][ny] is None and S[
                        nx][ny] == '.':
                    stack2 += [[nx, ny]]
    if stack2 == []:
        break
    else:
        d += 1
        stack = stack2
print(-1)


Measured memory_bytes: 118308
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
ll n,m,k,ans;
string s,t;
const ll powll = 1LL<<1;

int main(void){
  int n,k; cin >> n >> k;
  int a[n]; rep(i,n) cin >> a[i];

  sort(a,a+n);
  ll ans = 0;
  for(int i = n-1-k; i>=0; i--){
    ans += a[i];
  }
  cout << ans << "\n";
}

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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX

typedef long long ll;
typedef pair<int, int> ii;

/*
class Node {
public:
  int num;
  int index;
  bool operator<(const Node& b) const {
    if(num < b.num) return (num < b.num);
    else return index > b.index;
  }

  Node(){
    num=0; index=0;
  }
  Node(int n, int i) : num(n), index(i){
  }
};
*/

int main(){
  ll n;
  cin >> n;
  ll i = 0;
  while(i*(i  +1) < 2 * n){i++;}
  i--;
  if(i*(i+ 1) == 2*n){
    REP(j, 1, i+1) cout <<j<<endl;
  }
  else{
    ll sa = n - i * (i+1) / 2;
    REP(j, 1, i  + 1 - sa) cout << j<<endl;
    REP(j, i + 2 - sa, i + 2) cout << j <<endl;
  }



  return 0;
}


Measured memory_bytes: 256
import math

(a,b,x)= list(map(float,input().split()))
if x >= (a * a * b/2.0):
    print(math.degrees(math.atan(2.0 * (a * a * b - x)/ (a * a * a))))
else:  
    print(math.degrees(math.atan( (a * b *b)/(2.0 * x))))

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{   char a[1000];
    int  n,m,i;
    while(~scanf("%s",a))
    {    m=0;
        n=strlen(a);
        for(i=0;i<n;i++)
        {
            if(a[i]=='+')
            {
                m++;
            }
            if(a[i]=='-')
            {
                m--;
            }
        }
        printf("%d\n",m);
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int r;
	scanf("%d",&r);

	printf("%d\n",r*r);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define SZ(a) (int)((a).size())
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef double db;
typedef pair <int, int> Pii;
typedef pair <ll, int> Pli;
typedef unsigned long long ull;
const double eps = 1e-8;
const ll infll = 0x7fffffffffffffff;
const int mod = (int)(1e9) + 7;
const int inf = 0x7fffffff;
const int maxn = (int)(2e5) + 7;
const int maxm = 300;

int n, a[maxn];

int main() {

    // freopen("in.in", "r", stdin);
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    sort(a + 1, a + 1 + n, greater<int>());
    ll res = a[1]; int p = 1;
    for (int i = 1; i <= n - 2; i++) {
        if (i & 1) p++;
        res += a[p];
    }
    printf("%lld\n", res);

    return 0;
}

Measured memory_bytes: 4548
#include<stdio.h>
int main(void)
{
	int a,b,x[1001],s[1001],cnt,X,i;
	while(1){
		scanf("%d%d",&a,&b);
		if(a==0&&b==0) break;
		cnt=0; X=0;
		for(i=0;i<a;i++){
			scanf("%d",&x[i]);
		}
		for(i=0;i<b;i++){
			scanf("%d",&s[i]);
		}
		for(i=0;i<b;i++){
			X+=s[i];
			X+=x[X];
			cnt++;
			if(X>=a) break;
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 2612
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll n;
	cin>>n;
	stack<ll>s;
	while(n>0){
		n--;
		ll asci=n%26+97;
		n/=26;
		s.push(asci);
	}
	while(!s.empty()){
		char a = s.top();
		s.pop();
		cout<<a;
	}
	cout<<endl;
	return 0;	
}


Measured memory_bytes: 3636
A = input()
ODD =['R', 'U', 'D']
EVEN =['L', 'U', 'D']
Result = True
for i in range(len(A)):
  if i % 2 ==0:
    Result = Result and (A[i] in ODD)
  else:
    Result = Result and (A[i] in EVEN)
if Result:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
N,M = map(int,input().split())
L =[0]*N
cost = 0
for i in range(N):
    L[i] = list(map(int,input().split()))

#print(L)
#print(sorted(L))#第一要素でソート
L.sort()
for j in range(N):
    num = L[j][1]
    if M > num:
        money = L[j][0]*L[j][1]
        M -= num
        cost += money
    elif M == 0:
        break
    else:
        money = L[j][0]*M
        cost += money
        break
print(cost)

Measured memory_bytes: 57036
#include <bits/stdc++.h>
using namespace std;
long long n,h;
void solve()
{
    vector < long long > a(n),b(n);
    long long i,tag=0,maxi=0,ans=0;
    for (i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
        maxi=maxi>a[i]?maxi:a[i];
    }
    sort(b.rbegin(),b.rend());
    for (i=0;i<n;i++)
    {
        if (b[i]<maxi) break;
        h-=b[i];ans++;
        if (h<=0)  {tag=1;break;}
    }
    if (!tag)
    {
        ans+=h/maxi;
        if (h%maxi) ans++;
    }
    cout<<ans<<endl;
}
int main()
{
    while(cin>>n>>h)
        solve();
}

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

vector <int> v, noten;

int main(){
  int n;
  int s;

  scanf("%d",&n);
  REP (i, n) {
    scanf("%d",&s);
    v.push_back(s);
    if (s % 10 != 0) noten.push_back(s);
  }

  int acc = accumulate(v.begin(), v.end(), 0);
  if (acc % 10 != 0) printf("%d\n",acc);
  else {
    if (noten.empty()) printf("0\n");
    else {
      sort(noten.begin(), noten.end());
      printf("%d\n",acc - noten.at(0));
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl "\n"
#include "string"


int32_t main(){
	boost;
	int n, k;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int l  = 1 ,r = 1e9 , ans = 1e9;
 
	auto okk = [&] (int m) {
		int cnt = 0;
		for(int i = 0; i < n; i++) 
			cnt +=  (a[i] - 1) / m;
		//cout << m << ' ' << cnt << endl;
		return (cnt <= k);
	};

	while(l <= r) {
		int m = (l + r) / 2;
		if(okk(m)) {
			ans = m;
			r = m - 1;
		}
		else
			l = m + 1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 5200
#include <stdio.h>
int sg(int n, int k){
    if (n < k) return 0;
    if (n/k <= 10000) {
        for (int i = 1<<20; i; i>>=1){
            if ((1ll*n-1ll*(n/k+1)*i)/k == 1ll*n/k){
                n -= (n/k+1)*i;
            }
        }
    }
    if (n % k == 0) return n/k;
    return sg(n-n/k-1, k);
}
int main(){
    int n;
    scanf("%d", &n);
    int ans = 0;
    for (int i = 1, a, k; i <= n; ++i){
        scanf("%d%d", &a, &k);
        ans ^= sg(a, k);
    }
    printf("%s\n", ans ? "Takahashi" : "Aoki");
}

Measured memory_bytes: 128
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <set>
# include <cmath>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-3
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
int Scan() {
    int res=0, flag=0;
    char ch;
    if((ch=getchar())=='-') flag=1;
    else if(ch>='0'&&ch<='9') res=ch-'0';
    while((ch=getchar())>='0'&&ch<='9')  res=res*10+(ch-'0');
    return flag?-res:res;
}
void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
const int N=100005;
//Code begin...

LL a[N], b[N];

int main ()
{
    int n;
    LL ans=0;
    scanf("%d",&n);
    FOR(i,1,n) scanf("%lld%lld",a+i,b+i);
    for (int i=n; i>=1; --i) {
        LL val=(a[i]+ans+b[i]-1)/b[i]*b[i];
        ans+=val-a[i]-ans;
        //printf("%lld\n",val-a[i]);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
double EPS=1e-10;
double EQ(double a,double b){
	return abs(a-b)<EPS;
}
map<char,int> m;
int idx=0;
int Mask;

bool analize(string s){
	if(s.size()==1){
		if(s[0]=='T')return true;
		else if(s[0]=='F')return false;
		else{
			int pos=m[s[0]];
			if((Mask>>pos)&1){
				return true;
			}
			return false;
		}
	}
	if(s[0]=='('&&s[s.size()-1]==')'){
		int cnt=1;
		bool ok=true;
		for(int i=1;i<s.size()-1;i++){
			if(s[i]=='(')cnt++;
			else if(s[i]==')')cnt--;
			if(cnt==0){
				ok=false;
				break;
			}
		}
		if(ok)return analize(s.substr(1,s.size()-2));
	}
	int cnt=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='(')cnt++;
		else if(s[i]==')')cnt--;
		if(cnt==0&&s[i]=='*'){
			return analize(s.substr(0,i))&analize(s.substr(i+1));
		}
	}
	cnt=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='(')cnt++;
		else if(s[i]==')')cnt--;
		if(cnt==0&&s[i]=='+'){
			return analize(s.substr(0,i))|analize(s.substr(i+1));
		}
	}
	cnt=0;
	for(int i=0;i<s.size()-1;i++){
		if(s[i]=='(')cnt++;
		else if(s[i]==')')cnt--;
		if(cnt==0&&s[i]=='-'){
			if(s[i+1]=='>'){
				if(analize(s.substr(0,i))&&!analize(s.substr(i+2)))
					return false;
				else return true;
			}
		}
	}
	if(s[0]=='-'){
		return !analize(s.substr(1));
	}
	return false;
}

void solve(){
	string s;
	while(getline(cin,s)&&s!="#"){
		idx=0;
		m.clear();
		string s1,s2;
		for(int i=0;i<s.size();i++){
			if(s[i]=='='){
				s1=s.substr(0,i);
				s2=s.substr(i+1);
			}
		}
		for(int i=0;i<s.size();i++){
			if(s[i]>='a'&&s[i]<='k'&&m.count(s[i])==0){
				m[s[i]]=idx++;
			}
		}
		bool ok=true;
		for(int mask=0;mask<(1<<idx);mask++){
			Mask=mask;
			if(analize(s1)!=analize(s2)){
				ok=false;
				break;
			}
		}
		if(ok)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}int main(){

	solve();

	return 0;
}

Measured memory_bytes: 1364
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<utility>
#define rep(i,n) for(i = 0; i < n; i++)
using namespace std;

int main2(), main();


int main(){
    int n, k, x, i, j;
    string s;
    cin>> s;
    if(s == "Sunny") cout << "Cloudy" << endl;
    if(s == "Cloudy") cout << "Rainy" << endl;
    if(s == "Rainy") cout << "Sunny" << endl;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N;
ll A[100010], B[100010];
ll ret;

int main() {
	cin >> N;
	rep(i, N) {
		cin >> A[i] >> B[i];
	}

	ll ad = 0;
	for (int i = N-1; i >= 0; --i) {
		ll x = A[i] + ad;
		ll d = (x + B[i]-1) / B[i] * B[i];
		ret += d - x;
		ad += d - x;
	}

	cout << ret << endl;

	return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int N, M, X;
	cin >> N >> M >> X;
	vec(D);
	vector<vector<int>> K(N);
	fx(N) {
		vecp(D);
		fy(M) {
			vecp(K[x]);
		}
	}

	int ans = INT_MAX;
	fx(1<<N) {
		int  y = x;
		int i = 0;
		int dp[20] = { 0, };
		int res = 0;
		while (y>0) {
			if (y&1) {
				res += D[i];
				fy(M) {
					dp[y] += K[i][y];
				}
			}
			i++;
			y >>= 1;
		}
		bool flag = true;
		fy(M) {
			if (dp[y]<X) {
				flag = false;
				break;
			}
		}
		if (flag) {
			ans = min(ans, res);
		}
	}
	if(ans!=INT_MAX)
	ce(ans)
	else ce(-1)
    return 0;
}



Measured memory_bytes: 3512
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stdbool.h>
#include<math.h>
#include<sstream>
typedef long long ll;
#define N (1000000000+7)
using namespace std;
typedef pair<int, int> P;
#define INF (-1000)

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

int a[10] = { 0,2,5,5,4,5,6,3,7,6 };
int dp[10010] = { INF };

int main(void) {
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define soja(i,a,n) for(ll i=a;i<=n;i++)
#define ulta(i,n,a) for(ll i=n;i>=a;i--)
ll n,m,k,sum;
int main()
{
string s,c;
ll count=0;
cin>>s>>c;
soja(i,0,s.size()-1)
{
    if(s[i]!=c[i])
        count++;
}
cout<<count<<endl;
return 0;
}


Measured memory_bytes: 3920
#include <bits/stdc++.h>
using namespace std;
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a); i >= (b); --i)
#define sz(a) int((a).size())
#define pconent(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef long double ld;
const ll MOD =  1e9 + 7;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(v) (cout<<v<<" ** "<<endl)
template <class T> inline void dbv(T a) { for(auto x : a){ cout<<x<<" ** " ;} cout<<endl;}
void output(ll tx)
{
    ll n;
    cin>>n;
    ll f =1;
    if(n%10==0)
    {
        f = 10;
    }
    ll ans = 0;
    while(n>0)
    {
        ans = ans + n%10;
        n/=10;
    }
    ans = ans*f;
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t =1;
    // cin>>t;
    FOR(i,0,t)
    {
        output(i+1) ;
    }
    return 0 ;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(s,n) for(int i=s;i<n;i++)
#define inf 10000000000 //1e10
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
const int MAXN = 110,MAXS=100100;
int n, valor[MAXN], peso[MAXN], tab[MAXN][MAXS];
int knapsack(int i,int K){
    if(tab[i][K]>=0) return tab[i][K];
    if(i==n or !K) return tab[i][K]=0;
    int nao_coloca=knapsack(i+1,K);
    if(peso[i]<=K){
        int coloca=valor[i]+knapsack(i+1,K-peso[i]);
        return tab[i][K]=max(coloca,nao_coloca);
    }
    return tab[i][K]=nao_coloca;
}
int32_t main(){
    fastio;
    int w;
    cin >> n >> w;
    memset(tab,-1,sizeof(tab));
    for(int i=0;i<n;i++){
        cin >> peso[i] >> valor[i];
    }
    cout << knapsack(0,w) << endl;
}

Measured memory_bytes: 86272
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int n;
vector<P> g[100010];
int ans[100010];
bool used[100010];
void dfs(int x){
    used[x]=1;
    for(auto p:g[x]){
        int y=p.first;
        if(!used[y]){
            if(p.second) ans[y]=1-ans[x];
            else ans[y]=ans[x];
            dfs(y);
        }
    }
}
int main()
{
    cin>>n;
    for(int i=0; i<n-1; i++){
        int u, v, w; cin>>u>>v>>w;
        u--; v--; w%=2;
        g[u].push_back(P(v, w));
        g[v].push_back(P(u, w));
    }
    dfs(0);
    for(int i=0; i<n; i++) cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
 
using namespace std;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<long long , long long>
#define pb push_back
#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
ll power(ll x,ll y,ll m){ll r=1;for(;y;y>>=1){if(y&1)r=r*x%m;x=x*x%m;}return r;}
const ll mod = 1e9 + 7;
 
int run_test(){
      int n;
      cin >> n;
      ll arr[n];
      for(int i=0; i<n; i++){
            cin >> arr[i];
      }
      sort(arr, arr + n);
      ll ans = 0;
      for(int i=0; i<n; i++){
            for(int j=i + 1; j<n; j++){
                  for(int k= j + 1; k<n; k++){
                        if((arr[i] + arr[j] > arr[k]) && arr[i]!= arr[k] && arr[i] != arr[j] && arr[j] != arr[k]) ans++;
                  }
            }
      }
      cout << ans << "\n";
      return 0;
}
 
int main(){
    FAST;
    ll t;
    t = 1;
 
    while(t--){
        run_test();
    }
}


Measured memory_bytes: 3664
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#define ll long long 
#define dd double
using namespace std;
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n,m;
  cin>>n>>m;
  int l[m],r[m];
  int i;
  for(i=0;i<m;i++){
  	cin>>l[i]>>r[i];
  }
  
  int x=l[0];
  int y=r[0];
  for(i=0;i<m;i++){
  	x=max(l[i],x);
  	y=min(r[i],y);
  	
  }
  
  
  int ans=y-x+1;
  if(ans<0){
  	cout<<"0"<<endl;
  }
  else if(ans>n){
  	cout<<n<<endl;
  }
  
  else{
  	cout<<ans<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 4416
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define maxn 500010
#define mod 1000000007
char s[maxn];
int a[maxn];
int p[maxn];
int main(){
    int n;
    scanf("%d",&n);
    scanf("%s",s);
    for(int i=0;i<2*n;i++){
        if(s[i]=='W') a[i]=1;
        else a[i]=0;
    }
    int l=0,r=0,cnt=0,f=1;
    ll ans=1;
    for(int i=0;i<2*n;i++){
        if((a[i]+cnt)%2==0){
            p[i]=0;
            l++;
            cnt++;
        }
        else{
            p[i]=1;
            r++;
            ans=ans*cnt%mod;
            cnt--;
        }
        if(cnt<0){
            f=0;
            break;
        }
    }
    //for(int i=0;i<2*n;i++) printf("%d",p[i]);
    //printf("\n");
    if(f==0||cnt!=0){
        printf("0\n");
        return 0;
    }
    for(int i=1;i<=n;i++){
        ans=ans*i%mod;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}


int main(){
    //cin.tie(0);

    Int N, Y; cin >> N >> Y;
    for (Int i = 0; i <= N; i++){
        for (Int j = 0; j <= N-i; j++){
            Int k = N-i-j;
            if (10000*i + 5000*j + 1000*k == Y){
                printf("%lld %lld %lld", i, j, k);
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;

}


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

struct Data {
  int x;
  int y;
  int h;
};

inline int calc_top(const Data& d, int cx, int cy) { return d.h + abs(d.x - cx) + abs(d.y - cy); }
inline int calc_height(const Data& d, int ch, int cx, int cy) {
  return max(0, ch - abs(d.x - cx) - abs(d.y - cy));
}

int main() {
  int N;
  cin >> N;
  vector<Data> ds(N);
  Data cd;
  for(int i = 0; i < N; ++i) {
    cin >> ds[i].x >> ds[i].y >> ds[i].h;
    if(ds[i].h > 0) {
      cd = ds[i];
    }
  }
  vector<Data> sccs;
  for(int x = 0; x <= 100; ++x) {
    for(int y = 0; y <= 100; ++y) {
      bool isSuccess = true;
      int h = calc_top(cd, x, y);
      for(int i = 0; i < ds.size(); ++i) {
        if(ds[i].h != calc_height(ds[i], h, x, y)) {
          isSuccess = false;
          break;
        }
      }
      if(isSuccess) {
        sccs.push_back({x, y, h});
      }
    }
  }
  if(sccs.size() > 0) {
    sort(sccs.begin(), sccs.end(), [](const auto& a, const auto& b) { return a.h > b.h; });
    cout << sccs[0].x << " " << sccs[0].y << " " << sccs[0].h << endl;
  }
  return 0;
}

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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define all(c) begin(c),end(c)

template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


auto solve() {
    int N;
    cin >> N;
    vi h(N);
    for (auto &&e: h) cin >> e;

    const ll LINF = 1ll << 60;
    vll dp(N, LINF);
    dp[0] = 0;
    REP(i, N) {
        FOR(j, 1, 2+1) {
            if(i-j >=0)
                dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
        }
    }

    return dp[N-1];
}


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

    cout << solve() << endl;
//    solve();

    return 0;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left, int mid, int right) {
  int n1 = mid -left;
  int n2 = right - mid;
  for(int i=0;i<n1;i++) L[i] = A[left + i];
  for(int i=0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i=0, j=0;
  for(int k=left; k<right; k++) {
    cnt++;
    if(L[i]<=R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[],int n,int left,int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int main(void) {
  int A[MAX], n, i;
  cnt = 0;

  cin >> n;
  for(i=0;i<n;i++) cin >> A[i];

  mergeSort(A, n, 0, n);
  for(i=0;i<n;i++) {
    if(i)cout << " ";
    cout << A[i];
  }
  cout << endl;

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 6980
def maxHeapify(A,i,H):
    l=2*i
    r=2*i+1

    if l<=H and A[l-1]>A[i-1]:
        largest=l
    else:
        largest=i
    if r<=H and A[r-1]>A[largest-1]:
        largest=r
    
    if largest!=i:
        A[i-1],A[largest-1]=A[largest-1],A[i-1]
        maxHeapify(A,largest,H)
        
H=int(input())
A=list(map(int,input().split()))
for i in range(H//2,0,-1):
    maxHeapify(A,i,H)
    
print(" {}".format(" ".join(map(str,A))))


Measured memory_bytes: 63700
import math

def modcomb(n, k, mod, fac, ifac):
    x = fac[n]
    y = ifac[n-k] * ifac[k] % mod
    #print(x * y % mod)
    return x * y % mod

def makeTables(n, mod):
    fac = [1, 1]
    ifac = [1, 1]
    inv = [0, 1]

    for i in range(2, n+1):
        fac.append(i * fac[i-1] % mod)
        inv.append(-inv[mod % i] * (mod // i) % mod)
        ifac.append(inv[i] * ifac[i-1] % mod)
    return fac, ifac

def answer(n, k, mod, fac, ifac):
    if k >= n:
        k = n - 1
    ans = 0
    for i in range(k+1):
        c = modcomb(n, i, mod, fac, ifac) * modcomb(n-1, i, mod, fac, ifac) % mod
        ans = (ans + c) % mod

    return ans

n, k = map(int, input().split())
mod = 1000000007

fac, ifac = makeTables(n, mod)
print(answer(n, k, mod, fac, ifac))


Measured memory_bytes: 26864
#include<bits/stdc++.h>
using namespace std;
char a[1200000];
int main(){
	cin>>a;
	int ans=0,n=strlen(a);
	for(int i=0;i<n;i++){
		if(a[i]=='+') ans++;
		else ans--;	
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N; cin >> N;
  for(long long h = 1; h <= 3500; h++){
    for(long long n =1; n <=3500; n++){
      if(4*h*n -N*(h+n) == 0)continue;
      if((N*h*n)% (4*h*n -N * (h+n)) != 0) continue; 
      long long w = (N*h*n)/(4*h*n -N*(h+n));
      if(w > 0){
        cout << h << " " << n << " " << w << endl;
        return 0;
      }
    }
  }      
      
}

Measured memory_bytes: 3632
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = Integer.parseInt(stdIn.next());
        int[] a = new int[n];
        boolean flag = false;
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(stdIn.next());
            if (a[i] % 2 == 0 && (a[i] % 3 != 0 && a[i] % 5 != 0)) {
                flag = true;
            }
        }

        if (flag) {
            System.out.println("DENIED");
        } else {
            System.out.println("APPROVED");
        }
    }
}

Measured memory_bytes: 23764
import heapq
N, M, S, T = map(int, input().split())
S,T = S-1, T-1 # 0-indexed
A = [[] for _ in range(N)]
B = [[] for _ in range(N)]
inf = 10**18

for i in range(M):
  u,v,a,b = map(int, input().split())
  u,v = u-1, v-1
  A[u].append((v,a))
  A[v].append((u,a))
  B[u].append((v,b))
  B[v].append((u,b))
  
def dij(D, parent):
  fixed = [ False for _ in range(N)]
  ret = [ 10**18 for _ in range(N)]
  h = []
  heapq.heappush(h, (0,parent))
  while h:
    d, now = heapq.heappop(h)
    if fixed[now]:
      continue
    fixed[now] = True
    ret[now] = d
    for nxt, cost in D[now]:
      if fixed[nxt]:
        continue
      heapq.heappush(h, (d+cost, nxt))
  return ret
  
DA = dij(A, S)
DB = dij(B, T)

ANS = [ 0 for _ in range(N+1) ]
ANS[N] = inf
for i in range(N-1,-1,-1):
  ANS[i] = min(ANS[i+1], DA[i] + DB[i])
  
for i in range(N):
  print(10**15 - ANS[i])

#print(DA)
#print(DB)
"""
aのネットワークと、bのネットワーク別々に作って、SからTの最短距離を出す
n-1年目から1年目に遡っていく形で最短を出していく。
A[S][T] と A[S][N-1] + B[N-1][T]を比較すれば良い
"""

Measured memory_bytes: 84156
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)1e6 + 7;
const int infint = (int)1e9;
const ll inf = (ll)1e18;


int n, dp[MAXN], par[MAXN], added[MAXN], parent[MAXN], ans[MAXN], st[MAXN], en[MAXN], tme = 0, rev[MAXN];
vector<int> G[MAXN], mx[MAXN];
ordered_set<int> dsu[MAXN];


void dfs(int u, int p)
{
	st[u] = tme;
	rev[tme] = u;
	
	for (auto v : G[u])
		if(v != p)
			tme++, parent[v] = u, dp[v] = max(dp[u], u), dfs(v, u);
	en[u] = tme;
}
void merge(int u, int v)
{
	u = par[u], v = par[v];
	if(dsu[u].size() < dsu[v].size())
		swap(u, v);
	for (auto c : dsu[v])
		dsu[u].insert(c), par[rev[c]] = u;
}
void add(int u)
{
	added[u] = 1;
	for (auto v : G[u])
		if(added[v])
			merge(u, v);
	
	for (auto v : mx[u])
	{
		//halat bandi mikonim rooye rasi ke gharare bebinimesh
		ans[v]++;
		for (auto adj : G[v])
			if(adj != parent[v] && added[adj])
			{
				int x = dsu[par[adj]].order_of_key(en[adj] + 1) - dsu[par[adj]].order_of_key(st[adj]);
				ans[v] += x;
				ans[adj] -= x;
			}
	}
}
void dfs_col(int u, int p)
{
	for (auto v : G[u])
		if(v != p)
			ans[v] += ans[u], dfs_col(v, u);
}
int main()
{
	ios::sync_with_stdio(false); 
	cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1, -1);
	dp[1] = 1;
	for (int i = 1; i <= n; i++)
		par[i] = i, mx[dp[i]].push_back(i), dsu[i].insert(st[i]);
	
	for (int i = 1; i <= n; i++)
		add(i);
	dfs_col(1, -1);
	for (int i = 2; i <= n; i++)
		cout << ans[i] - 1 << " ";
}


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

int main(void){
    int n;

    cin >> n;

    n=n%10;
    if(n==2||n==4||n==5||n==7||n==9){
        cout<<"hon"<<endl;
    }else if(n==0||n==1||n==6||n==8){
        cout<<"pon"<<endl;
    }else{
        cout<<"bon"<<endl;
    }
    return 0;
}

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

int main() {
	string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
  char a = s1.at(0); 
  char b = s2.at(0);
  char c = s3.at(0);

  cout << a<<b <<c << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	unordered_map<int, int> cnt;
	cnt.reserve(n);
	long long sum{};
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		sum += x;
		cnt[x]++;
	}
	
	int q;
	cin >> q;
	long long ans[q];
	for (int i = 0; i < q; i++) {
		long long b, c;
		cin >> b >> c;
		sum += (c - b)*cnt[b];
		cnt[c] += cnt[b];
		cnt[b] = 0;
		ans[i] = sum;
	}
	
	for (long long l : ans) cout << l << '\n';
}

Measured memory_bytes: 7924
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        int[] a = Read.ints();
        Console.WriteLine(Math.Min(a[2],a[1]*a[0]));
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                // 素数ではない
                return false;
            }
        }

        // 素数である
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13268
// ※※※ 解答不能 ※※※
// 正解者のソースを学習する(一部改変).
// tourist氏
// https://atcoder.jp/contests/agc035/submissions/6377009
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
vector<LL> a;
int N;

LL Go(int from, int to, LL ca, LL cb){
    if(to - from == 1) return 0;
    LL best = 1e18;
    for(int i = from + 1; i < to; i++){
        LL cur = a[i] * (ca + cb) + Go(from, i, ca, ca + cb) + Go(i, to, ca + cb, cb);
        best = min(best, cur);
    }
    return best;
}

int main() {
    scanf("%d", &N);
    a.resize(N);
    for(int i = 0; i < N; i++) scanf("%d", &a[i]);
    printf("%lld\n", Go(0, N - 1, 1, 1) + a[0] + a[N - 1]);
    return 0;
}

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

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

ll power(ll  a, ll b){
   ll  ans = 1;
   while(b){
      if(b&1){
         ans *= a;
      }
      a *= a;
      b /= 2;
   }
   return ans;
}

int lar[2234567];

void pre(){
    memset(lar, 0, 1e6+7);
     lar[1] = 1;
     for(int i = 2; i <= 1e5; i++){
         cout << i << endl;
         if(lar[i]){
            continue;
         }
         lar[i] = i;
         for(ll j = 1LL*i*i; j <= 1e5; j += i){
             lar[j] = i;
         }
     }
     for(int i = 1; i <= 100; i++) cout << lar[i] << endl;

}

ll mod = 1e9+7;


int main()
{
   int n, k;
   cin >> n >> k;
   vector <int> vec(n);
   for(int i = 0; i < n; i++) cin >> vec[i];
   sort(vec.begin(), vec.end());
   int min1 = INT_MAX;
   if(k > vec[n-1]){
      cout << "IMPOSSIBLE";
      return 0;
   }
   for(int i = 0; i < n-1; i++){
       if(vec[i+1] == vec[i]) continue;
       if(vec[i+1] - vec[i] < min1) min1 = vec[i+1]-vec[i];
   }
   for(int i = 0; i < n; i++){
       if(vec[i] < k) continue;
       if((vec[i] - k)%min1 == 0){
          cout << "POSSIBLE";
          return 0;
       }
   }
   cout << "IMPOSSIBLE";
}



Measured memory_bytes: 640
#include<cstdio>
typedef long long ll;
ll min(ll a,ll b) {return a>b?b:a;}
int main()
{
	int n;
	ll T,x,pre,ans=0;
	scanf("%d%lld",&n,&T);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&x);
		if(i==1) {pre=x;continue;}
		ans+=min(x-pre,T);
		pre=x;
	}
	printf("%lld\n",ans+T);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;

const int inf=0x3f3f3f3f;
int G[110][110];
int d[110];
bool vis[110];
int n;

void Dijsktra(){
    d[0]=0;
    for(int i=0;i<n;i++){
        int u=-1,minn=inf;
        for(int j=0;j<n;j++){
           // if(d[j]<minn&&vis[j]==false){
           if(d[u]<minn&&vis[u]==false){
                u=j;
                minn=d[j];
            }
        }
        if(u==-1)
            return ;
        vis[u]=true;
        for(int v=0;v<n;v++){
            if(vis[v]==false&&G[u][v]!=-1&&d[u]+G[u][v]<d[v]){
                d[v]=d[u]+G[u][v];
            }
        }
    }
}

int prim(){
    d[0]=0;
    int ans=0;
    for(int i=0;i<n;i++){
        int u=-1,minn=inf;
        for(int j=0;j<n;j++){
           // if(d[j]<minn&&vis[j]==false){
           if(d[j]<minn&&vis[j]==false){
                u=j;
                minn=d[j];
            }
        }
        if(u==-1)
            return -1;
        vis[u]=true;
        ans+=d[u];
        for(int v=0;v<n;v++){
            if(vis[v]==false&&G[u][v]!=-1&&G[u][v]<d[v]){
                d[v]=G[u][v];
            }
        }
    }
    return ans;
}

int main(){
    //fill(G[0],G[0]+110*110,inf);
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            scanf("%d",&G[i][j]);
        }
    }
    //memset(d,0,sizeof(d));
    memset(vis,0,sizeof(vis));
    fill(d,d+110,inf);
    printf("%d\n",prim());

    return 0;
}



Measured memory_bytes: 3224
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int N,A,B;

    private void solve() {

        N = nextInt();
        A = nextInt();
        B = nextInt();

        out.println(Math.min(N * A,B));

    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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

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

int main(){
  int n;
  cin >> n;
  int p[n];
  for(int i = 0;i < n;i++){
    cin >> p[i];
  }
  int count = 0;
  for(int i = 1;i < n-1;i++){
    if(p[i] > p[i-1] && p[i] < p[i+1]){
      count++;
    }
    if(p[i] < p[i-1] && p[i] > p[i+1]){
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
constexpr const int INF=1<<30,MOD=1000000007;constexpr const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
#ifndef LOCAL
struct osd{template<class T>osd&operator<(const T&t){return*this;}template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;template<class...T>void _print(osd&a,T&&...t){}
#define cerr cer_
#endif
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}template<class T>istream&operator>(istream&i,T&t){return i>>t;}
void _print(ostream&s){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<t<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}template<class...T>void dprint(T&&...t){_print(cerr,t...);}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<p.F<' '<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>p.F>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>queue<T>&operator<<(queue<T>&q,const T&t){q.push(t);return q;}template<class T>queue<T>&operator<<(T&t,queue<T>&q){t=q.front();q.pop();return q;}
template<class T>deque<T>&operator>>(const T&t,deque<T>&q){q.push_front(t);return q;}template<class T>deque<T>&operator<<(T&t,deque<T>&q){t=q.front();q.pop_front();return q;}
template<class T>deque<T>&operator<<(deque<T>&q,const T&t){q.push_back(t);return q;}template<class T>deque<T>&operator>>(deque<T>&q,T&t){t=q.back(t);q.pop_back();return q;}
template<class T>stack<T>&operator<<(stack<T>&s,const T&t){s.push(t);return s;}template<class T>stack<T>&operator>>(stack<T>&s,T&t){t=s.top();s.pop();return s;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n;
    cin>n;
    string s;
    cin>s;
    int k;
    cin>k;
    REP(i,n){
        cout<(s[k-1]==s[i]?s[i]:'*');
    }
    cout<endl;
    return 0;
}


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

using namespace std;

int main(){
  int n;
  cin >> n; 
 
  int res=1;
 for(int i=2;i*i<=n;i++){
   int exp=i*i;
   while(exp<=n){
    exp*=i;
   }
   res=max(res,exp/i);
 }
  
  cout << res << endl;
  
}

Measured memory_bytes: 256
n,a,b = map(int,input().split())
ans=0
Sum=0
for i in range(1,n+1):
  Sum=0
  x=i
  for j in range(len(str(i))):
    Sum+=x%10
    x//=10
  if a<=Sum<=b:
    ans+=i
print(ans)
    
    
    

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] vals = Console.ReadLine().Split(' ').Select(tmp => long.Parse(tmp)).ToArray();

            for (int i =0; i<5; i++) {
                if (vals[i] == 0) {
                    Console.WriteLine(i+1);
                }
                
            }
            
        }
    }
}


Measured memory_bytes: 27896