akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.util.Map;
import java.util.Arrays;
import static java.util.stream.Collectors.*;
import static java.util.function.Function.*;
 
public class Main { //クラス名はMain
    public static void main(String[] args) {
      //整数の入力
      Scanner sc = new Scanner(System.in);
      int n = Integer.parseInt(sc.next());
      
      //重複はSetでいい
      List<String> numList = new ArrayList<>();
      for (int i=0; i<n; i++) {
          String di = sc.next();
          numList.add(di);
      }

      
      Map<String, Long> map = numList.stream().collect(groupingBy(identity(), counting()));
      List<String> List = Arrays.asList("AC","WA","TLE","RE");
      for(String num : List){
        Long value = map.get(num);
        if(value != null){
      		System.out.println(num + " x " + map.get(num));
        }else{
        	System.out.println(num + " x " + 0);
        }
      }
    }
}

Measured memory_bytes: 64952
#include <stdio.h>
#include <stdlib.h>
int main()
{
    long long int len;
    scanf("%lld",&len);

    long long int n,m;
    scanf("%lld %lld",&n,&m);

    if(len==1)
    {
        if(n==m)
            printf("1\n");
        else
            printf("0\n");
    }
    else
    {
        if(n>m)
            printf("0\n");
        else
        {
          long long int min=n*(len-1)+m;
          long long int max=n+(len-1)*m;
          printf("%lld\n",max-min+1);
        }

    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define pb emplace_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define PI acosl(-1.0)
#define mp(a, b) make_pair(a, b)
#define eps 1e-9
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
const int N = 1e5 + 10;
const ll INF = 1LL << 60;
ll iv[N];
ll powM(ll a, ll b){ll res = 1;for(;b;a=a*a%M,b/=2) if(b&1) res=res*a%M;return res;}
ll nckbig(int n, int k){ll ans = 1;for(int i=1; i<=k; ++i){ans = ans*(n-i+1)%M*iv[i]%M;}return ans;}
void caliv(){iv[1] = 1;for(int i=2; i<N; i++){iv[i] = M-M/i*iv[M%i]%M;}}
ll f1[N], f2[N];
void calf(){f1[0] = f2[0] = 1;for(int i=2; i <N; ++i){f1[i] = f1[i-1]*i%M;f2[i] = f2[i-i]*iv[i]%M;}}
ll nck(int n, int k){return f1[n]*f2[n-k]%M*f2[k]%M;}
ll npk(int n, int k){return f1[n]*f2[n-k]%M;}
void Rnck(int big){if(big){caliv();}else{calf();}}

void solve()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif
	int x;
	cin>>x;
	int ans = x / 2 + x%2;
	cout<<ans<<endl;
}


int main()
{
    FAST
    ll Tests = 1;
    //cin>>Tests;
    while(Tests--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
	int x, y, z;
	cin >> x >> y >> z;
	x -= z;
	cout << x / (y + z) << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int a, b;
  scanf("%d %d", &a, &b);

  int ans = a - 1;
  if (a <= b) ans++;  
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

const int mod = 1e9+7;

int n;
int q;
int l[N];
int r[N];
int tim = 1;
int disc[N];
long long cm[N];
vector < int > adj[N];

void dfs(int u , int p){
     for(auto v : adj[u]){
        if(v == p)
            continue;
        cm[v] += cm[u];
        dfs(v , u);
     }
}

void dfs1(int u , int p){
     for(auto v : adj[u]){
        if(v == p)
            continue;
        dfs(v , u);
        cm[u] += cm[v];
     }
}

int main(){
    scanf("%d%d" , &n , &q);
    for(int i = 1; i < n; i++){
        int u , v;
        scanf("%d%d" , &u , &v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    while(q--){
        int p , x;
        scanf("%d%d" , &p , &x);
        cm[p] += x;
    }
    dfs(1 , -1);
    for(int i = 1; i <= n; i++){
        printf("%lld " , cm[i]);
    }
}


Measured memory_bytes: 26240
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int h,w,n;
    in>>h>>w>>n;
    cout<<(n-1)/max(h,w)+1<<endl;
}

Measured memory_bytes: 256
c = list(input())
ans = [0, 0]
for i in range(len(c)):
    if i % 2 == 0 and c[i] == '0' or i % 2 == 1 and c[i] == '1':
        ans[0] += 1
    if i % 2 == 0 and c[i] == '1' or i % 2 == 1 and c[i] == '0':
        ans[1] += 1
print(min(ans))

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

#define crap ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CN cout<<"NO\n"
#define CY cout<<"YES\n"

using namespace std;
using ll = long long;
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
// #define MAXN 1000001 
// ll sieve[MAXN]; 
// void makesieve()
// {
//     sieve[1] = 1; 
//     for (int i = 2; i < MAXN; i++) 
//         sieve[i] = i; 
//     for (int i = 4; i < MAXN; i += 2) 
//         sieve[i] = 2; 
//     for (int i = 3; i * i < MAXN; i++) { 
//         if (sieve[i] == i) { 
//             for (int j = i * i; j < MAXN; j += i) 
//                 if (sieve[j] == j) 
//                     sieve[j] = i; 
//         } 
//     } 
// }
ll powerflow(ll x, ll n)
{
    ll res;
    if (n == 0) {
        return 1;
    }
    res = powerflow(x, n-1);             // recurse
    if(INT_MAX / res < x) {          // check for overflow
        return -1; //LONG_MAX;
    }
    return x * res;
}
struct compare  
 {  
   bool operator()(const int& l, const int& r)  
   {  
       return l > r;  
   }  
 };
void solve()
{
    ll a,b,c,d; cin>>a>>b>>c>>d;
    ll ans=a*c;
    ans=max(ans,a*c);
    ans=max(ans,a*d);
    ans=max(ans,b*c);
    ans=max(ans,b*d);
    cout<<ans;
}
int main()
{
    crap;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin) ;
        freopen("output.txt","w", stdout) ;
        freopen("error.txt","w", stderr) ;
    #endif
    int t;t=1;
    //cin>>t;
    while(t--)
        {solve();}
    return 0;
}

Measured memory_bytes: 3648
N,M=map(int,input().split())
k=M
s=0
A=[list(map(int,input().split())) for i in range(N)]
A=sorted(A,key=lambda x:x[0])
while k>0:
  for i in range(N):
    if k>A[i][1]:
      s+=A[i][0]*A[i][1]
      k=k-A[i][1]
    else:
      s+=A[i][0]*k
      k=0
print(s)

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

int main()
{
    int n;
    cin >> n;
    unordered_map<string, priority_queue<int>> mp;
    unordered_map<int, int> ind;
    vector<string> s;
    rep(i, n)
    {
        string city;
        int px;
        cin >> city >> px;
        s.push_back(city);
        mp[city].push(px);
        ind[px] = i + 1;
    }
    sort(s.begin(), s.end());
    rep(i, n)
    {
        while (!mp[s[i]].empty())
        {
            int x = mp[s[i]].top();
            cout << ind[x] << endl;
            mp[s[i]].pop();
        }
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  ll N;
  cin>>N;
  VL B(N);
  rep(i,N) cin>>B[i];
  ll sum=0;
  rep(i,N) sum+=B[i];
  int ans=1;
  if(sum%(N*(N+1)/2)) ans=0;
  ll cnt=sum*2/N/(N+1);
  VL A(N);
  rep(i,N) A[i]=B[(i+1)%N]-B[i];
  rep(i,N) A[i]=cnt-A[i];
  rep(i,N){
    if(A[i]<0 or A[i]%N) ans=0;
    cnt-=A[i]/N;
  }
  if(cnt!=0) ans=0;
  cout<<(ans?"YES":"NO")<<endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
int n,m;


ll sum[100005];
ll len(int i,int j){
    if(i>j)return 0;
    return sum[i]-sum[j+(j-i)%2];
}

ll s[100001],t[100001];
ll p[100001];


int main(void){
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++){
        scanf("%lld %lld",&s[i],&t[i]);
    }
    p[0]=0;
    for(int i=0;i<m;i++){
        scanf("%lld",&p[i]);
    }
    sort(p,p+m);
    sum[m-2]=p[m-1]-p[m-2];
    for(int i=m-1;i>1;i--){
        sum[i-2]=sum[i]+p[i-1]-p[i-2];
    }
    ll res=0;
    for(int i=0;i<n;i++){
        ll a=min(s[i],t[i]),b=max(s[i],t[i]);
        int l=lower_bound(p,p+m,a)-p;
        int r=lower_bound(p,p+m,b)-p-1;
        if(l==m || r==-1 || l>r){
            res+=b-a;
            continue;
        }
        if(s[i]<t[i] || (r-l)%2==1)res+=p[l]-a;
        if(s[i]>t[i] || (r-l)%2==1)res+=b-p[r];
        if(s[i]<t[i])res+=len(l+1,r);
        else res+=len(l+(l+r)%2,r);
    }
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 4168
s = input()
d = [[0]*2 for _ in range(len(s)+1)]
count_r = 0
count_l = 0
ans = 0
for i in range(len(s)):
    if s[i] == "<":
        d[i+1][0] = d[i][0]+1
    else:
        d[i+1][0] = 0
for i in range(len(s)-1, -1, -1):
    if s[i] == ">":
        d[i][1] = d[i+1][1]+1
    else:
        d[i][1] = 0
for i in range(len(s)+1):
    ans += max(d[i])
print(ans)

Measured memory_bytes: 70568
n,m=map(int, input().split()) 
a=list(map(int, input().split()))
s=[list(map(int, input().split())) for i in range(m)]

ans=sum(a)
cnt=0

a.sort()
s=sorted(s, key=lambda x :x[1])
s.reverse()

for i in range(m):
    
        
        for j in range(cnt,s[i][0]+cnt):
            if s[i][1]>a[j]:
                ans+=s[i][1]-a[j]
                cnt+=1
                if j==n-1:
                    print(ans)
                    exit()
            else:
                break
                
print(ans)

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

using dbl=double;
using ll=long long;
using pii=pair<int, int>;
using pll=pair<ll, ll>;

#define sz(a) ((int)a.size())
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define forse(i,s,e) for(int i=(int)s;i<(int)e;i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

const dbl PI=3.141592653589793;


void solve(){
	int n;
	cin >> n;
	int out=0;
	forn(i,n){
		int k;cin >> k;
		out+=(((i+1)&1)&&(k&1));
	}
	cout << out;
}

int main() {
//	ios::sync_with_stdio(0);
//	cin.tie(0); 
	int T=1;
//	cin >> T;
	for(int c=1;c<=T;c++){
		solve();
	}
}


Measured memory_bytes: 3584
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = (1e-10);
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

string solve(int N) {
    vector<int> key(N);
    for (int i = 0; i < N; i++) {
        cin >> key[i];
    }
    string S; cin >> S;
    string ret;

    map<char, int> ctoi;
    map<int, char> itoc;
    for (int i = 0; i < 26; i++) {
        itoc[i] = 'A' + i;
        ctoi[itoc[i]] = i; 
        itoc[i+26] = 'a' + i;
        ctoi[itoc[i+26]] = i+26;
    } 
    for (int i = 0; i < S.length(); i++) {
        ret.push_back(itoc[(ctoi[S[i]] - key[i%N] + 52) % 52]);
    }
    return ret;
}

int main(void) {
    vector<string> ans;
    int N;
    while (1) {
        cin >> N;
        if (!N) break;
        ans.push_back(solve(N));
    }
    for (auto &i : ans) {
        cout << i << endl;
    }
}




Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	cout << (a==b?"Yes":"No");
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
C=list(map(int, input().split()))
m=0
for i in range(1,N):
  m+=B[A[i-1]-1]
  if A[i-1]-A[i]==-1:
    m+=C[A[i-1]-1]
m+=B[A[-1]-1]
print(m)

Measured memory_bytes: 3064
from math import sqrt

def IsPrime(n: int) -> bool:
    cnt = 2
    while cnt * cnt <= n:
        if n % cnt == 0:
            return False
        else:
            cnt += 1
    return True

def main():
    x = int(input())
    while True:
        if (IsPrime(x)):
            print(x)
            exit()
        else:
            x += 1

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define vec vector<ll>
#define ms multiset<ll>
#define f(i,x,n) for(int i=x;i<n;i++)
#define int long long
#define mod 998244353
#define endl "\n"
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int32_t main()
{
    fastio();
    int n;
    cin>>n;
    int a[n],mx=0;
    f(i,0,n)
    {
    	cin>>a[i];
    	if(a[i]>mx)
    		mx=a[i];
    }
    int ct=0,m2=0;
    f(i,0,n)
    {
    	if(a[i]==mx)
    		ct++;
    	if(a[i]!=mx)
    	{
    		if(a[i]>m2)
    			m2=a[i];
    	}
    }
    if(ct>1)
    {
    	f(i,0,n)
    	{
    		cout<<mx<<endl;
    	}
    }
    else
    {
    	f(i,0,n)
    	{
    		if(a[i]==mx)
    			cout<<m2<<endl;
    		else
    			cout<<mx<<endl;
    	}
    }

}

Measured memory_bytes: 3200
//Robs Code
/***********HEADER***************/
#include<bits/stdc++.h>
/***********MACROS***************/
#define ll long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 10000007
#define mxval 1e9
#define grt [](auto x,auto y){return x>y;}
#define pii pair<ll,ll>
/*********VARIABLE****************/
using namespace std;
ll i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/***********MAIN******************/
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
    bool flag=0;
    if(n&1) n--,flag=1;
    vector<pii> v;
    {
        for(i=1;i<=(n/2);i++){
            for(j=i+1;j<=n-i;j++){
                v.pb({i,j});
            }
            for(j=i+1;j<=n-i;j++){
                v.pb({n-i+1,j});
            }
        }
    }
    if(flag==1)
    for(i=1;i<=n;i++){
        v.pb({n+1,i});
    }
    cout<<v.size()<<endl;
    for(auto x: v){
        cout<<x._1<<" "<<x._2<<endl;
    }
    return 0;
}
//.........

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <functional>

using namespace std;

int main()
{
    int N;
    cin>>N;
    vector<vector<int>> E(N);
    for (int i=0; i<N-1; i++)
    {
        int x, y;
        cin>>x>>y;
        E[x-1].push_back(y-1);
        E[y-1].push_back(x-1);
    }

    vector<long long> B(N), W(N);
    long long M = 1000000007LL;
    function<void(int, int)> f = [&](int c, int p)
    {
        B[c] = W[c] = 1LL;
        for (int e: E[c])
        if (e != p)
        {
            f(e, c);
            B[c] *= W[e];
            B[c] %= M;
            W[c] *= (B[e] + W[e]);
            W[c] %= M;
        }
    };
    f(0, -1);
    cout<<(B[0]+W[0])%M<<endl;
}


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

using namespace std;

int const maxn = 2e5 + 5;
int a[maxn], b[maxn];

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i] >> b[i];
    }
    sort(a + 1, a + n + 1);
    sort(b + 1, b + n + 1);
    if (n % 2 == 1) cout << b[(n + 1) / 2] - a[(n + 1) / 2] + 1 << '\n';
    else cout << (b[n / 2] + b[n / 2 + 1] - a[n / 2] - a[n / 2 + 1]) + 1 << '\n';
    return 0;
}



Measured memory_bytes: 5220
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, 1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<vector<int>> grid(h, vector<int>(w, -1));
    int now{0};
    for (int i{0}; i < h; i++)
    {
        for (int j{0}; j < w; j++)
        {
            if (a[now] <= 0)
            {
                now++;
            }
            // cout << "dbg:" << now << endl;
            int tmp{j};
            if(i % 2){
                tmp = w - j - 1;
            }
            grid[i][tmp] = now + 1;
            a[now]--;
        }
    }
    // cout << endl;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cout << grid[i][j] << ' ';
        }
        cout << endl;
    }
}

Measured memory_bytes: 384
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <cstring>
using namespace std;
typedef long long int lli;
typedef pair<int,int> P;
const int INF=100000000;
const long long int INF_=1000000000000000000;
 
int N,Cost[20][20],Count[20];
vector<int> T[20];
bool Done[20];

int dfs(int v){
	int result=0;
	Done[v]=true;
	for(int i=0; i<T[v].size(); ++i){
		if(Count[T[v][i]]>1&&!Done[T[v][i]]&&Cost[v][T[v][i]]!=INF){
			int tmp=Cost[v][T[v][i]];
			Cost[v][T[v][i]]=INF;
			result=max(result,tmp+dfs(T[v][i]));
		}
	}
	return result;
}

int main(){
	cin.tie(0);
    ios::sync_with_stdio(0);
    while(cin >> N&&N){
		for(int i=0; i<N; ++i) T[i].clear();
        memset(Done,0,sizeof(Done));
        memset(Count,0,sizeof(Count));
        fill_n((int*)Cost,20*20,INF);
        int sum=0;
        for(int i=0; i<N-1; ++i){
            int a,b,t;
            cin >> a >> b >> t;
            --a; --b;
            T[a].push_back(b);
            T[b].push_back(a);
            Cost[a][b]=Cost[b][a]=t;
            ++Count[a];
            ++Count[b];
        }
        for(int i=1; i<N; ++i){
			if(Count[i]>1){
				for(int j=0; j<T[i].size(); ++j){
					if(Count[T[i][j]]>1||j==0){
						sum+=Cost[i][T[i][j]];
					}
				}
			}
		}
		
		for(int i=0; i<T[0].size(); ++i){
			if(Count[T[0][i]]>1) sum+=Cost[0][T[0][i]];
		}
        cout << sum-dfs(0) << endl;
    }
    return 0;
}

Measured memory_bytes: 1228
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

ll solveSpecial(const vector<int>& S, int cand) {
  ll res = 0;
  for (int i = 0; i < S.size(); i++) {
    int x = S[i];
    if ((cand >> x) & 1) {
      res += i + 1;
    } 
  }
  return res;
}

ll solve(const vector<int>& S, int P) {
  map<int, int> mp;
  ++mp[0];
  ll res = 0;
  int acc = 0, pw = 1;
  for (int i = S.size() - 1; i >= 0; i--) {
    acc += pw * S[i] % P;
    acc %= P; 
    res += mp[acc];
    ++mp[acc];
    pw = pw * 10 % P;
  }
  return res;
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, P;
  string S;
  while (cin >> N >> P >> S) {
    vector<int> X(N);
    for (int i = 0; i < N; i++) X[i] = S[i] - '0';
    ll res;
    if (P == 2) {
      res = solveSpecial(X, (1 << 0) | (1 << 2) | (1 << 4) | (1 << 6) | (1 << 8));
    } else if (P == 5) {
      res = solveSpecial(X, (1 << 0) | (1 << 5));
    } else {
      res = solve(X, P);
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 1668
#include<stdio.h>
#define M 1000000
int main(){
  int n,c,i,j;
  char p[M]={1,1};
  for(i=2;i*i<M;i++){
    if(p[i])continue;
    for(j=i*i;j<M;j+=i)p[j]=1;
  }
  while(scanf("%d",&n)!=EOF){
    for(c=n;n;n--)c-=p[n];
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 1580
import random, copy

D = int(input())
c = list(map(int, input().split()))
s = []
for i in range(D):
    s.append(list(map(int, input().split())))
t = [random.randint(1, 26) for i in range(D)]
dq = [[random.randint(1, D), random.randint(1, 26)] for i in range(10 ** 5)]
last0 = []
last = [0] * 26
score = 0
for i in range(D):
    contest = t[i] - 1
    score += s[i][contest]
    last = [last[i] + 1 for i in range(26)]
    last[contest] = 0
    last0.append(last)
    for j in range(26):
        score -= c[j] * last[j]
ans = t
for i in range(10 ** 5):
    temp = score
    temp2 = copy.copy(t)
    d, q = dq[i][0] - 1, dq[i][1] - 1
    contest = t[d] - 1
    score += s[d][q]
    score -= s[d][contest]
    num = last0[d][q] - last0[d][contest]
    for j in range(d, D):
        if last0[j][q] == 0:
            break
        else:
            score += c[q] * num
            last0[j][q] -= num
    for j in range(d, D):
        if last0[j][contest] == 0:
            if j == d:
                score -= c[contest] * num
                last0[j][contest] += num
                pass
            else:
                break
        else:
            score -= c[contest] * num
            last0[j][contest] += num
    t[d] = q + 1
    if temp < score:
        ans = copy.copy(t)
for i in ans:
    print(i)

Measured memory_bytes: 20204
N,M=map(int,input().split())
A=[0]*N;p=0;q=M
for i in range(N):
  a,b=map(int,input().split())
  A[i]=[b,a]

A.sort(key=lambda x: x[1])
#print(A)
i=0
while q>0:
  if q>=A[i][0]:
    p=p+A[i][0]*A[i][1]
    q=q-A[i][0]
    i=i+1
  else:
    p=p+q*A[i][1]
    q=q-q
    break
print(p)

Measured memory_bytes: 21208
import java.util.*;
import java.util.TreeMap;
import java.util.List;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[] s = sc.next().toCharArray();
    for (char c = 'a'; c <= 'z'; c++) {
      int flag = 1;
      for (int i = 0; i < s.length; i++) {
        if (s[i] == c) {
          flag = -1;
        }
      }
      if (flag == 1) {
        System.out.println(c);
        return;
      }
    }
    System.out.println("None");
  }
}


Measured memory_bytes: 26712
char a[5],R[99];h,b;main(i){for(;scanf("%s%s",R,a)*R[1];h=!printf("%d %d\n",h,b/2-h)){for(b=4;b--;h+=R[b]==a[b])R[R[b]]++,R[a[b]]--;for(i=47;++i<58;R[i]=0)b+=!R[i];}}

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

int main() {
    // input
    int N, M;
    cin >> N >> M;

    // solve
    vector<int> cnt(N, 0);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        cnt[a - 1]++;
        cnt[b - 1]++;
    }

    // output
    for (int i = 0; i < cnt.size(); ++i) {
        cout << cnt[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,n,m,i,j,sum = 0;
    vector<long long int>v;
    map<long long int,long long int>mp;
    set<long long int>s;
    string str;
    cin>>n;
    m = 100;
    while(m<n)
    {
        m+=(m/100);
        sum++;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>

 

using namespace std;

 

int main() 
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(x-r >= 0 && y-r >= 0 && x+r <= w&& y+r <= h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3116
# 自力,配るイメージ
INF=float("inf")
def LI():return list(map(int,input().split()))
h,n=LI()
AB=[LI() for _ in range(n)]  
dp=[0]+[INF]*(h+11000) #max(a)<=10000
for i in range(0,h+1):
  for j,k in AB:
    dp[i+j]=min(dp[i+j],dp[i]+k)
print(min(dp[h:]))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

const ll mod = 3;
const int N = 1e6 + 10, M = 1e7 + 10;
const ll INF = 1e18;
const int inf = 0x3f3f3f3f;
const double eps = 1e-6;

#define pi acos(-1)

int a[N];
int n, k;

bool check(double x)
{
    int cnt = 0;
    for (int i = 1; i <= n && cnt <= k; i++)
    {
        double y = a[i];
        if (y > x)
        {
            cnt += ceil((y - x) / x);
        }
    }
    return cnt <= k;
}

int main()
{
    cin >> n >> k;
    int maxn = 0;
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]), maxn = max(maxn, a[i]);
    double l = 0, r = maxn;
    while (r - l > eps)
    {
        double mid = (l + r) / 2;
        if (check(mid))
            r = mid;
        else
        {
            l = mid;
        }
    }
    int ans = ceil(r);
    printf("%d\n", ans);
    return 0;
}

/*
rwwww
rrwww
rrrww

*/


Measured memory_bytes: 4616
#include<cstdio>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<numeric>
#include<functional>
#include<utility>
#include<stack>
#include<tuple>
#include<math.h>
using namespace std;
const long long int big = 1152921504606846976;
double dig = 98765432100000000;//10の9乗を軽く超えます

//AGC10C
//	1
// 254
//3   6
int N;

vector<int>node[100010];//2次元配列
long long int nost[100010];//上方向にまわる石の数
long long int stone[100010];//元の石の数
int solve(int ter,int parent) {
	int i,tchild;
	long long int max = 0, sum = 0;
	//maxは子ノードのnostの最大値
	if (node[ter].size() == 1) { nost[ter] = stone[ter]; return 0; }
	for (i = 0; i < node[ter].size(); i++) {
		tchild = node[ter][i];
		if (tchild == parent) { continue; }//親ノードは無視する
		solve(tchild, ter);
		if (nost[tchild] == -1) {nost[ter] = -1;return 0;}
		sum += nost[tchild];
		if (max < nost[tchild]) { max = nost[tchild]; }
	}
	nost[ter] = stone[ter] * 2 - sum;
	if (sum < stone[ter]) { nost[ter] = -1; }//合計より自分の石が多いとか無理
	if (sum > stone[ter] * 2) { nost[ter] = -1; }//合計が多すぎて石のペアが作れない。むりぽ.
	if (max > stone[ter]) {nost[ter] = -1;}//最大がでかすぎてペアがそんなに作れなくてむry(
	
	
	return 0;
}
int main(void) {
	int root = 0,a,b,i,j,ans;
	scanf("%d", &N);
	if (N == 2) {
		scanf("%d %d", &a, &b);
		if (a == b) { printf("YES"); }
		else { printf("NO"); }
		return 0;
	}//N==2ならば全てが葉ノードなので別処理
	for (i = 1; i <= N; i++) {
		scanf("%d", &a);
		stone[i] = a;
		nost[i] = a;
	}
	for (i = 0; i < N - 1; i++) {
		scanf("%d %d", &a, &b);
		node[a].push_back(b);
		node[b].push_back(a);
	}
	if (node[N/2].size() > 1) { root = N/2; }
	else { root = node[N/2][0]; }//N/2でなくてもよいが1だと狙い打ち入力でTREそう
	solve(root,0);
	ans = nost[root];
	if (ans == 0) { printf("YES\n"); }
	else { printf("NO\n"); }
	return 0;
}

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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int cmpDsc(const void* a, const void* b){
    lld x = *(lld*)a, y = *(lld*)b;
    if(x < y){
        return 1;
    }
    if(x > y){
        return -1;
    }
    return 0;
}

int main(){
    int n;
    lld a, b;
    scanf("%d %lld %lld", &n, &a, &b);
    a -= b;
    lld h[n];
    rep(i, 0, n){
        scanf("%lld", &h[i]);
    }
    qsort(h, n, sizeof(lld), cmpDsc);
    lld l = 0, r = 10000000000;
    lld p;
    while(l < r){
        p = (l + r) / 2;
        int f = 0;
        lld cnt = p;
        rep(i, 0, n){
            if(p * b < h[i]){
                cnt -= (h[i] - p*b + a - 1) / a;
            }
        }
        if(cnt >= 0){
            r = p;
        }else{
            l = p+1;
        }
    }
    p = (l + r) / 2;
    printf("%lld", p);

    return 0;
}

Measured memory_bytes: 1788
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using ll = long long;
using namespace std;

void solve() {
    string s, t;
    cin>>s>>t;
    for (int i =0;i<s.size();i++) {
        if(s==t){
            cout<<"Yes"<<'\n';
            return;
        } 
        s = s.substr(1, s.size()-1)+s.front();

    }
cout<<"No"<<'\n';

}

int main()
{
    std::ios::sync_with_stdio(false); \
        std::cin.tie(NULL);
    int test=1;
    // cin>>test;
    while (test--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main(void){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(W<x+r||H<y+r||0>x-r||0>y-r){
    printf("No\n");
  }else{
  printf("Yes\n");
  }
 
  
  return 0;
  }

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



int main() {
	int N; cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	uint64_t count = 0;
	int len = 0;
	int tmp = 0;
	for (int i = 0; i < N; i++) {
		while (len > 0 && (tmp & A[i])) {
			len--;
			tmp -= A[i - len - 1];
		}
		if ((tmp & A[i]) == 0) {
			len++;
			count += len;
			tmp += A[i];
		}
	}
	cout << count << endl;

	
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
import functools
import fractions

N, X = map(int, input().split())
x = list(map(int, input().split()))
d = [0]*N
for i in range(N):
    d[i] = abs(x[i]-X)
ans = functools.reduce(lambda a,b: fractions.gcd(a,b), d)
print(ans)

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

using namespace std;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) (int)a.size()
#define fi first
#define se second
#define ar array

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int > pii;
const ll MOD =1e9+7;


void solve(){
	int n; cin >> n;
	vi a(n); 
	for(int i = 0; i < n; ++i)
		cin >> a[i], a[i] -= (i+1);
	sort(all(a));
	
	ll ans=0,s = a[n/2];
	for(int i = 0; i < n; ++i)
		ans += abs(a[i]-s);
	cout << ans;
	
}

int main(){
	int t=1;
	//cin >> t;
	while(t--){
		solve();
		cout <<'\n';
	}
}


Measured memory_bytes: 4008
/*************************************************************************
	> File Name: abc121_c.cpp
	> Author:lynko 
	> Mail: 
	> Created Time: 2019年03月09日 星期六 20时24分27秒
 ************************************************************************/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct node
{
    ll val;
    ll  num;
}a[10010010];
bool cmp(node c,node d)
{
    return c.val<d.val;
}
int main()
{
    int n,m;
    cin>>n>>m;
  for(int i=1;i<=n;i++)
    { 
        cin>>a[i].val>>a[i].num;
    }
    sort(a+1,a+1+n,cmp);
     long long ans=0;
    for(int i=1;i<=n;i++)
    {
          if(m==0)break;
        if(m>=a[i].num)
        {
            m-=a[i].num;
            ans+=a[i].val*a[i].num;
        }else 
        {
            ans+=a[i].val*m;
            break;
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int a[1000000];

int main(){
	int n;
	cin>>n;
	char c;
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		cin>>c;
		if(a[c]!=0);
		else {
			a[c]++;
			sum++;
		}
	}
	if(sum==3) cout<<"Three";
	else cout<<"Four";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#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() {
  string s, p;
  cin >> s >> p;
  int n = s.size(), m = p.size();
  rep(i, n) {
    if (p[0] == s[i]) {
      rep(j, m) {
        int k = i + j;
        if (i + j >= n)
          k = i + j - n;
        if (p[j] == s[k]) {
          if (j == m - 1) {
            cout << "Yes" << endl;
            return 0;
          }
          continue;
        } else
          break;
      }
    }
    if (i == n - 1) {
      cout << "No" << endl;
      return 0;
    }
  }
  return 0;
}


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

int N;
const int MAX_N = 100 + 10;
int d[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> d[i];

    sort(d, d+N);

    int ans = 1;
    for (int i = 1; i < N; i++) {
        if (d[i-1] < d[i]) ans++;
    }

    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n=0,m,a,b,c,d,e;
	long double z,w;
	string str,str2,str3;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b;
	cout<<a+(b-a)*2;







	cout<<endl;
} 


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

  int n, max1 = 0, max2 = 0, pos = 0, k;
  cin >> n;
  for(int i = 1;i <= n;i++){
    cin >> k;
    if(max1 <= k){
      pos = i;
      max2 = max1;
      max1 = k;
    }else if(max2 < k){
      max2 = k;
    }

  }
  for(int i = 1;i <= n;i++){
    //cin >> k;
    if(pos == i){
      cout << max2 << '\n';
    }else{
      cout << max1 << '\n';
    }

  }
  return 0;
}


Measured memory_bytes: 3472
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

# import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    AB = {m + 1: [] for m in range(M+1)}
    for _ in range(M):
        a, b = il()
        AB[a].append(b)
        AB[b].append(a)

    ret = []
    visit = [0] * (N + 1)
    fifoqu = queue.Queue()
    fifoqu.put(1)

    while not fifoqu.empty():
        now = fifoqu.get()
        next = AB[now]
        for n in next:
            if visit[n] != 0:
                continue
            visit[n] = visit[now] + 1
            fifoqu.put(n)
    else:
        if visit[1] == 0:
            print('No')
            exit()
        else:
            visit[1] = 0
            print('Yes')
            for n in range(2, N + 1):
                deep = visit[n]
                rooms = AB[n]
                for room in rooms:
                    if visit[room] == deep - 1:
                        print(room)
                        break


if __name__ == '__main__':
    main()


Measured memory_bytes: 57128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include<bitset>
#include <utility>
using namespace std;
#define rank rankk
#define mp make_pair
#define pb push_back
#define xo(a,b) ((b)&1?(a):0)
//#define LL ll
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,int> pli;
const int INF=0x3f3f3f3f;
const ll INFF=0x3f3f3f3f3f3f3f3fll;
//const ll M=1e9+7;
//const ll maxn=2e5+7;
//const int MAXN=1005;
const int MAX=2e4+5;
const int MAX_N=MAX;
//const int N=55;
const ll MOD=1000000007;
//const double eps=0.00000001;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
inline ll powMM(ll a,ll b,ll M){
    ll ret=1;
    a%=M;
//    b%=M;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
void open()
{
    freopen("1009.in","r",stdin);
    freopen("out.txt","w",stdout);
}
ll q,h,s,d,n;
int main()
{
    scanf("%lld%lld%lld%lld%lld",&q,&h,&s,&d,&n);
    ll tem=min(4LL*q,2LL*h);tem=min(tem,s);//单价
//    ll tem2=(n+1LL)/2LL*d;
    ll tem2=tem*n;

    if(n%2)
        tem2=min(tem2,tem+n/2LL*d);
    else
        tem2=min(tem2,n/2LL*d);
    printf("%lld\n",tem2);
    return 0;
}
/*
10
0
1 1
2 2 2
3 3 3 3
4 4 5 4 4
5 5 4 5 5 5
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string str;
    cin>>str;
    if (str[0] == 'Y' && str[1] == 'A' && str[2] == 'K' && str[3] == 'I')
        cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin >> a;
  int x=0, y=0;
  for(int i=0;i<a;i++){
      string b, c;
      cin >> b >> c;
      if(b > c)x+=3;
      else if(c>b)y+=3;
      else{
          x++;
          y++;
      } 
  }
  cout << x << ' ' << y << endl;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    ll n, m; cin >> n >> m;

    if(n > m) swap(n, m);

    if(n == 1){
        cout << abs(m-2) << endl;
    }
    else if(n == 2){
        cout << 0 << endl;
    }
    else{
        cout << (n-2)*(m-2) << endl;
    }
}

Measured memory_bytes: 256
import fractions
N, M = map(int, input().split())
S = input()
T = input()

def lcm(x, y):
    return (x*y)//(fractions.gcd(x, y))

L = lcm(N, M)
num = lcm(L//N, L//M)

n = (N-1)*(L//N)+1
m = (M-1)*(L//M)+1

if(max(n, m) < num):
    if(S[0] == T[0]):
        print(L)
    else:
        print(-1)
else:
    if(N > M):
        tmp = M//(L//N)
    else:
        tmp = N//(L//M)
    for i in range(tmp):
        if(S[i*L//M] != T[i*L//N]):
            print(-1)
            break
    else:
        print(L)

Measured memory_bytes: 5428
#include <stdio.h>

int main(){
    int h,w;
    int i,j;

    while(1){
        scanf( "%d %d ", &h, &w );
        if( h==0&&w==0 ) break;
        for( i=0;i<h;i++ ){
            for( j=0;j<w;j++ ){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

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

int main(void){
  int k, x;
  cin >> k >> x;
  for(int i = 0; i < 2*k-1; i++){
    cout << x-k+1+i;
    if(i == 2*k-2) cout << endl;
    else cout << " ";
  }
  return 0;
}


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

int n, c, x[100005], v[100005];
int A[100005], maxA[100005];
int B[100005], maxB[100005];

signed main(){
  
  cin>>n>>c;
  
  for(int i=0;i<n;i++) cin>>x[i]>>v[i];
  
  A[0] = v[0] - x[0];
  maxA[0] = max( maxA[0], A[0] );
    
  for(int i=1;i<n;i++){
    A[i] = v[i] - ( x[i] - x[i-1] ) + A[i-1];
    maxA[i] = max( maxA[i], maxA[i-1] );
    maxA[i] = max( maxA[i], A[i] );
  }
  
  B[n-1] = v[n-1] - ( c - x[n-1] );
  maxB[n-1] = max( maxB[n-1], B[n-1] );
  
  for(int i=n-2;i>=0;i--){
    B[i] = v[i] - ( x[i+1] - x[i] ) + B[i+1];
    maxB[i] = max( maxB[i], maxB[i+1] );
    maxB[i] = max( maxB[i], B[i] );
  }
  
  int ans = 0;
  
  for(int i=0;i<n;i++){
    
    ans = max( ans, A[i] );
    
    ans = max( ans, B[i] );
    
    if( i < n - 1 ) ans = max( ans, A[i] - x[i] + maxB[i+1] );
    
    if( i ) ans = max( ans, B[i] - ( c - x[i] ) + maxA[i-1] );
    
  }
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
int main()
{
    int n,m,i,j;
    cin>>n>>m;
    vector<int>v(n);
    lli sum=0;
    for(i=0; i<n; i++)
    {
        cin>>v[i];
        sum+=v[i];
    }
    double s = (double)sum/(4*m);
    for(i=0; i<n; i++)
    {
        if(v[i]>=s)m--;
    }
    if(m>0)
        cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>

using namespace std;
const int N = 1e5 + 100;
const int INF = 0x3f3f3f3f;
int main(){
    int n, T, A;
    cin >> n;
    cin >> T >> A;
    T *= 1000;
    A *= 1000;
    int dif = INF, pos;
    for (int i = 1; i <= n; i ++){
        int x;
        scanf("%d", &x);
        //printf("%d %d\n", T - 6 * x, dif);
        if (abs(A - (T - x * 6)) < dif) {
            pos = i;
            dif = abs(A - (T - x * 6));
        }
    }
    cout << pos << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <cstdio>
using namespace std;
#define PI acos(-1,0)
#define eps 1e-10
#define ll long long
#define mst(ss,b) memset((ss),(b),sizeof(ss))
const int N=10005;
const int mod=1e9+7;
int a[101];
int main()
 {
     int n;
     while(cin>>n){
         int s=0;
         for(int i=0;i<n;i++)
             cin>>a[i];
         sort(a,a+n);
         if(a[0]==a[n-1])
            cout<<s<<endl;
         else{
             s=1000000;
             int t=0,j;
             for(int i=a[0];i<a[n-1];i++){
                 t=0;
                 for(j=0;j<n;j++){
                     t+=(i-a[j])*(i-a[j]);
                 }
                 if(t<s) s=t;
             }
             cout<<s<<endl;
         }
     }
     return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,k,x,sum,cnt;
	scanf("%d %d",&n,&k);
	cnt=1;	sum=1;	n--;
	while(1)	{
		x=sum/k+(sum%k!=0);
		if(x>n)	break;
		cnt++;	n-=x;	sum+=x;
	}
	printf("%d\n",cnt);
	return 0;
}


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

int main()
{
    char s[100001];
    int a[26] = {};
    int i;
    scanf("%s", s);
    int len = strlen(s);
    for (i=0; i<len; i++)
    {
        a[s[i] - 97] = 1;
    }
    for (i=0; i<26; i++)
    {
        if (a[i] == 0) {
            printf("%c\n", i + 97);
            return 0;
        }
    }
    printf("None\n");
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	S, T := ReadString(), ReadString()
	a := make(map[byte]byte)
	b := make(map[byte]byte)

	for i := 0; i < len(S); i++ {
		if ac, exists := a[S[i]]; exists {
			if ac != T[i] {
				fmt.Println("No")
				return
			}
		}
		if bc, exists := b[T[i]]; exists {
			if bc != S[i] {
				fmt.Println("No")
				return
			}
		}
		a[S[i]] = T[i]
		b[T[i]] = S[i]
	}

	fmt.Println("Yes")
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 4548
#include<iostream>
#include<algorithm>
#include<numeric>
#include<cstdint>

int const MAXN = 2000;
int64_t A[MAXN], dp[MAXN+1][MAXN+1];
int N, ix[MAXN];

int64_t iabs(int64_t i) { return std::max(i, -i); }

int main() {
  std::cin >> N;
  for(int i = 0; i < N; ++i) std::cin >> A[i];
  std::iota(ix, ix+N, 0);
  std::sort(ix, ix+N, [&](int l, int r){ return A[l] > A[r]; });
  dp[0][0] = 0;
  for(int i = 1; i <= N; ++i) for(int j = 0; j <= i; ++j) {
    int k = i-j; //min:j max:k
    int64_t tmp = 0;
    if(j>0) tmp = dp[j-1][k] + A[ix[i-1]]*iabs(ix[i-1]-(j-1));
    if(k>0) tmp = std::max(tmp, dp[j][k-1] + A[ix[i-1]]*iabs(ix[i-1]-(N-k)));
    dp[j][k] = tmp;
  }
  int64_t ans = 0;
  for(int i = 0; i <= N; ++i) ans = std::max(ans, dp[i][N-i]);
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 26260