akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int N=gi();
	    String[] S = new String[N];
	    Map<String, Integer> m = new HashMap<String, Integer>();

	    int max = 1;
	    for (int i=0; i<N; i++) {
	    	S[i] = gs();
	    	if (m.containsKey(S[i])) {
	    		int n= m.get(S[i])+1;
	    		m.put(S[i], n);
	    		if (n>max) max=n;
	    	} else {
	    		m.put(S[i], 1);
	    	}
	    }
	    List<String> ss = new ArrayList<String>();
	    for (Map.Entry<String, Integer> entry : m.entrySet()) {
	    	if (entry.getValue() == max) {
	    		ss.add(entry.getKey());
	    	}
	    }

	    Collections.sort(ss);

	    for (int i=0; i<ss.size(); i++) {
	    	System.out.println(ss.get(i));
	    }
        //System.out.println(c);
//        if (X%Y==0) {
//        	System.out.print("-1");
//        }else{
//        	long c=1;
//        	while(true) {
//        		if (((X*c) %Y) != 0) {
//        			System.out.print(X*c);
//        			return;
//        		}
//        		c++;
//        	}
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
}

Measured memory_bytes: 82484
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using P = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
int INF = 1e9+7;
int A[100000];

int main() {
    int N;
    cin >> N;
    vi Avec(N);
    for (int i=0; i<N; i++) {
        cin >> Avec[i];
        A[Avec[i]] += 1;
    }
    sort(Avec.begin(), Avec.end());

    int arg = 0;
    int maxsum = 0;
    for (int i=1; i<100000;i++) {
        int sum = 0;
        sum += A[i]+A[i-1]+A[i+1];
        maxsum = max(sum,maxsum);
    }
    cout << maxsum << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

int N,T;

signed main(){
  cin>>N>>T;

  int min=10000;
  int cont=0;
  for(int i=0;i<N;i++){
    int c,t;cin>>c>>t;
    if(T>=t){
      if(min>c){
        min=c;
      }
      cont++;
    }
  }

  if(cont==0){
    cout<<"TLE"<<"\n";
    return 0;
  }
  
  cout<<min<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll A,B,FA,FB;
  cin>>A>>B;
  A--;
  
  if(A%4==0) FA=A;
  if(A%4==1) FA=1;
  if(A%4==2) FA=A+1;
  if(A%4==3) FA=0;
  
  if(B%4==0) FB=B;
  if(B%4==1) FB=1;
  if(B%4==2) FB=B+1;
  if(B%4==3) FB=0;
  
  ll ans=FA^FB;
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
int main(void){
  int n,i,j,sum=0,b,sum2=0;
  while(1){
    int a[10]={0};
  scanf("%d",&n);
  if(n==0)break;
  sum2=0;
  for(i=0,sum=0;i<n;i++,sum=0){
    for(j=0;j<n;j++){
      scanf("%d",&b);
      a[j]+=b;
      sum+=b;
      printf("%5d",b);
    }
    printf("%5d\n",sum);
    sum2+=sum;
  }
  for(i=0;i<n;i++)printf("%5d",a[i]);
  printf("%5d\n",sum2);
  }
  return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
 
using namespace std;
 
int main() {
	int n;
	cin >> n;
	long long len[n];
	for(int i=0; i<n; i++){
	    cin >> len[i];
	}
	sort(len,len+n);
	int count=0;
	for(int i=0; i<n-2; i++){
	    for(int j=i+1; j<n-1; j++){
	        for(int k=j+1; k<n; k++){
	            if(len[i]!=len[j] && len[i]!=len[k] && len[j]!=len[k]){
	                if(len[i]+len[j] > len[k]){
	                    count++;
	                }
	            }
	        }
	    }
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
#define inf 1e9
#define F first
#define S second
#define dbg(x) cout<<#x<<" value : "<<x<<"\n";
#define rep(i,j,k) for(int i = (j); i <= (k); i++)
#define rep__(i,j,k) for(int i = (j); i < (k); i++)
#define per(i,j,k) for(int i = (j); i >= (k); i--)
#define per__(i,j,k) for(int i = (j); i > (k); i--)
#define mst(a,b) memset(a,b,sizeof(a))
#define sf(n) scanf("%d",&n)
#define stf(n,m) scanf("%d%d",&n,&m)
#define pf(n) printf("%d\n",n)
#define sllf(n) scanf("%lld",&n)
#define pllf(n) printf("%lld\n",n)
priority_queue<int,vector<int>,greater<int> > q;
const int N=1e5+10;
const int mod=1e9+7;
int n,m,sum=0;
struct node{
	int x,id;
}w[N];
bool cmp(node a,node b){
	return a.x<b.x;
}
int main()
{
	sf(n);
	rep(i,1,n){
		sf(w[i].x);
		w[i].id=i;
	}
	sort(w+1,w+1+n,cmp);
	rep(i,1,n)printf("%d ",w[i].id);
	return 0;
}

Measured memory_bytes: 1536
import java.util.Scanner;
//import java.Math;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n,T,A,i,ansb=0,gosa=987654321;
		n=scan.nextInt();
		T=scan.nextInt();
		A=scan.nextInt();
		for(i=0;i<n;i++){
			int H=scan.nextInt();
			if(gosa>Math.abs(T*1000-H*6-A*1000)){
				gosa=Math.abs(T*1000-H*6-A*1000);
				ansb=i+1;
			}
		}
		System.out.println(ansb);
	}
}

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

int main(){
    int a[4][3][10] = {{{}}};
    int n, b, f, r, v;
    
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> b >> f >> r >> v; 
        a[b-1][f-1][r-1] += v;
    }
    
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 10; k++){
                cout << " ";
                cout << a[i][j][k];
            }
            cout << endl;
        }
        if(i < 3) cout << "####################" << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
Program main
  implicit none
  integer(8) :: n, a,b, K
  integer(8) :: a_1, b_1
  integer(8) :: i, j
  integer(8) :: mbase
  integer(8),allocatable :: f(:),finv(:),inv(:)
  integer :: out
  mbase = 998244353
  read(*,*) n, a, b, K
  allocate( f(0:N), finv(0:N), inv(0:N) )
  f(0) = 1
  f(1) = 1
  finv(0) = 1
  finv(1) = 1
  inv(0) = 0
  inv(1) = 1
  do i = 2,N
     f(i) = modulo( f(i-1)* i,mbase  )
     inv(i) = modulo ( -inv(modulo(mbase,i)) *(mbase/ i ), mbase )
     finv(i) = modulo( finv(i-1)*inv(i), mbase ) 
  end do
  out = 0
  do i = 0, N
     if ( mod( ( K - (A*i) ),B) == 0 ) then
        j = ( K - (A*i) )/B
        if ( 0 <= j.and.j <= N  ) then
           out = modulo(modulo( nCr2(n,i,finv,f) * nCr2(n,j,finv,f) , mbase) + out, mbase)
        end if
     end if
  end do
  write(*,'(i0)') out
  stop
contains
  integer(8) function mpow(a,n,mbase )
    ! a**n mod mbase
    integer(8) :: a
    integer(8) ::  n, mbase
    integer(8) :: ntmp, atmp
    mpow = 1
    atmp = a
    ntmp = n
    do while(ntmp > 0)
       !if ( mod(ntmp,2) == 0   ) mpow = modulo( mpow * atmp,mbase)
       if ( iand(ntmp,1) >0 ) mpow = modulo( mpow * atmp,mbase)
       atmp = modulo( atmp * atmp, mbase )
       ntmp = ishft(ntmp,-1)
    end do
  end function mpow

  
  integer(8) function nCr(n,r )
    integer(8) :: n, r
    integer(8) :: n_r
    integer(8) :: i
    integer(8) :: n1, n2
    integer(8) :: inv, inv2
    if ( r == 0 ) then
       nCr = 1
       return
    end if
    n_r = n-r
    n1 = 1
    do i = n,n_r+1,-1
       n1 =  mod(n1*i,mbase)
    end do
    n2 = 1
    do i = 1,r
       n2 = mod(n2*i,mbase)
    end do
    n2 = mpow(n2,mbase-2,mbase)
    nCr =  mod( n1*n2,mbase)
  end function nCr
  
  integer(8) function nCr2(n,r,finv,f)
    integer(8) :: finv(0:N), f(0:N)
    integer(8) :: n,r, r2
    r2 = min(r,n-r)
    !nCr = modulo( f(n)*modulo( (finv(r2)*finv(n-r2)), mbase ), mbase )
    nCr2 = mod( f(n)*(mod(finv(r2)*finv(n-r2),mbase) ), mbase )
  end function nCr2
  
end program main


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
using namespace std::chrono; 
#define ll long long
#define fo(i,v,e) for(v=i;v<e;v++)
#define pb(x) push_back(x)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fi first 
#define se second
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector<ll>
#define sz(x) (int)x.size()
#define ull unsigned long long

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x);
#else
#define deb(x...)
#endif

vector<ll> sieveOfErthnosis(ll n)
{
    vector<bool>flag(n+5,false);
    vector<ll>primes;
    for(int i=2;i*i<=n;i++)
    {
        if(!flag[i])
        {
            for(int j=i*i;j<=n;j+=i)
            {flag[j]=true;}
        }
    }
    for (int  i = 2; i < n+1; i++)
    {
        if(!flag[i])primes.pb(i);
    }
    return primes;
}
void init()
{

}
bool check(string s,int l,int r)
{
    while(l<r)
    {
        if(s[l]!=s[r])return false;
        l++;r--;
    }
    return true;
}
void solve()
{
    long double n;cin>>n;
    n/=3;
    cout<<fixed<<setprecision(12);
    cout<<(n*n*n)<<endl;
}
int main()
{
    #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    #endif
    init();
    auto start = high_resolution_clock::now(); 
    int T = 1;
    // cin>>T;
	while(T--)
	{
		solve();
	}
    auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<milliseconds>(stop - start); 
    #ifndef ONLINE_JUDGE
	// cout << "time taken : "<<duration.count()<<" ms" << endl;
     #endif
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
    
    char S[101];
    int K;
    scanf("%d",&K);
    getchar();
    scanf("%[^\n]", &S);
    
    if (strlen(S) > K ){
        for(int i = 0; i < K; i++){
            printf("%c", S[i]);
        }
        printf("...\n");
    }else{
        for(int i = 0; i < strlen(S); i++){
            printf("%c", S[i]);
        }
    }
    return 0;
}

Measured memory_bytes: 1624
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int>A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    } 
    int ans = A[0];
    for(int i = 0; i < N; i++) {
        ans = __gcd(ans,A[i]);
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n; cin >> n;

    vector<ll> a(n);
    vector<ll> s(n+1, 0);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
        s[i+1] = s[i] + a[i];
    }

    ll t = s[n] / 2;

    ll ans = LINF;

    ll m = 0;

    for (ll i = 0; i < n+1; ++i) {
        if (s[i] >= t) {
            m = i;
            break;
        }
    }

    ans = min(ans, abs(s[m] - t) + abs((s[n] - s[m]) - t));
    ans = min(ans, abs(s[m-1] - t) + abs((s[n] - s[m-1]) - t));

    cout << ans << endl;
}

Measured memory_bytes: 3328
a,b,c,d = gets.chomp.split(" ").map(&:to_i)

if (a >= 0) && (c >= 0)
  puts (b*d)
elsif (b <= 0) && (d <= 0)
  puts (a*c)
elsif (b <= 0) && (c >= 0)
  puts (b*c)
elsif (d <= 0) && (a >= 0)
  puts (a*d)
elsif (b<=0) && (c<=0) && (d >=0 )
  puts (a*c)
elsif (d<= 0) && (a<=0) && (b>=0)
  puts (a*c)
elsif (c>=0) && (b>=0) && (a<= 0)
  puts (b*d)
elsif (a>=0) && (d>=0) && (c<=0)
  puts (b*d)
elsif (a<=0) && (c<=0) && (b>=0) && (d>=0)
  x = a*c
  y = b*d
  if x >= y
    puts x
  else
    puts y
  end
end


Measured memory_bytes: 14392
#include<stdio.h>

int main(){
    int n,p,a=0;
    scanf("%d",&n);
    for(int i=1;i<n+1;i++){
        scanf("%d",&p);
        if(p!=i){
            a++;
        }
    }
    if((a==0)||(a==2)){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
	
int res,n,A[50];
	
int solve(int i, int m){
	if(m==0) return 1;
	if(i>=n) return 0;
	int res=solve(i+1,m) || solve(i+1,m-A[i]);
	return res;
}

int main(){
	int q,M,i;
	
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&A[i]);
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&M);
		if(solve(0,M)) printf("yes\n");
		else printf("no\n");
	}
	return 0;
}

Measured memory_bytes: 1748
package main

import (
    "fmt"
)

func main() {
    var n, y int
    fmt.Scan(&n, &y)

    for i := 0; i <= n; i++ {
        for j := 0; j <= (n - i); j++ {
            k := n - i - j
            if i*10000+j*5000+k*1000 == y {
                fmt.Println(i, j, k)
                return
            }
        }
    }

    fmt.Println(-1, -1, -1)
}

Measured memory_bytes: 512
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  vector<pii> A(2);
  for (int i = 0; i < 2; i++) {
    int a, b;
    cin >> a >> b;
    A[i] = {a, b};
  }
  sort(A.begin(), A.end());
  cout << max(0, min(A[1].second - A[1].first, A[0].second - A[1].first)) << endl;

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll n;
  cin >> n;
  vector<string> s(n);
  rep(i,n){
    cin >> s[i];
  }
  sort(all(s));
  ll count = 1;
  for (ll i = 1; i < n;i++){
    if(s[i-1]!=s[i]){
      count++;
    }
  }
  print(count);
}

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

int main()
{
	int n;
	cin >> n;
	long long sum = 0, min = 10000000001, max = -10000000001;
	int x;
	for (int i = 0; i < n; i++)
	{
		cin >> x;
		sum = sum + x;

		if (x < min)
			min = x;
		if (x > max)
			max = x;
	}
	cout << min << " " << max << " " << sum << endl;
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;
const int MAX = 1e5 + 50;
typedef pair<int, int> P;

// factorial
long long fac[MAX];

long long fact(int n) {
    if (n == 1) return fac[n] = 1;
    if (fac[n]) return fac[n];
    return fac[n] = (fact(n - 1) % M * n) % M;
}

void invalid() {
    cout << 0 << endl;
    exit(0);
}

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

    if (s[0] == 'W') invalid();

    ll ans = 1;
    int l = 1;
    int r = 0;
    int curr = 0;
    repeat(i, 1, 2 * n) {
        if (s[i - 1] == s[i]) {
            curr ^= 1;
        }

        if (curr == 1) {
            ans *= (l - r) % M;
            ans %= M;
        }

        if (curr == 0)
            l++;
        else
            r++;

        if (r > l) invalid();
    }
    if (l != r) invalid();

    ans *= fact(n) % M;
    ans %= M;
    cout << ans << endl;
}


Measured memory_bytes: 2948
# C - Sum of product of pairs

N = int(input())
A = list(int(a) for a in input().split())
MOD = 10**9 + 7

csA = [0] * (N+1)
for i in range(N):
    csA[i+1] = csA[i] + A[i]

ans = 0
for i in range(N-1):
    ans += (A[i] * (csA[N] - csA[i+1])) % MOD
print(ans%MOD)

Measured memory_bytes: 31392
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            int n = Integer.parseInt(br.readLine());
            int k = Integer.parseInt(br.readLine());
            int x = Integer.parseInt(br.readLine());
            int y = Integer.parseInt(br.readLine());
            int ans = 0;
            for (int i = 0; i < n; i++) {
                if (i + 1 > k) {
                    ans += y;
                } else {
                    ans += x;
                }
            }
            System.out.println(ans);
        } catch (IOException e) {
            e.printStackTrace();
           }
    }
}


Measured memory_bytes: 25044
#pragma GCC optimize("O2")
#define NDEBUG
#include <bits/stdc++.h>
#define clean(x,y) memset(x,y,sizeof(x))
#define inc(i,s,t) for(int i=s;i<=t;++i)
#define dec(i,s,t) for(int i=s;i>=t;--i)
#define debug(x) std::cerr<<(x)<<" "
typedef unsigned long long ll;
const int inf = 0x7f7f7f7f;

inline void gettime() {
	debug("Time: ");
	debug(clock()) << " ms\n";
}
inline int read() {
	static char c;
	static int x;
	while (c = getchar(), !isdigit(c));
	x = c - '0';
	while (c = getchar(), isdigit(c))
		x = (x << 1) + (x << 3) + c - '0';
	return x;
}
inline char achar() {
	static char c;
	while (c = getchar(), !isalpha(c));
	return c;
}

const ll mod = 29996224275833;
ll ans;
int n, ls[40], rs[40], vis[40];
//cnt存储了颜色染成红色的串的数目。
std::map<ll, int> cnt;
ll hash(int *ns) {
	ll code = 0;
	for (int i = 1; i <= n; ++i)
		if (vis[i])
			code = code * 52 + ns[i] - 'a', code %= mod;
	for (int i = 1; i <= n; ++i)
		if (!vis[i])
			code = code * 52 + ns[i] - 'a' + 26, code %= mod;
	return code;
}

void dfs(int x) {
	if (x > n) {
		++cnt[hash(rs)];
		// printf("%lld %d\n", hash(rs), cnt[hash(rs)]);
		return;
	}

	dfs(x + 1);
	vis[x] = 1;
	dfs(x + 1);
	vis[x] = 0;
}

//update 枚举染成蓝色的串的数量
void update(int x) {
	// printf("vis %d\n", x);
	if (x > n) {
		ans += cnt[hash(ls)];
		// printf("Adding %d %lld\n", cnt[hash(ls)], hash(ls));
		return;
	}

	update(x + 1);
	vis[x] = 1;
	update(x + 1);
	vis[x] = 0;
}

int main() {
#ifndef ONLINE_JUDGE
	std::atexit(gettime);
#endif

	n = read();
	for (int i = 1; i <= n; ++i)
		ls[i] = achar();
	for (int i = n; i >= 1; --i)
		rs[i] = achar();

	dfs(1);
	update(1);

	printf("%lld\n", ans);
}

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

using namespace std;

using ll = long long;

template<const int CHAR_NUM = 26, const char FIRST_CHAR = 'a', const int NONE = -1>
struct Trie {
    struct Node {
        bool word_exists;
        int idxs[CHAR_NUM]; // idxs[c - FIRST_CHAR]: 次の文字がcであるNodeの場所(treeのindex)
        Node() : word_exists(false) {
            fill(idxs, idxs + CHAR_NUM, NONE);
        };
    };

    vector<Node> tree;

    Trie() {
        tree.emplace_back();
    }

    void insert(const string& s) {
        int cur = 0;
        for (char c : s) {
            if (tree[cur].idxs[c - FIRST_CHAR] == NONE) {
                tree[cur].idxs[c - FIRST_CHAR] = tree.size();
                tree.emplace_back();
            }
            cur = tree[cur].idxs[c - FIRST_CHAR];
        }
        tree[cur].word_exists = true;
    }

    bool find(const string& s) {
        int cur = 0;
        for (char c : s) {
            if (tree[cur].idxs[c - FIRST_CHAR] == NONE) {
                return false;
            }
            cur = tree[cur].idxs[c - FIRST_CHAR];
        }
        return tree[cur].word_exists;
    }

    void solve(int cur, int idx, vector<ll>& hoge, ll L) {
        if ((tree[idx].idxs[0] == NONE) ^ (tree[idx].idxs[1] == NONE)) hoge.push_back(L - cur);
        if (tree[idx].idxs[0] != NONE) solve(cur + 1, tree[idx].idxs[0], hoge, L);
        if (tree[idx].idxs[1] != NONE) solve(cur + 1, tree[idx].idxs[1], hoge, L);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll L;
    cin >> n >> L;

    Trie<2, '0'> tr;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        tr.insert(s);
    }

    vector<ll> hoge;
    tr.solve(0, 0, hoge, L);
    ll foo = 0;
    for (ll x : hoge) {
        int cnt = 0;
        while (x > 0) {
            if (x & 1) break;
            cnt++;
            x >>= 1;
        }
        foo ^= (1LL << cnt);
    }
    cout << (foo != 0 ? "Alice" : "Bob") << endl;
    return 0;
}


Measured memory_bytes: 5856
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll n;
  cin >> n;
  ll l[n],r[n],ans=0;
  for(int i=0;i<n;i++){
    cin >> l[i] >> r[i];
    ans += r[i]-l[i]+1;
  }
  cout << ans <<endl;
}


Measured memory_bytes: 256
N = raw_input()
X = map(int, raw_input().split())

counter = 0
possible = True
nextchanged = False
while counter < int(N) - 1:
  if X[counter] > X[counter + 1]:
    if nextchanged:
      possible = False
      break
    else:
      X[counter] -= 1
      if X[counter] == X[counter + 1]:
        nextchanged = True
      if X[counter] > X[counter + 1]:
        possible = False
        break
  else:
    if X[counter] < X[counter + 1]:
      nextchanged = False
  counter += 1
if possible:
  print "Yes"
else:
  print "No"

Measured memory_bytes: 11340
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 1012345678
#define NINF (-2147483647-1)
#define LLINF 9012337203685477580
using ll = long long;
using namespace std;

//powMod
ll powMod(ll k, ll n, ll mod) {
    ll x = 1;
    while (n > 0) {
        if (n & 1) {
            x = x * k % mod;
        }
        k = k * k % mod;
        n >>= 1;
    }
    return x;
}

const int MAX_N = 200000;
ll FACT[MAX_N], IFACT[MAX_N];

ll comb(ll n, ll r) {
    if (n < 0 || r < 0 || r > n)return 0;
    if (r > n / 2) r = n - r;
    return FACT[n] * IFACT[n - r] % MOD * IFACT[r] % MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    ll ans = 1;
    FACT[0] = 1;
    IFACT[0] = 1;
    for (int i = 1; i <= MAX_N; i++) {
        FACT[i] = FACT[i - 1] * i % MOD;
        IFACT[i] = powMod(FACT[i], MOD-2,MOD);
    }
    for (int i = 2; i <= M; i++)
    {
        int k = 0;
        while (M % i == 0) {
            M /= i;
            k++;
        }
        if (k > 0) {
            ans *= comb(k + N - 1, k);
            ans %= MOD;
        }
    }
    cout << ans << endl;
    getchar(); getchar();
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
char map[50][50];
int H;
int W;

int check(int h, int w){

    bool flag = false;
    if(map[h][w] == '.') flag = true;
    if(map[h][w] == '#'){
        if(h + 1 < H){
            if(map[h+1][w] == '#') flag = true;
        }
        if(h - 1 >= 0){
            if(map[h-1][w] == '#') flag = true;
        }
        if(w + 1 < W){
            if(map[h][w+1] == '#') flag = true;
        }
        if(w - 1 >= 0){
            if(map[h][w-1] == '#') flag = true;
        }
    }
    return flag;

}

int main(){

    cin >> H;
    cin >> W;

    for(int h = 0; h < H; h++){
        for(int w = 0; w < W; w++){
            cin >> map[h][w];
        }
    }

    for(int h = 0; h < H; h++){
        for(int w = 0; w < W; w++){
            bool flag = check(h, w);
            if(flag == false){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

}

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

int main(void)
{
    int A, B;
    cin >> A >> B;
    cout << max({A+B, A*B, A-B}) << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
s = input().rstrip()
MOD = 998244353

r = 0; g = 0; b = 0
rg = 0
gb = 0
br = 0
ans = 1
for ch in s:
    if ch == "R":
        if gb > 0:
            ans *= gb
            gb -= 1
        elif g > 0:
            ans *= g
            g -= 1
            rg += 1
        elif b > 0:
            ans *= b
            b -= 1
            br += 1
        else:
            r += 1
    elif ch == "G":
        if br > 0:
            ans *= br
            br -= 1
        elif b > 0:
            ans *= b
            b -= 1
            gb += 1
        elif r > 0:
            ans *= r
            r -= 1
            rg += 1
        else:
            g += 1
    elif ch == "B":
        if rg > 0:
            ans *= rg
            rg -= 1
        elif g > 0:
            ans *= g
            g -= 1
            gb += 1
        elif r > 0:
            ans *= r
            r -= 1
            br += 1
        else:
            b += 1
    ans %= MOD
for i in range(n):
    ans *= i+1
    ans %= MOD
print(ans)

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

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> P(N);
	rep(i,N) cin >> P[i];
	int max = *max_element(P.begin(),P.end());
	cout << accumulate(P.begin(),P.end(),0) - max/2; 
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int n;
map<int, int> mp;

int main() {
  cin >> n;
  for(int i=2; i<=n; i++){
    int a = i;
    for(int j=2; j<=n; j++){
      while(a%j == 0){
        a /= j;
        mp[j]++;
      }
    }
  }

  vector< int > v;
  for(auto i=mp.begin(); i!=mp.end(); i++){
    if(i->second == 1) continue;
    v.push_back(i->second + 1);
  }

  int m = v.size();

  int cnt = 0;
  for(int i=0; i<m; i++){
    if(v[i] >= 75) cnt++;
    if(v[i] >= 25) {
      for(int j=0; j<m; j++){
        if(i==j) continue;
        if(v[j] >= 3) cnt++;
      }
    }
    if(v[i] >= 15) {
      for(int j=0; j<m; j++){
        if(i==j) continue;
        if(v[j] >= 5) cnt++;
      }
    }
    if(v[i] >= 5) {
      for(int j=i+1; j<m; j++){
        if(i==j) continue;
        if(v[j] >= 5) {
          for(int k=0; k<m; k++){
            if(i==k) continue;
            if(j==k) continue;
            if(v[k] >= 3) cnt++;
          }
        }
      }
    }
  }
  cout << cnt << endl;
  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 - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class UnionFind {
    int n;
    vector<int> par, rank;
    vector<ll> num;

public:
    UnionFind(int N) : n(N), par(N, -1), rank(N), num(N, 1) {}
    int root(int i) {
        if (par[i] < 0) return i;
        return par[i] = root(par[i]);
    }
    bool same(int i, int j) { return root(i) == root(j); }
    void unite(int i, int j) {
        i = root(i);
        j = root(j);
        if (i == j) return;
        num[i] += num[j];
        num[j] = num[i];
        if (rank[i] <= rank[j]) {
            par[i] = j;
            if (rank[i] == rank[j]) { rank[j]++; }
        } else {
            par[j] = i;
        }
    }
    ll num_group(int i) { return num[root(i)]; }
};

class Main {
    ll N, M;
    vector<int> A, B;
    void input() {
        cin >> N >> M;
        A.resize(M);
        B.resize(M);
        REP(i, M) {
            cin >> A[i] >> B[i];
            A[i]--;
            B[i]--;
        }
    }
    void output() {
        UnionFind ufd(N);
        vector<ll> res(M);
        res[M - 1] = N * (N - 1) / 2;
        FORR(i, 1, M) {
            res[i - 1] = res[i];
            if (ufd.same(A[i], B[i])) continue;
            res[i - 1] -= ufd.num_group(A[i]) * ufd.num_group(B[i]);
            ufd.unite(A[i], B[i]);
        }
        REP(i, M) { cout << res[i] << endl; }
    }

public:
    Main() {
        input();
        output();
    }
};

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

    Main();

    return 0;
}


Measured memory_bytes: 6336
package main

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

func main() {
	nextReader = newScanner()
	N := nextInt()
	M := nextInt()
	Hs := nextInts(N)
	Flg := make([]int, N)
	for m := 0; m < M; m++ {
		a := nextInt()
		b := nextInt()
		if Hs[a-1] < Hs[b-1] {
			Flg[a-1] = 1
		} else if Hs[a-1] > Hs[b-1] {
			Flg[b-1] = 1
		} else {
			Flg[a-1] = 1
			Flg[b-1] = 1
		}
	}
	ans := 0
	for _, v := range Flg {
		if v == 0 {
			ans += 1
		}
	}
	fmt.Printf("%d", ans)
}

var nextReader func() string

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	// r.Split(bufio.ScanLines)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func nextStrings() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}


Measured memory_bytes: 5856
/*
Problem Statement

There are N people living on a number line.The i-th person lives at coordinate 
Xi.You are going to hold a meeting that all N people have to attend.The 
meeting can be held at any integer coordinate. If you choose to hold the 
meeting at coordinate P, the i-th person will spend (Xi−P)^2 points of stamina 
to attend the meeting.

Find the minimum total points of stamina the N people have to spend.

Constraints
All values in input are integers.

1≤N≤100
1≤Xi≤100

Input
Input is given from Standard Input in the following format:

N
X1 X2 ... XN


Output

Print the minimum total stamina the N people have to spend.

*/
// Wrong Answer but WHY?? Its givin random memory if watch(x) is not put but
// shouldn't fucking change anything.
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef pair< double,double> dd;
#define pb push_back
#define eb emplace_back
#define sz(a) int((a).size))
#define all(c) c.begin(),c.end()
#define FOR(i,a,b) for(i=a; i<b; i++)
#define FORR(i,a,b) for(i=a;i>=b;i--)
#define REP(i,n) FOR(i,0,n)
#define x first
#define y second
#define mp make_pair

const int INF = 1000000009;
const long long INFLL = (ll)INF * (ll)INF;

int better_minimum(vi pos)
{
	int ans;
	int m,l=pos[0],r=pos[0];
	int n=(int)pos.size();
	for(int i=0;i<n;i++)
	{
		l = min(l,pos[i]);
		r = max(r,pos[i]);
		//watch(l);
		//watch(r);
	}
	for(int a=l;a<=r;a++)
	{
		m=0;
		for(int b=0;b<n;b++)
		{
			m+=(pos[b]-a)*(pos[b]-a);
		}
		ans=min(ans,m);
		//watch(ans);
	}
	return ans;
}
		
/*int minimum(vi pos)
{
	int x=0,mid;
	int n=pos.size();
	sort(pos.begin(),pos.end());
	if(n%2==0)
	{
		mid = (pos[n/2]+pos[n/2 -1 ])/2;
	}
	else
	{
		mid = pos[n/2];
	}
	watch(mid);
	for(int i = 0;i<n;i++)
	{
		x+=pow(pos[i]-mid,2);
		watch(x);
	}
	return x;
}
 */
int32_t main()
{
	int n;
	int i;
	vi pos;
	int x;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>x;
		pos.pb(x);
	}
	int result;
	result = better_minimum(pos);
	cout<<result;
	IOS;
	return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }    
}


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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define inf 0x3f3f3f3f
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

/* 
 * * stuff you should look for
 * * int overflow, array bounds
 * * special cases (n=1?), set tle
 * */

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

int main(){
    fcin;

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

    cout << lcm(a, b) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//n ~ mの和
ll sigma(ll n, ll m)
{
  return ((n + m) * (m - n + 1) * 0.5);
}

void Main()
{
  ll h, w; cin >> h >> w;
  vvc s(h + 2, vc(w + 2, '.'));
  for(ll i = 1;i <= h;i++)
  {
    for(ll j = 1;j <= w;j++)
    {
      cin >> s[i][j];
    }
  }
  for(ll i = 1;i <= h;i++)
  {
    for(ll j = 1;j <= w;j++)
    {
      if(s[i][j] == '#'&&s[i + 1][j] == '.'&&s[i - 1][j] == '.'&&s[i][j + 1] == '.'&&s[i][j - 1] == '.')
      fin("No");
    }
  }
  fin("Yes");
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 256
import math
def main():
    n,h = map(int,input().split())
    A =0
    BA = []
    for i in range(n):
        a,b = map(int,input().split())
        BA.append([b,a])
        A = max(A,a)
    BA.sort(reverse=True)
    cnt = 0
    for i in range(n):
        if BA[i][0]> A:
            h -= BA[i][0]
            cnt += 1
            if h <= 0:
                break
    
    if h>0:
        cnt += math.ceil(h/A)
    print(cnt)

main()


Measured memory_bytes: 23992
/**
*    created: 14.05.2020 13:51:33
**/
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

int maxtime(int n) {
    while (n % 10 != 0) n++;
    return n;
}

int remtime(int n) {
    return maxtime(n)-n;
}

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    int sum = maxtime(a) + maxtime(b) + maxtime(c) + maxtime(d) + maxtime(e);
    int rem = max({remtime(a), remtime(b), remtime(c), remtime(d), remtime(e)});
    cout << sum - rem << endl;
    return 0;
}

Measured memory_bytes: 256
from bisect import *
import sys

def solve(N, A):
    INF = 10**10

    dp = [INF]*(N+1)
    dp[0] = -1
    for a in A:
        idx = bisect(dp, a-1)
        dp[idx] = min(a, dp[idx])
    return max(i for i in range(N+1) if dp[i] < INF)

N, *A = map(int, sys.stdin.read().split())
sys.stdout.write("%d\n" % solve(N, A))


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

typedef std::pair<int, int> ipair;
#define   pb            push_back
#define   ff            first
#define   ss            second
#define   fr(i, j, k)   for (int i = j; i < k; i++)
#define   rf(i, j, k)   for (int i = j; i >= k;i--)
#define   int           long long
#define   ld            long double
#define   all(x)        x.begin(), x.end()
#define   rall(x)       x.rbegin(),x.rend()
#define   mp            make_pair
#define   inf           INT_MAX
#define   read_file();	freopen("input.txt", "r", stdin);	freopen("output.txt", "w", stdout);
#define   IOS           std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int mod  =  2019;
const ld  pi   =  acos(-1);
const int Maxn =  105;

template<class T> ostream& operator <<(ostream &out,vector<T> &A){for(auto x:A) out<<x<<" ";return out;}
template<class T> ostream& operator <<(ostream &out,set<T> &A){for(auto x:A) out<<x<<" ";return out;}
template <class T1,class T2>T1 powr(T1 a,T2 b){T1 res = 1;fr(i,1,b+1)res = res*a;return res;}

int32_t main(){ IOS;
  int w,h,x,y;  cin>>w>>h>>x>>y;
  double area = (double)(w*h)/2;
  cout<<area<<" ";
  if(x==(double)w/2 and y==(double)h/2)
    cout<<1<<endl;
  else cout<<0<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, ans;
int dp[MAXN], par[MAXN];
deque<int> dq;
string s;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>m>>s;
	dq.pb(0);
	for (int i=1; i<=n; i++) if (s[i]=='0'){
		while (dq.size() && dq.front()<i-m) dq.pop_front();
		if (dq.empty()) continue ;
		dp[i]=1;
		par[i]=dq.front();
		dq.pb(i);
	}
	if (!dp[n]) kill(-1)
	vector<int> out;
	for (int i=n; i; i=par[i]) out.pb(i-par[i]);
	reverse(all(out));
	for (int i:out) cout<<i<<' ';
	
	return 0;
}


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

int n, m;
int a[10];
string dp[10010];
map<int, int> mp;

string solve(int x){
  if(x < 0) return "#";
  if(x==0 || dp[x].size()>0) return dp[x];
  string ret = "";
  rep(i, m){
    string tmp = solve(x-mp[a[i]]) + to_string(a[i]);
    if(tmp[0] == '#') continue;
    if(tmp.size() > ret.size()){
      ret = tmp;
      continue;
    }
    if(tmp.size() < ret.size()) continue;
    if(tmp > ret) ret = tmp;
  }
  if(ret == "") return dp[x] = "#";
  return dp[x] = ret;
}

int main(){
  cin >> n >> m;
  rep(i, m) cin >> a[i];
  mp[1] = 2; mp[2] = 5; mp[3] = 5; mp[4] = 4; mp[5] = 5; mp[6] = 6; mp[7] = 3; mp[8] = 7; mp[9] = 6;
  rep(i, n+1) dp[i] = "";
  cout << solve(n) << endl;
}


Measured memory_bytes: 26624
N = int(input())
X = map(int, input().split())
X = list(X)

head = min(X)
tail = max(X)

min_score = float('inf')
for p in range(head, tail+1):
    min_score = min(sum(map(lambda x: (x - p)**2, X)), min_score)

print(min_score)

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


void solve(long long X, long long Y, long long Z){
    printf ("%lld %lld %lld\n",Z,X,Y);

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    long long Z;
    scanf("%lld",&Z);
    solve(X, Y, Z);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    char a, b;
    cin >> a >> b;
    string s = "";
    if (a > b) {
        rep(i, a - '0') s += b; 
    }
    else {
        rep(i, b - '0') s += a;
    }
    cout << s << endl;
    return 0;
}


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

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

  if (A == 5 && B == 7 && C== 5) {
    cout << "YES" << endl;
  }
  else if (A == 7 && B == 5 && C== 5) {
    cout << "YES" << endl;
  }
  else if (A == 5 && B == 5 && C== 7) {
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main()
{
	string s;

	while (true) {
		int x, sum = 0;
		cin >> s;
		if (s[0] == '0') break;

		for (int i = 0; i < s.length(); i++) {
			x = s[i] - '0';
			sum += x;
		}
		cout << sum << "\n";
	}
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<pair<int,string>>P(M);
  for(int i=0;i<M;i++){
    cin>>P.at(i).first>>P.at(i).second;
  }
  vector<int>AC(N,0);
  vector<int>WA(N,0);
  for(int i=0;i<M;i++){
    if(AC.at(P.at(i).first-1)==1){
    }
    else{
      if(P.at(i).second=="AC"){
        AC.at(P.at(i).first-1)=1;
      }
      else{
        WA.at(P.at(i).first-1)=WA.at(P.at(i).first-1)+1;
      }
    }
  }
  int sumWA=0;
  int sumAC=0;
  for(int i=0;i<N;i++){
    if(AC.at(i)==1){
      sumAC=sumAC+1;
      sumWA=sumWA+WA.at(i);
    }
  }
  cout<<sumAC<<" "<<sumWA<<endl;
}


Measured memory_bytes: 7296