akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N;
int A[200010];
int prev_zero[200010];
int next_zero[200010];
vector<int> AA;

signed main()
{
	cin >> N;
	REP(i, N)
	{
		cin >> A[i];
	}

	int sum = 0;

	int cnt = 0;
	int zero = 0;
	for (int i = 0; i < N; i++)
	{
		if (A[i] == 0)
		{
			zero++;
		}
		else
		{
			prev_zero[cnt] = zero;
			if (cnt > 0)
			{
				next_zero[cnt - 1] = zero;
			}
			sum += ((zero + 1) * (zero)) / 2;
			zero = 0;
			cnt++;
		}
	}
	if (zero > 0)
	{
		next_zero[cnt - 1] = zero;
		sum += ((zero + 1) * (zero)) / 2;
	}


	for (int i = 0; i < N; i++)
	{
		if (A[i] != 0)
		{
			AA.push_back(A[i]);
		}
	}

	for (int i = 0; i < AA.size(); i++)
	{
		int a = 0;
		int b = 0;
		for (int j = i; j < i + 21; j++)
		{
			if (j >= AA.size())
			{
				break;
			}
			a += AA[j];
			b ^= AA[j];
			if (a == b)
			{
				int s = (prev_zero[i] + 1) * (next_zero[j] + 1);
				sum += s;
			}
		}
	}

	cout << sum << endl;
}







Measured memory_bytes: 7156
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp

signed main(){
	int a,b; cin>>a>>b;
	if((a+b)%2==0) cout<<(a+b)/2;
	else cout<<((a+b)/2)+1;
	
	return 0;
}

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

/////////////////////////////////////////////////////////

void DFS(vector<vector<int>> V, vector<int> P, int cur , int &res){
  P.push_back(cur);
  if(P.size() == V.size()) res++;
  else{
    rep(i, 0, V[cur].size()){
      if(find(all(P), V[cur][i]) != P.end()) continue;
      DFS(V, P, V[cur][i], res);
    }
  }
}

void Main(){
  int N, M; cin >> N >> M;
  vector<vector<int>> V(N);
  rep(i, 0, M){
    int a, b; cin >> a >> b;
    a--; b--;
    V[a].push_back(b);
    V[b].push_back(a);
  }
  vector<int> P;
  int res = 0;
  DFS(V, P, 0, res);
  cout << res << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d', $N);
$P = explode(' ', trim(fgets(STDIN)));
$Q = explode(' ', trim(fgets(STDIN)));
$a = range(1, $N);
$s[] = implode('', $a);
while(true) {
    $a = next_permutation($a);
    if ($a === false) break;
    $s[] = implode('', $a);
}
$p = array_search(implode('', $P), $s);
$q = array_search(implode('', $Q), $s);
printf('%d', abs($p - $q));

function next_permutation($a) {
    $cnt = count($a);
    $r = null;
    for ($i = $cnt - 1; $i > 0; $i--) {
        if ($a[$i] > $a[$i - 1]) {
            $r = $a[$i - 1];
            break;
        }
    }
    if (is_null($r)) {
        return false;
    }
    $part_a = array_slice($a, 0, $i - 1);
    $part_b = array_slice($a, $i - 1);
    sort($part_b);
    $pos = array_search($r, $part_b);
    $num = $part_b[$pos + 1];
    unset($part_b[$pos + 1]);
    $part_a[] = $num;
    $part_c = array_merge($part_a, array_values($part_b));

    return $part_c;
}


Measured memory_bytes: 8696
n = gets.to_i
as = gets.split.map(&:to_i)

cnt = Hash.new(0)

bs = n.times.map {|i| [as[i], i]}

as.each do |a|
  cnt[a] += 1
end

total = 0
cnt.each do |k, v|
  total += v * (v - 1) / 2
end


n.times do |i|
  a = as[i]
  c = cnt[a]

#  - c * (c - 1) / 2 + (c - 1) * (c - 2) / 2

  p total - c + 1

end

Measured memory_bytes: 61672
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    i64 a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    i64 ans = 1e18;
    for (int i = 0; i <= 2 * max(x, y); i++)
    {
        ans = min(ans, a * max(0L, x - i / 2) + b * max(0L, y - i / 2) + c * i);
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdio.h>
#include<string.h>
#include<unistd.h>
#include<stdlib.h>
#include<time.h>
int main(){
	int a[100];
	int n,k,i,j,m,sp,c=0;
	scanf("%d%d",&a[1],&a[2]);
	if(a[1]>a[2])
	{
		for(i=0;i<a[1];i++)
		{
			printf("%d",a[2]);
		}
		printf("\n");
	}
	else if(a[2]>a[1])
	{
		for(i=0;i<a[2];i++)
		{
			printf("%d",a[1]);
		}
		printf("\n");
	}
	else if(a[2]==a[1])
	{
		for(i=0;i<a[2];i++)
		{
			printf("%d",a[1]);
		}
		printf("\n");
	}
	return 0;
}	
	
	


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
 
#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main(void){
  string S;
  cin >> S;
  if(S.at(S.size()-1)=='s'){
    S += "es";
  }
  else{
    S += "s";
  }
  cout << S;
}

Measured memory_bytes: 3624
#pragma comment(linker, "/STACK:64000000")
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define y1 stupid_cmath
#define left stupid_left
#define right stupid_right
#define vi vector <int>
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))

const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);

int n, m, a[100100];

int main(){

    int k = 0;

    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++) scanf("%d", a + i);

    for (int i = 0; i < m; i++) k += a[i] % 2;

    if (k > 2) {
        printf("Impossible\n");
        return 0;
    }

    if (m == 1) {
        if (n == 1) cout << 1 << endl << 1 << endl << 1 << endl;
        else {
            cout << a[0] << endl << 2 << endl << n - 1 << " " << 1 << endl;
        }
        return 0;
    }

    int was = 0;
    for (int i = 0; i < m; i++) {
        if (a[i] % 2) {
            if (was) {
                swap(a[i], a[m - 1]);
                break;
            }
            was = true;
            swap(a[0], a[i]);
        }
    }

    vector<int> b;

    b.pb(a[0] + 1);
    for (int i = 1; i < m - 1; i++) b.pb(a[i]);
    b.pb(a[m - 1] - 1);

    vector<int> c;
    for (int i = 0; i < b.size(); i++)
        if (b[i]) c.pb(b[i]);

    for (int i = 0; i < m; i++) {
        if (i) printf(" ");
        printf("%d", a[i]);
    }
    printf("\n");
    printf("%d\n", sz(c));
    for (int i = 0; i < sz(c); i++) {
        if (i) printf(" ");
        printf("%d", c[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;
using Graph = vector<vector<int>>;

int main(){
    string S;
    cin >> S;
    REP(i,S.size()) S[i] = 'x';
    cout << S << endl;
}

Measured memory_bytes: 3592
S=input()

good=True

for i, s in enumerate(S):
  if (i+1)%2==0:
    if s in ['L','U','D']:
      pass
    else:
      good=False
  else:
    if s in ['R','U','D']:
      pass
    else:
      good=False
  
if good:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin>>n>>k;
	int ans = 1;
	for(int i = 0; i<n; i++)
	{
		if(ans<k)
			ans *=2;
		else
			ans +=k;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,k,p=0;
    cin>>n>>k;
    ll m=k;
    while((n/m)>=1)
    {
        p++;
        m=m*k;
    }
    cout<<p+1;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--) 
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
typedef pair<int, int> pii;
#define x first
#define y second
int main() {
	LL a, b; cin >>a>>b;
	dep(i,60,0) if ((a >> i & 1) != (b >> i & 1)) {
		LL t1 = a & ((1LL << i) - 1), t2 = b & ((1LL << i) - 1);
		if (t2 >= t1) { cout <<(b | ((1LL << i) - 1)) - a + 1<<endl; }
		else {
			LL ans = b - a + 1, t = t2;
			dep(j,i-1,0) if (t2 >> j & 1) {
				t |= (1LL << j) - 1; break;
			}
			ans += (min(t, t1 - 1) - t2) + (1LL << i) - t1;
			cout <<ans<<endl;
		}
		return 0;
	}
	cout <<1<<endl;
	return 0;
}


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

m = float("inf")
for i in range(1,N):
    A = i
    B = N - i
    factor_A = [int(x) for x in list(str(A))]
    factor_B = [int(x) for x in list(str(B))]
    tmp = sum(factor_A) + sum(factor_B)
    if m > tmp:
        m = tmp

print(m)

Measured memory_bytes: 3060
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


a = int(input().split()[0])
prime_res = prime_factorize(a)

prime_dict = {}
for prime_i in prime_res:
    if prime_i not in prime_dict:
        prime_dict[prime_i] = 1
    else:
        prime_dict[prime_i] += 1

res = 0
for key in prime_dict:
    base = 1
    while True:
        if prime_dict[key] < base:
            break
        else:
            prime_dict[key] -= base
            base += 1
            res += 1

print(res)


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

using namespace std;

const int mod = 2019;
typedef long long ll;


int main()
{
    int l, r, ll, rr;
    cin >> l >> r;
    ll = l;
    rr = r;
    l %= mod;
    r %= mod;
    if ((l >= r) || (rr / 2019 != ll / 2019)){
        cout << 0;
    } else {
        int ans = 1e9 + 5;
        for (int i = l; i <= r; i++){
            for (int j = i + 1; j <= r; j++){
                ans = min(ans, (i * j) % mod);
            }
        }
        cout << ans;
    }
    return 0;
}


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

int main(){
    string s,t; cin >> s >> t;
    int ans = 0;
    rep(i,3){
        if(s[i] == t[i]) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){
    const int PRICES_LENGTH = 4;
    int prices[PRICES_LENGTH];
    
    for(int i=0;i<PRICES_LENGTH;i++){
        if(i>0){
            int eval;
            cin >> eval;
            
            prices[i] = min(prices[i-1]*2, eval);
        }else{
            cin >> prices[i];
        }
    }
    
    long quantity;
    long cost = 0;
    cin >> quantity;
    
    long count;
    
    count = floor(quantity/2);
    quantity-= count*2;
    cost+=prices[3]*count;
    
    count = floor(quantity);
    quantity-= count;
    cost+=prices[2]*count;
    
    cout << cost;
    
    return 0;
}


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

#define ll long long
#define ld long double
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define ppb pop_back
#define vll vector<ll>
#define vi vector<int>
#define endl "\n"

const ll INF = 1000000007;

/*
const int max_size = 100001;
int parent[max_size];
int Size[max_size];

int root(int x){
	while(x!=parent[x]){
		parent[x] = parent[parent[x]];
		x = parent[x];
	}
	return x;
}

void sunion(int x,int y){
	int rx = root(x);
	int ry = root(y);
	if(rx != ry){
		if(Size[rx] > Size[ry]){
			parent[ry] = parent[rx];
			Size[rx] += Size[ry];
		}
		else{
			parent[rx] = parent[ry];
			Size[ry] += Size[rx];
		}
	}
}
*/

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin >> t;
	while(t--){
		ll k;
		cin >> k;
		ll sum=0LL;
		for(ll a=1;a<=k;a++)
			for(ll b=1;b<=k;b++)
				for(ll c=1;c<=k;c++){
					sum += __gcd(a,__gcd(b,c));
				}
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define mod 1000000007
 
/*long long power(long long a,int k)
{
	long long ans=1,y=a;
	while(k!=0)
	{
		if(k%2!=0)
			ans=ans*y%mod;
		y=y*y%mod;
		k=k/2;
	}
	return ans;
}
*/
 
long long power(long long a,int b)
{
	long long ans=1,y=a;
	int k=b;
	while(k!=0)
	{
		if(k%2==1)
		    ans=ans*y%mod;
		y=y*y%mod;
		k/=2;
	}
	return ans;
}/*
long long power(long long a,int k)
{
	long long ans=1,y=a;
	while(k!=0)
	{
		if(k%2==1)
		    ans=ans*y%mod;
		y=y*y%mod;
		k/=2;
	}
	return ans;
}*/
long long fun[1000005],ans=1;
int main()
{
	long long n,m;
	scanf("%lld%lld",&n,&m);
	fun[0]=1;
	for(int i=1; i<1000000; i++)
		fun[i]=fun[i-1]*i%mod;
	for(int i=2; i*i<=m; i++)
		if(m%i==0)
		{
			long long s=0;
			while (m%i==0)
			{
				m=m/i;
				s++;
			}
			ans=ans*fun[n+s-1]%mod*power(fun[n-1], mod-2)%mod*power(fun[s], mod-2)%mod;
		}
	if(m>1)
		ans=ans*n%mod;
	printf("%lld\n",ans);
	return 0;
}
/*for(int i=2;i*i<=m;i++)
    if(m%i==0)
    {
    	long long s=0;
    	while(m%i==0)
    	{
    		s++;
    		m/=i;
		}
		ans=ans*fun[s+n-1]%mod*power(fun[n-1],mod-2)%mod*power(fun[s],mod-2)%mod;
	}
*//*
for(register int i=1;i*i<=m;i++)
    if(m%i==0)
    {
    	long long s=0;
    	while(m%i==0)
    	{
    		m/=i;
    		s++;
		}
		ans=ans*fun[n-1+s]%mod*power(fun[n-1],mod-2)%mod*power(fun[s],mod-2)%mod;
	}*/

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

using namespace std;

#define mod 1000000007
#define ll long long int
#define mk make_pair
#define pb push_back
#define xx first
#define yy second
#define ar array

double pi=3.141592653589793238;
const int M = 1e9+7;
const int Nmax=5005;
const int MM = 1e7+1;
const int N=200010;

int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int T=1;
//cin>>T;
while(T--){
ll a,b,c,k;
cin>>a>>b>>c>>k;
bool f=false;
        int cnt=0;
        while(b<=a){
            b*=2;
            cnt++;
        }
        while(c<=b){
            c*=2;
            cnt++;
        }
        if(cnt<=k)f=true;
if(f)cout<<"Yes\n";
else cout<<"No\n";
}
return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	long long a,b,c,d;
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

	printf("%lld\n", max(a*b,c*d));

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a.at(i);
  int count = 0;
  for(int i = 1; i+1 < n; i++){
    if(a.at(i-1)<a.at(i)&&a.at(i)<a.at(i+1)){
      count++;
    }
    if(a.at(i-1)>a.at(i)&&a.at(i)>a.at(i+1)){
      count++;
    }
  }
  cout << count << endl;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    string s;

    while (getline(cin, s)) {
        for (int i = 0; i < 26; i++) {
            for (int j = 0; j < s.size(); j++) {
                if (s[j] >= 'a' && s[j] <= 'z') {
                    s[j] = (s[j] - 'a' + 1) % 26 + 'a';
                }
            }

            //cout << s << endl;

            if (s.find("the") != string::npos || s.find("this") != string::npos || s.find("that") != string::npos) {
                cout << s << endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;cin>>S;
  long long int p=0,x=0;
  while(p<S.size()){
    long long int i=0,j=0;
    while(p+i<S.size()&&S.at(p+i)=='<')i++;
    while(p+i+j<S.size()&&S.at(p+i+j)=='>')j++;
    x+=i*(i+1)/2+j*(j+1)/2-min(i,j);
    p+=i+j;
  }
  cout<<x<<endl;
}

Measured memory_bytes: 900
#!/usr/bin/env python3
import sys

sys.setrecursionlimit(10 ** 8)
INF = 1 << 62


def solve(N: int, a: "List[int]"):
    dp = [[INF] * N for _ in range(N + 1)]
    cumsize = [0] * (N + 1)
    for i in range(1, N + 1):
        cumsize[i] = cumsize[i - 1] + a[i - 1]

    def mincost(length, head):
        if head + length > N:
            return INF
        if dp[length][head] < INF:
            return dp[length][head]
        base_cost = cumsize[head + length] - cumsize[head]
        if length == 1:
            dp[length][head] = 0
            return 0
        cost = INF
        split_point = head
        for j in range(1, length):
            if split_point + j >= N:
                continue
            c = mincost(j, head) + mincost(length - j, head + j)
            if cost > c:
                cost = c
        cost += base_cost
        dp[length][head] = cost
        return cost

    return mincost(N, 0)


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
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, a))


if __name__ == "__main__":
    main()


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

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

	int w[26] = {};
	for (int i = 0; i < s.length(); i++) {
		w[s.at(i) - 'a']++;
	}

	string ans = "yes";
	for (int i = 0; i < 26; i++) {
		if (1 < w[i]) {
			ans = "no";
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int N;
  cin >> N;
  int ans;
  if(N >= 1800) ans = 1;
  else if(N >= 1600) ans = 2;
  else if(N >= 1400) ans = 3;
  else if(N >= 1200) ans = 4;
  else if(N >= 1000) ans = 5;
  else if(N >= 800) ans = 6;
  else if(N >= 600) ans = 7;
  else ans = 8;

  cout << ans << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include <math.h>
using namespace std;

int main(){
  int a,b,aw[102],bw[102],out;
  double sor[4],min;
  while(1){
    cin>>a>>b;

    if(a==0)break;
    for(int i=0;i<=101;i++)aw[i]=0;
    for(int i=0;i<=101;i++)bw[i]=0;
    for(int i=1;i*i<=a;i++)if(a%i==0)aw[i]=a/i;
    for(int i=1;i*i<=b;i++)if(b%i==0)bw[i]=b/i;
    min=1000000000;
    for(int i=0;i<=101;i++){
      for(int j=0;j<=101;j++){
	if(aw[i]!=0&&bw[j]!=0){
	  sor[0]=i;
	  sor[1]=j;
	  sor[2]=aw[i];
	  sor[3]=bw[j];
	  sort(sor,sor+4);
	  //cout<<sor[0]<<" "<<sor[1]<<" "<<sor[2]<<" "<<sor[3]<<endl;//////////
	  if(min>pow(sor[3]-sor[2],2.0)+pow(sor[2]-sor[1],2.0)+pow(sor[1]-sor[0],2.0))
	    min=pow(sor[3]-sor[2],2.0)+pow(sor[2]-sor[1],2.0)+pow(sor[1]-sor[0],2.0);
	}
      }
    }
    out=min;
    cout<<out<<endl;
  }
  return 0;
}

Measured memory_bytes: 3088
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner seer = new Scanner(System.in);
		int a = seer.nextInt();
		int b = seer.nextInt();
		if(a <= 5){
			System.out.println(0);
		}
		else if(a <= 12){
			System.out.println(b/2);
		}
		else{
			System.out.println(b);
		}
	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int ans[5];
int main(){
	string str;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>str;
		if(str=="AC") ans[1]++;
		if(str=="WA") ans[2]++;
		if(str=="TLE") ans[3]++;
		if(str=="RE") ans[4]++;
	}
	cout<<"AC x "<<ans[1]<<endl;
	cout<<"WA x "<<ans[2]<<endl;
	cout<<"TLE x "<<ans[3]<<endl;
	cout<<"RE x "<<ans[4]<<endl;
	return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,A,B;
  int PLAN1,PLAN2;
  
  cin >> N >> A >> B;
  
  //プラン1,2の料金をそれぞれ計算
  PLAN1 = N * A;
  PLAN2 = B;
  
  if ( PLAN1 < PLAN2 ){
    cout << PLAN1 << endl;
  }
  else if(PLAN1 > PLAN2){
    cout << PLAN2 << endl;
  }
  else{
    cout << PLAN1 << endl;
  }
}

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

#define se second
#define fi first
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;

char str[100];

int main(){
    scanf("%s", &str);
    str[3] = '8';
    printf("%s\n", str);
    return 0;
}


Measured memory_bytes: 256
def main():
    sx, sy, tx, ty = [int(a) for a in input().split()]

    dx, dy = tx - sx, ty - sy

    p1 = "U" * dy + "R" * dx
    p2 = "D" * dy + "L" * dx
    p3 = "L" + "U" * (dy + 1) + "R" * (dx + 1) + "D"
    p4 = "R" + "D" * (dy + 1) + "L" * (dx + 1) + "U"
    print(p1 + p2 + p3 + p4)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
const int INF = 1<<30;

int main(){
  string s;cin>>s;
  int ans=700;
  for(int i=0;i<3;i++){if(s[i]=='o')ans+=100;}
  cout<<ans<<endl;
}

Measured memory_bytes: 256
from itertools import accumulate
n, w, h = map(int, input().split())
xlst = [0] * (w + 1)
ylst = [0] * (h + 1)
for _ in range(n):
  x, y, width = map(int,input().split())
  xlst[max(0, x - width)] += 1
  ylst[max(0, y - width)] += 1
  xlst[min(w, x + width)] -= 1
  ylst[min(h, y + width)] -= 1

accx = list(accumulate(xlst))[:-1]
accy = list(accumulate(ylst))[:-1]
if 0 not in accx or 0 not in accy:
  print("Yes")
else:
  print("No")



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

int main() {
    int K,N;
    cin >> K >> N;
    vector<int> A(N+2);
    for(int i=1;i<=N;++i) cin >> A[i];
    A[0] = A[N];
    A[N+1] = A[1];
    int ans = 10000000;
    for (int i = 1; i <= N; i++)
    {
        int a;
        if(A[i-1] < A[i]) a = K - (A[i] - A[i-1]);
        else a = A[i-1] - A[i];
        int b;
        if(A[i] < A[i+1]) b = K - (A[i+1]-A[i]);
        else b = A[i] - A[i+1];
        ans = min(ans, min(a,b));
    }
    cout << ans << endl;
    

}


Measured memory_bytes: 1024
//raja1999

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define int ll

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


//std::ios::sync_with_stdio(false);

int main(){
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	string s,t;
	cin>>s>>t;
	int i;
	rep(i,s.length()){
		if(s[i]!=t[i]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
} 


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

int main() {

    int n,y,b,r,t;

    while(1){

        cin >> n;

        if(n==0) break;

        cin >> y;

        int ans = 0;
        double maxg = 0.0;

        for(int i=0;i<n;i++){
            double bank;
            cin >> b >> r >> t;
            if(t==1){
                bank = 1.0+(double)(y)*(double)(r)/100.0;
            }
            else{
                bank = 1.0;
                double base = 1.0+(double)(r)/100.0;
                for(int j=0;j<y;j++){
                    bank = bank*base;
                }
            }

            if(bank >= maxg){
                ans = b;
                maxg = bank;
            }

        }

        cout << ans << endl;




    }

    return 0;
}

Measured memory_bytes: 3048
x=str(input())
y = x[-1]


if y == "3":
	 	 z="bon"
elif y == "0":
	z="pon"
elif y == "1":
	z="pon"
elif y == "6":
	z="pon"
elif y =="8":
	z="pon"
else:
	z="hon"

print(z)
exit()

Measured memory_bytes: 9112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
using namespace std;

int main() {
  int N,D;
  cin>>N>>D;
  
  vector<vector<int>> v(N,vector<int>(D,0));	// ２次元配列を０で初期化
  
  for(int i=0;i<N;++i){
    for(int j=0;j<D;++j){
    	cin>>v[i][j];
    }
  }
  
  int count=0;
  int a=0;
  
  for(int i=0;i<N-1;++i){
    for(int j=i+1;j<N;++j){
      for(int k=0;k<D;++k){
        a+=(v[i][k]-v[j][k])*(v[i][k]-v[j][k]);
      }
      double b=sqrt(a);
      int c=b;	// 整数判定のための変数
      
      a=0;	// aを０で初期化
      
      if(b==c)
        ++count;
    }
  }
  
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>


using namespace std;
typedef long long ll;
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}
int gcd(int x, int y){
	if(x<y){
    return gcd(y,x);
  }
  if(y==0){
    return x;
  }
  return gcd(y,x%y);
}
int moji(char in)
{
    int ans = (int)in-(int)'a'+1;
    if((in < 1) || (in > 26)){
        ans = 100;
    }
    return ans;
}







int main() {
  int X,Y,Z;
  cin>>X>>Y>>Z;
  int sum=0;
  X-=Y+2*Z;
  sum++;
  while(X>=Y+Z){
    sum++;
    X-=Y+Z;
  }
  cout<<sum<<endl;
  
  
}



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

using namespace std;

#define li long long int

const int N = 1e5 + 5;

int n;
int a[N];
int dp[N];

int go(int idx) {
	if (idx >= n) return 0;
	if (idx == n - 1) return abs(a[idx] - a[idx + 1]);
	if (dp[idx] != -1) return dp[idx];
	int ans = 1e9 + 7;
	ans = min(ans, go(idx + 1) + abs(a[idx] - a[idx + 1]));
	ans = min(ans, go(idx + 2) + abs(a[idx] - a[idx + 2]));
	return dp[idx] = ans;
}

void solve() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	memset(dp, -1, sizeof(dp));
	int ans = go(1);
	cout << ans;
}

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

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const double PI = 3.14159265358979323846;

int main() {
  string s;
  cin >> s;
  for(int i = 0; i < (int)s.size(); i++) {
    s.at(i) = 'x';
  }
  for(int i = 0; i < (int)s.size(); i++) {
    cout << s.at(i);
  }
  cout << endl;
  return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
    
  long long ans = 0;
  for (int i = 0; i < n - k ; i++) {
   ans += a.at(i);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
}

ll getdigit(ll n){
	string s=to_string(n);
	return s.size();
}
	
int main(){
	init();
	string a,b;
	cin>>a>>b;
	if(a.length()>b.length()){
		cout<<"GREATER"<<endl;
		return 0;
	}
	if(a.length()<b.length()){
		cout<<"LESS"<<endl;
		return 0;
	}
	
	if(a>b){
		cout<<"GREATER"<<endl;
		return 0;
	}
	if(a<b){
		cout<<"LESS"<<endl;
		return 0;
	}
	cout<<"EQUAL"<<endl;
}


Measured memory_bytes: 256
/* ex4_2
   moka223711 */

#include <stdio.h>
#include <math.h>
#define PI 3.14159265358

int main(void){
    // 時針の長さがlenh[cm]、分針の長さがlenm[cm]である時計のhour時minute分における
    // 時針の先端と分針の先端の距離を求める
    
    double lenh, lenm, hour, minute, radh, radm, rad, ans;
    scanf("%lf %lf %lf %lf", &lenh, &lenm, &hour, &minute);
    
    // 針が12時を指しているときを0[rad]とする
    // 時針は12時間(12*60分)で一周するので、hour時minute分のとき
    // 時針の角度radhは、2*PIに(hour/12+minute/60/12)をかけたものになる
    radh = 2 * PI * (hour + minute / 60) / 12;
    // 分針は60分で一周するので、分針の角度radmは2*PIにminute/60をかけたものになる
    radm = 2 * PI * minute / 60;
    // なす角を知りたいのでPI(180°)より小さい方を選ぶ
    rad = (radh-radm < PI) ? radh-radm : radm-radh;
    
    
    // 余弦定理を用いて時針の先端と分針の先端の距離を求める
    ans = sqrt(pow(lenh, 2) + pow(lenm, 2) - 2*lenh*lenm*cos(rad));
    // 誤差は10^{-9}まで許されるので10^{-10}まで表示する
    printf("%.10lf", ans);
    
    return 0;
}


Measured memory_bytes: 2536
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main(){
    int n,m,c;
    cin >> n >> m >> c;
    vector<int> b(m);
    vector<vector<int>> a(n,vector<int>(m));
    for(int i=0;i<m;i++) cin >> b[i];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        int sum=0;
        for(int j=0;j<m;j++){
            sum+=a[i][j]*b[j];
        }
        if(sum+c>0) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int N, M;
int ruisekiwa[5050][5050];

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		ruisekiwa[a][b]++;
		ruisekiwa[a][b + 1]--;
		ruisekiwa[a + c + 1][b]--;
		ruisekiwa[a + c + 2][b + 1]++;
		ruisekiwa[a + c + 1][b + c + 2]++;
		ruisekiwa[a + c + 2][b + c + 2]--;
	}
	
	//???????????¢????´???????
	for (int i = 0; i <= N + 10; i++) {
		for (int j = 1; j <= N + 10; j++) {
			ruisekiwa[i][j] += ruisekiwa[i][j - 1];
		}
	}
	
	//??????????????????????´???????
	for (int i = 1; i <= N + 10; i++) {
		for (int j = 0; j <= N + 10; j++) {
			ruisekiwa[i][j] += ruisekiwa[i - 1][j];
		}
	}
	
	//??????????????????????´???????
	for (int i = 1; i <= N + 10; i++) {
		for (int j = 1; j <= i; j++) {
			ruisekiwa[i][j] += ruisekiwa[i - 1][j - 1];
		}
	}

	int ans = 0;
	for (int i = 0; i <= N + 10; i++) {
		for (int j = 0; j <= N + 10; j++) {
			if (ruisekiwa[i][j] > 0)ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 101948
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long n,m,a,k,i,j,num[500005],ans,pos[500005],l,r;
int main()
{
	ios_base::sync_with_stdio(0);
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>num[i];
	}
	if (num[1]!=0)
	{
		cout<<-1;
		return 0;
	}
	for (i=2;i<=n;i++)
	{
		if (num[i]>num[i-1]+1)
		{
			cout<<-1;
			return 0;
		}
		if (num[i]==num[i-1]+1) ans++; else ans+=num[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4352
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;

typedef long long ll;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999

ll ans[100010];

int main(){
  ll A,B,d,ans=1;
  ll a,b,r;
  cin >> A >> B;
  a=min(A,B);
  b=max(A,B);
  r=a%b;
  while(r!=0){
    a=b;
    b=r;
    r=a%b;
  }
  d=b;
  FOR(i,2,sqrt(d)+1){
    if(b%i==0){
      ans++;
      while(b%i==0)b=b/i;
    }
  }
  if(b!=1)ans++;
  cout << ans;
}


Measured memory_bytes: 256
from collections import deque
A, B = [int(x) for x in input().split()]

def gcd(x, y):
  if y == 0:
    return x
  return gcd(y, x % y)

t = gcd(A, B)
l = deque([1])
sqrt_t = int(t ** 0.5) + 1
for i in range(2, sqrt_t + 1):
  if t % i == 0:
    l.append(i)
    while t % i == 0:
      t //= i
      
l.append(t)
print(len(set(l)))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
const ll mod = 998244353;
ll Prev[305][305];
ll Next[305][305];
//[i][j]:i回'1'のdelete
//j個の'1'持ち

bool AllSame(string S) {
    for(auto c : S) {
        if(c != S[0]) return false;
    }
    return true;
}

vector<ll> f(string S) {
    vector<ll> ret;
    ll tmp = 0;
    for(auto c : S) {
        if(c == '0') {
            ret.push_back(tmp);
            tmp = 0;
        } else {
            tmp++;
        }
    }
    ret.push_back(tmp);
    return ret;
}
ll sum1[305][305];
ll sum2[305][305];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    ll K;
    cin >> S >> K;
    chmin(K, 300LL);
    if(AllSame(S)) {
        cout << 1 << endl;
        return 0;
    }
    auto v = f(S);
    Prev[0][0] = 1;
    for(int q = v.size() - 1; q >= 0; q--) {
        ll num = v[q];
        for(int i = 0; i <= 300; i++) {
            for(int j = 0; j <= 300; j++) {
                if(Prev[i][j] != 0) {
                    //cerr << q << " " << num << " " << i << " " << j << " " << Prev[i][j] << endl;
                }
                Next[i][j] = 0;
                sum1[i][j] = 0;
                sum2[i][j] = 0;
            }
        }
        for(int i = 0; i <= 300; i++) {
            for(int j = 0; j <= 300; j++) {
                /*
                for(int k = 0; k <= num; k++) {
                    if(i+k <= 300 and j+k <= 300) {
                        Next[i+k][j+k] += Prev[i][j];
                        Next[i+k][j+k] %= mod;
                    }
                }
                */
                sum1[i][j] += Prev[i][j];
                int delta = num;
                chmin(delta, 300 - i);
                chmin(delta, 300 - j);
                sum1[i+delta+1][j+delta+1] += mod - Prev[i][j];
                /*
                for(int k = 1; k <= j; k++) {
                    Next[i][j-k] += Prev[i][j];
                    Next[i][j-k] %= mod;
                }
                */
               sum2[i][0] += Prev[i][j];
               sum2[i][j] += mod - Prev[i][j];
            }
        }
        for(int i = 0; i <= 300; i++) {
            for(int j = 0; j <= 300; j++) {
                if(i > 0 and j > 0) {
                    sum1[i][j] += sum1[i-1][j-1];
                    sum1[i][j] %= mod;
                }
                if(j > 0) {
                    sum2[i][j] += sum2[i][j-1];
                    sum2[i][j] %= mod;
                }
                Next[i][j] = (sum1[i][j] + sum2[i][j]) % mod;
            }
        }
        //cerr << v[i] << endl;
        swap(Prev, Next);
    }
    ll ans = 0;
    for(int i = 0; i <= K; i++) {
        ans += Prev[i][0];
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6552
#include <stdio.h> // C++???????????????
#include <string.h> // c++???????????????
#include <math.h> // c++???????????????
#include <iostream>
#include <string>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

typedef long long int lli;

list<lli> lis;

int main(void) {
	int n;
	list<lli>::iterator p;

	char a[20];
	lli x;
	scanf("%d", &n);

	while (n--) {
		scanf("%s", a);
		if (a[0] == 'i') {
			scanf("%lld", &x);
			lis.push_front(x);
		}
		else if (a[0] == 'd') {
			if (strlen(a) > 6 && a[6] == 'F') {
				lis.pop_front();
			}
			else if (strlen(a) > 8 && a[6] == 'L') {
				lis.pop_back();
			}
			else {
				scanf("%lld", &x);
				for (p = lis.begin(); p != lis.end(); p++) {
					if (*p == x) {
						lis.erase(p);
						break;
					}
				}
			}
		}
	}
	bool f=false;
	for (p = lis.begin(); p != lis.end(); p++) {
		if (f) printf(" ");
		printf("%lld", *p);
		f = true;
	}
	printf("\n");
	return 0;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

int p[1009];
void solve()
{
	int n,k;
	cin>>n>>k;
	int i;
	for(i=0;i<n;i++) cin>>p[i];
	sort(p,p+n);
	ll sum=0;
	for(i=0;i<k;i++) sum+=p[i];
	cout<<sum;
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3648
/// Source : https://atcoder.jp/contests/abc042/tasks/arc058_b
/// Author : liuyubobobo
/// Time   : 2020-09-22

#include <iostream>
#include <vector>

using namespace std;


/// Combinatorics
/// Time Complexity: O((H + W) * logP)
/// Space Complexity: O(H + W)
class Combinatorics{

private:
    long long MOD = 1e9 + 7;
    vector<long long> fac, inv_fac;

public:
    Combinatorics(int N, long long MOD = 1e9 + 7): fac(N + 1, 1ll), inv_fac(N + 1, 1ll), MOD(MOD){

        for(int i = 2; i <= N; i ++){
            fac[i] = fac[i - 1] * i % MOD;
            inv_fac[i] = mypow(fac[i], MOD - 2);
        }
    }

    long long C(int n, int k){
        return fac[n] * inv_fac[k] % MOD * inv_fac[n - k] % MOD;
    }

private:
    long long mypow(int x, int k){

        if(k == 0) return 1ll;

        long long t = mypow(x, k / 2);
        long long res = t * t % MOD;
        if(k % 2) res = res * x % MOD;
        return res;
    }
};

class Solution{

private:
    const long long MOD = 1e9 + 7;
    
public:
    int ways(int H, int W, int A, int B){

        Combinatorics c(2 * (H + W), MOD);

        long long res = 0ll;
        for(int j = B + 1; j <= W; j ++) {
            long long a = c.C(H - A + j - 2, j - 1);
            long long b = c.C(W - j + 1 + A - 2, A - 1);
            res += a * b % MOD;
            res %= MOD;
        }
        return res;
    }
};

int main() {

//    cout << Solution().ways(2, 3, 1, 1) << endl;
//    // 2
//
//    cout << Solution().ways(10, 7, 3, 4) << endl;
//    // 3570
//
//    cout << Solution().ways(100000, 100000, 99999, 99999) << endl;
//    // 1

    int H, W, A, B;
    scanf("%d%d%d%d", &H, &W, &A, &B);
    printf("%d\n", Solution().ways(H, W, A, B));

    return 0;
}


Measured memory_bytes: 9148
#include <iostream>
#include <vector>
#include <map>
#include <functional>

using namespace std;

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

    if(N*A<B){
        cout << N*A << endl << flush;
    }else{
        cout << B << endl << flush;
    }
    return 0;
}


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

using namespace std;

int main(){
    string s;
    cin >> s;
    if(s[0]==s[1]&&s[1]==s[2]){
        cout << "Yes" << endl;
    }else if(s[2]==s[3]&&s[1]==s[2]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

int main(void){
  string s;
  cin >> s;
  int len = s.length();
  for(int i=0;i<len;i++){
    if(s[i] == '7'){
      cout << "Yes" << endl;
      return 0;
    }
  }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 9223372036854775807;
const ll half_inf = 0x3f3f3f3f;
const ll inf = 0x7fffffff;
const ll mod = 998244353;
const ll maxn = 200005;
ll dp[3005]={0},a[3005],n,s,ans=0;
int main(){  
	cin.tie(0);
    ios::sync_with_stdio(false);
	scanf("%lld%lld",&n,&s);
	for(ll i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(ll i=1;i<=n;i++){
		for(ll j=s-a[i];j>=0;j--){
			dp[j+a[i]]+=dp[j];
			dp[j+a[i]]%=mod;
		}
		dp[a[i]]+=i;
		ans+=dp[s];
		ans%=mod;
	}
	printf("%lld",ans);
    return 0;
}

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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A), b(B);
  cin >> a;
  cin >> b;
  int ans = *min_element(all(a)) + *min_element(all(b));
  for (int i = 0; i < M; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    x--;
    y--;
    chmin(ans, a[x] + b[y] - c);
  }
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;

long long gcd(int x, int y) {
  if(x%y == 0) {
      return y;
  } else {
    return gcd(y, x%y);
  }
}

int main() {
    long long a, b;
    cin >> a >> b;

    long long ans = a*b;
    ans = ans/gcd(a, b);
    cout << ans << endl;
}


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  SCIN(S, T);
  bool ok = false;
  REP(si, S.size()) {
    S = S.back() + S.substr(0, S.size() - 1);
    // debug(S);
    if (S == T) ok |= true;
  }
  OK(ok);

  return 0;
}



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

long long s, c, g;
int main(){
    cin >> s >> c;
    if(c >= s*2){ g += s; c -= s*2; s = 0; }
    else { g += c/2; s -= c/2; c -= ((long long)(c/2))*2; }
    g += c/4;
    cout << g;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace  std;
int main(){
    int a,b,cnt = 0;
    cin >> a >> b;
    for (int i=0;i<2;i++){
    if(a>b){
        cnt += a;
        a--;
    }
    else{
        cnt += b;
        b--;
    }}
    cout << cnt << endl;
}

Measured memory_bytes: 256