akhauriyash/Code-Regression huggingface dataset:
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

use std::cmp::Ordering;
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

impl<T: Copy> Copy for Rev<T> {}

fn main() {
    input! {
        n: usize,
        k: usize,
        s: chars
    }

    let mut s = s;
    s[k - 1] = (s[k - 1] as u8 - 'A' as u8 + 'a' as u8) as char;
    let ans = s.into_iter().collect::<String>();
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std; 
string a,b,c;
int d,e;
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>a>>b>>d>>e>>c;
	if(a==c)d--;
	if(b==c)e--;
	cout<<d<<' '<<e<<endl;
    return 0; 
}/*
*/

Measured memory_bytes: 256
s=[]
p=[]
a=i=0
for cur in input():
 if"\\"==cur:s+=[i]
 elif"/"==cur and s:
  j=s.pop()
  t=i-j
  a+=t
  while p and p[-1][0]>j:t+=p[-1][1];p.pop()
  p+=[(j,t)]
 i+=1
print(a)
if p:print(len(p),*list(zip(*p))[1])
else:print(0)


Measured memory_bytes: 6500
#!/usr/bin/env python3

def main():
    K = int(input())

    d = [100] * K
    d[1] = 1
    Q = []
    for i in range(45 + 1):
        Q.append([])
    Q[1].append(1)
    for i in range(1, 45 + 1):
        q = Q[i]
        while 0 < len(q):
            v = q.pop(0)
            nv = (v * 10) % K
            if i < d[nv]:
                d[nv] = i
                q.append(nv)
            nnv = (v + 1) % K
            if i + 1 < d[nnv]:
                d[nnv] = i + 1
                Q[i + 1].append(nnv)



    print(d[0])


if __name__ == '__main__':
    main()



Measured memory_bytes: 5780
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	LL N;
	cin >> N;
	vector<LL> A(N);
	rep(i,N) cin >> A[i];
	LL M=1000, K=0;
	rep(i,N-1){
		if(A[i]<=A[i+1]){
			K+=M/A[i];
			M%=A[i];
		}
		else{
			M+=K*A[i];
			K=0;
		}
	}
	cout << M+K*A[N-1] << endl;

	return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793

int main(){
	int sx, sy, tx, ty;
	scanf("%d%d%d%d", &sx, &sy, &tx, &ty);
	int xmove, ymove;
	xmove = tx-sx;
	ymove = ty-sy;
	for(int i=0; i<xmove; i++){
		printf("R");
	}
	for(int i=0; i<ymove; i++){
		printf("U");
	}
	for(int i=0; i<xmove; i++){
		printf("L");
	}
	for(int i=0; i<ymove; i++){
		printf("D");
	}
	printf("D");
	for(int i=0; i<xmove+1; i++){
		printf("R");
	}
	for(int i=0; i<ymove+1; i++){
		printf("U");
	}
	printf("LU");
	for(int i=0; i<xmove+1; i++){
		printf("L");
	}
	for(int i=0; i<ymove+1; i++){
		printf("D");
	}
	printf("R\n");


	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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 long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[110][110];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}
ll res = 0;
vector<ll> A(13);
ll p = 0;
ll q, ans;
struct item {
	ll a, b, c, d;
} st[55];


int main() {
	cin >> n;
	ll a, b;
	cin >> a >> b;
	if (a > b) {
		cout << 0 << endl;
		return 0;
	}
	if (a != b && n == 1) {
		cout << 0 << endl;
		return 0;
	}else if (a == b && n == 1) {
		cout << 1 << endl;
		return 0;
	}
	ll x = a * (n - 1) + b;
	ll y = a + b * (n - 1);
	cout << y - x + 1 << endl;
}

Measured memory_bytes: 256
/**
 * C - Attention
 * https://atcoder.jp/contests/abc098/tasks/arc098_a
 **/
#include<iostream>
#include<string.h>

using namespace std;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int lc = 0;
    int rc = 0;
    for(int i=1; i<S.length(); i++) {
        // 10^5
        if(S[i]=='E') {
            rc += 1;
        }
    }

    // リーダ移動
    int ans = rc;
    for(int i=1; i<S.length(); i++) {
        // 10^5
        if(S[i]=='E') {
            rc -= 1;
        }
        if(S[i-1]=='W') {
            lc += 1;
        }
        ans = min(ans, rc+lc);
    }

    cout << ans << endl;

}

Measured memory_bytes: 900
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007LL;

vector<int> u(100010), v(100010);
vector<ll> dist(100010), w(100010);
vector<vector<pair<int,ll>>> adj(100010);

void bfs(void) {
    queue<pair<int,int>> Q;
    vector<int> visit(100010,0);

    
    dist[1] = 0;
    visit[1] = 1;
    for (auto itr = adj[1].begin();itr != adj[1].end();itr++) {
        Q.push(make_pair(1,itr->first));
        dist[itr->first] = dist[1] + itr->second;
        visit[itr->first] = 1;
    }

    while (!Q.empty()) {
        int i = Q.front().first, j = Q.front().second;
        // cout << i << "," << j << endl;
        Q.pop();
        for (auto itr = adj[j].begin();itr != adj[j].end();itr++) {
            if (visit[itr->first] == 0) {
                Q.push(make_pair(j,itr->first));
                dist[itr->first] = dist[j] + itr->second;
                visit[itr->first] = 1;
            }
        }
    }

}

int check(vector<int> X) {
    int N = X.size() - 1;
    int flag = 1;
    for (int i=0;i<N-1;i++) {
        if (w[i] % 2 == 0 && X[u[i]] == X[v[i]]) flag |= 1;
        else if (w[i] % 2 != 0 && X[u[i]] != X[v[i]]) flag |= 1;
        else flag = 0;
    }
    return flag;
}

int main(void) {
    int N;
    cin >> N;
    for (int i=0;i<N-1;i++) {
        cin >> u[i] >> v[i] >> w[i];
    }
    for (int i=1;i<=N;i++) {
        dist[i] = 1000000000000000LL;
    }
    for (int i=0;i<N;i++) {
        adj[u[i]].push_back(make_pair(v[i],w[i]));
        adj[v[i]].push_back(make_pair(u[i],w[i]));
    }
    bfs();
    // for (int i=1;i<=N;i++) {
    //     cout << i << ": " << dist[i] << endl;
    // }
    vector<vector<int>> comb(2, vector<int>(N+1,-1));
    comb[0][1] = 0;
    comb[1][1] = 1;
    for (int i=2;i<=N;i++) {
        if (dist[i] % 2 == 0) for (int j=0;j<2;j++) {
            comb[j][i] = comb[j][1];
        } else for (int j=0;j<2;j++) {
            comb[j][i] = 1-comb[j][1];
        }
    }
    if (check(comb[0])) for (int i=1;i<=N;i++) {
            cout << comb[0][i] << endl;
    } else for (int i=1;i<=N;i++) {
            cout << comb[1][i] << endl;
    }

    return 0;
}


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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}
template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    ll x, k, d;
    cin >> x >> k >> d;

    x = abs(x);
    ll ans;
    
    if(x/d >= k) {
        ans = x - d * k;           
    } else {
        ll cnt = x/d;
        k -= cnt;
        x -= d*cnt;
        if(k%2 == 1) {
            x -= d;
        } 
        ans = x;
    }
    cout << abs(ans) << endl;
    return 0;
} /*atcoder*/




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

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

	if (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#create date: 2020-07-03 10:17

import sys
stdin = sys.stdin
from itertools import product
import numpy as np

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n, m, x = na()
    c, a = list(), list()
    for i in range(n):
        ci, *ai = na()
        c.append(ci)
        a.append(ai)
    a = np.array(a)
    buy_book = product([0,1], repeat=n)
    ans = 10**10
    f = False
    for book_list in buy_book:
        cost = 0
        b = [0] * m
        for book, ci, ai in zip(book_list, c, a):
            if book==1:
                cost += ci
                b += ai
        if np.min(b) >= x:
            f = True
            ans = min(ans, cost)
    print(ans if f else -1)



if __name__ == "__main__":
    main()

Measured memory_bytes: 27260
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<int,int>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i,n) for (ll i=(ll)n-1;i>=0;i--)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
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; }
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
#define INF 1<<30
#define INFTY 1LL<<60
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}//最大公約数
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}//最小公倍数
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
const int MOD = 1000000007;

inline ll mod_add(ll a,ll b){return (a+b)%MOD;}
inline ll mod_sub(ll a,ll b){return (a+MOD-b)%MOD;}
inline ll mod_mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;
x=x*x%mod;n>>=1;}return res;}
inline ll mod_inv(ll x){return mod_pow(x,MOD-2);}
inline ll mod_div(ll a, ll b){return mod_mul(a,mod_inv(b));}
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back

int H ,W ,D , A ;
int Q ,L , R ;
int px [90001] , py[90001];
int d[90001];

int main(){
scanf ("%d %d %d " ,&H ,&W ,&D );
for ( int i =0; i < H ; i++)
{
for ( int j =0; j < W ; j++)
{
scanf ("%d " ,&A );
px [ A ]= i , py [ A ]= j ;
}
}
for ( int i = D +1; i <= H * W ; i++)
d[ i ]= d [i - D ]+ abs ( px [ i ] - px [i - D ])+ abs ( py [ i ] - py [i - D ]);
scanf ("%d " ,&Q );
while (Q--)
{
scanf ("%d %d " ,&L ,& R );
printf ("%d \n " , d [ R ] - d [ L ]);
}
}

Measured memory_bytes: 4716
import sys
sys.setrecursionlimit(10**6)

N=input()
A=[]
def func(d,n,t):
	if d==t:
		return
	for i in [3,5,7]:
		A.append(10*n+i)
		func(d+1, 10*n+i,t)
func(0,0,len(N))


ans=0
for a in A:
	a_str=str(a)
	if '3' in a_str and '5' in a_str and '7' in a_str and a<=int(N):
		ans+=1
print(ans)

Measured memory_bytes: 4332
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
dlist = []

for i in range(n):
    d = t - h[i] * 0.006 - a
    
    if d >= 0:
        dlist.append(d)
    else:
        d = -d
        dlist.append(d)
        
m = dlist[0]
  
for i in range(1,n):
    if dlist[i-1] <= dlist[i]:
        if dlist[i-1] <= m:
            m = dlist[i-1]
        else:
            pass
    else:
        if dlist[i] <= m:
          	m = dlist[i]
        else:
          pass

        
print(dlist.index(m) + 1)
    

Measured memory_bytes: 3064
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  int K; cin >> K;
  int H1 = K / 2, H2 = K - H1;
  cout << H1 * H2 << endl;

  return 0;
}


Measured memory_bytes: 256
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision; 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second
#define pb push_back
#define REP(i,a,b) for(long long int i=a ; i<b ; i++)
#define mp make_pair
#define INF 1000000000000000000
#define mod 1000000007
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define vi vector<ll>
#define vd vector<ld>
#define vvi vector<vi>
#define vvd vector<vd>
#define vpi vector<pi>
#define vpd vector<pd>
#define us unordered_set<ll>
#define um unordered_map<ll,ll>
#define sortA(a) sort(a.begin(),a.end())
#define sortD(a) sort(a.begin(),a.end(),greater<ll>())
#define all(a) a.begin(),a.end()
#define N 100005


#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define in insert
#define fbo find_by_order
#define ook order_of_key


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

ll powmod(ll x,ll y)
{
	if(x==0)
		return 0;
	if(y==0 || x==1)
		return 1;
	if(y%2==0)
		return powmod((x*x)%mod,y/2)%mod;
	return (x*powmod(x,y-1)%mod)%mod;
}
void print1D(vi a)
{
	for(ll i=0;i<a.size();++i)
	{
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
void print2D(vector<vi> a)
{
	for(ll i=0;i<a.size();++i)
	{
		for(ll j=0;j<a[i].size();++j)
		{
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
}
void solve()
{
	ll n;
	cin>>n;
	vvi a(n,vi(3));
	for(ll i=0;i<n;++i)
	{
		for(ll j=0;j<3;++j)
		{
			cin>>a[i][j];
		}
	}
	for(ll i=1;i<n;++i)
	{
		for(ll j=0;j<3;++j)
		{
			a[i][j]+=max(a[i-1][(j+1)%3],a[i-1][(j+2)%3]);
		}
	}
	cout<<max(a[n-1][0],max(a[n-1][1],a[n-1][2]))<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
	ll t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}


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

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

    vector<pair<int,int>> inc;
    vector<pair<int,int>> dec;
    int64_t sum = 0;
    for (int i = 0; i < N; ++i) {
        string str;
        cin >> str;
        int minDiff = 0;
        int diff = 0;
        for (char ch : str) {
            if (ch == '(') {
                ++diff;
            }
            else {
                --diff;
                minDiff = min(minDiff, diff);
            }
        }
        sum += diff;
        pair<int,int> x = {-minDiff, diff - minDiff};
        if (diff >= 0) {
            inc.push_back(x);
        }
        else {
            dec.push_back(x);
        }
    }
    if (sum != 0) {
        cout << "No" << endl;
        return 0;
    }

    sort(begin(inc), end(inc), [](const pair<int,int> &a, const pair<int,int> &b){
        return (a.first < b.first) || (a.first == b.first && a.second > b.second);
    });
    sort(begin(dec), end(dec), [](const pair<int,int> &a, const pair<int,int> &b) {
        return (a.second > b.second) || (a.second == b.second && a.first < b.first);
    });

    sum = 0;
    auto check = [&](vector<pair<int,int>> &v) -> bool {
        for (const auto &[right, left] : v) {
            if (sum - right < 0) {
                return false;
            }
            sum += (left - right);
        }
        return true;
    };
    if (check(inc) && check(dec)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 11248
#include <cmath>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define sd1(a) scanf("%d",&a)
#define slld1(a) scanf("%lld",&a)
#define sd2(a,b) scanf("%d%d",&a,&b)
#define sd3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define pd1(a) printf("%d\n",a)
#define plld1(a) printf("%lld\n",a)

int a,b,c;
int main(){
	//ios::sync_with_stdio(false);
	while(sd2(a,b)!=EOF){
		c=a*b-a-b+1;
		pd1(c);
	}

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
//#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x,m) (((x)%m*(x)%m)%m)%m
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const ll mod           = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
#define N 1000001
const ll N2      = 70;
const ld PI      = 3.141592653589793;
//template<class T>using onset=tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
void solve(){
  #ifndef ONLINE_JUDGE  
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
signed main(){
    fastio();
    ll n; 
    cin>>n; 
    ll a[n],b[n];
    for(ll i=0;i<n;i++){
      cin>>a[i]>>b[i];
    }
    ll c[n]={0};
    bool ok=0;
    for(ll i=0;i<n;i++){
      if(a[i]==b[i]){
        c[i]=1;
      }
    }
    for(ll i=0;i<(n-2);i++){
      if(c[i]==1 and c[i+1]==1 and c[i+2]==1){
        ok=1;
        break; 
      }
    }
    if(ok==1){
      cout<<"Yes";
    }
    else{
      cout<<"No";
    }
    //printclock;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>


int main() {
  int H, W;
  int j, k;
  char odd = '#', even = '.';

  for (int i = 0; i < 300; i ++) {
    std::cin >> H >> W;
    if (H == 0 && W == 0) break;
    for (j = 0; j < H; j ++) {
      for (k = 0; k < W; k ++) {
        if ((k + j) % 2 == 0) {
          std::cout << odd;
        } else {
          std::cout << even;
        }
      }
      std::cout << std::endl;
    }
    std::cout << std::endl;
  }
  return 0;
}




Measured memory_bytes: 3088
t=input()
N=int(t.split()[0])
Y=int(t.split()[1])

flag=False
for i in range(N+1):
  for j in range(N-i+1):
    if 10000*i+5000*j+1000*(N-i-j)==Y:
      if not flag:
        flag=True
        print(i,j,N-i-j)

if not flag:
  print(-1,-1,-1)

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

#define int long long

const int N = 2e5 + 10;
int n, sz, sum, ans, point, cntl;
map <int, int> cnt;
set <int> st;

void go_left() {
	auto it = st.find(point);
	assert(it != st.begin() && it != st.end());
	it--;
	
	int x = *it, d = point - x;
	ans += (sz - cntl) * d;
	ans -= cntl * d;
	cntl -= cnt[x];
	point = x;
}

void go_right() {
	auto it = st.upper_bound(point);
	assert(it != st.end());
	
	int x = *it, d = x - point;
	ans += (cntl + cnt[point]) * d;
	ans -= (sz - cntl - cnt[point]) * d;
	cntl += cnt[point];
	point = x;
}

void add(int x) {
	cnt[x]++;
	st.insert(x);
	sz++;
	if (sz == 1) {
		point = x;
		return;
	}
	
	if (x > point)
		ans += x - point;
	else if (x < point)
		ans += point - x, cntl++;
	
	while ((sz + 1) / 2 > cntl + cnt[point])
		go_right();
	while ((sz + 1) / 2 <= cntl)
		go_left();
}

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		int t, a, b;
		cin >> t;
		if (t == 2) {
			cout << point << ' ' << ans + sum << '\n';
			continue;
		}
		
		cin >> a >> b;
		sum += b;
		add(a);
	}
}

Measured memory_bytes: 13568
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f40;
const long long mod=1e9+7;
const long double PI = acos(0);
// }}} End Header
int main() {
	ll n, ans = 0, sum = 0;
	cin >> n;
	vector<ll> a(n);
	rep(i,n){
		cin >> a[i];
		sum+=a[i];
	}
	rep(i,n-1){
		sum-=a[i];
		ll t = (a[i]*(sum%mod));
		ans+=t;
		ans%=mod;
	}
	cout << ans << endl;
	//cout << sum << endl;
	return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int dp[110000];
const int INF = 1001001001;
int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n)dp[i] = INF;
    dp[0] = 0;
    rep(i,n)cin >> h[i];
    rep(i,n-1){
        dp[i+1] = min(dp[i+1],dp[i] + abs(h[i] - h[i+1]));
        if(i+2<=n-1)dp[i+2] = min(dp[i+2],dp[i] + abs(h[i+2]- h[i]));
    }
    cout << dp[n-1] << endl;
    


    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdint>

int main()
{
	std::uint32_t d;
	while (std::cin >> d) {
		std::uint32_t total = 0;
		for (std::uint32_t i = 0; i < (600 - d) / d; ++i) {
			total += i * i;
		}
		std::cout << d * d * d * total + (600 - d) * (600 - d) * d << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs


int main() {
  char c; cin >> c;
  char d;
  if (c=='A') d='T';
  else if (c=='T') d='A';
  else if (c=='C') d='G';
  else d='C';
  cout << d << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int x[200000], n, r[200000];
bool search() {
	int minx = 1000000; for (int i = 0; i < n; i++)minx = min(minx, x[i]);
	int cnt = 0; for (int i = 0; i < n; i++) { if (x[i] == minx) { cnt++; } }
	if (cnt >= 3)return false;
	int maxn = 0; for (int i = 0; i < n; i++)maxn = max(maxn, x[i]);
	if (minx * 2 + 1 - cnt != maxn)return false;
	for (int i = minx + 1; i <= maxn; i++) {
		if (r[i] <= 1)return false;
	}
	return true;
}
int main() {
	cin >> n; for (int i = 0; i < n; i++) { cin >> x[i]; r[x[i]]++; }
	bool ans = search();
	if (ans == true)cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 256
import collections

n= int(input())
A =[input() for _ in range(n)]
Ac = collections.Counter(A)
m= int(input())
B =[input() for _ in range(m)]
Bc = collections.Counter(B)
ans =[]
for i in Ac.keys():
    ans.append(Ac[i]-Bc[i])
print(max(max(ans),0))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >> N;
  double X;
  X = N /1.08;
  M = X;
   int O = M *1.08;  
   int P =(M+1)*1.08;
   int Q = (M-1)*1.08;
 // cout << O << P << Q;
  if (O == N) cout << M << endl;
  else if (P == N) cout << M+1 << endl;
  else if (Q == N ) cout << M-1 << endl;
  else cout << ":(" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>

int main(){
    int n;
    std::cin >> n;
    int pre_x = 0, pre_y = 0, pre_t = 0;
    for(int i = 0; i < n; i++){
        int t, x, y;
        std::cin >> t >> x >> y;

        int need_t = t - pre_t, need_x = std::abs(x - pre_x), need_y = std::abs(y - pre_y);
        if(need_x + need_y > need_t){
            std::cout << "No" << std::endl;
            return 0;
        }else{
            int diff = need_t - (need_x + need_y);
            if(diff % 2 != 0){
                std::cout << "No" << std::endl;
                return 0;
            }
        }

        pre_x = x, pre_y = y, pre_t = t;
    }

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


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(9**9)
n,m=map(int,input().split())
L=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    L[a-1].append(b-1)
    L[b-1].append(a-1)
A=[0]+[-1]*(n-1)
B=[[0,L[0]]]
def wfs(A,B):
    C=[]
    f=False
    for b in B:
        for l in b[1]:
            if A[l]==-1:
                A[l]=b[0]
                C.append([l,L[l]])
                f=True
    if f:
        return wfs(A,C)
    else:
        print('Yes')
        for a in A[1:]:
            print(a+1)
wfs(A,B)

Measured memory_bytes: 128880
n=int(input())
d={}
a=[]
for i in range(n):
  s=input()
  if s not in d:
    d[s]=1
    a.append(s)
  else:
    d[s]+=1
m=max(d.values())
a.sort()
for i in a:
  if d[i]==m:
    print(i)

Measured memory_bytes: 36768
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

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

  for (int i = 1; i < n; i++)  {
    vector<int> tmp;
    for (int j = 1; j <= k; j++) {
      int prevIdx = i - j;
      if (prevIdx < 0) {
        continue;
      }
      tmp.push_back(memo[prevIdx] + abs(hs[i] - hs[prevIdx]));
    }
    memo[i] = *min_element(tmp.begin(), tmp.end());
  }
  cout << memo[n-1] << endl;
  return 0;
}

Measured memory_bytes: 1024
// Best practice

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 

#define int         long long
#define pb          emplace_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#define fbo find_by_order
#define ook order_of_key

signed main() {
   tezz
   
   int n;
   cin >> n;
   int f1;
   vector<int> a(n);
   int sum=0;
   int mm=INT_MAX;
   for(int i=0; i<n; i++){
       cin >> a[i];
       sum+=abs(a[i]);
       mm = min(mm, abs(a[i]));
   }
   for(int i=0; i<n-1; i++){
       if(a[i]<0){
           a[i]=-a[i];
           a[i+1]=-a[i+1];
           f1=i;
       }
   }
   if(a[n-1]<0){
       cout << sum-2*mm << endl;
   }
   else{
       cout << sum << endl;
   }
   
   return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  string c;
  cin >> c;
  if (c == "a" || c == "i" || c == "u" || c == "e" || c == "o") {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

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

    if(a >= b)
    {
    	while(a > 0)
    	{
    		cout << b;
    		a --;
    	}
    }
    else if(a < b)
    {
    	while(b > 0)
    	{
    		cout << a;
    		b --;
    	}
    }
    cout << endl;
}

Measured memory_bytes: 256
using System;

class B{
  public static void Main(){
    string[] Ar = Console.ReadLine().Split(' ');
    int N = int.Parse(Ar[0]);
    string Temp;
    for (int i = 0; i < N; i++){
      Temp = Console.ReadLine();
      Console.WriteLine(Temp);
      Console.WriteLine(Temp);
    }
  }
}

Measured memory_bytes: 11092
#include<stdio.h>

int main(void){
	int dx[]={0,0,1,-1,1,1,-1,-1,0,0,2,-2};
	int dy[]={1,-1,0,0,1,-1,1,-1,2,-2,0,0};
	int map[10][10];
	int x,y,ink_size;
	int max=0,cnt;
	int tmp_x,tmp_y;
	int i,j;

	cnt=0;
	for(i=0;i<10;i++)
		for(j=0;j<10;j++)
			map[i][j]=0;
	while(scanf("%d,%d,%d",&x,&y,&ink_size)!=EOF){
		map[y][x]++;
		for(i=0;i<4*ink_size;i++){
			tmp_x=x+dx[i];
			tmp_y=y+dy[i];
			if(tmp_x>=0 && tmp_x<10 && tmp_y>=0 && tmp_y<10)
				map[tmp_y][tmp_x]++;
		}
	}
	for(i=0;i<10;i++){
		for(j=0;j<10;j++){
			if(map[i][j]==0)
				cnt++;
			if(map[i][j]>max)
				max=map[i][j];
		}
	}
	printf("%d\n%d\n",cnt,max);
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    double t = 0.0;
    vector<int> d(n, 0);

    for (int i = 0; i < n; i++)
    {
        cin >> d[i];
        t += 1.0 / d[i];
    }
    cout << 1.0 / t;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];
        int[] C = new int[N];
        for (int i=0;i<N;i++){
            A[i] = sc.nextInt();
        }
        for (int i=0;i<N;i++){
            B[i] = sc.nextInt();
        }
        for (int i=0;i<N;i++){
            C[i] = sc.nextInt();
        }
        Arrays.sort(A);
        Arrays.sort(B);
        Arrays.sort(C);
        long[] recordB = new long[N];
        int left = 0;
        for(int j=0; j<N; j++){
            while(left<N&&A[left]<B[j]) left++;
            if(j==0) recordB[j]+=left;
            else recordB[j] += left+recordB[j-1];
        }
        // recordB[j] is an integer
        int right = 0;
        int[] recordC = new int[N];
        for(int k=0;k<N;k++){
            while(right<N&&B[right]<C[k]) right++;
            recordC[k]=right;
        }
        long ans = 0;
        for(int k=0;k<C.length;k++){
            if(recordC[k]==0) continue;
            ans += recordB[recordC[k]-1];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 96136
S = int(input())

if S <= 10 ** 9:
    print(0, 0, S, 0, S, 1)
else:
    a = S // (10 ** 9)
    b = S % (10 ** 9)
    if b == 0:
        print(0, 0, 10 ** 9, 1, 0, a)
    else:
        print(0, 0, 10 ** 9, 1, 10 ** 9 - b, a + 1)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N;
string s;

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

  int r = 0, b = 0;
  REP(i, N) {
    if(s[i] == 'R') r++;
    else b++;
  }

  if(r > b) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (2006)
ll n,k,memo[MAXN][MAXN][2],mod=1e9+7,total=1;
ll dp(ll x,ll left,bool b){
	if(~memo[x][left][b])return memo[x][left][b];
	ll&ans=memo[x][left][b]=0;
	if(x==1){
		if(left == n-k) return ans = 1;
		else if(left > n-k && b) return ans = dp(1, left-1, 1);
		return 0;
	}
	if(b){
		ans = dp(x-1, left, 1) + dp(x-1, left+1, 0) + (left > 0 ? dp(x, left-1, 1) : 0), ans %= mod;
	}else{
		ans = dp(x-1, left, 1) + dp(x-1, left+1, 0), ans %= mod;
	}
	return ans;
}
int main(){
	FAST
	cin>>n>>k;
	mmst(memo,-1);
	FOR(i,1,n-k-1) total *= 2, total %= mod;
	cout<<dp(n,0,1) * total % mod<<'\n';
}


Measured memory_bytes: 66692
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;
int main(){
   ll q,h,s,d,n;
   cin >> q >> h>> s>> d;
   cin >> n;
   h=min(q*2,h);
   s=min(h*2,s);//1L
   if(2*s<=d) cout << n*s<<endl;
   else cout <<(n/2)*d+(n%2)*s<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
 
using lint=long long;
using pint=pair<int,int>;
template<class T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

int main()
{
   string s; cin>>s;
   cout<<string(s.size(),'x')<<endl;
   return 0;
}


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

const int MLOG = 63;

struct gavi{                    //  l : -------------      r : ---------------
	deque <int> r, l;           //      ^           ^          ^             ^
	void push_back(int x) {     //    front        back      midl           far
		l.push_back(x);
	}
	void push_midl(int x) {
		r.push_front(x);
	}
	void push_frnt(int x) {
		l.push_front(x);
	}
	void push_far(int x) {
		r.push_back(x);
	}
	void out() {
		cout << l.size() + r.size() << endl;
		for (int i : l) 
			cout << i << ' ';
		for (int i : r)
			cout << i << ' ';
	}
} me;

int main() {
	ll n;
	cin >> n;
	vector <int> l, r;
	int cnt = 1;
	vector <bool> all;
	while (n) {
		if (n & 1) {
			all.push_back(false);
			n /= 2;
		} else {
			all.push_back(true);
			n--;
		}
	}
	reverse(all.begin(), all.end());
	for(int i = 0; i < (int)all.size(); i++) {
		cerr << all[i];
		if(all[i]) {
			me.push_back(cnt);
			me.push_midl(cnt++);
		} else {
			me.push_frnt(cnt);
			me.push_midl(cnt++);
		}
	}
	cerr << endl;
	me.out();
}


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

ll func(ll x, ll ar[], ll dp[]) {
  if(dp[x] != -1) 
    return dp[x];
  return (dp[x] = min(func(x-1, ar, dp)+abs(ar[x]-ar[x-1]), func(x-2, ar, dp)+abs(ar[x]-ar[x-2])));
}
        
int main()
{
	ll n;
	cin >> n;
	ll ar[n+1];
  	for(ll x = 1; x <= n; x++) {
    	cin >> ar[x];
    }
	ll dp[n+1];
  	memset(dp, -1, sizeof(dp));
  	dp[1] = 0;
  	dp[2] = abs(ar[2]-ar[1]);
  	cout << func(n, ar, dp);
}	

Measured memory_bytes: 9012
#include <bits/stdc++.h>
using namespace std;
#define min(...) minn(__VA_ARGS__)
#define max(...) maxx(__VA_ARGS__)
#define stringio() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
char _;
typedef long long ll;
typedef pair<int,int> pii;
template<typename t>constexpr const t minn(const t x,const t y){return x<y?x:y;}
template<typename t,typename ...r>constexpr const t minn(const t x,const r ...xs){return minn(x,minn(xs...));}
template<typename t>constexpr const t maxx(const t x,const t y){return x>y?x:y;}
template<typename t,typename ...r>constexpr const t maxx(const t x,const r ...xs){return maxx(x,maxx(xs...));}
template <typename t> void scan (t& x) {do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0);}
template <typename t, typename ...r> void scan (t& x, r&... xs) {scan(x); scan(xs...);}
const int MAXN = 100005;
int main() {
    int n,d;
    scan(n,d);
    printf ("%d\n",(int)ceil((double)n/(d<<1|1)));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define N 2010
using namespace std;
int n;
int q[N<<1],head,tail,p[N<<1];
ll res,ans,a[N],x;
int main()
{
	scanf("%d%lld",&n,&x);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	for(int i=0;i<n;i++)
	{
		if(i>0&&x*i>=ans)break;
		head=1;
		tail=0;
		res=0;
		for(int j=n-i+1;j<=n;j++)
		{
			while(head<=tail&&q[tail]>=a[j])--tail;
			q[++tail]=a[j];p[tail]=j-n;
		}
		for(int j=1;j<=n;j++)
		{
			while(head<=tail&&q[tail]>=a[j])--tail;
			q[++tail]=a[j];p[tail]=j;
			while(p[head]<j-i)++head;
			res+=q[head];
		}
		if(i==0)ans=res;
		else ans=min(ans,res+x*i);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 256
n, m, l = map(int, input().split())

a = []
for x in range(n):
    a.append(list(map(int, input().split())))

b = []
for x in range(m):
    b.append(list(map(int, input().split())))

for x in range(n):
    string = ""
    flag = False
    for y in range(l):
        if(flag):
            string += " "
        else:
            flag = True

        tmp = 0
        for z in range(m):
            tmp += a[x][z] * b[z][y]
        string += str(tmp)
    print(string)


Measured memory_bytes: 6312
N = int(input())
b = [int(i) for i in input().split()]

a = [0] * N
a[0] = b[0]
a[N - 1] = b[N - 2]
for i in range(1, N - 1):
    a[i] = min(b[i - 1], b[i])

print(sum(a))


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


int main(){
    long long m,n,ans=1;
    cin>>m>>n;
    while(n>0){
        if(n&1){           
            ans*=m;
        }
        m *=m;
        m%=1000000007;
        n >>= 1;
        ans = ans%1000000007;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define loop(i,a,b)for(ll i=a;i<=b;i++)
#define loopr(i,a,b)for(ll i=b;i>=a;i--)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define vll vector<ll> 
#define vvl vector<vll>
#define vpll vector<pll>
#define pll pair<ll,ll>
#define F first
#define S second
#define MOD 1000000007
ll max(ll a,ll b){if (a>b) return a; else return b;}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll T=1;
	//cin >> T;
	ll t=0;
	while(t++<T){
		ll n,d;
		cin>>n>>d;
		ll cnt=0;
		fo(i,n){
			ll x,y;
			cin>>x>>y;
			if(x*x+y*y<=d*d)cnt++;
		}
		cout<<cnt<<endl;
		
	}
return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    int i;
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    vector<ll> dp(n + 1, -1);
    dp[0] = 1000;
    int j;
    for (i = 1; i <= n; i++) {
        for (j = 0; j < i; j++) {
            if (dp[j] < 0) continue;

            dp[i] = MAX(dp[i], dp[j]);
            int p, q;
            for (p = j; p < i; p++) {
                for (q = p + 1; q < i; q++) {
                    if (a[p] < a[q]) {
                        ll num=dp[j] / a[p];
                        ll tmp=dp[j] + (a[q] - a[p])*num;
                        dp[i] = MAX(dp[i], tmp);
                    }
                }
            }
        }
    }
    printf("%lld\n", dp[n]);

    return;
}

int main()
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 3224
#include <stdio.h>
 
using namespace std;
 
int main(){
    int a,b;
    while(true){
        scanf("%d %d",&a,&b);
        if(a == 0 && b == 0) break;
        if(a > b) printf("%d %d\n",b,a);
        else{
            printf("%d %d\n",a,b);
        }
    }
}


Measured memory_bytes: 2704