akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{

#if !ONLINE_JUDGE

	freopen("in1.txt", "r", stdin);
	freopen("out1.txt", "w" , stdout);

#endif

	int k, s;
	cin >> k >> s;

	int ct = 0;
	for (int i = 0; i <= k; i++)
	{
		for (int j = 0; j <= k ; ++j)
		{

			int z = s - i - j;
			if (z <= k and z >= 0)
			{
				ct++;
			}
		}

	}
	cout << ct << endl;





	return 0;
}

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

namespace arc076_a
{
    class Program
    {
        public static long  p = 1000000007;
        static void Main(string[] args)
        {
            var NM = GetIntList();

            if (Math.Abs(NM[0] - NM[1]) >= 2) 
                Console.WriteLine(0);
            else if(NM[0] == NM[1]) 
                Console.WriteLine((k(NM[0]) * k(NM[1]) * 2) % p);
            else 
                Console.WriteLine((k(NM[0]) * k(NM[1])) % p);
        }

        public static long k(long a)
        {
            long r = 1;
            for(int i = 2;i <= a; i++)
            {
                r = (r * i) % p;
            }
            return r;
        }

        public static string GetStr() => Console.ReadLine();
        public static int GetInt() => int.Parse(Console.ReadLine());
        public static long GetLong() => long.Parse(Console.ReadLine());
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static decimal GetDecimal() => decimal.Parse(Console.ReadLine());

        public static List<string> GetStrList() => Console.ReadLine().Split(' ').ToList();
        public static List<int> GetIntList() => Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        public static List<long> GetLongList() => Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
        public static List<double> GetDoubleList() => Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToList();
        public static List<decimal> GetDecimalList() => Console.ReadLine().Split(' ').Select(x => decimal.Parse(x)).ToList();


    }
}


Measured memory_bytes: 13268
#一個だけRE、わからねえ
#解答見る
import sys
sys.setrecursionlimit(1005)
h,w=map(int,input().split())

def go_next(I,J,n):
    n+=1
    global dp,w,h
    if n>1000:
        return
    if 0<=I<h-1:
        if x[I+1][J]=="." and dp[I+1][J]>dp[I][J]+1:
            dp[I+1][J]=dp[I][J]+1
            go_next(I+1,J,n)
    if 0<I<=h-1:
        if x[I-1][J]=="." and dp[I-1][J]>dp[I][J]+1:
            dp[I-1][J]=dp[I][J]+1
            go_next(I-1,J,n)
    if 0<=J<w-1:
        if x[I][J+1]=="." and dp[I][J+1]>dp[I][J]+1:
            dp[I][J+1]=dp[I][J]+1
            go_next(I,J+1,n)
    if 0<J<=w-1:
        if x[I][J-1]=="." and dp[I][J-1]>dp[I][J]+1:
            dp[I][J-1]=dp[I][J]+1
            go_next(I,J-1,n)

x=[]
for i in range(h):
    x.append(list(input()))
#print(x)
c=0
for i in range(h):
    for j in range(w):
        if x[i][j]==".":
            c+=1
dp=[[10000000000 for i in range(w)]for j in range(h)]
dp[0][0]=1
go_next(0,0,0)
if dp[h-1][w-1]==10000000000:
    print(-1)
else:
    print(c-dp[h-1][w-1])


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

int N, A[100002];

int main(){
    cin >> N;
    int base = 0;
    for(int i = 1; i <= N; i++){
        cin >> A[i];
    }
    for(int i = 1; i <= N + 1; i++){
        base += abs(A[i] - A[i-1]);
    }
    for(int i = 1; i <= N; i++){
        cout << base - abs(A[i] - A[i-1]) - abs(A[i+1] - A[i]) + abs(A[i+1] - A[i-1])<< endl;
    }
}



Measured memory_bytes: 1664
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    if A[0] != 0:
        print(-1)
        return

    for i in range(N - 1):
        if A[i] + 1 < A[i + 1]:
            print(-1)
            return

    ans = 0
    i = N - 1
    while i > 0:
        M = A[i]
        ans += M
        while A[i] > A[i - 1] and i - 1 >= 0:
            i -= 1
        i -= 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 11064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	dump(max(a * b, c * d));
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    string n; cin>>n;
    int p=0;
    rep(i,3){
        if(n[i]-'0'==7) p=1;
    }
    cout<<(p==1 ? "Yes" : "No")<<endl;
}

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

bool check(long long int n, long long int k)
{
    if (n == 1)
        return true;
    if ((n - 1) % k == 0)
        return true;
    if (n % k != 0)
        return false;
    return check(n / k, k);
}
int main()
{
    long long int n, ans = 1;
    cin >> n;
    set<long long int> st;
    st.insert(n);
    n--;
    for (long long int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            if (i != 1)
                st.insert(i);
            if (n / i != i)
                st.insert(n / i);
        }
    }
    n++;
    for (long long int i = 1; i * i <= n; i++)
    {
        if (check(n,i)&&i!=1)
        {
            // cout<<i<<" ";
            st.insert(i);
        }
    }
    // for (auto it : st)
    //     cout << it << " ";
    cout << st.size();
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c,d;
	while(~scanf("%d%d%d%d",&a,&b,&c,&d))
	{
		if((a<c&&b<d)||(c<a&&d<b))
		{
			for(int i = 0; i < abs(d-b); i++)
			printf("U");
			for(int i = 0; i < abs(c-a); i++)
			printf("R");
			for(int i = 0; i < abs(d-b); i++)
			printf("D");
			for(int i = 0; i < abs(c+1-a); i++)
			printf("L");
			for(int i = 0; i < abs(d+1-b); i++)
			printf("U");
			for(int i = 0; i < abs(c+1-a); i++)
			printf("R");
			printf("DR");
			for(int i = 0; i < abs(d+1-b); i++)
			printf("D");
			for(int i = 0; i < abs(c+1-a); i++)
			printf("L");
			printf("U\n");
		}
		else
		{
			for(int i = 0; i < abs(d-b); i++)
			printf("U");
			for(int i = 0; i < abs(c-a); i++)
			printf("L");
			for(int i = 0; i < abs(d-b); i++)
			printf("D");
			for(int i = 0; i < abs(c+1-a); i++)
			printf("R");
			for(int i = 0; i < abs(d+1-b); i++)
			printf("U");
			printf("DL");
			for(int i = 0; i < abs(c+1-a); i++)
			printf("D");
			for(int i = 0; i < abs(d+1-b); i++)
			printf("R");
			printf("U\n");
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=4010,P=924844033;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
ll ans,s;
int n,m,i,j,k,a[N],f[N];
int main(){
	//freopen("1.out","w",stdout);
	n=read();m=read();
	for(i=1;i<=n;i++)ans+=a[i]=f[i]=read();
	for(i=1;i<=n;i++){
		s=1ll*i*m;
		for(j=1;j<=n;j++){
			k=j-i;if(k<1)k+=n;
			s+=f[j]=min(f[j],a[k]);
		}
		ans=min(ans,s);
	}write(ans);puts("");
	return 0;
}

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

int main()
{
	int month[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	int m,day,sumday;
    while(1){
		cin >> m; // 月
		if (m==0){ break;}
		cin >> day;  //日付
		for(int i=0;i<m;i++){
			day+=month[i];
		}
		switch(day%=7){
			case 1:
				cout<<"Thursday"<<endl;
				break;
			case 2:
				cout<<"Friday"<<endl;
				break;
			case 3:
				cout<<"Saturday"<<endl;
				break;
			case 4:
				cout<<"Sunday"<<endl;
				break;
			case 5:
				cout<<"Monday"<<endl;
				break;
			case 6:
				cout<<"Tuesday"<<endl;
				break;
			default:
				cout<<"Wednesday"<<endl;
				break;
		}
		
	}
	return 0;
}

Measured memory_bytes: 1156
# X = int(input())

# ans = 0
# n = X // 500
# X -= n * 500
# ans = n * 1000
# ans += (X // 5) * 5

# print(ans)

S = input()

if S[2] == S[3] and S[4] == S[5]:
    print('Yes')
else:
    print('No')


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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int h,w,n;
string o[35];

string t[35];
bool d[35][35];

bool proceed(){
	bool update=true;
	while(update){
		update=false;
		for(int i=h-2;i>=0;--i)rep(j,w){
			if(t[i][j]=='.')
				continue;
			int ni;
			for(ni=h-1;ni>i;--ni)
				if(t[ni][j]=='.')
					break;
			if(ni!=i) swap(t[i][j],t[ni][j]);
		}
		rep(i,35)rep(j,35) d[i][j]=false;
		rep(i,h)rep(j,w){
			if(t[i][j]=='.')
				continue;
			char cur=t[i][j];
			if(i+n-1<h){
				bool ok=true;
				rep(e,n) if(cur!=t[i+e][j]) ok=false;
				if(ok){
					update=true;
					rep(e,n) d[i+e][j]=true;
				}
			}
			if(j+n-1<w){
				bool ok=true;
				rep(e,n) if(cur!=t[i][j+e]) ok=false;
				if(ok){
					update=true;
					rep(e,n) d[i][j+e]=true;
				}
			}
		}
		rep(i,h)rep(j,w)if(d[i][j]) t[i][j]='.';
	}
	bool ok=true;
	rep(i,h)rep(j,w) if(t[i][j]!='.') ok=false;
	return ok;
}

int main(void){
	cin >> h >> w >> n;
	rep(i,h) cin >> o[i];
	bool ans=false;
	rep(i,h)rep(j,w){
		if(o[i][j]=='.')
			continue;
		rep(a,h) t[a]=o[a];
		if(j+1<w){
			swap(t[i][j],t[i][j+1]);
			ans|=proceed();
		}
	}
	if(ans)
		puts("YES");
	else
		puts("NO");
	return 0;
}

Measured memory_bytes: 1188
#coding: utf-8

n = raw_input()
a = []
for i in range(int(n)):
    l = map(int,raw_input().split())
    a.append(l)

for l in a:
    l = [x * x for x in l]
    l.sort()
    if l[0] + l[1] == l[2]:
        print 'YES'
    else:
        print 'NO'

Measured memory_bytes: 6312
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    map<int, int>mp;
    for(int i=0; i<3; i++){
        cin>>a;
        mp[a]++;
    }
    if(mp[5]==2 && mp[7]==1){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}


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

ll abs(ll a, ll b){
  ll c;
  c=a-b;
  if(c<0)
    return -c;
  else
    return c;
}

int main() {
  ll N,K;
  cin>>N>>K;
  
  ll s=N%K;
  ll t=abs(s,K);
  
  ll ans=min(s,t);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = 0;
        sc.close();

        ans = Math.max(a + b, a - b);
        ans = Math.max(ans, a * b);

        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        long[] array = new long[87];
        array[0] = 2;
        array[1] = 1;
        for (int i = 2; i < array.length; i++) {
            array[i] = array[i - 1] + array[i - 2];
        }
        long result = array[n];

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 23892
#include <queue>
#include <cstdio>
#include <vector>
using namespace std;
struct edge { int to; long long cost; };
bool operator<(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}
int N, M, C, a, b, c; bool vis[100009]; long long d[100009]; vector<edge> G[100009];
int main() {
	scanf("%d%d%d", &N, &M, &C);
	long long sum = 0;
	for (int i = 0; i < M; i++) {
		scanf("%d%d%d", &a, &b, &c); a--, b--;
		G[a].push_back(edge{ b, c });
		G[b].push_back(edge{ a, c });
		sum += c;
	}
	long long ret = sum;
	fill(d + 1, d + N, 1LL << 60);
	priority_queue<edge> que; que.push({ 0, 0 });
	while (!que.empty()) {
		edge u = que.top(); que.pop();
		if (!vis[u.to]) {
			vis[u.to] = true;
			for (edge e : G[u.to]) {
				if (vis[e.to]) sum -= e.cost;
			}
			ret = min(ret, C * d[u.to] + sum);
		}
		for (edge e : G[u.to]) {
			if (d[e.to] > d[u.to] + e.cost) {
				d[e.to] = d[u.to] + e.cost;
				que.push(edge{ e.to, -d[e.to] });
			}
		}
	}
	printf("%lld\n", ret);
	return 0;
}

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

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

// ========================================================================= //

const int N = 2002;

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

    static bitset<N*N> bb;
    bb.set(0);
    int n;
    cin >> n;
    int s = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        s += a;
        bb |= bb << a;
    }

    for (int i = (s + 1) / 2; true; ++i)
        if (bb[i]) {
            std::cout << i << "\n";
            return 0;
        }
    assert(0);

    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>

#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
	int N;
	std::vector<int> W;

	scanf("%d", &N);

	for( int i = 0; i < N; i++)
	{
		int w;
		scanf("%d", &w);
		W.push_back(w);
	}

	int abs_last = 99999999;
	for( int i = 1; i < N; i++)
	{
		int s1 = 0;
		int s2 = 0;

		for( int n = 0; n < i; n++)
		{
			s1 += W[n];
		}

		for( int n = i; n < N; n++)
		{
			s2 += W[n];
		}

		if( abs_last < abs(s1 - s2) )
		{
			break;
		}

		abs_last = abs(s1 - s2);
	}

	printf("%d\n", abs_last);

	return 0;
}




Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int a=0,i,kisu=0,count=0;
  scanf("%d", &a);
  long N[a];
  for (i=0;i<a;i++)scanf("%ld", &N[i]);
  
  while(kisu == 0){
    for (i=0;i<a;i++){
      if(N[i]%2 ==0){
        N[i]=N[i]/2;
      }
      else kisu=1;
    }
    count++;
  }
  printf("%d",count-1);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  string s;
  cin >> s;
  for (size_t i=1; i<s.size(); ++i) {
    if (s.substr(i-1, 2)=="AC") {cout << "Yes" << endl; return 0;}
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = (int) 1e6 + 10;
const int MOD = (int) 1e9 + 7;

int n, m;
int dp[MAXN];

int main(){
	scanf("%d%d", &n, &m);
	int f = (1 << n) - 1;
	for (int i=1; i<=f; i++)
	    dp[i] = 1e9;
	for (int i=1; i<=m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		int now = 0;
		for (int j=1; j<=b; j++) {
			int c;
			scanf("%d", &c);
			now |= (1 << (c-1));
		}
		for (int i=0; i<=f; i++)
		    if (dp[i] != 1e9) dp[i|now] = min(dp[i|now], dp[i] + a);
	}
	if (dp[f] == 1e9) puts("-1");
	else printf("%d\n", dp[f]);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
int a[100005];
int main ()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int ai;
        scanf("%d",&ai);
        a[ai]=i;
    }
    for(int i=1;i<=n;i++)
    {
        printf("%d ",a[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 4076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;





int main() {
    int x,y; cin >> x >> y;
    int a=x,b=0;
    string ans = "No";
    for(int i = 0;i < x+1;i++){
        if(a * 2 + b * 4 == y) {
            ans = "Yes";
            break;
        }
        a--;b++;
    }
    cout << ans;
}


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

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

    map<string, int> mp;

    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
  
  long long ans = 0;
  
    for(auto p : mp){
        long long k = p.second;
        ans += k * (k - 1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 11136
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=100+10;
int n,cnt;
int main(){
	//freopen("a.in","r",stdin);
	cin>>n;
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)if(i+j!=(!(n&1))+n) cnt++;
	cout<<cnt<<endl;
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)if(i+j!=(!(n&1))+n) printf("%d %d\n",i,j);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int k,n=0;
  cin >> k;
  r(i,s.length()){
    if(s[i]!='1'){
      n = i;
      break;
    }
  }
  if((k-1)<n) cout << 1 << endl;
  else cout << s[n] << endl;
}


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

using namespace std;

#define fast_io ios_base::sync_with_stdio(0); cin.tie(0);
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define pb push_back
#define in insert
#define sz(x) (int) x.size()
#define sqr(x) ((x) * (x))
#define fi first
#define se second
#define y1 ksjdkf

template<typename T>
void vout(T x) {
    cout << x << endl;
    exit(0);
}

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;

const int inf = 1e9 + 1;
const ll INF = 1e18 + 1e2;
const int mod = 1e9 + 7;

string convert_to_26(ll num) {
    string result = "";
    while (num) {
        ll last_digit = num % 26;
        if(last_digit == 0) {
            result += 'z';
            num = num / 26 - 1;
        } else {
            result += last_digit - 1 + 'a';
            num /= 26;
        }
    }
    reverse(all(result));
    return result;
}

void solve() {
    ll n; cin >> n;
    cout << convert_to_26(n);
}

int main() {
    fast_io

    int q = 1;
//    cin >> q;
    while(q--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3588
import sys
 
sys.setrecursionlimit(100000)
 
N, M = map(int, input().split(" "))
G = [[] for _ in range(N)]
 
for _ in range(M):
    x, y = map(int, input().split(" "))
    G[x-1].append(y-1)
dp = [-1] * N
def pathlen(G, dp, v):
    if dp[v] != -1:
        return dp[v]
 
    plen = 0
    for i in G[v]:
        plen = max(plen, pathlen(G, dp, i)+1)
    dp[v] = plen
    return plen
ans = 0
for i in range(N):
    ans = max(ans, pathlen(G, dp, i))
print(ans)

Measured memory_bytes: 59056
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
ll n,a,b,c,d;
cin >> n >> a >> b;
c=n%(a+b);
d=n/(a+b);
if(a>=c){
  cout << d*a+c << endl;
}else{
  cout << d*a+a << endl;
}
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("O1")
#pragma GCC optimize("O2")
#pragma GCC optimize("Os")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000000
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<pair<int,int>,int> &a, const pair<pair<int,int>,int> &b)
{
    return (a.first.second<b.first.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
void vok()
{
    FAST
    FO
    FI
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif
}
int main()
{
    vok();
    ld r;
    IN r;
    ld pi= asin(1.0);
    pi*=2.0;
    ld ans= 2.0*pi*r;
    OUT fixed<<setprecision(9);
    OUT ans<<endl
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  string s; cin >> s;

  if (s.back() == 's') {
    s += "es";
  } else {
    s += "s";
  }
  cout << s << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 3640
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

#define N 200000
#define M 998244353
#define TEST 0

int xo[N], yo[N], x[N], y[N];
int n = gi();
int t[530000];
ll p[N+1];

int fxo(int a, int b) {
    return (x[a] < x[b]);
}

int fyo(int a, int b) {
    return (y[a] < y[b]);
}

int bs(int xx) {
    int l = 0, r = n-1;
    while (1) {
        int m = (l+r)/2;
        if (x[xo[m]] == xx)
            return m;
        if (x[xo[m]] < xx)
            l = m+1;
        else
            r = m-1;
    }

    return 0;
}

void insrt(int xx, int w = 0, int l = 0, int r = n-1) {
#if TEST
    printf("INSERT called. xx = %d, x[%d] = %d, x[%d] = %d\n", xx, l, x[l], r, x[r]);
#endif
    if (xx < x[xo[l]] || xx > x[xo[r]])
        return;
    t[w]++;
    if (l < r) {
        int m = (l+r)/2;
        insrt(xx, w*2+1, l, m);
        insrt(xx, w*2+2, m+1, r);
    }
}

int fndt(int xx, int w = 0, int l = 0, int r = n-1) {
    if (xx <= x[xo[l]])
        return 0;
    if (x[xo[r]] <= xx)
        return t[w];
    int m = (l+r)/2;
    int f1 = fndt(xx, w*2+1, l, m);
    int f2 = fndt(xx, w*2+2, m+1, r);
    return f1+f2;
}

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

    p[0] = 1;
    for (int i = 0; i < n; i++) {
        x[i] = gi();
        y[i] = gi();
        xo[i] = i;
        yo[i] = i;
        p[i+1] = (p[i]*2)%M;
    }

    sort(xo, xo+n, fxo);
    sort(yo, yo+n, fyo);

#if TEST
    int mnx = x[xo[0]];
    int mny = y[yo[0]];
    printf("MIN is (%d, %d)\n", mnx, mny);
    for (int i = 0; i < n; i++) {
        int xx = x[yo[i]];
        for (int j = mnx; j < x[yo[i]]; j++)
            printf(" ");
        printf("O\n");
    }
#endif

    memset(t, 0, sizeof(t));

    ll res = 0;
    for (int i = 0; i < n; i++) {
        int w = yo[i];
        int T = i;
        int B = n-1-T;
        int L = bs(x[w]);
        int R = n-1-L;

        int TL = fndt(x[w]);
        int TR = T - TL;
        int BL = L - TL;
        int BR = B-BL;

        ll vl = p[n]-1 - (p[L] + p[R] + p[B] + p[T] - p[TL] - p[TR] - p[BR] - p[BL]);

#if TEST
        printf("L %d R %d T %d B %d TL %d TR %d BL %d BR %d\n", L, R, T, B, TL, TR, BL, BR);
        cout << vl << endl;
#endif

        res += vl;
        res %= M;

        insrt(x[w]);
    }

    cout << (res+M)%M << endl;

    return 0;
}


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

using namespace std;

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

#define int ll

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

	int t = c/b;
	if(c%b>0) t++;
	int u = a/d;
	if(a%d>0) u++;

	if(t<=u){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	

	return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main(){
    int i,a,b,c,n;
    
    scanf("%d",&n);
    
    for(i=1;i<=n;i++)
    {
        a=i%10;
        b=i%100;
        c=i%1000;
        
        if(i%3==0)
        printf(" %d",i);
        else if(a==3)
        printf(" %d",i);
        else if(30<=b&&b<=39)
        printf(" %d",i);
        else if(300<=c&&c<=399)
        printf(" %d",i);
        else if(i/1000==3)
        printf(" %d",i);
    
    }
    printf("\n");
    
    return(0);
}


Measured memory_bytes: 2056
N = int(input())
d = {0:0,1:0,2:0}
for a in list(map(int,input().split())):
  if a%2 == 0 :
    if a%4 == 0 :
      d[2]+=1
    else:
      d[1]+=1
  else:
    d[0]+=1

## 0と4だけの時はこれでok
if d[1] == 0:
  if d[0] <= d[2]+1:
    print("Yes")
  else:
    print("No")
else:
  if d[0] + (1 if d[1]>0 else 0 ) <= d[2]+1:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 14252
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	int num, len;
	scanf("%d%d", &num, &len);
	vector<string>v;
	for (int i = 0; i < num; i++)
	{
		string s;
		cin >> s;
		v.push_back(s);
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < num; i++)cout << v[i];
	cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if (a >= b && a >= c){
         printf("%d\n", b + c);
         goto fun1;
    }

    if (b >= a && b >= c){
       printf("%d\n", a + c);
       goto fun1;
    }

    if (c >= a && c >= b){
        printf("%d\n", a + b);
        goto fun1;
    }

    fun1:
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
signed main(){
    long long x , ans;
    cin>>x;
    ans=(x/11)*2;
    x=x%11;
    if(x>0){
        ans++;
        x-=6;
    } 
    if(x>0){
        ans++;
        x-=5;
    }
    cout<<ans<<endl;
    return(0);
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (a, b, c) = read!(i32, i32, i32);
    let after_a = min(a, b + c);
    let b_to_a = after_a - b;
    println!("{}", c - b_to_a);
}


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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	char c;
	cin >> c;
	if(c <= 'z' && 'a' <= c) cout << 'a';
	else cout << 'A';
}


Measured memory_bytes: 3600
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#define ll long long
#define mod 998244353
#define Mod1(x) (x>=mod?x-mod:x)
#define Mod2(x) (x<0?x+mod:x)
#define maxn 3000010
inline ll read()
{
    ll x=0; char c=getchar(),f=1;
    for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
    for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
    return x*f;
}
inline void write(ll x)
{
    static int buf[20],len; len=0;
    if(x<0)x=-x,putchar('-');
    for(;x;x/=10)buf[len++]=x%10;
    if(!len)putchar('0');
    else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
ll fac[maxn],inv[maxn];
int n,m;
inline ll power(ll a,ll b)
{
    ll ans=1;
    for(;b;b>>=1,a=a*a%mod)
        if(b&1)ans=ans*a%mod;
    return ans;
}
inline ll C(int n,int m){return fac[n]*inv[m]%mod*inv[n-m]%mod;}
inline ll calc(int n,int m,int k)
{
    ll sum=0;
    for(int i=0;i<=n&&i<=k;i++)
        if(!((m-i)&1)&&m>=i)sum=(sum+C(n,i)*C((m-i)/2+n-1,n-1))%mod;
    // writeln(sum);
    return sum;
}
int main()
{
    n=read(); m=read();
    fac[0]=inv[0]=1;
    for(int i=1;i<=n+3*m;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=power(fac[i],mod-2);
    }
    ll ans=(calc(n,3*m,m)-n*(calc(n,m,m)-calc(n-1,m,m)+mod))%mod;
    writeln(Mod2(ans));
    return 0;
}


Measured memory_bytes: 41216
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = replicateM 6 readLn >>= print . solve

solve :: [Int] -> Int
solve (n : a : rs) = r + c + 4
    where
        x = min a $ minimum rs
        c 
            | m > 0 = 1
            | otherwise = 0
        (r, m) = n `divMod` x 


readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

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

int main(){
  int A, B;
  cin >> A >> B;

  if(A==B) cout << "Draw" << endl;
  else if(A>B){
    if(B==1){
      cout << "Bob" << endl;
    }else {
      cout << "Alice" << endl;
    }
  }else{
    if(A==1){
      cout << "Alice" << endl;
    }else{
      cout << "Bob" << endl;
    }
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

int main() {
    ll A, B, K;
    cin >> A >> B >> K;

    for (ll i = 1; i <= K; i++) {
        if (i % 2 == 1) {
            if (A == 0) break;

            if (A % 2 == 1) {
                A -= 1;
            }
            B += A / 2;
            A /= 2;
        } else {
            if (B == 0) break;
            if (B % 2 == 1) {
                B -= 1;
            }
            A += B / 2;
            B /= 2;
        }
    }
    cout << A << " " << B << endl;

    return 0;
}

Measured memory_bytes: 256
N=int(input())
D,M,C=map(ord,'DMC')
import numpy as np
S=np.array([ord(c) for c in input()])
input()
K=map(int,input().split())
iD=S==D
iM=S==M
iC=S==C
cD=np.cumsum(iD,dtype=np.int64)
cM=np.cumsum(iM,dtype=np.int64)
for k in K:
    cD2=cD-np.concatenate((np.zeros(k,dtype=np.int64),cD[:-k]))
    cM2=cM-np.concatenate((np.zeros(k,dtype=np.int64),cM[:-k]))
    DM=np.cumsum(cD2*iM-np.concatenate((np.zeros(k,dtype=np.int64),cM2[k-1:-1]*iD[:-k])))
    print(np.sum(iC*DM))

Measured memory_bytes: 103400
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

ll min4(ll a, ll b, ll c, ll d){
  return min(a, min(b, min(c, d)));
}

int main()
{
  ll q,h,s,d,n;
  cin >> q >> h >> s >> d >> n;
  ll cost = 0;
  ll l2_cost = min4(q*8, h*4, s*2, d);
  ll l1_cost = min4(q*4, h*2, s, 1e10);
  cost += (n/2) * l2_cost;
  if(n>=2) n %= 2;
  cost += n * l1_cost;
  cout << cost << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::cmp;
use std::num::Wrapping; // overflowを回避
use std::f64::consts;


fn main() {
    let n: u32 = read();
    let k: u32 = read();
    let mut vec: Vec<i32> = (0..n).map(|_| read()).collect();
    vec.sort();

    let mut ans = 1000000000;

    let mut start: u32 = 0;
    while (start+k-1 < n) {
        let startIndex = start as usize;
        let endIndex = (start + k-1) as usize;
        ans = cmp::min(ans, vec[endIndex] - vec[startIndex]);
        start += 1;
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

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

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                    // intのvector
typedef vector<double> vd;                 // doubleのvector
typedef vector<ll> vll;                    // llのvector
typedef vector<ld> vld;                    // ldのvector
typedef vector<pair<int, int>> vi_i;       // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<pair<ll, ll>> vl_l;         // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;       // ld_ldのvector
typedef vector<string> vs;                 // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

/* main */
void Main(void)
{
    int a, b;
    cin >> a >> b;
    if (a < b)
    {
        cout << "a < b" << endl;
    }
    else if (a > b)
    {
        cout << "a > b" << endl;
    }
    else
    {
        cout << "a == b" << endl;
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();

    return 0;
}



Measured memory_bytes: 3124
n,k=map(int,input().split())
ans=0
mod=10**9+7
l=[i for i in range(n+1)]
mi=sum(l[:k])
ma=sum(l[n+1-k:])
ans=(ans+ma-mi+1)%mod
for i in range(k+1,n+2):
    mi+=l[i-1]
    ma+=l[-i]
    ans=(ans+ma-mi+1)%mod
print(ans)

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  int ans = 0;
  bool div_by_2 = true;
  while(div_by_2){
    for(int i=0; i<N; i++){
      if(A[i] % 2 == 1){
        div_by_2 = false;
        break;
      }else{
        A[i] /= 2;
      }
    }
    //すべて２で割りきれる
    if(div_by_2){
      ans++;
      }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
#define all(x) (x).begin() , (x).end()
#define endl '\n'
using namespace std;



void solve(){
    int n;
    cin >> n;

    vector<int>arr(n);
    for(int i=0;i<n;i++)cin >> arr[i];


    int dp[n+2];
    memset(dp , -1 , sizeof(dp));

    dp[0] = 0;
    dp[1] = abs(arr[0] - arr[1]);

    for(int i=2;i<n;i++){
        dp[i] = min(dp[i-1] + abs(arr[i-1] - arr[i]) , dp[i-2]  + abs(arr[i-2] - arr[i]) ); 
    }

    cout << dp[n-1] << endl;

    return;
}



int main(){
    int test;
    test = 1;
    while(test--){
        solve();
    }
    return 0;
}






Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define base 31
#define MOD 1e9+7
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORs(i, a, b) for(int i = a; i >= b; i--)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define __FOR(i, a, b, k) for(int i = a; i <= b; i+= k)
#define __REP(i, a, b, k) for(int i = a; i < b; i+= k)
#define pb push_back
#define _io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef pair <int, int> ii;
typedef vector <ii> vii;
#define fi first
#define se second
#define mp make_pair
#define N  1000000
int n,a[N],b[N],c[N],res,d;
void nhap(){
	cin>>n;
	FOR(i,1,n-1) cin>>b[i];
	a[1]=b[1]; a[n]=b[n-1];
}
int main(){

	_io;
	nhap();
	res=0;
	FOR(i,1,n-2) a[i+1]=min(b[i],b[i+1]);
	FOR(i,1,n) res+=a[i]; cout<<res;
}




Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
  ll k,a,b,ans=0;
  cin>>k>>a>>b;

  if(a+2>=b) ans=k+1;
  else{
    k-=(a-1);
    ll tmp=k/2;
    ans=(tmp*(b-a)+(k%2)+a);
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
using namespace std;
typedef long long ll;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#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 bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX_N 200100
#define MAX_B 1001001//6
#define MAX_S 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1<<30
#define INFTY 1000000000000000001LL
#define MAX_INT INT_MAX
#define Endl '\n'
#define mian() main()
#define greater greater<int>()
VI findAll(string S,string pattern){VI P;ll pos=(ll)S.find(pattern);
while(pos!=string::npos){P.push_back(pos);pos=(ll)S.find(pattern,pos+1);}return P;}
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);}
bool is_prime(ll n){if(n<2)return 0;for(int i=2;i*i<n;i++)if(n%i==0)return 0;return 1;}
inline void eratosthenes(VB& p){rep(i,SZ(p))p[i]=1;p[0]=p[1]=0;
rep(i,SZ(p)/2+1){if(p[i])for(ll j=i+i;j<SZ(p);j+=i)p[j]=0;}}
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));}

using Graph=vector<vector<P> >;

int main(){
    ll a,b,n;cin>>a>>b>>n;
    //(xをBで割った余り*A)/Bの最大値
    //(B-1)*A/B
    if(n>=b-1)cout<<(b-1)*a/b<<endl;
    else cout<<n*a/b<<endl;
}

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

int main()
{
    int x, y, z;
    long ans;
    // scanf("%d", &x);
    cin >> x >> y >> z;
    // printf("%d\n", x * x * x);
    x, y = y, x;
    x, z = z, x;
    cout << z << " " << x << " " << y << endl;
}

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

using namespace std;

int G[100][100];
int D[100];
void init() {
	for (int i = 0; i < 100; i++) {
		for(int j = 0; j < 100; j++)
			G[i][j] = 0;
		D[i] = -1;
	}	
}

void bfs(int src);

int main() {
	init();
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			int v_j;
			cin >> v_j;
			G[u - 1][v_j - 1] = 1;
		}
	}
	bfs(0);
	for (int i = 0; i < n; i++)
		cout << i + 1 << " " << D[i] << endl;
}

void bfs(int src) {
	D[src] = 0;
	queue<int> Q;
	Q.push(src);
	while (!Q.empty()) {
		int cur = Q.front();
		Q.pop();
		for (int dst = 0; dst < 100; dst++)
			if (G[cur][dst] == 1 && D[dst] == -1){
				D[dst] = D[cur] + 1;
				Q.push(dst);
			}
	}
}

Measured memory_bytes: 1244