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

int main() {
	ll n, m;
	cin >> n >> m;
	vector<int>a(m);
	for (int i = 0; i < m; i++)cin >> a.at(i);
	ll sum = 0;
	for (int i = 0; i < m; i++) {
		sum += a.at(i);
	}
	ll x = -1;
	ll ans = max(x, n - sum);
	cout << ans << endl;
}

Measured memory_bytes: 3632
N = int(input())
S = input()
Sr = []

al = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

for i in range(len(S)):
  n = al.index(S[i])
  Sr.append(al[(1 + n + N) % 26 - 1])
  
print(''.join(Sr))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip> // 文字幅の指定 setw(int), 詰めたい文字の指定 setfill(char)
#include <algorithm> // sort
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define p(x) cout << (x) << endl
#define FOR(i,r,n) for(ll i=(ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n); i>=r; i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) REP(i,0,n)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pb push_back

// 定義する？→左揃えで0埋め
// cout << setfill('0') << left << setw(4) << 12; // "0012"
// http://marycore.jp/prog/cpp/padding-left-right-zero/

const int inf = (int)1e9;
const ll INF = (ll)1e18;

// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

ll gcd (ll a, ll b) {
	while (b > 0) {
		ll t = a % b;
		a = b, b = t;
	}
	return a;
}

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

bool is_prime (ll n) {
		if (n < 2) return false;
		else if (n == 2) return true;
		else if (n % 2) return false;
		
		double sqrtn = sqrt(n);
		for (ll i = 3; i < sqrtn; i += 2) {
			if (n % i == 0) return false; 
		}
		return true;
}

ll ctoi(char c) {
	return (ll)(c - 48);
}

ll n, k, cnt=0, ans=0;
string s,t;

// ==================== template ============================

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

	int x; cin >> x;
	if (x == 1 || x == 2 || x == 3) {
		p(1); return 0;
	}
	int mx = 1;
	for (int b = 2; b <= sqrt(x); b++) {
		int p = 2;
		while (pow(b, p) <= x) {
			p++;
		}
		mx = pow(b, p-1) > mx ? pow(b, p-1) : mx;
	//	cout << "b:" << b << endl;
	//	cout << "p:" << p-1 << endl;
	//	cout << pow(b, p-1) << endl;
	//	p(mx);
	}
	p(mx);

}



Measured memory_bytes: 512
import time
import random
def score(a,c,s,d):
  l=[-1 for i in range(26)]
  r=0
  for i in range(d):
    l[a[i]]=i
    r+=s[i][a[i]]
    for j in range(26):
      r-=c[j]*(i-l[j])
  return r
  
st=time.time()
d=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(d):
  s.append(list(map(int,input().split())))

ans=[]
l=[-1 for i in range(26)]
ld=[]
for i in range(d):
  ms=-10**9
  mt=None
  for j in range(26):
    js=c[j]*(i-l[j])+s[i][j]
    if ms<js:
      ms=js
      mt=j
  l[mt]=i
  ans.append(mt)
  ld.append([l[mt],d])
  if l[mt]>=0:
    ld[l[mt]][1]=i

os=score(ans,c,s,d)
nt=st
rate=100
while nt-st<1.50:
  nt=time.time()
  ri=random.randint(0,d-1)
  rj=random.randint(0,25)
  na=[ans[i] for i in range(d)]
  na[ri]=rj
  ns=score(na,c,s,d)
  if ns>os:
    os=ns
    ans=na


for i in ans:
  print(i+1)

Measured memory_bytes: 83836
import java.util.Scanner;
public class Main {
   public static void main(String[] args){
     Scanner scanner = new Scanner(System.in);
     for(int i=1;i>0; i++){
          int H = scanner.nextInt();
          int W = scanner.nextInt();
          if(H==0&&W==0)break;
          for(int j=1;j<=H; j++){
              for(int k=1;k<=W; k++){
              System.out.print("#");
              }
              System.out.println();
          }
          System.out.println();
   }   
}
}

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


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

for(int i=0;i<=100000;i++){

  if(int(i*0.1)==b&&int(i*0.08)==a) {
    cout<<i<<endl;
    return 0;
  }
}

cout<<-1<<endl;
}


Measured memory_bytes: 384
#include <queue>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
struct edge {
	int to, cost, lim;
};
struct state {
	int pos; double cost; int prev, speed;
};
bool operator<(const state& s1, const state& s2) {
	return s1.cost < s2.cost;
}
int n, m, s, g, a, b, c, l;
int main() {
	while (cin >> n >> m, n | m) {
		cin >> s >> g; s--, g--;
		vector<vector<edge> > G(n);
		for (int i = 0; i < m; i++) {
			cin >> a >> b >> c >> l; a--, b--;
			G[a].push_back(edge{ b, c, l });
			G[b].push_back(edge{ a, c, l });
		}
		vector<vector<vector<double> > > dist(n, vector<vector<double> >(n, vector<double>(31, 1.0e+10))); dist[s][s][0] = 0;
		priority_queue<state> que; que.push(state{ s, 0, s, 0 });
		while (!que.empty()) {
			state u = que.top(); que.pop();
			for (int i = -1; i <= 1; i++) {
				int sp = u.speed + i;
				if (1 <= sp && sp <= 30) {
					for (edge e : G[u.pos]) {
						if (sp > e.lim || u.prev == e.to) continue;
						double cost = dist[u.pos][u.prev][u.speed] + 1.0 * e.cost / sp;
						if (dist[e.to][u.pos][sp] > cost) {
							dist[e.to][u.pos][sp] = cost;
							que.push(state{ e.to, -cost, u.pos, sp });
						}
					}
				}
			}
		}
		double ret = 1.0e+10;
		for (int i = 0; i < n; i++) ret = min(ret, dist[g][i][1]);
		if(ret < 1.0e+9) cout << fixed << setprecision(15) << ret << endl;
		else cout << "unreachable" << endl;
	}
	return 0;
}

Measured memory_bytes: 3840
package main

import (
	"fmt"
	"math"
)

func main() {
	var a int
	fmt.Scan(&a)

	num := 0
	count := 0
	for i := 0; i < a; i++ {
		num++
		b := int(math.Log10(float64(num))) + 1
		if b%2 == 1 {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
// make pair, tuple
// __gcd(int, int)
// bool isPrime(int n){
//       if(n <= 1)return false;
//       if(n <= 3)return true;
//       if(n % 2 == 0 || n % 3 == 0)return false;
//       for(int i = 5;i * i <= n;i += 6){
//             if(n % i == 0 || n % (i + 2) == 0)return false;
//       }
//       return true;
// }
// int countSubString(string s, string temp){
//       int ans = 0;
//       size_t f = s.find(temp);
//       while(f != string::npos){
//             ans++;
//             f = s.find(temp, f + 1);
//       }
//       return ans;
// }

int main(){
    int n,k,q;cin >> n >> k >> q;
    int d = q - k;
    map<int, int> m;
    for(int i = 0;i < q;i++){
        int t;cin >> t;
        m[t]++;
    }
    for(int i = 0;i < n;i++){
        if(m[i + 1] > d)cout << "Yes\n";
        else cout << "No\n";
    }
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  // 
  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string s;cin>>s;
  int start_index, end_index;
  REP(i,(int)s.size()){
    if(s[i]=='A'){
      start_index=i;
      break;
    }
  }
  for(int i=(int)s.size()-1;i>=0;i--){
    if(s[i]=='Z'){
      end_index=i;
      break;
    }
  }
  P(end_index-start_index+1);
  return 0;
}


Measured memory_bytes: 720
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val W = readLine()!!.split(" ").map(String::toInt)
    var min = Integer.MAX_VALUE
    for (T in 1 until N) {
        val S1 = W.subList(0, T).sum()
        val S2 = W.subList(T, W.size).sum()
        min = Math.min(Math.abs(S1 - S2), min)
    }
    println(min)
}

Measured memory_bytes: 37748
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		////////////////////////////////////
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] alphabet = new int[26];
		int[] memory = new int[k];
		String s;
		char c;
		int m;
		int x;
		int y;
		int cnt = 0;
		boolean flag = true;
		
		for (int i=0; i<n; i++) {
			s = sc.next();
			c = s.charAt(0);
			m = (int) (c - 'A');
			alphabet[m]++;
		}
		
		
		while (flag) {
			Arrays.sort(alphabet);
			x=0;
			y=0;
			flag = false;
			for (int i=25; i>=0; i--) {
				if (alphabet[i]>0) {
					memory[y++]=i;
					x++;
					if (x==k) {
						flag = true;
						cnt++;
						for (int mem: memory) {
							alphabet[mem]--;
						}
						break;
					}
				}
			}
		}
		
		System.out.println(cnt);
		
		////////////////////////////////////
		sc.close();
	}
}

Measured memory_bytes: 18688
n,a,b=map(int,input().split())
x=list(map(int,input().split()))
c=0
for i in range(n-1):
  if (x[i+1]-x[i])*a<b:
    c=c+(x[i+1]-x[i])*a
    i=i+1
  else:
    c=c+b
    i=i+1
print(c)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
int main() {
     int n,k;
     cin>>n>>k;
     long long int a[n];
     for(int i=0;i<n;i++)cin>>a[i];
     for(int i=k;i<n;i++)
     {
         if(a[i]>a[i-k])cout<<"Yes\n";
         else cout<<"No\n";
     }}

Measured memory_bytes: 5164
INF = 10 ** 18
n = gets.to_i
nums = gets.split.map(&:to_i)
if nums.any? { |num| num == 0 }
  puts 0
  exit
end
tmp = nums.shift
nums.each do |num|
  tmp *= num
  if tmp > INF
    puts -1
    exit
  end
end
puts tmp


Measured memory_bytes: 21568
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int total = 700;

		Scanner scanner = new Scanner(System.in);

		String string = scanner.next();
		string = string.replaceAll("x", "");

		total = 700 + 100*string.length();

		System.out.println(total);

		scanner.close();

	}

}


Measured memory_bytes: 22996
#include<stdio.h>  
#include<string.h>  
#include<math.h>  
#include<algorithm>  
using namespace std;  
int main()  
{  
    long long n, a, b, x1, x2;  
    scanf("%lld%lld%lld", &n, &a, &b);  
    x1=a;x2=b;  
    for(int i=0;i<n-1;i++)  
    {  
        scanf("%lld%lld", &a, &b);  
        long long temp=x1/a;  
        if(x1%a!=0)  
            temp++;  
        long long temp2=x2/b;  
        if(x2%b!=0)  
            temp2++;  
        long long m=max(temp, temp2);  
        x1=a*m;x2=b*m;  
    }  
    printf("%lld\n", x1+x2);  
    return 0;  
}   
       	
  
 

Measured memory_bytes: 256
N = int(input())
S = input()

top, temp = 0, 0
for i in range(N) :
    if S[i] == "(" :
        temp += 1
    else :
        if temp > 0 :
            temp -= 1
        else :
            top += 1

ans = "(" * top + S + ")" * temp
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
int ihp, mhp;
int p;
vi portion, dmg; 
vector<vi> fld;
int dp[1111][4444];

bool solve()
{
	dp[0][0] = ihp;
	REP(i, dmg.size())
	{
		REP(j, 1 << p)
		{
			if (dp[i][j] == 0) continue;
			chmax(dp[i + 1][j], dp[i][j] - dmg[i]);
			REP(k, p)
			{
				if (!((j >> k) & 1))
				{
					chmax(dp[i][j | (1 << k)], min(mhp, dp[i][j] + portion[k]));
				}
			}
		}
	}
	return dp[dmg.size()][(1 << p) - 1] > 0;
}


int main()
{
	while (cin >> ihp >> mhp, ihp)
	{
		portion.clear();
		dmg.clear();
		fld.clear();
		MS(dp, 0);
		int h, w;
		cin >> h >> w;
		fld.resize(h, vi(w));
		vs fldc(h);
		REP(i, h) cin >> fldc[i];
		int t; cin >> t;
		int mp[26];
		REP(i, t)
		{
			char c; int d;
			cin >> c >> d;
			mp[c - 'A'] = d;
		}
		REP(i, h)REP(j, w)
		{
			fld[i][j] = mp[fldc[i][j] - 'A'];
		}

		int tx = 0, ty = 0;
		int s; cin >> s;
		REP(i, s)
		{
			char c; int d;
			cin >> c >> d;
			pii tmp;
			if (c == 'U') tmp = pii(-1, 0);
			if (c == 'D') tmp = pii(1, 0);
			if (c == 'L') tmp = pii(0, -1);
			if (c == 'R') tmp = pii(0, 1);
			REP(j, d)
			{
				tx += tmp.first, ty += tmp.second;
				dmg.push_back(fld[tx][ty]);
			}
		}
		cin >> p;
		REP(i, p)
		{
			int a; cin >> a;
			portion.push_back(a);
		}
		puts(solve() ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 22372
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
using namespace std;
int main(){
	int n, A, B, m, x[100000], y[100000], c[100000], a[100000], b[100000], amin = 10000000,bmin = 5610000;
	cin >> A >> B >> m;
	for (int i = 0; i < A;i++) { 
		cin >> a[i];
		amin = min(a[i], amin);
	}
	for (int i = 0;i < B;i++) { 
		cin >> b[i];
		bmin = min(bmin, b[i]);
	}
	int sum = amin + bmin;
	for (int i = 0; i < m;i++) {
		cin >> x[i] >> y[i] >> c[i];
		x[i]--;y[i]--;
		sum = min(a[x[i]] + b[y[i]] - c[i], sum);
	}
	cout << sum << endl;
}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		long H = sc.nextLong();
		long W = sc.nextLong();

		long A[] = new long[N];
		long B[] = new long[N];

		for (int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
			B[i] = sc.nextLong();
		}

		int ans = 0;

		for (int i = 0; i < N; i++) {
			if (A[i] >= H && B[i] >= W) {
				ans++;
			}
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 25456
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();

		if ((B-A)%2 == 0) {
			System.out.println("Alice");
		}
		else {
			System.out.println("Borys");
		}

	}

}


Measured memory_bytes: 23764
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

//00:15
fn main(){
    let n: usize = read_as_vec()[0];
    let s = read_as_string().chars().collect::<Vec<char>>();

    let mut stack: Vec<char> = vec![];
    let mut counter = 0;
    for &c in &s{
        if c == '('{
            stack.push('(');
        }else{
            if stack.len() > 0{
                stack.pop();
            }else{
                counter += 1;
            }
        }
    }

    for _ in 0..counter{
        print!("(");
    }

    for &c in &s{
        print!("{}", c);
    }

    for _ in 0..stack.len(){
        print!(")");
    }

    println!("");
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdlib>

#define TRUE 1
#define FALSE 0

int use_num[10];

int get_input(void) {
    int i;
    std::cin >> i;
    if (std::cin.fail()) 
        exit(0);
    return i;
}

int power(int m, int n) {
    int acc = 1;
    for (int i = 0; i < n; i++) {
        acc *= m;
    }
    return acc;
}    

void solve(int weight) {
    for (int i = 9; i >= 0; i--) {
        if (power(2, i) > weight) {
            use_num[i] = FALSE;
        } else {
            use_num[i] = TRUE;
            weight -= power(2, i);
        }
    }
}

void output(void) {
    // find last TRUE elem
    int last;
    for (int i = 0; i <= 9; i++) {
        if (use_num[i] == TRUE) {
            last = i;
        }
    }

    for (int i = 0; i < last; i++) {
        if (use_num[i] != FALSE) {
            std::cout << power(2, i) << ' ';
        }
    }
    if (use_num[last] != FALSE) {
        std::cout << power(2, last);
    }
    std::cout << std::endl;
}

int main(void) {
    int weight;
    while (weight = get_input()) {
        solve(weight);
        output();
    }
    return 0;
}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

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

#ifdef OJ
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#else
#define debug(x)
#define debugv(x)
#endif

#define all(x) (x).begin(), (x).end()
#define rsort(x) sort((x).rbegin(), (x).rend())
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n, e) for (int i = (int)(n); i >= (int)(e); --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << (x) << '\n'; return 0;}while(0)

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

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

void solve() {
    int x; cin >> x;
    int g = gcd(360, x);
    debug(g);
    cout << 360 / g << endl;
}

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int ntest = 1; 
    //cin >> ntest; 
    while(ntest--) solve();

    return 0;
}


Measured memory_bytes: 3608
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] map = new int[2][N];
		int tmpSum;
		int maxSum = 0;
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < N; j++) {
				map[i][j] = sc.nextInt();
			}
		}
		for (int i = 0; i < N; i++) {
			tmpSum = 0;
			for (int j = 0; j < N; j++) {
				if (j <= i) {
					tmpSum += map[0][j];
				}
				if (j >= i) {
					tmpSum += map[1][j];
				}
			}
			maxSum = Math.max(tmpSum,  maxSum);
		}
		System.out.print(maxSum);
	}
}


Measured memory_bytes: 23764
long long a[39][2];i,n,k;main(t){for(;~scanf("%d",&k);++n-2?t=!t:++*a[k+9])for(i=8;n&&++i<30;)a[i][!t]=a[i-k][t]+a[i+k][t];n=!printf("%lld\n",a[k+9][!t]);}

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

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

using namespace std;

int n;
int x[10];
int dp[11][11][11];

string solve(){
  fill_n((int*)dp, 11 * 11 * 11, 0);
  dp[0][0][0] = 1;
  for(int i = 1; i <= 10; ++i){
    int v = x[i - 1];
    rep(j, 11){
      rep(k, v){
        dp[i][j][v] += dp[i - 1][j][k];
      }
    }
    rep(k, 11){
      rep(j, v){
        dp[i][v][k] += dp[i - 1][j][k];
      }
    }
  }
  rep(j, 11){
    rep(k, 11){
      if(dp[10][j][k]){
        return "YES";
      }
    }
  }
  return "NO";
}

int main(){
  cin >> n;
  rep(i, n){
    rep(j, 10){
      cin >> x[j];
    }
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 3144
from itertools import groupby
import numpy as np
N = int(input())
s = groupby(list(input()))
table = []
for key,group in s:
  cnt = 0
  for id,_ in enumerate(group,1):
    cnt = id
  table.append([key,cnt])
#print(table)
if len(table) == 1:
  print(0)
  exit()
B = [0] * (len(table) + 1)
W = [0] * (len(table) + 1)
for i in range(len(table)):
  if table[i][0] == "#":
    B[i+1] += table[i][1]
  else:
    W[i+1] += table[i][1]
B = np.cumsum(np.array(B))
W = np.cumsum(np.array(W)) 
ans = float("inf")
for i in range(len(table)+1):
  ans = min(ans,B[i] + W[-1] - W[i])
print(ans)



Measured memory_bytes: 40220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, w, r;
string s;

int main() {
	cin >> n >> s;
	for (int i = 0; i < s.length(); i++) {
		w += s[i] == 'W';
		r += s[i] == 'R';
	}
	if (w == 0 || r == 0) {
		cout << 0;
		return 0;
	}
	int good = 0;
	for (int i = 0; i < r; i++)
		good += s[i] == 'R';
	cout << r - good;
    return 0;
}


Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001

const int MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint = Fp<MOD>;

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

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int a[40]={0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	cin>>n;
	cout<<a[n]<<endl;
	return 0;
}
//

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 1<<29;
/****** define constant end ********/
ll binary(ll bina, ll k, ll t_ans) {
    ll ans = 0;
    for (ll i = 0; bina > 0; i++) {
        ans = ans + (bina % k) * pow(10, i);
        bina = bina / k;
        t_ans++;
    }
    return t_ans;
}

const int MAX = 10000000;
/****** define variable start ******/
ll n, k;
/******* define variable end *******/
ll solve(){
    cin >> n >> k;
    ll t_ans = 0;
    cout << binary(n, k, t_ans) << endl;
    return 0;
}
int main(){
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    
    return (int)end_solve;
}


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

#define MAXN 100000

using namespace std;

struct POINT {
  int a,b;
};

POINT A[MAXN];

bool compr ( POINT &x, POINT &y )
{
  return x.b < y.b;
}

int func ( int n, int m )
{
  //cout << "testaaaa\n";
  sort(A,A+m, compr );
  int tmp = -1;
  int sum = 0;
  //cout << " testaa\n";

  /*
  for ( int i = 0; i < m; ++i ) {
    cout << A[i].a << " " << A[i].b << "\n";
  }*/

  for ( int i = 0; i < m; ++i )
  {
    if ( A[i].a <= tmp ) continue;
    tmp = A[i].b-1;
    ++sum;
  }

  return sum;
}

int main()
{
  int n,m;

  cin >> n >> m;

  for ( int i = 0; i < m; ++i )
  {
    int tmpa, tmpb;
    scanf("%d%d", &A[i].a, &A[i].b);
  }

  cout << func(n,m) << endl;
}


Measured memory_bytes: 1024
let rec range s t f = if s > t then [] else (f s) :: range (s + 1) t f

let lst = range 1 9 (fun x ->
  range 1 9 (fun y ->
    Printf.sprintf "%dx%d=%d" x y (x*y)))

let _ = List.iter print_endline (List.concat lst)

                                      

Measured memory_bytes: 2308
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

int main(void)
{
    int ans = 0;
    int n;
    
    cin >> n;
    
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, m, k;
	cin >> n >> m >> k;
	ll a[n], b[m];
	zep(i, 0, n)cin >> a[i];
	zep(j, 0, m)cin >> b[j];
	
	set<P> s;
	ll sm = 0;
	s.insert(P(0, 0));
	zep(i, 0, n){
		sm += a[i];
		s.insert(P(-sm, i + 1));
	}
	
	sm = 0;
	ll ans = (*s.lower_bound(P(-k, -INF))).second;
	zep(j, 0, m){
		sm += b[j];
		if(k - sm >= 0){
			ans = max(ans, j + 1 + (*s.lower_bound(P(-(k-sm), -INF))).second);
		}
	}
	print(ans)
	
	return 0;
}

Measured memory_bytes: 19268
// Best practice

#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// #include <functional> // for less

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
// using namespace __gnu_pbds;

// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds;

// #define fbo find_by_order
// #define ook order_of_key

// Code from Here -------------------------------------------------------------------------------


signed main() {
	tezz

	int n;
	cin >> n;
	int a = 100;
	int c = 0;
	while (a < n) {
		a = a + a / 100;
		c++;
	}
	cout << c << endl;

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  int p[20];
  
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  
  int count = 0;
  for (int i = 0; i < n - 2; i++) {
    if (p[i] < p[i + 1] && p[i + 1] < p[i + 2]) {
      count++;
    } else if (p[i] > p[i + 1] && p[i + 1] > p[i + 2]) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
/*
    Created by vasu090 on 19 Apr, 2020
*/
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, a, b) for(auto (i)=a;i<b;i++)
#define list(i, N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define int ll
#define INF 1e18+5
#define mod 1000000007

template<class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int32_t main() {

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

    int n,m; cin >> n >> m;
    vi a(m); list(i,m) cin >> a[i];

    int sm = 0;
    list(i,m) sm += a[i];

    if(n < sm){
        cout << "-1\n"; return 0;
    }


    cout << n-sm << '\n';
    return 0;
}

Measured memory_bytes: 3192
//AtCoder ABC058 A - ι⊥l
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(b-a==c-b?"YES":"NO")<<endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python

from sys import stdin
from math import floor

N, M = (int(wd) for wd in stdin.readline().split())
a = [int(wd) for wd in stdin.readline().split()]

def kouyakusuu(g1, g2):
    if g1 < g2:
        return kouyakusuu(g2, g1)
    if g2 == 0:
        return g1
    return kouyakusuu(g2, g1 % g2)

def koubaisuu(g1, g2):
    return (g1 * g2) // kouyakusuu(g1, g2)




def solve2(N, M, a):
    ret = 1
    cnt2 = 1
    while a[0] % (2**cnt2) == 0: cnt2 += 1
    ng = 2 ** cnt2
    cnt2 -= 1
    ok = 2 ** cnt2
    for aa in a:
        if aa % ng == 0:
            return 0
        if aa % ok != 0:
            return 0
        ret = koubaisuu(ret, aa // 2)
    return int(floor((M - ret) / (ret * 2)) + 1)

print(solve2(N, M, a))


Measured memory_bytes: 14244
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_084_B.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP    PIC X(11).
    01 S      PIC X(10).
    01 A      PIC 9(1).
    01 B      PIC 9(1).
    01 i      PIC 9(2).
    01 flg    PIC 9(1) VALUE 1.
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT INP.
    ACCEPT S.

    UNSTRING INP
    DELIMITED BY SPACE
    INTO A B.

    PERFORM VARYING i FROM 1 BY 1 UNTIL A + B + 1 < i
        IF A + 1 = i AND S(i:1) NOT = '-' THEN
            MOVE 0 TO flg
        ELSE
            IF A + 1 NOT = i AND S(i:1) = '-' THEN
                MOVE 0 TO flg
            END-IF
        END-IF
    END-PERFORM.

    IF flg = 1 THEN
        DISPLAY "Yes"
    ELSE
        DISPLAY "No"
    END-IF.

    STOP RUN.


Measured memory_bytes: 384
#include<stdio.h>
int main(void){
	int n, x, a, b, c, cnt = 0;
	
	do{
		scanf("%d %d\n", &n, &x);
		if(n == 0 && x == 0){
			break;
		}
		for(a = 1; a <= n-2; a++){
			for(b = a+1; b <= n-1; b++){
				for(c = b+1; c <= n; c++){
					if(a+b+c == x){
						cnt++;
					}
				}
			}
		}
		printf("%d\n", cnt);
		cnt = 0;
	}while(1);
	
	return 0;
}


Measured memory_bytes: 2064
#include <bits/stdc++.h>
using namespace std;
long long b[100005];
int main(void){
	int N,Q,flag;
	int right=0;
	cin >> N >> Q;
	long long a[N+1];
	long long x[Q];
	for(int i=1;i<=N;i++)cin >> a[i];
	for(int i=0;i<Q;i++)cin >> x[i];
	b[0]=0;
	for(int i=1;i<=N;i++)b[i]=b[i-1]+a[i];
	//(l,r)はb[r]-b[l-1]で出せる
	//各x[i]について
	for(int i=0;i<Q;i++){
		//( l,r)が満たされていたらl,l+1,l+2...l+?=rまで成り立つはず
		//あるlに対して一番大きいrを求める
		long long ans = 0;
		flag = 0;
		for(int left=1;left<=N;left++){
			if(flag==0){
				for(right=N;right>=left;right--){
					if(x[i]>=b[right]-b[left-1]){
						//rightはあるleftに対して一番大きいrightである
						//これを保持しておいて、left++したらrightはここから右にいけるか
						//どうかを調べれば良いのであ～る
						ans += right-(left-1);
						flag = 1;
						break;
					}
				}
			}else{
				//上の分岐でrightが見つかった場合に以下を実行する
				//leftは既に加算済みなので、rightを増やせるかどうか調べる
				int j=0;
				while(x[i]>=(b[right+j]-b[left-1])&&(right+j)<N){
					j++;
					if(x[i]<(b[right+j]-b[left-1])){
						j--;
						break;
					}
				}
				right = right+j;
				ans += right-(left-1);
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 4640
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
  int n,count[6]={0};
  double a;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a>185.0)a=185.0;
    count[(int)((a-160.0)/5.0)]++;
  }
  for(int i=0;i<6;i++){
    printf("%d:",i+1);
    for(int j=0;j<count[i];j++){
      printf("*");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 1216
import math

a,b,h,m = map(int, input().split())

htom = h * 60 + m
hkaku = htom / 2
mkaku = m * 6
aida = abs(hkaku - mkaku)
if aida > 180:
    aida = 360 - aida
ans = a * a + b * b - 2 * a * b * math.cos(math.radians(aida))
ans = math.sqrt(ans)
print(ans)

Measured memory_bytes: 9456
fun main(args: Array<String>) {
    val (A, B, K) = readLine()!!.split(" ").map(String::toInt)
    val a = (1..A).filter { A % it == 0 }
    val b = (1..B).filter { B % it == 0 }
    val ans = a.intersect(b).sortedDescending()[K - 1]
    println(ans)
}

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

using namespace std;


int main() {
	string s, t;
	cin >> s >> t;
	
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != '0') {
			for (int j = i + 1; j < s.size(); j++) {
				if (s[i] == s[j]) {
					if (t[i] != t[j]) {
						cout << "No";
						return 0;
					} else {
						s[j] = '0';
					}
				} else {
					if (t[i] == t[j]) {
						cout << "No";
						return 0;
					}
				}
			}
		}
	}
	cout << "Yes";
	
	
	return 0;
}




Measured memory_bytes: 776
#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 D, T, S;
	cin >> D >> T >> S;

	if (T * S >= D)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}

	return 0;
}


Measured memory_bytes: 3584
ENV[Z='RUBY_THREAD_VM_STACK_SIZE']||exec({Z=>?5*8},'ruby',$0)
p=*0...gets.to_i;s=0;
f=->a{a==p[a]?a: p[a]=f[p[a]]}
a,b=$<.map{|s|s.split.map &:to_i}.transpose.map{|a|a.map.with_index.sort.each_cons(2).map{|(x,i),(y,j)|[y-x,i,j]}};
(a+b).sort_by{|a|a[0]}.map{|c,a,b|(s+=c;p[f[b]]=f[a])if f[a]!=f[b]}
p s

Measured memory_bytes: 94620
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
const int INF = 1e9;
int n,m,dp[maxn];
struct node {
	int u;	//ÁÚ½Óµã
	int w;	//±ßÈ¨ 
};

vector<node> v[maxn];	//ÁÚ½Ó±í 

int dfs(int i) {
	if(dp[i] != 0) return dp[i];
	for(int j = 0;j < v[i].size();j++) {		//±éÀúÁÚ½Óµã 
		int w = v[i][j].w;		//È¡È¨ÖØ 
		dp[i] = max(dp[i],w+dfs(v[i][j].u));		//ËÑË÷ÖÕµã 
	}
	return dp[i];
}

int main() {
	cin>>n>>m;
	int x,y;
	for(int i = 0;i < m;i++) {
		cin>>x>>y;
		v[x].push_back({y,1});
	}
	int ans = 0;
	for(int i = 1;i <= n;i++) {
		ans = max(dfs(i),ans);
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 8192
#include <iostream>
using namespace std;
int main(void) {
	int a, b;
	cin >> a >> b;
	if (0 < a && 0 < b) {
		cout << "Positive" << endl;
		exit(0);
	}
	if (a <= 0 && 0 <= b) {
		cout << "Zero" << endl;
		exit(0);
	}
	if (b < 0) {
		int diff = b - a + 1;
		if (diff % 2 == 0) cout << "Positive" << endl;
		else cout << "Negative" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void){
	int n, i, j, k;
	char str[26], order[7], c, tmp;
	scanf("%d%*c",&n);
	for(i = 0;i < n;i++){
		j = 0;
		while((c = getchar()) != '\n')
			order[j++] = c;
		order[j] = '\0';
		j = 0;
		while((c = getchar()) != '\n')
			str[j++] = c;
		str[j] = '\0';
		for(j = strlen(order) - 1;j >= 0;j--){
			if(order[j] == 'J'){
				tmp = str[strlen(str) - 1];
				for(k = strlen(str) - 1;k > 0;k--)
					str[k] = str[k - 1];
				str[0] = tmp;
			}else if(order[j] == 'C'){
				tmp = str[0];
				for(k = 0;k < strlen(str) - 1;k++)
					str[k] = str[k + 1];
				str[strlen(str) - 1] = tmp;
			}else if(order[j] == 'E'){
				for(k = 0;k < strlen(str) / 2;k++){
					tmp = str[k];
					str[k] = str[k + (strlen(str) - 1) / 2 + 1];
					str[k + (strlen(str) - 1) / 2 + 1] = tmp;
				}
			}else if(order[j] == 'A'){
				for(k = 0;k < strlen(str) - 1 - k;k++){
					tmp = str[k];
					str[k] = str[strlen(str) - 1 - k];
					str[strlen(str) - 1 - k] = tmp;
				}
			}else if(order[j] == 'P'){
				for(k = 0;k < strlen(str);k++){
					if(isdigit(str[k])){
						if(str[k] == '0')
							str[k] = '9';
						else
							str[k]--;
					}
				}
			}else if(order[j] == 'M'){
				for(k = 0;k < strlen(str);k++){
					if(isdigit(str[k])){
						if(str[k] == '9')
							str[k] = '0';
						else
							str[k]++;
					}
				}
			}
		}
		printf("%s\n",str);
	}
	return 0;
}

Measured memory_bytes: 1016
import itertools
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(N)]

a = list(itertools.accumulate(A, max))
b = list(itertools.accumulate(A[::-1], max))[::-1]

for i in range(len(A)):
    r = 0
    if 0 <= i - 1 < N:
        r = max(r, a[i - 1])
    if 0 <= i + 1 < N:
        r = max(r, b[i + 1])
    print(r)


Measured memory_bytes: 16748
#include <bits/stdc++.h>
#define ll long long
#define pr pair<int,int>
#define mp make_pair
#define fi first
#define next fuck
#define se second
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    for(auto &x : a) cin>>x;
    sort(a.begin(),a.end());
    ll ans = 0;
    if(n % 2 == 1)
    {
        int mid = (n + 1)/2 -1;
        b[0] = a[mid];
        if(a[mid] - a[mid-1] < a[mid+1] - a[mid])
        {
            for(int i  =0;i<mid;i++)
            {
                b[(i+1)*2] = a[i];
                b[i*2+1] = a[n-i-1];
            }

        }
        else
        {
            for(int i = 0;i<mid;i++)
            {
                b[i*2+1] = a[i];
                b[(i+1)*2] = a[n-i-1];
            }
        }
    }
    else
    {
        int mid = n/2;
        for(int i = 0;i<mid;i++)
        {
            b[i*2+1] = a[i];
            b[i*2] = a[mid+i];
        }
    }
    for(int i = 1;i<n;i++)
    {
        ans += 1LL*abs(b[i] - b[i-1]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 int main(){
 int64_t X;
 cin >> X;
 int64_t P = 100, step = 0;
 while(P < X){
 P += P / 100;
 step++;
 }
 cout << step << endl;
 return 0;
 }


Measured memory_bytes: 3552
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
using ll = long long;

int main() {

    string S, T;
    cin >> S >> T;

    int counter = 0;
    for (int i = 0; i < 3; ++i) {
        if (S[i] == T[i]) {
            ++ counter;
        }
    }

    cout << counter << endl;

    return 0;
}


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

#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,lessl<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define int long long
#define double long double

#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()

#define ff first
#define ss second
#define mp make_pair

#define pb push_back
#define endl "\n"

#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)

#define bp __builtin_popcountll
#define inf 1e18

const int N=1e5+5;
const int M=1e9+7;
void solve()
{
	string s;
	cin>>s;
	int ans=0;
	if(s[0]=='R' && s[1]=='R' && s[2]=='R')
	ans=3;
	else if((s[0]=='R' && s[1]=='R') || (s[1]=='R' && s[2]=='R'))
	ans=2;
	else if(s[0]=='R' || s[1]=='R' || s[2]=='R')
	ans=1;
	cout<<ans<<endl;
}



signed main()
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}


Measured memory_bytes: 3636
#include<iostream>
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 n,int left,int right,int mid)
{
    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 n,int left,int right)
{
    if (left+1<right){
        int mid=(left+right)/2;
        mergesort(A,n,left,mid);
        mergesort(A,n,mid,right);
        merge(A,n,left,right,mid);
    }
}

int main()
{
    int A[MAX],n,i;
    cnt=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>A[i];
    }
    mergesort(A,n,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
import java.util.Scanner;

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

    int N = scanner.nextInt();
    for (int i = 9; i > 0; i--) {
      if (N % i == 0 && N / i < 10) {
        System.out.println("Yes");
        return;
      }
    }
    System.out.println("No");
  }
}


Measured memory_bytes: 22996
#include <stdio.h>

int main(int argc,char* argv[]){
  int num;
  int a,b,c;
  int count = 0;
  int ans;

  scanf("%d",&num);

  for(;count < num;++count){
    scanf("%d %d %d",&a,&b,&c);

    
    ans = ((a*a == (b*b + c*c)) 
	   ? 1 
	   : ((b*b == (a*a + c*c)) 
	      ? 1 
	      : (((a*a + b*b) == c*c) 
		 ? 1 
		 : 0)));

    printf("%s\n",(ans == 1) ? "YES" : "NO");
  }

  return 0;
  
}

Measured memory_bytes: 0
#include <cstdio>

int compute_fibonacci(int num)
{
    int prev_num = 1;
    int current_num = 1;
    for(int i = 2; i <= num; i++) {
        int tmp = current_num;
        current_num = current_num + prev_num;
        prev_num = tmp;
    }
    return current_num;
}

int main()
{
    int num;
    scanf("%d", &num);
    printf("%d\n", compute_fibonacci(num));
    return 0;
}

Measured memory_bytes: 2748
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  ll a, b, x;
  cin >> a >> b >> x;
  if(a==b){
      if(a%x==0){
        puts("1");
      }else{
        puts("0");
      }
      return 0;
  }
  ll k, j, A, B;
  if (a < x) {
    A = x;
  } else {
    A = (a / x + 1) * x;
  }
  j = b % x;
  if (b < x) {
    B-= 1;
  } else {
    B = (b / x) * x;
  }

   if (b % x == 0) B -= x;
  ll ans = (B - A) / x + 1;
  if (ans < 0) ans = 0;
  if (a % x == 0) ans++;
  if (b % x == 0) ans++;
  cout << max(ans, (ll)0) << endl;
}

Measured memory_bytes: 256
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

void solve(ll D, ll G, std::vector<ll> p, std::vector<ll> c) {
  ll result = 1000000000;

  for (int tmp = 0; tmp < (1 << 10); tmp++) {
    bitset<10> s(tmp);
    if (D != 10 && s.test(D) == 1) {
      break;
    }
    ll cnt = 0;
    ll sum = 0;
    rep(i, D) {
      if (s.test(i)) {
        sum += p.at(i) * 100 * (i + 1) + c.at(i);
        cnt += p.at(i);
      }
    }

    for (int i = D - 1; i >= 0; i--) {
      if (s.test(i))
        continue;
      if (sum >= G)
        break;
      ll a = min((G - sum) / (100 * (i + 1)), p[i]);
      sum += (i + 1) * 100 * a;
      cnt += a;
    }

    if (sum >= G)
      result = min(cnt, result);
  }

  cout << result << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  ll D;
  scanf("%lld", &D);
  ll G;
  scanf("%lld", &G);
  std::vector<ll> p(10, 0);
  std::vector<ll> c(10, 0);
  for (int i = 0; i < D; i++) {
    scanf("%lld", &p[i]);
    scanf("%lld", &c[i]);
  }
  solve(D, G, std::move(p), std::move(c));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define MAXS 8005
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

string S;
int X, Y;
vi vert, hori;

bool check(int goal, vi vec){
    int val;
    set<int> prev;
    prev.insert(0); //原点

    rep(i,vec.size()){
        set<int> dp;
        val = vec[i];
        for (auto itr = prev.begin(); itr != prev.end(); ++itr){
            dp.insert(*itr+val);
            dp.insert(*itr-val);
        }
        swap(prev, dp);
    }

    return prev.count(goal);
}

int main(){
    cin >> S >> X >> Y;

    if(S[S.size()-1]!='T') S += 'T';


    int tmp = 0;
    bool state = true;

    rep(i, S.size()){
        if(S[i] == 'F'){
            tmp++;
        } else {
            if(state)
                hori.push_back(tmp);
            else
                vert.push_back(tmp);
            tmp = 0;
            state = !state;
        }
    }

    X -= hori[0];
    hori.erase(hori.begin()); //初期値だけシフトして対称性を保つ

    // printf("goal: (%d,%d)\n",X,Y);

    // printf("vertical: ");
    // rep(i,vert.size())
    //     cout << vert[i] << " ";
    // cout << endl;

    // printf("horizontal: ");
    // rep(i,hori.size())
    //     cout << hori[i] << " ";
    // cout << endl;

    if(check(Y,vert) && check(X, hori)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 640