akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cmath>
#include <set>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cstdio>

using namespace std;

constexpr long long mod = 1000000007;
constexpr double eps = 0.0000000001;

namespace arithmetic {
    class utils {
    private:
    public:
        template<typename T>
        static multiset<T> factor(T n) {
            T m = n;
            multiset<T> ret;
            for (T i = 2; i <= m && i * i <= n; i++) {
                while (m % i == 0) {
                    ret.insert(i);
                    m = m / i;
                }
            }
            if (m != 1) ret.insert(m);
            return ret;
        }

        template<typename T>
        static long long gcd(T a, T b) {
            if (b == 0) return a;
            return gcd(b, a % b);
        }

        template<typename T>
        static pair<T, T> extgcd(pair<T, T> a) {
            if (a.second == 0) return make_pair(a.first, 0);
            auto t = extgcd(make_pair(a.second, a.first % a.second));
            return make_pair(t.second, t.first - t.second * (a.first / a.second));
        }

        template<class T>
        class combination {
        private:
            map<pair<T, T>, T> dp;
        public:
            T compute(T n, T k) {
                if (k == 0) return T(1);
                if (dp.find(make_pair(n, k)) == dp.end()) {
                    dp[make_pair(n, k)] = (compute(n - 1, k - 1) * n) / k;
                }
                return dp[make_pair(n, k)];
            }
        };

    };

    template<typename T>
    class modulo {
    private:
        T n = 0;
    public:
        T mod = 1000000007;

        modulo(T n_, T mod_) {
            mod = mod_;
            n = ((n_ % mod) + mod) % mod;
        }

        modulo(T n_) {
            n = ((n_ % mod) + mod) % mod;
        }

        modulo() {
            n = 0;
        }

        explicit operator T() const {
            return n % mod;
        }

        modulo operator+(modulo e) {
            return modulo((n + (T) e) % mod, mod);
        }

        modulo operator-(modulo e) {
            return modulo((n - (T) e) % mod, mod);
        }

        modulo operator*(modulo e) {
            return modulo((n * (T) e) % mod, mod);
        }

        modulo operator/(modulo e) {
            return modulo(((n * utils::extgcd(make_pair((T) e, -mod)).first)) % mod, mod);
        }

        bool operator==(modulo e) const {
            return n == (T) e && mod == e.mod;
        }

        bool operator<(modulo e) const {
            return n == (T) e ? mod < e.mod : n < (T) e;
        }
    };
};

int main() {
    int x, y;
    cin >> x >> y;
    if ((x + y) % 3) {
        cout << 0 << endl;
        return 0;
    }
    int m = (x + y) / 3;
    x -= m;
    y -= m;
    if (x < 0 || y < 0) {
        cout << 0 << endl;
        return 0;
    }
    arithmetic::modulo<long long> c(1);
    for (int i = 1; i <= x; i++) {
        c = c * (y + i) / i;
    }
    cout << (long long) c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin >> N;
  vector<int> btn(N);
  int K=1;
  for (int i=0;i<N;i++){
    cin >> btn.at(i);
  }
  for (int j=0;j<N+1;j++){
    if (btn.at(K-1)==2) {
      cout << j+1 << endl;
      break;
    }
    else K=btn.at(K-1);
    if (j==N) cout << -1 << endl;
  }
}
      
    

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
using namespace std;

#define FOR(i, j, k) for(int i=j ; i<k ; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    ll n, m, d; cin >> n >> m >> d;

    // ll a = ((n - d) * 2 ) * (m - 1) * 2;
    /*
    long double a = n;
    if (d > 0) a = (n - d);
    long double ans = 1;
    REP(i, m - 1) {
        ans *= a / n;
    }
    */

    ll ans1 = (n - d) * (m - 1);
    ll ans2 = n * n;
    if (d > 0) ans1 *= 2;

    cout << setprecision(15) << (long double)ans1 / (long double)ans2 << endl;
    return 0;
}


Measured memory_bytes: 256
#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>;

int main(){
	vector<int> a(3);
	vector<int> b(3);
	rep(i, 3) cin >> a.at(i);
	b.at(0) = abs(a.at(0) - a.at(1));
	b.at(1) = abs(a.at(1) - a.at(2));
	b.at(2) = abs(a.at(2) - a.at(0));
	sort(b.begin(), b.end());
	cout << b.at(0) + b.at(1) << endl;
	return 0;
}

Measured memory_bytes: 256
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

class Comb:
    def __init__(self,n,mo=10**9+7):
        self.fac=[0]*(n+1)
        self.inv=[1]*(n+1)
        self.fac[0]=1
        self.fact(n)
        for i in range(1,n+1):
            self.fac[i]=i*self.fac[i-1]%mo
            self.inv[n]*=i
            self.inv[n]%=mo
        self.inv[n]=pow(self.inv[n],mo-2,mo)
        for i in range(1,n):
            self.inv[n-i]=self.inv[n-i+1]*(n-i+1)%mo
        return
    
    def fact(self,n):
        return self.fac[n]
        
    def invf(self,n):
        return self.inv[n]

    def comb(self,x,y):
        if y<0 or y>x:
            return 0
        return self.fac[x]*self.inv[x-y]*self.inv[y]%mo

show_flg=False
show_flg=True


ans=0

s=input()
l_alp=l_alp*2
ans=l_alp[l_alp.index(s)+1]
print(ans)


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

using namespace std;

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

    int n;
    cin >> n;
    vector<int> b(n-1);
    for (auto &&x : b)
        cin >> x;

    int a_sum = 0;
    for (int i = 0; i < n; i++)
    {
        if(i==0)
        {
            a_sum += b[0];
        }
        else if (i==n-1)
        {
            a_sum += b[n - 1 - 1];
        }
        else
        {
            a_sum += min(b[i], b[i - 1]);
        }
    }

    cout << a_sum << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  vector<bool> list(26, false);
  for (int i = 0; i < s.size(); i++) {
    list[s[i] - 'a'] = true;
  }
  for (int i = 0; i < 26; i++) {
    if (list[i] == false) {
      cout << char('a' + i) << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    string S,T;
    cin >> S >> T;
    long hit = 0;
    for(size_t i=0;i<3; i++)
    {
        if(S[i]==T[i]) hit++;
    }
    cout << hit << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vi vector <ll> 
#define qu queue <ll>
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;
 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl;
*/
 
bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}
 
 
void solve()
{
    float r; cin >> r;
    nout(2*r*3.1415);
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n,m,c=0,s=0,y,z;
    cin>>n>>m;
    int a[n];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        s=s+a[i];
    }
    float x=s*(float)1/(4*m);
    for(j=0; j<n; j++)
    {
        if(a[j]>=x)
        {
            c++;
        }
    }
    if(c>=m)
    {
        cout<<"Yes";
    }
    else
        cout<<"No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rgi register int
#define ll long long
class fastin{
	private: int _ch,_f;
	public: inline fastin& operator>>(char&c) {c=getchar(); return *this;}
		template<typename _Tp> inline fastin& operator>>(_Tp&_x){
		_x=0; while(!isdigit(_ch)) _f|=(_ch==45),_ch=getchar();
		while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
		_f&&(_x=-_x,_f=0); return *this;}
	fastin() {_ch=_f=0;}
}fin;
class fastout{
#define endl '\n'
	private: int _num[32],_head;
	public: inline fastout& operator<<(char c) {putchar(c); return *this;}
		template<typename _Tp> inline fastout& operator<<(_Tp _x){
		_Tp _k; if(_x==0) {putchar('0'); return *this;} if(_x<0) putchar('-'),_x=-_x;
		while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
		while(_head>0) putchar(_num[_head]),--_head; return *this;}
	fastout() {_head=0;}
}fout;
// ----------------------------
#define int ll
// using namespace std;
const int maxn=10000004;
const int mod=998244353,inf=1000000007;

bool isnp[maxn];
signed main()
{
	ll n,siz,ans=0;
	fin>>n;
	siz=std::sqrt(n);
	// fout<<siz<<endl;
	for(rgi i=2;i<=siz;++i)
		if(!isnp[i])
		{
			for(ll j=(ll)i*i;j<=siz;j+=i) isnp[j]=1;
			ll cnt=0;
			while(n%i==0) n/=i,++cnt;
			// fout<<i<<' '<<cnt<<endl;
			ll add,sum;
			for(add=0,sum=0;sum<=cnt;) sum+=++add;
			// fout<<add<<endl;
			ans+=add-1;
		}
	if(n>1) ++ans;
	fout<<ans;
	return 0;
}
// ----------------------------
// by imzzy


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

int main(){
	ll N, n;
	cin >> N;
	n = sqrt(N);
	ll ans = INT32_MAX, cnt;
	string S, T;
	for (ll i = 1;i <= n;i++) {
		if (N%i == 0) {
			S = to_string(i);
			T = to_string(N / i);
			cnt = max(S.size(), T.size());
			ans = min(ans, cnt);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();

            out.println(a * b % 2 == 1 ? "Odd" : "Even");
        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

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

    }
}



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

int main() {
  int R;
  cin >> R;
  if (R < 1200) {
    cout << "ABC" << endl;
  } else if (R < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# vim: set fileencoding=utf-8

# pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation


"""Module docstring
"""

import sys


def solve(values, _nb):
    ca, cb, cc = 0, 0, 0
    for a, b, c in values:
        new_ca = max(cb + b, cc + c)
        new_cb = max(ca + a, cc + c)
        new_cc = max(ca + a, cb + b)
        ca, cb, cc = new_ca, new_cb, new_cc
    return max(ca, cb, cc)


def do_job():
    "Do the work"
    # first line is number of test cases
    N = int(input().strip())
    values = []
    for _ in range(N):
        values.append(map(int, input().split()))
    result = solve(values, N)
    print(result)


def print_output(testcase, result) -> None:
    "Formats and print result"
    if result is None:
        result = "IMPOSSIBLE"
    print("Case #{}: {}".format(testcase + 1, result))


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    do_job()
    return 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    sys.exit(main())


Measured memory_bytes: 58384
#include <bits/stdc++.h>
#define N 1000001
#define f first
#define s second
using namespace std;
typedef pair <int,int> P;
int n,u,v,m,num[N];
P U[N],V[N];

void in(P a[]){
  for(int i=1;i<=n;i++)
    for(int j=1,b;j<=n;j++) cin>>b,a[b]=P(i,j);
}

int game(P A[],int B){
  int ta[501]={},yo[501]={},X[2]={},cnt=0;
  if(n==1)cnt-=3;
  for(int i=0;i<m;i++){
    int y=A[num[i]].f,x=A[num[i]].s;
    if(x==0)continue;
    X[0]+=(x==y);
    X[1]+=(x+y==n+1);
    if(X[0]==n) X[0]=-1e9,cnt++;
    if(X[1]==n) X[1]=-1e9,cnt++;
    cnt+=(++ta[y]==n)+(++yo[x]==n);
    if(cnt>=B)return i;
  }
  return m;
}

int main(){
  cin>>n>>u>>v>>m;
  in(U),in(V);
  for(int i=0;i<m;i++) cin>>num[i];
  int Uscore=game(U,u);
  int Vscore=game(V,v);
  if(Uscore<Vscore) cout <<"USAGI"<<endl;
  else if(Uscore>Vscore)cout <<"NEKO"<<endl;
  else cout<<"DRAW"<<endl;
  return 0;
}

Measured memory_bytes: 17544
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( iter = $ iter : ident , $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut $ iter = s . split_whitespace ( ) ; input_inner ! { $ iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , mut $ var : usize $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , $ var : usize $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , { chars : $ base : expr } ) => { read_value ! ( $ iter , String ) . chars ( ) . map ( | c | ( c as u8 - $ base as u8 ) as usize ) . collect ::< Vec < usize >> ( ) } ; ( $ iter : expr , { char : $ base : expr } ) => { read_value ! ( $ iter , { chars : $ base } ) [ 0 ] } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , char ) => { read_value ! ( $ iter , chars ) [ 0 ] } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
fn rec(n: usize, x: &mut Vec<usize>) {
    if x.len() == n {
        println!(
            "{}",
            x.iter()
                .map(|&p| (p as u8 + 'a' as u8) as char)
                .collect::<String>()
        );
        return;
    }
    let mut s = std::collections::HashSet::new();
    for i in 0..x.len() {
        if s.contains(&x[i]) {
            continue;
        }
        s.insert(x[i]);
        let y = x[i];
        x.push(y);
        rec(n, x);
        x.pop();
    }
    let y = *x.iter().max().unwrap() + 1;
    x.push(y);
    rec(n, x);
    x.pop();
}
fn main() {
    input! { n };
    rec(n, &mut vec![0]);
}


Measured memory_bytes: 5500
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

ll gcd(ll a,ll b){
  if(a%b == 0) return b;
  else return gcd(b,a%b);
}
int main(){
  ll a,b;
  cin >> a >> b;
  ll c = gcd(a,b);
  cout << a*b/c << endl;

  return 0;
}


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

from fractions import gcd
# from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

N = int(input())
A = [int(input()) for i in range(N)]

c = Counter(A)

ret = list(filter(lambda x: x % 2 == 1,  c.values()))

print(len(ret))


Measured memory_bytes: 21776
#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 fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	ll q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;
	q = min(q * 4, min(h * 2, s));
	ll p = min(q * 2, d);
	ll ans = (n / 2) * p + (n % 2 ? q : 0);
	cout << ans << endl;
	return 0;
}

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

int main() {

    char a;
    cin >> a;
    if (a == 'A') {
        cout << 'T';
    }
    else if (a =='C') {
        cout << "G";
    }
    else if (a == 'G') {
        cout << "C";
    }
    else {
        cout << "A";
    }
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }



int main() {
    int h, a; cin >> h >> a;
    cout << (h+(a-1))/a << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Li long long
#define Fasting()  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PuB push_back
#define PoB pop_back
#define All(x) x.begin(), x.end()
#define F first
#define S second

using namespace std;
const int N=1e5+10;
int arr[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;


int main(){
    Fasting();
    cin>>k;
    cout<<arr[k-1];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

using dat = pair<int, int>;
int main() {
    init();


    ll n; cin >> n;

    if (n % 2 == 1)cout << "0\n";
    else {
        ll ans = n / 10;
        for (n /= 10; 0 < n; n /= 5)ans += n / 5;
        cout << ans << "\n";
    }

}

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

using namespace std;

string s;

void init()
{
	cin >> s;
	for (int i = 0; i < 12; ++i)
		{
			if(i == 4) cout << "" << ' ' ;//<< '\n';
			cout << "" << s[i] ;// '\n';
		}	
		cout << "" << "" << '\n';
}

int main()
{

	//#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	//#endif

	init();

	return 0;
}

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

int N, A[200000];

bool check(int X){
    vector<pair<int, int>> V;
    V.emplace_back(0, 0);
    for(int i=1; i<N; i++) if(A[i-1] >= A[i]){
        while(V.back().first > A[i]) V.pop_back();
        if(V.back().first == A[i]){
            V.back().second++;
            while(V.back().second == X){
                int pt = V.back().first;
                V.pop_back();
                if(V.back().first == pt-1){
                    V.back().second++;
                }else{
                    V.emplace_back(pt-1, 1);
                }
            }
        }else{
            V.emplace_back(A[i], 1);
        }
        if(V[0].second > 0) return false;
    }
    return true;
}

int main(){
    cin >> N;
    for(int i=0; i<N; i++) cin >> A[i];
    bool ok1 = true;
    for(int i=1; i<N; i++) if(A[i-1] >= A[i]) ok1 = false;
    if(ok1){
        cout << 1 << endl;
        return 0;
    }

    int ok = N, ng = 1;
    while(ok-ng>1){
        int mid = (ok+ng)/2;
        (check(mid) ? ok : ng) = mid;
    }
    cout << ok << endl;
}


Measured memory_bytes: 1024
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


string S;

void main() {
  try {
    for (; ; ) {
      S = readToken();
      
      long ans;
      long now;
      foreach_reverse (c; S) {
        switch (c) {
          case 'A': {
            if (now % 2 == 0) {
              ans += now / 2;
            } else {
              now = 0;
            }
          } break;
          case 'B': {
            if (now % 2 == 0) {
              now = 0;
            } else {
              ++now;
            }
          } break;
          case 'C': {
            if (now % 2 == 0) {
              ++now;
            } else {
              now = 1;
            }
          } break;
          default: assert(false);
        }
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 2684
from collections import defaultdict
import sys
input = sys.stdin.readline

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

# 素因数分解、リストで返す
#############################################################
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    a.sort()
    return a
#############################################################

primes = defaultdict(int)

for i in range(N):
    p = prime_factorize(A[i])
    p_set = set(p)
    for pi in p_set:
        primes[pi] += 1

# 全て1の時、primesが空になってmaxが取れない
if len(primes) == 0:
    print("pairwise coprime")
    exit()

max_cnt = max(primes.values())
# min_cnt = min(primes.values())

if max_cnt == 1:
    print("pairwise coprime")
elif max_cnt != N:
    print("setwise coprime")
else:
    print("not coprime")


Measured memory_bytes: 177492
//BISMILLAHHIR RAHMANIR RAHIM
#include<bits/stdc++.h>
using namespace std;
typedef long long int            ll;
typedef unsigned long long int   ull;
#define min3(a,b,c)              min(a,min(b,c))
#define F                        first
#define S                        second
#define PB                       push_back
#define MP                       make_pair
#define PI                       2*acos(0.0)
#define MOD                      998244353
int main()
{
    int n,sum=0;
    cin>>n;
    for(int i=1; i<=3; i++){
        sum+=pow(n,i);
    }
    cout<<sum<<endl;
}


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

#define int long long

signed main() {
  vector<char> ca;
  vector<int> la;
  {
    char c;
    while ( cin >> c, c != '$' ) {
      int l;
      cin >> l;
      ca.emplace_back(c);
      la.emplace_back(l);      
    }
  }

  vector<char> cb;
  vector<int> lb;
  {
    char c;
    while ( cin >> c, c != '$' ) {
      int l;
      cin >> l;
      cb.emplace_back(c);
      lb.emplace_back(l);      
    }
  }

  vector<char> cc;
  vector<int> lc;
  {
    char c;
    while ( cin >> c, c != '$' ) {
      int l;
      cin >> l;
      cc.emplace_back(c);
      lc.emplace_back(l);      
    }
  }

  int a = ca.size(), b = cb.size(), c = cc.size();
  vector<char> ansc;
  vector<int> ansl;  
  for ( int i = 0; i < a; i++ ) {
    if ( ca[i] != cb[0] || la[i] < lb[0] ) continue;
    if ( i+b > a ) continue;
    if ( ca[i+b-1] != cb[b-1] ||la[i+b-1] < lb[b-1] ) continue;
    bool flag = true;
    for ( int j = 1; j < b-1; j++ ) {
      if ( ca[i+j] != cb[j] ||la[i+j] != lb[j] ) {
	flag = false;
	break;
      }
    }

    if ( flag ) {
      if ( b == 1 ) {
	for ( int j = 0; j < i; j++ ) {
	  // cout << ca[j] << " " << la[j] << " ";
	  ansc.emplace_back(ca[j]);
	  ansl.emplace_back(la[j]);
	}
	for ( int j = 0; j < c; j++ ) {
	  // cout << cc[i] << " " << lc[j] << " ";
	  ansc.emplace_back(cc[j]);
	  ansl.emplace_back(lc[j]);
	}
	if ( la[i]-lb[0] >= 1 ) {
	  ansc.emplace_back(ca[i]);
	  ansl.emplace_back(la[i]-lb[0]);
	}
	for ( int j = i+b; j < a; j++ ) {
	  // cout << ca[j] << " " << la[j] << " ";
	  ansc.emplace_back(ca[j]);
	  ansl.emplace_back(la[j]);	
	}
	break;  
      } else {
	for ( int j = 0; j < i; j++ ) {
	  // cout << ca[j] << " " << la[j] << " ";
	  ansc.emplace_back(ca[j]);
	  ansl.emplace_back(la[j]);
	}
	// cout << ca[i] << " " << la[i]-lb[0] << " ";
	if ( la[i]-lb[0] >= 1 ) {
	  ansc.emplace_back(ca[i]);
	  ansl.emplace_back(la[i]-lb[0]);
	}
	for ( int j = 0; j < c; j++ ) {
	  // cout << cc[i] << " " << lc[j] << " ";
	  ansc.emplace_back(cc[j]);
	  ansl.emplace_back(lc[j]);
	}
	// cout << ca[i+b-1] << " " << la[i+b-1]-lb[b-1] << " ";
	if ( b > 1 ) {
	  if ( la[i+b-1]-lb[b-1] >= 1 ) {
	    ansc.emplace_back(ca[i+b-1]);
	    ansl.emplace_back(la[i+b-1]-lb[b-1]);
	  }
	}
	for ( int j = i+b; j < a; j++ ) {
	  // cout << ca[j] << " " << la[j] << " ";
	  ansc.emplace_back(ca[j]);
	  ansl.emplace_back(la[j]);	
	}
	break;      
      }
    }
  }

  if ( ansc.size() == 0 ) {
    ansc = ca; ansl = la;    
  }
  
  for ( int i = 0; i < (int)ansc.size(); i++ ) {
    if ( ansl[i] == 0 ) continue;    
    if ( i < (int)ansc.size()-1 ) {
      if ( ansc[i] == ansc[i+1] ) {
	ansl[i+1] += ansl[i];	
      } else {
	cout << ansc[i] << " " << ansl[i] << " ";	
      }
    } else {
      cout << ansc[i] << " " << ansl[i] << " ";	
    }
  }
  cout << '$' << endl;
  
  return 0;
}


Measured memory_bytes: 3212
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

bool used[26];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	rep(i,s.size()){
		int j = (s[i]-'a');
		used[j] = true;
	}
	rep(i,26){
		if(!used[i]){
			char c = ('a'+i);
			cout << c << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;
}


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

int main()
{
	int H, W;
	std::cin >> H >> W;

	std::vector<std::vector<char>> pix_map;
	//領域を指定しないと値の代入時にエラーになった。
	pix_map.resize(H);
	for (int i = 0; i < H; i++) {
		pix_map[i].resize(W);
	}

	char c_buff;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			std::cin >> c_buff;
			pix_map[i][j] = c_buff;
		}
	}

		for (int i = 0; i < H; i++) {
			for (int k = 0; k < 2; k++) {
				for (int j = 0; j < W; j++) {
					std::cout << pix_map[i][j];
				}
				std::cout << std::endl;
			}
		}

    return 0;
}

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

using namespace std;
 
#define ll long long int
#define pb push_back
#define mp make_pair
#define inff 100000
#define ff first
#define ss second
#define sz(x) ((int) (x).size())
#define fast cin.sync_with_stdio(0);cin.tie(0)
#define rep(i,N) for(int i = 0;i < N;i++)
#define frep(i,a,b) for(int i = a;i <= b;i++)
#define pii pair<int , int>
#define pll pair<ll , ll>
#define vii vector<int>
#define vpii vector< pii >
#define fill(A,v) memset(A,v,sizeof(A))
#define setbits(x) __builtin_popcountll(x)
#define print(A,j,k) for(int ii=j;ii<k;ii++)cout<<A[ii]<<" ";cout<<"\n"
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
#define CASES int t;cin>>t;for (int tt = 1;tt <= t;tt++)
#define FILE freopen("inp.txt" , "r" , stdin);
#define ld long double

const int MOD = 1e9 + 7;
const int N = 1e6 + 5;
const int K = (1 << 17) + 10;	
const ll INF = 2e18 + 500;
const int inf = 0x7fffffff;
const int SQRT = 500;
const int lgN = 20;


int main(int argc, char const *argv[])
{
	fast;

	ll a, b, c;
	cin >> b >> a >> c;

	ll eat = min(a + b, c);
	ll ans = eat;
	ans += min(a, eat);
	a -= eat;
	c -= eat;
	if (a > 0) ans += a;
	if (c > 0) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 10000000
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
ll a[N+5];
ll c[N+5];
ll ans[N+5];
void siv()
{
    for(int i=1;i<=N;i++)
    {
        for(int j=i;j<=N;j+=i)
        {
            a[j]++;
        }
    }
    for(int i=1;i<=N;i++)
    {
        ans[i]=a[i]*i;
        c[i]=c[i-1]+ans[i];
    }
}
main()
{
    siv();
    int n;
    cin>>n;
    cout<<c[n];

}


Measured memory_bytes: 238016
#include <bits/stdc++.h>  // This will work only for g++ compiler.

#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define sz(a) int((a).size())


using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

void fast()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
void solve()
{
  ll a,b;
  cin >> a >> b;
  if(a<=b) cout << "0\n";
  else cout << a-b << "\n";
}
int main()
{
  fast();
  solve();

return 0;
}


Measured memory_bytes: 3616
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`

	5
	20
	11 12 9 17 12

	`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	n, k := nextInt(), nextInt()

	ans := 0
	for i := 0; i < n; i++ {
		x := nextInt()
		db := int(math.Abs(float64(x - k)))
		if x < db {
			ans += 2 * x
		} else {
			ans += 2 * db
		}
	}

	fmt.Fprintln(out, ans)
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


Measured memory_bytes: 640
L = input()
n = len(L)
mod = 10**9+7
dp1 = [0]*(n+1)
dp2 = [0]*(n+1)
dp1[0] = 1
for i in range(n):
    if L[i] == "1":
        dp1[i+1] = (dp1[i]*2)%mod
        dp2[i+1] = (dp1[i] + dp2[i]*3)%mod
    else:
        dp1[i+1] = dp1[i]
        dp2[i+1] = (dp2[i]*3)%mod
print((dp1[n]+dp2[n])%mod)

Measured memory_bytes: 11124
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main() {

    string a,b,c; cin >>a>>b>>c;

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




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int h,w;
    cin>>h>>w;
    ll ans=0;
    if(h%2==0||w%2==0)ans=(ll)h*w/2;
    else ans=(ll)h*w/2+1;
    if(h==1||w==1)ans=1;
    cout<<ans<<endl;
    return 0;
}

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


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

int main()
{
    char a[101],b[101],ans[3][16] = {"GREATER","LESS","EQUAL"};
    int ansp = 0;
    scanf("%s %s",a,b);

    int len[2] = {strlen(a),strlen(b)},i,j;

    if(len[0] > len[1])
    {
        ansp = 0;
    }
    else if(len[0] < len[1])
    {
        ansp = 1;
    }
    else
    {
        for (i = 0; i < len[0]; i++)
        {
            if(a[i] > b[i])
            {
                ansp = 0;
                break;
            }
            else if(a[i] < b[i])
            {
                ansp = 1;
                break;
            }
        }
        if(i == len[0])ansp = 2;
    }
    
    printf("%s",ans[ansp]);
}

Measured memory_bytes: 128
def main(text=""):
    n = int(input())
    a = [input() for i in range(n)]
    #a = text.split("\n")[1:]
    num = 0
    for i in range(len(a)):
        a[i] = "".join(sorted(a[i]))
    a.sort()
    i = 0
    while i < len(a):
        e = a[i]
        j = 1
        while i+j < len(a) and e == a[i+j]:
            j = j + 1
        if j != 1:
            num = num + combination(j)
            i = i+j
        else:
            i = i+1
    print(num)


def combination(x):
    return int(x*(x-1)/2)


main()


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

int main()
{
    long long int n;
    int c=0,d=0,e=0,f=0;
    cin>>n;
    string s;
    while(n--)
    {
        cin>>s;
        if(s[0]=='A'&&s[1]=='C')
        {
            c++;
        }
        else if(s[0]=='W'&&s[1]=='A')
        {
            d++;
        }
        else  if(s[0]=='T'&&s[1]=='L'&&s[2]=='E')
        {
            e++;
        }
        else if(s[0]=='R'&&s[1]=='E')
        {
            f++;
        }

    }
    cout<<"AC x "<<c<<endl;
    cout<<"WA x "<<d<<endl;
    cout<<"TLE x "<<e<<endl;
    cout<<"RE x "<<f<<endl;
    return 0;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
long long dp[1<<20] = {0};
int h[1<<20];
 
int main () {
  ios_base::sync_with_stdio(false); cin.tie(0);

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

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

  dp[0] = 0;
  for (int i = 1; i < n; ++i) {
    dp[i] = LLONG_MAX; 
    for (int j = max(0, i - k); j < i; ++j) {
      dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
    }
  }
  cout << dp[n - 1] << '\n';
}


Measured memory_bytes: 2688
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c; cin >> a >> b >> c;
    c -= (a - b);
    cout << max(0, c) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	int k;cin>>k;
	int a,b;cin>>a>>b;
	int q = b/k;
	if(q*k>=a){
		cout<<"OK"<<endl;
	}
	else{
		cout<<"NG"<<endl;
	}
}


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


 
signed main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    rep(i,N) cin >> A[i] >> B[i];
    
    int maxrank=0, score=0;
    rep(i,N){
        if(A[i]>maxrank){maxrank=A[i]; score=B[i];}
    }
    cout << maxrank + score << endl;
    
    
    return 0;
}


Measured memory_bytes: 1792