akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define fr first
#define sc second
#define pb push_back
const ll mod = 1e9+7;
const int N = 2e5+205;
void solve(){
	int a,b,t;
	cin>>a>>b>>t;
	cout<<b*(t/a)<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}

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

int main(){
  vector<double> vec(5);
  for(int i=0;i<5;i++){
    cin>>vec.at(i);
  }
  double k=0;
  cin >> k;
  reverse(vec.begin(),vec.end());
  
  for(double x : vec){
    if(x-vec.at(4)>k){
    cout<<":("<< endl;
      exit(0);
  }
  }
  cout<<"Yay!"<<endl;
  
}

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

const int MAX_N = 10001, MAX_Q = 501;

int main()
{
  int n, q, s[MAX_N], t[MAX_Q], C;
  cin >> n; REP(i, n) cin >> s[i];
  cin >> q; REP(i, q) cin >> t[i];
  C = 0;
  REP(i, q) {
    int j = 0;
    s[n] = t[i];
    while (s[j] != t[i]) j++;
    if (j == n) continue;
    C++;
  }
  cout << C << endl;
  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

//1円、5円、10円、50円、100円、500円
int a[10], b[] = {1, 5, 10, 50, 100, 500};
signed main(){
	int n = 6, ans = 0;
	rep(i,6)scanf("%lld", &a[i]);
	rep(i,6)ans += a[i]*b[i];
	printf("%lld\n", (int)(ans >= 1000));
	return 0;
}








Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5005;

int n;
int z[N];
string s;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    cin >> s;
    int sol = 0;
    for(int i = 0; i < n; i++){
        int l = i,r = i;
        z[i] = 0;
        for(int j = i+1; j < n; j++){
            z[j] = 0;
            if(j <= r){
                z[j] = min(r-j+1,z[j-l+i]);
            }
            while(j+z[j]<n && s[i+z[j]] == s[j+z[j]]){
                z[j]++;
            }
            if(j+z[j]-1 > r){
                l = j;
                r = j+z[j]-1;
            }
        }
        for(int j = i+1; j < n; j++){
            sol = max(sol,min(j-i,z[j]));
        }
    }
    cout << sol << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
#define yn(x) puts((x ? "Yes" : "No"))
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MAX = 2 * 1e6 + 8, INF = 5LL << 57, MOD = 1e9 + 7;

int N, A, B;
string S;
vi va, vb;

void input() {
  ;
  ;
  cin >> N >> A >> B;
}
long long fac[MAX], finv[MAX], inv[MAX];
void com_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long pow_mod(long long a, long long b) {
  long long ans = 1;
  long long mul = a;
  for (; b; mul = (mul * mul) % MOD) {
    if ((b & 1) == 1) ans = (ans * mul) % MOD;
    b >>= 1;
  }
  return ans;
}

long long com(int n, int k) {
  if (n < k) {
    return 0;
  }
  if (n < 0 || k < 0) {
    return 0;
  }
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modinv(long long a) {
  long long b = MOD - 2, r = 1;
  while (b) {
    if (b & 1) r = r * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return r;
}
int factmod(int n) {
  int p = MOD;
  int res = 1;
  while (n > 1) {
    res = (res * ((n / p) % 2 ? p - 1 : 1)) % p;
    for (int i = 2; i <= n % p; ++i) res = (res * i) % p;
    n /= p;
  }
  return res % p;
}
void solve() {
  int k = pow_mod(2, N) - 1;

  int fac, facp, inv, invp;
  int kaijo = 1;
  int finva, finvb, finvak, finvbk;
  int nca;

  int cmb = 1;
  rep(i, 1, B) {
    // nCb
    cmb *= N - i + 1;
    cmb %= MOD;
    cmb *= modinv(i);
    cmb %= MOD;
    if (i == A) {
      nca = cmb;
    }
  }
  cout << (k - nca - cmb + MOD + MOD) % MOD << endl;

  ;
  ;
}
signed main() {
  cout << setprecision(12);
  input();
  solve();
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void){
  int N, result;
  scanf("%d", &N);
  if ((N%2)==1){
    result = (N-1)/2*((N-1)/2+1);
    printf("%d", result);
  }
  else{
    result = (N)/2*(N)/2;
    printf("%d", result);
  }
  return 0;
}

Measured memory_bytes: 128
fun main(args:Array<String>) {
    val ans = if(Proc().getAns()) "Yes" else "No"
    println(ans)
}

class Proc() {
    val num = readLine()!!.split(" " ).map { it.toInt() }
    val s = readLine()!!
    fun getAns():Boolean {
        val splitted = s.split('-')
        if(splitted.size != 2) {
            return false
        }
        if(splitted[0].all { ('0'..'9').contains(it) } && splitted[1].all { ('0'..'9').contains(it) }) {

        } else {
            return false
        }
        return splitted[0].length == num[0] && splitted[1].length == num[1]
    }
}





Measured memory_bytes: 37928
def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
  
A, B, K = map(int, input().split())
ans = list(set(divisor(A)) & set(divisor(B)))
ans.sort(reverse=True)
print(ans[K-1])

Measured memory_bytes: 3060
q=[1.0]+[k=0]*n=gets.to_i
g=[]
$<.map{|s|a,b=s.split;(g[a.to_i-1]||=[])<<b.to_i-1}
g.map{|h|h.map{|t|q[t]+=q[k]/h.size};k+=1}
e=[a=0]*n
(s=m=0.0
g[k-=1].map{|t|s+=c=e[t];m=[m,c].max}
e[k]=1+s/z=g[k].size
z>1&&a=[a,q[k]*=(s-m)/~-z-s/z].min)while k>0
p e[0]+a

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

string ticket;

string find_7(int roop_count, int ticket_result){
    if(roop_count == 3){
        if(ticket_result == 7){
            return "=7";
        }else{
            return "";
        }
    }else{
        if(find_7(roop_count + 1, ticket_result + ticket[roop_count + 1] - '0') != ""){
            return "+" + to_string(ticket[roop_count + 1] - '0') + find_7(roop_count + 1, ticket_result + ticket[roop_count + 1] - '0');
        }else if(find_7(roop_count + 1, ticket_result - ticket[roop_count + 1] + '0') != ""){
            return "-" + to_string(ticket[roop_count + 1] - '0') + find_7(roop_count + 1, ticket_result - ticket[roop_count + 1] + '0');
        }else{
            return "";
        }
    }
}

int main(){
    cin >> ticket;
    cout << ticket[0] << find_7(0, ticket[0] - '0') << endl;
}

Measured memory_bytes: 256
def solve(a, b, c, d):
    while a > 0 and c > 0:
        c -= b
        if c <= 0:
            return True
        a -= d
        if a <= 0:
            return False
    pass


if __name__ == "__main__":
    a, b, c, d = map(int, input().split())
    print("Yes" if solve(a, b, c, d) else "No")

Measured memory_bytes: 9120
N = int(input())
H = list(map(int, input().split()))

max_step = 0
count = 0
prev_h = -float('inf')
for h in H:
    if h > prev_h:
        count = 0
    else:
        count += 1
    max_step = max(count, max_step)
    prev_h = h
print(max_step)


Measured memory_bytes: 63856
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(-a + b <= 0) {
			System.out.println("delicious");
		} else if(-a + b <= x) {
			System.out.println("safe");
		} else {
			System.out.println("dangerous");
		}
	}

}


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

int main() {
  int n;
  cin >> n;
  
  vector<long> data(n);
  for(int i=0; i<n; i++){
    cin >> data[i];
  }
  
  long ans = 0;
  
  for(int i=0; i<(n-1); i++){
    for(int k=i+1; k<n; k++){
      ans += data[i] * data[k];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

const int N = 105;
ll a[N], b[N], c[N];

signed main() {
    ll n;
    scanf("%lld", &n);

    for(ll i = 1; i <= n; ++i) cin >> a[i] >> b[i] >> c[i];

    for(ll x = 0; x <= 100; ++x) for(ll y = 0; y <= 100; ++y) {
        ll h = -1;

        for(ll i = 1; i <= n; ++i) if(c[i] > 0) {
            h = c[i] + abs(x - a[i]) + abs(y - b[i]);
            break;
        }

        bool ok = true;
        for(ll i = 1; i <= n; ++i) {
            ll hi = max(0LL, h - llabs(x - a[i]) - llabs(y - b[i]));
            if(hi != c[i]) ok = false;
        }

        if(ok) {
            printf("%lld %lld %lld\n", x, y, h);
            return 0;
        }
    }
}

Measured memory_bytes: 256
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :- 
    get_number(X), 
    N2 is N - 1, 
    get_numbers(N2, Xs).

put_numbers([]).
put_numbers([X|Xs]) :-
    writeln(X),
    put_numbers(Xs).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    length(S, L),
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==

    between(L,U,X): L <= X <= U
    nth0(I, Xs, Y), nth1(I, Xs, Y): (Xs,Y) -> I, (I, Xs) -> Y 

    sort(Key, Order, List, Sorted): Keyは通常0?, Orderは=なしが重複削除，=は重複保持
    \+ P(X) : not P(X)

    sum_list(Xs, Sum)
*/

f(0, _, 0).
f(X, K, Z) :- X2 is X div K, f(X2, K, Z2), Z is Z2 + 1.

main :-
    get_number(N, K),
    f(N, K, Z),
    writeln(Z).

    % statistics(inferences, IC), writeln(IC).


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

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

int main() {
	int n;
	cin>>n;
	vector<int> d(n);
	rep(i,n) cin>>d[i];
	int num[110]={0};
	rep(i,n) num[d[i]]++;
	int ans=0;
	for(int i=1;i<=100;++i){
		if(num[i])++ans;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
	char c; cin >> c;
	const string s = "aiueo";
	FORE(e, s) if (e == c) {
		cout << "vowel" << endl;
		return 0;
	}
	cout << "consonant" << endl;
}


Measured memory_bytes: 256
L = int(input())
A = [int(input()) for _ in range(L)]

func = [lambda x: x,
        lambda x: 2 if x == 0 else int(x%2),
        lambda x: int(x%2==0),
        lambda x: 2 if x == 0 else int(x%2),
        lambda x: x]

before = [0]*5
for i in range(L):
    bmin = 1e10
    after = [0]*5
    for j in range(5):
        bmin = min(bmin, before[j])
        after[j] = bmin + func[j](A[i])
    before = after

print(min(before))


Measured memory_bytes: 11040
#include <bits/stdc++.h>
#define N 100005
#define mod 1000000007
#define ll long long

using namespace std;

char s[N];
int n;
ll f[N],g[N];

int main(){
	scanf("%s",s + 1);n = strlen(s + 1);f[1] = 2;g[1] = 1;
	for(int i = 2; i <= n; ++i){
		if(s[i] == '0'){
			f[i] = f[i - 1];
			g[i] = g[i - 1] * 3ll % mod;
		}
		else{
			f[i] = f[i - 1] * 2ll % mod;	
			g[i] = (g[i - 1] * 3ll % mod + f[i - 1]) % mod;
		}
	}
	cout << (f[n] + g[n]) % mod << endl;
	return 0;
}

Measured memory_bytes: 1920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();
		Pattern upperStr = Pattern.compile("[A-Z]");
		Pattern lowerStr = Pattern.compile("[a-z]");

		String str = br.readLine();
		for(int i=0; i<str.length();i++){
			String checkStr = str.substring(i, i+1);
			if(upperStr.matcher(checkStr).find()){
				builder.append(checkStr.toLowerCase());
			}else if(lowerStr.matcher(checkStr).find()){
				builder.append(checkStr.toUpperCase());
			}else{
				builder.append(checkStr);
			}
		}

		System.out.println(builder);
	}
}

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

using namespace std;
using Pi = pair<bool, int>;

int main() {
    int N;
    int c = 0;
    while(cin >> N, N != 0) {
        c++;
        //if(c == 37) cerr << N << endl;
        vector<vector<Pi>> mp(40001, vector<Pi>());
        int x, y;
        cin >> x >> y;
        int sx = x, sy = y;
        for(int i = 0; i < N; ++i) {
            int x2, y2;
            if(i == N - 1) {
                x2 = sx, y2 = sy;
            } else {
                cin >> x2 >> y2;
            }
            if(x < x2) {
                for(int xn = x; xn < x2; ++xn) {
                    mp[xn + 20000].push_back(Pi(0, y));
                }
            } else if(x2 < x) {
                for(int xn = x2; xn < x; ++xn) {
                    mp[xn + 20000].push_back(Pi(0, y));
                }
            }
            x = x2, y = y2;
        }
        cin >> x >> y;
        sx = x, sy = y;
        for(int i = 0; i < 4; ++i) {
            int x2, y2;
            if(i == 3) {
                x2 = sx, y2 = sy;
            } else {
                cin >> x2 >> y2;
            }
            if(x < x2) {
                for(int xn = x; xn < x2; ++xn) {
                    mp[xn + 20000].push_back(Pi(1, y));
                }
            } else if(x2 < x) {
                for(int xn = x2; xn < x; ++xn) {
                    mp[xn + 20000].push_back(Pi(1, y));
                }
            }
            x = x2, y = y2;
        }
        long long ans = 0;
        for(int x = -20000; x <= 20000; ++x) {
            sort(mp[x + 20000].begin(), mp[x + 20000].end(), [](const Pi &l, const Pi &r) { return l.second < r.second; });
            bool window = 0, carten = 0;
            int window_start;
            for(Pi p : mp[x + 20000]) {
                if(p.first == 0) {
                    if(window == 0) {
                        window = 1;
                        window_start = p.second;
                    } else {
                        if(!carten) {
                            ans += p.second - window_start;
                        }
                        window = 0;
                    }
                } else {
                    if(carten == 0) {
                        if(window) {
                            ans += (p.second - window_start);
                        }
                        carten = 1;
                    } else {
                        if(window) {
                            window_start = p.second;
                        }
                        carten = 0;
                    }
                }
                //cerr << ans << endl;
            }
            //if(!mp[x + 20000].empty()) cerr << "debug:" << x << " " << ans << endl;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 24432
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.SortedMap;
import java.util.TreeMap;

public class Main {
	public static void main(String[] arg) {
		Scanner in = new Scanner(System.in);
		in.nextInt();
		int q = in.nextInt();
		SortedMap<Integer, Integer> counter = new TreeMap<Integer, Integer>();
		Integer topNum = null;
		int max = 0;
		for (int i = 0; i < q; i++) {
			final Integer number = Integer.valueOf(in.next());
			int newVal = in.nextInt();
			if (counter.containsKey(number)) {
				newVal += counter.get(number);
			}
			if (newVal == 0) {
				counter.remove(number);
			} else {
				counter.put(number, newVal);
			}
			if (max < newVal || (max == newVal && number.compareTo(topNum) < 0)) {
				max = newVal;
				topNum = number;
			} else if (number.equals(topNum) && max > newVal) {
				max = 0;
				for (Entry<Integer, Integer> entry : counter.entrySet()) {
					if (entry.getValue() > max) {
						max = entry.getValue();
						topNum = entry.getKey();
					}
				}
			}
			System.out.print(topNum);
			System.out.print(' ');
			System.out.println(max);
		}
		in.close();
	}
}

Measured memory_bytes: 73316
n, y = input().split()
n = int(n)
y = int(y)
amx = min(n, y // 10000)
bmx = min(n, y // 5000)
ans1, ans2, ans3 = -1, -1, -1
for a in range(0, amx + 1):
    for b in range(0, bmx + 1):
        c = n - a - b
        if c < 0:
            break
        if c > n:
            continue
        yy = a * 10000 + b * 5000 + c * 1000
        if yy  == y:
            ans1, ans2, ans3 = a, b, c
            break
    if ans1 >= 0 and ans2 >= 0 and ans3 >= 0:
        break
print("{} {} {}".format(ans1, ans2, ans3))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;

int main(){
  prep();
  int a, b, c;
  cin >> a >> b >> c;
  if (a+b+c >= 22){
      cout << "bust";
  }else{
      cout << "win";
  }
  return 0; 
}


Measured memory_bytes: 256
//   PIGMEISTER™   //

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

#define ll long long
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD (ll)1000000007
//#define MOD (ll)998244353
#define MAX 100005

int main()
{
    jaldi;
    
    string s, t;
    cin >> s >> t;
    s += t[s.size()];
    if (s == t) cout << "Yes\n";
    else cout << "No\n";
    
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string alp = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> ll gcd(T1 a, T2 b){return a % b ? gcd(b , a % b) : b;}
template<class T1, class T2> void reduce(T1 &a, T2 &b){ll g = gcd(a, b); a /= g; b /= g; return;}
bool valid(ll H, ll W, ll h, ll w){return 0 <= h && h < H && 0 <= w && w < W;}

int main(){
    ll N; cin >> N;
    N++;
    vector<ll> a(N); rep(i, N) cin >> a[i];
    vector<ll> ap(N);
    ap[N - 1] = a[N - 1];
    for(ll i = N - 2; 0 <= i; i--){
        ap[i] = ap[i + 1] + a[i];
    }
    ll ans = 0;
    ll node = 1;
    rep(i, N){
        // pt(i, node, ap[i]);
        ans += min(node, ap[i]);
        node -= a[i];
        if(node < 0){
            pt(-1);
            return 0;
        }
        node *= 2;
        if (node >= INF) node = INF;
    }
    // ans += a[N - 1];
    pt(ans);
}


Measured memory_bytes: 4848
// inputに入力データ全体が入る
function Main(input) {
  const num = parseInt(input[0]);
    
  console.log(num*num*num);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace abc148
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader("input.txt"));
            solve_abc148D();
        }

        public static void solve_abc148D()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            Dictionary<int, int> dic = new Dictionary<int, int>();
            for (int i = 0; i < n; i++)
            {
                dic.Add(i, a[i]);
            }
            var srt = dic.OrderBy((x) => x.Value);
            int cnt = 0;
            int k = 1;
            int[] used = new int[200001];
            int maxIdx = -1;
            foreach(var item in srt)
            {
                if (used[item.Value] == 0 && item.Value == k && maxIdx < item.Key)
                {
                    used[item.Value] = 1;
                    maxIdx = item.Key;
                    k++;
                }
                else
                {
                    cnt++;
                }
            }

            Console.WriteLine(maxIdx != -1 ? cnt : -1);
        }

        public static void solve_abc148C()
        {
            long[] ab = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
            Console.WriteLine(lcm(ab[0], ab[1]));
        }

        public static long lcm(long a, long b)
        {
            return a / gcd(a, b) * b;
        }
        public static long gcd(long a, long b)
        {
            if (b == 0)
            {
                return a;
            }
            else
            {
                return gcd(b, a % b);
            }
        }

        public static void solve_abc148B()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            string[] st = Console.ReadLine().Split();
            char[] ans = new char[2 * n];
            int k = 0;
            for (int i = 0; i < n; i++)
            {
                ans[k++] = st[0][i];
                ans[k++] = st[1][i];

            }

            Console.WriteLine(new string(ans));
        }

        public static void solve_abc148A()
        {
            int a  = Convert.ToInt32(Console.ReadLine());
            int b = Convert.ToInt32(Console.ReadLine());

            if ((a == 1 && b == 2) || (a == 2 &&  b == 1))
            {
                Console.WriteLine(3);
            }
            else if ((a == 1 && b == 3) || (a == 3 && b == 1))
            {
                Console.WriteLine(2);
            }
            else
            {
                Console.WriteLine(1);
            }


        }
    }
}


Measured memory_bytes: 44996
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int MAX = 10000;
static const int INF=(1<<20);
static const int SHIRO=0;
static const int HAI=1;
static const int KURO=2;
int n;
vector<pair<int, int> > adj[MAX];

void dij(){
  priority_queue<pair<int, int> > PQ;
  int color[MAX];
  int d[MAX];
  int i=0;
  int j=0;
  int v;
  for(i=0;i<n;i++){
    d[i]=INF;
    color[i]=SHIRO;
  }
  d[0]=0;
  PQ.push(make_pair(0,0));
  color[0]=HAI;

  while( !PQ.empty()){
    pair<int, int>f=PQ.top();
    PQ.pop();
    int u=f.second;
    color[u]=KURO;
    if(d[u]<f.first*(-1)){
      continue;
    }
    for(j=0;j<adj[u].size();j++){
      v=adj[u][j].first;
      if(color[v]==KURO){
        continue;
      }
      if(d[v]>d[u]+adj[u][j].second){
        d[v]=d[u]+adj[u][j].second;
        PQ.push(make_pair(d[v]*(-1),v));
        color[v]=HAI;
      }
    }
  }
  for(i=0;i<n;i++){
    cout << i << " " << (d[i]==INF ? -1 : d[i])<< endl;
  }
}
int main(){
  int k,u,v,c,i,j;

  cin>>n;
  for(i=0;i<n;i++){
    cin>>u>>k;
    for(j=0;j<k;j++){
    cin>>v>>c;
    adj[u].push_back(make_pair(v,c));
    }
  }
  dij();

  return 0;
}

Measured memory_bytes: 8092
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;
const int MAX = 1e5;

vector<pair<int, int>> G[MAX];
vector<ll> d(MAX, INF);

void dfs(int u) {
  for (pair<int, int> p: G[u]) {
    if (d[p.first] != INF) continue;
    d[p.first] = d[u] + p.second;
    dfs(p.first);
  }
}

int main() {
  int n;
  cin >> n;
  rep(i, n - 1) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    G[a].push_back({b, c});
    G[b].push_back({a, c});
  }
  int q, k;
  cin >> q >> k;
  k--;
  vector<int> x(q), y(q);
  rep(i, q) {
    cin >> x[i] >> y[i];
    x[i]--, y[i]--;
  }

  d[k] = 0;
  dfs(k);

  rep(i, q) {
    cout << d[x[i]] + d[y[i]] << endl;
  }




  
  return 0;
}

Measured memory_bytes: 13568
#include <iostream>
#include <string>
#define M 1046527
#define NIL (-1)
#define L 14

using namespace std;

string H[M];

int getChar(char ch){
	if( ch == 'A' ) return 1;
	else if( ch == 'C' ) return 2;
	else if( ch == 'G' ) return 3;
	else if( ch == 'T' ) return 4;
	else return 0;
}

long long getKey(string str){
	long long sum = 0, p = 1, i;
	for( i = 0; i < str.length(); i++ ){
		sum += p*(getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+(key%(M-1)); }

int find(string str){
	long long key, i, h;
	key = getKey(str);
	for( i = 0;; i++ ){
		h = (h1(key)+i*h2(key))%M;
		if( H[h].compare(str) == 0 ) return 1;
		else if( H[h].length() == 0 ) return 0;
	}
	return 0;
}

int insert(string str){
	long long key, i, h;
	key = getKey(str);
	for( i = 0;; i++ ){
		h = (h1(key)+i*h2(key))%M;
		if( H[h].compare(str) == 0 ) return 1;
		else if( H[h].length() == 0 ){
			H[h].assign(str);
			return 0;
		}
	}
	return 0;
}

int main(){
	int i, n, h;
	string str, com;
	for( i = 0; i < M; i++ ) H[i][0] = '\0';
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> com >> str;
		if( com[0] == 'i' ) insert(str);
		else {
			if( find(str) ) cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 27740
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    s64 N, A, B;
    cin >> N >> A >> B;

    s64 ans;
    if ((B - A) % 2 == 0)
    {
        ans = (B - A) / 2;
    }
    else
    {
        ans = MIN((A + B - 1) / 2, N - (A + B - 1) / 2);
    }

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



Measured memory_bytes: 256
from collections import defaultdict
import sys
import math
from datetime import datetime

def rec(S):
    if S is None: return 0
    elif len(S) == 1: return sum(S)
    elif len(S) == 2:
        return sum(S) / 2.0
    else: # len(S) >= 2
        S.sort()
        S[1] = (S[0] + S[1]) / 2.0
        return rec(S[1:])



def sol(n, S):
    return rec(S)



do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    print(parsed_lines)
    n = int(parsed_lines[0][0])
    S = list(map(int, parsed_lines[1]))
    # S = parsed_lines[1][0]
    # return n, k, S
    return n, S


if not do_submit:
    n, S = input_parse("""
    3
    500 300 200
    """)
    print(sol(n, S))

    n, S = input_parse("""
    5
    138 138 138 138 138
    """)
    print(sol(n, S))




else:
    n = int(input().strip())
    S = list(map(int, input().split()))
    #S = input().split()
    # print(sol(n, k, S))

    #s = input().strip()
    # S = input().strip()
    print(sol(n, S))

Measured memory_bytes: 3824
package main

import (
	"fmt"
	"sort"
)

func main() {
	var p, q, r int
	fmt.Scanf("%d %d %d", &p, &q, &r)

	fmt.Println(logic(p, q, r))
}

func logic(p, q, r int) int {
	nums := []int{p, q, r}
	sort.Ints(nums)

	return nums[0] + nums[1]
}


Measured memory_bytes: 512
N, K = map(int, input().split())
D = []
A = []
result = []
for i in range(K*2):
    if i % 2 == 0:
        d = int(input())
        D.append(d)
    else:
        a = list(map(int, input().split()))
        A.append(a)

for a in A:
    for b in a:
        result.append(b)

print(N-len(set(result)))

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

int n, m;
int a[100001], b[100001], chk[100001];
vector<int> gph[100001];

void go(int now, int cnt) {
    chk[now] = cnt;
    for (int nxt : gph[now]) {
        if (chk[nxt] < 0) {
            go(nxt, cnt);
        }
    }
}

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        b[a[i]] = i;
    }
    while (m--) {
        int u, v;
        scanf("%d %d", &u, &v);
        gph[u].push_back(v);
        gph[v].push_back(u);
    }

    for (int i = 1; i <= n; i++) {
        chk[i] = -i;
    }
    int cnt = 1;
    for (int i = 1; i <= n; i++) {
        if (chk[i] < 0) {
            go(i, cnt);
            cnt++;
        }
    }

    for (int i = 1; i <= n; i++) {
        if (a[i] == i) {
            continue;
        }
        if (chk[a[i]] == chk[b[a[i]]]) {
            swap(a[i], a[b[i]]);
            swap(b[i], b[a[b[i]]]);
        }
    }

    int res = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i] == i) {
            res++;
        }
    }

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

    return 0;
}

Measured memory_bytes: 8960
#include <stdio.h>

int main()
{
    int r, g, b, n;
    int i, j, cnt;
    scanf("%d",&r);
    scanf("%d",&g);
    scanf("%d",&b);
    scanf("%d",&n);

    cnt = 0;
    for(i=0; i <= n/r; i++)
        for(j=0; j <= (n - i * r) / g; j++)
            if((n - (i * r) - (j * g)) % b == 0)
                cnt++;
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 2112
n, k = map(int, input().split())
height = [int(input()) for i in range(n)]

height.sort()
dh = 10 ** 10
for i in range(n - k + 1):
  if height[i + k -1] - height[i] < dh:
    dh = height[i+k-1] - height[i]

print(dh)

Measured memory_bytes: 7384
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.Set as Set
import qualified Data.Sequence as Sq
import qualified Data.IntMap as IMap
import Data.Sequence (ViewL(..),ViewR(..),(><),(<|),(|>),Seq)

bsreadInt :: BC.ByteString -> Int
bsreadInt = fst . fromJust . BC.readInt

setadj :: [[Int]] -> IMap.IntMap (Set.Set Int) -> IMap.IntMap (Set.Set Int)
setadj [] adj = adj
setadj (x:xs) adj = setadj xs (IMap.insert a add adj) 
                            where a = x!!0
                                  b = x!!1
                                  add = Set.union (Set.singleton b) cs
                                  cs = if IMap.member a adj == True
                                       then (IMap.!) adj a
                                       else Set.empty

nsetadj :: [[Int]] -> IMap.IntMap (Set.Set Int) -> IMap.IntMap (Set.Set Int)
nsetadj xs adj = setadj (xs ++ (map reverse xs)) adj

main = do
    [n,m] <- map bsreadInt . BC.words <$> BC.getLine --n頂点，m本の辺
    ab <- map ((map bsreadInt . BC.words)) <$> replicateM m BC.getLine -- a-->b :path のリスト
    let q = Sq.singleton [1]
    let chk = Set.singleton 1
    print $ length $ filter (==False) [connectchk q n (nsetadj (ab \\ [ab!!(k-1)]) IMap.empty) chk | k <-[1..m]]
    --print $ length $ filter (==False) [connectchk q n (delete adjs) chk | k <- [1..m]]
    --print $ length $ filter (==False) [connectchk q n (Set.union (Set.fromList (ab \\ [ab!!(k-1)] ) ) (Set.fromList (map reverse (ab \\ [ab!!(k-1)] )) )) chk | k <- [1..m]]

connectchk :: Sq.Seq [Int] -> Int -> IMap.IntMap (Set.Set Int) -> Set.Set Int -> Bool
connectchk q n adjs chk = foldr (&&) True [ (bsearch q n g adjs chk) /= [] | g <- [2..n] ]
         
adjset :: Int -> Int -> IMap.IntMap (Set.Set Int) -> Set.Set Int -> [Int]
adjset x n adjs chk  = Set.toList (Set.difference (f adjs x) chk)
                        where f adj a = if IMap.member a adj == True
                                        then (IMap.!) adj a
                                        else Set.empty

bsearch :: Sq.Seq [Int] -> Int -> Int -> (IMap.IntMap (Set.Set Int) ) -> Set.Set Int -> [Int]
bsearch q n g adjs chk = if Sq.length q == 0
                         then []
                         else if head (sqleft q) == g
                              then reverse $ sqleft q
                              else bsearch q2 n g adjs chk2
                                where qa = sqleft q
                                      q2 = (Sq.drop 1 q) >< (Sq.fromList add)
                                      add = [x : qa | x <- adjset (head qa) n adjs chk]
                                      chk2 = Set.union chk (Set.fromList (adjset (head qa) n adjs chk))
                                      
sqleft :: Seq a -> a
sqleft q = sqleft_(Sq.viewl q)
sqleft_ :: ViewL a -> a
sqleft_ (x :< xs) = x
sqright :: Seq a -> a
sqright q = sqright_(Sq.viewr q)
sqright_ :: ViewR a -> a
sqright_ (xs :> x) = x

    


Measured memory_bytes: 1532
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int main () {
    ll K ,temp;
    cin >> K ;
    ll ans = 0 ;
    rep(i , K){
        rep(j , K){
            rep(k , K){
              temp = gcd( i + 1 , j + 1) ;
              ans += gcd(k + 1 , temp) ;

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

 


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
int main(){
	int n=read();
	int ans=0;
	while(n) ans+=n%10,n/=10;
	if(ans==1) cout<<10<<endl;
	else cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long yen = 1000;
    long stock = 0;
    int n = sc.nextInt();
    int[] price = new int[n];
    for (int i = 0; i < n; i++) {
      price[i] = sc.nextInt();
    }
    for (int i = 0; i < n - 1; i++) {
      // 株がない場合とりあえず全力で買う
      if (stock == 0) {
        stock = yen / price[i];
        yen -= stock * price[i];
      }
      if (price[i] > price[i + 1]) {
        yen += stock * price[i];
        stock = 0;
      }
    }
    if (stock != 0) {
      yen += stock * price[n - 1];
    }
    System.out.println(yen);
  }
}


Measured memory_bytes: 35952
#include <bits/stdc++.h>
using namespace std;
 
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}
 
void solve(){
 
 
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    int n,k;cin>>n>>k;
    vector<ll> r,l;
    r.pb(0);
    rep(i,n){
        int x;cin>>x;
        if(x>=0)r.pb(x);
        else l.pb(-x);
    }
    l.pb(0);
    reverse(all(l));

    k+=2;
    
    ll ans=1e18;
    repA(i,0,k-2) if(sz(l)>i && sz(r)>k-i-2)
        ans=min(ans, l[i]+r[k-i-2]+min(l[i], r[k-i-2]));
    cout<<ans<<endl;


	return 0;
}
 


Measured memory_bytes: 1656
from fractions import gcd
# from datetime import date, timedelta
# from heapq import *
import heapq
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors





def main():
    
    n, m = map(int, input().split())
    ps = [list(input().split()) for i in range(m)]

    c = 1
    ac, wa = 0, 0
    d = defaultdict(int)
    dwa = defaultdict(int)
    for i in range(m):
        if ps[i][1] == "AC" and d[int(ps[i][0])] == 0:
            ac += 1
            d[int(ps[i][0])] = 1
            wa += dwa[int(ps[i][0])]
        elif ps[i][1] == "WA" and d[int(ps[i][0])] == 0:
            # wa += 1
            dwa[int(ps[i][0])]+=1
    print(ac,wa)

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

            
    
    # l = [1, 2, 3, 4, 5, 6]
    # dmax = defaultdict(int)
    # dmin = defaultdict(int)
    # d = defaultdict(int)
    # for i in itertools.combinations(l, 2):
    #     dmax[max(i)] += 1
    #     dmin[min(i)] += 1
    #     d[max(i) - min(i)] += 1
    
    # print(dmax)
    # print(dmin)
    # print(d)
                
        




    


if __name__ == '__main__':
    main()


Measured memory_bytes: 111700
<?php
list($s) = strs();
$a = ['N' => 0, 'S' => 0, 'E' => 0, 'W' => 0];
for ($i = 0; $i < strlen($s); ++$i) $a[$s[$i]] = 1;
echo $a['N'] ^ $a['S'] || $a['E'] ^ $a['W'] ? 'No' : 'Yes';
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}


Measured memory_bytes: 16204
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int n;
  cin >> n;
  cout << "ABC" << n << "\n";
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a;
  cin>>a;
  if(a[0]==a[1] && a[2]==a[1]){
    cout<<"Yes\n";
  }else{
    if(a[1]==a[2] && a[3]==a[2]){
      cout<<"Yes\n";
    }else{
      cout<<"No\n";
    }
  }
}


Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))

total = [float("inf")] * N
total[0] = 0

for i in range(1, N):
    try:
        total[i] = min(total[i], total[i-1] + abs(h[i] - h[i-1]))
        total[i+1] = min(total[i+1], total[i-1] + abs(h[i+1] - h[i-1]))
    except IndexError:
        break

print(total[N-1])


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

using namespace std;

#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2 + 2], R[MAX/2 + 2];
int cnt;

void merge(int A[], int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right -mid;
    for (int i = 0; i < n1; i++)
    {
        L[i] = A[left + i];
    }
    for (int i = 0; i < n2; i++)
    {
        R[i] = A[mid + i];
    }
    L[n1] = R[n2] = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k < right; k++)
    {
        cnt++;
        if(L[i] <= R[j]){
            A[k] = L[i++];
        }else
        {
            A[k] = R[j++];
        }
    }
}

void mergeSort(int A[], int left, int right){
    if(left + 1 < right){
        int mid = (left + right)/2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main(){
    int A[MAX], n, i;
    cnt = 0;

    cin >> n;
    for (i = 0; i < n; i++)
    {
        cin >> A[i];
    }
    mergeSort(A, 0, n);

    for ( i = 0; i < n; i++)
    {
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << cnt << endl;
    
    return 0;
}


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

using namespace std;

template <typename T>
using vec1 = vector<T>;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

template <typename T>
vec1<T> cin2vec(size_t size)
{
    vec1<T> vec1;
    for (size_t i = 0; i < size; ++i) {
        vec1.push_back(cin2var<T>());
    }
    return vec1;
}

int main()
{
    while (true) {
        const auto N(cin2var<int>());
        if (!N) break;
        const auto hits(cin2vec<int>(N / 4));
        const auto sum = accumulate(hits.cbegin(), hits.cend(), 0);
        cout << sum << endl;
    }
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    string r = s;
    reverse(r.begin(),r.end());
    if(s != r) {
        cout << "No" << endl;
      	return 0;
    }
    s = s.substr(0,s.size()/2);
    string t = s;
    reverse(t.begin(),t.end());
    if(s != t) {
        cout << "No" << endl;
      	return 0;
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);

		String[] nico = sc.nextLine().split(" ");
		int n = Integer.parseInt(nico[0]);
		int m = Integer.parseInt(nico[1]);

		String ans = "IMPOSSIBLE";

		boolean[] flag = new boolean[n];
		for (int i = 0; i < n; i++) {
			flag[i] = false;
		}
		
		for (int i = 0; i < m; i++) {
			String[] tmp = sc.nextLine().split(" ");
			int t0 = Integer.parseInt(tmp[0]);
			int t1 = Integer.parseInt(tmp[1]);
			
			if ((t0 != 1) && (t0 != n) && (t1 != 1) && (t1 != n)) continue;

			if ((t0 == 1) || (t0 == n)) {
				if (flag[t1] == true) {
					ans = "POSSIBLE";
					break;
				}
				flag[t1] = true;
			}
			
			if ((t1 == 1) || (t1 == n)) {
				if (flag[t0] == true) {
					ans = "POSSIBLE";
					break;
				}
				flag[t0] = true;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 161740
#include<iostream>
using namespace std;
int main(){
  int H,W;
  while(1){
    cin>>H>>W;
    if(H>0&&W>0){
      for(int k=0;k<W;k++){
        cout<<"#";
      }cout<<endl;
      for(int i=2;i<H;i++){
        cout<<"#";
        for(int l=2;l<W;l++){
          cout<<".";
        }cout<<"#"<<endl;
      }
      for(int j=0;j<W;j++){
        cout<<"#";
      }cout<<endl;
    }
    else if(H==0&&W==0){
      break;
    }cout<<endl;
  }
  
}


Measured memory_bytes: 3084