akhauriyash/Code-Regression huggingface dataset:
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
from operator import mul
import bisect
import sys
import logging
import heapq
import itertools

logging.basicConfig(level=logging.ERROR)

input = sys.stdin.readline

setrecursionlimit(1000000)


def main():
	l =  list(reversed(['SUN','MON','TUE','WED','THU','FRI','SAT','UNTI']))
	print(l.index(input()[:-1]))

def factorization(n):
	if n<2:
		return []

	arr = []
	temp = n
	for i in range(2, int(-(-n**0.5//1))+1):
		if temp%i==0:
			cnt=0
			while temp%i==0:
				cnt+=1
				temp //= i
			arr.append([i, cnt])

	if temp!=1:
		arr.append([temp, 1])

	if arr==[]:
		arr.append([n, 1])

	return arr

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(numbers):
	return reduce(fractions.gcd, numbers)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

class PriorityQueue():
	def __init__(self):
		self.queue = []
	def push(self,i):
		heapq.heappush(self.queue,-i)
	def pop(self):
		return -1 * heapq.heappop(self.queue)
	def sum(self):
		return -sum(self.queue)

main()


Measured memory_bytes: 69356
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define pii pair<int, int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(c) (c).begin(),(c).end()
#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define PW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <class T> inline bool CHMIN(T& a, T b) { if(a>b) { a=b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if(a<b) { a=b; return 1; } return 0; }
template <class T> inline void SORT(T& a) { sort(ALL(a)); }
template <class T> inline void REV(T& a) { reverse(ALL(a)); }
template <class T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int n,t;
int h[100010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> n >> t;
  REP(i,n) cin >> h[i];
  int mx = 0;
  int sum = 0;
  REP(i,n) {
    CHMAX(mx,h[i]);
    int d = max(0LL,t-sum);
    cout << d/mx + 1 + (d%mx >= h[i]) << endl;
    sum += h[i];
  }

  return 0;
}


Measured memory_bytes: 4004
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    int N, M;
    cin >> N >> M;
    ll ans = 1;
    if (N == M) {
        rep(i, N) ans =
            (ans * (i + 1) % (1000000000 + 7)) * (i + 1) % (1000000000 + 7);
        ans = ans * 2 % (1000000000 + 7);
    } else if (abs(N - M) == 1) {
        ans = max(N, M);
        rep(i, min(N, M)) ans =
            (ans * (i + 1) % (1000000000 + 7)) * (i + 1) % (1000000000 + 7);
    } else
        ans = 0;
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

ll a, b, k;
void show()
{
    cout << a << " " << b << endl;
}

int main(int argc, char const *argv[])
{

    cin >> a >> b >> k;
    ll r = min(a, k);
    a -= r;
    k -= r;
    if (k == 0)
    {
        show();
        return 0;
    }
    r = min(b, k);
    b -= r;
    k -= r;
    show();
    return 0;
}


Measured memory_bytes: 256
N = int(input())
dic = {}
ans = 0
A = list(map(int, input().split()))
for i in range(N):
    dic[i] = 0

for i in range(N):
    b = A[i]+N-i-1
    if A[i] < N-i:
        a = N-i-A[i]-1
        dic[a] += 1
    if b < N:
        ans += dic[b]
print(ans)

Measured memory_bytes: 40352
#include <algorithm>
#include <climits>
#include <functional>
#include <iterator>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#ifdef _MSC_VER
using ll = __int64;
using ull = unsigned __int64;
#else
using ll = long long int;
using ull = unsigned long long int;
#endif

// 二乗を計算する。
ll sq(ll x) { return x * x; }

// 領域内にいるか。
bool within(ll x, ll min, ll max) {
	return min <= x && x <= max;
}

// container の中から key より小さい値を見つける。
// 見つからない場合は container.end() を返す。
template<typename T>
typename T::iterator less_than(T& container, typename T::key_type& key) {
	typename T::iterator prev = container.lower_bound(key);
	if (prev == container.begin()) prev = container.end();
	else prev--;
	return prev;
}

// container の中から key より大きい値を見つける。
// 見つからない場合は container.end() を返す。
template<typename T>
typename T::iterator greater_than(T& container, typename T::key_type& key) {
	return container.upper_bound(key);
}

// b^e (mod m) を求める
ll modpow(ll b, ll e, ll m) {
	ll result = 1;
	while (e > 0) {
		if ((e & 1) == 1) result = (result * b) % m;
		e >>= 1;
		b = (b * b) % m;
	}
	return result;
}


// ここから解法

int main(void) {
	int N;
	cin >> N;
	vector<int> d(N);
	for (int i = 0; i < N; ++i) cin >> d[i];
	sort(d.begin(), d.end());
	int start = d[N / 2 - 1];
	int end = d[N / 2];
	cout << (end - start) << endl;
	return 0;
}



Measured memory_bytes: 640
import sys
import heapq
input=sys.stdin.readline
INF=2<<28

def dijkstra(G,start,n):#グラフ,初期頂点,頂点数

    dist=[INF]*n;dist[start]=0
    used=[False]*n;used[0]=True
    q=[]

    for v in G[start]:
        heapq.heappush(q,v)
    
    while len(q)>0:
        now=heapq.heappop(q)
        if used[now[1]]:
            continue
        v=now[1]
        dist[v]=now[0]
        used[v]=True

        for e in G[v]:
            if not used[e[1]]:
                heapq.heappush(q,(e[0]+dist[v],e[1]))

    return dist

N=int(input().rstrip())
g=[[] for _ in range(N)]
for _ in range(N):
    u,k,*c=map(int,input().split())
    for j in range(0,k*2,2):
        g[u].append((c[j+1],c[j]))

ans=dijkstra(g,0,N)
for i,x in enumerate(ans):
    print(i,x)


Measured memory_bytes: 6208
#include <stdio.h>

int main(){
	int a1;
	int a2;
	int a3;
	
	scanf("%d %d %d", &a1, &a2, &a3);
	if (a1 + a2 + a3 >= 22){
		printf("bust\n");	
	}
	else {
		printf("win\n");
	}
	return 0;
	
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC omodtimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll k;
	cin >> k;
	ll ans = 0;
	for (int z=1;z<=k;z++){
		for (int x=1;x<=k;x++){
			for (int y=1;y<=k;y++){
				ans += __gcd(y,__gcd(z,x));
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int n,ans;
int main()
{
    cin>>n;
    for(int i=0;i<=10;i++)
    {
        if(pow(2,i)<=n)
        {
            ans=pow(2,i);
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
vector<int> v[200000];
int cnt[200000];
void cal(int x, int y){
    for(int i=0;i<v[x].size();i++){
        int z = v[x][i];
        if(z != y){
            cnt[z] += cnt[x];
            cal(z, x);
        }
    }
}
int main(void){
    int n, q;
    cin >> n >> q;
    for(int i=0;i<n-1;i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    fill(cnt, cnt+n, 0);
    for(int i=0;i<q;i++){
        int p, x;
        cin >> p >> x;
        cnt[--p] += x;
    }
    cal(0, -1);
    for(int i=0;i<n;i++){
        cout << cnt[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 26624
H, W = map(int, input().split())

# H = 3
# W = 5
areas = [input() for _ in range(H)]
points = [[0] * W for _ in range(H)]

# areas = ['.....', '.#.#.', '.....']
# points = [[0] * W for _ in range(H)]

for h in range(H):
    for w in range(W):
        if areas[h][w] == '#':
            continue
        # 条件を変数にいれるべき...
        # 右隣
        if w + 1 < W and areas[h][w+1] == '#':
            points[h][w] += 1
        # 右斜め下
        if w + 1 < W and h + 1 < H and areas[h+1][w+1] == '#':
            points[h][w] += 1
        # 真下
        if h + 1 < H and areas[h+1][w] == '#':
            points[h][w] += 1
        # 左下
        if w - 1 >= 0 and h + 1 < H and areas[h+1][w-1] == '#':
            points[h][w] += 1
        # 左
        if w - 1 >= 0 and areas[h][w-1] == '#':
            points[h][w] += 1
        # 左斜め上
        if w - 1 >= 0 and h - 1 >= 0 and areas[h-1][w-1] == '#':
            points[h][w] += 1
        # 真上
        if h - 1 >= 0 and areas[h-1][w] == '#':
            points[h][w] += 1
        # 右斜め上
        if h - 1 >= 0 and w + 1 < W and areas[h-1][w+1] == '#':
            points[h][w] += 1


ans = []
for h in range(H):
    s = ''
    for w in range(W):
        area = areas[h][w]
        p = points[h][w]
        if p != 0:
            s += str(p)
        else:
            if area == '#':
                s += '#'
            else:
                s += '0'
    ans.append(s)
print('\n'.join(ans))


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int w = sc.nextInt();
		for (int i=0;i<s.length();i+=w) {
			System.out.print(s.charAt(i));
		}
	}
}

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

#define MAX 20
#define EXP 1024*64 + 10
#define INF 1000000000000000000LL

using namespace std;
typedef long long int lli;

int n;

int v[MAX][MAX];

lli dp[EXP];
lli cost[EXP];

lli DP(int mask)
{
	lli& ans = dp[mask];

	if(ans != -1) return ans;

	if(mask == 0) return ans = 0;

	ans = -INF;

	for(int sub = mask ; sub > 0 ; sub = (sub - 1) & mask)
		ans = max(ans , DP(mask ^ sub) + cost[ sub ]);

	return ans;
}

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

	memset(dp , -1 , sizeof(dp));

	for(int i = 0 ; i < n ; i++)
		for(int j = 0 ; j < n ; j++)
			scanf("%d",&v[i][j]);

	for(int mask = 0 ; mask < (1 << n) ; mask++)
	{
		for(int i = 0 ; i < n ; i++)
		{
			if( !(mask & (1 << i)) ) continue;

			for(int j = i + 1 ; j < n ; j++)
				if( mask & (1 << j) ) cost[ mask ] += v[i][j];
		}
	}

	printf("%lld\n",DP((1 << n) - 1));
}

Measured memory_bytes: 1408
#include <stdio.h>

int main(){
    int i, j, k, n, count[101] = {}, mode = -1;
    
    while(scanf("%d", &n) != EOF){
        count[n]++;
    }
    for (i = 0; i < 101; i++){
        if (mode < count[i]) {mode = count[i]; j = i;}
    }
    printf("%d\n", j);
    for (k = j + 1; k < 101; k++){
        if (count[j] == count[k]) printf("%d\n", k);
    }
    
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	string s,t;
	cin >> s  >> t;
	int m=0;
	for(int i=0;i<3;i++){
		if(s[i]==t[i])m++;
	}
	cout << m << endl;
	
	return 0;
}




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

int main() {
  string a,b,c;
  cin >> a >> b >> c;
  printf("A%cC\n", b[0]);
  return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  ABC156C
//
#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;
int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    int R=0;
    int L=101;
    vector<int>X(N);
    for (int i=0; i<N; i++) {
        cin>>X.at(i);
        R=max(R,X.at(i)); // 最大値 R
        L=min(L,X.at(i)); // 最小値 L
    }
    // R~Lの範囲で計算してみる
    int ans=1000000; // 答えは100*100*100より小さい
    for (int j=L; j<=R; j++) {
        int party=0;
        for (int k=0; k<N; k++) {
            party+=((X.at(k)-j)*(X.at(k)-j));
        }
        ans=min(party,ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
int m,k,i;
int main(){
    scanf("%d%d",&m,&k);
    if(1<<m<=k||m==1)return puts(k?"-1":"0 0 1 1")*0;
    for(;i<1<<m;i++)if(i!=k)printf("%d ",i);
    printf("%d ",k);
    for(;i--;)if(i!=k)printf("%d ",i);
    printf("%d\n",k);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n; cin>>n;
	VI a(n); rep(i,n) cin>>a[i];
	ll ans=LINF;
	for(ll i=-100;i<=100;i++){
		ll tmp=0LL;
		rep(j,n) tmp+=pow(i-a[j],2LL);
		chmin(ans,tmp);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define rep(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	double t, a;
	cin >> n >> t >> a;

	vector<double> H(n);
	double x;
	rep(i, n) {
		cin >> x;
		H[i] = abs(t - x * 0.006 - a);
	}

	double mi = 1e9;
	int ans;
	rep(i, n) {
		if (mi > H[i]) {
			mi = H[i];
			ans = i;
		}
	}

	cout << ans + 1 << endl;

	return 0;
}



Measured memory_bytes: 3728
package main

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

func main() {
	sc := NewScanner()
	N, A,B := sc.NextInt(), sc.NextInt(), sc.NextInt()


	fmt.Println(min(N*A,B))
}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}


type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

int N;
int A[111],B[111];

signed main(){
    cin>>N;
    rep(i,N)cin>>A[i];
    rep(i,N)cin>>B[i];

    rep(i,N-1)A[i+1]+=A[i];
    for(int i=N-1;i>0;i--)B[i-1]+=B[i];

    int ans=0;
    rep(i,N)chmax(ans,A[i]+B[i]);
    cout<<ans<<endl;
    return 0;
}


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

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

    long long s;
    cin >> s;
    long long v = 1000000000;
    cout << "0 0 1000000000 " << v * ((s + v - 1) / v) - s << ' ' << 1 << ' ' << (s + v - 1) / v << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1000000000100000000;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int n; cin >> n;
    vector<string> W(n); map<string, bool> mp;
    bool fg = true;
    rep(i, n){
        cin >> W[i];
        if(mp[W[i]])fg = false;
        mp[W[i]] = true;
    }
    rep(i, n-1){
        if(W[i+1][0] != W[i].back())fg = false;
    }
    if(fg)cout << "Yes" << ln;
    else cout << "No" << ln;
}

Measured memory_bytes: 3608
#!python3.8
# -*- coding: utf-8 -*-
# abc163/abc163_a
import sys
import math

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    R = i2n()
    print(R * math.pi * 2)
    return

main()


Measured memory_bytes: 9208
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/11/ALDS1_11_C

from collections import deque

n = int(input())
graph = {}
res = [-1 for i in range(n + 1)]

for i in range(1, n + 1):
    data = input().split()
    graph[i] = [int(i) for i in data[2:]]

visited = set()
q = deque()
q.append((1, 0))  # node,distance
visited.add(1)

while q:
    node, dis = q.popleft()
    res[node] = dis
    for _next in graph[node]:
        if _next not in visited:
            visited.add(_next)
            q.append((_next, dis + 1))

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



Measured memory_bytes: 6036
a,b,m=map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
tickets=list()
for i in range(m):
    tickets.append(list(map(int,input().split())))

price_min=float("INF")
for ticket in tickets:
    price = A[ticket[0]-1] + B[ticket[1]-1] - ticket[2]
    price_min = price if price_min>price else price_min

# 割引券を使わない場合
no_ticket=min(A)+min(B)
if price_min > no_ticket: price_min=no_ticket
print(price_min)

Measured memory_bytes: 38444
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

void dfs(int i, vector<pair<int,int> >&p, vector<vector<int> >&a,int start,vector<bool>&seen){
    for(auto v:a.at(start)){
        if(i==2){
            // cout<<"v="<<v<<endl;
        }
        if((v==p.at(i).first and start==p.at(i).second) or (v==p.at(i).second and start==p.at(i).first)){
            int z;
        }
        else{
            if(seen.at(v)==false){
                seen.at(v)=true;
                dfs(i,p,a,v,seen);
            }
        }
    }
    return;
}

int main() {
    int n,m;
    cin>>n>>m;
    vector<vector<int> >a(n);
    vector<pair<int,int> >p(m);
    vector<bool>seen(n,false);
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        x--;
        y--;
        a.at(x).push_back(y);
        a.at(y).push_back(x);
        p.at(i).first=x;
        p.at(i).second=y;
    }
    int cnt=0;
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            seen.at(j)=false;
        }
        // cout<<"i="<<i<<endl;
        seen.at(p.at(i).first)=true;
        dfs(i,p,a,p.at(i).first,seen);
        for(int j=0;j<n;j++){
            // if(i==2){
            //     cout<<"j="<<j<<endl;
            // }
            if(seen.at(j)==false){
                cnt++;
                // cout<<"i:"<<i<<" j:"<<j<<endl;
                break;
            }
        }
        // cout<<"i="<<i<<"回目成功！"<<endl;
        // cout<<"cnt="<<cnt<<endl;
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <set>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef unsigned long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 29;
const double EPS = 1E-10;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)

string card[4][13];
int get_rank(char ch){
	if(isdigit(ch)){
		return ch - '0';
	}else if(ch == 'T'){
		return 10;
	}else if(ch == 'J'){
		return 11;
	}else if(ch == 'Q'){
		return 12;
	}else if(ch == 'K'){
		return 13;
	}else return 100;
}

int main(){
	char trump, led;
	while(cin >> trump && trump != '#'){
		int cntEW = 0, cntNS = 0;
		int leader = 0;
		rep(i, 4)rep(j, 13) cin >> card[i][j];

		rep(i, 13){
			bool f = false;
			int best = 0;
			int id = 0;
			led = card[leader][i][1];
			rep(j, 4) if(card[j][i][1] == trump) f = true;
			rep(j, 4){
				if(f){
					if(card[j][i][1] == trump && get_rank(card[j][i][0]) > best){
						best = get_rank(card[j][i][0]);
						id = j;
					}
				}else{
					if(card[j][i][1] == led && get_rank(card[j][i][0]) > best){
						best = get_rank(card[j][i][0]);
						id = j;
					}
				}
			}
			if(id % 2 == 0) cntNS++;
			else cntEW++;
			leader = id;
		}

		if(cntEW > cntNS){
			cout << "EW " << cntEW - 6 << endl;
		}else{
			cout << "NS " << cntNS - 6 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	string s; cin >> s;
	int ans = 1;
	for(int i=0;i<n-1;i++){
		if(s[i]!=s[i+1]){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

ll N;
string s;
vector<vll> G;
ll dist[200010];
bool fav[200010];
void dfs1(ll v,ll p){
  fav[v] = s[v]=='1';
  for(ll u:G[v])if(u!=p){
    dfs1(u,v);
    dist[v] = max(dist[v],dist[u]+1);
    fav[v] |= fav[u];
  }
}
ll ans;
void dfs2(ll v,ll p,ll d_p,bool f_p){
  //debug(v);
  vector<tuple<ll,ll> > dc;
  dc.emplace_back(0,-1);
  ll minfdc=INF;
  ll cntf=s[v]=='1';
  for(ll u:G[v]){
    if(u==p){
      dc.emplace_back(d_p+1,u);
      if(f_p){
        cntf++;
        minfdc = min(minfdc,d_p+1);
      }
    }else{
      dc.emplace_back(dist[u]+1,u);
      if(fav[u]){
        cntf++;
        minfdc = min(minfdc,dist[u]+1);
      }
    }
  }
  sort(dc.rbegin(),dc.rend());
  //debug(dc.size());
  if(dc.size()>=3){
    ans += max(0ll,(get<0>(dc[1]))+1-(s[v]=='1'? 0:minfdc));
  }else{
    ans += s[v]=='1';
  }
  if(p!=-1){
    if((d_p <= dist[v] && f_p)||(d_p >= dist[v]&&fav[v])){
      ans++;
    }
  }
  //debug(ans);
  for(ll u:G[v])if(u!=p){
    dfs2(u,v,get<0>(dc[get<1>(dc[0])==u]),(cntf>fav[u]));
  }
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>N;
  G.resize(N);
  for(ll i=0;i<N-1;i++){
    ll a,b;cin>>a>>b;a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  cin>>s;
  dfs1(0,-1);
  dfs2(0,-1,0,false);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 51216
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define pi  acos(-1)
const int w=5e5+5;
const ll mod=998244353;
ll a[w],b[w],c[w];
int n,m;
int cmp(ll x,ll y)
{
    return x>y;
}
int main()
{
    int i,j;
    int x,y,z;
    cin>>n>>m>>x>>y>>z;
    for(i=1;i<=x;i++)
        scanf("%lld",&a[i]);
    for(i=1;i<=y;i++)
        scanf("%lld",&b[i]);
    for(i=1;i<=z;i++)
        scanf("%lld",&c[i]);
    sort(a+1,a+1+x,cmp);
    sort(b+1,b+1+y,cmp);
    sort(c+1,c+1+z,cmp);
    for(i=1;i<=x+1;i++)
        a[i]+=a[i-1];
    for(i=1;i<=y+1;i++)
        b[i]+=b[i-1];
    for(i=1;i<=z+1;i++)
        c[i]+=c[i-1];
    ll ans=0;
    int u=n,v=m;
    for(i=0;i<=z;i++)
    {
        ans=max(ans,a[u]+b[v]+c[i]);
        ll xx=1e9+5,yy=1e9+5;
        if(u>=1)
            xx=a[u]-a[u-1];
        if(v>=1)
            yy=b[v]-b[v-1];
        int pos=0;
        if(xx<=yy)
            pos=1;
        else
            pos=2;
        if(pos==1)
        {
            if(xx<c[i+1]-c[i])
                u--;
            else
                break;
        }
        if(pos==2)
        {
            if(yy<c[i+1]-c[i])
                v--;
            else
                break;
        }
    }
    cout<<ans<<endl;
    return 0;
}
/*
2 3 3 3 5
1 2 3
4 5 6
7 8 9 9 9
*/


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0 ; i < int(N);i++)
using namespace std ;
typedef long long ll;
typedef pair <int , int >pi;
typedef vector <int> vi ;
typedef vector <string> si;



// void solve(){
int main (){
	ios::sync_with_stdio(0);
	cin.tie(0);

	ll a,b,c,d;
	cin >> a >> b >> c >> d ;
	ll as,bs,cs;
	ll e = a*c ;
	ll f = a*d;
	ll g = b*c;
	ll h = b*d;
	 bs = max(e,f);
	 cs = max(g,h);
	 as = max(cs,bs);

	
	cout << as << endl;


	return 0 ;
}

Measured memory_bytes: 3648
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,a,b = get_nums_l()

kumi = n // (a+b)
ans = kumi*a + (min(a, n % (a+b) ))
print(ans)

Measured memory_bytes: 38452
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define eps 1e-9
#define oo 1e7+5

using namespace std;

typedef unsigned long long ull;
typedef vector<pair<int,pair<int,int>>> dirgraph;
typedef vector<vector<int>> graph;

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);

	int n,k;
	cin>>n>>k;
	vector<int> A(n);
	for(int& x: A)
		cin>>x;
		
//Can player 1 win for i stones = dp[i]
	vector<bool> dp(k+1);

	for (int stones=0;stones<k+1;stones++)
	{
		for(int elem=0;elem<n;elem++)
		{
			if(stones-A[elem]>=0 && !dp[stones-A[elem]])
				dp[stones]=1;
		}
	}
	
	if(dp[k])cout<<"First"<<endl;
	else cout<<"Second"<<endl;

	return 0;
}



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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using P = pair<int,int>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    string S;
    cin>>S;
    int ans = 0;
    int cnt = 0;
    rep(i,3){
        if(S[i]=='R') cnt++;
        else{
            chmax(ans,cnt);
            cnt=0;
        }
    }
    chmax(ans,cnt);
    cout<<ans<<endl;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A==5 && B==5 && C==7) cout << "YES" << endl;
  else if (A==5 && B==7 && C==5) cout << "YES" << endl;
  else if (A==7 && B==5 && C==5) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

constexpr unsigned long MOD = 998244353;
constexpr unsigned long mx = 1000001;
constexpr unsigned long R = 4294967296, MODinv = 998244351, R2 = 932051910, mask = R - 1, R_bitsize = 32;

constexpr unsigned long montgomery_reduction(unsigned long a){
    return (a + (mask & a * MODinv) * MOD) >> R_bitsize;
}

template<unsigned long maxsize, unsigned long MOD, unsigned long primesize>
class divisor_convolution_coefficients{
    unsigned long sieve[maxsize];
public:
    unsigned long prime[primesize];
    unsigned long coef[maxsize];
    constexpr divisor_convolution_coefficients() : coef(), sieve(), prime(){
        coef[1] = R2;
        for(unsigned long i = 2; i < maxsize; ++i){
            coef[i] = R2 * i % MOD;
            sieve[i] = 1;
        }
        for(unsigned long i = 2, c = 0; i < maxsize; ++i)if(sieve[i]){
                prime[c++] = i;
                for(unsigned long j = i; j < maxsize; j += i){
                    sieve[j] = 0;
                    (coef[j] *= MOD + 1 - i) %= MOD;
                }
            }
    }
};

constexpr divisor_convolution_coefficients<mx, MOD, 78498> coef{divisor_convolution_coefficients<mx, MOD, 78498>()};

int main(){
    using namespace std;

    unsigned long N;
    cin >> N;

    unsigned long ans{0};
    unsigned long max_size{0};
    vector<unsigned long> hoge(mx);
    for(unsigned long _ = 0, i; _ < N; ++_){
        cin >> i;
        max_size = max(i, max_size);
        ++hoge[i];
    }
    ++max_size;
    hoge.resize(max_size);

    for(const auto& i : coef.prime)for(unsigned long j = max_size / i; j; --j)hoge[j] += hoge[j * i] * i;
    for(auto& i : hoge)i %= MOD;

    ans = MOD - hoge[1];
    for(unsigned long i = 1; i < max_size; ++i)if(hoge[i])ans += montgomery_reduction(montgomery_reduction(hoge[i] * hoge[i]) * coef.coef[i]);
    (ans += (ans & 1) * MOD) >>= 1;
    cout << ans % MOD << endl;

    return 0;
}

Measured memory_bytes: 8700
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>
using namespace std;

vector<int> A(101);

bool Scan () {
    int a, b;
    bool f = false;

    while (cin >> a >> b) {
        if (a == b && b == 0) break;
        A[a]++;
        A[b]++;
        f = true;
    }
    return f;
}

int main ()
{
    while (1) {
        fill (A.begin(), A.end(), 0);
        A[1]++; A[2]++;
        if (!Scan()) break;
        bool flag = true;
        for (auto &i : A) {
            if (i % 2 == 1) {
                cout << "NG" << endl;
                flag = false;
                break;
            }
        }
        if (flag) cout << "OK" << endl;
    }


    return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<cstdio>

using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	for(int i=0;i<10000;i++){
//		cout<<(i*0.08)<<" "<<(i*0.1)<<endl;
		if((int)(i*0.08)==a&&(int)(i*0.1)==b){
			cout<<i<<endl;
			return 0;
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter("\\s");
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.print(a*b);
		System.out.print(" ");
		System.out.println(a*2+b*2);
	}
}

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

public class AtCoder
{
  const int D = 60;
  const int MAX_N = 200005;

  public static void Main()
  {
    var to = new int[D, MAX_N];

    var nk = Console.ReadLine().Trim().Split().ToArray();
    var n = int.Parse(nk[0]);
    var k = long.Parse(nk[1]);

    var a = Console.ReadLine().Trim().Split().Select(e => int.Parse(e)).ToArray();
    for (var i = 0; i < n; i++)
    {
      to[0, i] = a[i] - 1;
    }

    for (var i = 0; i < D - 1; i++)
    {
      for (var j = 0; j < n; j++)
      {
        to[i + 1, j] = to[i, to[i, j]];
      }
    }

    var v = 0;
    for (var i = D - 1; i >= 0; --i)
    {
      long l = 1L << i;
      if (l <= k)
      {
        v = to[i, v];
        k -= l;
      }
    }
    Console.WriteLine(v + 1);
  }
}

Measured memory_bytes: 92320
#include<bits/stdc++.h>
using namespace std;
const int N=200100;
int n,m,a[N],mn[N<<2];
struct st{int l,r;}q[N];
bool cmp(st a,st b){return a.l==b.l?a.r>b.r:a.l<b.l;}
void build(int x,int l,int r)
{
	if(l==r){mn[x]=(l==0)?0:N;return;}
	int mid=l+r>>1;build(x<<1,l,mid);build(x<<1|1,mid+1,r);mn[x]=min(mn[x<<1],mn[x<<1|1]);
}
void chg(int x,int l,int r,int p,int v)
{
	if(l==r){mn[x]=min(mn[x],v);return;}
	int mid=l+r>>1;
	if(p<=mid)chg(x<<1,l,mid,p,v);else chg(x<<1|1,mid+1,r,p,v);
	mn[x]=min(mn[x<<1],mn[x<<1|1]);
}
int qry(int x,int l,int r,int tl,int tr)
{
	if(tl<=l&&r<=tr)return mn[x];
	int mid=l+r>>1;
	if(tr<=mid)return qry(x<<1,l,mid,tl,tr);
	else if(tl>mid)return qry(x<<1|1,mid+1,r,tl,tr);
	else return min(qry(x<<1,l,mid,tl,tr),qry(x<<1|1,mid+1,r,tl,tr));
}
int main()
{
	scanf("%d",&n);int s=0;
	for(int i=1;i<=n;i++){scanf("%d",&a[i]);s+=(1-a[i]);}
	build(1,0,n);scanf("%d",&m);
	for(int i=1;i<=m;i++)scanf("%d%d",&q[i].l,&q[i].r);
	sort(q+1,q+m+1,cmp);
	for(int i=1,j=1;i<=n;i++)
	{
		for(;q[j].l==i;j++)chg(1,0,n,q[j].r,qry(1,0,n,q[j].l-1,q[j].r));
		chg(1,0,n,i,qry(1,0,n,i-1,i-1)+2*a[i]-1);
	}
	printf("%d\n",s+qry(1,0,n,n,n));
	return 0;
}


Measured memory_bytes: 5120
s=input()
N=len(s)

ans=[0]*N
R={}
L={}
if "L" not in s:
    R[0]=0

if s[0]=="R":
    count_R=1
else:
    count_R=0
count_L=0

if s[0]=="L":
    L[0]=1
  
else:
    L[0]=0

k=0


for i in range(1,N):
    if s[i]=="R" and s[i-1]=="R":
        count_R+=1
    elif s[i]=="L" and s[i-1]=="L":
        count_L+=1
    elif s[i]=="R" and s[i-1]=="L":
        L[k]+=count_L
        count_L=0
        count_R+=1
    else:
        R[i-1]=count_R
        k=i
        L[k]=0
        count_L+=1
        count_R=0
ans[N-1]+=count_R
L[k]+=count_L
if s[0]=="L":
    ans[0]=L[0]

#print(R)
#print(L)

for j in R.keys():
    if j==N-1:
        pass
    elif R[j]%2==1:
        ans[j]+=R[j]//2+1
        ans[j+1]+=R[j]//2
    else:
        ans[j]+=R[j]//2
        ans[j+1]+=R[j]//2

for l in L.keys():
    if l==0:
        pass
    elif L[l]%2==1:
        ans[l]+=L[l]//2+1
        ans[l-1]+=L[l]//2
    else:
        ans[l]+=L[l]//2
        ans[l-1]+=L[l]//2

print(" ".join(map(str,ans)))


Measured memory_bytes: 19704
#include<iostream>
#include<cstring>
using namespace std;
int main(int argc, const char* argv[])
{
	int a;
	cin >> a;
	char A[200];
	char B[200];
	cin >> A;
	cin >> B;
	char C[300];
	for (int i = 0, t = 0; i < 2 * (a - 1) + 1, t < a; i = i + 2, t = t + 1)
	{
		C[i] = A[t];
		C[i + 1] = B[t];
	}
	C[2 * a] = '\0';
	cout << C;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <fstream>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cstring>
#include <cctype>
#include <numeric>
#include <cstdio>
#include <math.h>
#include <functional>
using namespace std;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (i64 i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
#define na(a, n) rep(i, n) cin >> a[i];
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;
}
vb d(10);
int ans(int x)
{
    while (x)
    {
        if (d[x % 10])
            return 0;
        x /= 10;
    }
    return 1;
}
//ここからメイン
int main()
{
 f64 a,b;
  cin >>a>>b;
  cout << (2*b-a);
  }
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {1, 0}, dy = {1, 0};
//cin.tie(0);
//ios::sync_with_stdio(false);

void solve(vector<int> &v)
{
    rep(i, siz(v))
    {
        if (v[i] == 0)
        {
            cout << 'S';
        }
        else
        {
            cout << 'W';
        }
    }
    cout << endl;
    return;
}

signed main()
{
    int n;
    string s;
    cin >> n >> s;

    for (int j = 0; j < 4; j++)
    {
        vector<int> u(n,0);
        u[0] = j % 2;
        u[1] = j / 2;

        for (int i = 1; i < n; i++)
        {
            if ((s.at(i) == 'o' && u[i] == 0) || (s[i] == 'x' && u[i] == 1))
            {
                if(i==n-1 && u[0]!=u[n-2]){
                    goto flag;
                }
                u.at((i+1)%n) = u[i - 1];
            }
            else
            {
                if(i==n-1 && u[0]!=1-u[n-2]){
                    goto flag;
                }
                u.at((i+1)%n) = (1 - u[i - 1]);
            }
        }

        if(u[1]==u[n-1] && ((s[0]=='o'&&u[0]==0) || (s[0]=='x'&&u[0]==1))){
            solve(u);
            return 0;
        }else if(u[1]!=u[n-1] && ((s[0]=='o'&&u[0]==1) || (s[0]=='x'&&u[0]==0))){
            solve(u);
            return 0;
        }
        flag:;
    }

    cout << -1 << endl;
}

Measured memory_bytes: 1016
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int INF = 10e8;
const int maxN = 10010;
const int maxM = 100010;
const int N = 5000; 
const int MOD = 1000000007;


int D,n; 
ll a[maxN];
int b[maxN];
int c[maxN];
int power(int D)
{
	if(D == 0)
	{
		return 1; 
	}
	else if (D == 1)
	{
		return 100;
	}
	else 
	{
		return 10000;
	}
}
int main()
{
	scanf("%d %d",&D,&n);
	int p = power(D);
	int ans = p * n;
	if(n == 100)
	{
		ans += p;
	}
	printf("%d\n",ans);
	return 0;
}  

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[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")
    };
}

fn solve() {
    input! (
        hh: usize,
        ww: usize,
        h: usize,
        w: usize,
    );

    let mut ans = (hh * ww) as i64;
    ans -= (h * ww) as i64;
    ans -= (w * hh) as i64;
    ans += (h * w) as i64;
    println!("{}", ans);
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
// Example program
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int start = 0;
    int end = n-1;
    while(s[start] == '.' and start < n)
    {
    start++;
    if(start == n)
    break;
    }
    while(s[end] == '#' and end >= 0)
    {
        end--;
        if(end == -1)
        break;
    }
    if(start == n or end == -1)
    {
        cout << 0;
    }
    else
    {
        int count1 =0 ;
        int count2 = 0;
        for(int i = start;i<=end;i++)
        {
            if(s[i] == '#')
            count1++;
            else
            count2++;
        }
        int sol = min(count1, count2);
        int hash = 0;
        int dot = 0;
        for(int i = start ;i<=end;i++)
        {
            sol = min(hash + count2, sol);
            if(s[i] == '#')
            count1--;
            else
            count2--;
            if(s[i] == '#')
            hash++;
            else
            dot++;
            
        }
        cout << sol;
        
    }
    return 0;
}


Measured memory_bytes: 640