akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

int main(){

  double A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;

  vector <bool> water(31);
  water[0] = true;

  int MW = max(A, B), mw = min(A, B);
  for (int i = 1; i < 31; i++){
    if (i < mw) {
      water[i] = false;
    }else if (mw <= i && i < MW){
      if (water[i - mw] == true){
        water[i] = true;
      }
    }else{
      if (water[i - mw] == true || water[i - MW] == true){
        water[i] = true;
      }
    }
  }
  
  double sugar[31]; sugar[0] = 0;
  double MS = max(C, D), ms = min(C, D);

  for (int i = 1; i < 31; i++){
    if (water[i] == false || i * 100 > F){
      sugar[i] = 0;
    }else{
      int ans = 0;

      int max_solution = i * E;

      int max_MStimes = max_solution / MS;

      for (int j = 0; j <= max_MStimes; j++){
        int weight = 100 * i + MS * j;

        if (F < weight){
          break;
        }else{     
          int rest = min(F - weight, max_solution - MS * j);
          int m = ms;
          int S = (rest / m) * m + MS * j;
          if (ans < S) ans = S;
        }
      }
      
      sugar[i] = ans;
    }
  }
  
  double rate = 0;
  double aw = 0, as = 0;
  for (int i = 1; i < 31; i++){
    if (water[i] == true){
      double weight = 100 * i + sugar[i];
      if (rate < sugar[i] / weight){
        aw = i * 100;
        as = sugar[i];
        rate = sugar[i]/ weight;
      }
    }
  }
  if (aw == 0 && as == 0){
    aw = 100 * A;
  }
  
  cout << aw + as << " " << as << endl;


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  int n;
  cin >> n;
  ll s;
  bool ans = false;
  rep(i, n) {
    int a;
    cin >> a;
    if(a % 2) ans = true;
  }
  if(ans) cout << "first" << endl;
  else cout << "second" << endl;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

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

	cout << abs(a-b) << endl;

	return 0;
}


Measured memory_bytes: 3084
a,b = map(int, input().split())

aa = ""
bb = ""

for i in range(b):
    aa =  aa + str(a)

for i in range(a):
    bb = bb + str(b)

aaa = int(aa)
bbb = int(bb)

if aaa <= bbb:
    print(bbb)
else:
    print(aaa)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solveA();
		// new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
		//		new Main().solveE();
		//		new Main().solveF();
	}

	private void solveA() {
		Scanner scanner = null;
		int numN = 0;
		int numA = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			numA = scanner.nextInt();

			int res = numN % 500;

			System.out.println(res <= numA ? "Yes" : "No");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveE() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveF() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 21716
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prl puts("\n------------------\n")
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prl 
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

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;
}
const int maxn =2e5 + 6;
ll f[maxn];
int n;

void insert(int i, ll v) {
    for (int x = i; x <= n; x += x & -x) {
        f[x] = max(f[x], v);
    }
}

ll query(int i) {
    ll ans = 0;
    for (int x = i; x; x -= x & -x) {
        ans = max(ans, f[x]);
    }
    return ans;
}

int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    cin >> n;
    ll a[n], h[n], dp[n];
    for (int i = 0; i < n; ++i) cin >> h[i];
    for (int i = 0; i < n; ++i) cin >> a[i];
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ll temp = query(h[i] - 1);
        dp[i] = temp + a[i];
        insert(h[i], dp[i]);
        ans = max(ans, dp[i]);
    }
    cout << ans << endl;
    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  map<string,int>mp;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    mp[s]++;
  }
  long long ans=0;
  for(auto& p:mp){
    int u=p.second;
    ans+=(long long)u*(u-1)/2;
  }
  cout<<ans<<endl;
}
    
 


Measured memory_bytes: 11136
n = int(input())
h = list(map(int, input().split()))

if n == 1:
    print('Yes')
    exit()

for i in range(n-1, 0, -1):
    if h[i-1] - h[i] > 1:
        print('No')
        exit()
    elif h[i-1] - h[i] == 1:
        h[i-1] -= 1
    else:
        pass

print('Yes')

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

int main(){
    int64_t x,ans;
    cin>>x;
    ans=x/11*2;
    if(x%11>6)ans+=2;
    else if(x%11)ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <fstream>

using namespace std;

void solve(int a, int b, int d, int &x, int &y)
{
	for(int i = 1; ; i++) {
		for(y = 0; y <= i; y++) {
			x = i - y;
			if(a * x + b * y == d) return;
			if(a * x == b * y + d) return;
			if(b * y == a * x + d) return;
		}
	}
}

int main(void)
{
	int a, b, d;
	while(cin >> a >> b >> d) {
		if(a == 0 && b == 0 && d == 0) break;

		int x, y;

		if(a < b) {
			solve(a, b, d, x, y);
		}
		else {
			solve(b, a, d, y, x);
		}

		cout << x << " " << y << endl;
	}

	return 0;
}



Measured memory_bytes: 3032
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define bg begin
#define en end 
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll gcd(ll a,ll b){
    if(a==0)
    return b;
    else
    return gcd(b%a,a);
}
using namespace std;
int main()
{
    ll n;
    cin>>n;
    if(n>=400 && n<=599)
    cout<<"8";
    else if(n>=600 && n<=799)
    cout<<"7";
    else if(n>=800 && n<=999)
    cout<<"6";
    else if(n>=1000 && n<=1199)
    cout<<"5";
    else if(n>=1200 && n<=1399)
    cout<<"4";
    else if(n>=1400 && n<=1599)
    cout<<"3";
    else if(n>=1600 && n<=1799)
    cout<<"2";
    else if(n>=1800 && n<=1999)
    cout<<"1";
}

Measured memory_bytes: 3632
def gs() STDIN.gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end


n,m,q = gsmi #500,2*10^5,10^5
lrs = Array.new(m){gsmi}
pqs = Array.new(q){gsmi}

sumss = Array.new(n+1){ Array.new(n+1){0} }
lrs.each { |l,r| sumss[l][r] += 1  }
(1..n).each do |i|
  (1..n).each do |j|
    sumss[i][j] += sumss[i-1][j]
    sumss[i][j] += sumss[i][j-1]
    sumss[i][j] -= sumss[i-1][j-1]
  end
end

pqs.each do |p,q|
  puts sumss[q][q] - sumss[p-1][q] - sumss[q][p-1] + sumss[p-1][p-1]
end


Measured memory_bytes: 36168
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1000000007;
const int MOD = 1000000007;
template <int MOD>
struct Fp {
  long long val;
  constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
    if (val < 0) v += MOD;
  }
  constexpr int getmod() { return MOD; }
  constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; }
  constexpr Fp operator+(const Fp& r) const noexcept { return Fp(*this) += r; }
  constexpr Fp operator-(const Fp& r) const noexcept { return Fp(*this) -= r; }
  constexpr Fp operator*(const Fp& r) const noexcept { return Fp(*this) *= r; }
  constexpr Fp operator/(const Fp& r) const noexcept { return Fp(*this) /= r; }
  constexpr Fp& operator+=(const Fp& r) noexcept {
    val += r.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }
  constexpr Fp& operator-=(const Fp& r) noexcept {
    val -= r.val;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr Fp& operator*=(const Fp& r) noexcept {
    val = val * r.val % MOD;
    return *this;
  }
  constexpr Fp& operator/=(const Fp& r) noexcept {
    long long a = r.val, 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);
    }
    val = val * u % MOD;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr bool operator==(const Fp& r) const noexcept {
    return this->val == r.val;
  }
  constexpr bool operator!=(const Fp& r) const noexcept {
    return this->val != r.val;
  }
  friend constexpr ostream& operator<<(ostream& os, const Fp<MOD>& x) noexcept {
    return os << x.val;
  }
  friend constexpr istream& operator>>(istream& is, Fp<MOD>& x) noexcept {
    return is >> x.val;
  }
  friend constexpr Fp<MOD> modpow(const Fp<MOD>& a, long long n) noexcept {
    if (n == 0) return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1) t = t * a;
    return t;
  }
};
using mint = Fp<MOD>;

int main() {
  string l;
  cin >> l;
  mint res = 0;
  ll num = 0;
  for (int i = 0; i < (int)l.length(); i++) {
    int len = (int)l.length() - i - 1;
    if (l[i] == '1') {
      res += modpow(mint(2), num) * modpow(mint(3), len);
      num++;
    }
  }
  res += modpow(mint(2), num);
  cout << res << endl;
}


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

long long n, a, b, cnt = 0, now = -1;
double ave = 0;
vector<long long> v;

long long calccomb(long long x, long long y) {
  long long ans = 1;
  for(long long i = 1; i <= y; ++i) {
    ans *= x - i + 1;
    ans /= i;
  }
  return ans;
}
long long solve();

int main() {
  cout << fixed << setprecision(10);
  cin >> n >> a >> b;
  for(int i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end(), greater<long long>());
  for(int i = 0; i < a; ++i) {
    ave += v[i];
    ++cnt;
    if(now != v[i]) {
      now = v[i];
      cnt = 1;
    }
  }
  ave /= a;
  cout << ave << endl;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0, allcnt = cnt;
  for(long long i = a; i < n; ++i)
    if(now == v[i]) ++allcnt;
  ans += calccomb(allcnt, cnt);
  if(v[0] == now)
    for(long long i = 1; i <= b - a && cnt + i <= allcnt;
        ++i)
      ans += calccomb(allcnt, cnt + i);
  return ans;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int sum,n,c,i;
	while(1){
		sum=1150;
		scanf("%d",&n);
		if(n<0)break;
		c=n-10;
		if(n>10){
			for(i=0;i<10;i++){
				if(c==0)break;
				sum+=125;
				c-=1;
			}
		}
		if(n>20){
			for(i=0;i<10;i++){
				if(c==0)break;
				sum+=140;
				c-=1;
			}
		}
		if(n>30){
			while(1){
				if(c==0)break;
				sum+=160;
				c-=1;
			}
		}
		printf("%d\n",4280-sum);
	}
	return 0;
}

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

int main()
{
	int n;
	cin >> n;
	map<string, int> M;
	string s;
	int ma = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> s;
		++M[s];
		ma = max(ma, M[s]);
	}
	for (auto o : M)
	{
		if (o.second == ma)
		{
			cout << o.first << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 25216
import Control.Monad
import Data.List

solveSubSub [] xs = 1
solveSubSub (as:ass) xs
    | xs!!x' == y' = solveSubSub ass xs
    | otherwise = 0
        where
            x' = (as!!0) - 1
            y' = as!!1

solveSub [] xs = []
solveSub (ass:asss) xs
    | fst ass == 1 = (solveSubSub (snd ass) xs) : (solveSub asss xs)
    | otherwise = 0 : solveSub asss xs

solve [] [] = []
solve (asss:assss) (xs:xss)
    | ys == xs = (sum xs) : (solve assss xss)
    | otherwise = 0 : (solve assss xss)
    where
        ys = solveSub asss xs

main = do
    n <- readLn :: IO Int
    asss <- replicateM n $ do
        a <- readLn :: IO Int
        as <- replicateM a (map read . words <$> getLine) :: IO [[Int]]
        return $ as 
    let xss = replicateM n [0,1]
    print $ maximum $ solve (map (\x -> zip x asss) xss) xss


Measured memory_bytes: 8368
import java.util.*;
 
public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int[][] x = new int[2][2];
        for(int i = 0; i < 2; i++){
            x[i][0] = sc.nextInt();
            x[i][1] = sc.nextInt();
        }
        sc.close();

        int[] to2 = new int[2];
        to2[0] = x[1][0] - x[0][0];
        to2[1] = x[1][1] - x[0][1];
        int[] x3 = new int[2];
        int[] x4 = new int[2];
        x3[0] = x[1][0] - to2[1];
        x3[1] = x[1][1] + to2[0];
        x4[0] = x[0][0] - to2[1];
        x4[1] = x[0][1] + to2[0];

        System.out.println(x3[0] + " " +
                            x3[1] + " " +
                            x4[0] + " " + 
                            x4[1]);
    }
}

Measured memory_bytes: 21844
n, m = map(int, input().split())
ll = [0 for i in range(n+1)]
l_max = 0
r_min = 1000000
for _ in range(m):
    l, r = map(int, input().split())
    if l > l_max :
        l_max = l
    if r < r_min:
        r_min = r
if l_max <= r_min:
    print(r_min - l_max + 1)
else:
    print(0)


Measured memory_bytes: 3928
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
  int n;cin>>n;
  string a[n];
  for(int i = 0; n > i; i++){
    cin>>a[i];
  }
  int ans = 0;
  for(int i = 0; n > i; i++){
    if(a[i] == "E869120")ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3332
using System;
using System.IO;

namespace ConsoleApp8
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());

			int[,] d = new int[n, 3];
			int cnt = 0;

			for (int i = 0; i <= n - 1; i++)
            {
				string[] dice = Console.ReadLine().Split(' ');
				d[i, 0] = int.Parse(dice[0]);
				d[i, 1] = int.Parse(dice[1]);
				if (d[i, 0] == d[i, 1])
				{
					cnt++;
					if (cnt >= 3)
					{
						Console.WriteLine("Yes");
						break;
					}
				}
				else
				{
					cnt = 0;
				}
			}
			if (cnt < 3)
			{
				Console.WriteLine("No");
			}
		}
	}
}


Measured memory_bytes: 27540
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s; cin>>s;
	int n=s.size();
	deque<char>dq(s.begin(),s.end());
	bool rev=false;
	int q; cin>>q;
	while(q--){
		int t; cin>>t;
		if(t==1) {
			rev^=1;
			continue;
		}
		int c; 
		char ch; cin>>c>>ch;
		c--;
		if(rev != c) 
			dq.push_back(ch);
		else
			dq.push_front(ch);
	}
	string ret;
	if(rev) 
		ret=string(dq.rbegin(),dq.rend());
	else 
		ret=string(dq.begin(),dq.end());
	cout<<ret<<endl;
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
#include<queue>
using namespace std;

int main(void)
{
	int X, Y, Z, K;
	cin >> X >> Y >> Z >> K;

	vector<long long> A(X), B(Y), C(Z);
	for (int i = 0; i < X; i++)
		cin >> A[i];
	for (int i = 0; i < Y; i++)
		cin >> B[i];
	for (int i = 0; i < Z; i++)
		cin >> C[i];

	sort(A.rbegin(), A.rend());
	sort(B.rbegin(), B.rend());
	sort(C.rbegin(), C.rend());

	priority_queue<long long> ab;
	for (int i = 0; i < (int)A.size(); i++) {
		for (int j = 0; j < (int)B.size(); j++) {
			ab.push(A[i] + B[j]);
		}
	}

	priority_queue<long long> abc;
	for (int i = 0; i < K && ab.empty() != true; i++) {
		auto n = ab.top();
		ab.pop();

		for (int j = 0; j < (int)C.size(); j++) {
			abc.push(n + C[j]);
		}
	}

	for (int i = 0; i < K; i++) {
		cout << abc.top() << endl;
		abc.pop();
	}

	return 0;
}


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

using namespace std;

using int64 = long long;

double f(int n)
{
  if(n <= 1) return (n);
  return (1 + (n + 1.0) / n * f(n - 1));
}

int main()
{
  int N, D, X;
  cin >> N >> D >> X;
  cout << fixed << setprecision(10) << (D + (2 * N - 1) * 0.5 * X) * f(N) << endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;int p=0,m=0;
  cin>>s;
  for(int i=0;s[i]!='\0';i++)
  {
  	if(s[i]=='+')
      p++;
    else
      m++;
  }
  cout<<p-m;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <map>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline bool Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+" ";
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
constexpr const ll INF = 1e15;
constexpr const ll MOD = 1000000007;
constexpr int nx[4] = {1,0,-1,0};
constexpr int ny[4] = {0,1,0,-1};
typedef pair<ll,ll> P;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a),q(b),r(c);
    cins(all(p));
    cins(all(q));
    cins(all(r));
    RSORT(p);
    RSORT(q);
    RSORT(r);
    priority_queue<ll,vector<ll>,greater<ll>> l,m;
    priority_queue<ll> n;
    ll cnt = 0;
    rep(i,x){
        l.push(p[i]);
        cnt += p[i];
    }
    rep(i,y){
        m.push(q[i]);
        cnt += q[i];
    }
    rep(i,c) n.push(r[i]);
    while(!(l.empty()) && !(m.empty()) && !(n.empty())){
        ll p1 = l.top(),q1 = m.top(),r1 = n.top();
        if (p1 >= r1 && q1 >= r1) break;
        if (r1-p1 >= r1-q1){
            cnt += r1-p1;
            n.pop();
            l.pop();
        }
        else{
            cnt += r1-q1;
            n.pop();
            m.pop();
        }
    }
    while (!(l.empty()) && !(n.empty())){
        ll p1 = l.top();
        ll r1 = n.top();
        if (p1 >= r1) break;
        cnt += r1-p1;
        n.pop();
        l.pop();
    }
    while (!(m.empty()) && !(n.empty())){
        ll q1 = m.top();
        ll r1 = n.top();
        if (q1 >= r1) break;
        cnt += r1-q1;
        n.pop();
        m.pop();
    }
    PRINT(cnt);
}


Measured memory_bytes: 5620
H, W, D = map(int, input().split())
M = H * W
A = [list(map(int, input().split())) for i in range(H)]

a_to_ij = {}
for i, aa in enumerate(A):
  for j, a in enumerate(aa):
    a_to_ij[a] = (i, j)

cost = {}
def calc_cost(s):
  global cost
  t = s
  pre_i, pre_j = a_to_ij[s]
  c = cost[(s, s)] = 0
  while t + D <= M:
    t += D
    i, j = a_to_ij[t]
    c += abs(i-pre_i) + abs(j-pre_j)
    cost[(s, t)] = c
    pre_i, pre_j = i, j

for n in range(1, D+1):
  calc_cost(n)

ans = []
Q = int(input())
for i in range(Q):
  L, R = map(int, input().split())
  s = L % D
  if s == 0:
    s = D
  ans.append(cost[(s, R)] - cost[(s, L)])

print(*ans, sep='\n')

Measured memory_bytes: 44568
#include<stdio.h>
int main()
{
    long long a,b;
    if(scanf("%lld%lld",&a,&b)==2)
    {
        if(a == 0)
        {
            if(b == 100)
                printf("101\n");
            else
                printf("%lld\n",b);
        }
        else
        {
            if(a == 1)
            {
                if(b == 100)
                    printf("10100\n");
                else
                    printf("%lld\n",100*b);
            }
            else if(a == 2)
            {
                if(b == 100)
                    printf("1010000\n");
                else
                    printf("%lld\n",b*10000);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 128
def slove():
    import sys
    input = sys.stdin.readline
    c = [list(str(input().rstrip('\n'))) for _ in range(3)]
    s = []
    for i in range(3):
        s.append(c[i][i])
    print("".join(s))


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
using Int = long long unsigned;
typedef priority_queue<int> Pr;

vector<int> a[100001];

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

    int n,m; Int ans=0; cin>>n>>m;
    for (int i = 0; i < n; i++){
        int p,q; cin>>p>>q; a[p].push_back(q);
    }
    Pr q;
    for (int i = 1; i <= m; i++){
        for(auto t:a[i])q.push(t);
        if(!q.empty()){
            ans+=q.top(); q.pop();
        }
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	
	vector<ll> a(n);
	for(auto& e:a) cin >> e;
	vector<ll> p(n);
	p[0] = a[0];
	for (int i=1; i<n; i++) {
		p[i] = a[i] + p[i-1];
	}
	
	ll ans = 0;
	for (int i=1; i<n; i++) {
		ans += (a[i]%MOD)*(p[i-1]%MOD);
		ans %= MOD;
	}
	
	cout << ans << '\n';
	return 0;
}




Measured memory_bytes: 6296
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
arr = [1]
arr.extend([pow(9, i) for i in range(1, 7)])
arr.extend([pow(6, i) for i in range(1, 8)])
arr.sort(reverse=True)
dp = [inf for _ in range(n + 1)]
dp[0] = 0
for i in range(1, n + 1):
    for j in arr:
        if i - j >= 0:
            dp[i] = min(dp[i], dp[i - j] + 1)
print(dp[n])

Measured memory_bytes: 66028
#include <stdio.h>
int main(){
  int n, k;
  scanf("%d%d\n", &n, &k);
  int i;
  int l = 0;
  int r = 0;
  char first_c;
  char pre_c = 'a';
  int ans = 0;
  for(i=0;i<n;i++){
    char c = getchar();
    if (i == 0) {
      first_c = c;
    }
    if (c == 'L') {
      l++;
      if (pre_c == 'L') {
        ans++;
      } else {
        if (first_c == 'L' && k > 0 && i > 0) {
          k--;
          l += r;
          r = 0;
          ans += 2;
        }
      }
    } else if (c == 'R') {
      r++;
      if (pre_c == 'R') {
        r++;
        ans++;
      } else {
        if (first_c == 'R' && k > 0 && i > 0) {
          k--;
          r += l;
          l = 0;
          ans += 2;
        }
      }
    }
    pre_c = c;
  }
  if (k > 0) {
    ans = n - 1;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(ll i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(ll j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


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

    int N, M, C;
    cin >> N >> M >> C;

    vector<int> B(M, 0);
    REPinit(i, 0, M) cin >> B[i];

    int A, score = 0;
    int ans = 0;
    REPinit(i, 0, N) {
        score = 0;
        REPinit(j, 0, M) {
            cin >> A;
            score += (A * B[j]);
        }

        if ((score + C) > 0) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3616
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ll N;
int ans = 0;

int DFS(ll now, int i, int j, int k){
  if (now > N) return 0;
  if (i > 0 && j > 0 && k > 0) ans++;

  DFS(10 * now + 3, i + 1, j, k);
  DFS(10 * now + 5, i, j + 1, k);
  DFS(10 * now + 7, i, j, k + 1);
  return 0;
}

int main(){
  cin >> N;
  DFS(0, 0, 0, 0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)


[N,X] = [int(x) for x in input().split()]
xs = [int(x) for x in input().split()]

xs.append(X)
xs = sorted(xs)

d = [y-x for x,y in zip(xs[:-1], xs[1:])]

ans = d[0]
for i in range(1, len(d)):
    ans = gcd(ans, d[i])
print(ans)


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

int main(){
 int A,B;
  cin >> A >> B;
  if(A == 1 && B == 2){
  cout << "3";
  }
  else if(A == 2 && B == 1){
    cout << "3";
  }
    else if(A == 3 && B == 1){
    cout <<"2";
  }
    else if(A == 1 && B == 3){
    cout << "2";
  }
    else if(A == 3 && B == 2){
    cout << "1";
  }
    else if(A == 2 && B == 3){
    cout <<"1";
  }
}

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

int main() {
  
  int N,M;
  cin >> N >> M;
  vector <int> A(N,0);
  int sum = 0;
  float sum_4 = 0;
  
  for(int i=0;i<N;i++){
    cin >> A[i];
    sum = sum + A[i];
//    cout << A[i] <<endl;
  }
//  cout << A[M-1] << endl;
  sort(A.begin(), A.end()); 
//  cout << A[M-1] << endl;
  reverse(A.begin(), A.end());
//  cout << A[M-1] << endl;
  sum_4 = sum/4.0/M;
//  cout << "sum : " << sum << endl;
//  cout << sum_4 << " : " << A[M-1];
  if(sum_4 > A[M-1]){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
//  cout <<   << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int A = in.nextInt();
        int B = in.nextInt();
        int C = in.nextInt();
        int K = in.nextInt();
        int result = 0;
        while(K > 0 && A > 0) {
            result++;
            A--;
            K--;
        }
        while(K > 0 && B > 0) {
            B--;
            K--;
        }
        while(K > 0 && C > 0) {
            C--;
            K--;
            result--;
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 35756
"use strict";
function main(input) {
  input = input.split(" ");
  const ia = +input[0], ib = +input[1];
  for (let i = ib * 10; i < 10000; i++) {
    if (~~(i * 0.08) === ia && ~~(i * 0.1) === ib) {
      return console.log(i);
    }
  }
  console.log(-1);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int x; cin >> x;
    if(x == 0)cout << 1<<'\n';
    else cout << 0 << '\n';

}


Measured memory_bytes: 3608
package main

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

func main() {
	var s string
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	s = scanner.Text()
	sr := ""
	for _, x := range s {
		xs := string(x)
		// fmt.Println(xs)
		u := strings.ToUpper(xs)
		l := strings.ToLower(xs)
		if u == xs {
			sr += l
		} else if l == xs {
			sr += u
		} else {
			sr += xs
		}
	}
	fmt.Println(sr)
}


Measured memory_bytes: 1804
//プロコンの問題をキューの標準ライブラリを使って解く
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;

int main(){
    int n, q, t;
    string name;

    //標準ライブラリからqueueを使用
    queue<pair<string, int> > Q; //プロセスのキュー
    //キューは先入れ先出しのデータ構造

    cin >> n >> q; //プロセスの数、クオンタムの値

    //全てのプロセスをキューに順番に追加する
    for(int i = 0; i < n; i++){
        cin >> name >> t;
        Q.push(make_pair(name, t));
    }

    pair<string, int> u;
    int elaps = 0, a;

    //シミュレーション
    while(!Q.empty() ){
      u = Q.front(); Q.pop();
      a = min(u.second, q); //q(クオンタム)またはu.tだけ処理を行う
      u.second -= a; //残りの必要時間を計算
      elaps += a; //経過時間を加算
      if(u.second > 0){
        Q.push(u); //処理が完了していなければキューに追加
      }else{
        cout << u.first << " " << elaps << endl;
      }
    }

    return 0;
}


Measured memory_bytes: 6336
#include <stdio.h>

int main(){

    int a[100][100]={0};
    int b[100]={0},c[100]={0};
    int n,m,i,j;
    
    scanf("%d %d",&n,&m);
    
    for (i=0; i<n; i++)
    {
        for (j=0; j<m; j++)
        {
            scanf("%d",&a[i][j]);
        }
    }
    for (i=0; i<m; i++)
    {
        scanf("%d",&b[i]);
    }
    
    for (i=0; i<n; i++)
    {
        for (j=0; j<m; j++)
        {
            c[i]=c[i]+a[i][j]*b[j];
        }
    }
    
    for (i=0; i<n; i++)
    {
        printf("%d\n",c[i]);
    }
    return 0;
}

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

int main()
{
    int i,c=0,l;
    string s;

    cin>>s;

    l=s.size();

    for(i=0;i<(l/2);i++){
        if(s[i]!=s[l-i-1]){
            c++;
        }
    }
    cout<<c<<endl;

    return 0;
}


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

#define maxn 100005
#define ll long long

int n, m;
char s[maxn];
int dp[maxn], f[maxn];

typedef pair<int, int> P;
P smt[maxn * 4];
vector<int> ans;

void update(int idx, int l, int r, int k, int x)
{
    if (l > k || r < k)
        return;
    if (l == r)
    {
        smt[idx] = P(x, l);
        return;
    }
    int mid = (l + r) / 2;
    update(idx << 1, l, mid, k, x);
    update(idx << 1 | 1, mid + 1, r, k, x);
    smt[idx] = min(smt[idx << 1], smt[idx << 1 | 1]);
}

P query(int idx, int l, int r, int a, int b)
{
    if (r < a || l > b)
        return P(INT_MAX, 0);
    if (l >= a && r <= b)
        return smt[idx];
    int mid = (l + r) / 2;
    return min(query(idx << 1, l, mid, a, b), query(idx << 1 | 1, mid + 1, r, a, b));
}

int main()
{
    cin >> n >> m;
    scanf("%s", s);
    for (int i = 1; i <= n; i++)
    {
        if (s[i] == '1')
        {
            update(1, 0, n, i, INT_MAX);
            dp[i] = INT_MAX;
            continue;
        }
        int l = max(0, i - m);
        int r = i - 1;
        P p = query(1, 0, n, l, r);
        if (p.first == INT_MAX)
        {
            update(1, 0, n, i, INT_MAX);
            dp[i] = INT_MAX;
            continue;
        }
        dp[i] = p.first + 1;
        f[i] = p.second;
        update(1, 0, n, i, dp[i]);
    }
    if (dp[n] == INT_MAX)
    {
        cout << -1 << endl;
        return 0;
    }
    for (int i = n; i != 0; i = f[i])
        ans.push_back(i - f[i]);
    for (int i = ans.size() - 1; i >= 0; i--)
        printf("%d ", ans[i]);
    return 0;
}

Measured memory_bytes: 3836
s = list(str(input()))

f = ''
for i in s:
  if f == '':  
    if i == 'A':
      f = s.index(i)
  else:
    break  

for i in range(len(s)):
  if s[i] == 'Z':
    e = i

print(e - int(f) + 1)

Measured memory_bytes: 10456
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/

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


#define ll                          long long
#define ld                          long double

#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend();
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second

#define vpi                         <vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()

#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define MN                           INT_MIN
#define MX                           INT_MAX

bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}
int lcm(int a, int b){return(a*b)/gcd(a, b);}  


int32_t main()
{
	int a,b,c;
	cin >> a >> b >> c;
	cout << (a+b+c >= 22 ? "bust\n" : "win\n");
}

Measured memory_bytes: 3668
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
// #include "debug.h"
#define debug(...) 42

void solve() {
   int n, k, x;
   cin >> n >> k;
   set <array <int, 2> > s;
   for(int i = 0; i < n; i++) {
      cin >> x;
      s.insert({x, i});
   }

   while(k--) {
      auto t = *s.rbegin();
      s.erase(t);
      s.insert({t[0] / 2, t[1]});
   }

   ll ans = 0;
   for(auto t: s) {
      ans += t[0];
   }
   cout << ans << endl;
} 

int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   int testcase = 1;
   // cin >> testcase;

   for(int i = 0; i < testcase; i++) {
      solve();
   }
   return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  char x,y; cin >> x >> y;
  if(x<y) cout << "<" << endl;
  else if(x>y) cout << ">" << endl;
  else cout << "=" << endl;
  
  return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
 
int main (void){
  int num1,i,j;
  scanf("%d",&num1);
  int order[num1];
  int deorder[num1];
  for(i=0;i<num1;i++){
    scanf("%d",&order[i]);
    deorder[order[i]-1]=i+1;
  }
  for(j=0;j<num1;j++){
    printf("%d\n",deorder[j]);
  }
     return 0;
}

Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int a[100100];

int main(void){
	int n,v,i,l,r;
	fill(a,a+100100,0);
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> v;
		++a[v];
	}
	for(i=0; i<n; ++i){
		if(a[i]+a[i+1]!=n){
			continue;
		}
		l = a[i]+((a[i+1])?1:0);
		r = a[i]+a[i+1]/2;
		if(l<=i+1 && i+1<=r){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 640
x, y = map(int, input().split())

X = [1,3,5,7,8,10,12]
Y = [4,6,9,11]
Z = [2]

ax = 0
ay = 0

if x in X:
  ax = 1
elif x in Y:
  ax = 2
else:
  ax = 3
if y in X:
  ay = 1
elif y in Y:
  ay = 2
else:
  ay = 3
  
print('Yes') if ax == ay else print('No')

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

int N,Q;
string s;
vector<char> t,d;

int check(int p) {
    if (p<0) return -1;
    if (p>=N) return 1;
    for (int i=0;i<Q;i++) {
        if (t[i]==s[p]) {
            if (d[i]=='L') {
                p--;
                if (p<0) return -1;
            } else if (d[i]=='R') {
                p++;
                if (p>=N) return 1;
            }
        } 
    }
    return 0;
}

int main() {
    cin >> N >> Q >> s;
    t.resize(Q);
    d.resize(Q);
    for ( int i = 0; i < Q; i++ ) {
        cin >> t[i] >> d[i];
    }
    int l1 = -1, l2 = N, r1 = -1, r2 = N;
    while (l2-l1>1) {
        int p = (l1+l2)/2;
        int c = check(p);
        if (c<0) l1 = p;
        else l2 = p;
    }
    while (r2-r1>1) {
        int p = (r1+r2)/2;
        int c = check(p);
        if (c>0) r2 = p;
        else r1 = p;
    }
    int ans = r1>=l2 ? r1 - l2 + 1 : 0;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
int  main(){
int n;string s,t;
cin>>n>>s>>t;
for(int i=n;i>=0;i--){
if(s.substr(n-i,i)==t.substr(0,i)){cout<<n*2-i<<endl;break;}
}}







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

public class Main
{
	public static void main(String[] arg) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		for(int i=0; i<n; i++)
		{
		    StringBuffer s1 = new StringBuffer(br.readLine());
		    StringBuffer s2 = new StringBuffer(br.readLine());
  
		    if(s1.length() > 80 || s2.length() > 80)
			System.out.println("overflow");
		    else if ((s1.length() < 10) && (s2.length() < 10)) {
			System.out.println(Integer.parseInt(s1.toString()) + 
					   Integer.parseInt(s2.toString()));
		    } else {	
			StringBuffer s3 = cal(s1,s2);
			char[] budget = s3.toString().toCharArray();
			int m = budget.length;
			if( m > 80 ) System.out.println("overflow");
			else {
			    for(int j=0; j<m; j++)
			    System.out.print(Integer.parseInt(budget[j]+""));
			    System.out.println();
			}
		    }
		 }
	}

	private static StringBuffer cal(StringBuffer a, StringBuffer b)
	{
		a.reverse();
		b.reverse();
		int lenA = a.length(), lenB = b.length(), max = Math.max(lenA,lenB);
		int roundup=0; //determine whether round up is needed
		StringBuffer c = new StringBuffer();
		Integer temp=0;
		for(int i=0; i<max; i++)
		{
		    if( i < lenA && i < lenB) {
		        temp = Integer.parseInt(a.substring(i,i+1).toString()) + 
			       Integer.parseInt(b.substring(i,i+1).toString()) + 
			       roundup;
		    } else if( i < lenA && i >= lenB) {
			temp = Integer.parseInt(a.substring(i,i+1).toString()) + roundup;
		    } else {
			temp = Integer.parseInt(b.substring(i,i+1).toString()) + roundup;
		    }
		
		    if(temp>9) {roundup = 1; temp-=10;}
		    else       roundup = 0;
		    c.append(temp);
		    if(i==max-1 && roundup == 1)
			c.append(1);
		}
		return c.reverse();
	}
}

Measured memory_bytes: 9656
N,K = map(int,input().split())
Data = []
for _ in range(N):
    Data.append(list(map(int,input().split())))
Data.sort(key=lambda x:x[0])
num = 0
for i in range(N):
    a,b = Data[i]
    num += b
    if num >= K:
        ans = a
        break
print(ans)


Measured memory_bytes: 29144
L, R= (int(i) for i in input().split())  
 
_min = 2018
 
for g in range(R-L):
	_start = (L+g)*(L+g+1)
	for i in range(R-L-g):
		_min = min(_min, _start%2019)
		_start += L+g
		if _min == 0:
			break
	if g == 2019 or _min == 0:
		break

print(_min)

Measured memory_bytes: 3060
N,M = map(int,input().split())

m = 1
ds = set()
while m*m <= M:
    if M%m==0:
        ds.add(m)
        ds.add(M//m)
    m += 1

ans = 1
for d in ds:
    if d*N > M: continue
    ans = max(ans,d)
print(ans)

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
vector<set<int>> matrix(200006);
vector<bool> visited(200006);
vector<set<int>> answer;
set<int> st;
void dfs(int v) {
    visited[v] = true;
    st.insert(v);
    // for(int i = 1; i <= matrix[v].size(); i++) {
    for(auto it = matrix[v].begin(); it != matrix[v].end(); it++) {
        if(visited[*it] == false) {
            st.insert(*it);
            dfs(*it);
        }
    }
}
int main(){
    int n, m; cin >> n >> m;
    matrix = vector<set<int>> (n + 1);
    visited = vector<bool> (n + 1);
    map<int, bool> check;
    for(int i = 0; i < m; i++) {
        int x, y; cin >> x >> y;
        matrix[x].insert(y);
        matrix[y].insert(x);
        check[x] = true;
        check[y] = true;
    }
    int ans = 1;
    for(int i = 1; i <= n; i++) {
        if(visited[i] == false && check[i]) {
            dfs(i);
            ans = max(ans, (int)st.size());
            st.clear();
        }
    }
    cout << ans;
    // cout << answer.size() << endl;
    // for(int i = 0; i < answer.size(); i++) {
    //     cout << answer[i].size() << " ";
    //     for(auto it = answer[i].begin(); it != answer[i].end(); it++) {
    //         cout << *it << " ";
    //     }
    //     cout << endl;
    // }
    return 0;
}

Measured memory_bytes: 62624
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

template <typename T> using vec = std::vector<T>;
using vi = vec<int>;
using ll = long long;
using ld = long double;
// constexpr auto mod = 1000000007;
using namespace std;

int main() {
  string s{}, t{};
  cin >> s;
  for (auto &&si : s) {
    if (si != 'B') {
      t.push_back(si);
    } else if (!t.empty()) {
      t.pop_back();
    }
  }
  cout << t << endl;
  return 0;
}


Measured memory_bytes: 256
/// Zhupengfei 2018
/// Hereby declare: this program is in public domain.

/// Solution for problem: SoundHound A

#include <bits/stdc++.h>

#ifdef LOCAL
#pragma GCC poison printf // To avoid fastio problems
#pragma GCC poison scanf
#endif

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int a, b;
	cin>>a>>b;
	if(a+b==15) cout<<"+"<<endl;
	else if(a*b==15) cout<<"*"<<endl;
	else cout<<"x"<<endl;

	return 0;
}



Measured memory_bytes: 896
n = int(input())
p = list(map(int, input().split(' ')))
q = list(map(int, input().split(' ')))


def fac(n):
    res = 1
    for i in range(2, n+1):
        res *= i
    return res


ans = 0
for _ in range(2):
    res = 0
    use = [1] * (n + 1)
    for i in range(n):
        k = sum(use[1:p[i]])
        res += k * fac(n-i-1)
        use[p[i]] = 0
    p = q
    ans = abs(ans - res)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
int main(){
	while(1){
	int n; cin >> n ;if(n==0) break;
	char* ch=new char[2*n];
	for(int i=0;i<n;i++) cin >> ch[2*i] >> ch[2*i+1] ;
	char temp;
	int m; cin >> m ;
	char* ans=new char[m];
	for(int i=0;i<m;i++){
		cin >> temp ;ans[i]=temp;
		for(int j=0;j<n;j++){
			int flag=0;
			if(temp==ch[2*j]) do{ans[i]=ch[2*j+1];flag=1;}while(0);
			if(flag==1) break;
		};
	};
	for(int i=0;i<m;i++) cout << ans[i] ;
	cout << '\n' ;
	};
}

Measured memory_bytes: 1256
import sys

def solve():
	input=sys.stdin.readline
	n, m, l = map(int, input().split())
	edge = [[] for _ in range(n)]
	for _ in range(m):
		a, b, c = map(int, input().split())
		if c <= l:
			edge[a-1].append((c, b-1))
			edge[b-1].append((c, a-1))
	inf = 10 ** 20
	dist = [[inf for _ in range(n)]for i in range(n)]
	for i in range(n):
		dist[i][i]=0
		for c, b in edge[i]:
			dist[i][b]=c
			
	for k in range(n):
		for i in range(n):
			for j in range(n):
				dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])
				
	dist2 = [[n+50 for j in range(n)] for i in range(n)]
	for i in range(n):
		dist2[i][i] = 0
		for j in range(i+1, n):
			if dist[i][j] <= l:
				dist2[i][j] = 1
				dist2[j][i] = 1
	for k in range(n):
		for i in range(n):
			for j in range(n):
				dist2[i][j] = min(dist2[i][k] + dist2[k][j], dist2[i][j])
	q = int(input())		
	for i in range(q):
		s, t = map(int, input().split())
		print(dist2[s-1][t-1] - 1 if dist2[s-1][t-1] < n+50 else -1)
	return 0
	
if __name__ == '__main__':
	solve()

Measured memory_bytes: 116828
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, y, z;
  cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);
  cout << x << ' ' << y << ' ' << z << '\n';
  return 0;
}


Measured memory_bytes: 256