akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

int main() {
	string S;
	cin >> S;

	int len = S.length();

	int ans = 0;
	int now;
	int pre;//W=-1,B=1
	if (S[0] == 'W') pre = -1;
	else pre = 1;
	REP(i, len) {
		if (S[i] == 'W') now = -1;
		else now = 1;

		if (now * pre == -1) {
			pre = pre * -1;
			ans++;
		}
	}

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

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

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  ll a, b;
  cin >> a >> b;
  cout << (a*b)/__gcd(a, b) << ende;
  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);
    int w = sc.nextInt();
    int h = sc.nextInt();
    int n = sc.nextInt();
    int maxX = w;
    int minX = 0;
    int maxY = h;
    int minY = 0;
    for (int i = 0; i < n; i++) {
      int x = sc.nextInt();
      int y = sc.nextInt();
      int a = sc.nextInt();
      if (a == 1 && x > minX) {
        minX = x;
      } else if (a == 2 && x < maxX) {
        maxX = x;
      } else if (a == 3 && y > minY) {
        minY = y;
      } else if (a == 4 && y < maxY) {
        maxY = y;
      }
    }
    sc.close();

    int result = (maxX - minX) * (maxY - minY);
    if (minX > maxX || maxY < minY) {
      result = 0;
    }
    System.out.println(result);
  }
}


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

int main() {
  int a, b, c;
  cin>>a>>b>>c;
  if (a == b) {
    cout<<c<<endl;
  } else if (c == a) {
    cout<<b<<endl;
  } else {
    cout<<a<<endl;
  }
}

Measured memory_bytes: 256
from collections import deque
n, x, y = map(int, input().split())
g = dict()
for i in range(n):
    if i == 0:
        g[i] = [i+1]
    elif i == n-1:
        g[i] = [i-1]
    else:
        g[i] = [i-1, i+1]
g[x-1].append(y-1)
g[y-1].append(x-1)
# print(g)
distance = [0]*(n-1)
# 1番ノードから各ノードへの最短距離を求めていく.
for i in range(n):
    queue = deque()
    visited = [0]*n
    # まず処理される予定のノードが格納されているqueueに最初のノードを格納する
    queue.append(i)
    while queue:
        target = queue.popleft()
        for j in g[target]:
                if visited[j] == 0 or visited[j] > visited[target] + 1:
                    visited[j] = visited[target] + 1
                    queue.append(j)
    for k in range(len(visited)):
        if k > i:
            if visited[k] >= 1:
                distance[visited[k]-1] += 1
    # print(f"{i}番ノードからの各ノードへの最短距離は{visited}である")
for l in distance:
    print(l)

Measured memory_bytes: 48220
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N;
  cin>>N;
  vector<int>A(N),B(N),C(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  for(int i=0;i<N;i++){
    cin>>B[i];
  }
  for(int i=0;i<N;i++){
    cin>>C[i];
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
  int64_t sum=0;
  for(int i=0;i<N;i++){
   int64_t a=lower_bound(A.begin(),A.end(),B[i])-A.begin();
   int64_t b=upper_bound(C.begin(),C.end(),B[i])-C.begin();
   b=N-b;
   sum+=(a*b);
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 4584
n=int(input())
*a, = map(int,input().split())

seq=[0]*(10**5+3)
for i in range(n):
    l=max(a[i]-1,0)
    r=a[i]+2
    seq[l]+=1
    seq[r]-=1
from itertools import accumulate
seq=list(accumulate(seq))
print(max(seq))

Measured memory_bytes: 60204
n = int(input())
ans = [0] * (n+1)

for x in range(1, 10**2+1):
    for y in range(1, 10**2):
        for z in range(1, 10**2):
            num = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if num <= n:
                ans[num] += 1
            else:
                break

for res in ans[1:n+1]:
    print(res)



Measured memory_bytes: 9456
#include <cstdio>

const int maxn = (1<<15)+1;

int primes[maxn], cnt = 0;
bool not_prime[maxn];

void find_all_primes() {
    for(int i=2;i<maxn;i++)
        if(!not_prime[i]) {
            primes[cnt++] = i;
            for(int j=i+i;j<maxn;j+=i) not_prime[j] = true;
        }
}

int summary[maxn];

void get_all_summary() {
    for(int i=0;i<cnt;i++)
        for(int j=i;j<cnt;j++) {
            int tmp = primes[i] + primes[j];
            if(tmp >= maxn) break;
            summary[tmp] ++;
        }
}

int a;

int main() {
    find_all_primes();
    get_all_summary();
    while(~scanf("%d", &a) && a) {
        printf("%d\n", summary[a]);
    }
    return 0;
}

Measured memory_bytes: 1208
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]float64, n)
	ret := 0.0
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		ret += 1.0 / a[i]
	}
	fmt.Println(1.0 / ret)
}


Measured memory_bytes: 512
use std::io;
use std::cmp;


fn main() {
    let n = read_one::<usize>();
    let an = read::<i64>();
    let mut ans = ::std::usize::MAX;

    for j in 0..2 {
        let mut step: i64 = 0;
        let mut cumsum = 0;
        for i in 0..n {
            cumsum += an[i];
            if (i + j) % 2 == 0 { // minus
                if cumsum >= 0 {
                    step += cumsum + 1;
                    cumsum = -1;
                }
            } else { // plus
                if cumsum <= 0 {
                    step += 1 - cumsum;
                    cumsum = 1;
                }
            }
        }
        ans = cmp::min(ans, step as usize);
    }
    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 6396
package main

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

func parent(i int) int {
	return i / 2
}
func left(i int) int {
	return i * 2
}
func right(i int) int {
	return i*2 + 1
}

func maxHeapify(A []int, H int, i int) {
	l := left(i)
	r := right(i)

	var largest int
	if l <= H && A[l] > A[i] {
		largest = l
	} else {
		largest = i
	}
	if r <= H && A[r] > A[largest] {
		largest = r
	}

	if largest != i {
		tmp := A[i]
		A[i] = A[largest]
		A[largest] = tmp
		maxHeapify(A, H, largest)
	}
}

func buildMaxHeap(A []int, H int) {
	for i := H / 2; i >= 1; i-- {
		maxHeapify(A, H, i)
	}
}

func main() {
	var H int
	_, _ = fmt.Scanf("%d", &H)

	A := make([]int, H+1)

	r := bufio.NewReader(os.Stdin)
	for i := 1; i <= H; i++ {
		_, _ = fmt.Fscanf(r, "%d", &A[i])
	}

	buildMaxHeap(A, H)

	w := bufio.NewWriter(os.Stdout)
	for i := 1; i <= H; i++ {
		_, _ = fmt.Fprintf(w, " %d", A[i])
	}
	w.Flush()
	_, _ = fmt.Printf("\n")
}



Measured memory_bytes: 10088
program rainy_season
character(3) :: s
read *, s
if(s == "RRS" .or. s == "SRR")then
print *, 2
else if(s == "RRR")then
print *, 3
else if(s == "SSR" .or. s == "SRS" .or. s == "RSS" .or. s == "RSR")then
print *, 1
else
print *, 0
end if
end program 

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

int main()
{
    int d, n, res;

    cin >> d >> n;

    if(!d)
    {
        if(n == 100)
            n++;
        cout << n << endl;

    }
    else
    {
        if(d == 1)
            res = 100;
        else
            res = 10000;
        if(n == 100)
            n++;
        cout << res * n << endl;

    }





}


Measured memory_bytes: 256
import collections

n = int(input())
list1 = list(map(int,input().split()))
list2 = collections.Counter(list1)

kei1=0

for j in list2.values():
    kei1 += j * (j-1) // 2

for x in list1:
    print(kei1 - (list2[x] -1))

Measured memory_bytes: 87756
#include <iostream>
#include <stdio.h>
#define LL long long

using namespace std;

LL a[105];

LL gcd(LL x,LL y)
{
    if(x<y) swap(x,y);
    return y==0?x:gcd(y,x%y);
}

LL solve(int n)
{
    LL ans=a[0];
    for(int i=1;i<n;++i)
    {
 //       printf("--%lld\n",gcd(ans,a[i]));
        ans=ans/gcd(ans,a[i])*a[i];
    }
    return ans;
}

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        for(int i=0;i<n;++i)
            scanf("%lld",&a[i]);
        printf("%lld\n",solve(n));
    }
    return 0;
}



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

/* 三値論理の否定を計算する */
int tnot(int a) {
	return 2 - a;
}
/* 三値論理の積を計算する */
int tand(int a, int b) {
	return a < b ? a : b;
}
/* 三値論理の和を計算する */
int tor(int a, int b) {
	return a > b ? a : b;
}

/* 三値論理の式を計算する */
#define SIGN_NOT 3
#define SIGN_AND 4
#define SIGN_OR 5
#define SIGN_LEFT_PAREN 6
#define SIGN_RIGHT_PAREN 7
int calculate(const char *formula, int n, int p, int q, int r) {
	int stack[81];
	int size = 0;
	int i;

	for (i = 0; i < n; i++) {
		/* 式を1文字読む */
		switch (formula[i]) {
			case '-': stack[size] = SIGN_NOT; break;
			case '*': stack[size] = SIGN_AND; break;
			case '+': stack[size] = SIGN_OR; break;
			case '(': stack[size] = SIGN_LEFT_PAREN; break;
			case ')': stack[size] = SIGN_RIGHT_PAREN; break;
			case 'P': stack[size] = p; break;
			case 'Q': stack[size] = q; break;
			case 'R': stack[size] = r; break;
			default: stack[size] = formula[i] - '0'; /* 値 */
		}
		size++;

		/* 構文に一致する箇所がなくなるまで処理する */
		int b = 1;
		while (b) {
			b = 0;
			/* 構文に一致する箇所を計算する */
			if (size >= 2 && stack[size-2] == SIGN_NOT && (stack[size-1] >= 0 && stack[size-1] <= 2)) {
				/* 否定 */
				stack[size-2] = tnot(stack[size-1]);
				size--;
				b = 1;
			} else if (size >= 5 && stack[size-5] == SIGN_LEFT_PAREN  && stack[size-1] == SIGN_RIGHT_PAREN) {
				if (stack[size-3] == SIGN_AND) {
					/* 論理積 */
					stack[size-5] = tand(stack[size-4], stack[size-2]);
					size -= 4;
					b = 1;
				} else if (stack[size-3] == SIGN_OR) {
					/* 論理和 */
					stack[size-5] = tor(stack[size-4], stack[size-2]);
					size -= 4;
					b = 1;
				}
			}
		}
	}

	return stack[0];
}

int main(void) {
	char s[81];
	int i, l, n;

	/* データセット毎の処理 */
	while (scanf("%s", s) == 1 && s[0] != '.') {
		l = strlen(s); /* 式の長さ */
		n = 0;
		/* (P,Q,R) を総当たりで調べ計算結果が 2 となる場合の数を数える */
		for (i = 0; i < 3 * 3 * 3; i++) {
			if (calculate(s, l, (i / 3 / 3) % 3, (i / 3) % 3, i % 3) == 2) n++;
		}
		printf("%d\n", n);
	}

	return 0;
}

Measured memory_bytes: 536
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
using namespace std;

int main() {

    int n, k;
    cin >> n >> k;

    int a;
    vector<int> tmp(n);

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

        cin >> a;
        tmp[a] ++;
    }

    sort(tmp.begin(), tmp.end(), greater<int>());

    int ans = n;

    for (int i = 0; i < k; i++) {
        ans -= tmp[i];
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main () {
  string S;
  cin >> S;
  bool visited[26];
  fill(visited, visited+26, false);
  for (auto x : S) {
    visited[x - 'a'] = true;
  }
  for (auto i = 0; i < 26; ++i) {
    if (!visited[i]) {
      cout << (char) (i + 'a') << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main () {
    int k, s;
    int ans = 0;
    int sum;
    cin >> k >> s;

    for(int i = 0; i <= k; i++) {
        if (s > (i + 2 * k)) {
            continue;
        }
        for (int j = i; j <= k; j++) {
            if (s > (i + j + k)) {
                continue;
            }
            for (int l = j; l <= k; l++) {
                sum = i + j + l;
                if (sum > s) {
                    break;
                }
                if (sum == s) {
                    if (i == j && j == l) {
                        ans++;
                    }
                    else if (i == j || j == l || l == i) {
                        ans += 3;
                    }
                    else {
                        ans += 6;
                    }
                }
            }
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    let one_time = 100 * (n - m) + 1900 * m;
    let total = one_time << m;
    println!("{}", total);
}


Measured memory_bytes: 4352
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        if (n[0] == n[1]) {
            System.out.println(2 * n[0]);
        } else {
            System.out.println(2 * Math.max(n[0], n[1]) - 1);
        }

    }

}

Measured memory_bytes: 27220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    ll n; cin>>n;
    ll d,x; cin>>d>>x;
    ll res=x;
    rep(i,n){
        ll a; cin>>a;
        res++;
        res+=(d-1)/a;
    }
    cout<<res<<endl;
    return 0;
}

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

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

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

fn main() {
    input! {
        s:chars,
        t:chars
    }

    let mut dp = vec_md![0u64;s.len()+1;t.len()+1];
    let mut prev = vec_md![None;s.len()+1;t.len()+1];
    for i in 0..dp.len() {
        for j in 0..dp[0].len() {
            if i+1<dp.len() && j+1<dp[0].len() && s[i]==t[j] {
                dp[i+1][j+1] = dp[i][j] + 1;
                prev[i+1][j+1] = Some((i,j)); 
            }
            if i+1<dp.len() && chmax!(dp[i+1][j], dp[i][j]) {
                prev[i+1][j] = Some((i,j));
            }
            if j+1<dp[0].len() && chmax!(dp[i][j+1], dp[i][j]) {
                prev[i][j+1] = Some((i,j));
            }
        }
    }
    let mut y = s.len();
    let mut x = t.len();
    let mut ret = vec![];
    while let Some((py,px)) = prev[y][x] {
        if py+1==y && px+1==x {
            ret.push(s[py]);
        }
        y = py;
        x = px;
    }
    ret.reverse();
    println!("{}", ret .iter().cloned().collect::<String>());

}


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

using System.Text;
using System.Threading.Tasks;

using System.Globalization;

namespace AtCoder
{
    class Program
    {
        public static void Main()
        {
            string[] str = Console.ReadLine().Split(' ');
            double N = double.Parse(str[0]);
            double K = double.Parse(str[1]);
            double ans = 0;
            double i = 30;

            while(i >= 0)
            {
                if(N >= Math.Pow(K,i))
                {
                    ans = i;
                    ans++;
                    break;
                }

                i--;
            }
            Console.WriteLine("{0}", ans);
        }   
    }
}

Measured memory_bytes: 13268
n, m = map(int, input().split())
N = 1010
ans = [0] * (N +1)
g = [[] for _ in range(N)]

for _ in range(m):
    a, b = map(int, input().split())
    g[a].append(b)

#n, m = 6, 9
#g = [[], [2],[3],[4], [5], [1,6,2],[1,2]]
def minCircle(s):
    f = [0] * N
    d = [0]* N
    q = []
    q.append(s)
    while q:
        p = q.pop()
        for c in g[p]:
            if not d[c]:
                f[c] = p
                d[c] = 1
                q.append(c)
        if d[s]:
            break
    p = f[s]
    ret = []
    ret.append(s)
    while p and p!= s:
        ret.append(p)
        p = f[p]
    return ret

for i in range(1, n+1):
    t = minCircle(i)
    if len(t) > 1 and len(t) < len(ans):
        ans = t
if len(ans) == N+1:
    print(-1)
else:
    print(len(ans))
    for i in ans:
        print(i)

Measured memory_bytes: 46696
import sys
input = sys.stdin.readline

MAX = 10**5+1

n = int(input())
b = list(map(int, input().split()))

b_new = [MAX]
b_new.extend(b)
b_new.append(MAX)

a = []
for i in range(n):
    a.append(min(b_new[i], b_new[i+1]))

print(sum(a))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int main(){
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<int64_t> r(a),g(b),m(c);
    rep(i,a){
        cin>>r[i];
    }
    rep(i,b){
        cin>>g[i];
    }
    rep(i,c){
        cin>>m[i];
    }
    all(r);
    all(g);
    all(m);
    Re(r);
    Re(g);
    vector<int64_t> ans;
    rep(i,x){
        ans.push_back(r[i]);
    }
    rep(i,y){
        ans.push_back(g[i]);
    }
    rep(i,c){
        ans.push_back(m[i]);
    }
    all(ans);
    Re(ans);
    int64_t sum=0;
    rep(i,x+y){
        sum += ans[i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 8560
def resolve():
	nums = list(map(int, input().split()))
	k = int(input())
	ans = 0
	for i in range(k):
		m = 0
		for j in range(1, 3):
			if nums[m] < nums[j]:
				m = j
		nums[m] *= 2
	print(sum(nums))
resolve()

Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>

#define ll long long

using namespace std;

int main(){
    int N,K;
    cin >> N >> K;
    int a;
    int b,c;
    if(K%2==0){
        a = N/(K/2);
        if(a%2==0){
            b = a/2;
            c = b;
        }
        else{
            b = a/2;
            c = b+1;
        }
    }
    else{
        a = N/K;
    }
    if(K%2==1){
        cout << (ll)pow(a,3) << endl;
    }
    else{
        cout << (ll)pow(b,3)+(ll)pow(c,3) << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
int sum=0;
int main() {
   int n;
   cin>>n;
   vector<int> a(n);
   for(int i=0;i<n;i++) cin>>a.at(i);
   sort(a.begin(),a.end());
   cout<<a.at(n-1)-a.at(0)<<endl;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

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

const int infI=1e9+5;
const long long infL=1e16;
const int MOD=1e9+7;
const int MAX=2e5+5;

#define mp make_pair
#define in &
#define pb push_back
#define ii pair<int,int>
#define iii pair<ii,int>
#define ll long long
#define pll pair<ll,ll>
#define vvl vector<vector<ll> >
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define eb emplace_back
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define popb pop_back()
#define se second
#define fi first
#define test(t) int t;cin>>t;while(t--)
#define debug(x) cerr<<"=>"<<#x<<" = "<<x<<endl

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    if(b==1){
        return a;
    }
    ll temp=power(a,b/2);
    temp=(temp*temp)%MOD;
    if(b%2){
        temp=(temp*a)%MOD;
    }
    return temp;
}

//only use if mod is prime
ll mod_inv(ll a,ll mod){
    a%=mod;
    return power(a,mod-2);
}

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

//TLE can also occur if vectors are not passed by reference
//priority_queue implements max heap by default

ll f[MAX],inv_f[MAX],mul[MAX];

ll ncr(ll a,ll b){
    assert(a>=b);
    if(b<0){
        return 0;
    }
    ll ans = (f[a]*inv_f[b])%MOD;
    ans = (ans*inv_f[a-b])%MOD;
    return ans;
}

int main(){
    fastio;
    int n,k;
    f[0]=1;
    forn(i,1,MAX){
        f[i] = (i*f[i-1])%MOD;
    }
    inv_f[MAX-1] = mod_inv(f[MAX-1],MOD);
    for(int i = MAX-1;i>0;--i){
        inv_f[i-1] = (i*inv_f[i])%MOD;
    }
    cin>>n>>k;
    vl a(n);
    for(auto &x:a){
        cin>>x;
    }
    if(k==1){
        cout<<0;
        return 0;
    }
    forn(i,k-2,MAX){
        mul[i] = ncr(i,k-2);
        if(i){
            mul[i] = (mul[i]+mul[i-1])%MOD;
        }
    }
    sort(a.begin(),a.end());
    ll ans = 0;
    for(int i = n-1;i>=k-1;--i){
        ans = (ans + ((ncr(i,k-1)*a[i])%MOD))%MOD;
        // for(int j = i-k+1;j>=0;--j){
        //     ans = (ans + MOD - ((ncr(i-j-1,k-2)*a[j])%MOD))%MOD;
        // }
    }
    for(int i = n-2,j=0;i>=0 and j<=n-k;--i,j++){
        ans = (ans + MOD - ((a[j]*mul[i])%MOD))%MOD;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
         int x=0 ,max=0;
	scanf("%d",&n);
	char s[n];
	for(int i=0 ;i<n;){
	 cin>>s[i];
	 if(s[i]=='I') {
	 	++x;
	 	++i;
	 	
	 }
	 else if(s[i] =='D'){
	 	--x;
     	++i;
	 }
	 if(x>max)
	 max=x;
	}
	printf("%d",max);
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n,i,j,k,temp;
	int max,min;
	int base;
	int num[9];
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
	{
		for(j=0;j<8;j++) scanf("%1d",&num[j]);
		for(j=0;j<8;j++)
		{
			for(k=j+1;k<8;k++)
			{
				if(num[j]<num[k])
				{
					temp = num[j];
					num[j] = num[k];
					num[k] = temp;
				}
			}
		}
		max = 0;
		min = 0;
		base = 1;
		for(j=0;j<8;j++)
		{
			min+=base*num[j];
			base*=10;
		}
		base = 1;
		for(j=7;j>=0;j--)
		{
			max+=base*num[j];
			base*=10;
		}
		printf("%d\n",max-min);
	}
	return 0;
}

Measured memory_bytes: 596
<?php

$antennas = [];
for ($i = 0; $i < 5; ++$i) {
    $antennas[] = trim(fgets(STDIN));
}

fscanf(STDIN, "%d", $k);

$result = true;
for ($i = 0; $i < 4; ++$i) {
    for ($j = $i + 1; $j < 5; ++$j) {

        if ($antennas[$j] - $antennas[$i] > $k) {
            $result = false;
            break;
        }
    }
}
echo $result ? 'Yay!' : ':(';


Measured memory_bytes: 4728
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
  int A, B, C, K;
  cin >> A >> B >> C >> K;

  int array[10];
  array[0] = A;
  array[1] = B;
  array[2] = C;

  sort(array, array + 3, greater<int>());

  int ans = array[0];
  for (int i = 1; i <= K; i++) {
    ans = ans * 2;
  }

  cout << ans + array[1] + array[2] << endl;
}

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

int A;
int B;
int C;
int D;
int ans;

void solve() {
  ans = min(A, B) + min(C, D);
  cout << ans << endl;
}

int main() {
  cin >> A;
  cin >> B;
  cin >> C;
  cin >> D;
  solve();
}

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

using namespace std ;

const int inf = 1e9 ;
const int MAX = 2e5 + 10 ;

int arr[MAX] , last[MAX] , L[MAX] , R[MAX] , nxt[MAX] , dist[MAX] , ans[MAX] ;
int n , m ;

vector< pair<int , int> >pref[MAX] ;

void dijkstra()
{
	for(int i = 0 ; i <= n ; ++i)
		dist[i] = inf , ans[i] = inf ;
	for(int i = 0 ; i < m ; ++i)
	{
		if(R[last[i]] != m)
			dist[last[i]] = min(dist[last[i]] , last[i] + R[last[i]]+1 - i) ;
	}
	priority_queue< pair<int , int> , vector< pair<int , int> > , greater< pair<int , int> > >q ;
	for(int i = 1 ; i <= n ; ++i)
	{
		if(R[i] != m && dist[i] != inf)
			q.push({dist[i] , i}) ;
	}
	while(!q.empty())
	{
		pair<int , int>p = q.top() ;
		q.pop() ;
		int node = p.second , cost = p.first ;
		if(cost > dist[node])
			continue ;
		if(nxt[node] == n || R[nxt[node]] == m)
			continue ;
		int to = nxt[node] , cost2 = cost + nxt[node] - node + R[nxt[node]] - R[node] ;
		if(cost2 < dist[to])
		{
			dist[to] = cost2 ;
			q.push({dist[to] , to}) ;
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>m ;
	for(int i = 0 ; i < n ; ++i)
	{
		cin>>L[i]>>R[i] ;
		pref[L[i]].emplace_back(1 , i) ;
		pref[R[i]+1].emplace_back(-1 , i) ;
	}
	set<int>s ;
	int Max = 0 ;
	for(int i = 1 ; i <= m ; ++i)
	{
		for(auto &j : pref[i])
		{
			if(j.first == 1)
				s.insert(j.second) ;
			else
				s.erase(j.second) ;
		}
		for(auto &j : pref[i])
		{
			if(j.first == -1)
			{
				if(s.lower_bound(j.second) == s.end())
					nxt[j.second] = n ;
				else
					nxt[j.second] = *s.lower_bound(j.second) ;
			}
		}
		if(!s.size())
			last[i] = n ;
		else
			last[i] = *s.begin() ;
		Max = max(Max , last[i]) ;
	}
	dijkstra() ;
	for(int i = 0 ; i <= m+1 ; ++i)
		pref[i].clear() ;
	for(int i = 0 ; i < n ; ++i)
	{
		if(R[i] == m)
			continue ;
		pref[i].emplace_back(1 , dist[i] - i) ;
		pref[nxt[i]+1].emplace_back(-1 , dist[i] - i) ;
	}
	multiset<int>s2 ;
	for(int i = 0 ; i <= n ; ++i)
	{
		for(auto &j : pref[i])
		{
			if(j.first == 1)
				s2.insert(j.second) ;
			else
				s2.erase(s2.find(j.second)) ;
		}
		if(!s2.size())
			ans[i] = inf ;
		else
			ans[i] = *s2.begin() + i ;
	}
	for(int i = 1 ; i <= Max ; ++i)
		cout<<i<<"\n" ;
	for(int i = Max+1 ; i <= n ; ++i)
	{
		if(ans[i] >= inf)
			ans[i] = -1 ;
		cout<<ans[i]<<"\n" ;
	}
	return 0 ;
}		

Measured memory_bytes: 23460
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

pub fn divisor(n: u64) -> Vec<u64> {
    let mut res = Vec::new();
    for i in (1..).take_while(|x| x * x <= n) {
        if n % i == 0 {
            res.push(i);
            if i != n / i {
                res.push(n / i);
            }
        }
    }
    res
}

fn main() {
    input! {
        a: i64,
        b: i64,
        x: i64,
    }
    fn f(n: i64, x: i64) -> i64 {
        if n == -1 { 0 }
        else { n / x + 1 }
    }
    println!("{}", f(b, x) - f(a-1, x));
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void warshall_floyd(Graph &graph) {
    int V = graph.size();
    for (int k = 0; k < V; ++k) {
        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < V; ++j) {
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }
}

void solve() {
    ll N, M, L;
    cin >> N >> M >> L;
    Graph graph(N, vector<ll>(N, INF));
    rep(i, M) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        graph[a][b] = c;
        graph[b][a] = c;
    }
    rep(i, N) graph[i][i] = 0;
    warshall_floyd(graph);
    Graph graph1(N, vector<ll>(N, INF));
    rep(i, N) {
        rep(j, N) {
            if (i == j) graph[i][i] = 0;
            if (graph[i][j] <= L) {
                graph1[i][j] = 1;
            }
        }
    }
    warshall_floyd(graph1);
    ll Q;
    cin >> Q;
    rep(q, Q) {
        ll s, t;
        cin >> s >> t;
        s--;
        t--;
        ll ans = graph1[s][t];
        if (ans < INF) {
            cout << ans - 1<< '\n';
        } else {
            cout << -1 << '\n';
        }
    }

}

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


Measured memory_bytes: 1920
import java.util.*;
 
public class Main{
  public static int[] dp;
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String[] s = sc.nextLine().split(" ");
    int N = Integer.parseInt(s[0]);
    int K = Integer.parseInt(s[1])-1;
    String S = sc.nextLine();
    String str = "";
    if(S.charAt(K) == 'A'){
      str = "a";
    }else if(S.charAt(K) == 'B'){
      str = "b";
    }else{
      str = "c";
    }
    
    String ans = S.substring(0, K) + str + S.substring(K+1, N);

    System.out.println(ans);
  }
}

Measured memory_bytes: 23124
import math

N = int(input())
A = list(map(int, input().split()))

Sum = 0
mod = (10 ** 9) + 7

for i in range(len(bin(max(A)))-2):
    Sum_1 = 0
    for j in range(N):
        #print(i, j)
        if ((A[j] >> i) & 1):
            Sum_1 += 1

    Sum_0 = N - Sum_1

    Sum = (Sum + ((Sum_0 * Sum_1) % mod * (2 ** i)) % mod) % mod
    # print(Sum_0,Sum_1)

print(Sum)


Measured memory_bytes: 124664
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    int sum=0;
for(int i=1;i<=2;i++){
    if(a>=b){
        sum=sum+a;
        a=a-1;


    }
    else{

        sum=sum+b;
        b=b-1;

    }
}
cout<<sum<<endl;


}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int mod = 2019;

int cnt[2020];
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s;
    cin >> s;
    int n = s.size();
    vector<int> a(n);
    vector<ll> b(n+1);
    int digit = 1;
    for(int i=n-1;i>=0;i--){
        int c = s[i] - '0';
        a[i] = c * digit;
        a[i] %= mod;
        digit *= 10;
        digit %= mod;
    }
    cnt[0] ++;
    for(int i=n-1;i>=0;i--){
        b[i] = b[i+1] + a[i];
        b[i] %= mod;
        cnt[b[i]]++;
    }
    ll ans = 0;
    for(int i=0;i<=2019;i++){
        ans += cnt[i]*(cnt[i]-1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5872
i,j,n,x,y,a,b,map[30][30];
main()
{
  char c,t;
  for(;scanf("%d",&n),n;puts(n?"No":"Yes"))
    {
      for(i=0;i<30;i++)
	for(j=0;j<30;j++)
	  map[i][j]=0;
      for(j=n;j--;map[x][y]=1)
	  scanf("%d%d",&x,&y);
      scanf("%d",&j);
      getchar();
      for(a=b=10;j--;)
	{
	  i=c=0;
	  while((t=getchar())!='\n')
	    if(t>='0' &&t<='9')
	      i=i*10+t-'0';
	    else if(t>'A' && t<'Z')
	      c=t;
	  for(;i--;)
	    {
	      if(c=='N')
		b++;
	      if(c=='E')
		a++;
	      if(c=='S')
		b--;
	      c-'W'||a--;
	      if(map[a][b]==1)
		  map[a][b]=0,n--;
	    }
	}
    }
  exit(0);
}

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

void MAIN() {
    int n, k;
    scanf("%d%d", &n, &k);
    std::vector<bool> baned(10);
    for(int i = 0; i < k; ++ i) {
        int tmp;
        scanf("%d", &tmp);
        baned[tmp] = true;
    }
    while(true) {
        bool flag = true;
        int tmp = n;
        while(tmp != 0) {
            if(baned[tmp %10]) {
                flag = false;
                break;
            }
            tmp /= 10;
        }
        if(flag) {
            printf("%d\n", n);
            return ;
        }
        ++ n;
    }
}

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


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
  public static void main(String args[])throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    // String [][] dic = new String[n][2];
    Set<String> dic = new HashSet<>();
    String str[] =new String[2];
    int j;
    for(int i = 0; i<n; i++){
      str = br.readLine().split("\\s+");
      if(str[0].charAt(0)=='i'){
        dic.add(str[1]);
      }else{

        if(dic.contains(str[1])){
          System.out.println("yes");
        }else{
          System.out.println("no");
        }
      }
    }
  }
}


Measured memory_bytes: 339072
#include <string>
#include <iostream>
#include <cstring>
#include <list>
int main () {
  std::list<char> buffer;
  int reverse = 0;
  std::string s;
  std::cin>>s;
  for (int i = 0 ; i < s.length() ; ++i ) {
    buffer.push_back(s[i]);
  }
  int Q;
  std::cin>>Q;

  for (int i = 0 ; i < Q ; ++i ) {
    int T;
    std::cin>>T;
    if (T == 1 ) {
      reverse = 1 - reverse;
    }
    else {
      int F;
      char C;
      std::cin>>F>>C;
      if ((F == 1 && reverse == 0) ||
          (F == 2 && reverse == 1) ) {
        buffer.push_front(C);
      }
      else {
        buffer.push_back(C);

      }
    }
  }

  if ( reverse == 0 ) {
    for (auto iter = buffer.begin() ; iter != buffer.end() ; ++iter ) {
      std::cout<<*iter;
    }
  }
  else {
    for (auto iter = buffer.rbegin() ; iter != buffer.rend() ; ++iter ) {
      std::cout<<*iter;
    }
  }

  return 0;
}

Measured memory_bytes: 9984
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
	long long a,b,c,k;
    
    cin >> a >> b >> c >> k;
    
    long long ans;
    ans = min(k,a);
    k = max(k-(a+b), 0LL);
    ans -= k;
    
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")
#define pb(s) push_back(s)
#define SZ(x) ((int)(x).size())

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

vector<ll> Zalgo(const string &S) {
    int N = (int)S.size();
    VI res(N);
    res[0] = N;
    int i = 1, j = 0;
    while (i < N) {
        while (i+j < N && S[j] == S[i+j]) ++j;
        res[i] = j;
        if (j == 0) {++i; continue;}
        int k = 1;
        while (i+k < N && k+res[k] < j) res[i+k] = res[k], ++k;
        i += k, j -= k;
    }
    return res;
}

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

    // input
    ll N; cin >> N;
    string s; cin >> s;

    ll ma = 0;
    rep(i, N){
      string t = s.substr(i);
      auto z = Zalgo(t);
      rep(j, t.size()){
        ll lcp = z[j];
        lcp = min(lcp, j-0);
        chmax(ma, lcp);
      }
    }

    p(ma);

    return 0;
}



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

int main(){
  int N;
  cin >>N;
  vector<int> a(N);
  for(int i=0; i<N; i++)
    cin >>a.at(i);
  sort (a.begin(), a.end());
  reverse (a.begin(), a.end());
  int A=0,B=0;
  for(int i=0; i<N; i++){
    if(i%2==0)
      A+=a.at(i);
    if(i%2==1)
      B+=a.at(i);
  }
  cout<<A-B<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#include<numeric>
#define rep(a,b) for(ll a=0;a<b;++a)
#define REP(a,b,c,d) for(ll a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	string S; cin >> S;
	int ans = 0, num = 0;
	rep(i, S.size()) {
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T')++num;
		else num = 0;
		ans = max(ans, num);
	}
	cout << ans << endl;
	cin >> S;
}

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

int main() {
	int a,o=0;
	cin >> a;
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <100; j++) {
			if (i * 4 + j * 7 == a)o++;
		}
	}
	if (o == 0)cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  string s,t; cin >> s >>t;
  bool ans= true;
  for(int i=0;i<s.size();i++){
    if(s.at(i)!=t.at(i)) ans = false;
  }

  if(ans) puts("Yes");
  else puts("No");

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define endl "\n"
#define PI 3.141592653589793
using namespace std;


int main()
{
    FAST
    int n;cin>>n;
    int a[n];f(i,0,n) cin>>a[i];
    sort(a,a+n);
    map<int,int> m;
    int ans=0;
    if(n==1)
    {
        cout<<1;
        return 0;
    }
    if(n>1 && a[0]!=a[1]) ans++;
    m[a[0]]++;
    f(i,1,n)
    {
        int f=0;
        for(int j=1;j*j<=a[i];j++)
        {
            if(a[i]%j==0)
            {
                if(m[j] || m[a[i]/j])
                {
                    f=1;
                    break;
                }
            }
        }
        if(!f && i<n-1 && a[i]!=a[i+1]) ans++;
        if(i==n-1 && !f) ans++;
        m[a[i]]++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 33304
#include<bits/stdc++.h>
#define ll long long int
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_orde(ind)
using namespace std;
ll cnt[1000000],prnt[1000000];
ll root(ll n)
{
	if(prnt[n]==n)
	return n;
	return prnt[n]=root(prnt[n]);
}
ll unify(ll x,ll y)
{
	ll px=root(x);
	ll py=root(y);
	ll sum=cnt[px]*cnt[py];
	if(px==py)
	return (ll)0;
	else if(cnt[px]>cnt[py])
	{
		cnt[px]+=cnt[py];
		prnt[py]=px;
	}
	else
	{
		cnt[py]+=cnt[px];
		prnt[px]=py;
	}
	//cout<<x<<" "<<px<<" "<<y<<" "<<py<<" "<<" "<<cnt[px]<<" "<<cnt[py]<<" "<<cnt[px]*cnt[py]<<" "<<sum<<endl;
	return sum;
}
int main()
{
	sync;
	ll n,m;
	cin>>n>>m;
	vector<pair<ll,ll> >v;
	for(ll i=1;i<=n;i++)
	{
		prnt[i]=i;
		cnt[i]=1;
	}
	for(ll i=0;i<m;i++)
	{
		ll x,y;
		cin>>x>>y;
		vmp(v,x,y);
	}
	reverse(v.begin(),v.end());
	ll tot=(n*(n-1))/2;
	vector<ll>ans;
	for(ll i=0;i<m;i++)
	{
	ans.push_back(tot);	
	tot-=unify(v[i].f,v[i].s);
	}
	for(ll i=m-1;i>=0;i--)
	cout<<ans[i]<<" ";
}
	
	


Measured memory_bytes: 9584
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<pair<int, bool>> A(N);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        A.at(i) = make_pair(--a, false);
    }
    
    int ans = 0;
    int next = A.at(0).first;
    while (1) {
        if (next == 1) {
            ans++;
            break;
        } else if (A.at(next).second == true) {
            ans = -1;
            break;
        } else{
            A.at(next).second = true;
            next = A.at(next).first;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
#include<functional>
using namespace std;
string s;
long long a[15][15];
long long a1[15];
long long ans;
int main()
{
	cin>>s;
	a[0][0]=(long long)1;
	a[0][1]=(long long)1;
	for(int i=2;i<s.size();i++)
		a[0][i]=a[0][i-1]*2;
	for(int i=1;i<s.size();i++)
	{
		a[i][i]=a[i-1][i-1]+a[i-1][i];
		for(int j=i+1;j<s.size();j++)
			a[i][j]=a[i-1][j];
	}
	a1[s.size()-1]=(long long)1;
	for(int i=s.size()-2;i>=0;i--)
		a1[i]=a1[i+1]*10;
	for(int i=0;i<s.size();i++)
	{
		long long ans1=0;
		for(int j=0;j<s.size();j++)
			ans1+=a1[j]*a[i][j];
		ans1*=s[i]-'0';
		ans+=ans1;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<ll> a(n),sum(n+1,0);
	rep(i,n){
		cin>>a[i];
		sum[i+1]=sum[i]+a[i];
	}
	map<ll,ll> mp;
	ll ans=0;
	rep(i,n+1){
		ans+=mp[sum[i]];
		mp[sum[i]]++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 15872
x,y = map(int,input().split())
ans = 0
if x == 1:
    ans += 300000
    if y == 1:
        ans += 400000
elif x == 2:
    ans += 200000
elif x == 3:
    ans += 100000
if y == 1:
    ans += 300000
elif y == 2:
    ans += 200000
elif y == 3:
    ans += 100000

print(ans)


Measured memory_bytes: 3316