akhauriyash/Code-Regression huggingface dataset:
//ALDS1_3A

#include <iostream>
#include <cstdlib>
#include <stack>
using namespace std;

int main(){
 stack<int> S;
 int a,b,x;
 string s;

 while(cin>>s){
  if(s[0]=='+'){
   a=S.top();S.pop();
   b=S.top();S.pop();
   S.push(a+b);
  }else if(s[0]=='-'){
    b=S.top();S.pop();
    a=S.top();S.pop();
    S.push(a-b);
  }else if(s[0]=='*'){
    a=S.top();S.pop();
    b=S.top();S.pop();
    S.push(a*b);
  }else{
    S.push(atoi(s.c_str()));
  }
 }
 cout<<S.top()<<endl;
 return 0;
}

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

public class Hello
{
    public static void Main()
    {
        Calc calc = new Calc();
        List<double> ans = new List<double>();

        string str;
        while (!((str = Console.ReadLine()) == null))
        {
            int d = int.Parse(str);
            ans.Add(calc.Integral(d));
        }

        foreach(double item in ans)
        {
            Console.WriteLine(item);
        }
    }

}
class Calc
{
    internal double Integral(int d)
    {
        int x = 600;
        double s = 0;

        for (int i = 0; i < x / d ; i++)
        {
            s += (double) d * Math.Pow(i * d, 2);
        }

        return s;
    }

}


Measured memory_bytes: 15952
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try {
	    String[] st;
	    while(true){
		int n = Integer.valueOf(sc.readLine());
		if(n==0)
		    break;
		int max=0, min=500, now;
		for(int i=0; i<n; i++){
		    now = 0;
		    st = sc.readLine().split(" ");
		    for(int j=0; j<5; j++)
			now+=Integer.valueOf(st[j]);
		    if(now>max) max = now;
		    if(now<min) min = now;
		}
		System.out.println(max+" "+min);
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

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

#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)

using ll = long long;
#define INF 1e9


int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  ll sum = 0;
  int mina = INF;
  int zero = 0, plus = 0, minus = 0;
  REP(i, N){
    cin >> A[i];
    if(A[i] < 0){
      minus++;
      A[i] *= -1;
    }
    else if(A[i] > 0){
      plus++;
    }
    else{
      zero++;
    }
    mina = min(A[i], mina);
    sum += A[i];
  }
  
  if(minus % 2){
    cout << sum - mina * 2 << endl; 
  }
  else{
    cout << sum << endl;
  }
  
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
long long int Inv(long long int a, long long int m) {
  int c[50];
  long long int e[50];  
  c[0] = (m-2) % 2, e[0] = (m-2) / 2; 
  for (int i = 0; i < 50; ++i){
     c[i+1] = e[i] % 2;
     e[i+1] = e[i] / 2;  
  }
  long long int d[50]; 
  d[0] = a; 
  for (int j = 0; j < 50; ++j){
     d[j+1] = (d[j] * d[j]) % m; 
  }
  long long int Q; 
  Q = 1; 
  for(int k = 0; k < 50; ++k){
  if (c[k] == 0) Q = Q; 
  if (c[k] == 1) Q = (Q * d[k]) % m; 
  }
 return Q;
}
long long int Fac(long long int a) {
  long long int f[314159]; 
  f[0] = 1; 
  for (int i = 1; i < 314159; ++i){
     f[i] = (f[i-1] * i) % 998244353;  
  }
 return f[a];
}
int main() {
    long long int N, A, B, K; 
    cin >> N >> A >> B >> K;
    long long int p = 998244353; 
    long long int M[314159];
    int i; 
    M[0] = Fac(N) % p;
  for (int i = 0; i < N; ++i){
    M[i+1] = (((M[i] * (i+1)) % p) * Inv(N-i, p) ) % p;
    }
    long long int S = 0; 
    for (int m = 0; m <= N; ++m){
    if((K- A * m) % B == 0 
       && K-A * m>= 0 && (K-A * m) / B <= N){ 
    int n = (K- A * m) / B;
    long long int 
      U = M[n] % p; 
    long long int 
      V = M[m] % p; 
    long long int
      W = Inv((U * V) % p, p); 
    S = (S + W) % p;
    }
    }
    cout << (((Fac(N) * Fac(N)) % p) * S) % p << endl;
}

Measured memory_bytes: 5120
program FizzBuzz
      implicit none
      
      integer K,a(3),gcd,Mi,i,j,l
      read(*,*) K
      a=1
      gcd=0
      do i=1,K
        a(0)=i
      do j=1,K
        a(1)=j
      do l=1,K
         a(2)=l
         Mi=min(a(0),a(1),a(2))
         
         1 if (mod(a(0),Mi)==0.and.mod(a(1),Mi)==0.and.mod(a(2),Mi)==0) then
            gcd=gcd+Mi
         else
             Mi=Mi-1
             go to 1
         end if
      end do
      end do
      end do
      
      write(*,'(i0)') gcd
      stop 
      end program FizzBuzz

Measured memory_bytes: 2928
# ABC144 D
from math import atan2,pi

a,b,x=map(int,input().split())
if a*a*b>2*x:
    h=2*x/(a*b)
    print(90-atan2(2*x,a*b*b)*180/pi)
else:
    print(atan2((2*(a*a*b-x)),a**3)*180/pi)

Measured memory_bytes: 62352
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();
	long long x;
	cin >> x;
	for(long long i = -1000; i <= 1000; i++)
		for(long long j = -1000; j <= 1000; j++)
		{
			long long i1 = i * i * i * i * i;
			long long j1 = j * j * j * j * j;
			if(i1 - j1 == x) cout << i << ' ' << j, exit(0);
		}
}      

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

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define deb(x)     cout << #x << " = "<<x<<endl

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)

int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 200005;


ll gcd(ll  a , ll b) {
	return (b == 0) ? a : gcd(b, a % b);
}
ll binpow(ll a, ll b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}
ll powmod(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinv(ll n, ll p)
{
	return powmod(n, MOD - 2, MOD);
}
void max_self(ll &a, ll b) {
	a = max(a, b);
}


int main(int argc, char const *argv[])
{
	// two magical lines to speed up IO
	cin.tie(0);
	ios_base::sync_with_stdio(false);
// #ifndef ONLINE_JUDGE
// 	freopen("in.txt", "r", stdin);
// 	freopen("out.txt", "w", stdout);
// #endif
	int n, w;
	cin >> n >> w;
	vl dp(w + 1, 0);
	while (n--) {
		int wt;
		ll v;
		cin >> wt >> v;
		for (int i = w - wt; i >= 0; i--) {
			dp[i + wt] = max(dp[i + wt], dp[i] + v);
		}
	}
	cout << dp[w] << endl;
	return 0;

}










Measured memory_bytes: 3964
#include <iostream>
#include <vector>
#include <deque>

struct BFS
{
  size_t N;
  size_t M;
  std::vector<std::vector<size_t>> Graph;
  std::vector<size_t> dist;
  std::vector<std::vector<size_t>> distMap;
  std::deque<size_t> que;
  std::vector<size_t> arrow;

  BFS()
  {
    std::cin>>N;
    std::cin>>M;

    Graph.resize(N);
    for(size_t i=0;i!=M;i++)
    {
      size_t j1,j2;
      std::cin>>j1>>j2;
      j1--;
      j2--;
      Graph[j1].push_back(j2);
      Graph[j2].push_back(j1);
    }

    dist.assign(N,-1);
    distMap.resize(N);
    arrow.assign(N,-1);
  }

  void find(size_t pos)
  {
    dist[pos]=0;
    distMap[dist[pos]].push_back(pos);
    que.push_back(pos);

    while(que.empty()==false)
    {
      pos=que.front();
      que.pop_front();

      for(size_t i=0;i!=Graph[pos].size();i++)
      {
        size_t nextPos=Graph[pos][i];

        if(dist[nextPos]!=-1)
          continue;

        dist[nextPos]=dist[pos]+1;
        distMap[dist[nextPos]].push_back(nextPos);
        que.push_back(nextPos);
        arrow[nextPos]=pos;
      }
    }
  }
};

int main()
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  
  BFS f;
  f.find(0);

  for(size_t i=1;i!=f.arrow.size();i++)
  {
    if(f.arrow[i]==-1)
    {
      std::cout<<"No"<<std::endl;
      return 0;
    }
  }

  std::cout<<"Yes\n";
  for(size_t i=1;i!=f.arrow.size();i++)
  {
    std::cout<<f.arrow[i]+1<<"\n";
  }
  std::cout<<std::endl;
  
  return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define esort(s) sort((s).begin(),(s).end())

typedef long long ll;
typedef pair<int,int> ipair;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

int N;
string S,T;

void solve(){
    cin>>N;
    cin>>S>>T;
    rep(i,N) cout<<S[i]<<T[i];
    cout<<endl;

    return;
}

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

    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cmath>
#include<set>
#include<map>
#define INF 1e8
using namespace std;
int main(void){
set<long long> s;
double h,n;
cin>>h>>n;

long long sum=0;
for(int i=0;i<n;i++){
    int a;
    cin>>a;
    sum+=a;
}
if(sum>=h)
cout<<"Yes";
else
cout<<"No";
}



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

int main() {
  int n,m,M=0;
  cin >> n;
  vector<string> v(n);
  for (int i=0;i<n;i++)
    cin >> v.at(i);
  cin >> m;
  vector<string> u(m);
  for (int i=0;i<m;i++)
    cin >> u.at(i);//
  
  vector<int> x(n+1);
  for (int i=0;i<n;i++) {
    x.at(i)++;
    
    for(int j=0;j<n;j++) {
      if (i==j)
        continue;
      else if (v.at(i)==v.at(j))
        x.at(i)++;
    }//forj
    
    for(int j=0;j<m;j++) {
      if(v.at(i)==u.at(j))
        x.at(i)--;
    }//forj
  }//fori
  for(int i=0;i<n+1;i++) {
    for(int j=0;j<n+1;j++) {
      if (i==j)
        continue;
      if (x.at(i)>x.at(j)&&x.at(i)>M) {
        M = x.at(i);
        break;
      }//if
      if (x.at(i)==x.at(j)&&x.at(i)>M) {
        M=x.at(i);
      }//if
    }//forj
  }//fori
  
  cout << M << endl;
}

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

int main() {
  int n,m;cin>>n>>m;
  vector<int> a(n);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    sum += a.at(i);
  }

  int pop = 0;
  for (int i = 0; i < n; i++) if (a.at(i)*m*4 >= sum) pop++;

  if (pop >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

static const int N = 100;
int M[N][N];


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

	for (int i = 0; i < n; ++i){
		for (int j = 0; j < n; ++j)
			M[i][j] = 0;
	}

	for (int i = 0; i < n; ++i)
	{
		int u, d; cin >> u >> d;
		for (int j = 0; j < d; ++j) {
			int v;  cin >> v;
			M[u - 1][v - 1] = 1;
		}
	}

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j)	{
			if (j) cout << " ";
			cout << M[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3124
#include<cstdio>
#include<cstring>

char s[200001];
int n,la,tot,laa;

int main()
{
	scanf("%s",s+1); n=strlen(s+1);
	if (s[n]=='1') {printf("-1\n"); return 0;} 
	for (int i=1; i<=n/2; i++) 
		if (s[i]!=s[n-i]) {printf("-1\n"); return 0;}
	if (s[1]!='1') {printf("-1\n"); return 0;}
	tot=1; la=laa=1;
	for (int i=2; i<=n/2; i++)
		if (s[i]=='1') 
		{
			tot++;
			printf("%d %d\n",tot,laa); laa=tot;
			for (int j=1; j<=i-1-la; j++) tot++,printf("%d %d\n",laa,tot);
			la=i;
		}
	tot++;
	printf("%d %d\n",tot,laa); laa=tot;
	for (int j=1; j<=n-1-la; j++) tot++,printf("%d %d\n",laa,tot);
	return 0;
}

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

int main()
{
    int A, B, K;
    cin >> A >> B >> K;
    if (A + K - 1 < B - K + 1)
    {
        for (int i = 0; i < K; i++)
        {
            cout << A + i << '\n';
        }
        for (int i = 0; i < K; i++)
        {
            cout << B - K + 1 + i << '\n';
        }
    }
    else{
        for (int i = 0; i <= B - A; i++)
        {
            cout << A + i << '\n';
        }
    }
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Maybe

solve ts ds
  | null ts = "YES"
  | (not $ null ts) && (null ds) = "NO"
  | otherwise =
    case compare t d of
      EQ -> solve (tail ts) (tail ds)
      GT -> solve ts (tail ds)
      LT -> "NO"
  where
    t = head ts
    d = head ds
    

main = do
  n <- readLn :: IO Int
  ds <- sort . map (fst . fromJust . B.readInt) . B.words <$> B.getLine
  m <- readLn :: IO Int
  ts <- sort . map (fst . fromJust . B.readInt) . B.words <$> B.getLine
  putStrLn $ solve ts ds


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

using namespace std;
using ll = long long int;
using ull = unsigned long long int;
#define vll vector<ll>

#define FOR(i, b, e) for(int i = (b); i < (e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define REV(v) reverse((v).begin(), (v).end())
#define IN(v) cin >> (v);
#define VIN(v, n) REP(i, n) cin >> v[i];
#define OUT(v) cout << (v) << endl;
#define YN(b) OUT((b) ? "YES" : "NO")
#define Yn(b) OUT((b) ? "Yes" : "No")
#define yn(b) OUT((b) ? "yes" : "no")

const ll MOD = 1000000007;

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

  ll n, k, d, a;
  cin >> n >> k;
  set<ll> s;

  REP(i, k) {
    cin >> d;
    REP(j, d) {
      cin >> a;
      s.insert(a);
    }
  }

  ll c = 0;
  REP(i, n) {
    if (s.find(i + 1) == s.end()) c++;
  }

  cout << c << endl;

  return 0;
}

Measured memory_bytes: 3656
use input::Input;

fn main() {
    let mut input = Input::new();

    let mut a: i32 = input.parse();
    let b: i32 = input.parse();
    let mut c: i32 = input.parse();
    let d: i32 = input.parse();

    let mut turn = true;
    while a > 0 && c > 0 {
        if turn {
            c -= b;
        } else {
            a -= d;
        }
        turn = !turn;
    }
    if a > 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}

#[allow(dead_code)]
mod input {
    use std::io::{stdin, BufRead, StdinLock};

    pub struct Input<'a> {
        memory: Vec<String>,
        reader: StdinLock<'a>,
    }

    impl<'a> Input<'a> {
        pub fn new() -> Self {
            Self {
                memory: Vec::new(),
                reader: Box::leak(Box::new(stdin())).lock(),
            }
        }
        pub fn read_line(&mut self) -> String {
            let mut s = String::new();
            self.reader.read_line(&mut s).expect("read_line failed.");
            s
        }
        pub fn parse<T: std::str::FromStr>(&mut self) -> T {
            if self.memory.len() == 0 {
                let s = self.read_line();
                self.memory = s.split_whitespace().map(String::from).rev().collect();
            }
            self.memory.pop().unwrap().parse().ok().unwrap()
        }
    }
}


Measured memory_bytes: 2160
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val X = sc.nextInt()
    val Y = sc.nextInt()
    val x = (0 until n).map { sc.next().toInt() }
    val y = (0 until m).map { sc.next().toInt() }
    println(problem110b(n, m, X, Y, x, y))
}

fun problem110b(
    n: Int,
    m: Int,
    X: Int,
    Y: Int,
    x: List<Int>,
    y: List<Int>
): String {
    val xMax = x.max()!!
    val yMin = y.min()!!
    for (z in -100..101) {
        if (X < z && z <= Y && xMax < z && yMin >= z) {
            return "No War"
        }
    }
    return "War"
}

Measured memory_bytes: 31524
H, W = map(int, input().split())
import sys
sys.setrecursionlimit(500000)
S = []
for i in range(H):
    S.append(input())

#white = ".", black = "#"
def search(x, y, color):
    global black
    global white
    if color == ".":
        for m in [1, -1]:
            if 0 <= x+m <= H-1:
                if S[x+m][y] == "#" and not dp[x+m][y]:
                    black += 1
                    dp[x+m][y] = True
                    color = "#"
                    search(x+m, y, color)
        for n in [1, -1]:
            if 0 <= y+n <= W-1:
                if S[x][y+n] == "#" and not dp[x][y+n]:
                    black += 1
                    dp[x][y+n] = True
                    color = "#"
                    search(x, y+n, color)

    else:
        for m in [1, -1]:
            if 0 <= x+m <= H-1:
                if S[x+m][y] == "." and not dp[x+m][y]:
                    white += 1
                    dp[x+m][y] = True
                    color = "."
                    search(x+m, y, color)

        for n in [1, -1]:
            if 0 <= y+n <= W-1:
                if S[x][y+n] == "." and not dp[x][y+n]:
                    white += 1
                    dp[x][y+n] = True
                    color = "."
                    search(x, y+n, color)


ans = 0
dp = [[False] * W for a in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] == "#" and not dp[i][j]:
            black = 1
            white = 0
            dp[i][j] = True
            search(i, j, "#")
            ans += black * white

print(ans)


Measured memory_bytes: 162780
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Math;

/*Question
/??????????????¶??° x, y ?????\?????¨???????????????????????§??¬?´???°????±???????????????°????????????????????????????????????
/???????????´??° x ??¨ y ???????????????x ?? d ??¨ y ?? d ??????????????¨?????? 0 ??¨?????? d ??????????????§???????????????x ??¨ y ????????§??¬?´???°???Greatest Common Divisor?????¨?¨?????????????
/????????°???35 ??¨14 ????????§??¬?´???° gcd (35, 14) ??? 7 ??¨???????????????????????????35 ????´???°{1, 5, 7, 35}???14 ????´???° {1, 2, 7, 14} ?????¬?´???° {1, 7} ????????§?????¨??????????????? 
*/

/*Input
/x ??¨ y ?????????????????????????????§?????????????????????????????? 
*/

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		/*??\???
		/??????????´???°?????\???????¬??????°????????\???
		*/
		String[] st = sc.readLine().split(" ");
		int x = Integer.parseInt(st[0]);
		int y = Integer.parseInt(st[1]);
		GCD(Math.max(x,y),Math.min(x,y));
	}

	/*GCD????????????
	/?????°??????????????§??¬?´???°?????¢???????????????
	/x % y???o??§?????????????????????
	/?????????x % y????¨??????????????????\??????y % t?????°?????????
	*/

	public static void GCD(int x,int y) {
		//????????????x % y???????´???????????????????
		int t;
		while ((t = x % y) != 0) {
			x = y;
			y = t;
		}
		System.out.println(y);
	}
}

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

int main(){
    int n,a;
    cin>>n>>a;
    if(n%500>a) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 20;
string s[N];
int col[N], sum[N], cur[N];

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

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

    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    int ans = n * m;

    for (int i = 0; i < (1 << (n - 1)); i++) {
        int z = 0, cur_ans = 0;

        for (int j = 0; j < n; j++) {
            col[j] = z;
            if ((i >> j) & 1) {
                cur_ans++;
                z++;
            }
        }

        fill(sum, sum + n, 0);

        bool ok = true;

        for (int j = 0; j < m; j++) {
            fill(cur, cur + n, 0);

            for (int h = 0; h < n; h++) {
                cur[col[h]] += (s[h][j] == '1');
            }

            bool cut = false;

            for (int h = 0; h <= z; h++) {
                if (cur[h] > k) {
                    ok = false;
                    break;
                }
                if (cur[h] + sum[h] > k) {
                    cut = true;
                    break;
                }
            }

            if (!ok)
                break;

            if (cut) {
                fill(sum, sum + n, 0);
                cur_ans++;
            }

            for (int h = 0; h <= z; h++) {
                sum[h] += cur[h];
            }
        }

        if (ok)
            ans = min(ans, cur_ans);
    }

    cout << ans;

    return 0;   
}   

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt(), b = scanner.nextInt();
			int c = scanner.nextInt(), d = scanner.nextInt();
			int e = scanner.nextInt(), f = scanner.nextInt();
			// 水の組合せ
			Set<Integer> waters = new HashSet<>();
			IntStream.range(0, f / a / 100 + 1)
					.forEach(i -> IntStream.range(0, (f - 100 * a * i) / b / 100 + 1).forEach(j -> {
						int water = 100 * a * i + 100 * b * j;
						if ((water <= f) && (water > 0)) {
							waters.add(water);
						}
					}));
			// 砂糖の組合せ
			Set<Integer> sugars = new HashSet<>();
			IntStream.range(0, (f - a) / c).forEach(i -> IntStream.range(0, (f - a - i) / d).forEach(j -> {
				int sugar = c * i + d * j;
				if ((sugar <= (f - a))) {
					sugars.add(sugar);
				}
			}));
			double maxRatio = -0.1d;
			int maxWater = 0, maxSugar = 0;
			for (int water : waters) {
				for (int sugar : sugars) {
					if ((water + sugar) <= f) {
						double radio = calcRadio(water, sugar, e);
						if (radio > maxRatio) {
							maxRatio = radio;
							maxWater = water;
							maxSugar = sugar;
						}
					}
				}
			}
			System.out.println((maxWater + maxSugar) + " " + maxSugar);
		}
	}

	/**
	 * @param water    水の量
	 * @param sugar    砂糖の量
	 * @param maxRadio 最大濃度
	 * @return 現在の濃度（最大濃度を超えた場合は0）
	 */
	private static double calcRadio(int water, int sugar, int maxRadio) {
		int maxSugar = water / 100 * maxRadio;
		if (sugar > maxSugar) {
			return 0.0d;
		} else {
			return 100.0 * sugar / water;
		}
	}
}


Measured memory_bytes: 30740
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int A[3][3];
    
    for(int i = 0; i < 3;i++){
        for(int j = 0; j < 3;j++){
            cin >> A[i][j];
        }
    }
    int N;
    map<int,int> mp;
    cin >> N;
    int b;
    for(int i = 0; i < N;i++){
        cin >> b;
        mp[b]++;
    }
    
    string ans = "No";
    for(int i = 0; i < 3;i++){
        if(mp[A[i][0]]+mp[A[i][1]]+mp[A[i][2]]==3)ans = "Yes";
        if(mp[A[0][i]]+mp[A[1][i]]+mp[A[2][i]]==3)ans = "Yes";
    }
    
    if(mp[A[2][0]]+mp[A[1][1]]+mp[A[0][2]]==3)ans = "Yes";
    if(mp[A[0][0]]+mp[A[1][1]]+mp[A[2][2]]==3)ans = "Yes";
    
    cout << ans <<endl;
    
    
}


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

int main(){
  int N;
  cin >> N;
  pair<string,int> A[N],C[N];
  vi P(N,0);
  rep(i,N){
    cin >> A[i].first >> A[i].second;
    A[i].second *= -1;
    C[i].first = A[i].first;
    C[i].second = A[i].second;
  }
  sort(A,A+N);
  rep(i,N)
    rep(j,N){
    if(A[i].second == C[j].second && A[i].first==C[j].first)P[i] = j+1;
  }
  rep(i,N) cout << P[i] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	static int mod=1000000007;
	static long[] fact=new long[500001];
	static long[] rev=new long[500001];
	static long pow(long a,long x,long m){
		if(x==0) return 1;
		else if(x%2==0) return pow((a*a)%m,x/2,m)%m;
		else return (a*pow((a*a)%m,x/2,m))%m;
	}
	static long rev(long a,long mod){
		if(a%mod==0) return 0;
		return pow(a,mod-2,mod)%mod;
	}
	static long ncr(long n,long r){
		long res=1;
		if(n==0 || r==0 || n==r) return res;
		res*=fact[(int)n]; res%=mod;
		res*=rev[(int)r]; res%=mod;
		res*=rev[(int)(n-r)]; res%=mod;
		return res;
	}
	static void init(){
		fact[1]=1; rev[1]=1;
		for(long i=2;i<fact.length;i++){
			fact[(int)i]=i*fact[(int)(i-1)]; fact[(int)i]%=mod;
			rev[(int)i]=rev(fact[(int)i],mod);
		}
	}
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		init();
		while(sc.hasNext()){
			long h=sc.nextLong(),w=sc.nextLong(),a=sc.nextLong(),b=sc.nextLong();
			long ans=0;
			for(long i=1;i<=h-a;i++){
				ans+=(ncr(b+i-2,i-1)*ncr(w-b-1+h-i,h-i))%mod;
				ans%=mod;
			}
			System.out.println(ans);
		}
	}
}

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

int main(){
    int n,k,q;
    cin>>n>>k>>q;
    int arr[n+1];
    for (int i=1;i<=n;++i){
        arr[i] = k-q;
    }
    for (int i=0;i<q;++i){
        int x;
        cin>>x;
        arr[x]++;
    }
    for (int i=1;i<=n;++i){
        if (arr[i]>0){
            cout<<"Yes";
        }
        else{
            cout<<"No";
        }
        cout<<"\n";
    }
}

Measured memory_bytes: 4024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<map>
#include<cmath>
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; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c));
typedef long long ll;

int main()
{
  vector<int> t(3);
  for(int i = 0; i < 3; i++) cin >> t[i];

  sort(t.begin(), t.end());
  cout << t[0] + t[1] << endl;
}


Measured memory_bytes: 256
// Sum of Three Integers

func main() {
    let ks = readLine()!.split(separator: " ").map{Int($0)!}
    let k = ks[0]
    let s = ks[1]

    var count = 0

    let xmax = min(k, s)
    let xmin = max(0, s - 2 * k)
    for x in xmin...xmax {
        let ymin = max(s - x - k, 0)
        let ymax = min(s - x, k)
        let current = ymax - ymin + 1
        count += current
    }
    print(count)
}

main()

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

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

#define INF 1001001001

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

    int h, w, K;
    cin>>h>>w>>K;
    vector<string> ss(h);
    rep(i, h) cin>>ss[i];

    vector<vector<int>> is(h + 1, vector<int>(w + 1));
    rep(i, h) {
        rep(j, w) {
            is[i + 1][j + 1] = is[i][j + 1] + is[i + 1][j] - is[i][j];
            if (ss[i][j] == '1') is[i + 1][j + 1]++;
        }
    }

    int ans = INF;
    rep(i, 1<<(h - 1)) {
        vector<int> group;
        group.push_back(0);
        int cut = 0;
        rep(j, h - 1) {
            if ((i>>j) & 1) {
                group.push_back(j + 1);
                cut++;
            }
        }
        group.push_back(h);

        int prev = 0;
        bool pos = true;
        for (int j = 1; j < w + 1; ++j) {
            rep(k, group.size() - 1) {
                if (is[group[k + 1]][j] - is[group[k]][j] - is[group[k + 1]][prev] + is[group[k]][prev] > K) {
                    cut++;
                    prev = j - 1;
                }
                if (is[group[k + 1]][j] - is[group[k]][j] - is[group[k + 1]][j - 1] + is[group[k]][j - 1] > K) {
                    pos = false;
                    break;
                }
            }
        }
        if (!pos) continue;
        if (cut < ans) ans = cut;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <iostream>

int N;
int V[50];
int C[50];

int main() {
    std::cin >> N;

    for (int i = 0; i < N; i++) {
        std::cin >> V[i];
    }
    for (int i = 0; i < N; i++) {
        std::cin >> C[i];
    }

    int result = 0;
    for (int i = 0; i < N; i++) {
        result += (V[i] - C[i] > 0) ? V[i] - C[i] : 0;
    }

    std::cout << result << std::endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define mod 1000000007ll
#define mod1 998244353ll
#define endl '\n'
#define inf ((ll)1e18+1)
#include<chrono>
using namespace chrono;
mt19937_64 rng(high_resolution_clock::now().time_since_epoch().count());
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define debr(x,y) {cout<<"-->  "<<#x<<" to "<<#y<<" :  "; auto itr=x; while(itr!=y) cout<<(*itr++)<<' '; cout<<endl; }
#define deba(x) {cout<<"-->  "<<#x<<" :  "; for(auto ele:(x)) cout<<ele<<"  "; cout<<endl; }
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s);istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a <<"  ,  ";
    err(++it, args...);
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t=1;
    // cin>>t;
    while(t--){
        ll n;
        cin>>n;
        ll ans=0;
        for(ll x=1;x<=n;x++){
            ll val;
            cin>>val;
            if(x%2 && val%2)ans++;
        }
        cout<<ans<<endl;
    }
    return 0;

}

Measured memory_bytes: 3540
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;
 
int main(){
    int A,B;
    cin >> A >> B;
    cout << (A*A) - B << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#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 all(x) (x).begin(),(x).end()
const long long INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll cnt[1000000];
ll ans[1000000];
bool check[1000000];
void dfs(int now_v,ll count,Graph &G){
  if(check[now_v])return;
  count += cnt[now_v];
  check[now_v] = true;
  ans[now_v] += count;
  for(auto i : G[now_v]){
    dfs(i,count,G);
  }
  return;
}
int solve(){
  int n,q;
  cin >> n >> q;
  Graph G(n);
  rep(i,n - 1){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  rep(i,q){
    int a,b;
    cin >> a >> b;
    a--;
    cnt[a] += b;
  }
  dfs(0,0,G);
  rep(i,n)cout << ans[i] << " ";
  return 0;
}
int main(){
  ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

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

int main(){
  ll n;
  cin>>n;
  vector<ll> v(n);
  rep(i,n){
    cin>>v.at(i);
  }
  vector<ll> v2(n);
  v2 = v;
  sort(v2.begin(),v2.end());
  ll max1=v2.at(n-1),max2=v2.at(n-2);
  rep(i,n){
    if (v.at(i) == max1){
      cout << max2 << endl;
    }
    else{
      cout << max1 << endl;
    }
  }
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}

int main(){
    int N; cin >> N;
    ll L; cin >> L;
    vector<ll> v(N);
    ll tmp;
    REP(i,N) cin >> v[i];
    bool f = false;
    REP(i,N-1){
        if(v[i]+v[i+1]>=L) {
            f=true;
            tmp=i+1;
            break;
        }
    }
    if(!f) cout << "Impossible" << endl;
    else {
        cout << "Possible" << endl;
        deque<ll> res;
        FOR(i,1,N) {
            if(i<tmp) res.push_back(i);
            if(i>tmp) res.push_front(i);
        }
        res.push_back(tmp);
        while(!res.empty()) {
            cout << res.front() << endl;
            res.pop_front();
        }
    }
    return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define sz 100002
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define P push
#define PQ priority_queue<double, vector<double>, greater<double> >q
#define _sort(v) sort(v.begin(),v.end())
#define MP map<ll int,ll int>mp
#define MEM(x) memset(x,0,sizeof(x))
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define VEC(n) ll int x; vector<ll int>v;for(int i=0;i<n;i++){cin>>x;v.pb(x);}
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

//Upper_bound   auto x=upper_bound(v[a].begin(),v[a].end(),les);les=*x; if(x==v[a].end())break;
//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//ll mod_inverse(ll a, ll mod){return bigmod(a,mod-2,mod);}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;string mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}
//string add(string s,int n){ string res; int c=n,x; for(int i=s.size()-1;i>=0;i--)   { x=s[i]-'0'+c;res+=(x%10+'0'); c=x/10; }    while(c)    { res+=(c%10+'0'); c=c/10;} reverse(res.begin(),res.end()); return res;}


int main()
{
    FAST();
    int n;
    cin>>n;
    VEC(n);
    int cnt=0;
    vector<int>vv;
    for(int i=0;i<n-2;i++)
    {
        for(int j=i+1;j<n-1;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                vv.clear();
                vv.pb(v[i]);
                vv.pb(v[j]);
                vv.pb(v[k]);
                _sort(vv);
                if(vv[0]==vv[1]||vv[1]==vv[2])continue;
                else if(vv[0]+vv[1]>vv[2])cnt++;
            }
        }
        //cout<<cnt<<endl;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3628
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D: Mixing Experiment
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 40;
const int MAX_A = 10;
const int MAX_B = 10;
const int MAX_NA = MAX_N * MAX_A;
const int MAX_NB = MAX_N * MAX_B;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int as[MAX_N], bs[MAX_N], cs[MAX_N];
int dp[2][MAX_NA + 1][MAX_NB + 1];

/* subroutines */

/* main */

int main() {
  int n, ma, mb;
  cin >> n >> ma >> mb;

  for (int i = 0; i < n; i++)
    cin >> as[i] >> bs[i] >> cs[i];

  for (int a = 0; a <= MAX_NA; a++)
    for (int b = 0; b <= MAX_NB; b++)
      dp[0][a][b] = dp[1][a][b] = INF;
  dp[0][0][0] = 0;
  int cur = 0, nxt = 1;

  for (int i = 0; i < n; i++) {
    memcpy(dp[nxt], dp[cur], sizeof(dp[cur]));

    for (int a = 0; a < MAX_NA; a++)
      for (int b = 0; b < MAX_NB; b++)
	if (dp[cur][a][b] < INF) {
	  int d = dp[cur][a][b] + cs[i];
	  int a1 = a + as[i], b1 = b + bs[i];
	  if (dp[nxt][a1][b1] > d) dp[nxt][a1][b1] = d;
	}
    cur ^= 1, nxt ^= 1;
  }

  int mind = INF;
  for (int a = 1; a <= MAX_NA; a++)
    for (int b = 1; b <= MAX_NB; b++)
      if (a * mb == b * ma && mind > dp[cur][a][b])
	mind = dp[cur][a][b];

  printf("%d\n", (mind >= INF) ? -1 : mind);
  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N = 1e5 + 5;
#define int long long int

int32_t main() {
    IOS ;
    // int t ; cin >> t ; while(t--) {}
    int d, t, s ; 
    cin >> d >> t >> s ; 
    if(s*t >= d) cout << "Yes" ; 
    else cout << "No" ;
    return 0 ;
}


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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;

int a0, a1, a2, a3;
LL n;

void init ();
void input ();
void work ();



int main()
{
	init();
	input();
	work();
}



void init ()
{
	// Init Everything Here
	
	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method
	
	cin >> a0 >> a1 >> a2 >> a3 >> n;
}

void work ()
{
	// main work
	
	n *= 4;
	
	a1 = qmin ( a1, a0 << 1 );
	a2 = qmin ( a2, a1 << 1 );
	a3 = qmin ( a3, a2 << 1 );
	
	cout << ( n / 8 * a3 + ( ( n >> 2 & 1 ) * a2 ) + ( ( n >> 1 & 1 ) * a1 ) + ( ( n & 1 ) * a0 ) ) << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main{

	public static void main(String[] args) throws Exception
	{
		String strRing1 = "24532453";
		String strRing2 = "64136413";
		String strRing3 = "56215621";
		String strRing4 = "51265126";
		String strRing5 = "63146314";
		String strRing6 = "54235423";

//		String[] strRing = {"24532453","64136413","56215621","51265126","63146314","54235423"};

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );
		String[] strDice = br.readLine().split(" ");
		int q = Integer.parseInt(br.readLine() );

		HashMap<String,String> map = new HashMap<String,String>();

		for(int i=1; i<=6; i++)
		{
			map.put(strDice[i-1],Integer.toString(i) );
		}

		for(int i=0; i<q; i++)
		{
			String[] str = br.readLine().split(" ");

			String strB = Integer.toString(7 - Integer.parseInt(map.get(str[0]) )  );
			String strBST = strB + map.get(str[1]) + map.get(str[0]);

/*			for(int j=0; j<6; j++)
			{
				if(-1 < strRing[j].indexOf(strBST) ) System.out.println(strDice[j]);
			}*/

			if(-1 < strRing1.indexOf(strBST) )
			{
				System.out.println(strDice[1-1]);
			}
			else if(-1 < strRing2.indexOf(strBST) )
			{
				System.out.println(strDice[2-1]);
			}
			else if(-1 < strRing3.indexOf(strBST) )
			{
				System.out.println(strDice[3-1]);
			}
			else if(-1 < strRing4.indexOf(strBST) )
			{
				System.out.println(strDice[4-1]);
			}
			else if(-1 < strRing5.indexOf(strBST) )
			{
				System.out.println(strDice[5-1]);
			}
			else if(-1 < strRing6.indexOf(strBST) )
			{
				System.out.println(strDice[6-1]);
			}

		}

	}
}

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

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

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    string s;
    cin >> s;

    int ans = inf;
    range(i, 3, s.size() + 1) {
        chmin(ans, abs(753 - stoi(s.substr(i - 3, 3))));
    }

    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


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

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

    int f = 0;
    int t = N;

    while (t > 0)
    {
        f += t % 10;
        t /= 10;
    }

    if (N % f == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  ll v;
  cin >> n >> v;
  ll a[n], b[n], c[n], d[n];
  REP(i, n) cin >> a[i];
  REP(i, n) cin >> b[i];
  REP(i, n) cin >> c[i];
  REP(i, n) cin >> d[i];
  vector<ll> ab;
  REP(i, n) REP(j, n) ab.push_back(a[i] + b[j]);
  sort(ALL(ab));
  ll ans = 0;
  REP(i, n) REP(j, n) {
    ll cd = c[i] + d[j];
    ans += upper_bound(ALL(ab), v - cd) - lower_bound(ALL(ab), v - cd);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11288
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int min1(int a,int b,int c ){
    if(a<b&&a<c) return a;
    else if(b<a&&b<c) return b;
    else return c;
}
int main(){
    int n,k,x;
    long long num=0;
    cin>>n;
    for(int a=1;a<=n;a++){
        for(int b=1;b<=n;b++){
            for(int c=1;c<=n;c++){
                k=min1(a,b,c);
                for(int i=1;i<=k;i++){
                    if(a%i==0&&b%i==0&&c%i==0){
                        x=i;
                    }
                }
                num+=x;
            }
        }
    }
    cout<<num;
}


Measured memory_bytes: 3672
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;
#define maxn 10010
#define llg long long 
#define yyj(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);
llg n,m,mid,ans,x;
int main()
{
	//yyj("A");
	scanf("%I64d",&x);
	x*=2;
	llg l=1,r=1e9;
	while (l<=r)
	{
		mid=(l+r)>>1;
		llg val=mid*mid+mid;
		if (val>=x) {r=mid-1,ans=mid;} else l=mid+1;
	}
	printf("%I64d",ans);
	return 0;
}


Measured memory_bytes: 256