akhauriyash/Code-Regression huggingface dataset:
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define debug(var) cout << #var << ": " << var << endl
using namespace std;
using Int = int64_t;
using Double = double;
using Uint = uint64_t;
constexpr Uint mod = 1e9 + 7;
constexpr Int INF = INT_MAX;
using Container = vector<Int>;
template<typename T>
using Grid = vector<vector<T>>; // 二次元配列。[y][x]
template<typename T, typename U>
using Umap = unordered_map<T, U>;
template<typename T>
using Uset = unordered_set<T>;
template<typename T>
using P = pair<T, T>;

int main() {

	Int N; cin >> N;
	Container A(N);
	rep(i, N)cin >> A[i];
	bool isapproved = true;
	rep(i, N) {
		if (A[i] % 2 == 0 && A[i] % 3 != 0 && A[i] % 5 != 0) {
			isapproved = false;
			break;
		}
	}

	cout << (isapproved ? "APPROVED" : "DENIED") << endl;

}

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

black = 0
imos = [[0 for i in range(k)] for j in range(k)]

for i in range(n):
    X, Y, C = input().split()
    x = int(X)
    y = int(Y)
    c = 1 if C == "W" else 0

    x = x % (2*k)
    y = y % (2*k)
    if x > k-1:
        x -= k
        c += 1
    if y > k-1:
        y -= k
        c += 1
    c = 1 if c%2 == 1 else -1
    imos[x][y] += c
    if c == -1:
        black += 1

for i in range(k):
    for j in range(k-1):
        imos[i][j+1] += imos[i][j]

for j in range(k):
    for i in range(k-1):
        imos[i+1][j] += imos[i][j]

ans = 0
for i in range(k):
    for j in range(k):
        m = imos[k-1][k-1] - imos[k-1][j] - imos[i][k-1] + 2 * imos[i][j]
        ans = max(ans, max(n-(black+m), black+m))
print(ans)

Measured memory_bytes: 59868
n=int(input())
a=[0 for i in range(120)]
for i in range(n):
    b,f,r,v=map(int,input().split())
    a[(b-1)*30+(f-1)*10+r-1]+=v
for i in range(12):
    seq=a[10*i:10*i+10]
    print(" "+" ".join(map(str,seq)))
    if i%3==2 and i!=11:
        print("####################")


Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int A, B, C;
    cin >> A >> B >> C;
    int X;
    cin >> X;
    int cnt = 0;
    for(int i = 0; i <= A; i++){
        for(int j = 0; j <= B; j++){
            if(X - 500 * i - 100 * j >= 0 && (X - 500 * i - 100 * j) / 50 <= C) cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3584
import java.util.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		C(sc);
	}
	
	public static void A(Scanner sc) {
		out.println(sc.nextInt()/3);
	}
	
	public static void B(Scanner sc) {
		int n = sc.nextInt();
		for(int i=0;i<n;i++) {
			if(sc.next().charAt(0)=='Y') {
				out.println("Four");
				return;
			}
		}
		out.println("Three");
	}
	
	public static void C(Scanner sc) {
		HashMap<Character, Integer> map = new HashMap<Character, Integer>();
		int N = sc.nextInt();
		for(int i=0;i<N;i++) {
			char c = sc.next().charAt(0);
			if(map.containsKey(c)) map.put(c,map.get(c)+1);
			else map.put(c,1);
		}
		ArrayList<Integer> arr = new ArrayList<Integer>();

		HashSet<Character> lis = new HashSet<Character>(Arrays.asList('M','A','R','C','H'));
		for(Character c : map.keySet()) {
			if(lis.contains(c)) {
				arr.add(map.get(c));
			}
		}
		out.println(retksum(arr.toArray(new Integer[arr.size()]),0,3));
	}
	// arrからidx以降からk個選んで、掛け合わせる。全ての組み合わせに対して和
	public static long retksum(Integer[] arr, int idx, int k) {
		if(k==0) return 1;
		if(arr.length-idx<k) return 0;
		return arr[idx]*retksum(arr, idx+1, k-1) + retksum(arr,idx+1,k);
	}
}

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



vector<string> maxElements(unordered_map<string, int> ump){
  vector<string> Max;
  int max=0;
  for(auto it=ump.begin();it!=ump.end();it++){
    if(it->second>=max){
      max=it->second;
    }
  }
  for(auto it=ump.begin();it!=ump.end();it++){
    if(it->second==max){
      Max.push_back(it->first);
    }
  }
  return Max;
}
int main(){
int N;
cin>>N;

vector<string> K(N);
unordered_map<string,int> Ump;

for(int i=0;i<N;i++){
  cin>>K[i];
  Ump[K[i]]++;
}
vector<string> M=maxElements(Ump);
sort(M.begin(),M.end());
for(int i=0;i<M.size();i++){
  cout<<M[i]<<endl;
}
return 0;
}

Measured memory_bytes: 38384
#include <stdio.h>
int main(){
	int n,ans=0;
	int a[20]={};
	int b[20]={};
	int c[19]={};
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (int i = 0; i < n; i++)
		scanf("%d", &b[i]);
	for (int i = 0; i < n-1; i++)
		scanf("%d", &c[i]);
	for (int i = 0; i < n; i++){
		ans+=b[a[i]-1];
		if(i>0&&a[i]==a[i-1]+1){
			ans+=c[a[i-1]-1];
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
use std::cmp;

fn main(){
    let kav: Vec<i64> = read_vec();
    let k = kav[0];
    let a = kav[1];
    let b = kav[2];

    let ans: i64 = if a <= b {
        if a >= k { 1 } else { -1 }
    } else {
        let i: i64 = (k - b + a - b - 1) / (a - b);
        cmp::max(1, 2 * i - 1)
    };
    
    println!("{}", ans);
}

#[allow(dead_code)]
fn read_vec<T>() -> Vec<T>
where T: std::str::FromStr,
      T::Err: std::fmt::Debug
{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).expect("failed to read");
    buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}


Measured memory_bytes: 2076
#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x)     (x).begin() , (x).end()
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
typedef long long int ll;
using namespace std;

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

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


const ll mod = 1e9+7;
const double eps = 1e-9;


int a[101];

void solve(){
    int n,x;
    cin>>x>>n;
    for(int i=0;i<n;++i) {
        int t;
        cin>>t;
        a[t]=1;
    }
    int d=INT_MAX , ans=-1;
    for(int i=-10;i<=120;i++) {
        if(!a[i]) {
            if(d>abs(x-i)) {
                d=abs(x-i) , ans=i;
            }
        }
    }
    cout<<ans<<"\n";
}






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


Measured memory_bytes: 3564
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

a=b=0
for i in range(N):
    if A[i]>B[i]:
        a+=A[i]-B[i]
    else:
        b+=(B[i]-A[i])//2
if a>b:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 40560
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int Count(string, string);

int main(){
  int countjoi, countioi;
  string str, joi = "JOI", ioi = "IOI";

  while(cin >> str){
    countjoi = Count(str, joi);
    countioi = Count(str, ioi);
    cout << countjoi << endl;
    cout << countioi << endl;
  }

  return 0;
}

int Count(string str1, string str2){
  int count = 0;
  string::iterator i = str1.begin();
  while(1){
    i = search(i, str1.end(), str2.begin(), str2.end());
    if(i == str1.end()) break;
    ++count;
    ++i;
  }
  return count;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<time.h>
#pragma GCC optimize(2)
using namespace std;
long long k,i=0,n;
int main()
{
	ios::sync_with_stdio(0);
	cin>>k;
	if(k%2==0||k%5==0)
	{
		cout<<"-1";
		return 0;
	}
	while(i<=1000000)
	{
		i++;
		n=(n*10+7)%k;
		if(n==0)
		{
			cout<<i;
			return 0;
		}
	}
	cout<<"-1";
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define mod 1000000007
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
int main()
{
    FAST;
    string s,t;
    cin>>s>>t;
    ll n=s.length();
    ll m=t.length();
    ll i;
    if(n+1==m)
    {
        for(i=0;i<n;i++)
        {
            if(s[i]!=t[i])
            {
                cout<<"No";
                return 0;
            }
        }
        cout<<"Yes";
        return 0;
    }
    else
    {
        cout<<"No";
    }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<int>;
using A = array<int, 2>;
constexpr int MOD{1000000000 + 7};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr array<int, 4> dx{1, 0, -1, 0};
constexpr array<int, 4> dy{0, 1, 0, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
constexpr int div_roundup(int a, int b)
{
    return (a + b - 1) / b;
}
// vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));
// ***************************************************************************
void solve()
{
    string s;
    cin >> s;

    array<int, 'Z' - 'A' + 1> cs{};
    rep(i, 4)
    {
        cs[s[i] - 'A']++;
    }
    int count = 0;
    rep(i, cs.size())
    {
        if (cs[i] == 2)
            count++;
    }
    cout << (count == 2 ? "Yes" : "No") << endl;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(0);

    solve();
}


Measured memory_bytes: 256
/*
ID: 5ak0
PROG:
LANG: C++11
*/

#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define mpr make_pair

using namespace std;

typedef pair<int, int> pii;
const int INF = 1e9 + 7, MAXN = 1e5 + 10;

int n, a[MAXN], v;

main(){
    #ifndef SAKO
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    #endif // SAKO
    ios_base::sync_with_stdio(0);

    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    v = 1;
    for (int i = 1; i <= n; ++i){
        v = a[v];
        if (v == 2)
            return !(cout << i);
    }
    cout << -1;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using P = pair<ll, ll>;

struct Query
{
    using type = P;
    static type id() { return P(0, -1e15); }
    static type op(const type &l, const type &r) { return P(max(l.first + r.first, l.second + r.second), max(l.first + r.second, l.second + r.first)); }
};

template <typename M>
class SegmentTree
{
    using T = typename M::type;
    int n;
    std::vector<T> node;

  public:
    // v を基に初期化
    SegmentTree(const std::vector<T> &v)
    {
        // n は v.size() 以上の最小の2冪
        n = 1;
        while (n < int(v.size()))
            n *= 2;
        node.resize(2 * n - 1, M::id());

        // i の子 -> 2*i+1, 2*i+2 , 親 -> (i-1)/2
        for (int i = 0; i < int(v.size()); i++)
            node[i + n - 1] = v[i];
        for (int i = n - 2; i >= 0; i--)
            node[i] = M::op(node[2 * i + 1], node[2 * i + 2]);
    }
    // Monoid::id 初期化
    SegmentTree(int _n)
    {
        // n は v.size() 以上の最小の2冪
        n = 1;
        while (n < _n)
            n *= 2;
        node.resize(2 * n - 1, M::id());
    }
    // x 番目を val に更新
    void update(int x, T val)
    {
        x += n - 1;
        node[x] = val;
        while (x > 0)
        {
            x = (x - 1) / 2;
            node[x] = M::op(node[2 * x + 1], node[2 * x + 2]);
        }
    }
    // v[x] を M::op(v[x], val) に更新
    void add(int x, T val)
    {
        x += n - 1;
        node[x] = M::op(node[x], val);
        while (x > 0)
        {
            x = (x - 1) / 2;
            node[x] = M::op(node[2 * x + 1], node[2 * x + 2]);
        }
    }
    // [a, b) の op
    // k := 今居るノード
    T query(int a, int b, int k = 0, int l = 0, int r = -1)
    {
        if (r < 0)
            r = n;
        if (r <= a || b <= l)
            return M::id();
        if (a <= l && r <= b)
            return node[k];

        T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return M::op(vl, vr);
    }
};

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

    int n, q;
    cin >> n >> q;
    vector<ll> a(2 * n), b(2 * n);
    vector<P> v;
    for (int i = 0; i < 2 * n; i++)
        cin >> a[i];
    for (int i = 0; i < 2 * n; i++)
    {
        cin >> b[i];
        v.emplace_back(P(a[i], b[i]));
    }
    SegmentTree<Query> st(v);
    while (q--)
    {
        ll p, x, y;
        cin >> p >> x >> y;
        p--;
        a[p] = x;
        b[p] = y;
        st.update(p, P(x, y));
        ll ret = a[0] + a[2 * n - 1] + st.query(1, 2 * n - 1).first;
        cout << ret << endl;
    }
}


Measured memory_bytes: 16876
from itertools import permutations
n = int(input())
xy = []
for i in range(n):
  x, y = map(int, input().split())
  xy.append((x, y))
np = len(list(permutations(range(n))))
dd = 0
for perm in permutations(range(n)):
  for i in range(n-1):
    dd += ((xy[perm[i-1]][0] - xy[perm[i]][0]) ** 2 + (xy[perm[i-1]][1] - xy[perm[i]][1]) ** 2) ** 0.5
print(dd/np)

Measured memory_bytes: 8052
#include <stdio.h>

int main(){
        int h, f, turu, kame, flg;

        scanf("%d %d", &h, &f);

        for (turu = 0; turu <= h; turu++) {
                kame = h - turu;
                flg = (h == kame + turu) && (f == 2 * turu + 4 * kame);
                if (flg) {
                        break;
                }
        }
        if(flg){
                printf("Yes", turu);
        }else{
                printf("No");
        }
        return 0;
}


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

ll choose2(ll n) {
    return n*(n-1)/2;
}
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) a[i]--;
    vector<int> cnt(n);
    rep(i, n) cnt[a[i]]++;
    ll tot = 0;
    rep(i, n) {
        tot += choose2(cnt[i]);
    }
    rep(i, n) {
        ll ans = tot;
        ans -= choose2(cnt[a[i]]);
        ans += choose2(cnt[a[i]]-1);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
const ll inf = 1e9;
int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    a.erase(unique(all(a)), a.end());
    rep(i,a.size())cout << a[i] << ((i < a.size()-1)?" ":"\n");
    return 0;
}


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

#define rep(i,n)  for(int i=0;i<n;++i)
#define per(i,n)  for(int i=n-1;i>=0;--i)
#define sc1(a)  scanf("%d",&a)
#define sc2(a,b)  scanf("%d %d",&a,&b)
#define sc3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define sl1(a)  scanf("%lld",&a)
#define sl2(a,b)  scanf("%lld %lld",&a,&b)
#define sl3(a,b,c)  scanf("%lld %lld %lld",&a,&b,&c)
#define PI 3.1415926535897932

//typedef long long ll;


int lcm(int a,int b) { return a*b/__gcd(a,b); }
//ll lcm(ll a,ll b) { return a*b/__gcd(a,b); }

/**
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 **/


int main(){
    int mod=1000000007;
    int n;
    int ans[4]={0};
    char s[4];
    scanf("%d",&n);
    for (int i=0;i<n;i++) {
        scanf("%s",s);
        if (s[0]=='A') ans[0]+=1;
        else if (s[0]=='W') ans[1]+=1;
        else if (s[0]=='T') ans[2]+=1;
        else ans[3]+=1;
    }
    printf("AC x %d\n",ans[0]);
    printf("WA x %d\n",ans[1]);
    printf("TLE x %d\n",ans[2]);
    printf("RE x %d\n",ans[3]);
    return 0;
}


Measured memory_bytes: 3784
n, x, m = map(int, input().split())

cnt = [x]
c = set()
c.add(x)

for i in range(m+1):
    x = x*x % m
    if x in c:
        break
    cnt.append(x)
    c.add(x)

start = cnt.index(x)

ans = sum(cnt[:start])
roop = len(cnt) - start

n = n-start
ans = ans + (n//roop)*sum(cnt[start:]) + sum(list(cnt)[start:(start+n%roop)])

print(ans)

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

int N;
int A[21], B[21], C[21];

signed main()
{
  cin >> N;
  REP(n,N) cin >> A[n];
  REP(n,N) cin >> B[n];
  REP(n,N) cin >> C[n];

  int ans = 0;
  REP(n,N) {
    ans += B[n];
    if(n > 0) {
      if(A[n] - A[n-1] == 1) ans += C[A[n-1]-1];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;

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

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

    ll sum=1;
    for(int i=0; i<k; i++){
        if(a<=sum && i<k-1){
            sum-=a;
            sum+=b;
            i++;
        }
        else sum++;
    }

    cout << max(sum, k+1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll n,i,j,k;
	cin>>n;
	ll a[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	ll ct=0;
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			for(k=j+1;k<n;k++)
			{
				if(a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k])
				{
					if(a[i]+a[j]>a[k]&&a[j]+a[k]>a[i]&&a[i]+a[k]>a[j])
					ct++;
				}
			}
		}
	}
	cout<<ct;
}

Measured memory_bytes: 3584
using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("100");
            //ABC100
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("425");
            //ABC425
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("999");
            //ABC999
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string N = InputList[0];

        Console.WriteLine("ABC{0}", N);
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int const mod = 1e9 + 7;

void plusle (int &a, int b) {
    if (( a += b) >= mod ) a -= mod ;
}
void minun (int &a, int b) {
    if ((a -= b) < 0) a += mod ;
}
int add (int a, int b) {
    return (( a += b ) >= mod ) ? a - mod  : a;
}
int sub (int a, int b) {
    return (( a -= b) < 0) ? a + mod : a;
}
int mul(int a, int b) {
    return 1LL * a * b % mod;
}
int power(int a, int b) {
    int res = 1;
    for (; b > 0 ; b >>= 1 , a = mul(a, a))
        if (b & 1) res = mul(res, a);
    return res ;
}
const int Mx = 5e5 + 10;
int fac[Mx], invf[Mx] ;
void prefact () {
    fac[0] = 1 ;
    for (int i = 1 ; i < Mx ; i ++) {
        fac[i] = mul(fac[i - 1], i);
    }
    invf[Mx - 1] = power (fac[Mx - 1] ,  mod - 2 );
    for (int i = Mx - 2 ; i >= 0 ; i --) {
        invf[i] = mul(invf[i + 1], i + 1);
    }
}

int ncr (int N, int R) {
    if (R > N) return 0;
    if (R == 0 || R == N) return 1;
    return mul (fac[N], mul(invf[N - R], invf[R]));
}


int main () {
    prefact();
    int n, k;
    cin >> n >> k;
    if (k >= n){
     k = n;
     cout << ncr(n + k - 1, k - 1) << '\n';
     return 0;
    }
    int ans = 0;
    for (int sp = 0 ; sp <= k ; ++ sp) {
        int res = 1;
        res = mul(res, ncr(n, sp));
        res = mul(res, ncr(n - 1, sp));
       // cerr << res << endl ;
        plusle(ans, res);
    }
    printf("%d\n", ans);

}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 4224
N=int(input()) 
S = input()
num2alpha = lambda c: chr(c+64)
alpha2num = lambda c: ord(c) - ord('A') + 1

def rot(n):
  if n>26:
    return n-26
  else:
    return n

ans =''
for i in S:
  ans  = ans+num2alpha(rot(alpha2num(i)+N))
  

print(ans)


Measured memory_bytes: 3060
n,m = [int(i) for i in input().split()]

a = list(map(int,input().split()))

a.sort()

list = [i for i in range(len(a) - 1)]

for nn,value in enumerate(a):
    if nn == 0:
        diff = value
    else:
        list[nn-1] = value - diff
        diff = value

list.sort(reverse=True)
count = min(n-1, len(list))
for dl in range(count):
    list[dl] = 0

print(sum(list))



Measured memory_bytes: 13960
import Data.Vector (Vector, (!))
import qualified Data.Vector as V

main = do
  n <- readLn
  as <- map read.words <$> getLine
  print $ solve n as

solve n as = foldr1 (+%) $ zipWith (*%) as $ map (*%nf) ps
  where
  nf = foldr1 (*%) [1..n]
  ps = [invsum!(n+1-i) + invsum!i - 1 | i <- [1..n]]
  inv x = u where (u,_,_) = euc x mo
  invsum = V.fromListN (n+1) $ scanl (+%) 0 $ map inv [1..n]


mo = 1000000007

infixl 7 *%
a *% b = a * b `mod` mo

infixl 6 +%
a +% b = (a + b) `mod` mo

infixl 6 -%
a -% b = (a-b+mo) `mod` mo

euc = go 1 0 0 1
  where
  go u v u' v' x 0 = (u,v,x)
  go u v u' v' x y = go u' v' (u - q * u') (v - q * v') y r
    where (q,r) = quotRem x y

Measured memory_bytes: 68092
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  string ans = "Yes";
  if(S.size() < 4){
    ans = "No";
  }
  else if(S.at(0) != 'Y'){
    ans = "No";
  }
  else if(S.at(1) != 'A'){
    ans = "No";
  }
  else if(S.at(2) != 'K'){
    ans = "No";
  }
  else if(S.at(3) != 'I'){
    ans = "No";
  }
  cout << ans << endl;
}

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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var a = long.Parse(Console.ReadLine());
            var b = long.Parse(Console.ReadLine());
            var c = long.Parse(Console.ReadLine());
            var d = long.Parse(Console.ReadLine());
            var e = long.Parse(Console.ReadLine());

            var min = new[] { a, b, c, d, e }.Min();
            var output = n / min;
            if (n % min != 0) output++;

            output += 4;

            Console.Write(output);
        }
    }
}


Measured memory_bytes: 13268
package main

import (
	"fmt"
)

func main() {
	a, b, c, k := 0, 0, 0, 0
	fmt.Scanf("%d %d %d %d", &a, &b, &c, &k)

	if k < a {
		fmt.Println(k)
	} else if k < a+b {
		fmt.Println(a)
	} else {
		fmt.Println(a - (k - a - b))
	}
}


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

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
#define DRT() int t; si(t); while(t--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//# define M_PI           3.14159265358979323846264338327950288
// DSU
void IO(){
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
}

int main(){
	IO();
	LL a=0,w=0,t=0,r=0;
	string s;
	LL n;
	cin>>n;
	rep(i,0,n){
		cin>>s;
		if(s == "AC")
			a++;
		else if(s == "WA")
			w++;
		else if(s == "TLE")
			t++;
		else
			r++;
	}
	cout<<"AC x "<<a<<"\n";
	cout<<"WA x "<<w <<"\n";
	cout<<"TLE x "<<t<<"\n";
	cout<<"RE x "<<r<<"\n";
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 998244353;


int main() {
  int N;cin >> N;
  vint a(N),b(N);
  repeat(i,N) cin >> a[i];
  repeat(i,N) cin >> b[i];
  ll S=(1ll<<51)-2;
  for(int c=50;c>0;c--){
    S ^= 1ll<<c;
    bool g[51][51];
    repeat(i,51){
      repeat(j,51){
        g[i][j]=false;
      }
      g[i][i]=true;
      for(int t=1;t<=50;t++){
        if(S&(1ll<<t))g[i][i%t]=true;
      }
    }
    repeat(k,51){
      repeat(i,51){
        repeat(j,51){
          g[i][j] |= g[i][k]&g[k][j];
        }
      }
    }
    bool need=false;
    repeat(i,N){
      need|=!g[a[i]][b[i]];
    }
    if(need) S|=1ll<<c;
    //debug(S);
  }
  cout <<(S==((1ll<<51)-2)? -1:S)<< endl;
  return 0;
}


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

using namespace std;

int main() {
  int N; cin >> N;
  vector<int> vec(N), minVec(N);
  
  int ans = INT_MIN/2;

  for(int i=0; i<N; i++) {
    cin >> vec[i];
    if(!i) {
      minVec[i] = vec[i];
    }
    else  {
      ans = max(ans, vec[i] - minVec[i-1]);
      minVec[i] = min(minVec[i-1], vec[i]);
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 2588
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int y = sc.nextInt();
		boolean bl = false;
		int a = 0;
		int b = 0;
		for(int i=0; i<=n; i++){
			for(int j=0; j<=n-i; j++){
				if(10000*i+5000*j+1000*(n-i-j)==y){
					a = i;
					b = j;
					bl = true;
					break;
				}
			}
			if(bl==true)break;
		}
		System.out.println(bl==true ? a +" "+ b + " " + (n-a-b) : "-1 -1 -1" );
	}
}

Measured memory_bytes: 22608
#include <stdio.h>
int main(){
  int h1,m1,h2,m2,k,minute=0;
  
  scanf("%d %d %d %d %d %d",&h1,&m1,&h2,&m2,&k);
  minute+=(h2-h1)*60;
  minute+=(m2-m1);
  
  printf("%d",minute-k);
}

Measured memory_bytes: 1688
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
	if(ch == 'A') return 1;
	else if(ch == 'C') return 2;
	else if(ch == 'G') return 3;
	else if(ch == 'T') return 4;
	else return 0;
}

long long getKey(char str[]){
	long long sum=0,p=1,i;
	for(i=0;i<strlen(str);i++){
		sum += p*(getChar(str[i]));
		p*=5;
	}
	return sum;
}

int h1(int key){
	return key % M;
}

int h2(int key){
	return 1+(key%(M-1));
}

int find(char str[]){
	long long key,i,h;
	key=getKey(str);
	for(i=0;;i++){
		h=(h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str)==0)
			return 1;
		else if(strlen(H[h])==0)
			return 0;
	}
	return 0;
}

int insert(char str[]){
	long long key,i,h;
	key=getKey(str);
	for(i=0;;i++){
		h=(h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str)==0)
			return 1;
		else if(strlen(H[h])==0){
			strcpy(H[h],str);
			return 0;
	}
}
	return 0;
}

int main(){
	int i,n,h;
	char str[L],com[9];
	for(i=0;i<M;i++)
		 H[i][0]='\0';
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%s %s",com,str);

			if(com[0]=='i'){
				insert(str);
			}else{
				if(find(str)){
					printf("yes\n");
				}else{
					printf("no\n");
		}
	}
}
return 0;
}

Measured memory_bytes: 14916
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll a[Max],b[Max];
ll n,m,k,res; 
struct BIT {
private:
	vector<ll> node; int n;
public:
	void init(int n_) {
		n = n_; node.resize(n, 0);
	}
	//0-indexed
	void add(int a, ll w) {
		for (int i = a; i < n; i |= i + 1)node[i] += w;
	}
	//[0,a)
	ll sum(int a) {
		ll ret = 0;
		for (int i = a - 1; i >= 0; i = (i&(i + 1)) - 1)ret += node[i];
		return ret;
	}
	//[a,b)
	ll sum(int a, int b) {
		return sum(b) - sum(a);
	}
};
void solve(){
	ll N,A,B;
	cin>>N>>A>>B;
	cout<<A*(N/(A+B))+min(A,N%(A+B));
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int h = 0;
    int count = 0;
    for (int i = 0; i < N; i++) {
        int H;
        cin >> H;

        if (H >= h) {
            h = H;
            count++;
        }
    }

    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a,b,d,r;
    double f;
    scanf("%d %d",&a, &b);
    
    d = a/b;
    r = a%b;
    f = (double)a/b;
    
    printf("%d %d %lf\n",d, r, f);
    return 0;
}


Measured memory_bytes: 2108
adj = Array.new
n = gets.to_i
n.times do
  l = gets.split.map(&:to_i)
  adj << [l[0], l[2..-1]]
end
adj.sort.each do |v|
  arr = Array.new(n,0)
  v[1].each{|i| arr[i-1]=1}
  puts arr.join(" ")
end

Measured memory_bytes: 8836
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication28
{
    class Program
    {
        static void Main(string[] args)
        {
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                double a = double.Parse(line);
                if (a <= 48)
                    Console.WriteLine("light fly");
                else if (a <= 51) 
                Console.WriteLine("fly");
                else if (a <= 54)
                    Console.WriteLine("bantam");
                else if (a <= 57)
                    Console.WriteLine("feather");
                else if (a <= 60)
                    Console.WriteLine("light");
                else if (a <= 64)
                    Console.WriteLine("light welter");
                else if (a <= 69)
                    Console.WriteLine("welter");
                else if (a <= 75)
                    Console.WriteLine("light middle");
                else if (a <= 81)
                    Console.WriteLine("middle");
                else if (a <= 91)
                    Console.WriteLine("light heavy");
                else if (a > 91)
                    Console.WriteLine("heavy");
            }
        }
    }
}

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


int main(void)
{
	//変数の宣言
	int d,n;
	
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int min;
	//データの読み込み
	scanf("%d %d",&d,&n);
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	if(d==0){
		d=1;
	}else if(d==1){
		d=100;
	}else{
		d=10000;
	}
	
	
	
//	printf("計算部分終了\n");
	//出力
	
	if(n!=100){
		printf("%d",n*d);
	}else{
		printf("%d",101*d);
	}
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
#define int long long
using namespace std;
const int N=1e5+100;
int n,ans;
int get(int x)
{
	int cnt=0;
	while (x) cnt+=x%10,x/=10;
	return cnt;
}
signed main()
{
	scanf("%lld",&n);ans=inf;
	for (int i=1;i<n;i++) ans=min(ans,get(i)+get(n-i));
	printf("%lld\n",ans);
}

Measured memory_bytes: 3796
x,k,d = map(int,input().split())

kd = k * d

if(x + kd < 0):
    print(0 - x - kd)
elif(x - kd > 0):
    print(x - kd)
else:
    if(x < 0):
        x *= -1
    if(k%2 == 1):
        x += d
    xd = x % (d*2)
    xd2 = d*2 - xd
    print(min(xd,xd2))


Measured memory_bytes: 9080
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main() {

	string str;
	int a = 0;
	int i[1000] = {0};
	int j[1000] = {0};

	getline(cin,str);

	while(1) {
		a = str.find("peach",a);
		if(a == -1) {
			break;
		}
		i[a] = 1;
		a = a + 5;
		
	}

	a = 0;

	while(1) {
		a = str.find("apple",a);
		if(a == -1) {
			break;
		}
		j[a] = 1;
		a = a + 5;
	}

	for (int k = 0; k < str.size(); k++) {
		if (i[k] == 1) {
			cout << "apple";
			k = k + 4;
		}

		else if (j[k] == 1) {
			cout << "peach";
			k = k + 4;
		} 

		else {
			cout << str.substr(k,1);
		}
	}

	cout << endl;

	return 0;
}

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

int main(){
	ll a,b;
	cin >> a >> b;
	ll g = __gcd(a,b);
	ll ans = 1;
	for (ll i = 2; i*i <= g; ++i) {
		if(g % i == 0){
			while(g % i == 0){
				g /= i;
			}
			ans++;
		}
	}
	if(g != 1) ans++;
	cout << ans << endl;
    return 0;
}



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

using namespace std;

#define GRAPH_SIZE 300
static vector<uint32_t> graph[GRAPH_SIZE];
static vector<uint32_t> graph0[GRAPH_SIZE];

int32_t main()
{
  uint32_t N;
  cin >> N;

  for (uint32_t i = 0; i < N; i++) {
    for (uint32_t _ = 0; _ < N; _++) {
      uint32_t weight;
      cin >> weight;
      graph[i].push_back(weight);
      graph0[i].push_back(weight);
    }
  }

  for (uint32_t i = 0; i < N; i++) {
    for (uint32_t j = 0; j < N; j++) {
      bool has_same = false;
      for (uint32_t k = 0; k < N; k++) {
        uint32_t weight = graph[i][j];
        uint32_t weight0 = graph[i][k];
        uint32_t weight1 = graph[k][j];
        if ((weight0 + weight1) < weight) {
          cout << -1 << endl;
          return 0;
        }
        if ((k != i) && (k != j) && ((weight0 + weight1) == weight)) {
          has_same = true;
        }
      }
      if (has_same) {
        graph0[i][j] = 0;
      }
    }
  }

  uint64_t weights = 0;
  for (uint32_t i = 0; i < N; i++) {
    for (uint32_t j = i; j < N; j++) {
      weights += graph0[i][j];
    }
  }

  cout << weights << endl;

  return 0;
}



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

namespace ConsoleApp64
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);

            int[] A = new int[N];

            for (int i = 0; i < N; i++)
            {
                A[i] = 0;
            }
            for (int m = 0; m < M; m++)
            {
                string[] input2 = Console.ReadLine().Split(' ');
                int a = int.Parse(input2[0]);
                int b = int.Parse(input2[1]);

                A[a - 1]++;
                A[b - 1]++;
            }
            
            for(int i = 0; i < N; i++)
            {
                Console.WriteLine(A[i]);
            }

        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
ll dp[201010]; ll sum[201010];
int main(){
  ll N;  cin >> N;
  vector<ll> C(N);
  for(ll i = 0; i < N; i++){ cin >> C[i];}
  
  for(ll i = 0; i < 201010; i++){ dp[i] = 0; sum[0] = 0;}
                                  
  //同じものは圧縮する
  vector<ll> vec;
  ll head = 0; ll tail = 0;
  while( head < N){
    while( tail < N && C[head] == C[tail]){ tail++;}
   vec.push_back(C[head]);
   head = tail;}
  
  dp[0] = 1;  sum[vec[0]]++;
  
  for(ll i = 0; i <(ll)vec.size()-1; i++){ ll color = vec[i+1];
    dp[i+1] += dp[i] + sum[color]; dp[i+1] %= MOD;
    sum[color] += dp[i]; sum[color] %= MOD;}
 
  cout << dp[(ll)vec.size()-1] % MOD << endl; return 0;}
 
  

Measured memory_bytes: 6640
s = gets.chomp

if s.size == 1
  p 0
  exit
end

bs = s.chars

p bs.each_cons(2).map { |a, b| a == b }
    .each_with_index.select { |v, _i| v }
    .map(&:last)
    .map(&:succ)
    .each_slice(2).map { |a, b| b ? (a...b).size : 1 }
    .reduce(0, :+)


Measured memory_bytes: 17784
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
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;}
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll H,W;cin>>H>>W;
    vvl dp(H,vl(W));
    char info[H][W];
    rep(i,H)rep(j,W)cin>>info[i][j];
    rep(i,H)rep(j,W){
        if(info[i][j]=='#')continue;
        if(i+j==0)dp[i][j]=1;
        if(i>0 and info[i-1][j]=='.')dp[i][j]+=dp[i-1][j];
        if(j>0 and info[i][j-1]=='.')dp[i][j]+=dp[i][j-1];
        dp[i][j]%=MOD;
    }
    cout<<dp[H-1][W-1]<<endl;
    return 0;
}

Measured memory_bytes: 9088
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      q: usize,
      h: usize,
      s: usize,
      d: usize,
      n: usize,
    }

    let mut ans = n*4*q;
    ans = min(ans, n*2*h);
    ans = min(ans, n*1*s);
    ans = min(ans, n/2*d + n%2 * q*4);
    ans = min(ans, n/2*d + n%2 * h*2);
    ans = min(ans, n/2*d + n%2 * s);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() {
// Time Complexity: O(N)
// Space Complexity: O(N)
int n;
cin >> n;
long a[n + 1], dp[n + 1], odds[n + 1];
dp[0] = dp[1] = 0;
for (int i = 1; i <= n; ++i) cin >> a[i];
for (int i = 1; i <= n; i += 2)
odds[i] = (i == 1 ? 0 : odds[i - 2]) + a[i];
for (int i = 2; i <= n; ++i)
dp[i] = max(a[i] + dp[i - 2], i % 2 ? dp[i - 1] : odds[i - 1]);
cout << dp[n] << '\n';
return 0;
}

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

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

  if ( a + b == c + d ) {
    cout << "Balanced" << endl;
  }
  if ( a + b > c + d ) {
    cout << "Left" << endl;
  }
  if ( a + b < c + d ) {
    cout << "Right" << endl;
  }
 
}


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

int main(){
    int n;
    cin>>n;
    int a,b,c;
    int d,e,f;
    cin>>a>>b>>c;
    n--;
    int s1=a,s2=b,s3=c;
    while(n--){
        cin>>d>>e>>f;
        a=s1;b=s2;c=s3;
        s1=max(d+b,d+c);
        s2=max(e+a,e+c);
        s3=max(f+a,f+b);
        
        
    }
    cout<<max(s1,max(s2,s3));
    
    return 0;
}

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

#define pb push_back
using ll = long long;

const int mx = 1e5+5;
const int inf = 1e9+9;
const int mod = 1e9+7;

int main(int argc, const char** argv) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll x; cin >> x;
    ll ans = (x/500)*1000;
    x %= 500;
    ans += (x/5)*5;
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define mod 1000000007
using namespace std;
#define LL long double
int main() 
{

    
    string s;
    string t;
    cin >> s>>t;
    LL n=s.size();
    LL m=t.size();
    LL ans=m;
    for(LL i=0;i<n-m+1;i++)
    {
        LL count=0;
        string q;
        q=s.substr(i,m);
        for(LL j=0;j<m;j++)
        {
            if(t[j]!=q[j])
                count++;
        }
        ans=min(count,ans);
    }
    cout<<ans;

}
 
 

Measured memory_bytes: 3728
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n = 0; string s; int test[30] = { 0 };
	while (cin >> s) {
		for (int h = 0; h < s.size(); h++) {
			if (s[h] == 'a' || s[h] == 'A') { test[0]++; }
			if (s[h] == 'b' || s[h] == 'B') { test[1]++; }
			if (s[h] == 'c' || s[h] == 'C') { test[2]++; }
			if (s[h] == 'd' || s[h] == 'D') { test[3]++; }
			if (s[h] == 'e' || s[h] == 'E') { test[4]++; }
			if (s[h] == 'f' || s[h] == 'F') { test[5]++; }
			if (s[h] == 'g' || s[h] == 'G') { test[6]++; }
			if (s[h] == 'h' || s[h] == 'H') { test[7]++; }
			if (s[h] == 'i' || s[h] == 'I') { test[8]++; }
			if (s[h] == 'j' || s[h] == 'J') { test[9]++; }
			if (s[h] == 'k' || s[h] == 'K') { test[10]++; }
			if (s[h] == 'l' || s[h] == 'L') { test[11]++; }
			if (s[h] == 'm' || s[h] == 'M') { test[12]++; }
			if (s[h] == 'n' || s[h] == 'N') { test[13]++; }
			if (s[h] == 'o' || s[h] == 'O') { test[14]++; }
			if (s[h] == 'p' || s[h] == 'P') { test[15]++; }
			if (s[h] == 'q' || s[h] == 'Q') { test[16]++; }
			if (s[h] == 'r' || s[h] == 'R') { test[17]++; }
			if (s[h] == 's' || s[h] == 'S') { test[18]++; }
			if (s[h] == 't' || s[h] == 'T') { test[19]++; }
			if (s[h] == 'u' || s[h] == 'U') { test[20]++; }
			if (s[h] == 'v' || s[h] == 'V') { test[21]++; }
			if (s[h] == 'w' || s[h] == 'W') { test[22]++; }
			if (s[h] == 'x' || s[h] == 'X') { test[23]++; }
			if (s[h] == 'y' || s[h] == 'Y') { test[24]++; }
			if (s[h] == 'z' || s[h] == 'Z') { test[25]++; }
		}
	}
	cout << "a : " << test[0] << endl;
	cout << "b : " << test[1] << endl;
	cout << "c : " << test[2] << endl;
	cout << "d : " << test[3] << endl;
	cout << "e : " << test[4] << endl;
	cout << "f : " << test[5] << endl;
	cout << "g : " << test[6] << endl;
	cout << "h : " << test[7] << endl;
	cout << "i : " << test[8] << endl;
	cout << "j : " << test[9] << endl;
	cout << "k : " << test[10] << endl;
	cout << "l : " << test[11] << endl;
	cout << "m : " << test[12] << endl;
	cout << "n : " << test[13] << endl;
	cout << "o : " << test[14] << endl;
	cout << "p : " << test[15] << endl;
	cout << "q : " << test[16] << endl;
	cout << "r : " << test[17] << endl;
	cout << "s : " << test[18] << endl;
	cout << "t : " << test[19] << endl;
	cout << "u : " << test[20] << endl;
	cout << "v : " << test[21] << endl;
	cout << "w : " << test[22] << endl;
	cout << "x : " << test[23] << endl;
	cout << "y : " << test[24] << endl;
	cout << "z : " << test[25] << endl;
}


Measured memory_bytes: 3184
while 1:
	a,b,c=map(int,raw_input().split())
	if a==0:break
	t=[2]*(a+b+c)
	m=input()
	tests=sorted([map(int,raw_input().split()) for i in range(m)],key=lambda x:x[3])[::-1]
	for test in tests:
		na,nb,nc=test[0]-1,test[1]-1,test[2]-1
		if test[3]==1:
			t[na],t[nb],t[nc]=1,1,1
		else:
			ls=[t[na],t[nb],t[nc]]
			if ls.count(1)==2 and 2 in ls:
				if t[na]==2:t[na]=0
				if t[nb]==2:t[nb]=0
				if t[nc]==2:t[nc]=0
	for i in t:
		print i

Measured memory_bytes: 4396
#include <stdio.h>

int main (void)
{

int i, x;
for(i = 1; i <= 10000; i++)
{
	
	scanf("%d", &x);
		if( x==0 ){
			break;
		}
	printf("Case %d: %d\n", i, x);

}

return 0;
}

Measured memory_bytes: 1752
#include <iostream>
#include <string>
using namespace std;
#define MOD 1000000007

int main(int argc, char const *argv[]) {
  long long n,m;
  cin>> n >> m;
  if(n*2>=m){
    cout<<m/2<<endl;
  }else{
    cout<< n + (m - n*2)/4 <<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
const int N=105;
int n,ed,tot,fir[N],a[N],path[N],fa[N],dis[N],mx[N];
struct Edge{int v,nxt;}e[N*2];
void addedge(int x,int y){
  e[++ed].v=y;e[ed].nxt=fir[x];fir[x]=ed;
}
void dfs1(int x,int y){
  for(int i=fir[x];i;i=e[i].nxt)if(e[i].v!=y){
    fa[e[i].v]=x;
    dis[e[i].v]=dis[x]+1;
    dfs1(e[i].v,x);
  }
}
void add(int x,int y,int z){
  int sons=0;
  for(int i=fir[x];i;i=e[i].nxt)if(e[i].v!=y){
    add(e[i].v,x,z+1);
    ++sons;
  }
  mx[z]=max(mx[z],sons);
}
ll calc(){
  ll res=1;
  for(int i=0;i<=n;++i)if(mx[i]){
    //printf("mx %d %d\n",i,mx[i]);
    res*=mx[i];
    mx[i]=0;
  }
  //printf("cal %I64d\n",res);
  return res;
}
int main(){
  //freopen("C:/dasin/aa.in","r",stdin);
  int i,j;
  scanf("%d",&n); 
  for(i=1;i<n;++i){
    int x,y;scanf("%d%d",&x,&y);
    addedge(x,y);addedge(y,x);
  }
  dfs1(1,0);
  int s,t;
  for(s=i=1;i<=n;++i)if(dis[i]>dis[s])s=i;
  dis[s]=0;
  dfs1(s,0);
  for(t=i=1;i<=n;++i)if(dis[i]>dis[t])t=i;
  for(i=t;i!=s;i=fa[i])path[++tot]=i;path[++tot]=i;
  printf("%d ",(tot+1)/2);
  ll ans=((1LL<<62)-1)*2+1;
  if(dis[t]&1){
    int x=path[tot/2];
    int y=path[tot/2+1];
    add(x,y,0);
    add(y,x,0);
    ans=calc()*2;
  }else{
    int x=path[tot/2+1];
    add(x,0,0);
    ans=calc();
    for(i=fir[x];i;i=e[i].nxt){
      add(e[i].v,x,0);
      add(x,e[i].v,0);
      //printf("add %d %d\n",e[i].v,x);
      ans=min(ans,calc()*2);
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 256