akhauriyash/Code-Regression huggingface dataset:
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) (a).begin(), (a).end()

template<typename T>
void vdeb(vector<T> &da){
    int size=da.size();
    for(int i=0;i<size;i++){
        if(i==size-1){
            cout << da[i] << endl;
        }
        else{
            cout << da[i] << ' ';
        }
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    vector<int> dp(n + 1);
    dp[n] = 0;
    int mi = n;
    for(int i = n - 1;i > -1;i --){
        while(mi - i > m || s[mi] == '1'){
            mi--;
            if(mi == i){
                cout << -1 << endl;
                return 0;
            }
        }
        dp[i] = dp[mi] + 1;
    }
    vector<int> ans(1);
    int now = dp[0];
    rip(i,n+1,0){
        if(s[i] == '1'){
            continue;
        }
        if(dp[i] == now - 1){
            ans.push_back(i);
            now --;
        }
    }
    rip(i,dp[0] + 1,1){
        if(i == dp[0]){
            cout << ans[i] - ans[i - 1] << endl;
        }
        else{
            cout << ans[i] - ans[i - 1] << ' ';
        }
    }
}

Measured memory_bytes: 1528
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())

kyori_sa = abs(a-b)
if v < w:
    print("NO")
elif v > w:
    if (v-w)*t >= kyori_sa:
        print("YES")
    else:
        print("NO")
elif v==w:
    if a == b:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 9196
#include <iostream>

using namespace std;

int main(){
    int k;
    string s;

    cin >> k;
    cin >> s;

    if(k<(int)s.size()){
        for (int i = 0; i < k;i++){
            cout << s[i];
        }
        cout << "...";
    }
    else{
        cout << s;
    }
    return 0;

}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100005
int a[MAXN],f[MAXN];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)	scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=k;i++)
		for(int j=1;j<=n&&a[j]<=i;j++)
			if(!f[i-a[j]]){
				f[i]=1;break;
			}
	cout<<(f[k]?"First":"Second");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c;cin>>a>>b>>c;
    if(a+b+c>=22)cout<<"bust";
    else cout<<"win";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define INF (int)1e9+4
#define INFL (ll)1e18+4
#define md (int)1e9+7
#define mx 10000000  //use fixed<<setprecion
#define mk make_pair
#define pi pair<int,int>
#define ss second
#define ff first
#define pb emplace_back
#define onell(x) __builtin_popcountll(x)
#define one(x) __builtin_popcount(x)
#define maxi(a) *max_element(a.begin(),a.end());
#define mini(a) *min_element(a.begin(),a.end());
#define all(s) s.begin(),s.end()
#define rall(x) (x).rbegin(), (x).rend()
#define trav(x, a) for (auto& x: a)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define sz(x) ((long long)x.size())
#define mez(s) memset(s,0,sizeof s)
#define mex(s) memset(s,-1,sizeof s)
#define metr(s) memset(s,true, sizeof s)
typedef vector<int> vi;
typedef vector<ll>vl;
typedef map<int,int> mp;
typedef queue<int> que;
typedef vector<pi> vp;
int k;
void solve(){
int n=0,x=0,y=0,z=0,l=0,m=0;
cin>>n;
vi a(n),b(n);
rep(i,0,n)cin>>a[i]>>b[i];
rep(i,0,n)
{
	if(a[i]==b[i]){
		l++;
		if(l==3){
			cout<<"Yes\n";
			return;
		}
	}
	else{
		l=0;
	}
}
cout<<"No\n";

}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t=1;
 // cin>>k;
//  cin>>t; 
  while(t--){
  		solve();
  }
  return 0;
}


Measured memory_bytes: 3640
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N, Q;
	in >> N >> Q;
	std::vector<LL>A(N), X(Q);
	rep(i, N) in >> A[i];
	rep(i, Q) in >> X[i];

	std::vector<LL>imos1(N + 1), imos2(N + 1);
	rep(i, N)
	{
		imos1[i + 1] = imos1[i] + A[i];
		imos2[i + 1] += imos2[i];
		if (N % 2 != i % 2) imos2[i + 1] += A[i];
	}

	rep(i, Q)
	{
		LL it1 = std::upper_bound(A.begin(), A.end(), X[i]) - A.begin();
		LL left = it1 - 1, right = N;
		if (left == N - 1)
		{
			out << imos2[N] << std::endl;
			continue;
		}

		while (right - left > 1)
		{
			LL mid = (left + right) / 2;
			LL dis = std::abs(A[mid] - X[i]);
			LL it2 = std::lower_bound(A.begin(), A.end(), X[i] - dis) - A.begin();
			LL cnt = mid - it2 + 1;
			if (N - cnt <= mid) right = mid;
			else left = mid;
		}

		++left;
		LL cnt = N - left;
		out << (imos1[N] - imos1[left]) + imos2[std::max(left - cnt, 0LL)] << std::endl;
	}
}


Measured memory_bytes: 4864
#include <iostream>
#include <cstdint>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <cassert>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

#define REP(i,n) for(LL i=0, i##_len=(n); i<i##_len; ++i)

LL gcd(LL a, LL b) {
  if( b == 0 ) { return a; }
  return gcd(b, a % b);
}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template <LL MOD=1000000007> class MODLL {
public:
  LL x;
  MODLL(const LL _x) : x(_x % MOD) {};
  MODLL operator+(const MODLL rhs) const { return MODLL(*this) += rhs; }
  MODLL operator-(const MODLL rhs) const { return MODLL(*this) -= rhs; }
  MODLL operator*(const MODLL rhs) const { return MODLL(*this) *= rhs; }
  MODLL operator/(const MODLL rhs) const { return MODLL(*this) /= rhs; }
  MODLL& operator+=(const MODLL rhs) { x += rhs.x; x %= MOD; return *this; }
  MODLL& operator-=(const MODLL rhs) { x -= rhs.x; x %= MOD; if(x<0) x += MOD; return *this; }
  MODLL& operator*=(const MODLL rhs) { x *= rhs.x; x %= MOD; return *this; }
  MODLL inv() const {
    if(x == 0) { throw "does not have inverse"; }
    LL a = x, b = MOD, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b; swap(a, b);
      u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return MODLL(u);
  }
  MODLL& operator/=(const MODLL rhs) { (*this) *= rhs.inv(); return *this; }
  MODLL pow(ULL n) const {
    MODLL res = 1;
    MODLL a = x;
    while (n > 0) {
      if (n & 1) res *= a;
      a = a * a;
      n >>= 1;
    }
    return res;
  }
};

typedef MODLL<> ML;


void test() {
  {
    ML x = 3;
    assert(x.pow(45).x == 644897553);
  }
  {
    for(int i=1; i<13; i++) {
      MODLL<13> x = i;
      assert( (x.inv().x * i) % 13 == 1 );
    }
  }
}


int main() {
  LL N,K;
  cin >> N >> K;

  std::vector<LL> V(N);
  REP(n, N) {
    cin >> V[n];
  }

  LL ans = 0;
  LL l_max = min(N+1, K+1);
  REP(l, l_max) {  // take l items from left
    LL r_max = min(N-l+1, K-l+1);
    REP(r, r_max) {
      std::vector<LL> selected;
      REP(i,l) { selected.push_back( V[i] ); }
      for(LL i=(N-r); i<N; i++) { selected.push_back( V[i] ); }
      std::sort( selected.begin(), selected.end() );
      LL n_negative = 0;
      for(LL x: selected) { if(x<0) n_negative++; }
      LL d_max = min( K-(l+r), n_negative );
      LL score = 0;
      for(LL i=d_max; i<selected.size(); i++) { score += selected[i]; }
      ans = max(ans, score);
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;


public class Main{

    private static final Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
            char[] arr = in.next().toCharArray();

            if(arr.length == 26) {
                int[] cnt = new int[26];
                for(char c : arr) {
                    ++cnt[c - 'a'];
                }

                int ans = -1;
                int i = arr.length - 1;
                for(i = arr.length - 1; i >= 0; --i) {
                    //System.err.println(">" +i);
                    for(int j = arr[i] - 'a' + 1; j < 26; ++j) {
                       // System.err.println(">>" +j);
                        if(cnt[j] == 0) {
                            ans = j;
                            break;
                        }
                    }
                    
                    if(ans != -1) break;
                    --cnt[arr[i] - 'a'];
                }

                if(ans == -1) {
                    System.out.println(-1);
                } else {
                    for(int j = 0; j < i; ++j) {
                        System.out.print(arr[j]);
                    }

                    System.out.println((char) ('a' + ans));
                }
            } else {
                int[] cnt = new int[26];
                for(char c : arr) {
                    ++cnt[c - 'a'];
                }

                System.out.print(new String(arr));
                for(int i = 0; i < 26; ++i) {
                    if(cnt[i] == 0) {
                        System.out.println((char) ('a' + i));
                        break;
                    }
                }
            }
    }
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
int arr[200010], cnt[200010], suff[200010];
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> arr[i];
		++cnt[arr[i]];
	}
	long long tot = 0;
	for (int i = 1; i <= 200000; ++i) {
		tot += 1LL * (cnt[i] - 1) * cnt[i] / 2;
	}
	//cout << tot << '\n';
	for (int i = 1; i <= n; ++i) {
		long long t = tot;
		tot -= 1LL * (cnt[arr[i]] - 1) * cnt[arr[i]] / 2;
		--cnt[arr[i]];
		tot += 1LL * (cnt[arr[i]] - 1) * cnt[arr[i]] / 2;
		++cnt[arr[i]];
		cout << tot << '\n';
		tot = t;
	}
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f, N = 2e5 + 6, S = (1 << 20) + 5;
inline int read() {
	int x = 0, f = 1; char ch = getchar();
	while(!(ch >= '0' && ch <= '9')) {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	return x * f;
}
int a[N], L[20][N], R[20][N], l[N<<4], r[N<<4];
pair <int, int> s[N];
bool an[N];
int main() {
	int n = read(), m = read(), d;
	for(int i = 1; i <= n; i++) a[i] = read();
	a[0] = -INF - m - 1, a[n+1] = INF + m + 1;
	for(int i = m; ~i; i >>= 1, d++) {
		R[d][n+1] = n+1;
		for(int j = 1; j <= n; j++)
			L[d][j] = a[j] - a[j-1] <= i ? L[d][j-1] : j;
		for(int j = n; j; j--)
			R[d][j] = a[j+1] - a[j] <= i ? R[d][j+1] : j;
		if(!i) {d++; break;}
	}
	for(int i = 1; i <= n; i++) s[i] = make_pair(L[0][i], R[0][i]);
	int cnt = unique(s + 1, s + 1 + n) - s - 1;
	for(int i = 0; i < 1 << d; i++) r[i] = n + 1;
	for(int i = 0; i < 1 << d; i += 2)
		for(int j = 0; j < d; j++)
			if(i & 1 << j)
				l[i] = max(l[i], R[j][l[i^(1<<j)]+1]),
				r[i] = min(r[i], L[j][r[i^(1<<j)]-1]);
	if(cnt <= d) for(int i = 1; i <= cnt; i++)
		for(int j = 0; j < 1 << d; j += 2)
			if(l[j] >= s[i].first - 1 && r[(1<<d)-j-2] <= s[i].second + 1) {
				for(int j = s[i].first; j <= s[i].second; j++) an[j] = 1;
				break;
			}
	for(int i = 1; i <= n; i++)
		puts(an[i] ? "Possible" : "Impossible");
	return 0;
}


Measured memory_bytes: 41856
import sys  # sys.exit()を使いたいので

n = int(input())
a = list(map(int, input().split()))

if 0 in a:
# 0が1つでもあれば0です
    print(0)
else:
# 0がない場合
    cur = 1  # 現在の数値
    for x in a:
        cur *= x
        if cur > 10 ** 18:
        # 10**18を超えたので終了します
            print(-1)
            sys.exit()
    print(cur)  # 10**18以下なので、出力します

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

using namespace std;

const int N=1e5+5;
typedef long long ll;
set<int> s,s2;
int a[N];
int main()
{
    string s;
    cin >> s;
    ll k;
    cin >> k;
    int ans=1;
    for(int i=0;i<k;i++) if(s[i]-'0'!=1) {ans=s[i]-'0';break; }
    cout << ans << endl;
    return 0;
}


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

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++) // repマクロ
#define all(v) v.begin(), v.end() // sort等の関数呼び出しを簡潔にする

using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

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

    if((A == B) && (B == C)){
        cout << "No" << endl;
    }else if((A == B) || (A == C) || (B == C)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

multiset<ll> mt;

int main(){
	ll N;
	cin >> N;
	vector<ll> A(N);
	REP(i, N) cin >> A[i];

	REP(i, N) mt.insert(A[i]);
	ll res = 0;
	while(!mt.empty()){
		ll beki = 2;
		ll ma = *(--mt.end());
		mt.erase(--mt.end());
		while(beki<=(1<<30)){
			ll x = beki - ma;
			auto itr = mt.find(x);
			if(itr!=mt.end()){
				res++;
				mt.erase(itr);
				break;
			}
			beki *= 2;
		}
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 11136
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int n = b -a ;
		int sum = 0;
		int ans = 0;
		for(int i=0;i < n;i++){
			sum += i;
		}
		ans = sum -a;
		System.out.println(ans);
	}









}








Measured memory_bytes: 23764
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		String x=scanner.next();
		int cntS=0;
		int cnt=0;
		for(int i=0;i<x.length();i++) {
			char c=x.charAt(i);
			if(c=='S')cntS++;
			else {
				if(cntS>0) {
					cnt+=2;
					cntS--;
				}
			}
		}
		System.out.println(x.length()-cnt);
	}
}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 24020
import itertools
N = str(input())
Keta = len(N)
N_List = ["3","5","7"]

## ここまでの計算量はMax8回とみてOK？
## いずれにしろあまり気にしなくてOK
Ans = 0
for i in range(3,Keta):
    Ans += 3**i
    Ans -= (2**i*3) -3

N = int(N)

##　組み合わせはMaxでも3**10 = 60000くらい
##  計算量間に合う
if Keta >= 3:
    for Moji in itertools.product(N_List, repeat=Keta):
        Moji_Kazu = len(set(Moji))
        Str_Number = int("".join(Moji))
        if (Str_Number <= N) & (Moji_Kazu == 3):
            Ans += 1
    
print(Ans)

Measured memory_bytes: 9148
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define NREP(i, n) for(int i = 1; i <= (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cout << fixed << setprecision(7);
////////////////////////////////////////////
	int n;
    cin >> n;
    int p[n],q[n];
    REP(i,n){
        cin >> p[i];
        q[i]=p[i];
    }
    SORT(q,n);
    bool bb=1;
    REP(i,n){
        if(p[i]!=q[i]) bb=0;
    }
    if(bb){
        cout << "YES" << endl;
        return 0;
    }else{
        bb=1;
    }

    REP(i,n){
        REP(j,n){
            if(i==j) continue;
            swap(p[i],p[j]);
            bb=1;
            //cout << p[i] << endl;
            REP(k,n){
                if(p[k]!=q[k]) bb=0;
            }
            if(bb==1) break;
            swap(p[i],p[j]);
        }
        if(bb==1) break;
    }

    cout << (bb ? "YES" : "NO") << endl;
///////////////////////////////////////////
}


Measured memory_bytes: 256
package main

import "fmt"

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

	max := (n - 2) * (n - 1) / 2
	if max < k {
		fmt.Println(-1)
		return
	}

	m := (n - 1) + (max - k)
	fmt.Println(m)
	for i := 1; i <= n-1; i++ {
		for j := i + 1; j <= n; j++ {
			if m <= 0 {
				return
			}
			fmt.Println(i, j)
			m--
		}
	}
}


Measured memory_bytes: 640
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::PI;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let A: f64 = sc.get();
    let B: f64 = sc.get();
    let H: f64 = sc.get();
    let M: f64 = sc.get();
    let alpha = (30. * H + 0.5 * M - 6. * M).abs() / 360. * 2. * PI;
    let ans = (A * A + B * B - 2. * A * B * alpha.cos()).sqrt();
    println!("{}", ans);
}


Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<int,int>;

int main() {
    int n,x,t;
    cin >> n >> x >> t;
    if(n%x==0) {
        int ans=t*n/x;
        cout << ans << endl;
    }
    else{
        int ans=t*(n/x)+t;
        cout << ans << endl;
    }
}


Measured memory_bytes: 3632
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

string s;
bool a[26];

int main() {
    fastio();

    cin >> s;

    forn(i, s.size()) {
        a[s[i] - 'a'] = true;
    }

    forn(i, 26) {
        if (!a[i]) {
            cout << char(i + 'a') << endl;
            return 0;
        }
    }

    cout << "None\n";

    return 0;
}

Measured memory_bytes: 512
fun main(args: Array<String>) = println(run {
    val n = readLine()!!.toInt()
    val (t,a) = readLine()!!.split(" ").map { it.toInt() }
    val h = readLine()!!.split(" ").map { it.toInt() }

    h.map { t-it*0.006 }.withIndex().minBy { Math.abs(it.value-a) }!!.index+1
})


Measured memory_bytes: 37944
#include<iostream>
using namespace std;
int D;
int c[26];
int S[365][26];
int t[365];
int lst[26];
main()
{
	cin>>D;
	for(int i=0;i<26;i++)cin>>c[i];
	for(int i=0;i<D;i++)for(int j=0;j<26;j++)cin>>S[i][j];
	int ans=0;
	for(int i=0;i<D;i++)
	{
		cin>>t[i];
		ans+=S[i][t[i]-1];
		lst[t[i]-1]=i+1;
		for(int j=0;j<26;j++)ans-=c[j]*(i+1-lst[j]);
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 3628
S = input()[::-1]

S_mod = [0] * (len(S)+1)
S_mod[0] = int(S[0])

mod_count = [0] * 2019

d = 10

#for i in range(len(S)):
#    S_mod[i] = int(S[i:len(S)])%2019

for i in range(len(S)-1):
    S_mod[i + 1] = (S_mod[i] + int(S[i+1])*d)%2019
    d = d * 10 % 2019
    
#print(S_mod)

for i in range(len(S_mod)):
    mod_count[S_mod[i]] += 1

#print(mod_count)
    
count = 0
for i in range(2019):
    count += mod_count[i] * (mod_count[i] - 1) / 2
    
print(int(count))

#S = list(map(int, list(input())))



Measured memory_bytes: 16296
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
const int MAX=1000001;

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

    int count=0;
    bool ok=false;
    int cur=1;
    for(int i=0;i<n;i++){
        cur=a[cur];
        count++;
        if(cur==2){
            ok=true;
            break;
        }
    }

    if(ok) cout<<count<<endl;
    else cout<<-1<<endl;
}    

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n,m;cin>>n>>m;

    
    if(n%2 == 1){
        REP(i,m){
            int c1 = i+1;
            int c2 = c1 + 2*(m-i)-1;

            cout<<c1<<" "<<c2<<endl;
        }
        return;
    }

    
    REP(i,m/2){
        int c1 = i+2;
        int c2 = c1 + 2*(m/2-i)-1;

        cout<<c1<<" "<<c2<<endl;
    }
    REP(i,m/2){
        int c1 = i+1;
        int c2 = c1 + 2*(m/2-i);

        cout<<c1+n/2<<" "<<c2+n/2<<endl;
    }
    if(m%2==1){
        cout<<1<<" "<<n/2<<endl;
    }

    /*
    vector<bool> f(n+100,false);
    int dif = 1;
    int count = 0;
    REP(i,n){
        //dump(i)
        //REP(j,n){
        //    cerr<<f[i];
        //}
        //cerr<<endl;
        if(f[i] || f[(i+dif)%n]){
            continue;
        }
        cout<<i+1<<" "<<i+1+dif<<endl;
        f[i] = true;
        f[(i+dif)%n] = true;
        dif++;
        count++;
        if(count == m){
            break;
        }
    }
    */



	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
int main(){
 int w;
 int h;
 int x;
 int y;
 int r;
 std::cin >> w >> h >> x >> y >> r;
 if( w-r >= x && h-r >= y && x >=1 && y >= 1){
  std::cout << "Yes" << std::endl;
 } else {
  std::cout << "No" << std::endl;
 }
}

Measured memory_bytes: 3088
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll n,k,i,j;
	cin>>n>>k;
	ll ans=0;
	for(i=k;i<=n+1;i++){
		ans+=(n*(n+1))/2;
		if(i!=n+1)ans-=((n-i)*(n-i+1))/2;
		ans-=(i*(i-1))/2;
		ans++;
		ans%=hell;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3640
from itertools import product
n,m=map(int,input().split())
ks=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))
count=0
for i in product([0,1],repeat=n):
    for j in range(m):
        
        temp=0
        for k in range(ks[j][0]):
            if i[ks[j][k+1]-1]==1:
                temp+=1
        if temp%2!=p[j]:
            break
    else: 
        count+=1
print(count)


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

void show(int A[],int N){
    for(int i = 0; i < N;i++){
        if(i > 0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}

int bubble(int A[],int N){
    int count = 0;
    for(int i = 0; i < N-1; i++){
        int j = N-1;
        while(j > i){
            if(A[j-1] > A[j]){
                swap(A[j-1],A[j]);
                count += 1;
            }
            j--;
        }
    }
    return count;
}

int main(){
    int N;
    int ans;
    cin >> N;
    int A[N];
    for(int i = 0; i < N;i++){
        cin >> A[i];
    }
    ans = bubble(A,N);
    show(A,N);
    cout << ans << endl;
}


Measured memory_bytes: 3224
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main()
{
    int N, i;
    cin >> N >> i;
    cout << N - i + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
//#include "pch.h"
#include <iostream>
#include<algorithm>

using namespace std;

int main()
{
   
	int p,q, r;
	cin >> p >> q >> r;
	int ans;
	if (p + q <= q + r && p + q <= p + r) {
		ans = p + q;
	}
	else if (q + r <= p + r) {
		ans = q + r;
	}
	else {
		ans = p + r;
	}
	cout << ans << endl;
}



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

int main(void){
    int n;
    cin>>n;
    int x=n/25;
    n%=25;
    x+=n/10;
    n%=10;
    x+=n/5;
    n%=5;
    x+=n;
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
string s;
int n;
void dfs(int p,char k,int v)
{
	if(p==n+1)
	{
		cout<<s<<endl;
		return;
	}
	for(char c='a';c<=k;c++)
	{
		s+=c;
		dfs(p+1,k,v|(c==k));
		s.pop_back();
	}
	if(v)
	{
		k++;
		s+=k;
		dfs(p+1,k,1);
		s.pop_back();
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	dfs(1,'a',0);
	return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <string.h>

int main() {
	int n;
	int i, j;
	int flag = 0;

	scanf ("%d", &n);
	char w[n][11];

	for (i = 0; i < n; i++) {
		scanf ("%s", w[i]);
	}
	
	for (i = 0; i < n - 1; i++) {
		for (j = i+1; j < n; j++) {
			if (strcmp(w[i], w[j]) == 0) {
				flag = 1;
				break;
			}
		}

		if (w[i][strlen(w[i])-1] != w[i+1][0]) {
			flag = 1;
		}

		if (flag == 1)
			break;
	}

	if (flag == 0)
		printf ("Yes\n");
	else
		printf ("No\n");

	return 0;
}

Measured memory_bytes: 128
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(13);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);

#define debug(x) cout << __LINE__ << " : "#x << "..." << x << endl

const double PI = 3.141592653589793;

void solve()
{
	int n;
	cin >> n;
	vector <int> p(n);
	for(int i=0;i<n;i++) p[i] = i+1;
	vector <int> q(p);
	int a = 0, b = 0;
	vector <int> x(n);
	for(int &i : x) cin >> i;
	while(p!=x)
	{
		a++;
		next_permutation(all(p));
	}
	for (int &i : x) cin >> i;
	while(q!=x)
	{
		b++;
		next_permutation(all(q));
	}
	cout << abs(a-b);
}

int32_t main()
{
	FastIO;
	Fast_D;
	int T;
	T=1;
	while(T--) solve();
	return 0;
}



Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <string.h>

using namespace std;


int d,w;
int height[10][10];

int _func(int s1, int s2, int t1, int t2){
    int _min = 11;
    int _max = 0;
    int sum = 0;
    for(int s=s1;s<=s2;s++){
        for(int t=t1;t<=t2;t++){
            if(s == s1 || s == s2 || t == t1 || t == t2){
                _min = min(_min, height[s][t]);
            }
            else{
                _max = max(_max, height[s][t]);
                sum += height[s][t];
            }
        }
    }
    if(_max < _min){
        return (s2-s1-1)*(t2-t1-1) * _min - sum;
    }
    return 0;
}
int main() {
    while (true) {
        cin >> d >> w;
        if (d == 0 || w == 0) break;

        for(int i=0;i<d;i++){
            for(int j=0;j<w;j++){
                cin >> height[i][j];
            }
        }

        int m = 0;
        for(int s1=0;s1<d;s1++){
            for(int s2=s1+2;s2<d;s2++){
                for(int t1=0;t1<w;t1++){
                    for(int t2=t1+2;t2<w;t2++){
                        m = max(m, _func(s1,s2,t1,t2));
                    }
                }
            }
        }

        cout << m << endl;
    }
    return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	int n;
	cin >> n;
	vector<pair<LL, LL>> p;
	inc(i, n) {
		LL x, l;
		cin >> x >> l;
		p.EB(x + l, x - l);
	}
	sort(ALL(p));
	
	int ans = 0;
	LL s = -2e9;
	RF(e, p) {
		if(s <= e.SE) { ans++; s = e.FI; }
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(a,b) for(ll i=a;i<=b;i++)
#define show(x) cout<<x<<"\n"
#define vr vector<ll> 
ll fact(ll n); 
  
ll nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
// Returns factorial of n 
ll fact(ll n) 
{ 
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
int main()
{
	ll l;
	cin>>l;
	double c;
	c=(double)l/3;
	double ans=c*c*c;
	cout<<fixed<<setprecision(6)<<ans;

}

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

int main()
{
    char top[100005];
    cin >> top;
    int N=strlen(top);//じゃんけん回数
    int p_num = N/2;//パーを何回出せるか
    int top_p=0;
    for(int i=0; i<N; i++){
        if(top[i]=='p'){
            top_p++;
        }
    }
    cout << p_num-top_p;

    return 0;
}

Measured memory_bytes: 384
let n = read_int ()

let rec f i j s =
  if i = n then s + (j + 1) / 2
  else
    Scanf.scanf " %d" (fun p ->
      if p = i + 1 then f (i + 1) (j + 1) s
      else f (i + 1) 0 (s + (j + 1) / 2)
    )

let () = Printf.printf "%d\n" (f 0 0 0)


Measured memory_bytes: 9064
#include<iostream>
#include<vector>

using namespace std;

vector<int> A;

bool makeCombination(int depth, int m)
{
    if (depth == 0) {
        if (m == 0) {
            return true;
        } else {
            return false;
        }
    } else {
        int target = A[depth - 1];
        //cout << "target: " << target << " the rest: " << m - target << endl;
        if (m - target < 0) {
            if (makeCombination(depth - 1, m)) return true;
            else return false;
        } else {
            if (makeCombination(depth - 1, m - target) || makeCombination(depth - 1, m)) return true;
            else return false;
        }
    }

}

int main()
{
    int n, q;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
    }
    cin >> q;

    for (int i = 0; i < q; ++i) {
        int target;
        cin >> target;
        if (makeCombination(n, target)) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3140
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var solver = new Solver();
            solver.Calc();
        }

    }
    public class Solver
    {
        public void Calc()
        {
            var N = Console.ReadLine();

            Console.WriteLine(N.Any(x => int.Parse(x.ToString()) == 7) ? "Yes" : "No");

        }


    }
}


Measured memory_bytes: 18420
#include<stdio.h>
#include<string.h>

int main(void){

    char S[200001],T[200001];
    int len,i,count=0;

    scanf("%s",S);
    scanf("%s",T);

    len=strlen(S);

    for(i=0;i<len;i++){
        if(S[i]!=T[i]){
            count++;
        }
    }

    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 2120
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace ConsoleApp15
{
    class Class6
    {
        static void Main()
        {
            var HW = ReadLine().Split().Select(int.Parse).ToArray();
            int N = int.Parse(ReadLine());
            var a = ReadLine().Split().Select(int.Parse).ToArray();
            int H = HW[0], W = HW[1];

            string[] line = new string[H * W];
            int num = 0;
            for(int i = 0; i < N; i++)
            {
                for(int j = 0; j < a[i]; j++)
                {
                    line[num] = (i+1).ToString();
                    num++;
                }
            }
            
            for(int i = 0; i < H; i++)
            {
                string[] ans = new string[W];
                for (int k = 0; k < W; k++) ans[k] = line[i * W + k];
                if (i % 2 == 1) Array.Reverse(ans);
                WriteLine(string.Join(" ", ans));
            }
        }
    }
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

typedef long long ll;

int A,B,C,X,Y;

int main(){
	cin>>A>>B>>C>>X>>Y;
	int ans=0;
	ans=min(X,Y)*min(C*2,A+B);
	int m=min(X,Y);
	X-=m;
	Y-=m;
	if (X!=0){
		ans+=X*min(C*2,A);
	}
	if (Y!=0){
		ans+=Y*min(C*2,B);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))

i=n-1
while i>=0:
    if A[i]==1:
        s=i
        break
    i-=1

if i==-1:
    print(0)
elif s==0:
    print(1)
    print(1)
else:
    i=(s+1)//2-1
    while i>=0:
        B=[A[j] for j in range(i,n,i+1)]
        r=sum(B[1:])
        if r%2==0 and A[i]==0:
            A[i]=0
        elif r%2==0 and A[i]==1:
            A[i]=1
        elif r%2==1 and A[i]==0:
            A[i]=1
        else:
            A[i]=0
        i-=1
    C=[m for m,k in enumerate(A,1) if k!=0]
    print(len(C))
    print(*C)

Measured memory_bytes: 15412
N,K = map(int,input().split())

L = list(map(int,input().split()))

dp = [0 for i in range(N)]
if N >= K :    
    for i in range(1,K+1) :
        dp[i] = abs(L[i]-L[0])
    for i in range(K+1,len(dp)) :
        state = float("inf")
        for j in range(i-K,i) :
            calc = abs(L[i]-L[j]) + dp[j]
            if state > calc :
                state = calc
        dp[i] = state
    print(dp[N-1])
else :
    print(abs(min(L[1:])-L[0]))



Measured memory_bytes: 56544
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

using i64 = long long;
#define forn(a, e) for (i64 a = 0; a < (i64)(e); a++)
#define forr(a, s, e) for (i64 a = s; a < (i64)(e); a++)
#define fore(e, a) for (auto& e : a)

#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logvff(a, f1, f2) {cerr << #a".{"#f1 << ", "#f2 << "} = \n"; fore(e, a) { cerr << "(" << e.f1 <<", " << e.f2 << ") ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logvff(a, f1, f2)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif

using iip = pair<int, int>;
using llp = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;
template<typename T> using vec = vector<T>;

template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }

template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }

template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }
template<typename T, size_t N>
istream& operator>>(istream& is, array<T, N>& c) { for (auto& e : c) is >> e; return is; }

template<typename ...T>
istream& read(T&... args) { return (cin >> ... >> args); }

static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }

const i64 INF = 1e18;
const i64 M = 1e9 + 7;
const int MXB = 20;
using bin = bitset<MXB + 1>;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    rande.seed(chrono::steady_clock::now().time_since_epoch().count());

    string s;
    while (read(s)) {
        string ns = s;
        forn(i, s.size()) {
            if (i % 2 == 0) {
                ns[i] = 'g';
            } else {
                ns[i] = 'p';
            }
        }
        int ans = 0;
        forn(i, s.size()) {
            if (s[i] == 'p' && ns[i] == 'g') {
                ans--;
            } else if (s[i] == 'g' && ns[i] == 'p') {
                ans++;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3788
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    int c=sc.nextInt();
    System.out.println((a+b+c-Math.max(a,Math.max(b,c))));
  }
}

Measured memory_bytes: 21588
#include<stdio.h>
int main(){
  int n,a,b,c,d;
  char s[200020];
  scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
  scanf("%s",s);

  int i,k;
  if(c>d) k=c;
  else k=d;
  for(i=a;i<k-1;i++){
    if(s[i]==s[i+1] && s[i]=='#'){
      printf("No\n");
      return 0;
    }
  }

  if(c > d){
    for(i=b-1;i<d;i++){
      if(s[i-1]==s[i] && s[i]==s[i+1] && s[i]=='.'){
        printf("Yes\n");
        return 0;
      }
    }
    printf("No\n");
    return 0;
  }else
    printf("Yes\n");
  return 0;
}


Measured memory_bytes: 1852
package main

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

type S1 []int

func (s *S1) IsEmpty() bool {
	return len(*s) == 0
}

func (s *S1) Push(t int) {
	(*s) = append((*s), t)
}

func (s *S1) Pop() int {
	last := len(*s) - 1
	ret := (*s)[last]
	*s = (*s)[:last]
	return ret
}

type S2 [][]int

func (s *S2) IsEmpty() bool {
	return len(*s) == 0
}

func (s *S2) Push(j, a int) {
	(*s) = append((*s), []int{j, a})
}

func (s *S2) Pop() (int, int) {
	last := len(*s) - 1
	ret := (*s)[last]
	*s = (*s)[:last]
	return ret[0], ret[1]
}

func (s *S2) Top() []int {
	return (*s)[len(*s)-1]
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	in := strings.Split(sc.Text(), "")

	total := 0
	s1 := S1([]int{})
	s2 := S2([][]int{})
	for i, s := range in {
		switch s {
		case `\`:
			s1.Push(i)
		case `/`:
			if s1.IsEmpty() {
				continue
			}
			j := s1.Pop()
			a := i - j
			total += a
			for !s2.IsEmpty() && s2.Top()[0] > j {
				a += s2.Top()[1]
				s2.Pop()
			}
			s2.Push(j, a)
		}
	}

	fmt.Println(total)
	str := make([]string, 0, len(s2)+1)
	str = append(str, strconv.Itoa(len(s2)))
	for _, n := range s2 {
		str = append(str, strconv.Itoa(n[1]))
	}
	fmt.Printf("%s\n", strings.Join(str, " "))
}


Measured memory_bytes: 2372