akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

#[allow(unused_macros)]
macro_rules! vec_md {
    ( $ init : expr ; $ ( $ dim : expr ) ;* ) => { vec_md ! ( $ ( $ dim ) ;* => $ init ) };
    ( $ head : expr ; $ ( $ tail : expr ) ;* => $ init : expr ) => { vec ! [ vec_md ! ( $ ( $ tail ) ;* => $ init ) ; $ head ] };
    ( $ head : expr => $ init : expr ) => { vec ! [ $ init ; $ head ] };
}

#[allow(unused_macros)]
macro_rules! chmin {
    ( $ x : expr , $ y : expr ) => { if $ x > $ y { $ x = $ y ; true } else { false } };
}

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

    let mut dp = vec_md![None;n;n];
    for i in 0..n {
        dp[i][i] = Some(0);
    }
    let cum = Cum::new(&a);
    println!("{}", rec(&mut dp, &cum, 0, n-1));
}

fn rec(dp: &mut [Vec<Option<u64>>], cum: &Cum, l: usize, r: usize) -> u64 {
    if let Some(src) = dp[l][r] {
        return src;
    }

    let mut ret = 1u64 << 60;
    for i in l..r {
        chmin!(ret, rec(dp,cum,l,i) + rec(dp,cum,i+1,r));
    }
    ret += cum.sum(l, r+1);
    dp[l][r] = Some(ret);
    ret
}

#[derive(Debug)]
#[allow(dead_code)]
struct Cum {
    s: Vec<u64>,
}
#[allow(dead_code)]
impl Cum {
    fn new(a: &Vec<u64>) -> Cum {
        let mut s = vec![0; a.len() + 1];
        for i in 0..a.len() {
            s[i + 1] = s[i] + a[i];
        }
        Cum { s: s }
    }
    #[doc = " [l,r)"]
    fn sum(&self, l: usize, r: usize) -> u64 {
        self.s[r] - self.s[l]
    }
}

Measured memory_bytes: 6396
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[100010];
double Abs(double x) { return (x>0)?x:-x;}
int main()
{
	scanf("%d",&n);
	int Max=-1<<29,x=-1<<29;
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		Max=max(Max,a[i]);
	}
	for (int i=1;i<=n;i++)
		if (a[i]!=Max&&Abs((double)Max/2-a[i])<=Abs((double)Max/2-x)) x=a[i];
	printf("%d %d\n",Max,x);
	return 0;
}


Measured memory_bytes: 512
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	int n, m;
	cin >> n;
	vector<int> x(n), y(n), h(n);
	for (int i = 0; i < n; ++i) {
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] > 0) {
			m = i;
		}
	}
	for (int i = 0; i <= 100; ++i) {
		for (int j = 0; j <= 100; ++j) {
			int h1 = h[m] + abs(i - x[m]) + abs(j - y[m]);
			bool ok = true;
			for (int k = 0; k < n; ++k) {
				int h2 = max(0, h1 - abs(i - x[k]) - abs(j - y[k]));
				if (h2 != h[k]) {
					ok = false;
					break;
				}
			}
			if (ok) {
				cout << i << " " << j << " " << h1 << endl;
				return 0;
			}
		}
	}
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int L[2001];
  for (int i = 0; i < N; ++i) cin >> L[i];
  
  sort(L, L + N);
  
  int ans = 0;
  for (int i = 0; i < N - 2; ++i) {
    for (int j = i + 1; j < N - 1; ++j) {
      for (int k = j + 1; k < N; ++k) {
        int a = L[i];
        int b = L[j];
        int c = L[k];
        if ((a < (b + c)) && (b < (c + a)) && (c < (a + b))) {
          ans++;
        } 
      }
    }
  }
  
  cout << ans << endl;
}
  

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
s = input()
def z_algo(S):
    N = len(S)
    A = [0] * N
    i = 1; j = 0
    A[0] = l = N
    while i < l:
        while i+j < l and S[j] == S[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A
res = 0
for i in range(n):
    c = z_algo(s[i:])
    # print(c)
    for j,t in enumerate(c):
        tmp = min(j,t)
        res = max(res, tmp)
print(res)

Measured memory_bytes: 75608
N = int(input())
S = input()
S = [i for i in S]

cnt = 1
Cnt = []

for i in range(1, N):
    if S[i]==S[i-1]:
        cnt += 1
    elif S[i]!=S[i-1]:
        Cnt.append(cnt)
        cnt = 1
Cnt.append(cnt)
print(len(Cnt))

Measured memory_bytes: 10336
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();
        for(int i = 0; i < a.length(); i++){
            if(a.substring(i,i+1).equals("7")){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 35772
import java.util.Scanner;

public class Main {

    static long[][] C;

    static long DIV = 1000000000 + 7;

    private static void initC(){
        C = new long[4002][4002];

        C[0][0] = 1;

        for(int i=0; i<4001; i++){
            for(int j=0; j<=i; j++){
                C[i+1][j] += C[i][j];
                C[i+1][j] %= DIV;
                C[i+1][j+1] += C[i][j];
                C[i+1][j+1] %= DIV;
            }
        }
    }

    private static long comb(int a, int b){
        if(a==b){
            return 1;
        }else if(a < b){
            return 0;
        }
        return C[a][b];
    }

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        initC();

        int N = scanner.nextInt();
        int K = scanner.nextInt();

        for(int i=1; i<=K; i++){
            long ans = comb(K-1, i-1) * comb(N-K+1, i);
            ans %= DIV;

            System.out.println(ans);
        }

    }

}


Measured memory_bytes: 165196
# 問題：https://atcoder.jp/contests/abc146/tasks/abc146_a

week = ['SUN','MON','TUE','WED','THU','FRI','SAT']
s = input()
for i, day in enumerate(week):
    if day == s:
        res = 7 - i
        break
res = 7 - i
print(res)


Measured memory_bytes: 9096
import math

class point:

    def __init__(self, p):
        self._x = p[0]
        self._y = p[1]

    def disp(self):
        print("{0:f} {1:f}".format(self._x, self._y))

    @property
    def x(self):
        return self._x

    @property
    def y(self):
        return self._y


def get_s(p1, p2):
    p = point((p1.x/3*2 + p2.x/3, p1.y/3*2 + p2.y/3))
    return p


def get_t(p1, p2):
    p = point((p1.x/3 + p2.x/3*2, p1.y/3 + p2.y/3*2))
    return p


def get_u(s, t):
    x = (t.x - s.x)*math.cos(math.radians(60)) - (t.y - s.y)*math.sin(math.radians(60)) + s.x
    y = (t.x - s.x)*math.sin(math.radians(60)) + (t.y - s.y)*math.cos(math.radians(60)) + s.y
    return point((x, y))


def kock(n, p1, p2):
    if n == 0:
        return
    else:
        s = get_s(p1, p2)
        t = get_t(p1, p2)
        u = get_u(s, t)

        kock(n-1, p1, s)
        s.disp()
        kock(n-1, s, u)
        u.disp()
        kock(n-1, u, t)
        t.disp()
        kock(n-1, t, p2)

        return


if __name__ == '__main__':

    n = int(input())

    p1 = point((0, 0))
    p2 = point((100, 0))

    p1.disp()
    kock(n, p1, p2)
    p2.disp()


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

int main(int, char *[]) {
  int32_t n, m;
  std::cin >> n >> m;

  std::vector<int32_t> h(n);
  for (auto i = 0; i < n; ++i) {
    std::cin >> h[i];
  }

  std::vector<bool> is_nice(n, true);

  for (auto i = 0; i < m; ++i) {
    int32_t a, b;
    std::cin >> a >> b;
    --a;
    --b;

    if (h[a] <= h[b]) {
      is_nice[a] = false;
    }
    if (h[b] <= h[a]) {
      is_nice[b] = false;
    }
  }

  auto c = 0;
  for (auto v : is_nice) {
    if (v) {
      ++c;
    }
  }

  std::cout << c << std::endl;

  return 0;
}


Measured memory_bytes: 3776
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

template <class... Args>
struct tuple_input_impl;
template <std::size_t i, std::size_t... tail>
struct tuple_input_impl<std::index_sequence<i, tail...>>
{
    template <class... Args>
    static void f(std::tuple<Args...>& x)
    {
        std::cin >> std::get<i>(x);
        tuple_input_impl<std::index_sequence<tail...>>::f(x);
    }
};
template <>
struct tuple_input_impl<std::index_sequence<>>
{
    static void f(...) {}
};

template <class... Args>
std::istream& operator>>(std::istream& in, std::tuple<Args...>& x)
{
    tuple_input_impl<std::index_sequence_for<Args...>>::f(x);
    return in;
}
template <class T1, class T2>
std::istream& operator>>(std::istream& in, std::pair<T1, T2>& x) { return in >> x.first >> x.second; }

template <class T>
T read()
{
    T res;
    std::cin >> res;
    return res;
}
template <class T>
std::vector<T> read(std::size_t n)
{
    std::vector<T> res(n);
    for (std::size_t i = 0; i < n; ++i) std::cin >> res[i];
    return res;
}

template <class T>
void out_impl(T&& v) { std::cout << std::forward<T>(v); }
template <class T, class... Args>
void out_impl(T&& v, Args&&... args)
{
    std::cout << std::forward<T>(v) << ' ';
    out_impl(std::forward<Args>(args)...);
}
template <class... Args>
void out(Args&&... args)
{
    out_impl(std::forward<Args>(args)...);
    std::cout << '\n';
}
template <class... Args>
void out_noreturn(Args&&... args) { out_impl(std::forward<Args>(args)...); }

template <class T>
void print(const T& container)
{
    bool first = true;
    for (auto&& x : container) {
        if (!first) std::cout << ' ';
        std::cout << x;
        first = false;
    }
    std::cout << '\n';
}

void prog()
{
    long double t, x;
    std::cin >> t >> x;
    out(t / x);
}

int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    prog();
    return 0;
}


Measured memory_bytes: 256
import math

N = int(input())
P = [list(map(int, input().split())) for _ in range(N)]
dis = 0
c = 0

for i in range(N):
    xi = P[i][0]
    yi = P[i][1]
    for ii in range(i + 1, N):
        xj = P[ii][0]
        yj = P[ii][1]
        dis += ((xi - xj)**2 + (yi - yj)**2)**0.5
        c += 1
print(dis / c * (N - 1))
        
    
    

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int a, b, c; cin >> a >> b >> c;
	puts((b-a == c-b)?"YES":"NO");
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

typedef unsigned long long int ulint;
typedef long long int lint;

int main(){
  ulint N, M;
  cin >> N >> M;

  vector<bool> ACed(N, false);
  vector<ulint> WAs(N, 0);
  
  for (int i = 0; i < M; ++i) {
    ulint p;
    string s;
    cin >> p >> s;
    --p;
    if (ACed[p]) {
      ;
    } else if (s == "AC") {
      ACed[p] = true;
    } else {
      // s == WA
      ++WAs[p];
    }
  }

  cout << accumulate(ACed.begin(), ACed.end(), (ulint) 0) << " ";

  ulint was = 0;
  for (int i = 0; i < N; ++i) {
    if (ACed[i]) {
      was += WAs[i];
    }
  }  

  cout << was << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int MN = 5000;
const int ML = MN/2;
ll dp[2][MN][MN];
ll tp[MN];
ll bd[2][MN];
ll M;
int main() {
	ll n;
	cin >> n >> M;
	memset(dp,0,sizeof(dp));
	int cu = 0;
	for(int i=0;i<n;i++) {
		ll x = i;
		ll y = n-i-1;
		bd[cu][y] = max(bd[cu][y],x);
		dp[cu][x][y] += 1;
	}
	int num = (n-1)/2;
	ll res = 0;
	bool extra = !(n&1);
	for(int iter=0;iter<num;iter++) {
		//cout << "iteration " << iter << '\n';
		int nu = 1-cu;
		ll C = 0;
		memset(bd[nu],0,sizeof(bd[nu]));
		for(int i=0;i<n;i++) {
			ll lim = bd[cu][i];
			tp[lim] = dp[cu][lim][i];
			for(int j=lim-1;j>=0;j--) {
				tp[j] = tp[j+1]+dp[cu][j][i];
				if(tp[j] >= M) {tp[j] -= M;}
			}
			for(int j=lim;j>=0;j--) {
				if(j > 0) {
					tp[j-1] += tp[j];
					if(tp[j-1] >= M) {tp[j-1] -= M;}
				}
				C++;
				ll vy = i-j;
				if(vy < 0) {continue;}
				int u = j,v = vy;
				//cout << "IJ " << i << " " << j << '\n';
				//cout << "wat " << u << " " << v << " " << tp[j] << '\n';
				dp[nu][u][v] = tp[j];
				bd[nu][v] = max(bd[nu][v],ll(u));
			}
		}
		//cout << "use count " << C << '\n';
		cu = nu;
	}
	for(int i=0;i<n;i++) {
		for(int j=0;j<=bd[cu][i];j++) {
			if(extra) {
				res += ll(j+1)*dp[cu][j][i];
			} else {
				res += dp[cu][j][i];
			}
		}
	}
	res %= M;
	cout << res << '\n';
}


Measured memory_bytes: 391040
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n, cnt=0, maxi=0;
    cin >> n;
    vector<int> h(n);
    rep(i, n)  cin >> h[i];

    for(int i=0; i<n-1; i++){
        if(h[i+1] <= h[i]) cnt++;
        else cnt=0;
        maxi = max(maxi, cnt);
    }
    out(maxi);
}

Measured memory_bytes: 640
H, N = map(int, input().split())
Magic = [list(map(int, input().split())) for i in range(N)]
MAX_COST = max(Magic)[1]

# dp[damage] := モンスターに damage を与えるために必要な最小コスト
dp = [float('inf')] * (H + 1)
dp[0] = 0
for h in range(H):
    for damage, cost in Magic:
        next_index = min(h + damage, H)
        dp[next_index] = min(dp[next_index], dp[h] + cost)

print(dp[-1])


Measured memory_bytes: 43996
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
    string s1, s2;
    cin >> s1 >> s2;
    reverse(s2.begin(), s2.end());
    if (s1 == s2) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	static int W,H,ans;
	static int field[][];
	static int dh[]={1,0,-1,0};
	static int dw[]={0,1,0,-1};
	static int sw,sh,tw,th;
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			W=in.nextInt();
			H=in.nextInt();
			if((W|H)==0)
				return;
			field=new int[H][W];
			ans=11;
			for(int i=0;i<H;i++)
				for(int j=0;j<W;j++)
				{	
					int state=in.nextInt();
					field[i][j]=state;
					if(state==2)
					{
						sw=j;
						sh=i;
					}
				}	
			dfs(sw,sh,1);
			System.out.println(ans>10 ? -1:ans);
		}
	}
	static void dfs(int w,int h,int cnt)
	{
		if(cnt>=ans||cnt>10)
			return;
		for(int i=0;i<4;i++)
		{

			int nh=h;
			int nw=w;
			nh+=dh[i];
			nw+=dw[i];
			if(nh<0||nh>=H||nw<0||nw>=W||field[nh][nw]==1)
				continue;
			for(;;)
			{
				if(field[nh][nw]==3)
					ans=cnt;
				nh+=dh[i];
				nw+=dw[i];
				if(nh<0||nh>=H||nw<0||nw>=W)
					break;

				if(field[nh][nw]==1)
				{
					field[nh][nw]=0;
					dfs(nw-dw[i],nh-dh[i],cnt+1);
					field[nh][nw]=1;
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 34328
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
//---------------------------------------------------------------------------------------------------
typedef pair<int,int> P;

int main(void){
    // Your code here!
    int N; cin >> N;
    FOR(h,1,3500) {
        FOR(n,1,3500) {
            if(4*h*n-N*n-N*h <= 0) continue;
            double w = (double)N*h*n/(4*h*n-N*n-N*h);
            if (w > 0 && w <= 3500 && floor(w) == ceil(w)) {
                cout << h << " " << n << " " << w << endl;
                return 0;
            }
        }
    }
}


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

int main(void){
  int n,x;
  cin >> n;
  bool flg;
  while(n>1){
    x=n%10;
    n/=10;
    if(x==9) {
      flg = true;
      break;
    } else flg = false;
  }
  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <fstream>
#include <assert.h>
#include <string>
#include <cstring>
#include <unordered_map>
#include <bitset>
#include <climits>
#include <time.h>
#include <stdio.h>
#include <cstdlib>
#include <math.h>
#include <deque>
#include <cmath>
#include <set>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<int> > vii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpi;

#define INF 1000000000
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define loop(i,a,b) for (int i = a; i < b; i++)

void setIO(string name) {
	freopen((name+".in").c_str(), "r", stdin); 
	freopen((name+".out").c_str(), "w", stdout);
}

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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
	int X;
	cin >> X;
   	cout << 360 / (gcd(X,360)) << endl; 
    return 0;
}










Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;
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;
}
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 kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}
int n,a[364364],b[364364],mi=1145141919,sum;
signed main(){
	cin>>n;
	rep(i,n){
		cin>>a[i]>>b[i];
		if(a[i]>b[i])mi=min(mi,b[i]);
		sum+=a[i];
	}
	if(mi==1145141919)cout<<0<<endl;
	else cout<<sum-mi<<endl;
	return 0;
}


Measured memory_bytes: 2432
def sol(s):
    x = s
    s = s[::-1]
    return x == s


if __name__ == '__main__':
    s = input()
    if sol(s) and sol(s[:(len(s) - 1) // 2]) and sol(s[(len(s) + 2) // 2:]):
        print('Yes')
    else:
        print('No')

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	//~ cout.tie(0);
	char s[4];
	scanf("%s", s);
	printf("%c\n", s[0] + 1);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1000000001;

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

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

int main() {
  int T;
  int A;
  int B;
  
  cin >> T >> A >> B;
  
  if((T * A) >= B){
  	cout << B << endl;
  }else if((T * A) < B){
  	cout << T * A << endl;
  }
}

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

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
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;}
const long long INF = 1LL << 60;
typedef pair<int, int> P;

bool visited[8];
int N, M;
vector<int> G[8];

int dfs(int u, int count) {
    if (count == N) return 1;
    int res = 0;
    for (int i = 0; i < G[u].size(); i++) {
        if (!visited[G[u][i]]) {
            visited[G[u][i]] = true;
            res += dfs(G[u][i], count+1);
            visited[G[u][i]] = false;
        }
    }
    return res;
}

int main () {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1); 
        G[b-1].push_back(a-1); 
    }
    visited[0] = true;
    cout << dfs(0, 1) << "\n";
}

/*
int N, M;

int abs(int a) {
    if (a < 0) return -a;
    return a;
}

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

    if (2 * N > M || 4 * N < M) {
        cout << "-1 -1 -1\n";
        return 0;
    }

    int dif = abs(3 * N - M);

    if (3 * N >= M) {
        cout << dif << " " << N - dif << " 0\n";
    } else {
        cout << "0 " << N - dif << " " << dif << "\n";
    }
}
*/
/*
int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    vector<int> cost(N+1, 0);
    cost[1] = abs(a[1]-a[0]);
    for (int i = 2; i < N; i++) {
        int c = abs(a[i] - a[i-1]) + cost[i-1];
        chmin(c, abs(a[i] - a[i-2]) + cost[i-2]);
        cost[i] = c;
    }
    cout << cost[N-1] << "\n";
}
*/

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

using namespace std;


int main(int argc, const char * argv[]) {
    double T, X;
    cin >> T >> X;
    cout << T / X << endl;
    
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    int m=0;
    rep(i,n){
        m += a[i]-1;
    }
    cout << m<<endl;
}

Measured memory_bytes: 256
s = input()
s2 = ''
for c in s:
    if c in ('A','T','C','G'):
        s2 += '1'
    else:
        s2 += '0'


tmp = 0
ret = 0
for c in s2:
    if c == '1':
        tmp += 1
    else:
        ret = max(ret, tmp)
        tmp = 0
ret = max(ret, tmp)
print(ret)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

//istream& operator>>(istream& is, const mint& a){return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a){return os << a.x;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	vector<int> c(n+1);
	c[0] = 3;
	mint ans = 1;
	rep(i,n){
		if(!c[a[i]]){
			cout << 0 << endl;
			return 0;
		}
		ans *= c[a[i]];
		c[a[i]]--;
		c[a[i]+1]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import sys
readline = sys.stdin.readline

N, M, K = map(int, readline().split())
P = 998244353
def mod_prod(a,b):
    return a * b % P

def mod_fact(a):
    ret = 1
    for i in range(a):
        ret = ret * (i + 1) % P
    return ret

def mod_pow(a, n):
    ret = 1
    while n > 0:
        if n % 2 == 1:
            ret = ret * a % P
        a = a * a % P
        n = n // 2
    return ret

def mod_div(a, b):
    b_inv = mod_pow(b, P - 2)
    return a * b_inv % P

def mod_comb(a,b):
    ret = 1
    b = min(b, a - b)
    for i in range(b):
        ret *= a - i
        ret %= P
    ret = mod_div(ret, mod_fact(b))
    return ret

ans = 0
_n = N - 1
for k in range(K + 1):
    a = N - k
    # N-1 Comb k
    if k == 0:
        comb = 1
    elif k == 1:
        comb = _n
    else:
        comb = comb * mod_div((_n - k + 1), k) % P
    b = M * mod_pow(M-1, a-1) % P
    b = b * comb % P
    ans += b
    ans %= P


print(ans)

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

namespace ABC058A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a,b,c;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);
            if (b-a==c-b)
                Console.Write("YES");
            else
                Console.WriteLine("NO");
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include <cstdio>

int partition(int *a, int p, int r){
    int x = a[r];
    int i = p - 1;
    int tmp;
    for(int j=p;j<r;j++){
        if(a[j]<=x){
            i++;
            tmp = a[j];
            a[j] = a[i];
            a[i] = tmp;
        }
    }
    a[r] = a[i+1];
    a[i+1] = x;
    return i + 1;
}

int main(){
    int i, n, p;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)scanf("%d",a+i);
    p = partition(a, 0, n-1);
    for(i=0;i<n;i++){
        if(i!=p)printf("%d",a[i]);
        else printf("[%d]",a[i]);
        if(i<n-1)printf(" ");
        else printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2948
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, n) for (int i = (n)-1; i >= 0; i--)
#define pp(v) cout << #v "=" << (v) << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
using namespace std;

int main() {
  int d,g; cin >> d >> g; g /= 100;
  vector<int> p(d), c(d);
  rep(i,d) {
    cin >> p[i] >> c[i];
    c[i] /= 100;
  }

  int ans = 1e6;
  rep(bit, 1<<d) {
    int sum = 0, cnt = 0, rest = -1;
    rep(i,d) if (bit >> i & 1) {
      sum += p[i] * (i + 1) + c[i];
      cnt += p[i];
    } else {
      rest = i;
    }

    if (sum < g) {
      if (rest == -1) continue;
      int need = div_ceil(g - sum, rest + 1);
      if (need >= p[rest]) continue;
      cnt += need;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<algorithm>
#include<climits>

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1) {
        int n, m;
        cin >> n >> m;
        if (n == 0) break;
        vector<int> mn(n, 0);
        vector<int> mx(n, 0);
        REP(i, m) {
            int s, k;
            cin >> s >> k;
            if (k == 1) {
                int c0;
                cin >> c0;
                mn[c0 - 1] += s;
                mx[c0 - 1] += s;
            } else {
                REP(j, k) {
                    int cj;
                    cin >> cj;
                    mx[cj - 1] += s;
                }
            }
        }
        auto mxe = max_element(ALL(mx));
        auto mne = min_element(ALL(mn));
        if (distance(mx.begin(), mxe) != distance(mn.begin(), mne)) {
            cout << *mxe - *mne + 1 << endl;
            // D('?');
            continue;
        }
        auto mxv = *mxe;
        auto mnv = *mne;
        *mxe = -1;
        *mne = INT_MAX;
        auto mxv2 = *max_element(ALL(mx));
        auto mnv2 = *min_element(ALL(mn));
        cout << max(mxv - mnv2, mxv2 - mnv) + 1 << endl;
    }
}



Measured memory_bytes: 3240
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int c=0,p=0,pc=1,ppc=0,n=s.size();
	for(;p+pc<=n;)
	{
		if(pc==2)
		{
			p+=2;
			c++;
			ppc=pc;
			pc=1;
		}
		else
		{
			c++;
			ppc=pc;
			if(s[p]==s[p+1])pc=2;
			else pc=1;
			p+=1;
		}
	}
	if(ppc==1&&pc==1&&s[n-1]==s[n-2]&&p!=n)c--;
	cout<<c<<endl;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define PB push_back

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVi;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;

int main(){
	ios::sync_with_stdio(false);
    string s;
    int start=0,end=0;
    cin>>s;
    bool flag = false;
    rep(i,s.size()){
        if(s[i] == 'A'){
            start = i;
            break;
        }
    }

    for(int i=s.size()-1;i>=0;i--){
        if(s[i] == 'Z'){
                end = i;
                break;
        }

    }

    cout<<end-start+1<<endl;

    return 0;
}


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

int main() {
  int n; cin >> n;
  vector<int> v(n);
  vector<int> r(n+1, 1<<30); r[0] = 0;
  for (int i=0; i<n; i++) cin >> v[i];

  for (int i=0; i<n; i++) {
    for (int j=1; j<=2; j++) {
      int cost = abs(v[i] - v[i+j]);
      r[i+j] = min(r[i+j], r[i] + cost);
    }
  }

  cout << r[n-1] << endl;

  return 0;
}

Measured memory_bytes: 1024
//#include "pch.h"
#include <iostream>

using namespace std;

int field[100][100] = { 0 };
int x[100];
int y[100];
int a[100];


int main() {

	int w, h, n;

	cin >> w >> h >> n;

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

	for (int i = 0; i < w; i++) {
		for (int j = 0; j < h; j++) {
			field[i][j] = 0;
		}
	}

	for (int i = 0; i < n; i++) {
		int xbegin, xend;
		int ybegin, yend;
		//x < xiを満たす領域（左側）
		if (a[i] == 1) {
			xbegin = 0;
			xend = x[i];
			ybegin = 0;
			yend = h;
		}
		//x > xiを満たす領域（右側）
		else if (a[i] == 2) {
			xbegin = x[i];
			xend = w;
			ybegin = 0;
			yend = h;
		}
		//y < yiを満たす領域（下側）
		else if (a[i] == 3) {
			xbegin = 0;
			xend = w;
			ybegin = 0;
			yend = y[i];
		}
		//y > yiを満たす領域（上側）
		else {
			xbegin = 0;
			xend = w;
			ybegin = y[i];
			yend = h;
		}

		for (int index1 = xbegin; index1 < xend; index1++) {
			for (int index2 = ybegin; index2 < yend; index2++) {
				field[index1][index2] = 1;
			}
		}
	}

	int ans = 0;

	for (int i = 0; i < w; i++) {
		for (int j = 0; j < h; j++) {
			ans += (1 - field[i][j]);
		}
		
	}

	cout << ans << endl;

//	system("pause");


	return 0;
}

Measured memory_bytes: 256
#include <limits>
#include <iostream>
#include <cmath>
#include <set>
#include <vector>
#include <cstdint>
int main()
{
    int64_t n;
    std::cin >> n;
    int64_t s = 0;
    int64_t min = std::numeric_limits<int64_t>::max();
    int64_t max = std::numeric_limits<int64_t>::min();
    for(int64_t i=0;i<n;i++)
    {
        int64_t c;
        std::cin >> c;
        s += c;
        if(c < min)
        {
            min = c;
        }
        if(c > max)
        {
            max = c;
        }
    }
    std::cout << min << " " << max << " " << s << "\n";


    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> V(N);
    rep(i,0,N)cin >> V[i];
    vector<int> cnt(N+1);
    rep(i,0,N){
        cnt[V[i]] ++;
    }
    if(N % 2 == 0){
        //すべて奇数
        //1 ~ N/2が２つずつ
        
        rep(i,0,N+1)if(i % 2 == 0 && cnt[i]){
            cout << 0 << endl;
            return 0;
        }else if(i % 2 == 1 && cnt[i] != 2){
            cout << 0 << endl;
            return 0;
        }
    }else{
        //すべて偶数
        //0が１つ　残りは２つずつ
        if(cnt[0] != 1){
            cout << 0 << endl;
            return 0;
        }
        rep(i,1,N+1)if(i % 2 == 1 && cnt[i]){
            cout << 0 << endl;
            return 0;
        }else if(i % 2 == 0 && cnt[i] != 2){
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = 1;
    rep(i,0,N/2){
        ans = ans * 2 % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define spn setprecision
using namespace std;
char arr[3];
int main() {
	cin >> arr;
	int cost=700;
	for(int i = 0; i < 3; i++){
		if(arr[i]=='o'){
			cost+=100;
		}
	}
	pd(cost);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b , c , d;
    cin >> a >> b >> c >> d;
    int x = max( a , c ) , y = min( b , d );
    cout << max( y - x , 0 ) << endl;
}



Measured memory_bytes: 256
#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;}
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e17;
/* warshall_floyd(dist)
    入力：初期化した dist
    計算量：O(|V|^3)
    副作用：dis[i][j]にiからjへの最短路のコストを格納
*/
void warshall_floyd(vector<vector<long long>> &dist) {
    int V = dist.size();
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
}

int main() {
    int n;
    cin >> n;
    vector<vector<bool>>f(n,vector<bool>(n));
    vector<vector<ll>>dist(n,vector<ll>(n));
    rep(i,n) rep(j,n) {
        cin >> dist[i][j];
        f[i][j] = true;
    }
    rep(k,n) rep(i,n) rep(j,n) {
        if(dist[i][k] + dist[k][j] < dist[i][j]) {
            cout << -1 << endl;
            return 0;
        } else if(dist[i][k] + dist[k][j] == dist[i][j] && i != k && j != k) f[i][j] = false;
    }
    ll ans = 0;
    rep(i,n) rep(j,n) {
        if(f[i][j]) ans += dist[i][j];
    }
    cout << ans/2 << endl;
}



Measured memory_bytes: 4356
N,Y = map(int,input().split())
ind = 0
for i in range(min(N,Y//10000)+1):
    for j in range(min(N-i,(Y-10000*i)//5000)+1):
        if (Y-10000*i-5000*j)%1000==0 and i+j+(Y-10000*i-5000*j)//1000==N:
            a= i
            b= j
            c = (Y-10000*i-5000*j)//1000
            ind=1
            break
if ind==0:
    print(-1,-1,-1)
else:
    print(a,b,c)

Measured memory_bytes: 3064
s = gets.chomp
ans = Array.new(s.size, 0)
idx = 0
s.scan(/R+L+/).each do |x|
  num_r = x.count('R')
  num_l = x.count('L')
  r = 1
  l = 1
  (num_r-1).times do |i|
    if i.even?
      l += 1
    else
      r += 1
    end
  end
  (num_l-1).times do |i|
    if i.even?
      r += 1
    else
      l += 1
    end
  end
  ans[idx + num_r - 1] = r
  ans[idx + num_r] = l
  idx += x.size
end
puts ans.join(' ')

Measured memory_bytes: 19412
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>
#include<queue>
using namespace std;
typedef long long ll;
const ll inf=1744174417441744;
int main(){
  ll a,b,m,ma=inf,mb=inf;
  vector<ll> av,bv;
  cin>>a>>b>>m;
  for(int i=0;i<a;i++){
    ll k;
    cin>>k;
    ma=min(ma,k);
    av.push_back(k);
  }
  for(int i=0;i<b;i++){
    ll k;
    cin>>k;
    mb=min(mb,k);
    bv.push_back(k);
  }
  ll ans=ma+mb;
  for(int i=0;i<m;i++){
    ll x,y,c;
    cin>>x>>y>>c;
    x--;
    y--;
    ans=min(ans,av[x]+bv[y]-c);
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define ll long long
#define vl vector<ll>
#define pl pair<ll,ll>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,b) for(ll i=0;i<b;i++)
#define RFOR(i,a,b) for(ll i=b-1;i>=a;i--)
#define rsort(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(),(v).end()
using namespace std;

ll mod=1000000007;
ll A[3];
signed main() {
    ll n,m,a;
    cin>>A[0]>>A[1]>>A[2];
    sort(A,A+3);
    rep(i,3){
        cout<<A[i];
        if(i<2)cout<<" ";
    }
    cout<<endl;
}



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

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

        int x = Integer.parseInt(br.readLine());
        double[] vectorA = new double[x];
        double[] vectorB = new double[x];

        String[] input = br.readLine().split(" ");
        for(int i = 0; i < x; i++)  vectorA[i] = Double.parseDouble(input[i]);
        input = br.readLine().split(" ");
        for(int i = 0; i < x; i++)  vectorB[i] = Double.parseDouble(input[i]);

        double d1 = 0;
        double d2 = 0;
        double d3 = 0;
        double dinf = 0;

        for(int i = 0; i < x; i++){ 
            double abs = Math.abs(vectorA[i]-vectorB[i]);
            d1 += abs;
            d2 += Math.pow(abs , 2);
            d3 += Math.pow(abs , 3);
            dinf = Math.max(dinf , abs);
        }

        d2 = Math.sqrt(d2);
        d3 = Math.cbrt(d3);

        System.out.println(d1);
        System.out.println(d2);
        System.out.println(d3);
        System.out.println(dinf);
    }
}



Measured memory_bytes: 24536
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		modComb.Init(200020);
		long mod = (long)1e9+7;
		long ans = 0;
		
		for(int j=B;j<W;j++){
			long a = modComb.nCrMod(j+(H-A-1),(H-A-1));
			long b = modComb.nCrMod(W-j-1+(A-1),(A-1));
			
			long c = a * b % mod;
			ans += c;
			if(ans >= mod) ans -= mod;
		}
		Console.WriteLine(ans);
	}
	int H,W,A,B;
	public Sol(){
		var d = ria();
		H = d[0];
		W = d[1];
		A = d[2];
		B = d[3];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}
class modComb{
	public static long mod=(long)(1e9+7);
	public static long nCrMod(long n,long r){
		if(n<r)return 0;
		if(n<0)return 0;
		if(r<0)return 0;
		if(n==0||r==n||r==0)return 1;
		long a=FactorialMod(n);
		long b=InvMod(FactorialMod(r));
		long c=InvMod(FactorialMod(n-r));
		long ans=(((a*b)%mod)*c)%mod;
		return ans;
	}
	
	static long[] FM;
	static public void Init(int N){
		FM = new long[N];
		FM[0] = FM[1] = 1;
		for(int i=2;i<N;i++){
			FM[i] = FM[i-1] *(long)(i);
			if(FM[i]>=mod)FM[i] %= mod;
		}
	}
	public static long FactorialMod(long n){
		
		if(FM[(int)n]!=0)return FM[(int)n];

		if(n<2)return FM[(int)n]=1;
		long ret=n*FactorialMod(n-1);
		ret%=mod;
		return FM[(int)n]=ret;
	}
	
	static long PowMod(long n,long k){
		
		if(k==0)return 1;
		if(n==0)return 0;
		long ret=1;
		long x=n;
		while(k>0){
			if((k&1)==1){ret*=x;ret%=mod;}
			x*=x;x%=mod;
			k>>=1;
		}
		return ret;
		
	}

	public static long InvMod(long n){
		return PowMod(n,mod-2);
	}
	

}


Measured memory_bytes: 4312
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
using namespace std;
typedef long long int ll;
using ull = unsigned long long;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int a[4]={};
    while(n--){
        string s; cin >> s;
        if(s[0]=='A')a[0]++;
        if(s[0]=='W')a[1]++;
        if(s[0]=='T')a[2]++;
        if(s[0]=='R')a[3]++;
    }
    printf("AC x %d\n",a[0]);
    printf("WA x %d\n",a[1]);
    printf("TLE x %d\n",a[2]);
    printf("RE x %d\n",a[3]);
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n'
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
struct ed{
	int u;
	int v;
	int w;
	ed(int a, int b, int c)
	{
		u = a;
		v = b;
		w = c;
	}
};
int main()
{
    she_told_me_dont_worry
	vector< ed > edges;
	int l,i;
	cin>>l;
	int n, m;
	int lg = log2(l);
	int num = pow(2, lg);
	n = lg+1;
	m = 2*lg;
	int cur ;
	l--;
	while( l - num >= 0)
	{
		cur = log2(l - num + 1);
		edges.pb( ed(cur+1, lg+1, num));
		num += pow(2, cur);
		m++;
	}
	cout<<n<< " "<<m<<endl;
	cur = 1;
	FOR(i, 1, n)
	{
		cout<<i<< " "<<i+1<<" "<<0<<endl;
		cout<<i<<" "<<i+1<<" "<<cur<<endl;
		cur *=2;
	}
	int si = edges.size();
	FOR0(i, si)
	{
		cout<<edges[i].u<< " "<<edges[i].v<< " "<<edges[i].w<<endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b > c + d)cout << "Left" << endl;
	else if (a + b == c + d)cout << "Balanced" << endl;
	else cout << "Right" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std ;
int main( void )
{
	short n ;
	cin >> n ;
	short a ,b ,c ,p ;
	short one[ n ] ,two[ n ] ,three[ n ] ;
	short i ,j ;
	for( i = 0 ; i < n ; i++ )
	{
		cin >> one[ i ] >> two[ i ] >> three[ i ] ;
	}
	for( i = 0 ; i < n ; i++ )
	{
		a = b = c = p = 0 ;
		for( j = 0 ; j < n ; j++ )
		{
			if( i == j )
			{
				continue ;
			}
			if( one[ i ] != one[ j ] )
			{
				a++ ;
			}
			if( two[ i ] != two[ j ] )
			{
				b++ ;
			}
			if( three[ i ] != three[ j ] )
			{
				c++ ;
			}
		}
		if( a == n - 1 )
		{
			p += one[ i ] ;
		}
		if( b == n - 1 )
		{
			p += two[ i ] ;
		}
		if( c == n - 1 )
		{
			p += three[ i ] ;
		}
		cout << p << endl ;
	}
	return 0 ;
}

Measured memory_bytes: 3104
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  if (S[K-1] == 'A') S[K-1] = 'a';
  if (S[K-1] == 'B') S[K-1] = 'b';
  if (S[K-1] == 'C') S[K-1] = 'c';
  rep(i,N) cout << S[i];
  cout << endl;
  return 0;
}

Measured memory_bytes: 3044