akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF INT_MAX
#define rep(i,n)for(ll i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

ll a[100000];

int main() {
	ll n; cin >> n;
	rep(i, n) {
		scanf("%lld", &a[i]);
	}
	ll Max = 0;
	ll cnt = 0;
	bool back = 0;
	rep(i, 2) {
		for (int j = i; j < n; j++) {
			if (a[j] == 0) {
				back = 0;
				continue;
			}
			if (back) {
				cnt += (a[j] + 1) / 2;
				back = !(a[j] & 1);
			}
			else{
				cnt += a[j] / 2;
				back = a[j] & 1;
			}
		}
		Max = max(Max, cnt);
		cnt = 0;
		back = 0;
	}
	printf("%lld\n", Max);
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n;cin>>n;
    vl a(n);
    rep(i,n)cin>>a[i];
    ll l=a[0];
    for(int i=1;i<n;++i){
        l^=a[i];
    }
    if(l==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main() {
  int N;
  cin >> N;
  int A = N % 10;
  if (A == 3) {
    cout << "bon" << endl;
  }
  if (A == 0 || A == 1 || A == 6 || A == 8) {
    cout << "pon" << endl;
  }
  if (A == 2 || A == 4 || A == 5 || A == 7 || A == 9) {
    cout << "hon" << endl;
  }
}

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

#define mod 1000000007
#define INF (ll)9999999999999999

#define eb emplace_back
#define len(x) ((int)(x).size())
#define log(x) cout << (x) << endl;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define loop(i,a,b) for(int i = (int)(a); i < (int)(b); ++i)

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;


#define rsum(i,j) sm[j]-(i>0?sm[i-1]:0)

int main() {
	ll n;
	cin >> n;
	vll a(n), sm(n);
	rep (i, n) {
		cin>>a[i];
		sm[i] = (i>0)?a[i]+sm[i-1]:a[i];
	}

	ll mn = INF,x,y;
	rep (i, n-1) {
		x = rsum(0,i), y = rsum(i+1,n-1);
		mn = min(mn, abs(x-y));
	}

	log(mn);

	return 0;
}





Measured memory_bytes: 3328
#include<stdio.h>

long fibo[100001];
long p;


int main(void) {
	int N, M;
	int i;

	scanf("%d%d", &N, &M);

	fibo[0] = 1;
	fibo[1] = 1;
	for (i = 2;i < 100001;i++) {
		fibo[i] = fibo[i - 1] + fibo[i - 2];
		fibo[i] %= 1000000007;
	}
	
	if (M == 0) {
		printf("%ld", fibo[N]);
		return 0;
	}

	int a[M];

	for (i = 0;i < M;i++) {
		scanf("%d", &a[i]);
	}

	int sa[M + 1];
	sa[0] = a[0];
	sa[M] = N - a[M - 1];

	for (i = 0;i < M - 1;i++) {
		if (a[i + 1] == a[i] + 1) {

			printf("%d", 0);

			return 0;
		}
		else {
			sa[i + 1] = a[i + 1] - a[i] - 1;
		}
	}
	
	p = 1;

	for (i = 0;i < M+1;i++) {
		
			p *= fibo[sa[i] - 1];
			p %= 1000000007;
		
	}

	printf("%ld", p % 1000000007);
	
	return 0;
	
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

void solve()
{
	int n;
	cin>>n;
	set<string> s;
	while(n--)
	{
		string k;
		cin>>k;
		s.insert(k);
	}
	cout<<s.size()<<endl;
}

int main()
{
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 19228
#include<iostream>
using namespace std;
int main() {
    int r,D,x2000;
    cin >> r >> D >> x2000;
    for (int i=1; i<=10; i++) {
        int t = r * x2000 - D;
        cout << t << endl;
        x2000 = t;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ll n, total;
    cin >> n >> total;
    ll flag = 0;
    for(int i = 0; i <= n; i++){
        if(i * 4 + (n - i) * 2 == total) flag = 1;
    }
    if(flag) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  int a,b,c;
  cin >>a>>b >>c;
  cout << min(b/a,c) << endl;
  return 0;
}


Measured memory_bytes: 3488
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const double pi = acos(-1.0);

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    x /= a;
    double ans = 0.0;
    if (x <= a * b / 2){
        double d = 2 * x / b;
        ans = pi / 2 - atan2(d, b);
    }else{
        double y = a * b - x;
        double d = 2 * y / a;
        ans = atan2(d, a);
    }
    ans *= 180 / pi;
    printf("%.15f\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
  
signed main() {
    fast;
    int k,n;
    cin>>k>>n;
    int arr[n];
    for (int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    int max=INT_MIN;
    for (int i=1;i<n;i++)
    {
        if (arr[i]-arr[i-1]>max)
        max=arr[i]-arr[i-1];
    }
    if (arr[0]+k-arr[n-1]>max)
    max=arr[0]+k-arr[n-1];
    cout<<k-max<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
    long long a, b;
    char op;
    cin >> a >> op >> b;
    if(op == '+'){
        cout<<a+b;
    }else{
        cout<<a-b;
    }
    cout<<endl;
    return 0;
}


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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

void solve(std::string S) {
  if (S[S.size() - 1] == 's') {
    cout << S << "es" << endl;
  } else {
    cout << S << "s" << endl;
  }
}

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


Measured memory_bytes: 3636
n,max_w = map(int,input().split())
w1=[]
w2=[]
w3=[]
w4=[]
v1=[]
v2=[]
v3=[]
v4=[]

w_1,v_1 = map(int,input().split())
w1.append(w_1)
v1.append(v_1)

for i in range(1,n):
  tmp_w,tmp_v = map(int,input().split())
  if tmp_w == w_1:
    w1.append(tmp_w)
    v1.append(tmp_v)
  elif tmp_w == w_1+1:
    w2.append(tmp_w)
    v2.append(tmp_v)
  elif tmp_w == w_1+2:
    w3.append(tmp_w)
    v3.append(tmp_v)
  elif tmp_w == w_1+3:
    w4.append(tmp_w)
    v4.append(tmp_v)
  

count1 = len(w1)
count2 = len(w2)
count3 = len(w3)
count4 = len(w4)

v1 = sorted(v1,reverse=True)
v2 = sorted(v2,reverse=True)
v3 = sorted(v3,reverse=True)
v4 = sorted(v4,reverse=True)

ruiseki_v1 = [0]*count1
ruiseki_v2 = [0]*count2
ruiseki_v3 = [0]*count3
ruiseki_v4 = [0]*count4

if v1:
  ruiseki_v1[0]=v1[0]
  for i in range(count1-1):
    ruiseki_v1[i+1]=ruiseki_v1[i]+v1[i+1]

if v2:
  ruiseki_v2[0]=v2[0]
  for i in range(count2-1):
    ruiseki_v2[i+1]=ruiseki_v2[i]+v2[i+1]

if v3:
  ruiseki_v3[0]=v3[0]
  for i in range(count3-1):
    ruiseki_v3[i+1]=ruiseki_v3[i]+v3[i+1]

if v4:
  ruiseki_v4[0]=v4[0]
  for i in range(count4-1):
    ruiseki_v4[i+1]=ruiseki_v4[i]+v4[i+1]

ruiseki_v1.insert(0,0)
ruiseki_v2.insert(0,0)
ruiseki_v3.insert(0,0)
ruiseki_v4.insert(0,0)

ans = 0 
for i in range(count1+1):
  for j in range(count2+1):
    for k in range(count3+1):
      for l in range(count4+1):
        if i*w_1 + j*(w_1+1) + k*(w_1+2) +l*(w_1+3) <= max_w:
          ans = max(ans,ruiseki_v1[i]+ruiseki_v2[j]+ruiseki_v3[k]+ruiseki_v4[l])
print(ans)

Measured memory_bytes: 3192
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        n: usize,
        k: usize,
    }

    if n%k==0 {
        println!("0");
    } else {
        println!("1");
    }

}


Measured memory_bytes: 2196
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}


int main(){
    string x, y;
    cin >> x >> y;
    int counter = 0;
    for (int i = 0; i < x.length(); i++) {
        if (x[i] != y[i]) {
            counter++;
        }
    }
    cout << counter;
}



Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,k;
	cin>>k>>a>>b;
	for(int i=1;i<1001;i++){
		if(k*i<=b&&k*i>=a){
			cout<<"OK";
			return 0;
		}
	}
	cout<<"NG";
	return 0;
} 

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

ll n,k;
ll mx = 0;
vector<ll> a(200001);

int search(int l, int r){
    int x = (l+r)/2;
    if(x == 0) return 1;
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans += a[i]/x -1;
        if(a[i]%x != 0) ans++;
    }

    if(ans > k){
        l = x;
    } else {
        r = x;
    }

    if(r-l <= 1) return r;
    else return search(l, r);
}

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

    int ans = search(0, mx);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4708
#include <iostream>
#include <algorithm>
#include <iomanip>
#include"stdio.h"
#include <cstring>
#include<math.h>
#include<map>
#include<queue>
#include<stack>
#include"time.h"
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define db printf("where!\n");
#define pb push_back
using namespace std;
#define ll long long
template<class T>inline void read(T &res){
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
ll gcd(ll x,ll y){return y ? gcd(y,x%y) : x;}

int main()
{
    int a;
    cin>>a;
    int num=0;
    for(int i=1;i<=a;i++){
        for(int j=1;j<=a;j++){
            for(int k=1;k<=a;k++){
                int t=(int)gcd(i,j);
                num+=gcd(t,k);
            }
        }
    }
    cout<<num;
    return 0;
}

Measured memory_bytes: 3188
@Suppress("UNUSED_PARAMETER")
fun main(args: Array<String>) {
    val L: String = readLine()!!
    solve(L)
}

fun solve(L: String) {
    val MOD: Long = (1E9 + 7).toLong()
    var dp1 = LongArray(L.length)
    var dp2 = LongArray(L.length)
    var dp: Array<LongArray> = arrayOf(dp1, dp2)
    dp[0][0] = 1
    dp[1][0] = 2
    for (i in 1 until L.length) {
        if (L[i] == '1') {
            dp[1][i] = dp[1][i - 1] * 2
            dp[0][i] = dp[0][i - 1] * 3 + dp[1][i - 1] * 1
        } else {
            dp[1][i] = dp[1][i - 1] * 1
            dp[0][i] = dp[0][i - 1] * 3
        }
        dp[0][i] %= MOD
        dp[1][i] %= MOD
    }
    println((dp[0][L.length - 1] + dp[1][L.length - 1 ])%MOD)
}

Measured memory_bytes: 36512
while True:
    n = input()
    if n < 0:
        break
    m = int( n * 16)
    if m / 16.0 == n: #divided
         b = format(m, '012b')
         tmp = list(b)
         print "%s.%s" % ("".join(tmp[0:8]), "".join(tmp[8:12]))
    else:
        print "NA"

Measured memory_bytes: 6444
N,L = map(int,input().split())

allpi = 0
for i in range(N):
    allpi += (L + i) 

absmin = -1
absi   = -1
for i in range(N):
    absval = abs( L + i )
    if absmin == -1 or absmin > absval:
        absmin = absval
        absi = i

print( allpi - (L+absi))


Measured memory_bytes: 3060
@$_[@=]=map[glob<>],@=for 0,@==1..<>;$\=-5e9;for$i(1..1023){$c=0;$c+=$1[$j=$_][grep$0[$j][$_]&$i>>$_,0..9]for@=;$\+=$-=$c-$\}print


Measured memory_bytes: 3072
import java.util.Scanner;

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

    int n = scan.nextInt();
    String s = scan.next();
    String t = scan.next();
    StringBuilder sb =new StringBuilder();

    for(int i=0 ; i < n ; i++) {
    sb.append(s.charAt(i));
    sb.append(t.charAt(i));
    }
    System.out.println(sb.toString());
	}
}

Measured memory_bytes: 27092
let nats n =
  let rec loop i e =
    if i = 0 then 0 :: e
    else loop (i - 1) (i :: e) in
  loop n []


let inp_matrix : 'a array -> int -> int -> unit = fun a m n ->
  for i = 0 to m - 1 do
    for j = 0 to n - 1 do
      a.(i).(j) <- Scanf.scanf " %d" (fun x -> x)
    done
  done

let rec pairs : 'a list -> ('a * 'a) list = function
    [] -> []
  | x :: xs -> List.map (fun y -> (x, y)) xs @ (pairs xs)


let () =
  let n = Scanf.sscanf (input_line stdin) "%d" (fun a -> a) in
  let a = Array.make_matrix n 2 0 in
  let () = inp_matrix a n 2 in
  let ps = pairs (nats (n - 1)) in
  let lens =
    List.map (fun (p1, p2) ->
        sqrt (float_of_int
                ((a.(p1).(0) - a.(p2).(0))
                 * (a.(p1).(0) - a.(p2).(0))
                 + (a.(p1).(1) - a.(p2).(1))
                   * (a.(p1).(1) - a.(p2).(1))))  
      ) ps in
  let ans = 2. *. (List.fold_left (fun sum len -> len +. sum) 0.0 lens)
            /. (float_of_int n)
  in
  print_float ans;
  print_newline ()


Measured memory_bytes: 384
import itertools
n = int(input())
a = ["M","A","R","C","H"]
b = [0]*5
for i in range(n):
    s = input()
    for j in range(5):
        if a[j] == s[0]:
            b[j] += 1
ans = 0
for k in itertools.combinations(b,3):
    ans += k[0]*k[1]*k[2]
print(ans)

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

namespace Algorithm
{
    class Program
    {
        enum Color
        {
            Gray,Brown,Green,LightBlue,Blue,Yellow,Orange,Red,All
        }
        const int ColorCount = 9;
        static void Main(string[] args)
        {
            var N =int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var cluster = new int[ColorCount];

            for (var i = 0; i < N; i++)
            {
                Classification(a[i], cluster);
            }
            var otherAll = cluster.Count(z => z > 0);

            if (cluster[(int)Color.All] == 0)
                Console.WriteLine($"{otherAll} {otherAll}");
            else
            {
                if (otherAll > 1 || otherAll == 1) otherAll--;
                Console.WriteLine($"{(otherAll==0?1:otherAll)} {otherAll + cluster[(int)Color.All]}");
            }
        }

        static void Classification(int x, int[] cls)
        {
            if (x <= 399) cls[(int)Color.Gray]++;
            else if (x <= 799) cls[(int)Color.Brown]++;
            else if (x <= 1199) cls[(int)Color.Green]++;
            else if (x <= 1599) cls[(int)Color.LightBlue]++;
            else if (x <= 1999) cls[(int)Color.Blue]++;
            else if (x <= 2399) cls[(int)Color.Yellow]++;
            else if (x <= 2799) cls[(int)Color.Orange]++;
            else if (x <= 3199) cls[(int)Color.Red]++;
            else cls[(int)Color.All]++;
        }
    }
}


Measured memory_bytes: 11348
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)*}
    };
}

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

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

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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize
    }
    let mut l0: usize = 2;
    let mut l1: usize = 1;
    for i in 1..n {
        let l = l0 + l1;
        l0 = l1;
        l1 = l;
    }
    println!("{}", l1);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define int long long
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int _q;
int a,b,c,d,len;
int cnt[1002];
string res;
string baoli1(){
	//a>=b
	for(int i=b-len;i>0;i-=len)cnt[i]++,a--;
	for(int i=0;i<=b&&a;i++){
		if(cnt[i]==len)continue;
		int add=len-cnt[i];
		if(a<add){
			cnt[i]+=a;
			break;
		}
		a-=add;cnt[i]=len;
	}
	res="";
	while(cnt[0]--)res.push_back('A');
	for(int i=1;i<=b;i++){
		res.push_back('B');
		while(cnt[i]--)res.push_back('A');
	}
	res=" "+res;string ret="";
	for(int i=c;i<=d;i++)ret.push_back(res[i]);
	return ret;
}
string baoli2(){
	for(int i=len;i<a;i+=len){
		cnt[i]++;b--;
	}
	for(int i=a;i>=0;i--){
		if(cnt[i]==len)continue;
		int add=len-cnt[i];
		if(b<add){
			cnt[i]+=b;
			break;
		}
		b-=add;cnt[i]=len;
	}
	res="";
	while(cnt[0]--)res.push_back('B');
	for(int i=1;i<=a;i++){
		res.push_back('A');
		while(cnt[i]--)res.push_back('B');
	}
	res=" "+res;string ret="";
	for(int i=c;i<=d;i++)ret.push_back(res[i]);
	return ret;
}
int ok(int x){
	int l=(x)*len+1+(b-x-1)/len,r=l+(len-1);
//	cerr<<l<<" "<<r<<" "<<a<<endl;
	if(a<l)return -1;
	if(a<=r)return a-l+1;
	else return 0;
}
string solve1(){
	//a>=b
	int l=-1,r=b+1;
	while(r-l>1){
		int mid=l+r>>1;
		if(ok(mid))r=mid;
		else l=mid;
	}
	int size1=(len+1)*r+ok(r);
//	cerr<<r<<" "<<len+1<<" "<<ok(r)<<endl; 
	string ret="";
	while(c<=d&&c<=size1){
		ret.push_back(c%(len+1)==0?'B':'A');c++;
	}
	if(c>d)return ret;
	string sjctxdy="";
	for(int i=d;i>=c;i--){
		int T=a+b+1-i;//cerr<<i<<" "<<T<<endl;
		if(T%(len+1))sjctxdy.push_back('B');
		else sjctxdy.push_back('A'); 
	}
	reverse(sjctxdy.begin(),sjctxdy.end());
	return ret+sjctxdy;
}
string solve2(){
	swap(a,b);int tmpd=a+b+1-c,tmpc=a+b+1-d;
	c=tmpc;d=tmpd;//cerr<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
	string S=solve1();
//	cout<<S<<endl;
	reverse(S.begin(),S.end());
//	cout<<S<<endl;
	for(char &_c:S)if(_c=='A')_c='B';else _c='A';
//	cout<<S<<endl;
	return S;
}
void duipai(){
	srand(time(0));
	while(1){
		memset(cnt,0,sizeof cnt);
		cin>>a>>b>>c>>d;len=(a+b)/min(a+1,b+1);
		int ta=a,tb=b,tc=c,td=d,tlen=len;
		string s1=(a>=b?solve1():solve2());
		a=ta;b=tb;c=tc;d=td;len=tlen;
		string s2=(a>=b?baoli1():baoli2());
		if(s1!=s2){
			cout<<ta<<" "<<tb<<endl<<s1<<endl<<s2<<endl;system("pause");
		}else{
			puts("ok");
		}
	}
}
signed main(){
//	duipai();
	int ta,tb,tc,td,tlen;
	cin>>_q;
	for(int q=1;q<=_q;q++){
		cin>>a>>b>>c>>d;
	//	if(q>689)continue;
		len=(a+b)/min(a+1,b+1);
		ta=a;tb=b;tc=c;td=d;tlen=len;
		memset(cnt,0,sizeof cnt);
		if(a==b){
			for(int i=c;i<=d;i++)if(i&1)cout<<'A';else cout<<'B';
			cout<<endl;continue;
		}
		if(a>=b){
			string s=solve1();
			cout<<s<<endl;
		}
		else{
			string s=solve2();
			cout<<s<<endl;
		}
		a=b=c=d=ta=tb=tc=td=len=tlen=0;
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VI a(n), b(n), c(n-1);
    REP(i,0,n) cin >> a[i];
    REP(i,0,n) --a[i];
    REP(i,0,n) cin >> b[i];
    REP(i,0,n-1) cin >> c[i];
    int ans = b[a[0]];
    REP(i,1,n) {
        ans += b[a[i]];
        if (a[i] - a[i-1] == 1) ans += c[a[i-1]];
    }
    cout << ans << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
from collections import deque

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=deque(sorted(LIST()))

ans=[]
while len(A)>=3:
    if A[0]<=0 and A[-1]>=0:
        if A[1]<=0:
            y=A.popleft()
            x=A.pop()
            ans.append((x, y))
            A.append(x-y)
        elif A[-2]>=0:
            x=A.popleft()
            y=A.pop()
            ans.append((x, y))
            A.appendleft(x-y)
        else:
            if A[0]>0:
                x=A.popleft()
                y=A.pop()
                ans.append((x, y))
                A.appendleft(x-y)
            elif A[-1]<0:       
                y=A.popleft()
                x=A.pop()
                ans.append((x, y))
                A.append(x-y)
            else:
                raise Exception
    else:
        if A[0]>0:
            x=A.popleft()
            y=A.pop()
            ans.append((x, y))
            A.appendleft(x-y)
        elif A[-1]<0:       
            y=A.popleft()
            x=A.pop()
            ans.append((x, y))
            A.append(x-y)
        else:
            raise Exception
ans.append((A[-1], A[0]))
print(A[-1]-A[0])
for x, y in ans:
    print(x, y)


Measured memory_bytes: 19320
/* ex 5_4
   Kohei_Suzuki */

#include <stdio.h>
#define SIZE 50

int main(void){
    int count=0, ans=0;
    char sequence[SIZE], *ptr;
    //ptr: sequenceの各要素へのポインタ


    scanf("%s", sequence); //入力受取

    ptr = &sequence[0]; //ポインタへの代入

    // ACGT文字列の長さを求める
    while(*ptr){
        if(*ptr == 'A' || *ptr == 'C' || *ptr == 'G' || *ptr == 'T'){
            
            //A,T,C,Gのいずれからなcountを増やす
            count++;

            //これまでの長さの最大より大きければ更新
            if(count > ans){
                ans = count;
            }
        }
        else{
            //途切れたらcountを初期化
            count = 0;
        }
        ptr++;
    }

    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1732
#include <cstdio>
#include <list>
#include <algorithm>
using namespace std;
int main(){
  int n;
  int i,j=0,x;
  char com[10];
  list<int>v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='i'){
      scanf("%d",&x);
      v.push_front(x);
    } else if(com[6]=='F'){
      v.pop_front();
    } else if(com[6]=='L'){
      v.pop_back();
    } else if(com[0]=='d'){
      scanf("%d",&x);
      for(list<int>::iterator it =v.begin();it!=v.end();it++){
        if(*it==x){
          v.erase(it);
          break;
        }
      }
    }
  }
  for(list<int>::iterator it=v.begin();it!=v.end();it++){
    if(j++)printf(" ");
    printf("%d",*it);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 33984
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,aa,bb;
    cin>>n>>aa>>bb;
    long long a[n+1];
    int i;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    long long ans=0;
    for(i=2;i<=n;i++)
    {
        if((a[i]-a[i-1])*aa<bb)
        {
            ans+=(a[i]-a[i-1])*aa;
        }
        else
            ans+=bb;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
import java.util.*;
import java.io.*;

class Main {

    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);
	int T = stdin.nextInt();
	for ( int t = 0; t < T; t++ ) {
	    int[] ar = new int[10];
	    for (int i = 0; i < ar.length; ++i){
		ar[i] = stdin.nextInt();
	    }

	    boolean success = false;
	    for ( int i = 0; i < (1 << 10); i++ ) {
		if ( success( ar, i ) ){
		    success = true;
		    break;
		}
	    }
	    if ( success ) {
		System.out.println( "YES" );
	    } else {
		System.out.println( "NO" );
	    }
	    
	}	
    }

    static boolean success( int[] array, int n ) {
	int left = -1;
	int right = -1;
	for ( int i = 0; i < array.length; i++ ) {
	    if ( n % 2 == 1 ) {
		if ( left < array[i] ) {
		    left = array[i];
		} else {
		    return false;
		}
	    } else {
		if ( right < array[i] ) {
		    right = array[i];
		} else {
		    return false;
		}
	    }
	    n /= 2;
	}
	return true;
    }    
}

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

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    if(A + B == C + D){
        cout << "Balanced" << endl;
    }
    else if(A + B < C + D){
        cout << "Right" << endl;
    }
    else{
        cout << "Left" << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>

using namespace std;



int main()
{
	map<string, vector<int> > index;
	string s;
	int n;
	
	while (cin >> s >> n)
	{
		index[s].push_back(n);
		sort(index[s].begin(), index[s].end());
	}
	
	map<string, vector<int> >::const_iterator it;
	vector<int>::const_iterator it2;
	for (it=index.begin(); it!=index.end(); it++)
	{
		cout << (*it).first << endl;
		for (it2=(*it).second.begin(); it2!=(*it).second.end()-1; it2++)
		{
			cout << (*it2) << " ";
		}
		cout << (*it2) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1244
#include<stdio.h>
int main(void){
    int N, l, r, ans, i;
    scanf("%d", &N);
    ans = 0;
    for(i = 0; i < N; i++){
        scanf("%d %d", &l, &r);
        ans += r - l + 1;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
s = input()
odd = ["R","U","D"]
even = ["L","U","D"]
res = "Yes"
for i in range(len(s)):
    if i%2 == 0 and s[i] not in odd: res = "No"
    elif i%2==1 and s[i] not in even:res="No"
print(res)

Measured memory_bytes: 9012
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException
    {
	InputStreamReader isr = new InputStreamReader(System.in);
	BufferedReader br = new BufferedReader(isr);
	String buf = br.readLine();
	int num = Integer.parseInt(buf);

	num = (int)Math.pow(num,3);
	System.out.println(num);
    }
}

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

int main(void){
    int n, x;
    cin>>n>>x;
    int a[n];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }  
    sort(a, a+n);
    int i=0, count=0;
    while(a[i]<=x && i<n-1){
        x-=a[i];
        count++;
        i++;
    }
    if(a[n-1]==x){
        count++;
    }
    cout<<count<<endl;
}

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

int main() {
  int K;
  cin >> K;
  int A = 0;
  
  for (int i = 1; i <= K; i++) {
    for (int j = 1; j <= K; j++) {
      for (int k = 1; k <= K; k++) {
        int B = min(i,j);
        B = min(B,k);
        for (int l = B; l >= 1; l--) {
          if (i%l == 0 && j%l == 0 && k%l == 0){
            A += l;
            break;
          }
        }
      }
    }
  }
  cout << A << endl;
}
    

Measured memory_bytes: 3620
local n,m,q=io.read("n","n","n")
local a,b,c,d={},{},{},{}
for i=1,q do
    a[i],b[i],c[i],d[i]=io.read("n","n","n","n")
end

local t={}
for i=1,10 do
    t[i]={}
end
for i=1,m do
    table.insert(t[1],{i})
end

for i=1,n-1 do
    for j,_ in pairs(t[i]) do
        local x=t[i][j]
        local p=x[#x]
        for k=p,m do
            local U={table.unpack(x)}
            table.insert(U,k)
            table.insert(t[i+1],U)
        end
    end
end

local answer=0
for _,T in pairs(t[n]) do
    local total=0
    for i=1,q do
        if T[b[i]]-T[a[i]]==c[i] then
            total=total+d[i]
        end
    end
    answer=math.max(answer,total)
end
print(answer)

Measured memory_bytes: 61512
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
typedef long long int ll;
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define m0(x) memset(x,0,sizeof(x))

//qsort用(昇順，降順)
int cmp_asc( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}
int cmp_desc( const void *p, const void *q ) {
    return *(int*)q - *(int*)p;
}

int main(void){
	int n,x;
	scanf("%d%d",&n,&x);
	int l[n];
	rep(i,n) scanf("%d",&l[i]);
	int count=1,now=0;
	rep(i,n){
		now+=l[i];
		if(now>x) break;
		else count++;
	}
	printf("%d\n",count);
	return 0;
}

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

// #define f(a, b) for(auto i = a;i < b;i++)
// typedef long long int ll;

void solve()
{
	return ;
}

int main()
{

	string str;
	cin >> str;
	// solve();

	if(str[2] == str[3] && str[4] == str[5])
		cout << "Yes\n";
	else
		cout << "No\n";

}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let r = get!(usize);
    println!("{}", r*r);
}


Measured memory_bytes: 8572
#include<algorithm>
#include<cstdio>
#define s(A)std::sort(A,A+10);
main(){
int Z[20];
for(int i=0;i<20;)
scanf("%d",Z+i++);
s(Z);
s(Z+10);
printf("%d %d\n",Z[7]+Z[8]+Z[9],Z[17]+Z[18]+Z[19]);
return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct node
{
    int u,v;
    ll w;
    bool operator<(const node &o)const{return w<o.w;}
}e[6000005];
int n,cot=0,a[200005],fail[200005];
ll d;
void add(int l,int r)
{
    if(l>=r) return;
    int m=l+r>>1;
    ll mi=1e18,pos;
    for(int i=l;i<=m;i++)
    {
        ll f=a[i]-d*i;
        if(f<mi) mi=f,pos=i;
    }
    for(int i=m+1;i<=r;i++)
        e[cot].u=pos,e[cot].v=i,e[cot++].w=a[i]+a[pos]+d*(i-pos);
    mi=1e18;
    for(int i=m+1;i<=r;i++)
    {
        ll f=a[i]+d*i;
        if(f<mi) mi=f,pos=i;
    }
    for(int i=l;i<=m;i++)
        e[cot].u=i,e[cot].v=pos,e[cot++].w=a[i]+a[pos]+d*(pos-i);
    add(l,m);add(m+1,r);
}
int get_fa(int x)
{
    return fail[x]==x?x:fail[x]=get_fa(fail[x]);
}
ll kruskal()
{
    sort(e,e+cot);
    for(int i=1;i<=200000;i++) fail[i]=i;
    ll ans=0;
    for(int i=0;i<cot;i++)
    {
        int fu=get_fa(e[i].u),fv=get_fa(e[i].v);
        if(fu==fv) continue;
        fail[fu]=fv;
        ans+=e[i].w;
    }
    return ans;
}
int main()
{
    scanf("%d%lld",&n,&d);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    add(1,n);
    printf("%lld\n",kruskal());
}


Measured memory_bytes: 57984
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a.at(i);
    reverse(a.begin(), a.end());
    for(int i = 0; i < n; i++) {
        if(i == 0) cout << a.at(i);
        else cout << " " << a.at(i);
    }
    cout << endl;
}


Measured memory_bytes: 3092
x, n = map(int,input().split())
P = list(map(int,input().split()))
a = [i for i in range(-220, 220)]
for p in P:
    a.remove(p)

if x in a:
    print(x)
    exit()

l = x-1
r = x+1
for i in range(120):
    if l in a:
        print(l)
        exit()
    l -= 1

    if r in a:
        print(r)
        exit()
    r += 1

Measured memory_bytes: 9232
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split(" ")))

max = A[0]
min = A[0]

for i in range(1,N):
    if max < A[i]:
        max = A[i]
    if min > A[i]:
        min = A[i]

print(max-min)

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

const int P = 1000000007;
int fac[150], ifac[150], ans, n, k;
bool del[75];
vector<int> f, r;
char s[75];

int power(int a, int x) {
	int ans = 1;
	for (; x; x >>= 1, a = 1ll * a * a % P)
		if (x & 1) ans = 1ll * ans * a % P;
	return ans;
}

bool check() {
	fill(del + 1, del + 1 + k, false);
	for (int i = 0; i < f.size(); ++i) del[r[i]] = true;
	vector<int> b(f.size());
	for (int i = f.size() - 1; i >= 0; --i)
		if (f[i] >= 2) {
			int j;
			for (j = r[f.size() - 1 - i] + 1; (del[j] || s[j] == 'r') && j <= k; ++j);
			if (j > k) return false;
			b[i] = j;
			del[j] = true;
		}
	for (int i = f.size() - 1; i >= 0; --i)
		if (f[i] >= 3) {
			int cnt = f[i] - 2;
			for (int j = b[i] + 1; cnt && j <= k; ++j)
				if (!del[j]) del[j] = true, --cnt;
			if (cnt) return false;
		}
	return true;
}

void dfs(int lst, int sum) {
	if (f.size() > r.size()) return;
	if (check()) {
		int s = n + 1, c = fac[f.size()], s1 = 0;
		for (int i = 0, j; i < f.size(); i = j) {
			for (j = i + 1; j < f.size() && f[j] == f[i]; ++j);
			c = 1ll * c * ifac[j - i] % P;
			if (f[i] > 1) s += 2 * (j - i);
			s1 += 2 * f[i] * (j - i);
		}
		ans = (ans + 1ll * c * fac[s] % P * ifac[s1] % P * ifac[s - s1]) % P;
	}
	for (int i = lst; (sum + max(1, i - 1)) * 2 <= n + 1; ++i) f.push_back(i), dfs(i, sum + max(1, i - 1)), f.pop_back();
}

int main() {
	scanf("%d%d%s", &n, &k, s + 1);
	for (int i = 1; i <= k; ++i)
		if (s[i] == 'r') r.push_back(i);
	for (int i = fac[0] = 1; i <= 2 * n + 5; ++i) fac[i] = 1ll * fac[i - 1] * i % P;
	ifac[2 * n + 5] = power(fac[2 * n + 5], P - 2);
	for (int i = 2 * n + 5; i; --i) ifac[i - 1] = 1ll * ifac[i] * i % P;
	dfs(1, 0);
	printf("%d\n", ans);
	return 0;
}


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

int main(){
	int i, cnt;
	char c;
	string w;
	cin >> w;
	for(c = 'a'; c <= 'z'; c++){
		for(i = 0, cnt = 0; i < w.size(); i++){
			if(w[i] == c){
				cnt++;
			}
		}
		if(cnt % 2 == 1){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

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

int main()
{
    int  a,b,w,nu;

    while(cin>>w>>a>>b)
    {

        if(a<b&&a+w<b||b<a&&b+w<a )
        {

            if(b>a+w) nu=b-a-w;
            else nu=a-b-w;
        }
        else nu=0;

        cout<<nu<<'\n';


    }
    return 0;
}


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

using namespace std;

const int MAX_P = 301;
const int MAX_N = 1000;
int data[MAX_P];
int test[MAX_N][4];
int num;

void input(){
  for(int j = 0; j < num; j++){
    cin >> test[j][0] >> test[j][1] >> test[j][2] >> test[j][3];
    if(test[j][3]){
      data[test[j][0]] = 1;
      data[test[j][1]] = 1;
      data[test[j][2]] = 1;
    }
  }
}

int check(int pos){
  int sum = 0;
  for(int i = 0; i < 3; i++)
    if(data[test[pos][i]] == 1) sum++;
  
  if(sum == 2){
    for(int i = 0; i < 3; i++)
      if(data[test[pos][i]] == 2){
	data[test[pos][i]] = 0;
	return 1;
      }
  }
  return 0;
}

void solve(){
  int update = 0;
  while(1){
    for(int i = 0; i < num; i++){
      if(!test[i][3])
	if(check(i)) update = 1;
    }
    if(!update) break;
    update = 0;
  }
}

int main(){

  int a,b,c;
  while(cin>>a>>b>>c && a+b+c){
    fill(data,data+MAX_P,2);
    cin >> num;
    input();
    solve();
    for(int i = 1; i <= a+b+c; i++) cout << data[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

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

int main()
{
	int K;
	cin >> K;
	long long ans = 0;
	for (int a = 1; a <= K; ++a) {
		for (int b = 1; b <= K; ++b) {
			for (int c = 1; c <= K; ++c) {
				ans += gcd(gcd(a, b), c);
			}
		}
	}
	cout << ans << endl;
}


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

using namespace std;

typedef long long ll;

ll D[202020], K[202020], C[202020];
ll n;

bool check(ll k)
{
	ll i, x, cnt;
	
	for(i=0; i<=n+n+1; i++) K[i] = C[i] = 0;
	
	cnt = 0;
	x = n + 1; K[x] ++, C[x] ++;
	
	for(i=1; i<=n; i++){
		if(D[i] < k) x -= 1;
		else x += 1;
		cnt += C[x - 1] + K[x];
		K[x] ++; C[x] = C[x - 1] + K[x];
	}
	
	return cnt * 4 >= n * (n + 1);
}

int main()
{
	ll i, s, e, mid;
	
	scanf("%lld", &n);
	
	for(i=1; i<=n; i++){
		scanf("%lld", D + i);
	}
	
	for(s=1, e=1e9; s<=e; ){
		mid = s + e >> 1;
		if(check(mid)) s = mid + 1;
		else e = mid - 1;
	}

	check(1);
	
	printf("%lld\n", s - 1);
	
	return 0;
}

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

int main() {
  int N;
  cin >> N;

  // ここにプログラムを追記
  for(int i = 0; i < N; i++) {
    string S;
    cin >> S;
    
    if (i == N - 1 && S != "Y") {
      cout << "Three" << endl;
      break;
    }
    else if (S == "P") {
      continue;
    }
    else if (S == "W") {
      continue;
    }
    else if (S == "G") {
      continue;
    }
    else {
      cout << "Four" << endl;
      break;
    }
  }
}


Measured memory_bytes: 764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(int.Parse).ToArray();
        int result = 0;
        int count = n[3];
        if(count < n[0])
        {
            result += count;
            count = 0;
        }
        else
        {
            result += n[0];
            count -= n[0];
        }
        if(count < n[1])
        {
            result += count;
            count = 0;
        }
        else
        {
            count -= n[1];
        }
        if(count < n[2])
        {
            result -= count;
            count = 0;
        }
        else
        {
            result -= n[2];
            count -= n[2];
        }

        WriteLine($"{result}");
    }
}


Measured memory_bytes: 19072
#include <bits/stdc++.h>
using namespace std;
int a[1000005];
int b[1000005];
int main(){
    cin >> a[0];
    int ans;
    for(int i=1;i<1e6+1;i++){
        if(a[i-1]%2==0)a[i]=a[i-1]/2;
        else a[i]=3*a[i-1]+1;
        if(b[a[i]]>0||a[i]==a[0]){
            ans=i; break;
        }
        b[a[i]]=i;
    }
    cout << ans+1 << endl;
}

Measured memory_bytes: 2304
#include<iostream>
using namespace std;
int a,b,c,o,n;
int main()
{
	cin >>a>>b>>c;
	for (int i=0;i<a;i++)
	{
		cin >>n;
		if (n<b || n>=c) o++;
	}
	cout <<o<<endl;
	return 0;
}

Measured memory_bytes: 256
N,M=map(int, input().split())
a_list=[]
for i in range(M):
    a_list.append(list(map(int,input().split())))
V_list=[[] for i in range(N)]

for item in a_list :
    V_list[item[0]-1].append(item[1])
    V_list[item[1] - 1].append(item[0])

from collections import deque
s_list=[0]*N
current_V=deque()
current_V.append(1)

while (current_V!=deque([])) :
    a=current_V.popleft()
    current_list=V_list[a-1]
    for item in current_list :
        if s_list[item-1]==0 :
            current_V.append(item)
            s_list[item-1] =a
print('Yes')
for item in s_list[1:] :
    print(item)


Measured memory_bytes: 123376
h, w = map(int, input().split())
ls_a = [input() for _ in range(h)]

for i in range(h):
    ls_a[i] = "#" + ls_a[i] + "#"

top = "#" * len(ls_a[0])
bottom = "#" * len(ls_a[0])


print(top)
for j in range(h):
    print(ls_a[j])
print(bottom)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    ll n,a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e;
    ll mi=min({a,b,c,d,e});
    ll ans=(n+mi-1)/mi+4;

    cout<<ans<<endl;
}

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

#define ll long long

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
        int n;
	cin>>n;
	int arr[n];
	for(int i =0;i<n;i++)
		cin>>arr[i];
	vector<int>dp(n+1,-1);
	dp[1]=0;
	dp[2]=abs(arr[1]-arr[0]);
	if(n>2)
	{
		for(int i=3;i<n+1;i++)
		{
			dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i-2]),dp[i-2]+abs(arr[i-1]-arr[i-3]));
		}
	}
	int cost=dp[n];
	cout<<cost<<'\n';

}

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

int main() {
    long n;
    cin >> n;

    if (n == 1) {
        cout << "Hello World" << endl;
    }
    else if (n == 2) {
        long a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }

    return 0;
}


Measured memory_bytes: 256
function Main(input) {
    input = input.split("\n");
    const k = parseInt(input[0],10);
    const s = input[1];

    if(s.length <= k){
        console.log(s);
    }else{
        console.log(s.slice(0,k) + "...")
    }

}
 
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29540
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define pb emplace_back
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define rep(i, j, k) for(i=j; i<k; i++)
#define sep(i, j, k) for(i=j; i>k; i--)
const int N = 2e5+5, inf = 1e9+7;
int n, k, i, j;
int A[N], B[N], dp[101][N];

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int i, j, a, b, ans = 0;
    cin>>n>>k;
    rep(i, 1, n+1) cin>>A[i]>>B[i];
    rep(i, 0, n) {
    rep(j, 0, k-A[i+1]+1)
        dp[i+1][j+A[i+1]] = max(dp[i+1][j+A[i+1]], dp[i][j]+B[i+1]);
        rep(j, 0, k+1) dp[i+1][j]=max(dp[i+1][j], dp[i][j]);
    }
    cout<<dp[n][k];
}

Measured memory_bytes: 158464
x = int(input())

if x < 600:
    print("8")
elif x < 800:
    print("7")
elif x < 1000:
    print("6")
elif x < 1200:
    print("5")
elif x < 1400:
    print("4")
elif x < 1600:
    print("3")
elif x < 1800:
    print("2")
elif x < 2000:
    print("1")


Measured memory_bytes: 9168
#include<bits/stdc++.h>
#define LL long long
using namespace std;

const int maxn = 2e5 + 10;
int n;
bool flag = false;
LL sum = 0, a[maxn], b[maxn];

int main()
{
    scanf("%d", &n);

    LL ans = 0;
    for(int i = 1; i <= n; i ++) {
        scanf("%lld%lld", &a[i], &b[i]);
        if(a[i] < b[i])
            flag = true;
        sum += a[i];
    }
    for(int i = 1; i <= n; i ++) {
        if(a[i] > b[i])
            ans = max(ans, sum - a[i] + a[i] - b[i]);
    }
    printf("%lld\n", flag ? ans : 0);
    return 0;
}


Measured memory_bytes: 512
s = list(input())
n = len(s)

t = s[::-1]
a = s[0:(n-1)//2]
b = a[::-1]
c = s[(n+3)//2-1:n]
d = c[::-1]

if s == t and a == b and c == d:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064