akhauriyash/Code-Regression huggingface dataset:
from decimal import *
n,k=map(int,input().split())
a=list(map(int,input().split()))
aa=[[0,0] for i in range(n)]
for i in range(n):
    for j in range(n):
        if i>j:
            if a[i]>a[j]:
                aa[i][0]+=1
        if i<j:
            if a[i]>a[j]:
                aa[i][1]+=1
ans=0
mod=10**9+7
for i in range(n):
    ans+=(aa[i][0]+aa[i][1])*k*(k+1)//2
    ans-=aa[i][0]*k
print(int(ans%mod))

Measured memory_bytes: 78440
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	vector<int>a(n);
	vector<int>b(n);

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

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

	int ans = 0;
	for (int i = 0; i < n; i++) {
		int sum = 0;
		for (int j = 0; j <= i; j++) {
			sum += a[j];
		}

		for (int j = i; j < n; j++) {
			sum += b[j];
		}

		ans = max(ans, sum);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  int left=0,right=N;
  cout<<left<<endl;
  string L; cin>>L;
  rep(i,1,20){
    int mid=(left+right)/2;
    cout<<mid<<endl;
    string S; cin>>S;
    if(S=="Vacant") break;
    else if((mid-left)%2==0){
      if(L==S){
        left=mid;
        L=S;
      }
      else{
        right=mid;
      }
    }
    else{
      if(L==S){
        right=mid;
      }
      else{
        left=mid;
        L=S;
      }
    }
  }
  }


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

int main() {
  long N, MOD = 1e9+7;
  cin >> N;
  vector<long> A(N);
  for (long i = 0; i < N; i++) cin >> A.at(i);
  vector<long> R(N + 1);
  for (long i = 1; i < N + 1; i++) R.at(i) = R.at(i - 1) + A.at(i - 1);
  long ans = 0;
  for (long i = 0; i + 1 < N; i++) {
    long X = A.at(i);
    long Y = R.at(N) - R.at(i + 1);
    Y %= MOD;
    X *= Y;
    X %= MOD;
    ans += X;
    ans %= MOD;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 6420
#include <iostream>

using namespace std;

int main(){
	int vac, jap[2], math[2], hw;

	cin >> vac >> jap[0] >> math[0] >> jap[1] >> math[1];

	hw = 1;
	while (1){
		if ((jap[0] - jap[1]) > 0 || (math[0] - math[1]) > 0){
			jap[0] -= jap[1];
			math[0] -= math[1];
			hw++;
		}
		else {
			break;
		}
	}

	cout << vac - hw << endl;

	return 0;
}

Measured memory_bytes: 3036
#include <bits/stdc++.h>
#define MAX (ll)(1e5 + 7)
#define INF (ll)(1e18)
#define MOD (ll)(1e9 + 7)

using namespace std;
using ll = long long;
using cd = complex<double>;
using p = pair<ll,  ll>;
using pp = pair<pair<ll, ll>, pair<ll, pair<ll, ll>>>;

int main () {
	ll ans = 0;
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		ll x = n / i;
		ans += i * (x * (x + 1)) / 2;
	}
	cout << ans << "\n";
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int nlong,klong;
  char strs[10];
    cin >> nlong;
    cin >> strs;
    cin >> klong;
    
    for (int i = 0; i < nlong; i++) {
      if(strs[i] != strs[klong-1]){
        strs[i] = '*';
      }
    }
  
   cout << strs << endl;
 
  
    
}


Measured memory_bytes: 256
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    x=int(readline())
    flag=False
    for A in range(-200,201):
        for B in range(-200,201):
            if A**5-B**5==x:
                print(A,B)
                flag=True
        if flag:
            break

if __name__=="__main__":
    main()

Measured memory_bytes: 9120
import java.util.*;

/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<String, Integer> map = new HashMap<>();
		int maxCount = 1;

		for (int j = 0; j < n; j++) {
			String word = sc.next();
			if (map.containsKey(word)) {
				map.replace(word, map.get(word) + 1);
				maxCount = Math.max(maxCount, map.get(word));
			} else {
				map.put(word, 1);
			}
		}
		sc.close();

		Map<String, Integer> result = new TreeMap<>();
		for (Map.Entry<String, Integer> entry : map.entrySet()) {
			if (entry.getValue() == maxCount) {
				result.put(entry.getKey(), null);
			}
		}

		for (String word : result.keySet()) {
			System.out.println(word);
		}

	}
}

Measured memory_bytes: 89868
#include <stdio.h>
#include <cmath>
#include <algorithm>

using namespace std;



int main(){

	char buf[30];
	int n,sum,runner_num,out_count;

	scanf("%d",&n);

	for(int i=0; i < n; i++){

		sum = 0,runner_num = 0,out_count=0;

		while(out_count < 3){
			scanf("%s",buf);

			switch(buf[1]){
			case 'I':
				runner_num++;
				if(runner_num == 4){
					sum += 1;
					runner_num = 3;
				}
				break;
			case 'O':
				sum += runner_num + 1;
				runner_num = 0;
				break;
			case 'U':
				out_count++;
				break;
			}
		}
		printf("%d\n",sum);
	}
    return 0;
}

Measured memory_bytes: 2612
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2020 Bjarni Dagur Thor Karason

#include <bits/stdc++.h>

using namespace std;

#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); i++)
#define MP make_pair
#define PB push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
#define PI 3.14159265359

int n;
vi arr;
ll memo[3005][3005];

ll dp(int l, int r)
{
    if (memo[l][r] != -1) return memo[l][r];
    if (l == r) return arr[l];
    return memo[l][r] = max(arr[l] - dp(l + 1, r), arr[r] - dp(l, r - 1));
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    memset(memo, -1, sizeof(memo));
    cin >> n;
    arr.resize(n);
    for (int i = 0; i < n; i++) cin >> arr[i];
    cout << dp(0, n - 1) << endl;

    return 0;
}

Measured memory_bytes: 70912
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll n, k, l;
	cin>>n>>k;
	ll ans = 0, a[n];
	for(int i = 0 ; i< n; i++)
		cin>>a[i];
	if(n<=k)
		ans = 0;
	else
	{
		l = sizeof(a)/sizeof(a[0]); 
		sort(a, a+l);
	}
	for(int i = 0; i <n-k; i++)
	{
		ans = ans + a[i];
	}
	cout<<ans<<endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
	int n,i,ali,bob;
	cin >> n;
	vector<int> a(n);
	
	rep(i, n) {
		cin >> a.at(i);
	}
	ali = bob = 0;
	rep(i, n) {
		vector<int>::iterator iter = max_element(a.begin(), a.end());
		size_t index = distance(a.begin(), iter);
		if (i % 2 == 0)	ali += a.at(index);
		else			bob += a.at(index);
		a.at(index) = -1;
	}
	cout << ali - bob << endl;
	return 0;
}

Measured memory_bytes: 256
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int a, b;
	cin >> a >> b;
	cout << a*b - a -b +1 << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long w = sc.nextLong();
		long h = sc.nextLong();
		int x = sc.nextInt();
		int y = sc.nextInt();
		double s = w * h * 0.5;
		System.out.println(s+" "+(x * 2 == w && y * 2 == h ? 1 : 0));
	}
}

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

int main() {
    // input
    string w;
    cin >> w;

    // solve
    int cnt[26] = {0};
    bool flag = true;
    for (int i = 0; i < w.length(); ++i) {
        cnt[w[i] - 'a']++;
    }
    for (int i = 0; i < 26; ++i) {
        if (cnt[i] % 2 != 0) {
            flag = false;
            break;
        }
    }

    // output
    cout << (flag ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
x=1/n
y=1/2
ans=0
for i in range(1,n+1):
    if i>=k:
        ans+=x
        continue
    for j in range(18):
        if i*2**j>=k:
            ans+=x*y**j
            break
print(ans)

Measured memory_bytes: 3060
import math
import sys
import collections
import bisect


def main():
    n, m = map(int, input().split())
    x = sorted(list(map(int, input().split())))
    if m <= n:
        print(0)
        return
    y = sorted([x[i + 1] - x[i] for i in range(m - 1)])
    print(sum(y[0:(m-n)]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 20420
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <vector>
using namespace std;


int main(){
	/*input*/
//	long long n;
	int n ,r;
	cin >> n >> r;
//	int s[n];
//	for(int i = 0; i < n; i++){
//		cin >> s[i];
//	}

	/*calc*/
	int ans = 0;
	ans = 100*(10-n)+r;
//	for(int i = 0; i < n; i++){
//
//	}
	if(n >= 10)cout << r << endl;
	else{
		/*output*/
		cout<< ans <<endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <numeric>

int main(void) {
	int a, b, k;

	std::cin >> a >> b >> k;

	for (size_t i = 0; i < k; i++) {
		if (i % 2 == 0) {
			if (a % 2 == 1) {
				a--;
			}
			b += a / 2;
			a /= 2;
		}
		else {
			if (b % 2 == 1) {
				b--;
			}
			a += b / 2;
			b /= 2;
		}
	}
	
	std::cout << a << " " << b << std::endl;

	return 0;
}

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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
	int n, k;
	cin >> n >> k;
	int h[n];
	REP(i, n) cin >> h[i];
	int d[n];
	d[0] = 0;
	FOR(i, 1, n) d[i] = INF;
	FOR(i, 1, n){
		FOR(j, 1, min(i+1, k+1)) d[i] = min(d[i], d[i-j]+abs(h[i]-h[i-j]));
	}
	cout << d[n-1] << endl;
} 

Measured memory_bytes: 1024
#include <iostream> 
using namespace std; 
int main() 
{
int i,n,max,min;
long sum;
int a[10000];
cin >> n;
for(i=0;i<n;++i)
    cin >> a[i];
sum=0;
min=a[0];
max=a[0];
for(i=0;i<n;++i)
    sum+=a[i];
for(i=0;i<n;++i)
{
    if(min>a[i])
        min=a[i];
}
for(i=0;i<n;++i)
{
    if(max<a[i])
        max=a[i];
}
cout << min << ' ' << max << ' ' << sum << endl;
}


Measured memory_bytes: 3124
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int d,r;
		double f;
		
		d = a/b;
		r = a%b;
		f = (double)a/b;
		
		System.out.printf("%d %d %f\n",d,r,f);
		sc.close();
	}
}


Measured memory_bytes: 26552
s = sorted(list(input()))
t = sorted(list(input()), reverse = True)

Alpha = ['0', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 
         'u', 'v', 'w', 'x', 'y', 'z']

while len(s) != len(t):
    if len(s) > len(t):
        t.append('0')
    else:
        s.append('0')

for i in range(len(s)+1):
    if i == len(s):
        print('No')
    elif Alpha.index(s[i]) < Alpha.index(t[i]):
        print('Yes')
        break
    elif Alpha.index(s[i]) > Alpha.index(t[i]):
        print('No')
        break
    else:
        continue



Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var hn = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var ai = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(ai.Sum() >= hn[0] ? "Yes" : "No");
        }
    }
}


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


int main() {

	int n;
	cin >> n;

	vector <int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ma = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {

			if (i == j) {
				continue;
			}
			ma = max(ma, abs(a[i] - a[j]));

		}
	}

	cout << ma << endl;



	return 0;
}




Measured memory_bytes: 256
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define all(v) v.begin(), v.end()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
Long fun(string x) {
  fore(i, 0, SZ(x)) if (x[i] == '.') x[i] = ' ';
  stringstream ss(x);
  Long a, b;
  ss >> a >> b;
  return a * 100 + b;
}
void solve() {
  Long a;
  cin >> a;
  string f;
  cin >> f;
  Long val = fun(f);
  a *= val;
  a /= 100;
  cout << a << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int t = 1;
  //cin >> t;
  while (t--) solve();

  return 0;
}

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

using ull = unsigned long long;
using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;
const int inf = INT_MAX;

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

    int k;
    cin >> k;
    
    string res;
    while (k--) res += "ACL";
    cout << res;
    return 0;
}

Measured memory_bytes: 3596
// Problem : C - H and V
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_c
// Memory Limit : 1024 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cerr << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cerr << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define all(x) (x).begin() , (x).end()
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
		int n, m , k;
		cin >> n >> m >> k;
		
		int cnt = 0;
		
		string a[n];
		for(int i = 0 ; i < n ; i++)
			cin >> a[i];
		
		for(int i = 0 ; i < (1 << n) ; i++){
			for(int j = 0 ; j < (1 << m) ; j++){
				int sum = 0;
				for(int x = 0 ; x < n ; x++){
					for(int y = 0 ; y < m ; y++){
						if(a[x][y] == '#' && !(i & (1 << x)) && !(j & (1 << y)))sum++;
					}
				}
				
				if(sum == k)cnt++;
			}
		}
		
		cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#define ll long long
using namespace std;
int main()
{
    int a,b,c;
    while(~scanf("%d%d",&a,&b))
    {
        c=(a-1)*(b-1);
        printf("%d\n",c);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;

bool avl[1003][1003];

int main() {
	ll n; cin >> n;
	vector<vector<int>> a(n, vector<int>(n, -1));
	vector<int> idx(n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n - 1; j++) {
			cin >> a[i][j]; a[i][j]--;
		}
	}
	deque<pair<int, int>> que, que_;
	auto f = [&](int u) {
		return a[u][idx[u]];
	};
	for (int i = 0; i < n; i++) {
		avl[i][f(i)] = true;
		if (avl[f(i)][i]) {
			que_.push_back({ i, f(i) });
		}
	}
	int cnt = 0, ans = 0;
	while (!que_.empty()) {
		ans++;
		swap(que, que_);
		while (!que.empty()) {
			auto p = que.front(); que.pop_front();
			int u = p.first, v = p.second;
			cnt++;
			idx[u]++; idx[v]++;

			if (f(u) != -1) {
				avl[u][f(u)] = true;
				if (avl[f(u)][u]) que_.push_back({ u, f(u) });
			}
			if (f(v) != -1) {
				avl[v][f(v)] = true;
				if (avl[f(v)][v]) que_.push_back({ v, f(v) });
			}
		}
	}
	if (cnt == n*(n - 1) / 2) cout << ans << endl;
	else cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


ll check2(ll x, int t, ll n2){
  // 2^t = n2;
  // [0, x] の整数について、t ビット目が1となるものの数を返す
  // 偶奇が大事
  if (t == 0){
    // 0 ビット目に関しては2で割った切り上げが答え
    ll buf = (x + 1) / 2;
    return buf % 2;
  }else if (t == 1){
    // 4の倍数分は01, 10, 11, 00 なので2つ塊で偶数。
    // 4で割った余りが2であれば奇数
    ll buf = x % 4;
    int res = buf == 2 ? 1 : 0;
    return res;
  }else if (t == 2){
    // 8の倍数分は001,010,011,100,101,110,111,000 なので4つ塊で偶数。
    // 8で割った余りが4,6であれば奇数
    ll buf = x % 8;
    int res = 0;
    if (buf == 4 || buf == 6) res = 1;
    return res;
  }else{
    // 2^t = n2 の倍数分は - なので2^(t-1)つ塊で偶数。
    // 2^t で割った余りが2^(t-1), 2^(t-1) + 2, 2^(t-1) + 4, ..., 2^t - 2 であれば奇数
    ll buf = x % (n2 * 2);
    if (buf < n2) return 0;
    int tmp = buf % 2;
    if (tmp == 0) return 1;
    else return 0;
  }

}

ll check(ll x, ll y, int t, ll n2){
  // t ビット目について、[x, y] の排他的論理和を求める
  // ft(x, y) みたいなやつ
  // 2^t = n2
  // 要は t ビット目が1であるものが奇数個あればn2、偶数個あれば0を返す
  if (y < n2) return 0;
  // [0, y] の個数から[0, x-1] の個数を引けば [x, y] の個数が分かる
  int buf = check2(y, t, n2) - check2(x-1, t, n2) + 100;
  buf %= 2;
  ll res = buf == 1 ? n2 : 0;
  return res;
}

int main() {
  ll A,B; cin >>A >>B;
  if (A == B){ cout <<A <<endl; return 0; }
  if (A+1 == B){ cout <<(A^B) <<endl; return 0; }
  A = A == 0 ? 1 : A;

  ll res = 0;
  ll n2 = 1;
  rep(i, 41){
    if (i > 0) n2 *= 2;
    ll tmp = check(A, B, i, n2);
    // if (tmp == -1) break;
    res += tmp;
  }
  cout <<res <<endl;
}

/*

*/


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
class Main {
 
  
 
  public static void main(String[] args) {
    Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    int INF = (int) 1e9 + 7;
 
    int N = in.nextInt();
    int K = in.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) {
      a[i] = in.nextInt();
    }
 
    int[] dp = new int[K + 1];
    dp[0] = 1;
    // Arrays.fill(dp[0], 1);
    for (int child = 0; child < N; child++) {
      int[] tmp = new int[K + 1];
      for (int used = K; used >= 0; used--) {
 
        // pre + (j - a[i - 1] ... j)
        // int pre = (dp[i - 1][j] - (j - a[i - 1] <= 0 ? 0 : dp[i - 1][j - a[i - 1] - 1]));
        // if (pre < 0) {pre += INF;}
        // dp[i][j] = (j == 0 ? 0 : dp[i][j - 1]) + pre;
        // if (dp[i][j] >= INF) {dp[i][j] -= INF;}
        
        int delta = dp[used];
        int L = used + 1;
        int R = used + Math.min(a[child], K - used);

        if (L <= R) {
          tmp[L] += delta;
          if (tmp[L] >= INF) tmp[L] -= INF;
          if (R + 1 <= K) {
            tmp[R + 1] -= delta;
            if (tmp[L] < 0) tmp[L] += INF;
          }
        }

        // for (int here = 1; here <=  Math.min(a[child], K - used); here++) {
        //   dp[used + here] += dp[used];
        //   if (dp[used] >= INF) {dp[used] -= INF;}
        // }
      }

      int prefix = 0;
      for (int i = 0; i <= K; i++) {
        prefix += tmp[i];
        if (prefix >= INF) prefix -= INF;
        if (prefix < 0) prefix += INF;
        dp[i] += prefix;
        if (dp[i] >= INF) dp[i] -= INF;
        if (dp[i] < 0) dp[i] += INF;

      }
    }
    
    // int res = dp[N][K] - (K == 0 ? 0 : dp[N][K - 1]);
    System.out.println(dp[K]);
  }
 
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

int main() {
    fastio;
    int n;
    cin >> n;
    int* a = new int[n];

    for (int i = 0; i < n; ++i) cin >> a[i];

    sort(a, a + n);

    if (a[n / 2] == a[n / 2 - 1]) cout << 0;
    else {
        cout << a[n / 2] - a[n / 2 - 1];
    }

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
char s[100000];
long long int i,j,x;
int main()
{
    cin >> s;
    for(i = 0; s[i] != '\0'; i++)
    {
        if(s[i] == '+')
        {
            x++;
        }
        else
        {
            x--;
        }
    }
    cout << x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define mod 1000000007
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a)
int main(){
  lli A=0,B,C,D,E,F,N,M,K,sum=0,num=0,cnt=1,next=0;
  cin >> N >> K;
  Vec(P,lli,N,0);
  rep(i,0,N)cin >> P[i];
  rep(i,0,N){
    if(next>P[i])sum-=(next-P[i]);
    else next=P[i];
    sum+=K;
    next=P[i]+K;
  }
  Out(sum);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
int main() {
    int h, w, k;
    cin >> h >> w >> k;
    auto s = vector<vector<bool>>(h, vector<bool>(w, false));
    rep(i, h) {
        rep(j, w) {
            char c;
            cin >> c;
            if (c == '#') s[i][j] = true;
        }
    }
    auto ans = vector<vector<int>>(h, vector<int>(w, 0));
    int current = 0;
    rep(i, h) {
        rep(j, w) {
            if (s[i][j]) {
                current++;
                ans[i][j] = current;
                int l, r;
                if (j == 0) {
                    l = 0;
                } else {
                    for (l = j - 1; l >= 0; l--) {
                        if (ans[i][l] == 0 && s[i][l] == false) {
                            ans[i][l] = current;
                        } else {
                            break;
                        }
                    }
                    l++;
                }
                if (j == w - 1) {
                    r = w - 1;
                } else {
                    for (r = j + 1; r < w; r++) {
                        if (ans[i][r] == 0 && s[i][r] == false) {
                            ans[i][r] = current;
                        } else {
                            break;
                        }
                    }
                    r--;
                }
                auto row = i + 1;
                while (row < h) {
                    auto flag = true;
                    for (int j = l; j <= r; j++) {
                        if (ans[row][j] > 0 || s[row][j] == true) {
                            flag = false;
                            break;
                        }
                    }
                    if (flag) {
                        for (int j = l; j <= r; j++) {
                            ans[row][j] = current;
                        }
                    } else {
                        break;
                    }
                    row++;
                }
                row = i - 1;
                while (row >= 0) {
                    auto flag = true;
                    for (int j = l; j <= r; j++) {
                        if (ans[row][j] > 0 || s[row][j] == true) {
                            flag = false;
                            break;
                        }
                    }
                    if (flag) {
                        for (int j = l; j <= r; j++) {
                            ans[row][j] = current;
                        }
                    } else {
                        break;
                    }
                    row--;
                }
            }
        }
    }
    rep(i, h) {
        rep(j, w) {
            cout << ans[i][j] << ((j < w - 1) ? ' ' : '\n');
        }
    }
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define dF2(i,a,b) for(int i=a;i>(b);--i)
#define eF(i,u) for(int i=h[u];i;i=nxt[i])
#define ll long long
#define ld double
using namespace std;
typedef pair<int,int> pii;
inline int Gcd(int X,int Y){return Y?Gcd(Y,X%Y):X;}
inline ll Gcd(ll X,ll Y){return Y?Gcd(Y,X%Y):X;}
inline int Pow(int base,ll exp,int _mod){int _ans=1;for(;exp;exp>>=1,base=(ll)base*base%_mod)exp&1?_ans=(ll)_ans*base%_mod:0;return _ans;}
inline ll Pow(ll base,ll exp,ll _mod){ll _ans=1;for(;exp;exp>>=1,base=base*base%_mod)exp&1?_ans=_ans*base%_mod:0;return _ans;}
const int INF=0x3f3f3f3f;
const int Mod=1000000007;
int n,Ans;
int A[200001],B[200001];
#define rs(X) (X+2003)
// x : [-2000 , 2000] -> [3 , 4003]
int Tri[4009][4009];
int Ori[4009][4009]; // Ori[i][j] == C( i+j-2 , i-1 ) == Pascal[i-1][j-1]

int main(){
	scanf("%d",&n);
	F(i,1,n) scanf("%d%d",A+i,B+i), ++Tri[rs(-A[i])][rs(-B[i])];
	F(i,3,4003) F(j,3,4003) Tri[i][j]=(Tri[i][j]+Tri[i][j-1]+Tri[i-1][j])%Mod;
	Ori[1][1]=1;
	F(i,1,4001) F(j,1,4001) Ori[i][j]=(Ori[i][j]+Ori[i][j-1]+Ori[i-1][j])%Mod;
	F(i,1,n) Ans=(Ans+Tri[rs(A[i])][rs(B[i])])%Mod;
	F(i,1,n) Ans=(Ans-Ori[2*A[i]+1][2*B[i]+1]+Mod)%Mod;
	Ans=Ans*500000004ll%Mod;
	printf("%d",Ans);
	return 0;
}

Measured memory_bytes: 127360
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    int sx, sy;
    cin >> sy >> sx;
    string S, T;
    cin >> S >> T;
    int L = 0, D = H + 1, R = W + 1, U = 0;
    for(int i = S.size() - 1; i >= 0; i--) {
        if(i != S.size() - 1) {
            char c = T[i];
            if(c == 'L')
                R++;
            else if(c == 'R')
                L--;
            else if(c == 'U')
                D++;
            else if(c == 'D')
                U--;
        }
        U = max(0, U);
        L = max(0, L);
        R = min(W + 1, R);
        D = min(H + 1, D);

        char c = S[i];
        if(c == 'L')
            L++;
        else if(c == 'R')
            R--;
        else if(c == 'U')
            U++;
        else if(c == 'D')
            D--;
        U = max(0, U);
        L = max(0, L);
        R = min(W + 1, R);
        D = min(H + 1, D);
        if(L + 1 == R || U + 1 == D) {
            cout << "NO" << endl;
            return 0;
        }
    }
    if(sx > L && sx < R && sy > U && sy < D) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 776
A, B, C, D = map(int, input().split())
for i in range(100):
    if C-B > 0 and A-D > 0:
        C -= B
        A -= D
        continue
    elif C-B > 0 and A-D <= 0:
        print('No')
        break
    else:
        print('Yes')
        break

Measured memory_bytes: 9032
#include <stdio.h>

int main (){
	
	int n, k;
	scanf("%d %d", &n, &k);
	int z = 1;
	
for (int i = 0; i < n; i++) {
        if (2 * z <= z + k) {
            z *= 2;
        } else {
            z += k;
        }
    }
    printf("%d", z);
	
	
	return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;
const int mod = 1e9+7;
int n,m;
int solve(){
    int a = abs(n-m);
    if(a<2){
        ll ans = a?1:2;
        for(int i=1;i<=n;++i){
            ans *= i;
            ans %= mod;
        }
        for(int i=1;i<=m;++i){
            ans *= i;
            ans %= mod;
        }
        return (int)ans;
    }else return 0;
}
int main(){
    cin>>n>>m;
    cout << solve() << endl;
    return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int[,] dp = new int[N + 1, 3];
        dp[0, 0] = dp[0, 1] = dp[0, 2] = 0;
        for (int i = 0; i < N; i++)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = input[0];
            int b = input[1];
            int c = input[2];
            dp[i + 1, 0] = Math.Max(dp[i, 1] + a, dp[i, 2] + a);
            dp[i + 1, 1] = Math.Max(dp[i, 0] + b, dp[i, 2] + b);
            dp[i + 1, 2] = Math.Max(dp[i, 0] + c, dp[i, 1] + c);
        }
        Console.WriteLine(Math.Max(dp[N, 0], Math.Max(dp[N, 1], dp[N, 2])));
    }
}

Measured memory_bytes: 18360
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

const int MAX = 0x3f3f3f3f;
const int maxn = 50000 + 5;
const int maxm = 20 + 5;
int a[maxn];
int dp[maxn];

int main()
{
    int n, m;
    while (scanf("%d %d", &n, &m) != EOF)
    {
        for (int i = 1; i <= m; i++)
            scanf("%d", &a[i]);

        for (int i = 1; i <= n; i++)
            dp[i] = MAX;
        dp[0] = 0;

        for (int i = 1; i <= m; i++)
            for (int j = a[i]; j <= n; j++)
                {
                    dp[j] = min(dp[j], dp[j - a[i]] + 1);
                    //printf("dp[%d][%d]=%d\n", i, j, dp[j]);
                }

        printf("%d\n", dp[n]);
    }
    return 0;
}



Measured memory_bytes: 3392
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 10000000
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func main() {
	str := nextString()
	if len(str)%2 == 1 {
		fmt.Println("No")
		return
	}
	for i := 0; i < len(str)-1; i = i + 2 {
		if str[i] != 'h' {
			fmt.Println("No")
			return
		}
		if str[i+1] != 'i' {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2007;
const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = MOD;
int mod(int n) {
    return (n % MOD + MOD) % MOD;
}   
vector <pair <int, int> > g[N];
struct Edge {
    int u, v, c;
    bool operator < (Edge e) {
        return c < e.c;
    }   
};
int cnt_[3];
int dfs(int u, int p, int w) {
    if (u == w) return 0;
    for (auto e : g[u]) {
        if (e.first != p) {
            int t = dfs(e.first, u, w);
            if (t != INF) return max(t, e.second);
        }
    }   
    return INF;
}   
int add(Edge e) {
    return dfs(e.u, e.u, e.v);
}   
int par[N], cnt[N];
int root(int u) {
    if (u == par[u]) return u;
    else return par[u] = root(par[u]);
}   
void merge(int u, int v) {
    u = root(u); v = root(v);
    if (u == v) return;
    if (cnt[v] < cnt[u]) swap(u, v);
    par[v] = u; cnt[u] += cnt[v];
}   
int fp(int a, int p) {
    int ans = 1, c = a;
    for (int i = 0; (1ll << i) <= p; ++i) {
        if ((p >> i) & 1) ans = mod(ans * c);
        c = mod(c * c);
    }   
    return ans;
}   
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n, m, x;
    cin >> n >> m >> x;
    vector <Edge> a;
    for (int i = 0; i < m; ++i) {
        int u, v, c;
        cin >> u >> v >> c;
        a.push_back({u, v, c});
    }   
    sort(a.begin(), a.end());
    int mst = 0;

    for (int i = 1; i <= n; ++i) {
        par[i] = i; cnt[i] = 1;
    }   

    for (auto e : a) {
        if (root(e.u) != root(e.v)) {
            mst += e.c;
            merge(e.u, e.v);
            g[e.u].push_back({e.v, e.c});
            g[e.v].push_back({e.u, e.c});
        }   
    }              
    for (auto e : a) {
        int t = add(e);
        if (mst - t + e.c < x) ++cnt_[0];
        else if (mst - t + e.c == x) ++cnt_[1];
        else ++cnt_[2];
    }   
    
    #ifdef HOME
    for (int i = 0; i < 3; ++i) cout << cnt_[i] << ' ';
    cout << '\n';
    #endif

    if (x < mst) {
        cout << "0\n";
    }   
    else if (x == mst) {
        cout << mod(fp(2, cnt_[2]) * mod(fp(2, cnt_[1]) - 2)) << '\n';
    }
    else {
        cout << mod(2 * fp(2, cnt_[2]) * mod(fp(2, cnt_[1]) - 1)) << '\n';
    }   
}   

Measured memory_bytes: 512
N, K = map(int, input().split(" "))
V = list(map(int, input().split(" ")))

max_score = 0
for i in range(N+1):
    # print(list(range(i, N+1)))
    for j in range(i, N+1):
        # print(i, j)
        p = V[:i] + V[j:] 
        # print(p)
        if len(p) > K:
            continue
        p.sort(reverse=True)
        for _ in range(K-len(p)):
            if p and p[-1]<0:
                p.pop()
            else:
                break
        score = sum(p)
        # print(p)
        max_score = max(max_score, score)

print(max_score)

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

    ll ans = c * max(x, y) * 2;
    ans = min(ans, ll(a * x + b * y));
    if (x < y)
    {
        ans = min(ans, ll(c * x * 2 + b * (y - x)));
    }
    else
    {
        ans = min(ans, ll(c * y * 2 + a * (x - y)));
    }

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

Measured memory_bytes: 3616
#include<iostream>

using namespace std;

int main(void){
  int X;
  cin >> X;
  int ans = 1;
  for(int b = 2; b * b <= X; b++){
    int y = b * b;
    while(y * b <= X) y *= b;
    if(y > ans) ans = y;
  }
  cout << ans << endl;
  return 0;
}

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

namespace AtCoderABC114
{
    class Program
    {
        static int[] e;
        public static int Num(int m)
        {
            return e.Where(x => x >= m - 1).Count();
        }
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            e = new int[N + 1];
            for (int i = 2; i <= N; i++)
            {
                int cur = i;
                for (int j = 2; j <= N; j++)
                {
                    while (cur % j == 0)
                    {
                        e[j]++;
                        cur /= j;
                    }
                }
            }

            Console.WriteLine(
                Num(75) + Num(25) * (Num(3) - 1) + Num(15) * (Num(5) - 1) + Num(5) * (Num(5) - 1) * (Num(3) - 2) / 2
            );
        }
    }
}

Measured memory_bytes: 11348
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<iomanip>
#include<cmath>
#include<numeric>
#include<vector>
#include<algorithm>
#include<string>
#include<deque>
#include<stack>
#include<map>
#include<cstring>
#include<random>
#include<queue>
#include<iterator>
#include<bitset>
#include<unordered_set>
#include<set>

using namespace std;
#define ll long long
#define endl "\n"
const int dx[] = { -1 , -1 , -1 , 0 , 0 , 0 , 1 , 1 , 1 };
const int dy[] = { -1 , 0 , 1 , -1 , 0 , 1 , -1 , 0 , 1 };
const ll integer = pow(2, 32) - 1; // 4294967295
#define N 8010000
#define TC int t;cin>>t;for(int T=1;T<=t;T++)
#define mod 1000000007
#define PI acos(-1)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define clr(v, d) memset(v, d, sizeof(v)) 
void AIA() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isprime(ll n) {
	for (ll i = 2; i * i <= n; i++) {
		if (n % i == 0)return 0;
	}
	return (n != 1);
}
ll gcd(ll x, ll y)
{
	return (y == 0 ? x : gcd(y, x % y));
}
ll lcm(ll x, ll y) {
	return (x * y) / gcd(x, y);
}
/*
 _____________              __                ___        ___       ___________________________     ____        ____
|             |            /\ \              |   |      |   |     |                           |    \   \      /   /
|   __________|           / /\ \             |   |      |   |     |      _____      _____     |     \   \    /   /
|  |                     / /  \ \            |   |      |   |     |     |     |    |     |    |      \   \  /   /
|  |                    / /    \ \           |   |      |   |     |     |     |    |     |    |       \   \/   /
|  |______             / /      \ \          |   |______|   |     |     |     |    |     |    |        \      /
|         |           / /        \ \         |              |     |     |     |    |     |    |         \    /
|   ______|          / /          \ \        |    ______    |     |     |     |    |     |    |          |  |
|  |                / /============\ \       |   |      |   |     |     |     |    |     |    |          |  |
|  |               / /==============\ \      |   |      |   |     |     |     |    |     |    |          |  |
|  |              / /                \ \     |   |      |   |     |     |     |    |     |    |          |  |
|  |             / /                  \ \    |   |      |   |     |     |     |    |     |    |          |  |
|__|            /_/                    \_\   |___|      |___|     |_____|     |____|     |____|          |__|

										  <<<<<<<<<<< NEVER GIVE UP !! >>>>>>>>>>>
										<<<<<<<< YOU CAN DO IT IF YOU WANT !! >>>>>>>>
										 <<<<<<<<< BELIEVE IN YOURSELF !! >>>>>>>>>
*/
int n, x, k, m, cnt = 0;
vector<int>v1, v2, v3;
int dp[100007];
int main()
{
	//cout<<fixed<<setprecision(20);
	//freopen("Input.txt.txt", "r", stdin);
	//freopen("Output.txt.txt", "w", stdout);
	AIA();
	cin >> n;
	v1.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> v1[i];
	}
	dp[1] = abs(v1[0] - v1[1]);
	for (int i = 2; i < n; i++) {
		dp[i] = min(dp[i - 1] + abs(v1[i] - v1[i - 1]), dp[i - 2] + abs(v1[i] - v1[i - 2]));
	}
	cout << dp[n - 1];
	return 0;
}


Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
#define eprintf(...) fprintf(stderr,__VA_ARGS__)

const int N=505;

int n,l,r;
int a[N*N];
pii t[N];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) t[i].second=i,scanf("%d",&t[i].first);
	sort(t+1,t+n+1);
	for(int i=1;i<=n;i++) a[t[i].first]=t[i].second;
	bool ok=true;
	l=1;
	for(int i=1;i<=n;i++){
		int cnt=t[i].second-1;
		while(cnt--){
			while(a[l]) l++;
			if(l>t[i].first) ok=false;
			a[l++]=t[i].second;
		}
	}
	r=n*n;
	for(int i=n;i>=1;i--){
		int cnt=n-t[i].second;
		while(cnt--){
			while(a[r]) r--;
			if(r<t[i].first) ok=false;
			a[r--]=t[i].second;
		}
	}
	if(!ok)
		puts("No");
	else{
		puts("Yes");
		for(int i=1;i<=n*n;i++) printf("%d%c",a[i]," \n"[i==n*n]);
	}
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <utility>
#include <cstdlib>
using namespace std;
typedef long long int lli;
const lli mod = 1e9 +7;
const lli inf = 1e18;
typedef pair<lli, lli> pll;


int main(){
    int n;
    cin >> n;
    vector<pll> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i].second >> a[i].first;
    }
    sort(a.begin(), a.end());
    lli time = 0;
    bool ok = true;
    for(int i=0; i<n; i++){
        time += a[i].second;
        if(time > a[i].first){
            ok = false;
        }
    }
    if(ok){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main () {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  // まずはx1, y1を中心に90度回転する
  int x4, y4;
  x4 = x1 + -1 * (y2 - y1);
  y4 = y1 + 1  * (x2 - x1);
  int x3, y3;
  x3 = x2 + (y1 - y2);
  y3 = y2 + (x2 - x1);
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lint long long
#define st first
#define nd second
#define INF 0x3f3f3f3f

using namespace std;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	lint n; cin>>n;
	lint ans = (n/1000)*1000;
	if(ans < n) ans += 1000;
	cout<<(ans - n)<<"\n";

	return 0;	
}


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

int n, d[150], ans;
int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	ans = 0;
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> d[i];
	for(int i = 0; i < n-1; ++i) {
		for(int j = i+1; j < n; ++j) {
			ans += d[i]*d[j];
		}
	}
	cout << ans;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	int a,b,c;
	cin>>a>>b>>c;
	cout<<(c>=a&&c<=b?"Yes":"No");
	re 0;
}

Measured memory_bytes: 3572