akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#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 RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

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

const int MAX = 1e5 + 10;
int N, M;
VI G[MAX];
int S, T;
int ans[3][MAX];

int main(void) {
    scanf("%d%d", &N, &M);
    REP(i, M) {
        int u, v;
        scanf("%d%d", &u, &v);
        u--; v--;
        G[u].EB(v);
    }
    scanf("%d%d", &S, &T);
    S--; T--;
    REP(i, 3) REP(j, MAX) ans[i][j] = INF;

    queue<PII> que;
    que.emplace(S, 0);
    ans[0][S] = 0;
    while (!que.empty()) {
        int cur, cost;
        tie(cur, cost) = que.front();
        que.pop();

        const int mod3 = cost % 3;

        const int nxt_mod3 = (mod3 + 1) % 3;
        const int nxt_cost = cost + 1;
        FORE(nxt, G[cur]) {
            if (ans[nxt_mod3][nxt] <= nxt_cost) continue;
            ans[nxt_mod3][nxt] = nxt_cost;
            que.emplace(nxt, nxt_cost);
        }
    }

    if (ans[0][T] == INF) cout << -1 << endl;
    else cout << ans[0][T] / 3 << endl;
}


Measured memory_bytes: 6912
import java.util.*;
public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long cnt = 1;
        long mod = 1000000007;

        for(int i =1;i<=n;i++){
            cnt=(cnt*i)%mod;
        }
        System.out.println(cnt);
    }
}






Measured memory_bytes: 21844
# 安いやつから買い占めていく
# 少ないのでwhileしてもいいんだと思う多分

n, m = gets.chomp.split.map(&:to_i)
set = []
n.times do
  set << gets.chomp.split.map(&:to_i)
end
set = set.sort_by{|s| s[0]}
cost = 0
amount = 0
idx = 0
while amount < m do
  if set[idx][1] == 0
    idx+=1
    next
  end
  amount += 1
  cost += set[idx][0]
  set[idx][1]-=1
end
puts cost

Measured memory_bytes: 12664
N, M = map(int, input().split())
isAC = [False] * (N+1)
penalties = [0] * (N+1)
ac, penalty = (0, 0)
for _ in range(M):
  p, s = input().split()
  p = int(p)
  if s == "AC":
    if not isAC[p]:
      isAC[p] = True
      ac += 1
      penalty += penalties[p]
  else:
    penalties[p] += 1
print(ac, penalty)

Measured memory_bytes: 4596
from subprocess import*
with open('Main.java','w')as f:f.write(r"""
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		int d = Integer.parseInt(sc.next());
		int e = Integer.parseInt(sc.next());
		int f = Integer.parseInt(sc.next());
		int water = 0;
		int sugar = 0;
		for (int i = 0; i <= f; i += 100 * a) {
			for (int j = 0; i + j <= f; j += 100 * b) {
				for (int k = 0; i + j + k <= f; k += c) {
					for (int l = 0; i + j + k + l <= f; l += d) {
						if ((k + l) * 100 <= e * (i + j)) {
							if ((water == 0 && sugar == 0)|| sugar * (i + j + k + l) < (k + l) * water) {
								water = i + j + k + l;
								sugar = k + l;
							}
						}
					}
				}
			}
		}
		System.out.println(water + " " + sugar);
	}
}
""")
call(('javac','Main.java'))
call(('java','Main'))

Measured memory_bytes: 57604
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

bool lunlun(int N) {
	int prev = -1;
	while (N) {
		int current = N % 10;
		if (!(prev == -1 || abs(prev - current) <= 1)) {
			return false;
		}
		N /= 10;
		prev = current;
	}
	return true;
}

void Main() {
	int K; cin >> K;
	vl lunluns;
	auto dfs = [&](auto dfs, ll v) -> void {
		if (v > 3234566667) return;
		REP(i,10) {
			if (abs((v % 10) - i) > 1) continue;
            dfs(dfs, v * 10 + i);
        }
		lunluns.push_back(v);
    };
	FOR(i,1,10) {
		dfs(dfs,i);
	}
	sort(ALL(lunluns));
	cout << lunluns[K - 1] << endl;

}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 4272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> a(3 * n);
    rep(i, 3 * n) cin >> a[i];
    sort(all(a));
    ll sum = 0;
    rep(i, n) {
        sum += a[n + i * 2];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(){

	int a;
	int b;
	int c;

	int n;
	cin >> n;

	for(int i=1; i<=n; i++){

		cin >> a >> b >> c;

		if(a*a+b*b==c*c || a*a+c*c==b*b || b*b+c*c==a*a){

			cout << "YES\n";

		}
		else {
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 1152
ans=[0 for i in range(10**4+1)]

n=int(input())

def calc(x,y,z):
    return x**2+y**2+z**2+x*y+y*z+z*x

for i in range(1,100):
    for q in range(1,100):
        for p in range(1,100):
            if calc(i,q,p)<=10**4:
                ans[calc(i,q,p)]+=1

for i in range(1,n+1):
    print(ans[i])

            

Measured memory_bytes: 9156
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (M1, D1): (i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };
    let (M2, D2): (i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    let ans = if D2 == 1 { 1 } else { 0 };

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#include <ios>     
#include <iomanip> 
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}

//ここまで共通

int N;
int W[110];
int WW[110];
int R = 0;
int L = 0;
int ans;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> W[i];
		R += W[i];
	}

	ans = R;

	for (int i = 0; i < N; i++) {
		ans = min(ans, abs(R - L));
		R -= W[i];
		L += W[i];
	}
	cout << ans;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main() {
    int n;
    cin >> n;
    vector<int> e(100001), o(100001);
    rep(i, n) {
        int tmp;
        cin >> tmp;
        if (i % 2 == 0) {
            e[tmp]++;
        }
        else {
            o[tmp]++;
        }
    }
    vector<int> indices_e(100001), indices_o(100001);
    iota(all(indices_e), 0);
    iota(all(indices_o), 0);

    sort(all(indices_e), [&](int i1, int i2){
        return e[i1] > e [i2];
    });
    sort(all(indices_o), [&](int i1, int i2){
        return o[i1] > o [i2];
    });
    if (indices_e[0] == indices_o[0]) {
        int first = e[indices_e[0]];
        int second = max(e[indices_e[1]], o[indices_o[1]]);
        cout << n - first - second << endl;
    }
    else {
        int first = e[indices_e[0]];
        int second = o[indices_o[0]];
        cout << n - first - second << endl;
    }
}

Measured memory_bytes: 1792
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

neighbor_max_heights = [0] * N

for i in range(M):
    a, b = AB[i]
    neighbor_max_heights[b-1] = max(neighbor_max_heights[b-1], H[a-1])
    neighbor_max_heights[a-1] = max(neighbor_max_heights[a-1], H[b-1])

ans = 0
for j in range(N):
    if H[j-1] > neighbor_max_heights[j-1]:
        ans += 1
print(ans)

Measured memory_bytes: 32032
N, M = map(int, input().split())
P_Y_i = [list(map(int, input().split())) for i in range(M)]
for i in range(M):
    P_Y_i[i].append(i)
Ken_index = [[] for i in range(N)]

for i in range(M):
    Ken_index[P_Y_i[i][0] - 1].append(P_Y_i[i])
for i in range(N):
    if len(Ken_index[i]) != 0:
        Ken_index[i].sort(key=lambda x: x[1])

Ken_Update = []
for Ken in Ken_index:
    for i in range(len(Ken)):
        Ken_Update.append(['{0:06d}'.format(Ken[i][0]) + '{0:06d}'.format(i+1), Ken[i][2]])

Ken_Update.sort(key=lambda x: x[1])

for i in range(len(Ken_Update)):
    print(Ken_Update[i][0])


Measured memory_bytes: 55832
def main():
    import sys
    def I():
        return int(sys.stdin.readline().rstrip())

    def MI():
        return map(int, sys.stdin.readline().rstrip().split())

    N = I()
    dist = [[100] * (N + 1) for _ in range(N + 1)]  # 2点間の最短距離
    edges = {}

    for i in range(N - 1):
        a, b = MI()
        dist[a][b] = 1
        dist[b][a] = 1
        edges[(a, b)] = i
        edges[(b, a)] = i

    for i in range(1, N + 1):
        dist[i][i] = 0

    for k in range(1, N + 1):
        for i in range(1, N + 1):
            for j in range(1, N + 1):
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

    M = I()
    A = []  # uとvを結ぶ経路上にある辺の集合
    for _ in range(M):
        u, v = MI()
        B = set()
        while True:
            if dist[u][v] == 1:
                B.add(edges[(u, v)])
                break
            else:
                for i in range(1, N + 1):
                    if dist[u][i] == dist[u][v] - 1 and dist[i][v] == 1:
                        B.add(edges[(i, v)])
                        v = i
                        break
        A.append(B)

    # 包除原理

    ans = 0
    for i in range(2 ** M):
        C = set()
        a = 0
        for j in range(M):
            if (i >> j) & 1:
                C |= A[j]
                a += 1
        l = len(C)
        a %= 2
        ans += (-1) ** a * 2 ** (N - 1 - l)

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 68852
S = list(input())
N = len(S)
S_n_1 = S[:(N-1)//2]
S_n_2 = S[(N+3)//2-1:]
# print(S_n_1)
# print(S_n_2)

flag = 0
reverse_S = list(reversed(S))
reverse_S_n_1 = list(reversed(S_n_1))
reverse_S_n_2 = list(reversed(S_n_2))
# print(reverse_S_n_1)
# print(reverse_S_n_2)

if S == reverse_S and S_n_1 == reverse_S_n_1 and S_n_2 == reverse_S_n_2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

int main() {
	std::string s;
	int a_place = 0, z_place = 0;
	int calc(std::string str, int n);
	std::cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'A') { a_place = i+1; break; }
	}
	for (int i = s.length(); i > 0; i--) {
		if (s[i] == 'Z') { z_place = i+1; break; }
	}
	std::cout << z_place - a_place + 1 << std::endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    vector<int>b;
    for(int i = 1;i<n;i += 2) {
        b.push_back(a[i]);
    }
    reverse(b.begin(),b.end());
    for(int i = 0;i<n; i+= 2) {
        b.push_back(a[i]);
    }
    if(n%2 == 1) reverse(b.begin(),b.end());
    rep(i,n) {
        cout << b[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 5104
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
stringstream __ss__;
#define debug __ss__
#endif

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) debug << *i << " "; debug << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;i--)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);i--)
#define rep0(i,n) for(i=0;i<(n);++i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

map<string,int> cards;

int main() {
	int n=in();
	cards["A"]=1;
	cards["2"]=2;
	cards["3"]=3;
	cards["4"]=4;
	cards["5"]=5;
	cards["6"]=6;
	cards["7"]=7;
	cards["8"]=8;
	cards["9"]=9;
	cards["T"]=10;
	cards["J"]=10;
	cards["Q"]=10;
	cards["K"]=10;
	while(n--){
		vint hand,deck;
		string str;
		rep(i,2){
			cin>>str;
			hand.PB(cards[str]);
		}
		rep(i,8){
			cin>>str;
			deck.PB(cards[str]);
		}
		sort(all(hand));
		if(hand[0]==1&&hand[1]==10){
			cout<<"blackjack\n";
			continue;
		}
		int sum;
		rep(i,9){
			sum=0;
			rep(j,sz(hand)){
				sum+=hand[j];
			}
			if(sum!=7||hand[0]!=1){
				if(sum<=11&&hand[0]==1)sum+=10;
				if(sum>=17)break;
			}
			if(i==8)break;
			hand.PB(deck[i]);
			sort(all(hand));
		}
		if(sum>21)cout<<"bust\n";
		else cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define SIZE(a) int((a).size())
const int INF=INT_MAX;
const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll n;cin>>n;
  n%=10;
  if(n==0||n==1||n==6||n==8){cout<<"pon"<<endl;}
  else if(n==3){cout<<"bon"<<endl;}
  else{cout<<"hon"<<endl;}
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>

int main() {

        int n;
        std::cin >> n;

        int tn = n;
        int s = 0;
        while (tn != 0) {
                s += tn % 10;
                tn /= 10;
        }

        if (n % s == 0) {
                std::cout << "Yes" << std::endl;
        }
        else {
                std::cout << "No" << std::endl;
        }

        return 0;
}

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

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

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let mut ans = vec![0; n];

    for i in 0..n {
        ans[a[i] - 1] = i + 1;
    }

    for i in 0..n {
        print!("{} ", ans[i]);
    }
}


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

int main()
{
  cout<<fixed<<setprecision(10);
  int n;
  cin>>n;
  vector<int>a(n);
  vector<int>b(n);
  
  for(int i=0;i<n;i++)
  {
    cin>>a[i]>>b[i];
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  int ans=0;
  if(n%2!=0)
  {
    ans=b[n/2]-a[n/2]+1;
  }
  else 
  {
    long long am=(a[(n/2)]+a[(n/2)-1]);
    long long bm=(b[(n/2)]+b[(n/2)-1]);
 	ans=(bm-am)+1;
  }
  cout<<ans<<endl;
 
  return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

double getR(double a, double b, double c, double tana, double tanb, double S)
{
    double ok = 0, ng = a;
    REP(i, 50)
    {
        double r = (ok + ng) * 0.5;
        double n = r / tana, m = r / tanb;
        double h = 2 * S / a;
        double ts = b * r * 0.5 + c * r * 0.5 + (h - r) * r + r * 2 * r + n * r * 0.5 + m * r * 0.5;
        if (n + m + 2 * r > a || ts > S)
        {
            ng = r;
        }
        else
        {
            ok = r;
        }
    }
    return ok;
}

int main()
{
    pll A, B, C;
    cin >> A.first >> A.second;
    cin >> B.first >> B.second;
    cin >> C.first >> C.second;

    double AB = sqrt(pow(A.first - B.first, 2) + pow(A.second - B.second, 2));
    double BC = sqrt(pow(C.first - B.first, 2) + pow(C.second - B.second, 2));
    double CA = sqrt(pow(A.first - C.first, 2) + pow(A.second - C.second, 2));

    double s = 0.5 * (AB + BC + CA);
    double S = sqrt(s * (s - AB) * (s - BC) * (s - CA));

    double tanA = tan(asin(2 * S / (AB * CA)) * 0.5);
    double tanB = tan(asin(2 * S / (BC * AB)) * 0.5);
    double tanC = tan(asin(2 * S / (BC * CA)) * 0.5);

    double mr = 0;
    mr = std::max(mr, getR(AB, BC, CA, tanA, tanB, S));
    mr = std::max(mr, getR(BC, CA, AB, tanB, tanC, S));
    mr = std::max(mr, getR(CA, AB, BC, tanC, tanA, S));

    cout << OF64 << mr << endl;
    return 0;
}

Measured memory_bytes: 640
// Problem : C - Cat Snuke and a Voyage
// Contest : AtCoder - AtCoder Beginner Contest 068
// URL : https://atcoder.jp/contests/abc068/tasks/arc079_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int n,m;cin>>n>>m;
vector<set<int>> v(n+1);
while(m--)
{
	int x,y;cin>>x>>y;
	v[x].insert(y);
	v[y].insert(x);
}
for(int i:v[1])
{
	if(v[i].find(n)!=v[i].end())
	{
		cout<<"POSSIBLE";
		return;
	}
}
cout<<"IMPOSSIBLE";
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

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

    cin >> skipws;

    // for (;;) {
        int n; cin >> n;
        // if (!n) break;

        int tok = 0;
        bool isbad = false;

        rep(i, 0, n) {
            string s; cin >> s;
            if (s == "A") tok++;
            else {
                if (tok <= 0) isbad = true;
                tok--;
            }
        }

        if (isbad || tok != 0) {
            cout << "NO" << endl;
        } else {
            cout << "YES" << endl;
        }
    // }
}


Measured memory_bytes: 3248
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define max_n 1000000

using namespace std;

void solve()
{
	ll n;
	cin >> n;
	vector<set<pair<ll, pair<ll, ll>>>> v(1e4 + 1);
	for (int i = 1; i * i <= 1e4; ++i)
	{
		for (int j = 1; j * j <= 1e4; ++j)
		{
			for (int k = 1; k * k <= 1e4; ++k)
			{
				if (i * i + j * j + k * k + i * j + i * k + j * k <= 1e4)
					v[i * i + j * j + k * k + i * j + i * k + j * k].insert({i, {j, k}});
			}
		}
	}
	for (int i = 0; i < n; ++i)
	{
		cout << v[i + 1].size() << endl;
	}
}

int32_t main()
{
	IOS
	ll T = 1;
	// cin>>T;
	for (ll i = 1; i <= T; ++i)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 19292
#include <stdio.h>
int main(){
     int D;

     scanf("%d", &D);
    
     if(D == 25){
       printf("Christmas\n");
     }
     else if(D == 24){
       printf("Christmas Eve\n");
     }
     else if(D == 23){
       printf("Christmas Eve Eve\n");
     }
     else {
       printf("Christmas Eve Eve Eve\n");
     }

     return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#define SIZE 110001000

using namespace std;

bool isPrime[SIZE];

int main(){
	fill(isPrime, isPrime+SIZE, true);
	isPrime[0] = isPrime[1] = false;
	for(int i=0; i<SIZE; i++){
		if(!isPrime[i]) continue;
		for(int j=i+i; j<SIZE; j+=i){
			isPrime[j] = false;
		}
	}

	while(1){
		int n; cin >> n;
		if(!n) break;
		int ans = 0;
		for(int i=n+1; i<(2*n)+1; i++){
			if(isPrime[i]) ans++;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 110488
#include <iostream>
#include <algorithm>
#include <climits>

using namespace std;

int main() {
	int N, W;
	int v[101], w[101];
	int T[101][10001];

	cin >> N >> W;

	for (int i = 0; i <= W; i++) {
		T[0][i] = 0;
	}

	for (int i = 1; i <= N; i++) {
		cin >> v[i] >> w[i];
	}

	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < w[i]; j++) {
			T[i][j] = T[i - 1][j];
		}
		for (int j = w[i]; j <= W; j++) {
			T[i][j] = max(T[i - 1][j - w[i]] + v[i], T[i - 1][j]);
		}
	}

	cout << T[N][W] << endl;

	return 0;
}

Measured memory_bytes: 5104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define fr(i,n) for(i = 0 ; i < n ; i++)
int main()
{
    fio
    int n,i,j,k;
    cin>>n;
    int a[n][3];
    ll dp[n][3];
    fr(i,n)
    {fr(j,3)
        cin>>a[i][j];}
    for(i = 0;i<3;i++)
    dp[0][i] = a[0][i];
    for(i = 1;i<n;i++)
    {
        dp[i][0] = a[i][0]+max(dp[i-1][1],dp[i-1][2]);
         dp[i][1] = a[i][1]+max(dp[i-1][0],dp[i-1][2]);
          dp[i][2] = a[i][2]+max(dp[i-1][1],dp[i-1][0]);
    }
    cout<<(max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])));
    return 0;

}


Measured memory_bytes: 3840
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  while(h!=0){
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
    if(i==0||i==h-1||j==0||j==w-1)
      cout << "#";
    else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
  return 0;
}


Measured memory_bytes: 3088
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , a[N] , q ;

int main ( ){
 ll x , y;
 scanf("%lld %lld",&x,&y);
 printf("%lld\n",min(x%y,y-(x%y)));
return 0 ;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if(a <= 8 && b <= 8) cout << "Yay!" << endl;
    else cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 3524
#include<bits/stdc++.h>
using namespace std;
char shift(char ch,int N){
    int d = ch-'A';
    int dn=0;
    if(N+d>25) dn = N+d-26;
    else dn = N+d;
    return (char)(dn+'A');
}
int main (){
    int N;cin >> N;
    string S;cin>>S;
    for(int i=0;i<S.size();i++){
        S[i]=shift(S[i],N);
    }
    cout<<S<<endl;
    return 0;
}

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

ll n;
string s;

int main(){

  cin >> n;
  if(n == 0){
    cout << "0" << endl;
    return 0;
  }

  while(n != 0){
    if(n%2 == 0){
      s = "0" + s;
      n /= -2;
    }
    else {
      s = "1" + s;
      n = (n-1) / -2;
    }
  }
  cout << s << endl;

  return 0;
}


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

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}


int main(){
  
  int n,k;
  int ans=0;
  int p[1000];
  cin>>n>>k;
  
  for(int i=0;i<n;i++)
    cin>>p[i];
  
  qsort(p, n, sizeof(int), compare_int);
  
  for(int i=0;i<k;i++)
    ans += p[i];
  
  cout<<ans<<endl;
  
  return 0;
}

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

using namespace std;

const int mod = (int) 998244353;
const int N = (int) 2e5 + 9;

int n, k;
int l[N], r[N];
long long dp[N];

class BIT_SU{
// Writer: BERNARB.01
/// This is a Binary Indexed Tree that supports:
///  * range sum queries in O(log n).
///  * updating single element in O(log n).
/// Note: indexing starts from 1.

public:
    int size; // This is the size of the tree.
    vector<long long> Tree; // The tree is stored in this array.

    // Allocating the tree.
    void newBIT_SU (int siz) {
        Tree.resize(siz);
        this->size = siz;
    }

    // Update the element at index by delta.
    void update (int index, int delta) {
        while (index<size) {
            Tree[index] += delta;
            Tree[index] %= mod;
            index += index&-index;
        }
    }

    // Returns the sum of all element form the first one to the one at index
    // (returns the sum of the range [1, index]).
    long long sum (int index) {
        long long s = 0;
        while (index) {
            s += Tree[index];
            s %= mod;
            index -= index&-index;
        }
        return s;
    }

    // Returns the sum of the range [l, r].
    long long rangeSum (int lL, int rr) {
        return (sum(rr) - sum(lL-1) + mod) % mod;
    }

};

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    cin >> l[i] >> r[i];
  }
  BIT_SU st;
  st.newBIT_SU(4 * n);
  dp[n - 1] = 1;
  st.update(n, 1);
  for (int i = n - 2; i >= 0; i--) {
    for (int j = 0; j < k; j++) {
      dp[i] += st.rangeSum(l[j] + i + 1, r[j] + i + 1);
      dp[i] %= mod;
    }
    st.update(i + 1, dp[i]);
  }
  cout << dp[0] << '\n';
  return 0;
}

Measured memory_bytes: 11156
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

"""
約数を全列挙する
"""
# 参考: https://qiita.com/LorseKudos/items/9eb560494862c8b4eb56
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    
    return divisors

def main():
    n = int(input())
    cnt = 0

    for i in range(1, n+1):
        if i % 2 == 0:
            continue
        if len(divisors(i)) == 8:
            cnt += 1
    print(cnt)
    return

if __name__ == '__main__':
    main()

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

int main() {
 char c[55][55]; int h,w,cnt;
 cin >> h >> w;
 for(int i= 0;i<h;i++)for(int j=0;j<w;j++)cin >> c[i][j];
 for(int i =1;i<=h;i++){
 	for(int j =1;j<=w;j++){
 		if(c[i][j] == '#' && c[i][j-1] !='#'&& c[i-1][j] !='#' && c[i][j+1] !='#' && c[i+1][j] !='#' )cnt++;
 	}
 }
if(cnt == 0) cout <<"Yes" << endl;
else cout <<"No" << endl;
}

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

using namespace std;


//二項係数ライブラリ
const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
//前処理COMinit()忘れずに


long long pow(long long x, long long n) {
    if (n == 0) return 1;
    long long res = pow(x * x, n / 2);
    if (n & 1) res = res * x;
    return res; 
}


string S;
int N, K;


long long rec(int i, int k, int smaller) {
    if  (i == N) {
        if (k == 0) return 1;
        else return 0;
    }
    if (k == 0) return 1;

    if (smaller) return COM(N-i, k) * pow(9, k);
    else {
        if (S[i] == '0') return rec(i+1, k, false);
        else {
            long long zero = rec(i+1, k, true);
            long long aida = rec(i+1, k-1, true) * (S[i] - '1');
            long long icchi = rec(i+1, k-1, false);
            return zero + aida + icchi;
        }
    }
}


void solve() {
    cin >> S >> K;
    N = S.size();
    COMinit();
    cout << rec(0, K, false) << endl;
}


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

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

int N; string s;
vector<char> news;
int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> s;
    for (int i = 0; i < N; i++) {
        if(i==0)news.push_back(s[i]);
        else{
            if(news[news.size()-1]==s[i]) continue;
            news.push_back(s[i]);
        }
    }
    cout << news.size() << '\n';
    return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){ 
    int a[3];
    rep(i,3) cin >> a[i];
    sort(a,a+3);
    cout << a[0] + a[1] << endl;

}

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
  for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
  T x;
  cin >> x;
  return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
  cin >> head;
  CIN(move(tail)...);
}
#define CINT(...)                                                              \
  int __VA_ARGS__;                                                           \
  CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
  ll __VA_ARGS__;                                                            \
  CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
  string __VA_ARGS__;                                                        \
  CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
  {                                                                          \
  FOREACH(x, v) { cout << x << " "; }                                    \
    cout << "\n";                                                          \
    }

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N, M;

signed main(){
  while(1){
    ll b;
    cin >> b;
    if(b == 0)break;
    ll nmax = sqrt(b * 2) + 1;
    for(ll n = nmax; n >= 1; n--){
      if(2 * b % n == 0){
	int sm = 2 * b / n - n + 1;
	if(sm > 0 && sm % 2 == 0){
	  int s = sm / 2;
	  int tmp = ( 2 * s + n - 1 ) * n / 2;
	  if( tmp == b ){
	    cout << s << ' ' << n << endl;
	    break;
	  }
	}
      }
    }
  }
}



Measured memory_bytes: 3076
n = input()
p = list(map(int, input().split()))

c = 0

for i in range(len(p)-2):
    if p[i+1] != max([p[i],p[i+1],p[i+2]]) and p[i+1] != min([p[i],p[i+1],p[i+2]]):
        c += 1
        
print(c)

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

int main(){
	int n;
	double ind;
	string ins;
	double ans = 0;
	cin >> n;
	rep(i, n){
		cin >> ind >> ins;
		if(ins == "BTC") ans += ind * 380000;
		else ans += ind;
	}
	printf("%10f\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s;
  cin >> s;
  int n = len(s);
  s += "R";
  vector<int> ans(n,0);
  int k = 0, p = 0;
  rep(i,0,n+1) {
    if (k == 0) {
      if (s[i] == 'L') {
        int x = i-p;
        if (x % 2 == 0) {
          ans[i-1] += x/2;
          ans[i] += x/2;
        } else {
          ans[i-1] += dup(x,2);
          ans[i] += x/2;
        }
        k ^= 1;
        p = i;
      } else continue;
    } else {
      if (s[i] == 'R') {
        int x = i-p;
        if (x % 2 == 0) {
          ans[p-1] += x/2;
          ans[p] += x/2;
        } else {
          ans[p-1] += x/2;
          ans[p] += dup(x,2);
        }
        k ^= 1;
        p = i;
      } else continue;
    }
  }
  rep(i,0,n-1) {
    cout << ans[i] << " ";
  }
  cout << ans[n-1] << endl;
  return 0;
}


Measured memory_bytes: 3852
// ABC177-A
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int d,t,s;
    cin>>d>>t>>s;
    if(d<=t*s) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
#define N 100000
const int MOD = 1000000007;

int main(void)
{
	char a[50] = { "\0" }, b[50] = { "\0" };
	char c[50] = { "\0" };
	int a1 = 0, b1 = 0;
	scanf("%s %s", a, b);
	scanf("%d %d", &a1, &b1);
	scanf("%s", c);
	if (!strcmp(a, c))
	{
		a1--;
	}
	else
	{
		b1--;
	}
	printf("%d %d\n", a1, b1);
	return 0;
}


Measured memory_bytes: 128
/*
     Author: Wasi Ur Rahman
     RMSTU,Rangamati,Chittagong,Bangladesh
*/
#include <bits/stdc++.h>
using namespace std;
#define  gcd(a,b) __gcd(a,b)
#define  lcm(a,b) (a*b)/gcd(a,b)
#define  PI acos(-1.0)
#define  sqr(x) ((x)*(x))
#define  min3(a,b,c) min(a,min(b,c))
#define  min4(a,b,c,d) min(d,min(a,min(b,c)))
#define  max4(a,b,c,d) max(d,max(a,max(b,c)))
typedef   pair<int, int> ii;
typedef   std::vector<ii> vii;
#define   vi   std::vector<int>
#define   vll  std::vector<ll>
#define   all(n) n.begin(),n.end()
#define  mpsi std::map<string, int>
#define  pb             push_back
#define  ll             long long int
#define  ln             printf("\n");
#define  fast           ios::sync_with_stdio(false);cin.tie(0)
#define  max3(a,b,c)    max(a,max(b,c))
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define dec(x,y)        fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
#define  mod           1e9 + 7;
bool prm[1000001];
void sieve()
{
    prm[0] = prm[1] = 1;
    for(ll i = 4 ; i <= 1000000 ; i += 2)
        prm[i] = 1 ;
    for(ll i = 3 ; i * i <= 1000000 ; i += 2)
    {
        if(!prm[i])
        {
            for(ll j = i * i ; j <= 1000000 ; j+= i + i)
                prm[j] = 1 ;
        }
    }
}
const string str[32]={"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 main()
{
    fast;
    ll n,k;
    cin >> n>>k;
    cout << n % k << endl;
}


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

using namespace std;

void Main() {
    string O, E;
    cin >> O >> E;
    int N = O.size() + E.size();
    string ans = "";
    for (int i = 0; i < N; ++i) {
        if (i % 2 == 0) {
            ans += O[i / 2];
        }
        else {
            ans += E[i / 2];
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
#define pb push_back

int main() {

    ll n , t ,q  , j ;

    string s ;

    cin >> n ;
    ll ans = 0 ;


    for(ll i=1;i<=n;i++) {
        if (i%3 and i%5) ans+=i ;
    }
    cout << ans << endl ;

    return 0 ;
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(int N, int M, int[] X)
        {
            Array.Sort(X);
            var margins = new int[M - 1];
            for (int i = 0; i < M - 1; ++i)
            {
                margins[i] = X[i + 1] - X[i];
            }
            Array.Sort(margins);
            return margins.Take(Math.Max(M - N, 0)).Sum();
        }

        static void Main(string[] args)
        {
            int[] V = ReadInts();
            int[] X = ReadInts();
            Console.WriteLine(Solve(V[0], V[1], X));
        }
    }
}


Measured memory_bytes: 17120
n , k = map(int,input().split())
S = list(map(int,input().split()))
l = [1]
for i in range(2*n):
    l.append(S[l[i]-1])

L = len(l)
def f(s, e):
    a = s
    b = s

    while True:
        a += 2
        b += 1
        if a >= e:
            return None
        if l[a] == l[b]:
            break

    a = 0
    while True:
        a += 1
        b += 1
        if b >= e:
            return None
        if l[a] == l[b]:
            break

    return a, b

c, d = f(0, L)
loop = l[c:d]

m = d - c 
A = c + 1
B = d + 1
if k <=  n:
    print(l[k])
else:
   K = (k - c) % m
   print(loop[K])

Measured memory_bytes: 32272