akhauriyash/Code-Regression huggingface dataset:
use std::cmp::min;

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

fn main() {
    let n = scan!(usize);
    let hs = scan!(i64;;);

    let mut dp = vec![0; n];
    dp[0] = 0;
    dp[1] = (hs[1] - hs[0]).abs();
    for i in 2..dp.len() {
        dp[i] = min(
            dp[i - 1] + (hs[i] - hs[i - 1]).abs(),
            dp[i - 2] + (hs[i] - hs[i - 2]).abs(),
        )
    }
    println!("{}", dp[n - 1]);
}


Measured memory_bytes: 6396
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
#include <utility>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl
#define PI 3.14159265359

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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 main() {
  int n, k, r, s, p;
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  ll ans = 0;
  rep (i, t.size()) {
    if (t[i] == 'r') ans += p;
    else if (t[i] == 's') ans += r;
    else if (t[i] == 'p') ans += s;
  }
  for (int i = k; i < t.size(); i++) {
    if (t[i] == t[i - k]) {
      if (t[i] == 'r') ans -= p;
      if (t[i] == 's') ans -= r;
      if (t[i] == 'p') ans -= s;
      t[i] = '0';
    }
  }
  // rep (i, t.size()) {
  //   cout << t[i];
  // }
  // cout << endl;

  P(ans);
  return 0;
}



Measured memory_bytes: 512
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

from math import sqrt,cos,pi
a,b,h,m = ip()
angle = abs((h*60 + m)/2 - 6*m)
angle = min(360-angle,angle)*pi/180
c = sqrt(a**2 + b**2 - 2*a*b*cos(angle))
print(c)

Measured memory_bytes: 62544
N = int(input())
A = []
B = []
for i in range(N):
    x,y = map(int,input().split())
    A.append(x+y)
    B.append(x-y)

a = max(A)
b = min(A)
c = max(B)
d = min(B)

ans = max(a-b,c-d)
print(ans)

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

int main(){
    int n;
    cin >> n;
    vector<int> order(n);
    vector<int> food(n);
    vector<int> add(n-1);
    for(int i=0;i<n;i++){
        cin >> order.at(i);
    }
    for(int i=0;i<n;i++){
        cin >> food.at(i);
    }
    for(int i=0;i<n-1;i++){
        cin >> add.at(i);
    }
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=food.at(order.at(i)-1);
    }
    for(int i=0;i<n-1;i++){
        if(order.at(i)+1==order.at(i+1)){
            ans+=add.at(order.at(i)-1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF (2147483647)
#define MAXV (int)1e5+10

int N,W;
vector<int64_t>dp(MAXV,INF);
    
void solve()
{
    cin>>N>>W;
    dp[0]=0;
	for(int i=0;i<N;i++){
        int a,b;cin>>a>>b;
        for(int j=MAXV;j>=b;j--)
            dp[j]=min(dp[j],dp[j-b]+a);
    }
    for(int i=dp.size()-1;i>=0;i--)
        if(dp[i]<=W){
            cout<<i<<endl;
            break;
        }
}

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


Measured memory_bytes: 1024
def insert_sort(A, N):
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v; print(*A)

N = int(input())
A = [int(n) for n in input().split()]; print(*A)
insert_sort(A, N)



Measured memory_bytes: 5976
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[inline]
#[allow(dead_code)]
fn gcd(mut m: u64, mut n: u64) -> u64 {
    if m < n {
        std::mem::swap(&mut m, &mut n);
    }

    loop {
        let k = m % n;
        if k == 0 {
            return n;
        }

        m = n;
        n = k;
    }
}

#[inline]
#[allow(dead_code)]
fn lcm(m: u64, n: u64) -> u64 {
    m / gcd(m, n) * n
}

macro_rules! eprint(
    ($($arg:tt)*) => { {
        use std::io::Write;
        let r = write!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

macro_rules! eprintln(
    ($($arg:tt)*) => { {
        use std::io::Write;
        let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

macro_rules! dbg {
    ($val:expr) => {
        // Use of `match` here is intentional because it affects the lifetimes
        // of temporaries - https://stackoverflow.com/a/48732525/1063961
        match $val {
            tmp => {
                eprintln!("[{}:{}] {} = {:#?}",
                          file!(), line!(), stringify!($val), &tmp);
                tmp
            }
        }
    }
}

fn main() {
    use std::collections::HashMap;
    input!{
        n: usize,
        a_v: [usize; n],
    }

    let mut counts = HashMap::with_capacity(100010);
    for &a in &a_v {
        *counts.entry(a).or_insert(0u64) += 1;
        *counts.entry(a+1).or_insert(0u64) += 1;
        *counts.entry(a+2).or_insert(0u64) += 1;
    }

    let answer = counts.values().max().unwrap();
    println!("{}", answer);
}


Measured memory_bytes: 8444
# ABC111C
import collections

n = int(input())
v = list(map(int, input().split()))
if len(set(v)) == 1:
    print(n//2)
    exit()

v_odd = [0] * (n // 2)
v_even = [0] * (n // 2)
for i in range(n):
    if (i+1)%2 == 1:
        v_odd[i//2] = v[i]
    else:
        v_even[i//2] = v[i]
c_v_odd = collections.Counter(v_odd)
c_v_even = collections.Counter(v_even)

if c_v_odd.most_common()[0][0] == c_v_even.most_common()[0][0]:
    if c_v_odd.most_common()[0][1] > c_v_even.most_common()[0][1]:
        odd_count = n//2 - c_v_odd.most_common()[0][1]
        even_count = n//2 - c_v_even.most_common()[1][1]
        ans = odd_count + even_count
    elif c_v_odd.most_common()[0][1] < c_v_even.most_common()[0][1]:
        odd_count = n//2 - c_v_odd.most_common()[1][1]
        even_count = n//2 - c_v_even.most_common()[0][1]
        ans = odd_count + even_count
    else:
        if c_v_odd.most_common()[1][1] > c_v_even.most_common()[1][1]:
            odd_count = n//2 - c_v_odd.most_common()[1][1]
            even_count = n//2 - c_v_even.most_common()[0][1]
            ans = odd_count + even_count
        else:
            odd_count = n//2 - c_v_odd.most_common()[0][1]
            even_count = n//2 - c_v_even.most_common()[1][1]
            ans = odd_count + even_count
else:
    odd_count = n//2 -  c_v_odd.most_common()[0][1]
    even_count = n//2 -  c_v_even.most_common()[0][1]
    ans = odd_count + even_count
print(ans)

Measured memory_bytes: 20572
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct key_node_tag{
	int key;
	struct key_node_tag *prev;
	struct key_node_tag *next;
} key_node_contents;

typedef struct {
	key_node_contents dammy;
} key_list_contents;

typedef struct {
} *key_list;

key_list key_list_new(){
	key_list_contents *listc = malloc(sizeof(key_list_contents));
	listc->dammy.prev = &listc->dammy;
	listc->dammy.next = &listc->dammy;
	return (key_list)listc;
}

int key_list_insert(key_list list, int x){
	key_list_contents *listc = (key_list_contents*)list;
	key_node_contents *node = malloc(sizeof(key_node_contents));

	node->key = x;
	node->prev = &listc->dammy;
	node->next = listc->dammy.next;
	listc->dammy.next->prev = node;
	listc->dammy.next = node;
	
	return 0;
}

int key_list_delete(key_list list, int x){
	key_list_contents *listc = (key_list_contents*)list;
	key_node_contents *pdammy = &listc->dammy,
			  *node = pdammy->next;
	
	while(node != pdammy){
		if(node->key == x){
			node->prev->next = node->next;
			node->next->prev = node->prev;
			free(node);
			return 0;
		}
		node = node->next;
	}
	
	return -1;
}

int key_list_delete_first(key_list list){
	key_list_contents *listc = (key_list_contents*)list;
	key_node_contents *node = listc->dammy.next;

	if(node == &listc->dammy){
		return -1;
	}
	node->next->prev = node->prev;
	node->prev->next = node->next;
	free(node);

	return 0;
}

int key_list_delete_last(key_list list){
	key_list_contents *listc = (key_list_contents*)list;
	key_node_contents *node= listc->dammy.prev;

	if(node == &listc->dammy){
		return -1;
	}
	node->next->prev = node->prev;
	node->prev->next = node->next;
	free(node);

	return 0;
}

int key_list_print(key_list list){
	key_list_contents *listc = (key_list_contents*)list;
	key_node_contents *pdammy = &listc->dammy,
			  *node = pdammy->next;
	int flag_init = 1;

	while(node != pdammy){
		if(flag_init){
			flag_init = 0;
			printf("%d", node->key);
		}else{
			printf(" %d", node->key);
		}
		node = node->next;
	}
	printf("\n");

	return 0;
}

int key_list_do_query(key_list list, char *query_str){
	int x;

	if(0 == strcmp(query_str, "insert")){
		scanf("%d", &x);
		key_list_insert(list, x);
		return 0;
	}else if(0 == strcmp(query_str, "delete")){
		scanf("%d", &x);
		key_list_delete(list, x);
		return 0;
	}else if(0 == strcmp(query_str, "deleteFirst")){
		key_list_delete_first(list);
		return 0;
	}else if(0 == strcmp(query_str, "deleteLast")){
		key_list_delete_last(list);
		return 0;
	}

	return -1;
}

int key_list_delete_all(key_list list){
	while(0 == key_list_delete_first(list)){}
	return 0;
}

int main(void){
	key_list list = key_list_new();
	int n, i;
	char query_str[16];

	scanf("%d", &n);
	for(i=0; i<n; ++i){
		scanf("%s", query_str);
		key_list_do_query(list, query_str);
	}
	key_list_print(list);
	key_list_delete_all(list);

	return 0;
}

Measured memory_bytes: 32972
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define T !0

typedef struct edge{ll s,g,c;}E;
typedef struct vertex{ll i,x,y;}V;
int xsort(const void*a,const void*b){
	ll p=(*(V*)a).x,q=(*(V*)b).x;
	return p<q?-1:p>q?1:0;
}
int ysort(const void*a,const void*b){
	ll p=(*(V*)a).y,q=(*(V*)b).y;
	return p<q?-1:p>q?1:0;
}

//union-find
int uniroot[100010],unicnt[100010];
void ufinit(int n){for(int i=0;i<n;i++){uniroot[i]=i;unicnt[i]=1;}}
int root(int x){return uniroot[x]!=x?uniroot[x]=root(uniroot[x]):x;}
int same(int x,int y){return root(x)==root(y);}
void uni(int x,int y){if((x=root(x))==(y=root(y)))return;uniroot[x]=y;unicnt[y]+=unicnt[x];}

//クラスカル法
int csort(const void*a,const void*b){
	ll p=(*(E*)a).c,q=(*(E*)b).c;
	return p<q?-1:p>q?1:0;
}
ll d[200010];
void kurasukaru(int n,E*e,int ecnt){
	qsort(e,ecnt,sizeof(E),csort);
	ufinit(n);
	rep(i,0,ecnt){
		if(!same(e[i].s,e[i].g)){
			uni(e[i].s,e[i].g);
			d[i]=T;
		}
	}
}

V v[100010];
E e[200010];
int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n){
		int x,y;
		scanf("%d%d",&x,&y);
		v[i].i=i;
		v[i].x=x;
		v[i].y=y;
	}
	qsort(v,n,sizeof(V),xsort);
	rep(i,0,n-1){
		e[i].s=v[i].i;
		e[i].g=v[i+1].i;
		e[i].c=v[i+1].x-v[i].x;
	}

	qsort(v,n,sizeof(V),ysort);
	rep(i,0,n-1){
		e[n-1+i].s=v[i].i;
		e[n-1+i].g=v[i+1].i;
		e[n-1+i].c=v[i+1].y-v[i].y;
	}
	kurasukaru(n,e,2*n-2);
	
	ll ans=0;
	rep(i,0,2*n-2)ans+=d[i]*e[i].c;
	printf("%lld\n",ans);
	return 0;
}

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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

int cntset(int i){
	int ret = 0;
	while(i > 0){
		if(i & 1)ret++;
		i >>= 1;
	}
	return ret;
}

signed main(){
	int n,m; cin >> n >> m;
	vector<int> k(m);
	for(auto &e : k){
		int kk; cin >> kk;
		for(int j = 0; j < kk; j++){
			int s; cin >> s; s--;
			e += (1 << s);
		}
	}
	vector<int> p(m);
	for(auto &&e : p){
		int c; cin >> c;
		e = c;
	}
	int ans = 0;
	for(int i = 0; i < (1 << n); i++){
		int tmp = 0;
		for(int j = 0; j < m; j++){
			if((cntset(k[j] & i)%2) == p[j])tmp++;
		}
		if(tmp == m)ans++;
	}
	cout << ans << endl;
		




	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define N 1000000

using namespace std;
typedef long long ll;

int main(void) {
	ll i, j, num, k, ans, a = 0;
	cin >> num >> k;
	if (num == 1)
		ans = k;
	else {
		while (!(k & 1)) {
			a++;
			k >>= 1;
		}
		ans = max(1ll, 1ll << (a / num));
		for (i = 3; i < min((ll)N, k); i += 2) {
			a = 0;
			while (k % i == 0) {
				a++;
				k /= i;
			}
			for(j = 0; j < a / num; j++)
				ans *= i;
			if (k == 1)
				break;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	double a[n];
	int max=-1,p;
	for(int i=0;i<n;i++)
	{
		 cin>>a[i];
		 if(a[i]>max)
		 {
		 	max=a[i];
		 	p=i;
		 }
	}
	double ans=0;
	for(int i=0;i<n;i++)
	{
		if(i==p)
		{
			ans+=a[i]/2;
			continue;
		}
		ans+=a[i];
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var a = Console.ReadLine().Split().Select(long.Parse).ToArray();

		var p = a.Select((x, i) => (1L << Math.Min(60, i)) - x).ToArray();
		if (p.Take(n).Any(x => x <= 0) || p.Last() < 0) { Console.WriteLine(-1); return; }

		p[n] = 0;
		for (int i = n - 1; i >= 0; i--)
			p[i] = Math.Min(p[i], p[i + 1] + a[i + 1]);
		for (int i = 1; i <= n; i++)
			p[i] = Math.Min(p[i], 2 * p[i - 1] - a[i]);

		if (p.Take(n).Any(x => x <= 0) || p.Last() < 0) { Console.WriteLine(-1); return; }
		Console.WriteLine(a.Sum() + p.Sum());
	}
}


Measured memory_bytes: 39064
#include<iostream>
#include<vector>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
using namespace std;
int vector_finder(std::vector<int> vec, int number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
int main() {
  int a,b;
  cin>>a>>b;
  cout << a*b << endl;
  return 0;
}

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

long long fac(int k){long long sum = 1;for(int i=1;i<=k;++i)sum *= i;return sum;}
long long per(int n,int r){long long nn,rr;nn=fac(n);rr=fac(r)*fac(n-r);return nn/rr;}

static const int INF = (1<<29);

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

    int T[100000+1];

    vector<int> v;
    long long a = 1;
    v.push_back(1);
    while(1){
        a *= 6;
        if(a>100000){
            break;
        }
        v.push_back(a);
    }
    a = 1;
    while(1){
        a *= 9;
        if(a>100000){
            break;
        }
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    
    for(int i=0;i<=100000;i++)T[i] = INF;
    T[0] = 0;
    for(int i=0;i<=v.size();i++){
        for(int j=v[i];j<=N;j++){
            T[j] = min(T[j-v[i]]+1,T[j]);
        }
    }
    cout << T[N] << endl;
    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str[] = br.readLine().split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[1]);
            int c = Integer.parseInt(str[2]);
            int d = Integer.parseInt(str[3]);
            if (a + b > c + d) {
                System.out.println("Left");
            } else if (a + b < c + d) {
                System.out.println("Right");
            } else {
                System.out.println("Balanced");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}


Measured memory_bytes: 23124
#include<stdio.h>
#include<string.h>
int main(void){
	int sum,i,len,num;
	char x[1000];
	while(1){
		sum = 0;
		scanf("%s",x);
		len = strlen(x);
		for(i=0;i<len;i++){
			num = x[i] - '0';
			sum += num;
		}
		if(sum == 0) break;
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 536
#define ll long long
#define MOD 1000000007
#define MOD2 998244353
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set2d(array, val, m, n) memset(array, val, sizeof(array[0][0]) * m * n);
#include <bits/stdc++.h>
using namespace std;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x %= p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll po(ll base, ll powerRaised)
{
    if (powerRaised != 0)
        return (base * po(base, powerRaised - 1));
    else
        return 1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll x;
    cin >> x;
    ll ans = 0;
    ans += (x / 500) * 1000;
    x %= 500;
    ans += (x / 5) * 5;
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main() {
    string t ;
    int s = 0 ;
    cin >> t ;
    if ( t[0] == '1'){
        s += 1 ;
    }
    if ( t[1] == '1'){
        s += 1 ;
    }
    if ( t[2] == '1'){
        s += 1 ;
    }
    cout << s ;
    return 0 ;
}


Measured memory_bytes: 3608
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var ans = int.Parse(Console.ReadLine().Trim());
        var ansmax = 0;
        for (int i = 0; i < n; i++)
        {
            string[] s = Console.ReadLine().Trim().Split(' ');
            ans = ans + int.Parse(s[0]) - int.Parse(s[1]);
            if (ans < 0) break;
            ansmax = Math.Max(ansmax, ans);
        }
        if (ans < 0) Console.WriteLine(0);
        else Console.WriteLine(ansmax);
    }
}

Measured memory_bytes: 9188
#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);
  }
  int cnt=0;
  for(int i=0;i<N;i++){
    while(a.at(i)%2==0){
      a.at(i) /= 2;
      cnt++;
    }
  }
  cout << cnt << endl;
}

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

  int n,m,lock=1;
  string namelist[256];
  string in;
  bool check;
  
  cin >>n;
  
  for(int i=0 ; i < n ; i++)cin >>namelist[i];

  cin >>m;
  
  for(int i=0 ; i < m ; i++){
    cin >>in;
    check=true;
    for(int j=0 ; j < n ;j++){
      if(namelist[j]==in){
	if(lock){
	  cout <<"Opened by ";
	  lock=0;
	}else{
	  cout <<"Closed by ";
	  lock=1;
	}
	cout <<in<<endl;
	check=false;
	break;
      }
    }
    if(check){
      cout <<"Unknown "<<in<<endl;
    }
  }		   
  
  return 0;
}

Measured memory_bytes: 1216
#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[i];
  int ans = a[0];
  for(int i = 1; i < n; i++) ans += max(0, a[i] - a[i - 1]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
rect = 0
dia = 0

for s in sys.stdin:
	side1, side2, diag = map(int, s.split(','))
	rect += 1 if diag**2 == side1**2 + side2**2 else 0
	dia += 1 if side1 == side2 else 0

print(rect)
print(dia)

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

ll dp[3001][3001];

ll solve(vector<int> &a, int l ,int r){
   if(l>=(int)a.size() || r < 0)
      return 0;
  if(l > r)
      return 0;
  if(dp[l][r]!=-1)
     return dp[l][r];
  if(l==r && l>=0 && l<a.size()){
     return a[l];
   }
   
    ll temp = a[l] + min(solve(a,l+2,r),solve(a,l+1,r-1));
    ll temp2 = a[r] + min(solve(a,l+1,r-1),solve(a,l,r-2));
  //if(l==0 && r == a.size()-1)
    //cout<<temp <<" "<< temp2<<"\n";
  return  dp[l][r]=max(temp, temp2);
}

int main(){
   int n;
   cin>>n;
  vector<int> a(n);
  ll tot=0;
  for(int i=0;i<n;i++){
  cin>>a[i];
    tot+=a[i];
  }
  for(int i=0;i<3001;i++)
    for(int j=0;j<3001;j++)
      dp[i][j]=-1;
  ll ans = solve(a,0,n-1); 
  cout<<2*ans-tot<<"\n";
return 0; 
}

Measured memory_bytes: 74092
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1e5 + 10;
#define pb(x) push_back(x)
#define int long long
int vis[MaxN];
vector<int> V[MaxN];
void dfs(int u) {
	for(int i = 0; i < V[u].size(); i++) {
		int nxt = V[u][i];
		if(vis[nxt]) continue;
		vis[nxt] = 1;
		dfs(nxt);
	}
}
signed main() {
	int n, m;cin >> n >> m;
	while(m--) {
		int u, v;cin >> u >> v;
		V[u].pb(v);V[v].pb(u);
	}
	int Ans = 0;
	for(int i = 1; i <= n; i++)if(!vis[i]) {
		++Ans;dfs(i);
	}
	cout << Ans - 1 << endl;
	return 0;
} 

Measured memory_bytes: 11052
use proconio::input;
use proconio::fastout;


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

    let mut appear: Vec<usize> = Vec::new();
    for i in 0 .. 1000001 {
        appear.push(0);
    }
    for v in &a {
        appear[*v] += 1;
    }

    let mut ans = 0;
    a.sort();
    for v in &a {
        if appear[*v] == 1 {
            ans += 1;
        }
        if appear[*v] > 0 {
            for i in (*v .. 1000001).step_by(*v) {
                appear[i] = 0;
            }
        }
    }

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


Measured memory_bytes: 13392
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
struct point
{
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

i64 MOD = 1e9 + 7;

int main()
{
  i64 S;
  cin >> S;
  vector<i64> dp(S+1);
  dp[0] = 1;
  for (i64 i = 1; i <= S; i++)
    for (i64 j = 0; j <= i - 3; j++)
      (dp[i] += dp[j]) %= MOD;
  cout << dp[S] << endl;
  return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<ll,ll>> pc;
//int ABS(int a){return max(a,-a);}
//int a[100001];
int main(){
    string s;
    cin>>s;
    int r=0,b=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='0') r++;
        if(s[i]=='1') b++;
    }
    int m=min(r,b);
    cout<<m*2;
    return 0;
}

Measured memory_bytes: 512
MODE = "stdio"
#require 'matrix'
#include Math
line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = '5
  S7 D3 D4 C1 H3'.split("\n")
  tmp.each{|s|
    line << s.strip
  }
end

n = line[0].to_i

arr = line[1].split(" ")
arr2 = line[1].split(" ")

i=0
(0..n-1).each do |i|
  (n-1).downto(i+1) do |j|
    if arr2[j][1]<arr2[j-1][1]
      arr2[j], arr2[j-1] = arr2[j-1], arr2[j]
    end
  end
  i+=1
end



(0..n-1).each do |i|
  minj = i
  (i..n-1).each do |j|
    if arr[j][1]<arr[minj][1]
      minj = j
    end
  end
  if i!=minj
    arr[i],arr[minj] = arr[minj],arr[i]
  end
end

puts arr2.join(" ")
puts "Stable"
puts arr.join(" ")
puts "Not stable" if arr2 != arr
puts "Stable" if arr2 == arr

Measured memory_bytes: 8764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace Atcoder171
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            var Anum = new int[100001];
            long sum = 0;
            var As = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            foreach (var a in As)
            {
                Anum[a]++;
                sum += a;
            }
          
            var Q = int.Parse(Console.ReadLine());

            for (var i = 0; i < Q; i++)
            {

                var BS = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                var b = BS[0];
                var c = BS[1];

                sum += (c  * Anum[b] - b * Anum[b]);
                Console.WriteLine(sum);

                Anum[c] += Anum[b];
                Anum[b] = 0;
            }
        }
    }
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if ((a % b == 0) || (b % a == 0)) {
    cout << (a + b) / 2 << endl;
  }
  else {
    cout << (a + b) / 2 + 1 << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		int x = sc.nextInt();
		int y  =sc.nextInt();
				

		int ans = 0;
		for(int i = 0;i < k;i++){
			if(i >= n){
				break;
			}
			ans += x;
		}
		
		for(int i = 0;i < n-k;i++){
			ans += y;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    cout << N*(N-1)/2-N/2 << endl;
    for(int i = 1; i <= N; i++) {
        for(int j = i+1; j <= N; j++) {
            if(i+j == N && N%2 == 1) {
                continue;
            }
            if(i+j == N+1 && N%2 == 0) {
                continue;
            }
            cout << i << " " << j << endl;
        }
    }
}


Measured memory_bytes: 3596
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

string s;

int n;
int k;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cout.setf(ios::fixed), cout.precision(20);
	cin >> n >> k;
	cin >> s;
	string s2 = s;
	reverse(ALL(s2));
	string ans = s;
	s = s + s2;
	for (int i = 1; i + n <= s.size(); ++i)
		ans = min(ans, s.substr(i, n));
	--k;
	int cnt = 1;
	while (cnt < ans.size() && ans[0] == ans[cnt])
		++cnt;
	k = min(k, 20);
	int tmp = cnt;
	for (int i = 0; i < k; ++i)
		cnt = min(n, cnt * 2);
	for (int i = 0; i < cnt; ++i)
		cout << ans[0];
	for (int i = 0; i < n - cnt; ++i)
		cout << ans[tmp + i];
	cout << "\n";
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int h,w;
char s[22][22];
int d[22][22][22][22];
signed main(){
    cin>>h>>w;
    rep(i,h){
        rep(j,w){
            cin>>s[i][j];
        }
    }
    rep(i,h){
        rep(j,w){
            rep(k,h){
                rep(l,w){
                    if(i==k&&j==l)d[i][j][k][l]=0;
                    else d[i][j][k][l]=INF;
                }
            }
        }
    }
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#')continue;
            rep(k,4){
                int x=i+dx[k],y=j+dy[k];
                if(0<=x&&x<h&&0<=y&&y<w&&s[x][y]=='.'){
                    d[i][j][x][y]=1;
                    d[x][y][i][j]=1;
                }
            }
        }
    }
    rep(p,h){
        rep(q,w){
            rep(i,h){
                rep(j,w){
                    rep(k,h){
                        rep(l,w){
                            d[i][j][k][l]=min(d[i][j][k][l],d[i][j][p][q]+d[p][q][k][l]);
                        }
                    }
                }
            }
        }
    }
    int ans=0;
    rep(i,h){
        rep(j,w){
            rep(k,h){
                rep(l,w){
                    if(s[i][j]=='.'&&s[k][l]=='.')ans=max(ans,d[i][j][k][l]);
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
void parent(int);
void left(int);
void right(int);
int n;
int a[251];
int main(){
    
    scanf("%d",&n);
    int i;
    
    for(i=1;i<=n;i++)scanf("%d",&a[i]);
    for(i=1;i<=n;i++){
        printf("node %d: key = %d, ",i,a[i]);
        parent(i);
        left(i);
        right(i);
        printf("\n");
    }
    return 0;
}

void parent(int i){
    int p=i/2;
    if(p>=1)printf("parent key = %d, ",a[p]);
}
void left(int i){
    if(2*i<=n)printf("left key = %d, ",a[2*i]);
}
void right(int i){
    if(2*i+1<=n)printf("right key = %d, ",a[2*i+1]);
}

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
#include<vector>
#define N 110
using namespace std;

int n,m,num[N],cnt;
vector<int>ans,js;

inline void out(int u)
{
	int i;
	for(i=0;i<=u;i+=2) ans.push_back(2);
}

int main()
{
	int i,j,p,q;
	cin>>n>>m;
	for(i=1;i<=m;i++)
	{
		scanf("%d",&num[i]);
		if(num[i]%2)
		{
			cnt++;
			js.push_back(num[i]);
		}
	}
	if(cnt>2)
	{
		puts("Impossible");
		return 0;
	}
	if(!js.empty()) out(js[0]);
	else ans.push_back(1);
//	cout<<" ";for(i=0;i<ans.size();i++) cout<<ans[i]<<" ";return 0;
	for(i=1;i<=m;i++)
	{
		if(num[i]%2) continue;
		ans.push_back(num[i]);
	}
	if(cnt<=1)
	{
		p=ans[ans.size()-1]-2;
		ans.pop_back();
		ans.push_back(1);
		if(p) ans.push_back(p);
	}
	else
	{
		out(js[1]);
		ans.pop_back();
	}
	if(cnt) printf("%d ",js[0]);
	for(i=1;i<=m;i++) if(num[i]%2==0) printf("%d ",num[i]);
	if(cnt>1) printf("%d ",js[1]);
	printf("\n%d\n",ans.size());
	for(i=0;i<ans.size();i++)
	{
		printf("%d ",ans[i]);
	}
}

Measured memory_bytes: 640
def bugged_system():
	n = int(raw_input())
	scores = []
	for i in range(n):
		scores.append(int(raw_input()))
	max_score = sum(scores)
	if max_score%10!=0:
		print max_score
		return
	for s in sorted(scores):
		if s%10!=0:
			print max_score-s
			return
	print 0


if __name__ == "__main__":
	bugged_system()

Measured memory_bytes: 2568
#include<stdio.h>
int main(){
    long long int sum,a,b,n;
    scanf("%lld %lld %lld",&n,&a,&b);
    long long int sub=b-a;
    if(sub<0||(n==1&&(a!=b))||n<=0||a<=0||b<=0){
        printf("0");
    }
    else if((n==1&&a==b)||(n==2))
        printf("1");
    else{
        sum=b*(n-1)+a-a*(n-1)-b+1;
        printf("%lld",sum);
    }
}


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

using namespace std;

long long n,dp[2005][2005];
pair<long long,long long> arr[2005];

long long rec(long long i,long long j)
{
    if(dp[i][j]!=-1)return  dp[i][j];
    if(i > j)return 0;
    long long idx = i+(n-j)-1;
    long long x1 = abs(i-arr[idx].second)*arr[idx].first+rec(i+1,j);
    long long x2 = abs(j-arr[idx].second)*arr[idx].first+rec(i,j-1);
    return dp[i][j] = max(x1,x2);
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    long long i;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>arr[i].first;
        arr[i].second = i;
    }
    sort(arr,arr+n);
    reverse(arr,arr+n);
    memset(dp,-1,sizeof(dp));
    cout<<rec(0,n-1)<<endl;
 	return 0;
}


Measured memory_bytes: 35188
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;
int ans;

const int mod = 1000000007;
int cost[101][2];
int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS

    int n;
    cin >> n;

    
    for(int i = 1; i <= n; i++)
    {
      int x;
      cin >> x;
      ans += x-1;
    }


    cout << ans;









    return 0; 
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int A,B,C,d;
	cin>>A>>B>>C;
	d=max(max(A,B),C);
	if(d==A)
	cout<<d*10+B+C;
	else if(d==B)
	cout<<d*10+A+C;
	else 
	cout<<d*10+B+A;
	return 0;
}     	

Measured memory_bytes: 256
if __name__ =="__main__":
    n = int(input())
    ls = [[int(x) for x in input().split()] for _ in range(n)]

    now_t,now_a = ls[0]

    for i in range(1,n):
        x = max([~-now_t//ls[i][0] +1 ,~-now_a//ls[i][1] +1])
        now_t,now_a = x*ls[i][0],x*ls[i][1]
    print(now_t+now_a)

Measured memory_bytes: 39152
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
bool compare_by_left(pair<int, int> a, pair<int, int> b) {

    return a.first - a.second <= b.first - b.second;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
const int MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> X(N);

    rep(i, 0, N) { cin >> X[i].first >> X[i].second; }
    sort(X.begin(), X.end(), compare_by_left);
    int count = 0;
    int tmp = 0;
    rep(i, 1, N) {
        int le = X[i].first - X[i].second;
        int ri = X[i].first + X[i].second;
        int tl = X[tmp].first - X[tmp].second;
        int tr = X[tmp].first + X[tmp].second;
        if(tr > le) {

            count++;
            if(ri < tr) {
                tmp = i;
            }
        } else {
            tmp = i;
        }
    }
    cout << N - count << endl;
}

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

int main() {
  
  string s;
  cin >> s;
  
  int t=1;
  for (int i=0; i<(s.size()+1)/2; i++) {
    if (s.at(2*i)=='L') t*=0;
  }
  
  int u=1;
  for (int i=0; i<s.size()/2; i++) {
    if (s.at(2*i+1)=='R') u*=0;
  }
  
  if (t==0 || u==0) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	int h = 0;
	if (s[0] == 'R' && s[1] == 'R')
		h++;
	if (s[n - 1] == 'L' && s[n - 2] == 'L')
		h++;
	for(int i = 1;i < n - 1;i++) {
		if (s[i] == 'R' && s[i + 1] == 'R')
			h++;
		else if (s[i] == 'L' && s[i - 1] == 'L')
			h++;
	}
	cout << min(n - 1, h + 2 * k);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(ll, a);
    CIN(ll, b);
    CIN(ll, x);

    ll l, u, ans;
    if ( a == 0 ) {
        u = b / x;
        ans = u + 1;
    } else {
        l = (a - 1) / x;
        u = b / x;
        ans = u - l;
    }

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

Measured memory_bytes: 256
package main

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

var N, K, S int

var A []int

var ans []string

const mvalue int = 1000000000 - 1

func main() {
	N = readint() // 数列の長さ
	K = readint() // 条件を満たす整数の組の個数
	S = readint() // Al + Al+1 + ... + Ar を満たすS

	initans()

	// Sを満たすKが0の場合
	if K == 0 {
		putans()
		return
	}

	// K が 1以上で

	// 数列の長さNが1の場合
	if N == 1 {
		fmt.Println(S) // Sその値を持つ1要素のみの配列が答えである
		return
	}

	// N が 1より大きければ
	for i := 0; i < K; i++ {
		A[i] = S
	}

	// 回答
	putans()
}

func initans() {
	A = make([]int, N)
	n := 1
	if S <= N {
		n = mvalue
	}
	for i := 0; i < N; i++ {
		A[i] = n
	}
}

func putans() {
	ans = make([]string, N)
	for i := 0; i < N; i++ {
		ans[i] = strconv.Itoa(A[i])
	}
	fmt.Println(strings.Join(ans, " "))
}

const (
	iobufsize = 1 * 1024 * 1024 // 1 MB
)

var stdinsc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, iobufsize), iobufsize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func readint() int {
	stdinsc.Scan()
	v, err := strconv.Atoi(stdinsc.Text())
	if err != nil {
		panic(err)
	}
	return v
}

func readstr() string {
	stdinsc.Scan()
	return stdinsc.Text()
}

func pow(x, y int) int {
	if y < 1 {
		return 1
	}
	return x * pow(x, y-1)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}


Measured memory_bytes: 9088
#include<iostream>
#include<math.h>

using namespace std;

int main(){
    unsigned long long h,w,d;
    cin >> h >> w >> d;

    unsigned long long a[h][w];
    unsigned long long b[h*w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> a[i][j];
            b[a[i][j]] = i*1000+j;
        }
    }

    unsigned long long  q;
    cin >> q;
    unsigned long long l[q], r[q];
    for(int i=0;i<q;i++)cin >> l[i] >> r[i];

    unsigned long long dist[h*w+1];
    for(int i=0;i<h*w+1;i++)dist[i] = 0;
    for(int i=d+1;i<h*w+1;i++){
        dist[i] = dist[i-d] + abs(int(b[i]/1000)-int(b[i-d]/1000)) + abs(int(b[i]%1000)-int(b[i-d]%1000));
    }
    for(int i=0;i<q;i++)cout << dist[r[i]]-dist[l[i]] << endl;
}


Measured memory_bytes: 4736
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int,int>
#define pl pair<ll,ll>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
const ll DEP = (1LL << 50);
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
template<typename T>
T GCD(T x,T y){
    return y ? GCD(y,x%y) : x;
}
template<typename T>
string toString( const T &a ){
    ostringstream oss;
    oss << a;
    return oss.str();
};
int v,e;
vector<int> In[10001],Out[10001],ans;
queue<int> Q;


/* 
void toporogical_sort(){
    for(int i = 0; i < v; i++){
        if(!In[i].size()) Q.push(i);
    }
    while(!Q.empty()){
        int t = Q.front(); 
        Q.pop();
        ans.push_back(t);
        for(int i = 0; i < Out[t].size(); i++){
            int nx = Out[t][i];
            int size = In[nx].size();
            for(int j = 0; j < size; j++){
                if(In[nx][j] == t){
                    In[nx].erase(In[nx].begin()+j);
                    break;
                }
            }
            if(!In[nx].size()) Q.push(nx);
        }
    }
}
*/


void toporogical_sort(){
  for(int i=0;i<v;i++)
    if(!In[i].size())Q.push(i);
   
  while(!Q.empty()) {
    int t = Q.front(); Q.pop();
    ans.push_back(t);
  
    for(int i=0;i<Out[t].size();i++){
      int nx = Out[t][i];
      int size = In[nx].size();
      for(int j=0;j<size;j++)
    if(In[nx][j] == t){
      In[nx].erase(In[nx].begin()+j);
      break;
    }
      if(!In[nx].size()) Q.push(nx);
    }
  }
}

int main(){
    cin >> v >> e;
    for(int i = 0; i < e; i++){
        int s,t; cin >> s >> t;
        In[s].push_back(t);
        Out[t].push_back(s);
    }
    toporogical_sort();
    for(int i = ans.size()-1; i >= 0; i--){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 4364