akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  string S;
  cin >> S;
  int capital = 0;
  for(int i = 0; i < S.size(); i++){
    if(S[i] >= 'A' && S[i] <= 'Z') capital++;
  }
  int C = 0;
  for(int i = 2; i < S.size() - 1; i++){
    if(S[i] == 'C') C++;
  }
  if(S[0] == 'A' && capital == 2 && C == 1) cout << "AC" << endl;
  else cout << "WA" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	print(n*n);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <sstream>
#include <cctype>
using namespace std;

#define PQ priority_queue
#define P pair<int,int>
#define CLA(array) memset(array,0,sizeof array)
#define CLINF(array) memset(array,0x3f,sizeof array)
#define CLF(array) memset(array,-1,sizeof array)
#define DB(a) cout << "DEBUG " << a << endl;
typedef long long LL;
typedef unsigned long long ULL;
const int MAXN = 100000 + 50;
const int INF = 1 << 30;
int n;
LL a[105];
LL lcm(LL a, LL b){
	return a/__gcd(a, b)*b;
}
int main(){
    //ios_base::sync_with_stdio(false);
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%lld", &a[i]);
	}
	if(n == 1){
		printf("%lld\n", a[0]);
		return 0;
	}
	LL ans = lcm(a[0], a[1]);
	for(int i = 2; i < n; i++){
		ans = lcm(ans, a[i]);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
if N < 3:
    print(0)
    exit()

ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        if L[i] == L[j]:
            continue
        for k in range(j+1, N):
            if L[i] == L[k] or L[j] == L[k]:
                continue
            if L[i] < L[j] + L[k]:
                ans += 1

print(ans)


Measured memory_bytes: 9208
N = int(input())
li = list(map(int,input().split()))	
di = {}
count = 0
for i in range(N):
    if str((i+1)-li[i]) in di.keys(): 
        count += di[str((i+1)-li[i])]
    if str(i+1+li[i]) in di.keys(): 
        di[str(i+1+li[i])] += 1
    else:
        di[str(i+1+li[i])] = 1
print(count)

Measured memory_bytes: 116348
p = gets.chomp.to_i
x = gets.chomp.split.map(&:to_f)
y = gets.chomp.split.map(&:to_f)

def p_dist(x,y,p)
  x.zip(y).reduce(0){|t, (x_i, y_i)|
    t + (x_i - y_i).abs ** p
  } ** (1/p.to_f)
end

puts p_dist(x,y,1)
puts p_dist(x,y,2)
puts p_dist(x,y,3)
puts x.zip(y).map{|(x_i, y_i)| (x_i - y_i).abs}.max


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


int main(){
	int X; cin >> X;
	if(X>=30) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	
}













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

int main() {
	int K, A, B;
	cin >> K >> A >> B;
	if (A <= B / K * K && B / K * K <= B) {
		puts("OK");
	}
	else {
		puts("NG");
	}
	return 0;
}

Measured memory_bytes: 3644
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n= sc.nextInt();
		Map<Long,Long> a=new HashMap<>();
        Map<Long,Long> b=new HashMap<>();
		for(int i=0;i<n;i++){
            long t=sc.nextLong();
            Long x=a.get(i-t);
			if(x==null){
				a.put(i-t,(long)1);
			}else{
				a.put(i-t,x+1);
			}
            x=b.get(t+i);
			if(x==null){
				b.put(t+i,(long)1);
			}else{
				b.put(t+i,x+1);
			}
		}
		long ans=0;
		for (Long key : a.keySet()) {
			Long x=a.get(key);
			if(x==null){
				x=(long)0;
			}
            Long y=b.get(key);
			if(y==null){
				y=(long)0;
			}
            ans+=x*y;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 72340
#include <bits/stdc++.h>
#include <ext/numeric>
/**
       return NO_PAIN ? NO_GAIN : GAIN;
*/
using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define sz(x)    (int) x.size()
#define Unique(x) x.erase(unique(all(x)), x.end())
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define START cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power(n, m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define mem(x, val)    memset(x, val, sizeof(x)) //be careful of value and TLE
#define MOD 1000000007


typedef long long ll;
typedef long double ld;
typedef double dd;
typedef pair<int, int> pii;
typedef vector<int> vi;


int main()
{
    START
    //freopen("test cases\\in.txt", "r", stdin) ;
    //freopen("test cases\\out.txt", "w", stdout) ;
    ld a, b; cin>>a>>b;
    cout<<fixed<<setprecision(0)<<trunc(a*b);
	return 0;
}


Measured memory_bytes: 3812
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int a,b;
	cin>>a>>b;
	if(b>=a)
		cout<<"unsafe";
	else
		cout<<"safe";
	return 0;
}

Measured memory_bytes: 3648
#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;
}

int main(){
	ll N, L;
	cin >> N >> L;
	vector<ll> a;
	REP(i, N){
		ll p;
		cin >> p;
		a.push_back(p); 
	}

	ll ind = -1;
	vector<ll> res;
	REP(i, N-1){
		if(a[i]+a[i+1]>=L){
			ind = i;
			break;
		}
	}  
	if(ind==-1){
		cout << "Impossible" << endl;
		return 0;
	}
	res.push_back(ind+1);
	for(int i=ind;i>=1;i--) res.push_back(i);
	for(int i=ind+2;i<=N-1;i++) res.push_back(i);
	cout << "Possible" << endl;
	REP(i, res.size()){
		cout << res[res.size()-1-i] << endl;
	}
    return 0;
}

Measured memory_bytes: 2548
# A B

a, b = gets.chomp.split(" ").map(&:to_i)

def eratosthenes_sieve(n)
  check = Array.new(n, false)
  primes = []

  (2..n).each do |i|
    if !check[i]
      primes << i

      (i..n).step(i).each do |j|
        check[j] = true
      end
    end
  end

  primes
end

def prime_factorization(n)
  m = n
  result = []
  primes = eratosthenes_sieve(Math.sqrt(n).ceil)

  while true
    found = false

    primes.each do |pr|
      if m % pr == 0
        result << pr
        found = true
        m = m / pr
        break
      end
    end

    if !found
      result << m if m != 1
      break
    end
  end

  result
end

p_a = prime_factorization(a)
p_b = prime_factorization(b)

h_a = {}
h_b = {}

p_a.each do |i|
  h_a[i] ||= 0
  h_a[i] += 1
end

p_b.each do |i|
  h_b[i] ||= 0
  h_b[i] += 1
end

prod = 1

(h_a.keys + h_b.keys).uniq.each do |k|
  a = h_a[k] || 0
  b = h_b[k] || 0
  c = [a, b].max

  c.times do
    prod = prod * k
  end
end

puts prod


Measured memory_bytes: 1916
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <cmath>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
  ll N, Q ,tmp;
  cin >> N;
  ll naka[100010]={};
  set<ll> A;
  rep(i,N){
    cin >> tmp;
    if(naka[tmp]==0) A.insert(tmp);
    naka[tmp]++;
  }
  
  cin >> Q;
  ll B[100010];
  ll C[100010];
  rep(i,Q){
    cin >> B[i] >> C[i];
  }
  
  ll t1, t2;
  ll sum = 0;
  for(auto x : A){
    sum += x*naka[x];
  }
  rep(i,Q){
    //auto itr = A.find(B[i]);
    //if(itr != A.end()){
      t1 = naka[B[i]];
      naka[C[i]] += naka[B[i]];
      naka[B[i]] = 0;
      A.erase(B[i]);
      A.insert(C[i]);
      sum = sum + t1*(C[i]-B[i]);
    //}
    cout << sum << endl;
  }
  
}

Measured memory_bytes: 8828
//
//  C - Back and Forth.cpp
//  Practice
//
//  Created by Hajime Sakamoto on 2019/12/18.
//  Copyright © 2019 Hajime Sakamoto. All rights reserved.
//

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <iterator>

using namespace std;

class Trajectry{
public:
    
    int sx;
    int sy;
    
    int tx;
    int ty;
    
    int dx ;
    int dy ;
    
    vector<char> tra_1_x;
    vector<char> tra_1_y;
    
    vector<char> tra_2_x;
    vector<char> tra_2_y;
    
    vector<char> tra_3_x;
    vector<char> tra_3_y;
    
    vector<char> tra_4_x;
    vector<char> tra_4_y;
    
    vector<char> traJoin;
    
    string tra_outPut;
    
    void tra_12(){
        dx = tx - sx;
        dy = ty - sy;
        
        for (int i =0; i<dx; i++) {
            tra_1_x.push_back('R');
            tra_2_x.push_back('L');
        }
        for (int i =0; i<dy; i++) {
            tra_1_y.push_back('U');
            tra_2_y.push_back('D');
        }
    };
    
    void tra_34(){
        dx = tx - sx;
        dy = ty - sy;
        
        
        for (int i =0; i<dx+1; i++) {
            tra_3_x.push_back('R');
            tra_4_x.push_back('L');
        }
        for (int i =0; i<dy+1; i++) {
            tra_3_y.push_back('U');
            tra_4_y.push_back('D');
        }
    };
    
    
    void tra_join(){
        traJoin.insert(traJoin.end(), tra_1_y.begin(), tra_1_y.end());
        traJoin.insert(traJoin.end(), tra_1_x.begin(), tra_1_x.end());
        
        traJoin.insert(traJoin.end(), tra_2_y.begin(), tra_2_y.end());
        traJoin.insert(traJoin.end(), tra_2_x.begin(), tra_2_x.end());
        
        traJoin.insert(traJoin.end(), 'L');
        traJoin.insert(traJoin.end(), tra_3_y.begin(), tra_3_y.end());
        traJoin.insert(traJoin.end(), tra_3_x.begin(), tra_3_x.end());
        traJoin.insert(traJoin.end(), 'D');
        
        
        traJoin.insert(traJoin.end(), 'R');
        traJoin.insert(traJoin.end(), tra_4_y.begin(), tra_4_y.end());
        traJoin.insert(traJoin.end(), tra_4_x.begin(), tra_4_x.end());
        traJoin.insert(traJoin.end(), 'U');
        
        std::ostringstream os;
        std::copy(traJoin.begin(), traJoin.end(), std::ostream_iterator<char>(os));//型をvectorの要素と揃える
        tra_outPut  = os.str(); // 文字列結合
        
    };
    
    void tra_OutPut(){
        cout << tra_outPut;
    };
};

int main(){
    Trajectry Prc;
    
    cin >> Prc.sx >> Prc.sy >> Prc.tx >> Prc.ty;
    Prc.tra_12();
    Prc.tra_34();
    Prc.tra_join();
    Prc.tra_OutPut();
    
    return 0;
    
}



Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

string x[4] = {"dream", "dreamer", "erase", "eraser"};

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

    reverse(s.begin(), s.end());
    rep(i, 4) {
        reverse(x[i].begin(), x[i].end());
    }

    int flag1 = 1;
    int i = 0;
    while(i < s.size()) {
        int flag2 = 0;
        rep(j, 4) {
            string u = x[j];
            if(s.substr(i, u.size()) == u) {
                flag2 = 1;
                i += u.size();
            }
        }
        if(!flag2) {
            flag1 = 0;
            break;
        }
    }

    if(flag1) {
        cout << "YES";
    }
    else {
        cout << "NO";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

ll f(ll x) {
    int i = 1;
    while(x >= i*(i+1)/2) {
        i++;
    }
    return i-1;
}

int main () {
    ll n; cin >> n;
    vector<ll> p;
    ll cnt = 0;
    while (n%2 == 0) {
        n /= 2;
        cnt++;
    }
    p.push_back(cnt);
    for (ll i = 3; i <= 1000000; i += 2) {
        if (n%i != 0) continue;
        cnt = 0;
        
        while (n % i == 0) {
            n /= i;
            cnt++;
        }
        p.push_back(cnt);
        if (n == 1) break;
    }
    ll ans = 0;
    if (n > 1) ans++;
    for (ll x : p) {
        ans += f(x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
a, b, c, d = gets.split.map(&:to_i)
e = c.lcm(d)
aa = a - 1

bc = b / c
bd = b / d
be = b / e
bs = bc + bd - be
ans = b - bs

aac = aa / c
aad = aa / d
aae = aa / e
aas = aac + aad - aae
aaa = aa - aas

puts ans - aaa


Measured memory_bytes: 1788
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

ll c[N];
vi v[N];
void dfs(int u, int e)
{
	c[u] += c[e];
	for(auto it : v[u])
		if(it != e)
			dfs(it, u);
}
int main()
{
	int n, q;
	cin >> n >> q;
	for(int i = 2; i <= n; i ++)
	{
		int x, y;
		cin >> x>> y;
		v[x].pb(y);
		v[y].pb(x);
	}
	for(int i = 1; i <= q; i ++)
	{
		ll x, y;
		cin >> x >> y;
		c[x] += y;
	}
	dfs(1, 0);
	
	for(int i = 1; i <= n; i ++)
		cout << c[i] << ' ';




	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

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

int main(){
    long long N;
    cin >> N;
    long long p;
    long long q;
    for(p = 1; p*p <= N; p++){
        if(N%p == 0) q = N/p;
    }
    long long keta = 0;
    while(q){
        q /= 10;
        keta++;
    }
    cout << keta << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 504
/*==================================
 Author : Amrito
 Email  : amritohstu@gmail.com
 ===================================*/

#include <bits/stdc++.h>
using namespace std;

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

//definition
#define PI acos(-1)
#define MAX 1000000010

//main code
int main()
{
#ifdef LOCAL
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    // start code
    int a, b, c, m, k;
    cin >> a >> b >> c;
    cin >> k;
    m = max(a, b);
    m = max(m, c);
    ll sum = a + b + c - m + m * pow(2.0, k);
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) throws Exception {
        int[][][] num = new int[4][3][10];

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        IntStream.range(0, n).forEach(i -> {
            try {
                List<Integer> list = Arrays.stream(br.readLine().split(" "))
                        .map(Integer::parseInt)
                        .collect(Collectors.toList());

                num[list.get(0) - 1][list.get(1) - 1][list.get(2) - 1] += list.get(3);
            } catch (IOException e) {
            }
        });

        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 10; k++) {
                    System.out.print(" " + num[i][j][k]);
                }
                System.out.println();
            }
            if (i < 3) {
                System.out.println("####################");
            }
        }
    }
}

Measured memory_bytes: 31800
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
void fileio(){
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
}


int main(){
	//fileio();
	LL n, tot;
	cin>>n>>tot;
	LL w[n], v[n];
	for(LL i=0; i<n; i++) cin>>w[i]>>v[i];

	LL dp[n+1][tot+1];
	
	memset(dp, 0, sizeof(dp));
	for(LL i=0; i<=n; i++){
		for(LL wt=0; wt<=tot; wt++){
			if(i==0 || wt ==0 )dp[i][wt]=0;
			else if(w[i-1]<=wt) dp[i][wt]=max(dp[i-1][wt], (dp[i-1][wt-w[i-1]]+v[i-1]));
			else dp[i][wt]=dp[i-1][wt];
		}
	}

	cout<<dp[n][tot];



	return 0;
}

Measured memory_bytes: 79104
#include<stdio.h>
#include<ctype.h>
struct money{
	int ans,m;
}a[3]=
{{0,10000},{0,5000},{0,1000}};

inline int read(){
	int x=0;bool f=1;char ch=getchar();
	while(!isdigit(ch))
		if(ch=='-')
			f=0;
	while(isdigit(ch)){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return(f)?x:-x;
}

inline void write(int x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+48);
}

int main(){
	int n=read(),x=read();
	if(n*a[0].m<x){printf("-1 -1 -1\n");return 0;}
	if(x%a[0].m==0&&x/a[0].m==n){
		printf("%d 0 0\n",x/a[0].m);return 0;
	}
	if(x%a[1].m==0&&x/a[1].m==n){
		printf("0 %d 0\n",x/a[1].m);return 0;
	}
	if(x%a[2].m==0&&x/a[2].m==n){
		printf("0 0 %d\n",x/a[2].m);return 0;
	}
	for(int i=0;i<=x/10000;++i){
		for(int j=0;j<=x/5000;++j){
				int k=n-i-j;
				if(i*10000+j*5000+k*1000==x&&
				k>=0){
					printf("%d %d %d\n",i,j,k);
					return 0;
				}
		}
	}
	printf("-1 -1 -1\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

int main() {
    int A, B;
    std::cin >> A >> B;

    int coin = 0;

    for (int i = 0; i < 2; i++) {
        if (A > B) {
            coin += A;
            A--;
        } else {
            coin += B;
            B--;
        }
    }
    std::cout << coin << std::endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[4][105];
int l[4],t[4],f1;
int main()
{
	scanf("%s%s%s",s[1]+1,s[2]+1,s[3]+1);
	l[1]=strlen(s[1]+1);
	l[3]=strlen(s[3]+1);
	l[2]=strlen(s[2]+1);
	f1=1;
	while(1)
	{
		t[f1]++;
		if(t[f1]>l[f1])
		{
			printf("%c",'A'+f1-1);
			return 0;
		}
		f1=s[f1][t[f1]]-'a'+1;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
    vector<int> a(3);
    for (int i = 0; i < 3; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int cost = 0;
    for (int i = 1; i < 3; ++i) {
        cost += a[i] - a[i-1];
    }
    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
# define PI           3.14159265358979323846  /* pi */
using namespace std;

int main() {
    long long n;
    cin >> n;
    vector<long long> leaves(n+1);
    vector<long long> non_leaves(n+1);
    vector<long long> ar(n+1);
    vector<long long> max_non_leaves(n+1);
    max_non_leaves[n] = 0;
    for (auto &x: ar)
        cin >> x;
    long long fans = 0;
    if (ar[0] == 0)
    {
        leaves[0] = 0;
        non_leaves[0] = 1;
    }
    else if (ar[0] == 1)
    {
        leaves[0] = 1;
        non_leaves[0] = 0;
    }
    else
    {
        fans = -1;
    }
    if (fans != -1)
    {
        for (long long i = n-1; i>= 0; i--)
        {
            long long ll = ar[i+1];
            long long nl = max_non_leaves[i+1];
            max_non_leaves[i] = nl + ll;
        }

        for (long long i = 1; i<=n; i++)
        {
            long long req_leaves = ar[i];
            long long max_nodes_on_this_lvl = 2 * non_leaves[i-1];
            if (req_leaves > max_nodes_on_this_lvl)
            {
                fans = -1;
                break;
            }
            long long not_leaf = max_nodes_on_this_lvl - req_leaves;
            // if this is the last level then there are zero non leaves
            if (i == n)
                not_leaf = 0;
            if (not_leaf > max_non_leaves[i])
                not_leaf = max_non_leaves[i];

            non_leaves[i] = not_leaf;
            leaves[i] = req_leaves;
        }
        // now we go from bottom and remove extra non-leaves
        if (fans != -1) {
//            for (long long i = n - 1; i >= 0; i--) {
//                long long req_nodes_on_nxt_lvl = leaves[i + 1] + non_leaves[i + 1];
//                if (non_leaves[i] > req_nodes_on_nxt_lvl)
//                    non_leaves[i] = req_nodes_on_nxt_lvl;
//            }
//            fans = 0;
            for (long long i = 0; i <= n; i++)
                fans += leaves[i] + non_leaves[i];
        }
    }
    // exp: 250012613050149995
    cout << fans;
    return 0;
}

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

int S[100];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) S[i] = -1;
	while(m--) {
		int s, c;
		cin >> s >> c;
		s--;
		if(s == 0 && c == 0 && n != 1) return cout << -1, 0;
		if(S[s] != -1 && S[s] != c) return cout << -1, 0;
		S[s] = c;
	}
	if(n == 1 && S[0] == -1) S[0] = 0;
	for (int i = 0; i < n; i++) {
		if(S[i] == -1) {
			if(i) S[i] = 0;
			else S[i] = 1;
		}
		cout << S[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;

struct Edge {
    ll to;
    ll cost;
    Edge(ll t, ll c) {
        to = t;
        cost = c;
    }
};

typedef vector<vector<Edge>> Graph;

Graph G;
vector<int> seen;
vector<ll> d;

void dfs(ll node, ll value) {
    seen[node] = 1;
    d[node] = value;
    for (Edge e: G[node]) {
        if (seen[e.to] == 0) {
            dfs(e.to, value + e.cost);
        }
    }
}

void Main()
{
    ll n;
    cin >> n;

    vector<ll> a(n-1), b(n-1), c(n-1);
    rep(i, n-1) cin >> a[i] >> b[i] >> c[i];
    ll Q, K;
    cin >> Q >> K;
    vector<ll> x(Q), y(Q);
    rep(i, Q) cin >> x[i] >> y[i];

    G.assign(n, vector<Edge>());
    seen.assign(n, 0);
    d.assign(n, 0);
    rep(i, n-1) {
        G[b[i]-1].push_back(Edge{a[i]-1, c[i]});
        G[a[i]-1].push_back(Edge{b[i]-1, c[i]});
    }
    
    dfs(K - 1, 0);

    rep(i, Q) {
        ll res = d[x[i] -1] + d[y[i] - 1];
        put(res);
    }

}
signed main(){ Main();return 0;}

Measured memory_bytes: 18444
fn main() {
  let s = {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().as_bytes().to_owned()
  };

  for i in 0..3 {
    if s.get(i) == s.get(i + 1) {
      print!("Bad");
      return;
    }
  }

  print!("Good");
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main()
{
    long long a, b, c;
    cin >> a >> b >> c;
    long long d = c - a - b;
    if (d > 0 && d * d > 4 * a * b)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    // auto ans = (4 * a * b < (c - (a + b)) * (c - (a + b))) ? "Yes" : "No";
    // cout << ans << endl;
}

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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;
    }

    public static string Solve()
    {
        int N = ReadInt();
        int[] V = ReadInts();
        int[] C = ReadInts();
        int ans = 0;
        for (int i  =0;i<N;i++)
        {
            int tmp = V[i] - C[i];
            if (tmp>0)
            {
                ans += tmp;
            }
        }
        return ans.ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 13140
#include<stdio.h>
#define rep(a,b) for(int i = a;i <= b;i++)//繰り返し処理のマクロ

int main(void){
  int N,M; scanf("%d%d",&N,&M);//N,Mを入力
  int A[110]; rep(1,N){scanf("%d",&A[i]);}//Aの配列を作る
  long int SUM = 0; rep(1,N){SUM += A[i];}//得票数の合計を求める

  //"得票数に4Mを掛けた値がSUM以上になる商品の数"がM以上ならYes
  int cnt = 0; rep(1,N){if(A[i]*4*M >= SUM){cnt += 1;}}//選べる商品の数を求める

  if(cnt >= M){printf("Yes");}
  else{printf("No");}
  
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define pb push_back
    #define sz size()
     
    using namespace std;
    using ll = long long int;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
const int MOD = 1e9 + 7;
const ll ZER = 0;


int main(){
    string s;
    cin >> s;
    if(s.size() == 2)cout << s;
    else {
        reverse(ALL(s));
        cout << s << endl;
    }
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

ll d[500001];
void solve(std::string S){
  d[0]=0;
  for(ll i=1; i<500001; i++) {
    d[i] = d[i-1]+i;
  }
  ll lg = 0;
  ll rg = 0;
  ll ans = 0;
  char c = S[0];
  if(c == '<')
    lg++;
  else
    rg++;
  for(int i=1; i<S.size(); i++) {
    if(c == '<' and S[i]=='<') {
      lg++;
    } else if(c == '<' and S[i]=='>') {
      rg++;
    } else if(c == '>' and S[i]=='>') {
      rg++;
    } else if(c== '>' and S[i]=='<') {
      ans+=d[min(lg, rg)-1]+d[max(lg, rg)];

      lg = 1;
      rg = 0;

    }
    c = S[i];
  }
  ans+=d[min(lg, rg)-1]+d[max(lg, rg)];
  std::cout << ans << std::endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 5252
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;
typedef long long LL;
const int MAXN=100005;
int a[MAXN];
int main()
{
    int n;
    while(~scanf("%d", &n))
    {
        for(int i=1;i<=n;++i)
            scanf("%d", &a[i]);
        int ans=0;
        for(int i=1;i<=n-1;++i)
        {
            if(a[i]==i&&a[i+1]==i+1)
            {
                ans++;
                swap(a[i], a[i+1]);
            }
            else if(a[i]==i)
                ans++;
        }
        if(a[n]==n)
            ans++;
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(){
    char c; int i;
    for (i=1; i<=4; i++){
        cin >> c;
        cout << c;
    }
    cout << " ";

    for (i=1; i<=8; i++){
        cin >> c;
        cout << c;
    }

    cout << "\n";
    return 0;
}


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

using namespace std;
using ll = long long;

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

int main() {
  int n, d;
  cin >> n >> d;
  int ans = (n + 2 * d) / (2 * d + 1);
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const ll MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0) ;

int main()
{
    ll row, col, col1, col2, totCol, ans = 0 ;
    cin >> row >> col ;
    if (row == 1 or col == 1) {
        cout << 1 ;
        return 0 ;
    }
    if (col % 2 != 0) {
        col1 = (col / 2) + 1 ;
        col2 = (col / 2) ;
        totCol = col1 + col2 ;
    }
    else {
        col1 = (col / 2) ;
        col2 = (col / 2) ;
        totCol = col1 + col2 ;
    }
    if (row % 2 == 0) {
        ans = (row / 2) * totCol ;
    }
    else {
        ans = ((row / 2) * totCol) + col1 ;
    }
    cout << ans ;
    return 0 ;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<ctime>
#include<queue>
#include<cmath>
#include<climits>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
    int f=1,x=0;char s=getchar();   
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
#define MAXN 500
#define INF 0x3f3f3f3f
int a[MAXN+5][MAXN+5],tmp[MAXN+5][MAXN+5];
int main(){
	int H=read(),W=read(),cnt=0;
	for(int i=1;i<=H;i++)
		for(int j=1;j<=W;j++)
			tmp[i][j]=a[i][j]=read();
	for(int i=1;i<=H;i++)
		for(int j=1;j<W;j++)
			if(a[i][j]%2)
				cnt++,a[i][j]--,a[i][j+1]++;
	for(int i=1;i<H;i++)
		if(a[i][W]%2)
			cnt++,a[i][W]--,a[i+1][W]++;
	printf("%d\n",cnt);
	for(int i=1;i<=H;i++)
		for(int j=1;j<W;j++)
			if(tmp[i][j]%2)
				printf("%d %d %d %d\n",i,j,i,j+1),tmp[i][j]--,tmp[i][j+1]++;
	for(int i=1;i<H;i++)
		if(tmp[i][W]%2)
			printf("%d %d %d %d\n",i,W,i+1,W),tmp[i][W]--,tmp[i+1][W]++;
	return 0;
}

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    char c;
    cin>>c;
    if(c>='A' && c<='Z') cout<<"A\n";
    else cout<<"a\n";
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 3648
// 問題の URL を書いておく
// 

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <numeric>
using namespace std;

//#define ENABLE_PRINT

template<typename T>
T Input()
{
    T v;
    cin >> v;
    return v;
}

template<typename T>
vector<T> InputVector(int n)
{
    vector<T> v(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    return v;
}

template<typename T>
void InputArray(T* begin, int n)
{
    for(int i = 0; i < n; ++i)
    {
        cin >> begin[i];
    }
}

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

int main(int, const char**)
{
    int x, n;
    cin >> x >> n;
    if(n == 0)
    {
        cout << x << endl;
        return 0;
    }
    vector<bool> sets(102, false);
    rep(i, n)
    {
        int a;
        cin >> a;
        sets[a] = true;
    }
    int a = x;
    while(sets[a++] == true);
    a--;
    int b = x;
    while(sets[b--] == true);
    b++;

    if(a - x == x - b)
    {
        cout << b << endl;
        return 0;
    }
    if(a - x < x - b)
    {
        cout << a << endl;
        return 0;
    }
    cout << b << endl;

    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std; 
int n,m,i,j,a[100000],b[100000],mn,x,y;
int main(void)
{
	cin>>n>>m;
	for(i=0;i<n;i++) cin>>a[i];
	for(i=0;i<n;i++) b[i]=abs(a[i]-m);
	mn=b[0];
	for(i=1;i<n;i++) {
		x=mn;
		y=b[i];
		if(x<y) j=x,x=y,y=j;
		while(1){
			j=x%y;
			x=y;
			y=j;
			if(j==0) break;
		}
		mn=x;
	}
	cout<<mn<<endl;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main(){
    int a, b;
    char op;

    while(1){
        cin >> a >> op >> b;
        switch(op){
        case '+':{ cout << a+b << endl; break;}
        case '-':{ cout << a-b << endl; break;}
        case '*':{ cout << a*b << endl; break;}
        case '/':{ cout << a/b << endl; break;}
        case '?':{ goto OUT;}
        }
    }
OUT:
    return 0;
}

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

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int count = 0;

		while(count < 3000){
			String str = br.readLine();
			String[] s = str.split(" ");

			int a = Integer.parseInt(s[0]);
			int b = Integer.parseInt(s[1]);

			if((0 <= a) && (b <= 10000)){
				if((a == 0)&&(b == 0)){
					break;
				}else if(a > b){
					System.out.println(b +" "+a);
					count++;
					continue;

				}else{
					System.out.println(a +" "+b);
					count++;
					continue;
				}
			}
		}
	}
}

Measured memory_bytes: 26840
#include <bits/stdc++.h>
using namespace std;
int a,b;
void solve()
{
    string str;
    cin>>str;
    int i,len=str.length(),res1=0,res2=0;
    if (a+b+1==len)
    {
        if (str[a]=='-')
        {
            int tag=0;
            for (i=0;i<len;i++)
                if (i!=a)
                {
                    if (str[i]>='0'&&str[i]<='9') ;
                    else {tag=1;break;}
                }
            if (tag) cout<<"No";
            else cout<<"Yes";
        }
        else cout<<"No";
    }
    else cout<<"No";
    cout<<endl;
}
int main()
{
    while(cin>>a>>b)
        solve();
}

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

int main()
{
    int a, b, c, d;

    cin >> a >> b >> c >> d;

    if (abs(c - a) <=d || abs(b - a) <= d && abs(c - b) <= d)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        
        
        int ans =  K * (int)Math.pow(K-1, N-1);
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{

 int i,n,c=0;
 cin>>n;
 vector<int>v(n);
 for(i=0;i<n;i++)cin>>v[i];
 int j=0;
 for(i=1;i<=n;i++)
 {
   if(i%2==1&&v[j]%2==1)c++;
   j++;
 }
 cout<<c;
    return 0;
}



Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

int main() {
    vector<int> arr(3);
    int k;
    scanf("%d %d %d %d", &arr[0], &arr[1], &arr[2], &k);
    sort(all(arr));
    printf("%d\n", arr[0] + arr[1] + arr[2] * (1<<k));
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define all(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x,y)* mod_pow(kai(y,y), mod - 2, mod) % mod;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};
int a[55];
priority_queue<int, vector<int>, greater<int>> que;
signed main() {
	int n, m;
	cin >> n >> m;
	rep(i, n) {
		cin >> a[i];
	}
	int cnt=0, ans=0;
	rep(i, min(n, m) + 1) {
		rep(j, min(n, m) + 1 - i) {
			rep(k, i) {
				cnt += a[k];
				if (a[k] < 0)que.push(a[k]);
			}
			for (int k = n - 1; k >= n - j; --k) {
				cnt += a[k];
				if (a[k] < 0)que.push(a[k]);
			}
			rep(k, m - (i + j)) {
				if (que.size()) {
					cnt -= que.top();
					que.pop();
				}
			}
			while (que.size())que.pop();
			ans = max(ans, cnt);
			cnt = 0;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int a, b, c, d, ans=0;
	cin >> a >> b >> c >> d;
	rep(i,101){
		if((i>a && i<=b) && (i>c && i<=d)){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int64_t> stairs(N + 1);
  stairs.at(0) = 1;
  int64_t MOD = 1000000000 + 7;
  set<int> broken;
  for(int i = 0; i < M; i++) {
    int a;
    cin >> a;
    broken.insert(a);
  }
  for(int i = 1; i <= N; i++) {
    if(i == 1) {
      if(broken.count(1)) {
        stairs.at(1) = 0;
      }
      else {
        stairs.at(1) = 1;
      }
    }
    else {
      if(broken.count(i)) {
        stairs.at(i) = 0;
      }
      else {
        stairs.at(i) = stairs.at(i - 1) + stairs.at(i - 2);
        stairs.at(i) %= MOD;
      }
    }
  }
  cout << stairs.at(N) << endl;  
}

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

int main(){
	int N;
	string S, T, answer = "";
	cin >> N >> S >> T;
	for(int i = 0; i < N; i++){
		string subS = S.substr(i, 1);
		string subT = T.substr(i, 1);
		answer += subS + subT;
	}
	cout << answer << endl;
	return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, a, b);
  out((a - 1) * (b - 1));
}


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

using namespace std;

#define pb push_back

const long long mo = 998244353;
const int maxi = 5000;
int a[maxi];
int s, n;
long long dp[maxi][maxi];
int main()
{

   cin>>n>>s;

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


   long long ans = 0;

    dp[n+1][0] = 1;

   for (int i = n ;i>0;i--){

    for (int j = a[i];j<=s;j++)
        dp[i][j] = dp[i+1][j-a[i]];

       ans+=1ll*i*dp[i][s];
       ans%=mo;

       dp[i][0] = 1;

       for (int j = 0; j<=s; j++)
        dp[i][j] = (dp[i][j] + dp[i+1][j])%mo;
    }

    cout<<ans<<endl;
    return 0;
}
//volim tvoje oci tamne kao greh


Measured memory_bytes: 118528
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Double[] v = new Double[n];
        for(int i = 0; i < n; i++){
            v[i] = sc.nextDouble();
        }
        Arrays.sort(v);
        double ans = v[0];
        for(int i = 1; i < n; i++){
            ans = (ans+v[i])/2;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 22868
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

const MOD: usize = 1000000007;

#[fastout]
fn main() {
   input! {
      n: usize,
      m: usize,
      s: [usize; n],
      t: [usize; m]
   }

   let mut dp = vec![vec![0; m + 1]; n + 1];
   let mut sum = vec![vec![0; m + 1]; n + 1];
   for i in 0..n {
      for j in 0..m {
         sum[i + 1][j + 1] = dp[i][j] + sum[i + 1][j] + sum[i][j + 1] - sum[i][j];
         if s[i] == t[j] {
            dp[i + 1][j + 1] = sum[i + 1][j + 1] + 1;
            dp[i + 1][j + 1] %= MOD;
         }
      }
   }
   let mut ans = 1;
   for i in 0..n {
      for j in 0..m {
         ans += dp[i + 1][j + 1];
         ans %= MOD;
      }
   }
   println!("{}", ans);
}


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

int main(){
    int N; cin >> N;
    int A[N+1];
    int B[N+2];
    int C[N+2];
    for(int i=1;i<=N;i++){
        cin >> A[i];
    }
    B[0]=0;
    C[N+1]=0;
    for(int i=0;i<N;i++){
        B[i+1]=__gcd(B[i],A[i+1]);
    }
    for(int i=N+1;i>=1;i--){
        C[i-1]=__gcd(C[i],A[i-1]);
    }
    int ans=0;
    for(int i=1;i<=N;i++){
        ans=max(ans,__gcd(B[i-1],C[i+1]));
    }
    cout << ans << endl;

}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<a)
	{
		cout<<k<<'\n';
	}
	else if(k<=(a+b))
	{
		cout<<a<<'\n';
	}
	else
	{
		int rem = k - a - b;
		cout<<a-rem<<'\n';
	}
}


Measured memory_bytes: 3652