akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
from collections import deque


def read():
    X = input().strip()
    return X,


def solve(X):
    ans = 0
    q = deque()
    for x in X:
        if x == "S":
            q.append(x)
        elif x == "T":
            if len(q) > 0:
                q.popleft()
            else:
                ans += 1
    ans += len(q)
    return ans


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 10036
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vint a(n+10),b(n+10),c(n+10);
  rep(i,n){
    cin>>a[i+1]>>b[i+1]>>c[i+1];
  }
  vector<vector<int> > dp(n+100,vector<int>(100,0));
  dp[1][0]=a[1];
  dp[1][1]=b[1];
  dp[1][2]=c[1];
  REP(i,2,n+1){
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
    dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
  }
  cout<<max({dp[n][0],dp[n][1],dp[n][2]})<<'\n';
  return(0);
}

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

int main(){

    int N;
    cin >> N;
    int K;
    cin >> K;

    int array[N];
    int i;

    for(i=0; i<N;i++){
        cin >> array[i];
    }
    
    sort(array,array+N);
    int s =0;

    for(int j = 0; j<K; j++){
        s = s + array[j];
    }

    cout << s << endl;
}


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

int main()
{

	int n, cnt, flg;
	int s[12], cs[12];

	while (cin >> n)
	{
		if (n == 0) break;
		cnt = 0;
		flg = 1;

		for (int i = 0; i < n; i++)
		{
			cin >> s[i];
		}

		for (int i = 0; i < 12; i++)
		{
			cs[i] = 0;
		}

		while (1)
		{
			flg = 0;
			for (int i = 0; i < n; i++)
			{
				for (int j = 0; j < n; j++)
				{
					if (s[i] == s[j])
					{
						cs[i]++;
					}
				}
			}
			cnt++;
			for (int i = 0; i < n; i++)
			{
				if (s[i] != cs[i])
				{
					flg++;
				}
			}
			if (flg==0)
			{
				cnt--;
				break;
			}
			else
			{
				for (int i = 0; i < n; i++)
				{
					s[i] = cs[i];
					cs[i] = 0;
				}
			}
		}
		
		cout << cnt << endl;
		for (int i = 0; i < n-1; i++)
		{
			cout << cs[i] << " ";
		}
		cout << cs[n-1] << endl;
	}

	return 0;
}

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

int main()
{
    int n;
    cin>>n;
    vector<int> s(n+1,0),b(n+1,0),h(n+1,0);
    vector< vector<int> > p(n+1,vector<int>(3,0));
    for(int i=1;i<=n;i++)
    {
        cin>>s[i]>>b[i]>>h[i];
    }
    for(int i=1;i<=n;i++)
    {
        p[i][0]=s[i]+max(p[i-1][1],p[i-1][2]);
        p[i][1]=b[i]+max(p[i-1][0],p[i-1][2]);
        p[i][2]=h[i]+max(p[i-1][0],p[i-1][1]);
    }
    int points= max(p[n][0],p[n][1]);
    cout<<max(points,p[n][2]);
    return 0;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  while (n--) {
    int a;
    cin >> a;
    while (a % 2 == 0) {
      ans++;
      a >>= 1;
    }
  }
  cout << ans << endl;
}

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


int N, M, a[50], b[50];
int p[50];

int root(int x){
    if(p[x] == x){
        return x;
    }
    return p[x] = root(p[x]);
}

void unite(int x, int y){
    p[root(x)] = root(y);
}

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


void init(){
    for(int i = 0; i < 50; i++){
        p[i] = i;
    }
}

int main(){
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    int ans = 0;
    for(int i = 0; i < M; i++){
        init();
        for(int j = 0; j < M; j++){
            if(i != j){
                unite(a[j], b[j]);
            }
        }
        bool connected = true;
        for(int j = 0; j < N; j++){
            if(!is_same_set(0, j)){
                connected = false;
            }
        }
        if(!connected){
            ans++;
        }
    }
    cout << ans << endl;
}


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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

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

  ll n, m;
  cin >> n >> m;
  vector<ll> x(m), p(n);
  rep(i, m) cin >> x[i];
  if (n >= m) {
    cout << 0 << endl;
    return 0;
  }
  sort(x.begin(), x.end());
  priority_queue<ll> d;
  rep(i, m-1) {
    d.push(x[i+1]-x[i]);
  }
  rep(i, n-1) {
    d.pop();
  }
  ll ans = 0;
  while (!d.empty()) {
    ans += d.top();
    d.pop();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2808
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M, K = MAP()

A = []
for i in range(N+1):
    for j in range(M+1):
        tmp = M * i + N * j - i * j * 2
        A.append(tmp)

if K in set(A):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 61884
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

ll n, a, b, c, d, cost;
map<ll, ll> mp;

void solve(ll x) {
	if (x <= (1e18 - cost) / d) mp[0] = min(mp[0], cost + x * d);
	ll z = mp[x];
	if (z && z <= cost) return;
	mp[x] = cost;
	if (x == 1) return;
	for (ll i = 0; ; i++) {
		if ((x + i) % 2 == 0) {
			cost += i * d + a;
			solve((x + i) / 2);
			cost -= i * d + a;
			break;
		}
	}
	for (ll i = 0; ; i++) {
		if ((x + i) % 3 == 0) {
			cost += i * d + b;
			solve((x + i) / 3);
			cost -= i * d + b;
			break;
		}
	}
	for (ll i = 0; ; i++) {
		if ((x + i) % 5 == 0) {
			cost += i * d + c;
			solve((x + i) / 5);
			cost -= i * d + c;
			break;
		}
	}
	for (ll i = 0; ; i++) {
		if (x - i == 1) {
			mp[1] = min(mp[1], cost + i * d);
			break;
		}
		if ((x - i) % 2 == 0) {
			cost += i * d + a;
			solve((x - i) / 2);
			cost -= i * d + a;
			break;
		}
	}
	for (ll i = 0; ; i++) {
		if (x - i == 1) {
			mp[1] = min(mp[1], cost + i * d);
			break;
		}
		if ((x - i) % 3 == 0) {
			cost += i * d + b;
			solve((x - i) / 3);
			cost -= i * d + b;
			break;
		}
	}
	for (ll i = 0; ; i++) {
		if (x - i == 1) {
			mp[1] = min(mp[1], cost + i * d);
			break;
		}
		if ((x - i) % 5 == 0) {
			cost += i * d + c;
			solve((x - i) / 5);
			cost -= i * d + c;
			break;
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	ll t;
	cin >> t;
	while (t--) {
		cin >> n >> a >> b >> c >> d;
		cost = 0;
		mp.clear();
		mp[0] = INF;
		solve(n);
		cout << (*mp.begin()).second << '\n';
	}
}

Measured memory_bytes: 4424
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: String,
        b: String,
    }
    let mut s = a;
    s.push_str(&b);
    let val: u32 = s.parse().unwrap();
    for i in 0..1000 {
        if val == i * i {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(){
  char s[3];
  scanf("%s",s);
  if(s[0]=='S'&&s[1]=='U') printf("7");
  if(s[0]=='M'&&s[1]=='O') printf("6");
  if(s[0]=='T'&&s[1]=='U') printf("5");
  if(s[0]=='W'&&s[1]=='E') printf("4");
  if(s[0]=='T'&&s[1]=='H') printf("3");
  if(s[0]=='F'&&s[1]=='R') printf("2");
  if(s[0]=='S'&&s[1]=='A') printf("1");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h> 
#define ll long long 
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    long long q(1);//cin>>q;
    while(q--){
        long long n,m,k,tot(0),p(0);
        string s;
        bool ok(0),okk(1);
        cin>>n;cout<<1-n;
    }
}

Measured memory_bytes: 3648
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		long k = Long.parseLong(sc.next());
		Map<Integer, Long> m = new TreeMap<>();
		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			long b = Integer.parseInt(sc.next());
			if (m.containsKey(a)) {
				b += m.get(a);
			}
			m.put(a, b);
		}
		long c = 0;
		for (Integer i:m.keySet()) {
			c += m.get(i);
			if (c >= k) {
				System.out.println(i);
				return;
			}
		}
	}
}

Measured memory_bytes: 66556
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(v) (v).begin(),(v).end()

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int m,a,b;
bool is_prime[MAX_N];
vector<int> prime;

int sieve(int n)
{
	int p = 0;
	for(int i=0;i<=n;i++){
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for(int i=2;i<=n;i++){
		if(is_prime[i]){
			prime.push_back(i);
			for(int j=2*i;j<=n;j+=i){
				is_prime[j] = false;
			}
		}
	}
	return p;
}

int main()
{
    sieve(100000);
    sort(all(prime));
    while(1){
        scanf("%d%d%d",&m,&a,&b);
        if(m == 0){
            break;
        }
        int mxq = (int)(sqrt(b*m / a));
        // cout << mxq << "\n";
        int nq = upper_bound(all(prime),mxq) - prime.begin();
        nq--;
        // cout << prime[nq] << "\n";
        int opt = 0;
        int ap = 0,aq = 0;
        while(nq >= 0){
            if(opt >= prime[nq]*prime[nq]){
                break;
            }
            int p1 = (a * prime[nq] - 1) / b + 1;
            int p2 = min(prime[nq],m/prime[nq]);
            // cout << p1 << " " << p2 << "\n";
            int np = upper_bound(all(prime),p2) - prime.begin();
            np--;
            // cout << prime[np] << "\n";
            if(prime[np] >= p1){
                if(opt < prime[np] * prime[nq]){
                    opt = prime[np] * prime[nq];
                    ap = prime[np],aq = prime[nq];
                }
            }
            nq--;
        }
        cout << ap << " " << aq << "\n";
    }
	return 0;
}

Measured memory_bytes: 3412
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a == b){
		printf("a == b\n");
	}
	if(a < b){
		printf("a < b\n");
	}
	if(a > b){
		printf("a > b\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <stdio.h>
#include <string.h>
#pragma warning(disable : 4996)
#pragma warning(disable : 4996)

#define H_MAX 10000
#define A_MAX 10000
#define N_MAX 1000
#define INF 100000000


int min(int a, int b) {
	if (a < b) return a;
	return b;
}

// DP[j] jのダメージを与えるために使用する最低の魔力　
int DP[H_MAX+A_MAX+1];

int main(void) {
	int H, N;
	scanf("%d %d", &H, &N);
	for (int j = 0; j <= H+A_MAX; ++j) {
		DP[j] = INF;
	}
	DP[0] = 0;
	for (int i = 1; i <= N; ++i) {
		int A, B;
		scanf("%d %d", &A, &B);
		for (int j = 0; j <= H + A_MAX; ++j) {
			if ((j >= A) && (DP[j - A] + B < DP[j])) DP[j] = DP[j - A] + B;
		}
	}
	int min = INF;
	for (int i = H; i < H + A_MAX; ++i) {
		if (min > DP[i]) min = DP[i];
	}
	printf("%d\n", min);
	return 0;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>

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

using namespace std;
using ll = long long;

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

int gcd(int a, int b) {
	return b ? gcd(b, a%b) : a;
}

int main() {

	int n, k;

	cin >> n >> k;

	if (n % k == 0) {
		cout << 0 NL;
	} else {
		cout << 1 NL;
	}


	return 0;

}

Measured memory_bytes: 256
n = int(input())
lis = list(map(int, input().split()))
print(" ".join(map(str, lis)))
for i in range(1, n):
  v = lis[i]
  j = i - 1
  while j >= 0 and lis[j] > v:
    lis[j+1] = lis[j]
    j -= 1
  lis[j+1] = v
  print(" ".join(map(str, lis)))


Measured memory_bytes: 5596
n = raw_input()
n= n.split()
N = int(n[0])
M = int(n[1])
if N ==1 and M == 1:
	ANS = 1
if (N == 1 and M  >= 2) or (M == 1 and N >= 2) :
	ANS = N*M - 2
elif N >= 2 and M >= 2:
	ANS = (N-2)*(M-2)
	
print(ANS)

Measured memory_bytes: 2568
from itertools import accumulate
from bisect import bisect_left

N = int(input())
A = [int(s) for s in input().split()]
S = [0] + list(accumulate(A))


def score(i, j, k):
    mx = max(S[i], S[j] - S[i], S[k] - S[j], S[N] - S[k])
    mn = min(S[i], S[j] - S[i], S[k] - S[j], S[N] - S[k])
    return mx - mn


ans = float("inf")
i = 1
k = 3
for j in range(2, N - 1):
    while i < j - 1 and abs(S[j] - 2 * S[i]) > abs(S[j] - 2 * S[i+1]):
        i += 1
    while k <= j or k < N - 1 and abs(S[N] - 2 * S[k] + S[j]) > abs(S[N] - 2 * S[k+1] + S[j]):
        k += 1
    mx = max(S[i], S[j] - S[i], S[k] - S[j], S[N] - S[k])
    mn = min(S[i], S[j] - S[i], S[k] - S[j], S[N] - S[k])
    ans = min(ans, mx - mn)
print(ans)


Measured memory_bytes: 25548
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  
  const int A = 0, X = 1, Y = 2, Z = 3, W = 4, B = 5;
  
  string s;
  while(cin >> s) {
    if(s == "#") break;
    int now = A;
    int const size = s.size();
    bool over = false;
    for(int i=0; i<size; i++) {
      switch(now) {
      case A:
        if(s[i] == '0') now = X;
        else now = Y;
        break;
      case X:
        if(s[i] == '1') now = Z;
        else { over = true; goto EXIT; }
        break;
      case Y:
        if(s[i] == '0') now = X;
        else { over = true; goto EXIT; }
        break;
      case Z:
        if(s[i] == '1') now = B;
        else now = W;
        break;
      case W:
        if(s[i] == '1') now = Y;
        else now = B;
        break;
      case B:
        if(s[i] == '1') now = X;
        else now = Y;
        break;
      }
    }
  EXIT:;
    if(over || now != B) {
      cout << "No" << endl;
    }
    else {
      cout << "Yes" << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1180
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
  static InputReader in;
  static PrintWriter out;




  static class Solution {
    void solve() throws IOException {
      StringBuilder sb = new StringBuilder(in.next());
      sb.reverse();
      out.println(sb);
//      End solve()
    }
//    End Solution
}


  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}


  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }

    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }

    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken());
    }

    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }

    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }

  }

}

Measured memory_bytes: 24160
#include <stdio.h>

int calc(int *h,int N,int c){
	int i;
	int sum=0;
	int connect=0;
	
	for(i=0;i<N;i++){
		sum+=h[i];
	}
	if(sum==0)	return c;
	
	for(i=0;i<N;i++){
		if(h[i]>0 && connect==0){
			connect=1;
			c++;
			h[i]--;
		}else if(h[i]==0 && connect==1){
			connect=0;
		}else if(h[i]>0 && connect==1){
			h[i]--;
		}
	}
	
	calc(h,N,c);
}

int main(){
	int N;
	int i;
	
	scanf("%d",&N);
	
	int h[N];
	
	for(i=0;i<N;i++){
		scanf("%d",&h[i]);
	}
	
	printf("%d",calc(h,N,0));
	
	return 0;
}

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

signed main(){
	int n, a;
	scanf("%lld%lld", &n, &a);
	printf("%lld\n", n-a+1);
	return 0;
}






Measured memory_bytes: 256
package main

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

func aButtons(a, b int32) int32 {

    sum := int32(0)
    if a > b {
        sum += a
        a--
    } else {
        sum += b
        b--
    }

    if a > b {
        sum += a
        a--
    } else {
        sum += b
        b--
    }
    return sum
}

func main() {
    reader := bufio.NewReaderSize(os.Stdin, 1024 * 1024)

    arTemp := strings.Split(readLine(reader), " ")

    a, err := strconv.ParseInt(arTemp[0], 10, 64)
    checkError(err)

    b, err := strconv.ParseInt(arTemp[1], 10, 64)
    checkError(err)

    res := aButtons(int32(a), int32(b))
    fmt.Println(res)
}

func readLine(reader *bufio.Reader) string {
    str, _, err := reader.ReadLine()
    if err == io.EOF {
        return ""
    }

    return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
    if err != nil {
        panic(err)
    }
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
const int MAXM = 4e2 + 5;
const int MAXN = 26 + 5;
const int inf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;

int n=26, m;
int c[MAXN];
int a[MAXM][MAXN];

int p[MAXM];
set<int> idx[MAXN];
int ans;

void init(void)
{
	for(int i=1; i<=n; ++i)
	{
		idx[i].clear();
		idx[i].insert(0);
		idx[i].insert(m+1);
	}
	
	for(int k=1; k<=m; ++k)
		idx[ p[k] ].insert(k);
}

int recalc(register int pos, register int x)
{
	register int old = p[pos];
	if(old == x) return ans;
	
	register int res = ans;
	
	idx[old].erase(pos);
	
	set<int>::iterator it = idx[old].upper_bound(pos);
	register int nxt = *it;
	register int lst = *(--it);
	
	res -= (pos - lst) * c[old] * (nxt - pos) + a[pos][old];
	
	it = idx[x].upper_bound(pos);
	nxt = *it;
	lst = *(--it);
	
	res += (pos - lst) * c[x] * (nxt - pos) + a[pos][x];
	
	idx[x].insert(pos);
	
	p[pos] = x;
	return res;
}

int main(void)
{
	srand(time(0));
	
	scanf("%d",&m);
	for(int i=1; i<=n; ++i) scanf("%d",&c[i]);
	for(int i=1; i<=m; ++i)
		for(int j=1; j<=n; ++j)
			scanf("%d",&a[i][j]);
	
	static int lst[MAXN];
	
	ans = 0;
	for(int k=1; k<=m; ++k)
	{
		int mx = -inf;
		int mxi = -1;
		for(int i=1; i<=n; ++i)
		{
			int res = a[k][i];
			for(int j=1; j<=n; ++j) if(j!=i)
				res -= c[j] * (k-lst[j]);
			
			if(mxi==-1 || mx < res)
				mxi = i, mx = res;
		}
		lst[mxi] = k;
		
		ans += mx;
		p[k] = mxi;
	}
	
	init();
	
	static int pp[MAXM];
	static int qq[MAXM];
	
	for(int i=1; i<=m; ++i) pp[i] = i;
	for(int i=1; i<=n; ++i) qq[i] = i;
	
	register int T = 700;
	while(T--)
	{
		random_shuffle(pp+1,pp+m+1);
		
		for(int i=1; i<=m; ++i)
		{
			random_shuffle(qq+1,qq+n+1);
			for(int j=1; j<=n; ++j)
			{
				int pos = pp[i];
				int x = qq[j];
				
				int old = p[pos];
				int res = recalc(pos, x);
				if(res < ans) recalc(pos, old);
				else ans = res;
			}
		}
	}
	
	for(int i=1; i<=m; ++i) printf("%d\n",p[i]);
	return 0;
}

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

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

        for(int i = 0; i < 2; i++){
            String line = br.readLine();
            scores[i] = getScore(line);
        }

        int result;
        if(scores[0] == scores[1]){
            result = scores[0];
        }else{
            result = (scores[0] < scores[1])? scores[1] : scores[0];
        }

        System.out.println(result);
    }

    public static int getScore(String line){
        String[] scores = line.split(" " , 4);
        int score = 0;

        for(int i = 0; i < 4; i++){
            score += Integer.valueOf(scores[i]);
        }

        return score;
    }
    
}

Measured memory_bytes: 24424
use whiteread::parse_line;

fn main() {
    let s: String = parse_line().unwrap();
    let mut iter = s.chars();
    let mut idx_z = 0;
    let mut cnt = 0;

    while let Some(c) = iter.next() {
        if c == 'Z' {
            idx_z = cnt;
        }
        cnt += 1;
    }
    let len = idx_z - s.chars().position(|x| x == 'A').unwrap() + 1;
    println!("{}", len);
}


Measured memory_bytes: 2348
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
int N,K;
int v[100];
int Solve(int l,int r){
    int opCount=0;
    int sum=0;
    vector<int> minus;
    for(int i=0;i<l;i++){
        sum+=v[i];
        opCount++;
        if(v[i]<0){
            minus.push_back(v[i]);
        }
    }
    for(int i=r;i<N;i++){
        sum+=v[i];
        opCount++;
        if(v[i]<0){
            minus.push_back(v[i]);
        }
    }
    if(opCount>K){
        return -1;
    }
    sort(minus.begin(),minus.end());
    for(int i=0;opCount<K && i<minus.size();opCount++,i++){
        sum-=minus[i];
    }
    return sum;
}
int main(){
    cin>>N>>K;
    for(int i=0;i<N;i++){
        cin>>v[i];
    }
    int ans=0;
    for(int l=0;l<=N;l++){
        for(int r=l;r<=N;r++){
            ans=max(ans,Solve(l,r));
        }
    }

    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
// Example program
#include <iostream>
#include <string>
using namespace std;

int main()
{
    char* ST = "CODEFESTIVAL2016";
    string s;
    int change = 0;
    int i;
    
    cin >> s;
    for (i=0; i<16; i++) {
        if (s.c_str()[i] != ST[i]) change++;
    }
    
    cout << change << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0) {
				break;
			}

			int sum = 0, minScore = 1000, maxScore = 0;
			for (int i = 0; i < n; i++) {
				int tmp = scanner.nextInt();
				sum += tmp;
				minScore = Math.min(minScore, tmp);
				maxScore = Math.max(maxScore, tmp);
			}

			System.out.println((sum - minScore - maxScore) / (n - 2));
		}
		scanner.close();
	}
}

Measured memory_bytes: 20944
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define deb(x) cout<<#x<<" = "<<x<<"\n";
#define F first
#define S second
 
signed main()
{
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//#endif
	/************************************/
	
	int n; cin>>n;
	int sum = 0;
	int a[n];
	for(int i=0; i<n; i++)
	{
		cin>>a[i];
		sum += a[i];
	}
	int ans = sum+sum;
	int pre = 0;
	for(int i=0; i<n-1; i++)
	{
		pre += a[i];
		sum -= a[i];
		ans = min(ans, abs(sum - pre));
	}
	cout<<ans<<"\n";
	
	
	
	
}

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

int main( void )
{
    int a, b;
    cin >> a >> b;
    if ( a + b < 10 )
    {
        cout << a + b << endl;
    }
    else
    {
        cout << "error" << endl;
    }

    return 0;
}


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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> inline istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> inline ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

template<typename T> inline T min(vector<T>& v) {return *min_element(v.begin(), v.end());}

template<typename T> inline T max(vector<T>& v) {return *max_element(v.begin(), v.end());}

template<typename T> inline void sort(vector<T>& v) {sort(v.begin(), v.end());}

template<typename T, typename Function> inline void sort(vector<T>& v, Function func) {sort(v.begin(), v.end(), func);}

template<typename T> inline void rsort(vector<T>& v) {sort(v.rbegin(), v.rend());}

template<typename T> inline void reverse(vector<T>& v) {reverse(v.begin(), v.end());}

template<typename T> inline void unique(vector<T>& v) {v.erase(unique(v.begin(), v.end()), v.end());}

template<typename T> inline void nth_element(vector<T>& v, int n) {nth_element(v.begin(), v.begin() + n, v.end());}

template<typename T> inline bool next_permutation(vector<T>& v) {return next_permutation(v.begin(), v.end());}

template<typename T> inline int find(vector<T>& v, T t) {return find(v.begin(), v.end(), t) - v.begin();}

template<typename T> inline int in(vector<T> v, T t) {return find(v, t) != (int)v.size();}

template<typename T> inline int lower_bound(vector<T>& v, T t) {return lower_bound(v.begin(), v.end(), t) - v.begin();}

template<typename T> inline int upper_bound(vector<T>& v, T t) {return upper_bound(v.begin(), v.end(), t) - v.begin();}

template<typename T> inline T accumulate(const vector<T>& v, function<T(T, T)> func = plus<T>()) {return accumulate(v.begin(), v.end(), T(0), func);}

template<typename T> inline void adjacent_difference(vector<T>& v) {adjacent_difference(v.begin(), v.end(), v.begin());}

template<typename T> inline void adjacent_difference(vector<T>& v, vector<T>& u) {adjacent_difference(v.begin(), v.end(), u.begin());}

template<typename T> inline void partial_sum(vector<T>& v, vector<T>& u) {partial_sum(v.begin(), v.end(), u.begin());}

template<typename T> inline T inner_product(vector<T>& v, vector<T>& u) {return inner_product(v.begin(), v.end(), u.begin(), T(0));}

template<typename T, typename Function> inline int count_if(vector<T> v, Function func) {return count_if(v.begin(), v.end(), func);}

template<typename T, typename Function> inline void remove_if(vector<T>& v, Function func) {v.erase(remove_if(v.begin(), v.end(), func), v.end());}

template<typename T, typename Function> inline bool any_of(vector<T> v, Function func) {return any_of(v.begin(), v.end(), func);}

template<typename T> inline vector<T> subvector(vector<T>& v, int a, int b) {return vector<T>(v.begin() + a, v.begin() + b);}

int main() {
  int64_t a, b, c;
  cin >> a >> b >> c;
  cout << min({a % 2 * b * c, b % 2 * a * c, c % 2 * a * b}) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a;
	char c[10];
	char b[100][11];
	int check[100];
	for(int i=0;i<100;i++)
		check[i]=0;
	int n;
	int count=0;
	cin>>a;
	for(int i=0;i<a.size();i++){
		c[i]=a[i];
	}
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<10;j++){
			cin>>b[i][j];
		}
	}
	for(int i=0;i<n;i++){
		int s=0;
		for(int k=0;k<10;k++){
		for(int j=0;j<a.size();j++){
			if(b[i][(k+j)%10]==c[j]){
				s++;
				if(s==a.size()){
					if(check[i]==1)
						count--;
					count++;
					check[i]=1;
				}
			}
			else
				s=0;
		}
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 1200
h, w = map(int,input().split())
c = [list(map(int,input().split())) for i in range(10)]
a = [list(map(int,input().split())) for i in range(h)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            if i == j:continue
            c[i][j] = min(c[i][k] + c[k][j], c[i][j])

mp = 0
for i in range(h):
    for j in range(w):
        if a[i][j] == -1:continue
        mp += c[a[i][j]][1]
print(mp)

Measured memory_bytes: 41564
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double db;
typedef vector<ll> VI;
typedef vector<pair<ll,ll> > VII;
typedef map<ll,ll> mll;
typedef pair<ll,ll> pll;
//
#define M 1000000007
#define INF (ll)0x3f3f3f3f3f3f3f3f
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define itr iterator
#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
void fileioe(){
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout); 
	freopen("error.txt","w",stderr);
}

void error_out() { cerr << endl; }
template <typename Head, typename... Tail>
void error_out(Head H, Tail... T) {
  cerr << " " << H;
  error_out(T...);
}
void time_elapsed(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}
#ifndef ONLINE_JUDGE
#define error(...) cerr << "[" << #__VA_ARGS__ << "]:", error_out(__VA_ARGS__)
#define fioe() fileioe()
#define time() time_elapsed()
#else
#define error(...) 1
#define fioe() 1
#define time() 1
#endif
ll ways(ll h){
	if(h==1){
		return 1;
	}
	ll small=ways(h/2);
	return 2*small+1;
}
//
int main()
{
	GO
	//fioe();
	ll h;
	cin>>h;
	cout<<ways(h)<<endl;
	time();
	return 0;
}

Measured memory_bytes: 256
S = list(input())
S.append('R')
counter = 1
Num = [0]*len(S)
for i in range(len(S)-1):
  if S[i] == S[i+1]:
    counter += 1
  elif S[i] == 'R' and S[i+1] == 'L':
    if counter % 2 == 1:
      Num[i] += (counter//2) + 1
      Num[i+1] += counter // 2
      counter = 1
    else:
      Num[i] += counter // 2
      Num[i+1] += counter // 2
      counter = 1
  else:
    if counter % 2 == 1:
      Num[i-counter+1] += (counter//2) + 1
      Num[i-counter] += counter//2
      counter = 1
    else:
      Num[i-counter+1] += counter//2
      Num[i-counter] += counter//2
      counter = 1
Num.pop()
print(*Num)


Measured memory_bytes: 7092
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    B = inputList()
    
    ans = 0
    for i, val in enumerate(A):
        if i == N:
            break
        if B[i] <= val:
            ans += B[i]
        else:
            tmp = B[i] - val
            ans += val
            if i-1 <= N-1:
                if tmp <= A[i+1]:
                    ans += tmp
                    A[i+1] -= tmp
                else:
                    ans += A[i+1]
                    A[i+1] = 0
                    
    print(ans)
            	
if __name__ == "__main__":
	main()


Measured memory_bytes: 86748
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h> 
using namespace std;

typedef long long ll;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0) 
#define rep(pp,nn) for (int ii = pp; ii < nn; ++ii)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>

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");}

string int_to_string(int x) {
    stringstream ss;
	ss << x;
	string ni = ss.str();
	return ni;
}
int string_to_int(string x) {
	int n;
	stringstream s(x);
	s >> n;
	return n;
}

int64_t power_mod(ll a, ll b, ll mo) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = (ans % mo * a % mo) % mo;
		}
		a = (a % mo * a % mo) % mo;
		b /= 2;
	}
	return ans;
}
int64_t POW(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = ans * a;
		}
		a = a * a;
		b /= 2;
	}
	return ans;
}

vector<int64_t> INVERSE(int64_t nn, int64_t mo) {
	vector<int64_t> inv(nn + 1);
	vector<int64_t> mul(nn + 1);
	inv[0] = 1;
    inv[1] = 1;
	for (ll i = 2; i <= nn; ++i) {
		inv[i] = (mo - (mo / i) * inv[mo % i] % mo) % mo; 
	}
	mul[0] = 1;
	for (int i = 1; i <= nn; ++i) {
		mul[i] = (mul[i - 1] * inv[i]) % mo;
	}
	return mul;
}

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


int main() {
	int n, k;
	cin >> n >> k;
	vector<int64_t> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	for (int i = k; i < n; ++i) {
		if (v[i] > v[i - k]) {
			cout << "Yes\n";
		}else {
			cout << "No\n";
		}
	}
		
}














Measured memory_bytes: 4844
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define FASTIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define inf 1e9
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mod 1000000007
#define pb push_back
#define all(s) s.begin(),s.end()
#define pie 3.14159265358979323846
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=b-1;i>=a;i--)
#define gcd __gcd
#define con continue
#define pii pair<ll,ll>
const ll N=5e5+6;
ll seg[4*N];
void build(ll s,ll e,ll idx,ll a[]){
    if(s==e){
       //cout<<s<<" ";
       seg[idx]=a[s];
       return;
    }
    ll mid=(s+e)/2;
    build(s,mid,2*idx+1,a);
    build(mid+1,e,2*idx+2,a);
    seg[idx]=seg[2*idx+1]+seg[2*idx+2];
    return ;
}
void update(ll s,ll e,ll idx,ll pos,ll val){
    if(s==e){
       seg[idx]=val;
       return;
    }
    ll mid=(s+e)/2;
    if(pos<=mid)
    update(s,mid,2*idx+1,pos,val);
    else
    update(mid+1,e,2*idx+2,pos,val);
    seg[idx]=seg[2*idx+1]+seg[2*idx+2];
    return ;
}
ll query(ll s,ll e,ll idx,ll l,ll r){
   if(s>=l&&e<=r)return seg[idx];
   if(s>r||e<l)return 0;
   ll mid=(s+e)/2;
   return query(s,mid,2*idx+1,l,r)+query(mid+1,e,2*idx+2,l,r);
}
signed main(){
    FASTIO;
    ll tt=1;
    //cin>>tt;
    while(tt--){
         ll n,q,x,l,r;cin>>n>>q;
         ll a[n];
         for(ll i=0;i<n;i++){
            cin>>a[i];
         }
         build(0,n-1,0,a);
         while(q--){
            cin>>x;
            if(x){
               cin>>l>>r;
               cout<<query(0,n-1,0,l,r-1)<<"\n";
            }
            else{
               cin>>l>>x;
               a[l]+=x;
               update(0,n-1,0,l,a[l]);
            }
         }
    }
}


Measured memory_bytes: 16452
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
    static int[][] surface;
    public static void main (String[] args) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	surface = new int[8][8];
	String line;
	while ((line = br.readLine()) != null) {
	    for (int i = 0; i < 8; i++) {
		for (int j = 0; j < 8; j++) {
		    surface[i][j] = Integer.parseInt(line.substring(j, j+1));
		}
		line = br.readLine();
	    }
	    search();
	}
    }
    
    static int[] searchBlack () {
	int width = 0, height = 0;
	while (surface[height][width] == 0) {
	    width++;
	    if (width == 8) {
		width = 0;
		height++;
	    }
	}
	int[] data = {height, width};
	return data;
    }
    
    static int countBlack (int[] initialB) {
	int count = 0;
	int height = initialB[0];
	int width = initialB[1];
	while (width < 8 && surface[height][width] == 1) {
	    count++;
	    width++;
	}
	return count;
    }

    static void search () {
	int[] data = searchBlack();
	int height = data[0];
	int width = data[1];
	int count = countBlack(data);
	if (count == 1) {
	    if (isB(height, width)) {
		System.out.println("B");
	    } else if (isD(height, width)) {
		System.out.println("D");
	    } else if (isF(height, width)) {
		System.out.println("F");
	    }
	} else if (count == 2) {
	    int b = surface[height+1][width];
	    int c = surface[height+1][width+1];
	    if (b == 1 && c == 1) {
		System.out.println("A");
	    } else if (b == 0 && c == 1) {
		System.out.println("E");
	    } else if (b == 1 && c == 0) {
		System.out.println("G");
	    }
	} else if (count == 4) {
	    System.out.println("C");
	}
    }

    static boolean isB (int height, int width) {
	if (height > 4) {
	    return false;
	}
	if (surface[height+3][width] == 1) {
	    return true;
	} else {
	    return false;
	}
    }

    static boolean isD (int height, int width) {
	if (width == 0) {
	    return false;
	}
	if (surface[height+1][width-1] == 1) {
	    return true;
	} else {
	    return false;
	}
    }

    static boolean isF (int height, int width) {
	if (width == 7) {
	    return false;
	}
	if (surface[height+1][width+1] == 1) {
	    return true;
	} else {
	    return false;
	}
    }
}

Measured memory_bytes: 24400
#include <bits/stdc++.h>
using namespace std;
set<string> s;
set<string>::iterator it;
int main()
{
    string str;
    int k;
    cin >> str >> k;

    for (int i = 0; i < str.size(); i++)
    {
        for (int j = 1; j <= 5; j++)
        {
            s.insert(str.substr(i, j));
        }
    }

    for (int i = 1; i <= k - 1; i++)
        s.erase(s.begin());
    cout << (*(s.begin())) << endl;

    return 0;
}

Measured memory_bytes: 1664
s=input()
l=len(s)
for i in range(l):
    if(i%2!=1):
        if(s[i]=='R' or s[i]=='U' or s[i]=='D'):
            continue
        else:
            print('No')
            exit()
    else:
        if(s[i]=='L' or s[i]=='U' or s[i]=='D'):
            continue
        else:
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int R, G;
	cin >> R >> G;

	G *= 2;
	cout << G - R;

	return 0;
}


Measured memory_bytes: 3576
const log = console.log;

const parseLines = (s: string) => s.trim().split("\n");
const parseSpaceSeparated = (line: string) => line.trim().split(" ");
const parseDecimalInt = (s: string) => parseInt(s);
const parseSpaceSeparatedDecimalInt = (line: string) =>
  parseSpaceSeparated(line).map(parseDecimalInt);

// ----

function Main(input: string): void {
  const lines = parseLines(input);
  const [t, a] = parseSpaceSeparatedDecimalInt(lines[1]);
  const h = parseSpaceSeparatedDecimalInt(lines[2]);

  const temperatureArray = h.map(h => t - h * 0.006);
  const len = temperatureArray.length;
  let minDistance = Infinity;
  let index = -1;

  for (let i = 0; i < len; i += 1) {
    const distance = Math.abs(temperatureArray[i] - a);

    if (distance > minDistance) continue;

    minDistance = distance;
    index = i;
  }

  log(index + 1);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define msg(x) debug() << x
#define int long long
const int xx = 1e8;
const int mod = 1e9 + 7;
signed main(){
  ios::sync_with_stdio(false);cin.tie(0);

  int  x, y;
  cin >> x >> y;
  int ans = 0;

  if(x==1) ans += 3e5;
  else if(x==2) ans += 2e5;
  else if(x==3) ans += 1e5;

  if(y==1) ans += 3e5;
  else if(y==2) ans += 2e5;
  else if(y==3) ans += 1e5;

  if(x ==1 && y==1) ans += 4e5;

  cout << ans << '\n';


}

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

#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define fall(i, a, b) for (int i = a; i < b; i++)
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ed cout << "ed";
ll MOD = 1e9 + 7;
ll MOD1 = 1e9 + 123;
ll MOD2 = 1e9 + 321;

int main()
{
    fio;
    ll t, l, a, n, q, k, i, m, c, u, f, j, p, r, x, y, s, b, d;

    vector<int> v(100000, 0);
    for (i = 1; i <= 100; i++)
        for (j = 1; j <= 100; j++)
            for (k = 1; k <= 100; k++)
                v[i * i + j * j + k * k + i * j + k * j + i * k]++;
    cin >> n;
    for (i = 1; i <= n; i++)
        cout << v[i] << endl;
    return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n;
int a[11];
int si[11];
int exep = 0;

void solve(int k)
{
	if (k >= 0) {
		int temp = si[k];
		si[k] = -1;
		solve(k - 1);

		si[k] = 0;
		solve(k - 1);

		si[k] = 1;
		solve(k - 1);
		si[k] = temp;
	}
	else {
		int ch = 1;
		for (int i = 0;i < n;i++) {
			if ( (a[i] + si[i]) % 2 == 0) ch = 0;
		}
		exep += ch;
	}
}

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

	solve(n-1);

	cout << pow(3, n) - exep << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
//see answer
int main() {
	long long N, K;
	cin >> N >> K;
	vector<long long> A(N), F(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> F[i];
	sort(A.begin(), A.end());
	sort(F.begin(), F.end(), greater<long long>());
	long long MIN = 0, MAX = A[N - 1] * F[0];
	while (MIN != MAX) {
		long long MID = MIN + (MAX - MIN) / 2ll;
		long long cost = 0;
		for (int i = 0; i < N; i++) cost += max(0ll, (A[i] * F[i] - MID + F[i] - 1) / F[i]);
		if (cost <= K) MAX = MID;
		else MIN = MID + 1;
	}
	cout << MIN << endl;
	return 0;
}

Measured memory_bytes: 6408