akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>

using pa2 = std::pair<long long, long long>;
std::vector<pa2> foun;

constexpr double pi = 3.141592653589793238;
long long n;
constexpr long long INF = 1e+12;


double dist(pa2 a, pa2 b){
    auto ite = std::lower_bound(foun.begin(), foun.end() , a);
    std::vector<long long> lis(n, INF);
    auto high = std::max(a.second, b.second);
    auto low = std::min(a.second, b.second);
    while(ite != foun.end() && ite->first <= b.first){
        auto y = ite->second;
        if(low <= y && y <= high){
            auto l = std::lower_bound(lis.begin(), lis.end() , y);
            *l = y;
        }
        ite++;
    }

    long long circ = std::lower_bound(lis.begin(), lis.end() , INF) - lis.begin();
//    double Loss = 10*pi - 20;
    double Gain = -20 + 5 * pi;
    long long dis = std::abs(a.first- b.first) + std::abs(a.second- b.second);
    double ret = dis*100. + circ * Gain;
    if(std::min(std::abs(a.second- b.second), std::abs(a.first- b.first) ) +1 == circ){
        ret += 5.*pi;
    }
    return ret;

}

int main() {
    long long x1,y1,x2,y2;
    std::cin >> x1 >> y1 >> x2 >> y2
             >> n;
    bool flipx, flipy;
    flipx = flipy = false;
    if(x1 > x2){
        x1 *= -1;
        x2 *= -1;
        flipx = true;
    }
    if(y1 > y2){
        y1 *= -1;
        y2 *= -1;
        flipy = true;
    }
    for (int i = 0; i < n; ++i) {
        long long tx, ty;
        std::cin >> tx >> ty;
        foun.push_back({tx *(flipx ? -1 : 1),ty * (flipy ? -1 : 1)});
    }
    std::sort(foun.begin(), foun.end());

    std::cout << std::scientific << std::setprecision(17) <<  dist({x1,y1}, {x2,y2}) << std::endl;


}


Measured memory_bytes: 6384
<?php
fscanf(STDIN, "%d", $n);
$h = explode(' ', trim(fgets(STDIN)));
$max_count = 0;
$current_count = 0;
for ($i=0; $i < count($h) - 1; $i++) { 
    if ($h[$i] >= $h[$i+1]) {
        $current_count += 1;
    } else {
        $current_count = 0;
    }
    if ($max_count < $current_count) {
        $max_count = $current_count;
    }
}

echo $max_count . "\n";

Measured memory_bytes: 14840
import sys

MOD = 10 ** 9 + 7

h, w, k = map(int, sys.stdin.readline().split())

def main():
    ok = []
    for i in range(2 ** (w - 1)):
        prev = False
        for j in range(w-1):
            if i >> j & 1:
                if prev:
                    break
                else:
                    prev = True
            else:
                prev = False
        else:
            ok.append(i)
        
    res = [0] * w
    res[0] = 1
    for _ in range(h):
        nex = [0] * w
        for i in ok:
            j = 0
            while j < w:
                if i >> j & 1:
                    nex[j] += res[j+1]
                    nex[j+1] += res[j] 
                    j += 2
                else:
                    nex[j] += res[j]
                    j += 1
        for j in range(w):
            nex[j] %= MOD
        res = nex
    
    return res[k-1]
    
if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3064
from collections import deque, Counter

n, x, y = map(int, input().split())

inf = 100100100
x -= 1
y -= 1

ans = [0] * n

for i in range(n):
    dist = [inf] * n
    queue = deque()
    queue.append(i)
    dist[i] = 0
    while queue:
        current = queue.popleft()
        d = dist[current]

        if current - 1 >= 0 and dist[current - 1] == inf:
            queue.append(current - 1)
            dist[current - 1] = d + 1
        if current + 1 < n and dist[current + 1] == inf:
            queue.append(current + 1)
            dist[current + 1] = d + 1
        if current == x and dist[y] == inf:
            queue.append(y)
            dist[y] = d + 1
        if current == y and dist[x] == inf:
            queue.append(x)
            dist[x] = d + 1

    for j in range(n):
        ans[dist[j]] += 1

for k in range(1, n):
    print(ans[k] // 2)


Measured memory_bytes: 49884
n = int(input())
s = []
AC = 0
WA = 0
TLE = 0
RE = 0
s = [input() for i in range(n)]
for j in range(n):
    if s[j]=="AC":
        AC = AC +1
    elif s[j]=="WA":
        WA = WA + 1
    elif s[j]=="TLE":
        TLE = TLE + 1
    else:
        RE = RE+1
print("AC x ",AC )
print("WA x ",WA )
print("TLE x ",TLE )
print("RE x ",RE )

Measured memory_bytes: 16256
import sys
import time
from queue import Queue
limit_time = time.time() + 1.70
input = sys.stdin.readline
sys.setrecursionlimit(1000000000)

N, M, P = map(int, input().split())

A = [-1]*M
B = [-1]*M
C = [-1]*M
nodes_edges = [[] for _ in range(N)]
rev_nodes_edges = [[] for _ in range(N)]
coin = [-float('inf')]*N
coin[0] = 0
availables = set()

for edge in range(M):
    a, b, c = map(int, input().split())
    A[edge] = a-1
    B[edge] = b-1
    C[edge] = c-P
    nodes_edges[a-1].append(edge)
    rev_nodes_edges[b-1].append(edge)

def cut_graph(node):
    edges = rev_nodes_edges[node]
    availables.add(node)
    for edge in edges:
        prev = A[edge]
        if prev in availables:
            continue
        cut_graph(prev)

cut_graph(N-1)
q = Queue()
q.put(0)
count = 0
limit = M*(1+len(availables))
while not q.empty():
    if time.time() >= limit_time:
        print(-1)
        break
    node = q.get()
    edges = nodes_edges[node]
    for edge in edges:
        nxt = B[edge]
        if nxt not in availables:
            continue
        new_coin = C[edge]+coin[node]
        if new_coin > coin[nxt]:
            coin[nxt] = new_coin
            q.put(nxt)
    count += 1
else:
    ans = coin[N-1]
    ans = 0 if ans < 0 else ans
    print(ans)


Measured memory_bytes: 75860
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <cassert>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <complex>
using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 *1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 100100;

int A[MAX];
int B[MAX];

int main()
{
	//freopen("in.txt","r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n;
	scanf("%d", &n);
	set<int> s[2];
	FOR (i, 0, n)
	{
		scanf("%d", &A[i]);
		B[i] = A[i];
	}

	sort(A, A+n);
	FOR (i, 0, n)
	{
		s[i&1].insert(A[i]);
	}

	int res = 0;
	FOR (i, 0, n)
	{
		int x = B[i];
		if (!s[i&1].count(x)) res++;
	}

	cout<<res / 2<<endl;

}


Measured memory_bytes: 5888
//Daniel Grzegorzewski
#include <bits/stdc++.h>

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

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

int h, w;
char a[55][55];

int main() {
  init_ios();
  cin >> h >> w;
  for (int i = 1; i <= h; ++i)
    for (int j = 1; j <= w; ++j)
      cin >> a[i][j];
  for (int i = 1; i <= h; ++i)
    for (int j = 1; j <= w; ++j)
      if (a[i][j] == '#' && a[i-1][j] != '#' && a[i+1][j] != '#' && a[i][j-1] != '#' && a[i][j+1] != '#') {
        cout<<"No\n";
        return 0;
      }
  cout<<"Yes\n";
}

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

int n;
long long ans, a, b, x[100001];
int main() {
	scanf("%d%lld%lld",&n,&a,&b);
	for(int i = 0; i < n; i++) {
		scanf("%lld",x+i);
		if(!i) continue;
		ans += min(a*(x[i]-x[i-1]), b);
	}
	printf("%lld", ans);
}


Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

# import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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

    A, B = il()
    tap = 1

    cnt = 0
    while tap < B:
        tap += A - 1
        cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3932
//                             In The Name Of Allah                                           
//                             	Mohammad Hosseini
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
//#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 3e5 + 100, OO = 1e9, T = 4500 + 100, M = 1e9 + 7, P = 6151, SQ = 280, lg = 30;
typedef pair <int, int> pii;
vector <int> v[N];
int a[N];

bool dfs(int x, int y) {
	bool cerr = false;
	for(auto u : v[x]) 
		if(u != y && a[u] < a[x])
			cerr |= !dfs(u, x);
	return cerr;
}

int32_t main() {
	use_fast;
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	for(int i = 1; i < n; i++) {
		int x, y;
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x);
	}
	for(int i = 1; i <= n; i++) 
		if(dfs(i, 0))
			cout << i << " ";
	cout << endl;
	return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- uploaded by ubuntu 20.04 
5- ...
*/



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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define output(x) cout << ( x ? "Yes" : "No" ) << '\n' ;
#define mxn 100005
using namespace std;

void solve(){
	int n,x,t;
	cin >> n >> x >> t;
	cout << ((n + x - 1) / x) * t;
}

int32_t main()
{
	FLASH
	int t = 1;
	// cin >> t;
	while(t--){
		solve();
	}
	return 0;
}



Measured memory_bytes: 3644
a,b,c,x,y=map(int,input().split())
m=10**9
for i in range(0,max(x,y)*2+1,2):
    p=(c*i)+max((b*(y-(i//2))),0)+max((a*(x-(i//2))),0)
    if p<m:
        m=p
print(m)


Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
dp = [[[0] * (N + 1) for _ in range(N + 1)] for _ in range(N + 1)]
#dp[i3][i2][i1]...皿を寿司の数が多い順に並べたとき、i1, i2, i3 はそれぞれ寿司の数が1, 2, 3個の皿が終わる点(スライス)。dpはそのときの期待値。
i3, i2, i1 = 0, 0, 0

for i in range(N):
	if a[i] == 3:
		i3 = i + 1
		i2 = i3
		i1 = i3
	elif a[i] == 2:
		i2 = i + 1
		i1 = i2
	elif a[i] == 1:
		i1 = i + 1
		
c1, c2, c3 = 0, 0, 0

for j3 in range(0, i3 + 1):
	for j2 in range(j3, i2 + 1):
		for j1 in range(j2, i1 + 1):
			#サイコロで3貫の皿が出たときの処理
			if j3 > 0:
				c3 = dp[j3 - 1][j2][j1]
				p3 = j3 / N
			else:
				p3 = 0
			
			#2貫
			if j2 > j3:
				c2 = dp[j3][j2 - 1][j1] 
				p2 = (j2 - j3) / N
			else:
				p2 = 0
			
			#1貫
			if j1 > j2:
				c1 = dp[j3][j2][j1 - 1]
				p1 = (j1 - j2) / N
			else:
				p1 = 0
			
			p = p3 + p2 + p1
			if p > 0:
				dp[j3][j2][j1] = (c3 * p3 + c2 * p2 + c1 * p1) / p + 1 / p
			
print(dp[i3][i2][i1])


Measured memory_bytes: 498312
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N,M,X;
int A[12][12];
int C[12];
signed main() {
	cin.tie(0);ios::sync_with_stdio(false);
	cin>>N>>M>>X;
	rep(i,N){
		cin>>C[i];
		rep(j,M)cin>>A[i][j];
	}
	int ans=inf;
	rep(i,1<<N){
		int cost=0,sum[12];
		rep(j,M)sum[j]=0;
		rep(j,N){
			if(i>>j&1){
				cost+=C[j];
				rep(k,M)sum[k]+=A[j][k];
			}
		}
		rep(j,M){
			if(sum[j]<X)goto ng;
		}
		chmin(ans,cost);
		ng:;
	}
	if(ans!=inf)cout<<ans<<endl;
	else cout<<-1<<endl;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
#define MOD 1000000007
#define int long long

signed main(){
    int a,b;cin>>a>>b;
    if(a<1||9<a||b<1||9<b)cout<<-1<<endl;
    else cout<<a*b<<endl;
}

Measured memory_bytes: 256
# AOJ 0092 Square Searching
# Python3 2018.6.21 bal4u

cin = [[''] for r in range(1002)]
dp =  [[0 for c in range(1002)] for r in range(1002)]
while 1:
	n = int(input())
	if n == 0: break
	for r in range(n): cin[r] = input()
	ans = 0
	for r in range(n):
		for c in range(n):
			if cin[r][c] == '*': dp[r][c] = 0
			else :
				t = 1+min(dp[r-1][c-1], dp[r][c-1], dp[r-1][c])
				dp[r][c] = t
				if t > ans: ans = t
	print(ans)



Measured memory_bytes: 33064
// Aizu 3015: Palindrome
// 2017.9.25 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MIN(a,b)  ((a)<=(b)?(a):(b))

#define HASHSIZ 4001
typedef struct { char *s; int id; char r; } HASH;
HASH hash[HASHSIZ+2];				// Hash table

typedef struct { char *s; int n, p; } T;   // ????????????????????°????????¢??¨?????????????????°
T str[1002]; int ssize;
char body[2005][32]; int bsize;

int lookup(char *s, int w, int id, int *r)
{
	HASH *tp;
	int i = (101 * *s + 103 * *(s+w-1) + 107 * w) % HASHSIZ;

	tp = hash + i;
	if (tp->s != NULL) {
		int inc = *s + (*(s + 1) << 1);
		while (1) {
			if (!memcmp(tp->s, s, w)) { *r = tp->r; return tp->id; }
			i += inc;
			if (i >= HASHSIZ) i -= HASHSIZ;
			tp = hash + i;
			if (tp->s == NULL) break;
		}
	}
	tp->s = s, tp->id = id, tp->r = *r;
	return -1;
}

int cmp(T *a, T *b)
{
	if (a->n > 0 && b->n == 0) return -1;
	if (a->n == 0 && b->n > 0) return 1;
	return strcmp(a->s, b->s);
}

char *palindrome(char *des, char *src, int len)
{
	des += len; *des = 0;
	while (*src) *--des = *src++;
	return des;
}

int palindromic(char *s, int len)
{
	char *p = s + len - 1;
	while (p >= s) {
		if (*p-- != *s++) return 0;
	}
	return 1;
}

int main()
{
	int n, w, i, j, m, id, r, k;
	char *p, *mid;
	T *sp;

	scanf("%d%d", &n, &w);
	ssize = bsize - 0; while (n-- > 0) {
		scanf("%s", p = body[bsize]);
		r = 0;
		id = lookup(p, w, ssize, &r);
		if (id < 0) {
			sp = str + ssize;
			sp->s = p, sp->n = 1, sp->p = 0;
			bsize++;
			palindrome(body[bsize], p, w);
			r = 1; if ((id = lookup(body[bsize], w, ssize, &r)) < 0) bsize++;
			ssize++;
		} else if (r == 0) str[id].n++;
		else               str[id].p++;
	}

	m = 0;
	for (i = 0; i < ssize; i++) {
		if (str[i].n != str[i].p) {
			if (palindromic(str[i].s, w)) {
				if (str[i].n & 1) {
					if (m == 0 || memcmp(str[i].s, mid, w) < 0) m = 1, mid = str[i].s;
				}
				str[i].n >>= 1, str[i].p = str[i].n;
			} else {
				k = MIN(str[i].n, str[i].p);
				str[i].n = str[i].p = k;
			}
		}
		if (strcmp(str[i].s, p = palindrome(body[bsize], str[i].s, w)) > 0)
			memcpy(str[i].s, p, w);
	}
	qsort(str, ssize, sizeof(T), cmp);

	for (i = 0; str[i].n > 0; i++) {
		for (j = 0; j < str[i].n; j++) printf(str[i].s);
	}
	if (m) printf(mid);
	while (--i >= 0) {
		for (j = 0; j < str[i].n; j++) printf(palindrome(body[bsize], str[i].s, w));
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 2072
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int a,b;
  cin >> a >> b;
  
  int g[12] = {1,3,1,2,1,2,1,1,2,1,2,1};

  if(g[a-1] == g[b-1]) cout << "Yes" << endl;
  else                 cout << "No"  << endl;
    
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main() {
  int num = 0;
  scanf("%d\n", &num);
  int *a = (int *)malloc(sizeof(int) * num);
  int max = 0;
  for (int i=0; i<num; i++) {
    scanf("%d", a+i);
    if (a[i] > a[max]) {
      max = i;
    }
  }
  int fire = 0;
  for (int i=0; i<num; i++) {
    if (i != max) {
      fire += a[i];
    }
  }
  if (a[max] < fire) printf("Yes\n");
  else printf("No\n");
  free(a);
  return 0;
}
    

Measured memory_bytes: 128
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))
c = [[0]*W for _ in range(H)]

y, x = 0, 0
direction = 1
for i in range(N):
  for _ in range(a[i]):
    c[y][x] = (i+1)
    if direction == 1:
      if x+1 <= W-1:
        x += 1
      else:
        y += 1
        direction *= -1
    else:
      if x-1 >= 0:
        x -= 1
      else:
        y += 1
        direction *= -1
  
for cc in c:
  print(*cc)

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n[4];
    for(long i=0;i<4;i++)
        cin>>n[i];
    bool one,nine,seven,four;
    one=nine=seven=four=false;
    for(long i=0;i<4;i++)
    {
        if(n[i]==1)
            one=true;
        else if(n[i]==9)
            nine=true;
        else if(n[i]==7)
            seven=true;
        else if(n[i]==4)
            four=true;
    }
    if(one && nine && seven && four)
        cout<<"YES";
    else
        cout<<"NO";
}



Measured memory_bytes: 256
#include<stdio.h>
#define rep(a,b) for(long int i = a;i <= b;i++)

int main(void){
  //acquisition of data
  long int k,n; scanf("%ld%ld",&k,&n);
  long int a[200010],b[200010]; rep(1,n){scanf("%ld",&a[i]);}

  //b[i]:distance between i and i+1
  rep(1,n){
    if(i != n){b[i] = a[i+1] - a[i];}
    else{b[n] = k - (a[n]-a[1]);}
  }

  //find max element in array b
  long int max = 0;
  rep(1,n){if(max < b[i]){max = b[i];}}

  //answer
  printf("%ld",k - max);
  return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>

int GetCombination(int n, int x)
{	
	int count = 0;
	for(int i = 1; i <= n - 2; i++){
		for(int j = i + 1; j <= n - 1; j++){
			for(int k = j + 1; k <= n; k++){
				if(i + j + k == x){
					count++;
				} 
			}
		}
	}
	return count;
}

int main(void)
{
	int n, x;
	
	while(true){
	
		scanf("%d %d", &n, &x);
	
		if(n == 0 && x == 0){
			break;
		}
		
		printf("%d\n", GetCombination(n, x));
	}
}

Measured memory_bytes: 2632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia,a=sc.Ia;
		int g=s[0]/2,f=(s[0]%2)^1;
		long m=0;
		for(int i = s[0]-1;i>=g;i--) {m+=a[i];}
		int[][] q=new int[s[1]][];
		for(int i = 0;i<s[1];i++) {q[i]=new int[]{sc.I,i};}
		Array.Sort(q,(u,v)=>u[0]-v[0]);
		long[] ans=new long[s[1]];
		for(int i = 0;i<s[1];i++) {
			while(Math.Abs(q[i][0]-a[g])<Math.Abs(q[i][0]-a[f])){
				m=m-a[g]+a[f];
				f+=2;
				g++;
			}
			ans[q[i][1]]=m;
		}
		Console.WriteLine(String.Join("\n",ans));
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 39472
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){ 
    int n,k;
    cin >> n >> k;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    ll ans = 1e16,l_r,r_l;
    
    rep(i,n-k+1){
        l_r = abs(x[i]) + abs(x[i+k-1] - x[i]);
        r_l = abs(x[i+k-1]) + abs(x[i] - x[i+k-1]);
        //cout << l_r << "," << r_l << endl;
        if(ans > min(l_r,r_l)){
            ans = min(l_r,r_l);
        }
    }

    cout << ans << endl;
    return 0;
}

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

typedef long long int   ll;
#define int             ll
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
#define scan(n)         scanf("%lld",&n)
#define pb              push_back
#define PI              3.1415926535897932384626433832795
#define rep0            for(int i=0;i<n;i++)
#define rep1            for(int i=1;i<=n;i++)
#define inputar0(ar)    for(int i=0;i<n;i++)cin>>ar[i]
#define inputar1(ar)    for(int i=1;i<=n;i++)cin>>ar[i]
#define showar0(ar)     for(int i=0;i<n;i++)cout<<ar[i]<<" "
#define showar1(ar)     for(int i=1;i<=n;i++)cout<<ar[i]<<" "
int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
int binpow(int a,int b){int res=1;while(b>0){if(b%2){res=(res*a);b--;}a=(a*a);b/=2;}return res;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

int phi[10000005];

void init(int n){
    for (int i = 1; i <= n; ++i)
     for (int j = i; j <= n; j += i)
        ++phi[j];
}

signed main(){
  FIO
    int t=1;
//    scan(t);
    while(t--){
        init(10000001);
        int n;cin>>n;
        int ans=0;
        for(int i=1;i<=n;i++){
//            cout<<phi[i]<<" ";
            ans+=((phi[i])*i);
        }
//        cout<<endl;
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 81740
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
using namespace std;

int main(){
	int n;	cin>>n;
	int a[100010];
	vector<int> L;
	REP(i,0,n) cin>>a[i];
	L.push_back(a[0]);
	REP(i,1,n){
		if(L.back()<a[i])	L.push_back(a[i]);
		else	*lower_bound(L.begin(),L.end(),a[i])=a[i];
	}
	p(L.size());
	return 0;
}

Measured memory_bytes: 3876
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <functional>
#include<ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);
const double eps = 1e-10;

struct T
{
	int level, time;
	string s;
	T(int level = 0, int time = 0, string s = "") :level(level), time(time), s(s) {}
	bool operator<(const T &b) const {
		if (level == b.level) return time < b.time;
		else return level < b.level;
	}
};

int n, m, a, num, t;
char c;
string s;
set<T> hard, lazy;
map<string, P> Map;

int main()
{
	while (~scanf("%d", &n))
	{
		t = num = 0;
		hard.clear(), lazy.clear(), Map.clear();
		for (int i = 0; i < n; i++)
		{
			cin >> s >> a;
			Map[s] = P(a, ++t);
			T now = T(a, t, s);
			if (++num / 5 > hard.size())
			{
				set<T>::reverse_iterator ite = lazy.rbegin();
				if (ite == lazy.rend() || *ite < now) hard.insert(now);
				else {
					hard.insert(*ite);
					lazy.erase(*ite);
					lazy.insert(now);
				}
			}
			else {
				set<T>::iterator ite = hard.begin();
				if (ite == hard.end() || now < *ite) lazy.insert(now);
				else {
					lazy.insert(*ite);
					hard.erase(ite);
					hard.insert(now);
				}
			}
		}
		scanf("%d", &m);
		while (m--)
		{
			cin >> c >> s;
			if (c == '+')
			{
				scanf("%d", &a);
				Map[s] = P(a, ++t);
				T now = T(a, t, s);
				if (++num / 5 > hard.size())
				{
					set<T>::reverse_iterator ite = lazy.rbegin();
					if (ite != lazy.rend() && now < *ite)
					{
						cout << s << " is not working now.\n";
						cout << ite->s << " is working hard now.\n";
						hard.insert(*ite);
						lazy.erase(*ite);
						lazy.insert(now);
					}
					else {
						cout << s << " is working hard now.\n";
						hard.insert(now);
					}
				}
				else {
					set<T>::iterator ite = hard.begin();
					if (ite == hard.end() || now < *ite) {
						cout << s << " is not working now.\n";
						lazy.insert(now);
					}
					else {
						cout << s << " is working hard now.\n";
						cout << ite->s << " is not working now.\n";
						lazy.insert(*ite);
						hard.erase(ite);
						hard.insert(now);
					}
				}
			}
			else {
				map<string, P>::iterator it = Map.find(s);
				T now = T(it->second.first, it->second.second, s);
				Map.erase(it), num--;
				set<T>::iterator ite = hard.find(now);
				if (ite == hard.end())
				{
					lazy.erase(now);
					if (num / 5 < hard.size())
					{
						ite = hard.begin();
						cout << ite->s << " is not working now.\n";
						lazy.insert(*ite);
						hard.erase(ite);
					}
				}
				else {
					hard.erase(ite);
					if (num / 5 > hard.size())
					{
						set<T>::reverse_iterator iter = lazy.rbegin();
						cout << iter->s << " is working hard now.\n";
						hard.insert(*iter);
						lazy.erase(*iter);
					}
				}
			}
		}
	}
	return 0;
}

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

using namespace std;
long long MAXN = 2*(1e5)+1;
/*
long double pi = 3.1415926536;

long long mod = 1e9+7;

bool secgreat(pair<int, int> a, pair<int, int> b){
    return a.second<b.second;
}


long long fact(long long n){
    n%=mod;
    if(n==0){
        return 1;
    }
    else if(n == 1){
        return 1;
    }
    else{
        return ((n%mod)*(fact(n-1)%mod))%mod;
    }
}

long long power(long long n, long long pow){
    n%=mod;
    long long res = 1;
    while(pow){
        if(pow%2){
            res = ((res%mod)*(n%mod))%mod;
        }
        pow/=2;
        n= ((n%mod)*(n%mod))%mod;
    }
    res%=mod;
    return res;

}

long long inversemod(long long n){
    return power(n, mod-2)%mod;
}
*/
/*
struct node{
    long long key;
    node* left;
    node* right;
};

struct node* newnode(long long item){
    struct node* temp = new struct node;
    temp->key = item;
    temp->left = NULL;
    temp->right = NULL;
    return temp;
};

struct node* insert(struct node* root, long long key){
    if(root == NULL){
        return newnode(key);
    }

    if (key<root->key){
        root->left = insert(root->left, key);
    }
    else if(key>root->key){
        root->right = insert(root->right, key);
    }
};
*/
/*
string binary(int a){
    string s;
    int x = 9;
    while(x>0){
        s.push_back(48+a%2);
        a/=2;
        x--;
    }
    reverse(s.begin(), s.end());

    return s;
}

int strtoi(string s){
    int n = s.length();
    int i;
    int sum = 0;
    for(i = 0; i<n; i++){
        sum+=pow(2, i)*s[i];
    }
    return sum;
}
*/
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long n;
    cin>>n;
    long long i, j, k;
    long long sum = 0;
    for(j = 1; j<n; j++){
        for(k = n/j; k>=1; k--){
            if((n-j*k)<n && n-j*k!=0){
                //cout<<j*k<<" "<<n-j*k<<endl;
                sum++;
            }
        }
    }

    cout<<sum;

}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int L,R;
  cin >> L>>R;
  int m=((L%2019)*(R%2019))%2019;
  
  for (int i=L;i<min(L+2019,R);i++){
    int l=i%2019;
    for (int j=i+1;j<min(i+2019,R+1);j++){
      int r=j%2019;
      m=min(m,(l*r)%2019);
    }
  }
  cout << m<<endl;
  
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vii> vvii;

#define fastIO ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define forw(i,l,r) for( auto i = (l) ; i < (r) ; i++ )
#define forb(i,r,l) for( auto i = (r) ; i >= (l) ; i-- )
#define log2i(x) 32 - __builtin_clz((x)) - 1
#define log2ll(x) 64 - __builtin_clzll((x)) - 1
#define Pi acos(-1.0)
#define sz(x) (int)x.size()
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

const int N = 2e5+7;
const ll M = 1e9+7;
int n,m,a,b;
ll ans;
ll f[N], invf[N];

ll fexp(ll x, ll y) {
    ll res=1;
    while(y) {
        if(y&1) res=(res*x)%M;
        x=(x*x)%M;
        y>>=1;
    }
    return res%M;
}

void init() {
    f[0]=invf[0]=1;
    forw(i,1,N) {
        f[i]=(f[i-1]*i)%M;
        invf[i]=(invf[i-1]*fexp(i,M-2))%M;
    }
}

ll C(int n, int k) {return (f[n]*invf[k]%M*invf[n-k])%M;}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("test.inp","r",stdin);
    //freopen("test.out","w",stdout);
#endif
    fastIO;
    init();
    scanf("%d %d %d %d",&n,&m,&a,&b);
    forw(i,b,m) ans=(ans+C(n-a-1+i,i)%M*C(a-1+m-i-1,a-1)%M)%M;
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  cout<<((a+b+c==2*max(max(a,b),c)? "Yes":"No"))<<endl;
	return 0;
}

Measured memory_bytes: 256
s = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'

S = s.replace(' ', '').split(',')

k =int(input())
print(int(S[k - 1]))

Measured memory_bytes: 2940
n, c = map(int, input().split())
D = [tuple(map(int, input().split())) for _ in range(c)]
C = [tuple(map(lambda x:int(x)-1, input().split())) for _ in range(n)]

cols = [[0] * c for _ in range(3)]
for i in range(n):
    for j in range(n):
        c_from = C[i][j]
        cols[(i+j)%3][c_from] += 1

from itertools import permutations
d = 1000*500*500
for p0, p1, p2 in permutations(list(range(c)), 3):
    d_ = 0
    for c_from in range(c):
        d_ += cols[0][c_from]*D[c_from][p0]
        d_ += cols[1][c_from]*D[c_from][p1]
        d_ += cols[2][c_from]*D[c_from][p2]
    d = min(d, d_)
print(d)


Measured memory_bytes: 5108
N, K = map(int,input().split())
p = list(map(int,input().split()))
ma = sum(p[0:K]) 
newma = ma
for i in range(N-K):
  newma = newma + p[K+i] - p[i]
  if ma < newma:
    ma = newma
print((ma+K)/2)
   

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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    long long k;
    cin >> k;
    for(int i = 0; i < s.size(); ++i) {
        if(s[i] == '1') {
            if(i == k - 1) return cout << 1 << '\n', 0;
        } else {
            return cout << s[i] << '\n', 0;
        }
    }
    assert(0 == 1);
}


Measured memory_bytes: 256
#D
from heapq import heappush,heappop
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
d=[]
for i in range(x):
    for j in range(y):
        heappush(d,-a[i]-b[j])
e=[]
for i in range(min(3000,x*y)):
    e.append(-heappop(d))
f=[]
for i in range(len(e)):
    for j in range(z):
        heappush(f,-e[i]-c[j])
for i in range(k):
    print(-heappop(f))

Measured memory_bytes: 194080
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

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

int main(){
	int n,m;
	
	scanf("%d %d",&n,&m);
	
	vector<int> C(m);
	vector<int> T(n+1,INF);
	
	T[0]=0;
	for(int i=0;i<m;i++) scanf("%d",&C[i]);
	for(int i=0;i<m;i++){
		for(int j=C[i];j<=n;j++){
			T[j]=min(T[j],T[j-C[i]]+1);
		}
	}
	printf("%d\n",T[n]);
}


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

using namespace std;
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define mp make_pair
#define ld long double
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
const int N = 1e3 + 100;
int T;
char str[N][N];
int ans[N][N], vis[N][N], n, m, sx, sy, ex, ey;
int dis[4][2] = {{1,  0},
                 {-1, 0},
                 {0,  -1},
                 {0,  1}};
struct node {
    int x, y, step;
};
deque<node> q;

int main() {
    scanf("%d%d%d%d%d%d", &n, &m, &sx, &sy, &ex, &ey);
    for (int i = 1; i <= n; i++)scanf("%s", str[i] + 1);
    for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)ans[i][j] = INT_MAX;
    q.push_back(node{sx, sy, 0});
    ans[sx][sy] = 0;
    while (!q.empty()) {
        node now = q.front();
        q.pop_front();
        int x = now.x, y = now.y, st = now.step;
        if (vis[x][y])continue;
        vis[x][y] = 1;
//        ans[x][y] = st;
        for (int i = 0; i < 4; i++) {
            int xx = x + dis[i][0], yy = y + dis[i][1];
            if (xx > 0 && xx <= n && yy > 0 && yy <= m && !vis[xx][yy] && str[xx][yy] == '.') {
                if (ans[xx][yy] > st) {
                    ans[xx][yy] = st;
                    q.push_front(node{xx, yy, st});
                }
            }

        }
        for (int xx = max(1, x - 2); xx <= min(x + 2, n); xx++) {
            for (int yy = max(1, y - 2); yy <= min(y + 2, m); yy++) {
                if (!vis[xx][yy] && str[xx][yy] == '.') {
                    if (ans[xx][yy] > st + 1) {
                        ans[xx][yy] = st + 1;
                        q.push_back(node{xx, yy, st + 1});
                    }
                }
            }
        }
    }
    if (ans[ex][ey] == INT_MAX)puts("-1");
    else printf("%d\n", ans[ex][ey]);
    return 0;
}

Measured memory_bytes: 13456
solve [] _ _ 'A' = "A"
solve _ [] _ 'B' = "B"
solve _ _ [] 'C' = "C"
solve (c:cs) sb sc 'A' = case c of
                           'a' -> solve cs sb sc 'A'
                           'b' -> solve cs sb sc 'B'
                           'c' -> solve cs sb sc 'C'
solve sa (c:cs) sc 'B' = case c of
                           'a' -> solve sa cs sc 'A'
                           'b' -> solve sa cs sc 'B'
                           'c' -> solve sa cs sc 'C'
solve sa sb (c:cs) 'C' = case c of
                           'a' -> solve sa sb cs 'A'
                           'b' -> solve sa sb cs 'B'
                           'c' -> solve sa sb cs 'C'

main = do
  sa <- getLine
  sb <- getLine
  sc <- getLine
  putStrLn $ solve sa sb sc 'A'


Measured memory_bytes: 508
<?php
    fscanf(STDIN, "%s", $s);
    $result = '';
    if($s == 'Sunny'){
        $result = 'Cloudy';
    }else if($s == 'Cloudy'){
        $result =  'Rainy';
    }else if($s == 'Rainy'){
        $result = 'Sunny';
    }
    echo $result;
  ?>

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef int ut;
typedef complex<int> cli;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr> PQ;
typedef tuple<int,int,int,int> TP;
typedef vector<TP> VTP;
const int INF=1<<30;
const int SIZE=1000;
int C[SIZE][6];
TP CC;
TP conv(int a,int b,int c,int d){
	return min(min(TP(a,b,c,d),TP(b,c,d,a)),min(TP(c,d,a,b),TP(d,a,b,c)));
}
TP conv(int x){
	return conv(C[x][0],C[x][1],C[x][2],C[x][3]);
}
LL mult(TP x){
	if(get<0>(x)==get<2>(x) && get<1>(x)==get<3>(x)){
		if(get<0>(x)==get<1>(x)) return 4;
		return 2;
	}
	return 1;
}
map<TP,LL> mtp; 
LL solve(int a,int b){
	LL ALLans=0;
	mtp[conv(a)]--;
	mtp[conv(b)]--;
	REP(k,4){
		LL ans=1;
		REP(i,4){
			TP next=conv(C[a][(-i+4+1)%4],C[a][(-i+4)%4],C[b][(i+k+1)%4],C[b][(i+k)%4]); 
		//	cout << C[a][(-ii+4+1)%4] <<" "<< C[a][(-i+4)%4]<<" "<<C[b][(i+k+1)%4]<<" "<<C[b][(i+k)%4] << endl;
			ans*=mtp[next]*mult(next);
			ans=max<LL>(0,ans);
			mtp[next]--;
		}
		REP(i,4){
			TP next=conv(C[a][(-i+4+1)%4],C[a][(-i+4)%4],C[b][(i+k+1)%4],C[b][(i+k)%4]); 
			mtp[next]++;
		}
		ALLans+=max<LL>(0,ans);
	}
	mtp[conv(a)]++;
	mtp[conv(b)]++;
	return ALLans;
}
int main(){
	LL N;
	cin.tie(0);
	cin >> N;
	REP(i,N){
		REP(j,4){
			cin >> C[i][j];		
		}
		mtp[conv(i)]=mtp[conv(i)]+1;
	}
	LL ans=0;
	REP(i,N)
		REP(j,i)
			ans += solve(i,j);
	cout << ans/3 << endl;
	return 0;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN
#define INF         100000000000000000
#define PI          3.1415926535897932384626433832795l



#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)






// struct mycomp {
//     bool operator() (const pair<int,int> &a, const pair<int,int> &b) const{
//         if (a.second-a.first != b.second-b.first)
//         return (a.second-a.first > b.second-b.first);
//         return a.first < b.first;
//     }
// };



/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


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

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}	
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}


///////////////////////////BFS//////////////////////////////////
void bfs(vector<int>& distance, vector<int> a[], vector<bool>& visited, int u, vector<int>& parent)
{
	visited[u]=true;
	parent[u]=-1;
	distance[u]=0;
	queue<int> q;

	q.push(u); 
    while (!q.empty()) { 
  
        int f = q.front(); 
        q.pop(); 
  		for(int i =0; i < a[f].size(); i++)
  		{
  			if(visited[a[f][i]]==false)
  			{
  				distance[a[f][i]]=distance[f]+1;
  				parent[a[f][i]]=f;
  				visited[a[f][i]]=true;
  				q.push(a[f][i]);
  			}
  		}
    } 

}

void solve()
{

}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	int t=1;
	// cin>>t;
	while(t--)
	{
		int n;
		// cin>>n;
		string s;
		cin>>s;
		int ans = INT_MIN, ct = 0;
		for(int i = 0; i < 3; i++)
		{
			if(s[i]=='R') ct++;
			else
			{ 
				ans = max(ct, ans);
				ct=0;
			}
		}
		ans = max(ct, ans);
		cout<<ans<<endl;
	}
	return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1
#define j0 gray_cat_j0

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 16;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int get_time(char *c) {
	return 60 * ((c[0] - '0') * 10 + c[1] - '0') + ((c[3] - '0') * 10 + c[4] - '0');
}

void solve(){
	int m1, s1, m2, s2, k;
	cin >> m1 >> s1 >> m2 >> s2 >> k;
	int d = m2 * 60 + s2 - m1 * 60 - s1;
	printf("%d\n", d - k);
}

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 3756
#include <iostream>  
    #include <string>  
    #include <algorithm>  
    #include <map>  
    #include <queue>  
    using namespace std;  
       
    map<string, int> dp;  
    int direction[4] = { 1, -1, 4, -4 };  
    
    void bfs()  
    {  
        queue<string> que;  
        que.push("01234567");  
        dp["01234567"] = 0;  
        while (!que.empty())  
        {  
            string now = que.front(); que.pop();   
            int p = 0;  
            for (int j = 0; j < 8; ++j)  
            {  
                if (now[j] == '0')  
                {  
                    p = j;  
                    break;  
                }  
            }  
       
            for (int i = 0; i < 4; ++i)  
            {  
                int n = p + direction[i];  
                if (0 <= n && n < 8 &&   
                    !(p == 3 && i == 0) &&  
                    !(p == 4 && i == 1))   
                {  
                    string next = now;  
                    swap(next[p], next[n]);  
                    if (dp.find(next) == dp.end())  
                    {  
                        dp[next] = dp[now] + 1;  
                        que.push(next);  
                    }  
                }  
            }  
        }  
    }  
       
      
    int main()  
    {  
       
        bfs();  
        string line;  
        while (getline(cin, line))  
        {  
            line.erase(remove(line.begin(), line.end(), ' '), line.end());  
            cout << dp[line] << endl;  
        }  
       
        return 0;  
    }  


Measured memory_bytes: 5420
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque, Counter
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
INF = 10 ** 20

def main():
    h,w = getList()
    if h == 1 or w == 1:
        print(1)
        return
    yoko1 = h // 2 + (h % 2)
    yoko2 = (h // 2)
    ans = (w // 2) * (yoko1 + yoko2)
    if w % 2 == 1:
        ans += yoko1

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

int main() {
    cin>>N;
    long double pi = 3.1415926;
    cout<<fixed<<setprecision(10)<<pi * N * 2<<endl;
}

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

int main(){
  int n,kari;
  cin >> n;
  
  long long int count = 0;
  for(int i = 1;i < n + 1;i ++){
    if(i % 3 == 0)kari ++;
    else if(i % 5 == 0)kari ++;
    else count += i;
  }
  
  cout << count << endl;
}

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


int main(){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  while(1){
    c -= b;
    if(c<=0){
      printf("Yes\n");
      return 0;
    }
    a -= d;
    if(a<=0){
      printf("No\n");
      return 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1660
N = int(input())
s = input()
if N < 2:
  result = "No"
else:
  n = int(N/2)
  s1 = s[:n]
  s2 = s[n:]
  if s1 == s2:
    result = "Yes"
  else:
    result = "No"
print(result)

Measured memory_bytes: 9012
f = lambda : raw_input().rstrip()
f1 = lambda : f().split()
f2 = lambda t : map(t, f1())

def main1():
    A, B, C = f2(int)
    X = C - A
    print 0 if B + X <= A else (B + X) % A

def main2():
    n = int(f())
    p = 0
    ans = 0
    while 10**p<n:
        if 10**(p+1) > n:
            ans = ans + n - 10**p + 1
        else:
            ans = ans + 10**(p+1) - 10**p + 1
        p = p + 2
    print ans
    
def main3():
    n = int(f())
    a = f2(int)
    m = 0
    for i in xrange(1,n):
        if a[i] < a[i-1]:
            m = m + a[i] - a[i-1]
    print "YES" if m < 2 else "NO"

def main4():
    s = f()
    n = len(s)
    ans = [0]*n
    m = 1
    i = 1
    st = 0
    s = s + ("L" if s[-1]=="R" else "R")
    while i <= n:
        if s[i] != s[i-1]:
            #print i, st,
            j = st if s[i-1]=="L" else i
            #print j
            if m&1:
                ans[j-1] = ans[j-1] + m/2 + (1 if s[i-1] == "R" else 0) 
                ans[j] = ans[j] + m/2 + (1 if s[i-1] == "L" else 0)
            else:
                ans[j-1] =  ans[j-1] + m/2
                ans[j] = ans[j] + m/2
            m = 0
            st = i
        #print ans
        i = i + 1
        m = m + 1
    print " ".join(map(str,ans)) 
         
if __name__=="__main__":
    main4()

Measured memory_bytes: 4612