akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };

        
        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            var input = Console.ReadLine().Split().Select(double.Parse).ToArray();
            var a = input[0];
            var b = input[1];
            var x = input[2];

            double V = a * a * b;


            double ans = 0;
            if (x >= (V / 2))
            {
                /*double l = 0;
                double r = (PI / 4);
                while (r - l > 1e-7) 
                {
                    double c = (l + r) / 2;
                    double v = a * a * (b - (a * Tan(c)));
                    if (v >= x)
                    {
                        l = c;
                    }
                    else
                    {
                        r = c;
                    }
                }

                ans = l;*/
                ans = Atan((2 * (a * a * b - x)) / Pow(a, 3));

            }
            else
            {
                /*double l = (PI / 4);
                double r = (PI / 2);
                while (r - l > 1e-7)
                {
                    double c = (l + r) / 2;
                    double v = a * b * b / Tan(c);

                    if (v > x)
                    {
                        l = c;
                    }
                    else
                    {
                        r = c;
                    }
                }
                ans = l;*/
                ans = Atan(a * b * b / (2 * x));

            }

            Console.WriteLine(ans * 180 / PI);
           

            //Console.Out.Flush();
        }
        static public double rad(double r)
        {
            return r * PI / 180;
        }

    }
    

    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

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

int eve(int x)
{
    if (x % 400 == 0)
        return 1;
    if (x % 100 == 0)
        return 0;
    if (x % 4 == 0)
        return 1;
    return 0;
}

int main(void)
{
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vll p(a), q(b), r(c);
    rep(i, 0, a) cin >> p[i];
    rep(i, 0, b) cin >> q[i];
    rep(i, 0, c) cin >> r[i];
    sort_v(p);
    sort_v(q);
    sort_v(r);
    reverse_v(p);
    reverse_v(q);
    reverse_v(r);
    ll sum = 0;
    rep(i, 0, x) sum += p[i];
    rep(i, 0, y) sum += q[i];
    x--, y--;
    for (int i = 0; i < c; i++)
    {
        if (min(p[x], q[y]) < r[i])
        {
            sum += r[i] - min(p[x], q[y]);
            (p[x] < q[y]) ? x-- : y--;
            if (x < 0)
                x = 0, p[x] = INF;
            if (y < 0)
                y = 0, q[y] = INF;
        }
        else
            break;
    }
    cout << sum << endl;
}

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

using namespace std;

int n, m;
vector<string> s;

int f(int w, int b, int r) {
  int res = 0;
  for (int i = 0; i < w; i++) {
    for (int j = 0; j < m; j++) {
      res += s[i][j] != 'W';
    }
  }
  for (int i = w; i < w + b; i++) {
    for (int j = 0; j < m; j++) {
      res += s[i][j] != 'B';
    }
  }
  for (int i = w + b; i < n; i++) {
    for (int j = 0; j < m; j++) {
      res += s[i][j] != 'R';
    }
  }
  return res;
}

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

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

  int ans = 50 * 50;
  for (int i = 1; i < n; i++) {
    for (int j = 1; i + j < n; j++) {
      ans = min(ans, f(i, j, n - i - j));
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3200
import java.util.*;
import java.io.*;
import java.math.BigInteger;
 
public class Main {
	public static void main(String[] args) {
	Scanner s = new Scanner(System.in);
	int N = s.nextInt();
	long[] L = new long[N];
	for(int i = 0; i < N; i++){
		L[i] = s.nextLong();
	}

	int count = 0;
	for(int i = 0; i < N; i++){
		for(int j = i+1; j < N; j++){
			for(int k = j+1; k < N; k++){
				if((L[i]+L[j]>L[k] && L[i]+L[k]>L[j] && L[k]+L[j]>L[i]) 
				&& L[i] != L[j] && L[i] != L[k] && L[k] != L[j]){
					count++;
				}
			}
		}
	}

	

	System.out.println(count);

    
  }
}

Measured memory_bytes: 36764
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;


int n, x;
vvi G;
int ans;
vi h;

bool dfs(int i, int k) {
    bool treasure = false;
    for(int next:G[i]) {
        if(next == k) continue;
        if(dfs(next, i)) {
            ++ans;
            treasure = true;
        }
    }
    if(h[i]) {
        treasure = true;
    }
    return treasure;
}


int main() {
    int n;
    cin >> n;
    
    vector<vector<ll> >  c(10, vector<ll>(10));
    rep(i, 10) {
        rep(j, 10) {
            if(!(i*j)) {
                continue;
            }
            rep(k, n) {
                string S = to_string(k+1);
                if(S[0] == i+'0' && *(S.end()-1) == j+'0') {
                    c[i][j]++;
                }
            }
        }
    }

    ll ans=0;
    rep(i, 10) {
        rep(j, 10) {
            ans += c[i][j]*c[j][i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3696
#include<iostream>
using namespace std;
const int N=1e5+1;
int n,m,a[N],b[N],f[N],c[N],x,y;
long long p,A[N];
int F(int k)
{
	if(f[k]==k)
		return k;
	return f[k]=F(f[k]);
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
		cin>>a[i]>>b[i];
	p=(long long)n*(n-1)/2;
	for(int i=1;i<=n;i++)
		f[i]=i,c[i]=1;
	for(int i=m;i>=1;i--)
	{
		A[i]=p,x=F(a[i]),y=F(b[i]);
		if(x!=y)
			p-=c[x]*c[y],f[y]=x,c[x]+=c[y];
	}
	for(int i=1;i<=m;i++)
		cout<<A[i]<<'\n';
	return 0;
}

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

class Program {

    static int Main(string[] args) {
        List<string> list = new List<string>();

        while (true) {
            string[] v = Console.ReadLine().Split(' ');
            int m = int.Parse(v[0]);
            int f = int.Parse(v[1]);
            int r = int.Parse(v[2]);
            if (m == -1 && f == -1 && r == -1) { break; }

            int t = m + f;
            if (m == -1 || f == -1) { list.Add("F"); }
            else if (80 <= t) { list.Add("A"); }
            else if (65 <= t) { list.Add("B"); }
            else if (50 <= t) { list.Add("C"); }
            else if (30 <= t && 50 <= r) { list.Add("C"); }
            else if (30 <= t) { list.Add("D"); }
            else { list.Add("F"); }
        }

        for (int i = 0; i < list.Count; i++) {
            Console.WriteLine(list[i]);
        }

        return 0;
    }

}


Measured memory_bytes: 15892
#include<stdio.h>

int main()
{
  int a,b;
  int w,x,y,z;
  int i,ans=0;
  scanf("%d %d",&a,&b);
  for(i=a;i<=b;i++)
  {
    w=i/10000;
    x=(i/1000)%10;
    y=(i/10)%10;
    z=i%10;
    if(w==z&&x==y)ans++;
  }
  printf("%d",ans);
}


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

int main()
{
  int N; cin >> N;
  
  string ans = "No";
  for (int A = 1; A <= 9; A++)
  {
    for (int B = 1; B <= 9; B++)
    {
      if (N == A * B)
      {
        ans = "Yes";
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,c=0;
    cin >> n;
    vector<int>v(n);
    for(int i=0;i<n;i++){
        cin >> v[i];
        if(v[i]!=i+1)c++;
    }
    (c<=2)?cout << "YES\n" : cout << "NO\n" ;

    return 0;
}


Measured memory_bytes: 3632
s=input()
t=input()
m=float("infinity")
for i in range(len(s)):
	count=0
	if i+len(t)<=len(s):
		for j in range(len(t)):
			if t[j]!=s[i+j]:
				count+=1
		m=min(m,count)
if t in s:
	m=0
print(m)





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

int main() {
  int a, b;
  string op;
  cin >> a >> op >> b;

  if (op == "-") {
    a  -= b;
    cout << a << endl;
  }
  else {
    a += b;
    cout <<  a << endl;
  }
}


Measured memory_bytes: 256
"use strict"

function Main(input) {
  input = input.trim().split('\n');
  const N = input[0].trim().split(' ').map(Number)[0];
  let X = input[0].trim().split(' ').map(Number)[1];
  const a = input[1].trim().split(' ').map(Number).sort((a,b) => a-b);

  let ret = 0;
  for(let i=0; i<N; i++){
    if(i === N-1){
      if(a[i] === X) ret += 1;
    }else if(X >= a[i]){
      X -= a[i];
      ret += 1;
    } else {
      break;
    }
  }

  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n,W;
  cin >> n >> W;
  vec dp(1e5+10,inf);
  dp[0]=0;
  vec w(n),v(n);
  for(ll i=0;i<n;i++) cin >> w[i] >> v[i];
  for(ll i=0;i<n;i++) {
    for(ll j=1e5;j;j--) {
      if(j+1<=1e5) {
        dp[j]=min(dp[j],dp[j+1]);
      }
      if(j-v[i]>=0) {
        dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
      }
    }
  }
  for(ll j=1e5;j>=0;j--) {
    if(dp[j]<=W) {
      cout << j << endl;
      return 0;
    }
  }
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef double dd;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
typedef vector<pair<ll, ll>> vpll;
typedef pair<ll, ll> pll;

#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(c) (c).begin(), (c).end()
#define MOD 1000000007
#define MAX 1e5 + 10

int main() {
#ifdef HOME
    freopen("kek.in", "r", stdin);
    freopen("kek.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vll arr(3 * n);
    for (int i = 0; i < 3 * n; i++)
        cin >> arr[i];
    vll first(3 * n, 0);
    multiset<ll> s;
    s.insert(arr[0]);
    first[0] = arr[0];
    for(int i = 1; i < n; i++){
        s.insert(arr[i]);
        first[i] = first[i - 1] + arr[i];
    }
    for(int i = n; i < 2 * n; i++) {
        if (arr[i] > *s.begin()) {
            first[i] = first[i - 1] - *s.begin() + arr[i];
            s.erase(s.find(*s.begin()));
            s.insert(arr[i]);
        }
        else
            first[i] = first[i - 1];
    }
    vll sec(3 * n, 0);
    s.clear();
    s.insert(arr[3 * n - 1]);
    sec[3 * n - 1] = arr[3 * n - 1];
    for(int i = 2; i <= n; i++) {
        s.insert(arr[3 * n - i]);
        sec[3 * n - i] = sec[3 * n - i + 1] + arr[3 * n - i];
    }
    for(int i = 2 * n - 1; i >= n; i--) {
        if (arr[i] < *s.rbegin()) {
            sec[i] = sec[i + 1] - *s.rbegin() + arr[i];
            s.erase(s.find(*s.rbegin()));
            s.insert(arr[i]);
        }
        else
            sec[i] = sec[i + 1];
    }
    ll ans = -9223372036854775807;
    for(int i = n; i <= 2 * n; i++)
        ans = max(ans, first[i - 1] - sec[i]);
    cout << ans;
    return 0;
}

Measured memory_bytes: 12032
#include<stdio.h>

int main(void)
{
    int a, b, c;
    while(1)
    {
        char buffer[256];
        fgets(buffer, 256, stdin);
        sscanf(buffer, "%d %d %d", &a, &b, &c);
        if((0<=a && a<=100) &&
        (0<=b && b <= 100) &&
        (0<=c && c <= 100)) break;
    }
    if(a<b && b < c) printf("Yes\n");
    else printf("No\n");
    
    return(0);
}


Measured memory_bytes: 2040
// Jalpaiguri Government Engineering college //


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

ll power(ll a,ll N)
{
	if(N==0)
	{
		return 1;
	}
	else
	{
		ll r=power(a,N/2);
		if(N%2==0)
		{
			return r*r;
		}
		else
		{
			return r*r*a;
		}
	}
}

ll powerMod(ll a,ll N,ll MOD)
{
	if(N==0)
	{
		return 1;
	}
	else
	{
		ll r=powerMod(a,N/2,MOD);
		if(N%2==0)
		{
			return (r*r)%MOD;
		}
		else
		{
			return (r*r*a)%MOD;
		}
	}
}


#define aso ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)


void solve()
{
	ll n,i;
	cin>>n;
	vector<ll>a(n+4);
	vector<ll>b(n+4);
	vector<ll>c(n+4);
	ll dp1[n+5],dp2[n+5],dp3[n+5];
	for(i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	dp1[0]=a[0];
	dp2[0]=b[0];
	dp3[0]=c[0];
	for(i=1;i<n;i++)
	{
		dp1[i]=a[i]+max(dp2[i-1],dp3[i-1]);
		dp2[i]=b[i]+max(dp1[i-1],dp3[i-1]);
		dp3[i]=c[i]+max(dp2[i-1],dp1[i-1]);
	}
	cout<<max(dp1[n-1],max(dp2[n-1],dp3[n-1]));
	

}


int main()
{
    aso;
	
	// cout<<"hello\n";
	bool x=0;
	ll t=1;
	if(x)
	{
		cin>>t;
	}
	while(t--)
	{
		solve();
	}
	return 0;
	
}

Measured memory_bytes: 4992
def main():

    X, N = map(int, input().split())
    if N == 0: return X
    p = list(map(int, input().split()))

    p = set(p)
    ans = 1
    l = float('inf')
    for i in range(-1, 102):
        if i not in p and abs(i-X) < l:
            l = abs(i-X)
            ans = i
    return ans



if __name__ == '__main__':
    print(main())

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N;
  cin >> N;
  long long a = 0;
  for(long long i = 1; i <= N; i++){
    long long o = i%3;
    long long p = i%5;
  	if(o == 0 && p == 0){
    	continue;
    }else if(o == 0){
     	continue;
    }else if(p == 0){
    	continue;
    }else{
    	a = a + i;
    }
  }
  cout << a << endl;
}


Measured memory_bytes: 3632
#pragma comment(linker, "/STACK:128777216")
#pragma GCC optimize("fast-maths")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <climits>
#include <ctime>
#include <random>
#include <complex>
using namespace std;

#define forx(_name, _from, _to, _value) for (int _name = _from; _name < _to; _name += _value)
#define rforx(_name, _from, _to, _value) for (int _name = _from; _name > _to; _name -= _value)
#define all(_STL_NAME) _STL_NAME.begin(), _STL_NAME.end()
#define rall(_STL_NAME) _STL_NAME.rbegin(), _STL_NAME.rend()
#define mp(_FIRST,_SECOND) make_pair(_FIRST, _SECOND)

typedef long long ll;
typedef unsigned long long llu;
typedef long double ld;
const ld eps = 1e-6;
mt19937 rndm;

void start() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cout.precision(6); cout.setf(ios::fixed);
	string FILENAME = "\-_-/";
	rndm.seed(time(0));
#ifdef _DEBUG
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#else
	//freopen((FILENAME + ".in").c_str(), "rt", stdin);
	//freopen((FILENAME + ".out").c_str(), "wt", stdout);
#endif
}


int f(string s, string t) {
	int res = 0;
	for (int i = 0; i < s.size(); ++i)
		res += (s[i] != t[i]);
	return res;
}

int main() {
	/* File On */
	start();
	string s, t;
	cin >> s >> t;
	int ans = 1e9;
	for (int i = 0; i + t.size() <= s.size(); ++i)
		ans = min(ans, f(s.substr(i, t.size()), t));
	cout << ans;
#ifdef _DEBUG
	cout << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}

Measured memory_bytes: 3204
import sys
from io import StringIO
import unittest

def resolve():
    n=int(input().strip())
    ls=[]
    for i in range(n):
        ls.append(input().strip())
    
    d={}

    for s in ls:
        if s in d:
            d[s]+=1
        else:
            d[s]=1

    saidai=0
    for k in d.keys():
        if d[k] > saidai:
            saidai=d[k]

    l=[]

    for k in d.keys():
        if d[k] == saidai:
            l.append(k)

    l.sort(reverse=False)

    for p in l:
        print(p)
        
resolve()

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

int main() {
    int N, L;
    cin >> N >> L;
    int sum = 0;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        A[i] = L + i;
        sum += A[i];
    }

    int diff = 100000000;
    int res = 0;
    for (int i = 0; i < N; i++) {
        if (abs(sum - (sum - A[i])) < diff) {
            diff = abs(sum - (sum - A[i]));
            res = sum - A[i];
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 384
s = input()
s1 = s[0:2]
s2 = s[2:4]
#print(s1)
#print(s2)
if int(s2)<=12 and int(s2)>=1:
  if int(s1)<=12 and int(s1)>=1:
    print("AMBIGUOUS")
  else:
    print("YYMM")
else:
  if int(s1)<=12 and int(s1)>=1:
    print("MMYY")
  else:
    print("NA")

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

int main () {
  
  int n; cin >>n;
  vector<int> a(n); rep(i,n) cin >> a[i];

  sort(a.begin(), a.end());

  for (int i = 1; i < n; i++) {
    if (a[i-1] == a[i]) {
      cout << "NO" << endl;
      return 0;
    } 
  }

  cout << "YES" << endl;
  
  return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
 
int a,b,c,d,area1,area2;
cin>>a>>b>>c>>d;
area1=a*b;
area2=d*c;
if(area1<area2)
cout<<area2;
else
cout<<area1;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main() {
  string S;
  cin >> S;
  cout << S.substr(0, S.size()-8) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main 
{
	static boolean[][] grid;
	static int h,w;
	static boolean[][] visited;
	static long[][] islandbw = new long[160000][2];
	static int curisland = 0;
	
	static void findIsland(int x, int y, boolean state, int island)
	{
		if(x<0||y<0||x>=w||y>=h)return;
		if(visited[x][y])return;
		if(grid[x][y] == state)
		{
			visited[x][y] = true;
//			System.out.println(x + " " + y + ": island " + island);
			if(grid[x][y])
				islandbw[island][0]++;
			else islandbw[island][1]++;
			
			//expand
			findIsland(x-1,y,!state,island);
			findIsland(x+1,y,!state,island);
			findIsland(x,y-1,!state,island);
			findIsland(x,y+1,!state,island);
		}
	}

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		h = sc.nextInt();
		w = sc.nextInt();
		grid = new boolean[w][h];
		visited = new boolean[w][h];
		
		for(int y = 0; y < h; y++)
		{
			String s = sc.next();
			for(int x = 0; x < w; x++)
			{
				grid[x][y] = s.charAt(x)=='#';
			}
		}
		
		for(int y = 0; y < h; y++)
		{
			for(int x = 0; x < w; x++)
			{
				if(!visited[x][y])
				{
					findIsland(x,y,grid[x][y],curisland);
					curisland++;
				}
			}
		}
		
		long an = 0;
		for(int i = 0; i < curisland; i++)
		{
			an += (islandbw[i][0] * islandbw[i][1]);
		}
		
		System.out.println(an);

	}

}


Measured memory_bytes: 45860
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin>>n;
    int ok=0,ng=n-1;
    string left,right;
    cout<<0<<endl;
    cin>>left;
    if(left=="Vacant") return 0;
    cout<<n-1<<endl;
    cin>>right;
    if(right=="Vacant") return 0;
    
    rep(i,18) {
        int mid=(ok+ng)/2;
        string now;
        cout<<mid<<endl;
        cin>>now;
        if(now=="Vacant") return 0;
        
        if(mid%2==0) (now==left ? ok : ng)=mid;
        else (now==right ? ok : ng)=mid;
    }
}


Measured memory_bytes: 852
#include<iostream>
#include<math.h>
using namespace std;
int a[210];
int main(void) {
	int N, L, sum = 0, min = 1000; cin >> N >> L;
	for (int i = 0; i < N; i++) {
		a[i] = L + i;
		sum += a[i];
	}
	for (int i = 0; i < N; i++) {
		if (abs(min) > abs(a[i]))min = a[i];
	}
	cout << sum - min << endl;
	return 0;
}

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

int main() {
	string s;

	cin >> s;

	int min = 999;

	for (int i = 0; i < s.length()-2; i++) {
		int tmp = (int)(s[i]-'0') * 100 + (int)(s[i+1]-'0') * 10 + (int)(s[i+2]-'0');
		if (abs(tmp - 753) < min)
			min = abs(tmp - 753);
	}

	cout << min << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()

if N % 2 == 0:
  NN = int(N / 2)
  S1 = S[:NN]
  S2 = S[NN:]
  if S1 == S2:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Measured memory_bytes: 2940
package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

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

func nextInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = nextInt()
	}
	return ints
}

func main() {
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	m := nextInt()
	brokenSteps := nextInts(m)
	brokenIndex := 0
	dp := make([]int, n+1)

	for i := 0; i <= n; i++ {
		if i == 0 {
			dp[i] = 0
			continue
		}

		if len(brokenSteps) > brokenIndex && brokenSteps[brokenIndex] == i {
			dp[i] = 0
			brokenIndex++
			continue
		}

		if i == 1 {
			dp[i] = 1
			continue
		}

		if i == 2 {
			dp[i] = dp[i-1] + 1
			continue
		}

		dp[i] = (dp[i-2] + dp[i-1]) % 1000000007
	}

	fmt.Println(dp[n])
}


Measured memory_bytes: 2816
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

typedef struct item {
  int64 v,w;
} item;

int cmp(item a,item b){
  if(a.w!=b.w) return a.w<b.w?-1:1;
  return a.v>b.w?-1:1;
}

item* enumerate(item *a,int n){
  item *p=(item *)calloc(1<<n,sizeof(item));
  item *q=(item *)calloc(1<<n,sizeof(item));
  int i;
  for(i=0;i<n;i++){
    int l=0;
    int r=0;
    int len=0;
    while(l<(1<<i)){
      item t={p[r].v+a[i].v,p[r].w+a[i].w};
      if(cmp(p[l],t)<0){
	q[len++]=p[l++];
      } else {
	q[len++]=t;
	r++;
      }
    }
    while(r<(1<<i)){
      q[len++]=(item){p[r].v+a[i].v,p[r].w+a[i].w};;
      r++;
    }
    item *swap=p;
    p=q;
    q=swap;
  }
  free(q);
  for(i=1;i<(1<<n);i++) p[i].v=MAX(p[i].v,p[i-1].v);
  return p;
}

void run(void){
  int n;
  int64 w;
  scanf("%d%lld",&n,&w);
  item p[40];
  int i;
  for(i=0;i<n;i++) scanf("%lld%lld",&p[i].v,&p[i].w);
  int m=n/2;
  item *a=enumerate(p,m);
  item *b=enumerate(p+m,n-m);
  i=0;
  int j=(1<<(n-m))-1;
  int64 max=0;
  while(i<(1<<m) && j>=0){
    if(a[i].w+b[j].w<=w){
      max=MAX(max,a[i].v+b[j].v);
      i++;
    } else {
      j--;
    }
  }
  printf("%lld\n",max);
}

int main(void){
  run();
  return 0;
}



Measured memory_bytes: 42764
using System;
using System.Linq;
class Program
{
    static void Main()
    {
        int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray(); 
        //int a=int.Parse(Console.ReadLine());
        //string a = Console.ReadLine();
        
        Console.WriteLine(Math.Min(input[0]*input[1],input[2]));
        Console.ReadLine();
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
using namespace std;
int main(){
	string a,s;
	int f[26],g=0;
	cin>>a;
	for(int i=0;i<a.size();i++){
		f[i]=0;
		for(int j=0;j<a.size();j++){
			if(a[i]==a[j] && i!=j){
				f[i]=1;
				g=f[i];
				break;
			}
		}
	}
	if(g==1)cout<<"no"<<endl;
	if(g==0)cout<<"yes"<<endl;
	
	return 0;
}

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

int w, h, n;
struct Point {
  int x, y, num;
  bool operator < (const Point p) const {
    if(y == 0) {
      if(p.y == 0) return (x < p.x);
      return (true);
    }
    if(x == w) {
      if(p.y == 0) return (false);
      if(p.x == w) return (y < p.y);
      return (true);
    }
    if(y == h) {
      if(p.x == 0) return (true);
      if(p.y == h) return (x > p.x);
      return (false);
    }
    if(x == 0) {
      if(p.x == 0) return (y > p.y);
      return (false);
    }
  }
    
};


#define int long long

main()
{
  vector < Point > p;
  
  cin >> w >> h >> n;
  for(int i = 0; i < n; i++) {
    int sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;
    
    if(sx != 0 && sy != 0 && sx != w && sy != h || gx != 0 && gy != 0 && gx != w && gy != h) continue;
    
    p.push_back( (Point) { sx, sy, i } );
    p.push_back( (Point) { gx, gy, i } );
    
  }

  sort(p.begin(), p.end());

  stack < int > st;
  for(int i = 0; i < p.size(); i++) {
    if(st.empty() || st.top() != p[i].num) {
      st.push(p[i].num);
    } else {
      st.pop();
    }
  }

  if(st.empty()) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
  return (0);
}
  

Measured memory_bytes: 4596
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <string>
#define rep(i, n) for (int i = 0; i < n; i++) 

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int h[n];
    int cnt = 0;
    int A[m], B[m];
    map<int, int> high;
    rep(i, n) cin >> h[i];
    rep(i, m) {
        cin >> A[i] >> B[i];
        if (high.count(A[i]-1) == 0) {
            high.insert(make_pair(A[i]-1, h[B[i]-1]));
        }
        if (high.count(B[i]-1) == 0) {
            high.insert(make_pair(B[i]-1, h[A[i]-1]));
        }
        if (high.at(A[i]-1) < h[B[i]-1]) {
            high.erase(A[i]-1);
            high.insert(make_pair(A[i]-1, h[B[i]-1]));
        }
        if (high.at(B[i]-1) < h[A[i]-1]) {
            high.erase(B[i]-1);
            high.insert(make_pair(B[i]-1, h[A[i]-1]));
        }
    }
    rep(i, n) {
        if (high.count(i) == 0) {
            cnt++;
            continue;
        } 
        if (h[i] > high.at(i)) {
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 8832
N, K = map(int,input().split())
a = list(map(int,input().split()))
if a[0] > K:
    ans = a[0]-K
    a[0] = K
else:
    ans = 0
for i in range(1, N):
    if a[i-1]+a[i] > K:
        ans += a[i] - (K-a[i-1])
        a[i] = K-a[i-1]
print(ans)

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

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

      
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<climits>
#include<math.h>
#include<cstdio>
using namespace std;

struct Point{
	double x;
	double y;
};

void Projection(Point &p1,Point &p2,Point &p){
	double e=sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
	double ex=(p2.x-p1.x)/e;
	double ey=(p2.y-p1.y)/e;
	double inner=ex*(p.x-p1.x)+ey*(p.y-p1.y);
	double x=p1.x+inner*ex;
	double y=p1.y+inner*ey;
	printf("%.10lf %.10lf \n",x,y);
}

int main(){
	int q;
	Point p1,p2,p;
	cin >> p1.x >> p1.y >> p2.x >> p2.y;
	
	cin >> q;
	
	for (int i=0;i<q;i++){
		cin >> p.x >> p.y;
		Projection(p1,p2,p);
	}
	return 0;
}

Measured memory_bytes: 1248
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	ll N,H,W;
	cin >> N>>H>>W;
 
	// 解法
	ll ans = (N-H+1)*(N-W+1);
	
	//出力
	cout << ans << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	int x = in();
	cout << (x < 1200 ? "ABC" : "ARC") << endl;
}

Measured memory_bytes: 256
def f(a)
    if a.size == 1
        a[0] / 2 + 1
    else
        a.map{|b| f(b)}.sort[0..a.size/2].inject(:+)
    end
end
n = gets.to_i
n.times {
    s = gets.chomp.gsub!(/\](?=\[)/, '],')
    p f(eval(s))
}

Measured memory_bytes: 7508
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  int n,q;cin>>n>>q;
  string s;cin>>s;
  int i,j;
  int l[100001],r[100001];
  for(i=0;i<q;i++){
    cin>>l[i]>>r[i];
  }

  bool kari=false;
  int cir[100001];
  int count=0;
    for(i=0;i<n;i++){
      if(kari&&s[i]=='C') {count++;cir[i]=count;kari=false;}
      else if(s[i]=='A') {cir[i]=count;kari=true;}
      else {cir[i]=count;kari=false;}
    }

    for(i=0;i<q;i++){
      int ans=0;
      ans=cir[r[i]-1]-cir[l[i]-1];
      cout<<ans<<endl;
    }

}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;

int main(){
    int x;
    cin>>x;
    if(x==0) printf("1");
    else if(x==1) printf("0");
}


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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

int main() {

	IOS

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

	int sum = 0, a;
	for (int i = 0; i < m; i++) {
		cin >> a;
		sum += a;
	}

	int hangout = n-sum;
	cout << (hangout < 0 ? -1 : hangout) << endl;

	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;

bool yaku(int n) {
	int i, count = 0;

	for (i = 1; i <= n; i++) {
		if (n%i == 0) {
			count++;
		}
		if (count == 8)
			return 1;
	}

	return 0;
}

int main() {
	int n, i, count = 0;

	cin >> n;

	for (i = 1; i <= n; i+=2) {
		if (yaku(i)) {
			count++;
		}
	}
	cout << count;
	
	return 0;
}

Measured memory_bytes: 256
/*
 * ALDS1_11_D.cpp
 *
 *  Created on: May 8, 2018
 *      Author: 13743
 */

#include<iostream>
#include<vector>

using namespace std;

int visited[100000];
int la = 1;

void dfsRec(vector<int>* a, int v) {
	if(visited[v] != 0) return;
	visited[v] = la;
	for(int &x:a[v]) {
		dfsRec(a, x);
	}
}

int main() {
	int n, m;
	vector<int> adj[100000];

	cin >> n >> m;
	int u, v;
	for(int i=0; i<m; i++) {
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	for(int i=0; i<n; i++) {
		if(visited[i] == 0) {
			dfsRec(adj, i);
			la++;
		}
	}

	int q;
	cin >> q;
	while(q--) {
		cin >> u >> v;
		(visited[u]==visited[v]) ? printf("yes\n") : printf("no\n");
	}
}





Measured memory_bytes: 12056
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
const int N = 2e5 + 10, OO = 0x3f3f3f3f, mod = 1e9 + 7;

#define PI acos(-1)
#define clr(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, n) for (int i = 0; i < int(n); i++)
#define rloop(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define xloop(i, a, b) for (int i = int(a); i <= int(b); i++)
#define ALL(v) ((v).begin()), ((v).end())
#define SZ(v) ((int)((v).size()))
//int dx[] = {1, 0, -1, 0};
//int dy[] = {0, 1, 0, -1}; //4 Direction
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
//int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; //8 direction
int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

//-- "كلٌّ من يسعى لابد يصل .. كلٌّ من يسعى مضمون له الوصول" --//


int n , m , h[N];

int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	
	scanf("%d %d", &n , &m);
	for(int i = 1 ; i <= n ; ++i)
		scanf("%d" , &h[i]);
		
	map < int,  int> obs;
	for(int i = 0 ; i < m ; ++i){
		int from , to;
		scanf("%d %d", &from , &to);
		obs[from] = max(obs[from] , h[to]);
		obs[to] = max(obs[to] , h[from]);
	}
	
	int cnt = 0;
	for(int i = 1 ; i <= n ; ++i)
		if(h[i] > obs[i])
			cnt++;
	printf("%d\n" , cnt);
	
	
    return 0;
}




Measured memory_bytes: 8808
N=int(input())


X=[1]+[6**i for i in range(1,7)]+[9**i for i in range(1,6)]
X.sort()
X.reverse()

ANS=1000000



i=4



for i_0 in range(max(N//X[0]-i,0),N//X[0]+1):
    N_0=N-X[0]*i_0
    for i_1 in range(max(N_0//X[1]-i,0),N_0//X[1]+1):
        N_1=N_0-X[1]*i_1
        for i_2 in range(max(N_1//X[2]-i,0),N_1//X[2]+1):
            N_2=N_1-X[2]*i_2
            for i_3 in range(max(N_2//X[3]-i,0),N_2//X[3]+1):
                N_3=N_2-X[3]*i_3
                for i_4 in range(max(N_3//X[4]-i,0),N_3//X[4]+1):
                    N_4=N_3-X[4]*i_4
                    for i_5 in range(max(N_4//X[5]-i,0),N_4//X[5]+1):
                        N_5=N_4-X[5]*i_5
                        for i_6 in range(max(N_5//X[6]-i,0),N_5//X[6]+1):
                            N_6=N_5-X[6]*i_6
                            for i_7 in range(max(N_6//X[7]-i,0),N_6//X[7]+1):
                                N_7=N_6-X[7]*i_7
                                for i_8 in range(max(N_7//X[8]-i,0),N_7//X[8]+1):
                                    N_8=N_7-X[8]*i_8
                                    for i_9 in range(max(N_8//X[9]-i,0),N_8//X[9]+1):
                                        N_9=N_8-X[9]*i_9
                                        i_10=N_9//6
                                        N_10=N_9-X[10]*i_10
                                        if ANS>i_0+i_1+i_2+i_3+i_4+i_5+i_6+i_7+i_8+i_9+i_10+N_10:
                                            ANS=i_0+i_1+i_2+i_3+i_4+i_5+i_6+i_7+i_8+i_9+i_10+N_10


                                            




print(ANS)
        
    


Measured memory_bytes: 3192
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(N: int, K: int, X: int, Y: int):
    if N <= K:
        print(N*X)
    else:
        print(K*X+(N-K)*Y)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(N, K, X, Y)


if __name__ == '__main__':
    main()


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

// F: maximum flow, O(F|E|)
class Graph{
    public:
    const ll INF = 1e18;

    struct edge{
        ll to, cap, rev;
    };
    ll size;
    vector<vector<edge> > g;
    vector<bool> checked;

    Graph(ll n){
        size = n;
        g = vector<vector<edge> >(size);
        checked = vector<bool>(size);
    }

    void add_edge(ll from, ll to, ll cap){
        // one is the rev-edge of the other
        g[from].push_back((edge){to, cap, (ll)g[to].size()});
        g[to].push_back((edge){from, 0LL, (ll)g[from].size() - 1});
    }

    ll dfs(ll v, ll t, ll f){
        if(v == t) return f;
        checked[v] = true;
        for(edge &e: g[v]){
            if(!checked[e.to] && e.cap > 0){
                ll d = dfs(e.to, t, min(f, e.cap));
                if(d > 0){
                    e.cap -= d;
                    g[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    ll maxflow(ll s, ll t){
        ll flow = 0;
        while(1){
            fill(checked.begin(), checked.end(), false);
            ll f = dfs(s, t, INF);
            if(f == 0) return flow;
            flow += f;
        }
    }
};

// GRL_6_A: verified
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll v, e; cin >> v >> e;
    Graph graph(v);
    for(ll i=0;i<e;i++){
        ll u, v, c; cin >> u >> v >> c;
        graph.add_edge(u, v, c);
    }
    cout << graph.maxflow(0, v - 1) << endl;
}


Measured memory_bytes: 3256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
#include <math.h>
#include <iomanip>
#include <limits>

using namespace std;
using ll = long long;
const ll res = 1000000007;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int main() {
	ll n, ans = 0;
	cin >> n;
	for (ll i=1; i< n+1;i++){
		if (i % 3 != 0 and i % 5 != 0) ans += i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int n;
    cin >> n;
    string s , t, ans;
    cin >> s >> t;
    for(int i = 0; i < n; ++i){
        ans += s.at(i);
        ans += t.at(i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3576
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s,a="CODEFESTIVAL2016";
	int cnt=0,i;
	cin>>s;
	for(i=0;i<16;i++){
		if(s[i]!=a[i]) cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

// 最大公約数 : 3,4 ->  1
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

void solve()
{
	ll a, b;
	cin >> a >> b;

	map<ll, bool> cd;
	cd[1] = true;
	ll prime = 2;
	while(a >= prime * prime)
	{
		if (a % prime == 0)
		{
			while(a % prime == 0) a /= prime;
			cd[prime] = true;
		}
		prime++;
	}
	cd[a] = true;

	prime = 2;
	ll ans = 1;
	while(b >= prime * prime)
	{
		if (b % prime == 0)
		{
			while(b % prime == 0) b /= prime;
			if (cd.find(prime) != cd.end())
			{
				ans++;
			}
		}
		prime++;
	}
	if (b != 1 && cd.find(b) != cd.end())
	{
		ans++;
	}


	cout << ans;

	
	/*
	// 常に a < b にする
	if (a > b)
	{
		swap(a, b);
	}

	vector<ll> cd;
	for(ll i = 1; i * i <= a; ++i)
	{
		if (a % i == 0 && b % i == 0)
		{
			cd.emplace_back(i);
			if (b % (a / i) == 0)
			{
				cd.emplace_back(a / i);
			}
		}
	}

	sort(cd.begin(), cd.end());
	cd.erase(unique(cd.begin(), cd.end()), cd.end());

	if (cd.size() == 1)
	{
		cout << 1;
		return;
	}

	for(const auto& c : cd)
	{
		cout << c << " ";
	}
	cout << endl;

	ll ans = 2;
	ll lcd = cd[1];
	for(ll i = 2LL; i < cd.size(); ++i)
	{
		if (gcd(lcd, cd[i]) == 1LL)
		{
			lcd *= cd[i];
			ans++;
		}
	}
	cout << ans;
	//*/
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
long long n;
int main() {
    cin >> n;
    long long cnt = 0;
    if(n % 2 == 0) {
        n /= 2;
        long long pow = 5;
        while(n >= pow) {
            cnt += n / pow;
            pow *= 5;
        }
    }else {
        cnt = 0;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
<?php
$f = fopen( 'php://stdin', 'r' );
$line = fgets( $f );
$numbers = array_map('intval', explode(" ",$line));
$result[0] = $numbers[2];
$result[1] = $numbers[0];
$result[3] = $numbers[1];
echo implode(" ",$result);
?>

Measured memory_bytes: 4856
from sys import stdin

lines = stdin.readlines()

n, m = [int(x) for x in lines[0].rstrip().split()]
a_s = [int(x) for x in lines[1].rstrip().split()]

study_day = sum(a_s)
if n >= study_day:
    print(n - study_day)
else:
    print(-1)


Measured memory_bytes: 10068
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i < (int)n; i++)

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  
  rep(i,n) cin >> p[i];
  
  int k = 0;
  
  rep(i,n) if(p[i] != i+1)k++;
  if(k<=2) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXn = 2e5 + 10;
typedef pair<int, bool> pib;

vector<int> g[MAXn], vecb, veca;
bool flag[MAXn][2], aorb[MAXn];
int n, m, dega[MAXn], degb[MAXn], sz[MAXn], cnt;
set<int> st;
void dela(int a) {
	if (st.find(a) != st.end())
		return ;
	st.insert(a);
	for (int i = 0; i < g[a].size(); i++) {
		--dega[g[a][i]];
		if (0 == dega[g[a][i]]) {
			if (aorb[g[a][i]] == 0)
			veca.push_back(g[a][i]);
			else
			vecb.push_back(g[a][i]);
		}
	}
}

void delb(int a) {
	if (st.find(a) != st.end())
		return ;
	st.insert(a);
	for (int i = 0; i < g[a].size(); i++) {
		--degb[g[a][i]];
		if (0 == degb[g[a][i]]) {
			if (aorb[g[a][i]] == 0)
			veca.push_back(g[a][i]);
			else
			vecb.push_back(g[a][i]);
		}
	}
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		char ch;
		cin >> ch;
		if (ch == 'B')
			aorb[i] = 1;
	}
	
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;u--; v--;
		
		if (aorb[u])
			degb[v]++;
		else
			dega[v]++;
			
		if (v != u && aorb[v])
			degb[u]++;
		else if (v != u)
			dega[u]++;
				
		g[u].push_back(v);
		if (v != u)
			g[v].push_back(u);
	}
	for (int i = 0; i < n; i++) {
		if (dega[i] == 0 || degb[i] == 0) {
			if (aorb[i] == 0)
			veca.push_back(i);
			else
			vecb.push_back(i);
		}
	}
	int i = 0, j = 0;
	while((i != veca.size() || j != vecb.size())) {
		for ( ; i < veca.size(); i++)
			dela(veca[i]);
		for ( ; j < vecb.size(); j++)
			delb(vecb[j]);
	}
	if (st.size() != n)
		return cout << "Yes",0;
	cout << "No";
}

Measured memory_bytes: 22680
#include<bits/stdc++.h>
#define int long long int
#define ldouble long double
#define vin vector<int>
#define rep(a,n) for(int i=(a);i<(n);i++)
#define INF (int)1000000007

//setprecision()<<

const int MAX = 510000;
const int MOD = INF;

long long fac[MAX], finv[MAX], inv[MAX];

using namespace std;

void fin(int n, vin &a) {
	rep(0, n) {
		cin >> a.at(i);
	}
}

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main() {
	int N, K;
	cin >> N >> K;
	vin A(N);
	rep(0, N) {
		cin >> A.at(i);
	}
	sort(A.begin(), A.end());
	rep(i, N)A[i] = (A[i] + MOD) % MOD;
	int sum = 0;
	COMinit();
	for (int i = N; i >= K; i--) {
		sum += ((A.at(i - 1) - A.at(N - i)+MOD)%MOD)*COM(i - 1, K - 1) % INF;
		sum %= INF;
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 12928