akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int N;
    cin >> N;
    int pi;
    vector<int> P;
    for(int i=0;i<N;i++){
        cin >> pi;
        P.push_back(pi);
    }
    int res = 0;
    for(int i=0;i<N-2;i++){
        if(P[i] < P[i+1] && P[i+1] < P[i+2]) res++;
        if(P[i] > P[i+1] && P[i+1] > P[i+2]) res++;
    }
    cout<<res<<endl;

    return 0;
}

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

namespace AtCoder.Contest.D
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var cin = new Scanner();

			var sum = new List<int>();
			var prime = new HashSet<int>();
			sum.Add(0);
			for (int i = 1; i < 100000; i++)
            {
				if (i == 1) sum.Add(0);
                else
                {
					bool isPrime = true;
                    foreach (var e in prime)
                    {
						if (e * e > i) break;
						else if (i % e == 0) isPrime = false;
                    }
                    if (isPrime) prime.Add(i);
					if (isPrime && prime.Contains((i + 1) / 2)) sum.Add(sum[i - 1] + 1);
					else sum.Add(sum[i - 1]);
                }
            }
			int q = cin.NextInt();
            for (int i = 0; i < q; i++)
            {
				int l = cin.NextInt();
				int r = cin.NextInt();
				Console.WriteLine(sum[r] - sum[l - 1]);
            }

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 19280
#include<iostream>  
#include<algorithm>  
#include<string>  
#include<sstream>  
#include<set>  
#include<vector>  
#include<stack>  
#include<map>  
#include<queue>  
#include<deque>  
#include<cstdlib>  
#include<cstdio>  
#include<cstring>  
#include<cmath>  
#include<ctime>  
#include<functional> 
#define INT_MAX 2147483647
#define INT_MIN -2147483648
typedef long long LL;
using namespace std;
const int maxn = 1024 + 10;
int main()
{
	//freopen("data_in.txt", "r", stdin);
	//freopen("data_out.txt", "w", stdout);
	int n = 0, res = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int r = 0;
		cin >> r;
		while (!(r & 1)) {
			res++;
			r = (r >> 1);
		}
	}
	cout << res;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int h=0;
    int f;
    int co=0;
    string alp ="abcdefghijklmnopqrstuvwxyz";
    string c="C";
    f=s.find("C")+1;
    if(s.at(0)!='A'){
        h++;
        //cout << 'A' << endl;
        }
    if((f<3)||(f==(s.size()))){
        //cout << "NmC " << f <<endl;
        h++;
        }
        int g=0;
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='C'){
            co++;
            s.erase(i,1);
            }
    }
    if(co!=1)h++;
    if(s.at(0)=='A'){
        s.erase(0,1);
    }
    for(int j=0;j<s.size();j++){
        int r= alp.find(s.at(j));
        if(r==std::string::npos)h++;
    }

    if(h!=0)cout << "WA" << endl;
    else cout << "AC" <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

struct li{
	int dis,sw;//sw and sw+1
	int upl,upr;
	int dnl,dnr;
	li(){}
	li(int a,int b):sw(a),dis(b){}
};

bool cmp(const li &l1,const li &l2)
{
	return l1.dis<l2.dis;
}

li lis[100100];

int score[1010];

int ids[1010];
int pts[1010];

bool added[1010];

int main()
{
	while(1)
	{
	int N,M,H,K;
	scanf("%d%d%d%d",&N,&M,&H,&K);
	if(H==0&&M==0&&H==0&&K==0) break;
	for(int i=0;i<N;i++)
	{
		scanf("%d",score+i);
	}
	for(int i=0;i<M;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		lis[i].sw=a-1,lis[i].dis=b;
	}
	sort(lis,lis+M,cmp);
	for(int i=0;i<N;i++) ids[i]=i;
	for(int i=0;i<M;i++)
	{
		lis[i].upl=ids[lis[i].sw];
		lis[i].upr=ids[lis[i].sw+1];
		swap(ids[lis[i].sw],ids[lis[i].sw+1]);
	}
	for(int i=0;i<N;i++) pts[i]=score[i];
	for(int i=M-1;i>=0;i--)
	{
		lis[i].dnl=pts[lis[i].sw];
		lis[i].dnr=pts[lis[i].sw+1];
		swap(pts[lis[i].sw],pts[lis[i].sw+1]);
	}
	int ans=0;
	memset(added,false,sizeof(added));
	for(int i=0;i<M;i++)
	{
		if(lis[i].upl<=K-1&&added[lis[i].upl]==false)
		{
			ans+=lis[i].dnr;
			added[lis[i].upl]=true;
		}
		if(lis[i].upr<=K-1&&added[lis[i].upr]==false)
		{
			ans+=lis[i].dnl;
			added[lis[i].upr]=true;
		}
	}
	int Ma=0;
	for(int i=0;i<M;i++)
	{
		if(lis[i].upr<=K-1&&lis[i].upl>=K)
		{
			if(lis[i].dnr<lis[i].dnl)
			{
				Ma=max(Ma,lis[i].dnl-lis[i].dnr);
			}
		}
		if(lis[i].upl<=K-1&&lis[i].upr>=K)
		{
			if(lis[i].dnr>lis[i].dnl)
			{
				Ma=max(Ma,lis[i].dnr-lis[i].dnl);
			}
		}
	}
	printf("%d\n",ans-Ma);
	}
	return 0;
}

Measured memory_bytes: 3120
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s:Vec<char> = buf.trim().chars().collect();
	let mut cnt = 0;
	for i in s {
		if i == '1' {
			cnt += 1;
		}
	}
	println!("{}", cnt);
}

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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    string s; cin >> s;
    ll a = 0, ans = 0;
    rep(i, s.size()) {
        if(s[i] == 'A') {
            a++;
        }
        else if(s.substr(i, 2) == "BC") {
            if(a > 0) {
                ans += a;
            }
            i++;
        }
        else {
            a = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 3764
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
   return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
   os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  int h,w;cin>>h>>w;
  VV<char> v(h,V<char>(w)),r,b;
  rep(i,0,h)rep(j,0,w)cin>>v[i][j];
  r=v,b=r;

  rep(i,0,h)rep(j,1,w-1){
    if(i%2){
      b[i][j]='#';
    }else{
      r[i][j]='#';
    }
  }

  rep(i,0,h){
    r[i][0]='#';
    b[i][w-1]='#';
  }

  rep(i,0,h)rep(j,0,w){
    if(v[i][j]=='#'){
      r[i][j]='#';
      b[i][j]='#';
    }
  }

  rep(i,0,h){
    rep(j,0,w){
      cout<<r[i][j];
    }
    cout<<ENDL;
  }
  cout<<ENDL;
  rep(i,0,h){
    rep(j,0,w){
      cout<<b[i][j];
    }
    cout<<ENDL;
  }

}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

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

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

  bool ans = (S.size() >= 5);
  int i = S.size() - 1;
  while (i >= 4) {
    if (S[i] == 'm') {
      if (S.substr(i - 4, 5) == "dream") {
        i -= 5;
        continue;
      }
    } else if (S[i] == 'e') {
      if (S.substr(i - 4, 5) == "erase") {
        i -= 5;
        continue;
      }
    } else if (S[i] == 'r') {
      if (S.substr(i - 5, 6) == "eraser") {
        i -= 6;
        continue;
      } else if (S.substr(i - 6, 7) == "dreamer") {
        i -= 7;
        continue;
      }
    }
    ans = false;
    break;
  }

  cout << (ans ? "YES" : "NO") << endl;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		 
        String N = sc.next();
 
        if (N.charAt(0) == '7' || N.charAt(1) == '7' || N.charAt(2) == '7') {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

	}

}


Measured memory_bytes: 35732
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	int C[4];
	for (int i = 0; i < 4; i++)C[i] = 0;
	int mx = -1;
	for (int i = 0; i < 3; i++) {
		cin >> a >> b; a--; b--;
		C[a]++; C[b]++;
		mx = max(mx, C[a]);
		mx = max(mx, C[b]);
	}
	if (mx == 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(void) {
  int a,b,n = 0;
  scanf("%d %d",&a,&b);
  if (a <= b) {
    printf("%d",a);
  }  else {
    printf("%d",a - 1);
  }
  return 0;
}


Measured memory_bytes: 128
#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else
#define DMP(...) ((void)0)
#endif

#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	int n, x, t;
	cin >> n >> x >> t;

	cout << ((n - 1) / x + 1) * t << "\n";

	return 0;
}


Measured memory_bytes: 3600
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    int r = x%y;
    if (r == 0) {
        return y;
    }
    return gcd(y, r);
}

ll mypow(ll x, ll n) {
    if (n == 0) return 1;
    if (n%2 == 0) return mypow(((x%mod)*(x%mod))%mod, n/2);
    else return ((x%mod) * mypow(((x%mod)*(x%mod))%mod, (n-1)/2))%mod;
}

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while (A > 0 && C > 0) {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            break;
        }
    }
}

Measured memory_bytes: 3636
from math import sqrt

q = int(input())

p = []
for _ in range(q):
    p.append(list(map(int, input().split())))

for t in p:
    x = min(t)
    y = max(t)
    if x == y or x + 1 == y:
        print(x * 2 - 2)
    else:
        temp = sqrt(x * y)
        hoge = int(temp)
        if hoge == temp:
            hoge -= 1
        if hoge * (hoge + 1) >= x * y:
            print(2 * hoge - 2)
        else:
            print(2 * hoge - 1)



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




int main(){
    ll N;cin>>N;
    ll a[100100];
    rep(i,0,N)cin>>a[i];
    sort(a,a+N);
    int ok=1;
    if(N%2==1){
        if(a[0]!=0)ok=0;
        ll ju=0;
        rep(i,1,N){
            if(i%2==1)ju+=2;
            if(a[i]!=ju)ok=0;
        }
    }
    else{
        ll ju=-1;
        rep(i,0,N){
            if(i%2==0)ju+=2;
            if(a[i]!=ju)ok=0;
        }
    }
    ll ans=1;
    if(!ok)cout<<0<<endl;
    else{
        rep(i,0,N/2){
            ans=(ans*2)%1000000007;
        }
        cout<<ans<<endl;
    }
}







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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N + 2];


void solve()
{
	cin >> n;
	set<string> s;
	lop(i, 0, n)
	{
		string str;
		cin >> str;
		s.insert(str);
	}
	cout << s.size() << endl;

}

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

	int test = 1;
	// cin >> test;
	while (test--)solve();


}





Measured memory_bytes: 19248
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)
#define ll_cin(X) scanf("%lld", &X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0


#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);


int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}
#pragma endregion


int main(void)
{
	int  n, k,i,r,l;
	//char a[100001];

	i_cin2(n,k);

	//s_cin(a);

	r = 1;n -= k;
	k--;
    
	r += (n % k) ? n / k + 1 : n / k;
	i_cout(r);

	/*for (i = 0; i < n; i++)
		if (a[i] == '1') break;
	r = (i%(k-1))?i/k:i/k+1;

	n -= (i - 1);
	l = (n%(k-1))? n / k : n / k + 1;
	i_cout(n + l);*/

	return 0;
}



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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int a[3], b[3];
  int c[3][3];
  for(int y = 0; y < 3; ++y) {
    for(int x = 0; x < 3; ++x) {
      cin >> c[x][y];
    }
  }
  a[0] = 0;
  b[0] = c[0][0] - a[0];
  b[1] = c[0][1] - a[0];
  b[2] = c[0][2] - a[0];
  a[1] = c[1][0] - b[0];
  a[2] = c[2][0] - b[0];
  for(int y = 0; y < 3; ++y) {
    for(int x = 0; x < 3; ++x){
      if(a[x] + b[y] != c[x][y]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;

  return 0;
}


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

int main() {
  double D[80]; int d=0;
  char inbuf[99];
  while (gets(inbuf)) {
    char *tp = strtok(inbuf, " \n");
    while (tp!=NULL) {
      if ((tp[0] == '+') && (tp[1]==0)) {
        D[d-2]+=D[--d];
      }
      else if (tp[0] == '*') {
        D[d-2]*=D[--d];
      }
      else if ((tp[0] == '-') && (tp[1]==0)) {
        D[d-2]-=D[--d];
      }
      else if (tp[0] == '/') {
        D[d-2]/=D[--d];
      }
      else {
        D[d++]=atof(tp);
      }
      tp = strtok(NULL, " \n");
    }
    printf("%.6lf\n",D[--d]);
  }
  return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define dl 998244853
int main() {
    int n;
    cin>>n;
    vector<lli> a(n,0);
    for(int i=0;i<n;i++)cin>>a[i];
    //vector<lli> ans(n,0);
    lli f=0;
    lli h=abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        lli temp = min(f+abs(a[i]-a[i-2]),h+abs(a[i]-a[i-1]));
        f=h;
        h=temp;
        //cout<<f<<" "<<h<<endl;
    }
    cout<<h<<endl;
}

Measured memory_bytes: 1024
N, M = [int(i) for i in input().split()]

connections = []
for _ in range(M):
    k, *S = [int(i) for i in input().split()]
    connections.append([i-1 for i in S])
P = [int(i) for i in input().split()]


def get_bin(x, n=0):
    return format(x, 'b').zfill(n)


switches = [False] * N

count = 0
for i in range(2 ** N):
    binstr = get_bin(i, N)
    switches = [s == '1' for s in binstr]
    for j in range(M):
        conn = connections[j]
        p = P[j]

        f = 0
        for c in conn:
            if switches[c]:
                f += 1
        if f % 2 != p:
            break
    else:
        count += 1
print(count)


Measured memory_bytes: 42716
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, M;
int A[31][31];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M;
    rep(i, 0, N) {
        int k; cin >> k;
        rep(j, 0, k) {
            int a; cin >> a;
            a--;

            A[i][a] = 1;
        }
    }

    int ans = 0;
    rep(i, 0, M) {
        int cnt = 0;
        rep(j, 0, N) if (0 < A[j][i]) cnt++;
        if (cnt == N) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  cin >> n;

  map<string, int> mp;
  REP(i,n){
    string s;
    cin >> s;
    mp[s];
  }

  cout << mp.size() << endl;
  return 0;
}



Measured memory_bytes: 19252
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;

#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

int32_t main()
{
    fast 
    int t;
    cin >> t;
    if (t >= 400 && t < 600) cout << 8;
    else if (t >= 600 && t < 800) cout << 7;
    else if (t >= 800 && t < 1000) cout << 6;
    else if (t >= 1000 && t < 1200) cout << 5;
    else if (t >= 1200 && t < 1400) cout << 4;
    else if (t >= 1400 && t < 1600) cout << 3;
    else if (t >= 1600 && t < 1800) cout << 2;
    else if (t >= 1800 && t < 2000) cout << 1;
    return 0;
}

Measured memory_bytes: 3132
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val n = readLine.split(" ").map(_.toInt).head
    val a = readLine.split(" ").map(_.toInt).head
    val ans = (n % 500) <= a
    println(if(ans) "Yes" else "No")
  }
}


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

int main() {
  int H, N;
  cin >> H >> N;
  long long sum = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    sum += a;
  }

  cout << ((sum >= H) ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long int ll;

int N;

int main(){
	cin >> N;
	string res = "";
	int cnt = 0;
	while(N != 0){
		int M;
		if(N % (-2) == 0) M = 0;
		else M = 1;
		res += (char)(M + '0');
		N -= M;
		N /= (-2);
	}
	if(res == "") res += '0';
	reverse(res.begin(), res.end());
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		}
		int q = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < q; i++) {
		    int x = sc.nextInt();
		    if (arr[0] >= x) {
		        sb.append(0);
		    } else {
    		    int left = 0;
    		    int right = n;
    		    while (right - left > 1) {
    		        int m = (left + right) / 2;
    		        if (arr[m] < x) {
    		            left = m;
    		        } else {
    		            right = m;
    		        }
    		    }
    		    sb.append(right);
		    }
		    sb.append(" ");
		    if (arr[0] > x) {
		        sb.append(0);
		    } else {
    		    int left = 0;
    		    int right = n;
    		    while (right - left > 1) {
    		        int m = (left + right) / 2;
    		        if (arr[m] <= x) {
    		            left = m;
    		        } else {
    		            right = m;
    		        }
    		    }
    		    sb.append(right);
		    }
		    sb.append("\n");
		}
		System.out.print(sb);
	}
}



Measured memory_bytes: 108440
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = __int128_t;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int k;
    cin >> k;
    rep(i,k)cout << "ACL";
    cout << endl;
}


Measured memory_bytes: 3532
import bisect

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))

BC = []
for _ in range(M):
    b, c = map(int, input().split())
    BC.append((b, c))

BC.sort(reverse=True, key=lambda x: x[1])

ans, i = 0, 0
for bc in BC:
    ti = bisect.bisect(A, bc[1])
    if (ti > i) and (bc[0] >= (ti - i)):
        ans += bc[1] * (ti - i)
        i = ti
    elif (ti > i) and (bc[0] < (ti - i)):
        ans += bc[1] * bc[0]
        i = i + bc[0]

print(ans + sum(A[i:]))


Measured memory_bytes: 22492
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	_ = sc.NextInt()
	s := sc.NextLine()

	if len(s)%2 != 0 {
		fmt.Printf("No\n") // output for debug
		return
	}
	left := s[0 : len(s)/2]
	right := s[len(s)/2:]

	// fmt.Printf("%+v\n", left)  // output for debug
	// fmt.Printf("%+v\n", right) // output for debug

	if left != right {
		fmt.Printf("No\n") // output for debug
	} else {
		fmt.Printf("Yes\n") // output for debug
	}
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
import math


def main():
    k = int(input())
    k1 = k + 1

    sum = 0
    for i in range(1, k1):
        for j in range(1, k1):
            for m in range(1, k1):
                sum += math.gcd(math.gcd(i, j), m)
    print(sum)

main()



Measured memory_bytes: 9020
import math
import sys
input = sys.stdin.readline
number, jump =input().rstrip().split()
number = int(number)
jump = int(jump)
scaffolding = input().rstrip().split()
scaffolding = list(map(int, scaffolding))
res = [0 for i in range(number)]
res[1] = abs(scaffolding[1]-scaffolding[0])
#test = [math.inf for k in range(jump)]
#test[0] = 0

for i in range(2, number):
    h=max(0,i-jump)
    res[i]=min(res[k]+abs(scaffolding[i]-scaffolding[k]) for k in range(h,i))   
    #res[i] = min(test)
    

print(res[number-1])

Measured memory_bytes: 20856
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100100100;//10^17
const ll MOD = 1000000007;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}




int main(){
    char b;
    cin >> b;
    if(b == 'A')cout << 'T';
    if(b == 'C')cout << 'G';
    if(b == 'G')cout << 'C';
    if(b == 'T')cout << 'A';
    cout << endl;
}



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

unsigned int a[200001];
bool ans[200001];

int main(void) {
	int N;
	cin >> N;
	for (int i = 0; i <= N; i++) ans[i] = false;
	for (int i = 1; i <= N; i++) cin >> a[i];

	int ans_cnt = 0;
	for (int i = N; i > 0; i--) {
		unsigned int sum = 0;
		for (int j = i; j <= N; j+=i) {
			if (ans[j]) sum++;
		}
		if ((sum&1u)==a[i]) ; // 何もしない
		else { // 入れる
			ans[i] = true;
			ans_cnt++;
		}
	}

	cout << ans_cnt << endl;
	for (int i = 1; i <= N; i++) {
		if (ans[i]) cout << i << " ";
	}
	return 0;
}


Measured memory_bytes: 1920
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;



/* Name of the class has to be "Main" only if the class is public. */
public class Main
 
 
{
    static Scanner in = new Scanner(System.in);
    
    public static void solve()
    {
       String s=in.nextLine();
       String s1=in.nextLine();
       
       if(s.equals(s1.substring(0,s1.length()-1)))
       {
           System.out.println("Yes");
       }
       else
       {
           System.out.println("No");
       }
    }
    

    
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		
		int t=1;
	//	in.nextLine();
		
		while(t>0)
		{
		    
		    solve();
		    t--;
		}
		
		
	
	//	System.out.println(x);
	}
}


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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec)
    is >> x;
  return is;
}

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;

  int n, m;
  cin >> n >> m;

  vi l(m), r(m);
  REP(i, m) cin >> l[i] >> r[i];

  int lm = 0, rm = n;

  REP(i, m) {
    lm = max(lm, l[i]);
    rm = min(rm, r[i]);
  }

  cout << max(rm - lm + 1, 0) << endl;

  return 0;
}


Measured memory_bytes: 1024
n=int(input())
l=list(map(int,input().split()))
t=l[0]
a=l[1]
ll=list(map(int,input().split()))

q=0
d=abs(t-ll[0]*0.006-a)
for i in range(1,n):
    if abs(t-ll[i]*0.006-a)<d:
        q=i
        d=abs(t-ll[i]*0.006-a)
print(q+1)

Measured memory_bytes: 3064
#include <stdio.h>
int main(void) {
  
  int n, ryoiki;
  
  while( scanf("%d",&n) != EOF ) {
    ryoiki = 1;
    for(; n > 0; n--) {
      ryoiki += n;
    }
    printf("%d\n",ryoiki);
  }
  return(0);
}

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int n,a,b,f=1,cnt[300005];
int main(){
	scanf("%d%d%d",&n,&a,&b);
	if(a+b>n+1)f=0;
	if(1ll*a*b<n)f=0;
	if(!f){
		printf("-1");return 0;
	}
	for(int i=n-a+1;i<=n;i++)printf("%d ",i);
	n-=a;b--;
	if(!b)return 0;
	int t=n/b;
	for(int i=1;i<=b;i++)
		cnt[i]=t;
	int m=n%b;
	for(int i=1;i<=m;i++)
		cnt[i]++;
	for(int i=1;i<=b;i++){
		for(int j=n-cnt[i]+1;j<=n;j++)
			printf("%d ",j);
		n-=cnt[i];
	}
	return 0;
}


Measured memory_bytes: 2816
#include<iostream>
#include<algorithm>
#define fs first
#define sc second
using namespace std;

typedef pair<int,int> P;
typedef pair<int,P> E;

int n,m;
E e[11000];
int par[110],rank[110];

void init(int x){
  for(int i=1;i<=x;i++){par[i] = i; rank[i] = 0;}
}

int find(int x){
  if(par[x] == x)return x;
  return par[x] = find(par[x]);
}

bool same(int a,int b){return find(a)==find(b);}

void unite(int a,int b){
  a = find(a); b = find(b);
  if(a==b)return;
  if(rank[a]<rank[b])par[b] = a;
  else{
    par[a] = b;
    if(rank[a]==rank[b])rank[b]++;
  }
}

int main(){
  while(cin >> n >>m,n||m){
    for(int i=0;i<m;i++)cin >> e[i].sc.fs >> e[i].sc.sc >> e[i].fs;
    sort(e,e+m);

    int res = -1;
    for(int i=0;i<m;i++){
      init(n); int cnt = 0,j;
      for(j=i;j<m;j++){
	if(!same(e[j].sc.fs,e[j].sc.sc)){
	  unite(e[j].sc.fs,e[j].sc.sc);
	  cnt++;
	  if(cnt==n-1)break;
	}
      }
      if(cnt==n-1 && (res<0 || res>e[j].fs-e[i].fs))res = e[j].fs-e[i].fs;
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 1292
import math
N = int(input())
if N == 1:
    print(0)
    exit()
# print(((3**N  - 2**(N+1) + 1) / math.factorial(N)) % (10**9 + 7))
print(((10**N  - 9**(N) * 2 + 8**N)) % (10**9 + 7))

Measured memory_bytes: 11064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<int,ll> P;

ll cost[305][305];
ll dist[305][305];
ll num[305][305];

int main(void){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>cost[i][j];
            dist[i][j]=cost[i][j];
            num[i][j]=1;
        }
    }
    for(int i=0;i<n;i++){
        priority_queue<P,vector<P>,greater<P>>que;
        que.push(P(i,0));
        while(!que.empty()){
            P p=que.top();
            que.pop();
            int now=p.first;
            ll c_now=p.second;
            //cout<<now<<" "<<c_now<<endl;
            for(int j=0;j<n;j++){
                if(i==j)continue;
                ll c=cost[now][j];
                if(c>0){
                    ll d=c_now+c;
                    if(dist[i][j]>d){
                        cout<<-1<<endl;
                        return 0;
                    }
                    if(dist[i][j]==d){
                        if(num[i][j]==1){
                            num[i][j]++;
                            que.push(P(j,d));
                        }
                        else{
                            cost[i][j]=0;
                        }
                    }
                }
            }
        }
    }
    ll ans=0;
    for(ll i=0;i<n;i++){
        for(ll j=i;j<n;j++){
            ans+=cost[i][j];
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__  "YES"
#define FALSE__ "NO"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a
#define lcoutln(a) cout << a << endl
#define lcerr(a) cerr << a
#define lcerrln(a) cerr << a << endl
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007
#define PI 3.141592653589793238462643383

signed main()
{
	init();
	solve();
}

vector<ll> x(4);
int N;

void init()
{
	rep(i, 4) cin >> x[i];
	cin >> N;
}

/*
0 0.25
1 0.5
2 1
3 2
*/

void solve()
{
	x[1] = min(x[1], x[0] * 2);
	x[2] = min(x[2], x[1] * 2);
	x[3] = min(x[3], x[2] * 2);
	if (N % 2 == 0) {
		cout << x[3] * (N / 2) << endl;
	} else {
		cout << x[3] * (N / 2)  + x[2] << endl;
	}
}



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

int main(){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if(s<t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 1;
  for(int i = 1; i < n; ++i) {
    if(s[i] != s[i-1]) ++ans;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define gt(n) scanf("%d", &n)
#define gtll(n) scanf("%ld", &n)
#define out(n) printf("%d", n)
#define outll(n) printf("%ld", n)
#define loop(n) for(int i=0; i<n; i++)
#define MAXX 1001
#define mem(x, y) memset(x, y, sizeof(x))
#define loop1(n) for(int i=1; i<=n; i++)
#define ll long long
#define pb push_back
#define pi acos(-1)
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//(only in c)char[33];itoa(n,buffer,base);printf("%s",buffer);
#define dec_to_bin(n) std::string binary = std::bitset<64>(n).to_string();
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    fast;
    int n;
    cin>>n;
    int a[n+7];
    int c=0;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]!=i+1)c++;
    }
    if(c>2)
    {
        cout<<"NO"<<endl;
        return 0;
    }
    cout<<"YES"<<endl;
    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;
using namespace __gnu_pbds;

namespace std {
	#define u(x, a, b) for(ll x = a; x < b; x++)
	#define d(x, a, b) for(ll x = a; x > b; x--)
}

typedef long long ll;
typedef long double ld;

#define MAXI 100010
#define MOD 1000000007

int main(){
	ll n, k; 
	cin >> n >> k;
	
	ll a[n];
	ll tot = 0;
	u(one, 0, n){cin >> a[one];}
	sort(a, a+n);

	u(one, 0, k){tot += a[one];}
	
	cout << tot;
}


Measured memory_bytes: 3644
(let* ((n (read))
       (lst (loop :repeat n :collect (read)))
       (mem (cons (reduce #'+ (cdr lst)) (car lst))))
  (if (= n 2)
      (princ (abs (- (cdr mem) (car mem))))
      (princ (loop :for k :in (subseq lst 1 (1- n)) :minimize (abs (- (setf (car mem) (- (car mem) k))
                                                                  (setf (cdr mem) (+ (cdr mem) k))))))))

Measured memory_bytes: 61792
function Main(input) {
    input = input.split("\n");
    var ans = Number(input[0].split(' ')[0]) <= 8 && Number(input[0].split(' ')[1]) <= 8 ? 'Yay!' : ':('  
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Beginner092
{
    public class ABC092C
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int[] a = ("0 " + Console.ReadLine() + " 0").Split(' ').Select(int.Parse).ToArray();
            
            long total = 0;

            for(int i = 0; i <= n; i++)
            {
                total += Math.Abs(a[i] - a[i+1]);
            }
            
            for(int i = 1; i <= n; i++)
            {
                int diff1 = Math.Abs(a[i - 1] - a[i]) + Math.Abs(a[i] - a[i + 1]);
                int diff2 = Math.Abs(a[i - 1] - a[i + 1]);
                Console.WriteLine(total - diff1 + diff2);
            }
            
        }
    }
}

Measured memory_bytes: 27100
import sys
input = sys.stdin.readline
n = int(input())
sum = 0
for i in range(n):
    x,u = input().split()
    if u == "JPY":
        x = int(x)
        sum += x
    else:
        x = float(x)
        x = x * 380000
        sum += x
print(sum)

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9
ll gcd(ll a, ll b){
  if(a < b){
    swap(a, b);
  }
  if(b == 0){
    return a;
  }
  return gcd(b, a % b);
}

ll lcm(ll a, ll b){
  return a * b / gcd(a, b);
}
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> a(N);
  REP(i, N){
    cin >> a[i];
    a[i] /= 2;
  }
  int cnt = 0;
  int b = a[0];
  while(b && b % 2 ==0){
    b /= 2;
    cnt++;
  }
  REP(i, N){
    b = a[i];
    int c = 0;
    while(b && b % 2 == 0){
      b /= 2;
      c++;
    }
    if(cnt != c){
      cout << 0 << endl;
      return 0;
    }
  }


  ll l = a[0];
  REP(i, N){
    l = lcm(l, a[i]);
    if(l > M){
      cout << 0 << endl;
      return 0;
    }
  }
  cout << (M / l) / 2 + (M/l) % 2 << endl;;
  return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    String s = sc.next();
    String t = sc.next();
    Set<String> checked = new HashSet<>();
    while (!checked.contains(s)) {
      if (s.equals(t)) {
        System.out.println("Yes");
        return;
      }
      checked.add(s);
      s = s.charAt(s.length() - 1) + s.substring(0, s.length() - 1);
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 37140
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;

int main() {
  int n,m;
  cin>>n>>m;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  
  int sum=0;
  for(int i=0;i<n;i++){
    sum+=a[i];
  }
  int cnt=0;
  for(int i=0;i<n;i++){
    if(4*m*a[i]>=sum){
      cnt++;  
    } 
  }
  if(cnt>=m){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256