akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}


use std::fmt::Display;
pub fn print_vec<T: Display>(v: &Vec<T>, prefix: &str, suffix: &str) {
    if v.is_empty() {
        println!("[]");
        return;
    }
    print!("{}", prefix);
    print!("{}", v[0]);
    for i in 1..v.len() {
        print!(" {}", v[i]);
    }
    println!("{}", suffix);
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (s, ) = input!(String);

    let mut ans = vec![0; s.len()];

    let mut r_count = 0;
    let mut l_count = 0;

    let mut boundary_index = 0;

    for (i, c) in s.char_indices() {
        if c == 'R' {
            // print!("{} R l_count = {}, r_count = {}, boudary = {} : ", i, l_count, r_count, boundary_index);
            // print_vec(&ans, "[", "]");
            if l_count > 0 {
                ans[boundary_index] += (l_count / 2) + (l_count % 2);
                ans[boundary_index - 1] += l_count / 2;
                r_count = 1;
                l_count = 0;
            } else {
                r_count += 1;
            }
        } else {
            // print!("{} L l_count = {}, r_count = {}, boudary = {} : ", i, l_count, r_count, boundary_index);
            // print_vec(&ans, "[", "]");
            if r_count > 0 {
                ans[i - 1] += (r_count / 2) + (r_count % 2);
                ans[i] += r_count / 2;
                boundary_index = i;
                r_count = 0;
                l_count = 1;
            } else {
                l_count += 1;
            }
        }
    }

    ans[boundary_index] += (l_count / 2) + (l_count % 2);
    ans[boundary_index - 1] += l_count / 2;

    print_vec(&ans, "", "");
}

fn main() {
    solve();
}


Measured memory_bytes: 4476
use std::cmp::min;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

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

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

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

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

fn main(){
    input!{
        d:usize,
        g:i64,
        v:[(i64,i64);d],
    }
    let mut ans = std::i64::MAX;
    for bit in (0..1<<d) {
        let mut count = 0;
        let mut value_count = 0;
        for j in 0..d as i64 {
            if bit & (1 << j) != 0 {
                count += v[j as  usize].0;
                value_count += (j+1) * 100 * v[j as usize].0 + v[j as usize].1;
            }
        }
        if value_count >= g {
            ans = min(ans,count);
            continue;
        }
        let best = (0,0);
        for j in (0..d as i64).rev() {
            if bit & (1<<j) != 0 {
                continue;
            }

            if value_count + (j+1) * 100 * v[j as usize].0 >= g {
                let u = (g- value_count + (j + 1) * 100 - 1)/((j + 1) * 100);
                count += u;
                break;
            }
            count += v[j as usize].0;
            value_count += (j + 1) * 100 * v[j as usize].0;
        }
        ans = min(ans,count);
    }
    println!("{}",ans);
}

Measured memory_bytes: 4352
<?php
	while (true) {
		$n = trim(fgets(STDIN));
		if ($n == 0) break;

		$s = explode(" ", trim(fgets(STDIN)));
		$m = array_sum($s) / $n;
		$a2 = 0;
		for ($i = 0; $i < $n; $i++) {
			$a2 += pow(($s[$i] - $m), 2);
		}
		echo sqrt($a2 / $n) . "\n";
	}

Measured memory_bytes: 6976
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}



int main() {
	string x, y,z; cin >> x >> y;
	vector<string> a, b;
	for (int i = 0; i < y.length(); i++) {
		z += x.at(i);
		z += y.at(i);
	}
	if (x.length() - y.length() == 1) z += x.back();


	cout << z;

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int element;
  for(int i=0;i<n;i++)
  {
    cin>>element;
    if(element%2==0)
    {
      if(!((element%3==0)||(element%5==0)))
      {
        cout<<"DENIED";
        return 0;
      }
    }
  }
  cout<<"APPROVED";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
const int n=3000;
long long int dp[3000][3000][4];
long long int a[3000][3000];
long long int fun(long int x,long int y,long int z)
{
    //cout<<x<<" "<<y<<" "<<z<<endl;
    if(x<0 || y<0)
    return 0;
    if(dp[x][y][z]!=-1)
    return dp[x][y][z];
    dp[x][y][z]=max(fun(x-1,y,3),fun(x,y-1,z));
    if(z>0)
    dp[x][y][z]=max(dp[x][y][z],a[x][y]+max(fun(x-1,y,3),fun(x,y-1,z-1)));
    return dp[x][y][z];
}
int main() {
    long int r,c,k;
    cin>>r>>c>>k;
    memset(dp,-1,sizeof(dp));
    memset(a,0,sizeof(a));
    long int aa,bb,cc;
    for(long int i=0;i<k;i++)
    {
        cin>>aa>>bb>>cc;
        a[aa-1][bb-1]=cc;
    }
    cout<<fun(r-1,c-1,3);
    //goes here
	return 0;
}


Measured memory_bytes: 355604
#include <bits/stdc++.h>
        using namespace std;
        #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
        #define M_PI 3.14159265358979323846
        #define data data_
        #define ff first
        #define ss second
        #define pb push_back
        #define ld long double
        #define int long long
        #define print(t) cout << "Case #" << t << ": ";
        int32_t main()
        {
            tani_nachi_ke  
            
            double r;
            cin >> r;
            cout << setprecision(3) << fixed;
            cout << 2*M_PI*r << endl;
 
 
 
 
 
           return 0;
        }

Measured memory_bytes: 3804
lines = readlines(chomp: true).map{|line| line.split(' ')}

n = lines[0][0].to_i
k = lines[0][1].to_i
a = lines[1].map!(&:to_i)

(k+1).upto(n) do |i|
	if  a[i-1] > a[i-k-1]
		puts "Yes"
	else
		puts "No"
	end
end


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

#define INF (LLONG_MAX/2)
#define MAX_N 1000

struct edge {
    int u;
    int v;
    long long w;
};

long long memo[MAX_N];

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

    vector<edge> edges(N);

    // init
    for (int i=0; i<MAX_N; i++) {
        memo[i] = INF;
    }
    memo[0] = 0;

    for (int i=0; i<M; i++) {
        int a,b;
        long long c;
        cin >> a >> b >> c;
        edges.push_back( edge{a - 1, b - 1, -c} ); // 重みを反転させる
    }

    // べるまんふぉーど
    bool loop = false;
    for (int i=0; i<N; i++) {
        for (auto e: edges) {
            // u -> v
            if (memo[e.u] != INF && memo[e.v] > memo[e.u] + e.w) {
                memo[e.v] = memo[e.u] + e.w;
                if (i == N-1 && e.v == N-1) {
                    loop = true;
                }
            }
        }
    }
    
    if (loop) {
        cout << "inf" << endl;
    } else {
        cout << -1 * memo[N-1] << endl;
    }

    return 0;
}

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

int main()
{
    int n,i,j,s=0;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            s+=a[i]*a[j];
        }
    }
    cout<<s<<endl;

}


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

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

int main() {
    int ans = 0;
    int K;
    cin >> K;
    for (int i = 1; i<K+1; i++){
        for (int j = 1; j<K+1; j++){
            for (int k = 1; k<K+1; k++){
                ans += gcd(gcd(i, j), k);;
            }
        }
    }
    
    cout << ans << endl;
  }


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int H,W,K,A[309][309],num;
int cnt[309];
char c[309][309];

void solve(int cl,int cr){
	vector<int> P;
	for(int i=cl;i<=cr;i++){
		for(int j=1;j<=W;j++){
			if(c[i][j]=='#') P.push_back(j);
		}
	}
	sort(all(P));

	rep(i,P.size()){
		int v1=1,v2=W;
		if(i>=1) v1=P[i-1]+1;
		if(i<(int)P.size()-1) v2=P[i];

		num++;
		for(int j=cl;j<=cr;j++){
			for(int k=v1;k<=v2;k++) A[j][k]=num;
		}
	}
}

int main() {
	cin>>H>>W>>K;
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cin>>c[i][j];
			if(c[i][j]=='#') cnt[i]++;
		}
	}

	vector<int> vec;
	for(int i=1;i<=H;i++) {
		if(cnt[i]>=1) vec.push_back(i);
	}
	for(int i=0;i<vec.size();i++){
		int v1=1,v2=H;
		if(i>=1) v1=vec[i-1]+1;
		if(i<(int)vec.size()-1) v2=vec[i];

		solve(v1,v2);
	}

	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if(j>=2) cout<<" ";
			cout<<A[i][j];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1280
import java.io.*;
public class Main {
		public static void main(String[] arg) throws IOException {
			InputStreamReader is = new InputStreamReader(System.in); 
	        BufferedReader br = new BufferedReader(is);
			String str = br.readLine();
			String[] spl = str.split(" ", 0);
			System.out.println(Integer.parseInt(spl[0])*Integer.parseInt(spl[1])+" "+(Integer.parseInt(spl[0])*2+Integer.parseInt(spl[1])*2));
	}

}

Measured memory_bytes: 24416
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int a,b,c,k;
cin>>a>>b>>c>>k;
int ans=0;
ans+=min(a,k);
k-=min(a,k);
k-=min(b,k);
ans-=min(c,k);
cout<<ans<<endl;
    return 0;
}


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

int main(){
  int w,a,b;
  cin>>w>>a>>b;
  int a_1=a,a_2=a+w,b_1=b,b_2=b+w;
  int ans=0;
  if(a_1<=b_1 && b_1<=a_2){
    cout<<0<<endl;
    return 0;
  }else if(a_1<=b_2 && b_2<=a_2){
    cout<<0<<endl;
    return 0;
  }else if(a_1<=b_1 && b_2<=a_2){
    cout<<0<<endl;
    return 0;
  }else if(b_1<=a_1 && a_2<=b_2){
	cout<<0<<endl;
    return 0;
  }else{
	int f,s;
    f=abs(a_2-b_1);
    s=abs(a_1-b_2);
    ans=min(f,s);
    cout<<ans<<endl;
    return 0;
  }
}

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

// main.cpp

int main() {
  std::string S;
  std::cin >> S;
  std::unordered_map<char, std::int_fast64_t> map;
  for (const char& c : S) {
    map.insert(std::make_pair(c, 0));
    ++map[c];
  }
  std::cout << (map.size() == 2 && std::all_of(map.begin(), map.end(), [](const std::pair<char, std::int_fast64_t>& p) { return p.second == 2; }) ? "Yes" : "No") << std::endl;
  return 0;
}

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

typedef long long ll;

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

    int N;

    cin >> N;

    map<ll, ll> K;

    K[0]++;

    ll S = 0;

    for(int i = 0; i < N; i++) {
        ll A;
        cin >> A;
        S += A;
        K[S]++;
    }

    ll count = 0;

    for(auto i: K) {
        //cerr << i.first << endl;
        count += i.second * (i.second - 1LL) / 2LL;
    }

    cout << count << endl;
}

Measured memory_bytes: 12800
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<stack>
#include<set>
using namespace std;
using LL = long long;
class UnionFind{
	public:
	vector<LL> parent;
	UnionFind(LL N)
	{
		parent.resize(N,-1);
	}
	LL find(LL x)
	{
		if(parent[x] == -1) return x;
		else 
		{
			LL tmp = find(parent[x]);
			parent[x] = tmp;
			return tmp;
		}
	}
	void unite(LL x,LL y)
	{
		x = find(x);
		y = find(y);
		if(x == y) return;
		else parent[x] = y;
	}
	bool same(LL x,LL y)
	{
		if(find(x) == find(y)) return true;
		else return false;
	}
};
int main()
{
	LL N,M,K;
	cin >> N >> M >> K;
	UnionFind U(N);
	vector<LL> numofunion(N,0);
	LL i;
	vector<LL> dame(N,0);
	for(i = 0;i < M;i++)
	{
		LL tmpa,tmpb;
		cin >> tmpa >> tmpb;
		tmpa--; tmpb--;
		U.unite(tmpa,tmpb);
		(dame[tmpa])++; (dame[tmpb])++;
	}
	for(i = 0;i < K;i++)
	{
		LL tmpc,tmpd;
		cin >> tmpc >> tmpd;
		tmpc--; tmpd--;
		if(U.same(tmpc,tmpd))
		{
			(dame[tmpc])++; (dame[tmpd])++;
		}
	}
	for(i = 0;i < N;i++)
	{
		(numofunion[U.find(i)])++;
	}
	for(i = 0;i < N;i++)
	{
		numofunion[i] = numofunion[U.find(i)];
	}
	for(i = 0;i < N;i++)
	{
		cout << (numofunion[i] - dame[i] -1) << endl;
	}
	return 0;
}
	


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

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		solver.readH(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		K = Integer.parseInt(strArr[1]);
	}

	int K;

	public void readH(String str) {
		String[] strArr = str.split("\\s+");
		int ans = 0;
		for (int i = 0; i < N; i++) {
			int h = Integer.parseInt(strArr[i]);
			if (h >= K)
				ans++;
		}
		System.out.println(ans);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 30960
h1, h2 = map(int, input().split())
k1, k2 = map(int, input().split())
a, b, c, d = map(int, input().split())

hiroshi = h1*a + h1//10*c + h2*b + h2//20*d
kenji = k1*a + k1//10*c + k2*b + k2//20*d

if hiroshi > kenji :
    print('hiroshi')
elif hiroshi < kenji :
    print('kenjiro')
else :
    print('even')


Measured memory_bytes: 5596
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, A: "List[int]"):
    a_sum = N
    for x in A:
        a_sum -= x

    if a_sum < 0:
        print(-1)
    else:
        print(a_sum)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()


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

int main(){
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int dp[n]={0};
    dp[1]=abs(arr[0]-arr[1]);
    long int ans=0;
    for(int i=2;i<n;i++){
       dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? " " : "");
    outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? "\n" : "");
    outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
    cout << head;
    outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    var(int, n);
    int minv = INF, maxv = 0;
    rep(i, n) {
        var(int, a);
        chmax(maxv, a);
        chmin(minv, a);
    }
    cout << maxv - minv << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N;
    string S;
    cin >> N ;
    cin >> S;
    int n = S.length();
    for(int i=0; i<n; i++){
        S[i] = (S[i] - 'A' + N) % 26 + 'A';
    }
    cout << S << endl;
    return 0;
}

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

int main(){
    string str;
    int q;
    cin >> str;
    cin >> q;
    while(q--){
        string s;
        cin >> s;
        if(s == "print"){
            int a, b;
            cin >> a >> b;
            cout << str.substr( a, b - a + 1) << endl;
        } else if(s == "reverse"){
            int a, b;
            cin >> a >> b;
            reverse( str.begin() + a, str.begin() + b + 1);
        } else {
            int a, b;
            string p;
            cin >> a >> b >> p;
            str.replace( a, b - a + 1, p);
        }
    }
    return 0;
}



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

int main(void){
  char c[3][3];
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> c[i][j];
    }
  }

  cout << c[0][0] << c[1][1] << c[2][2] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int n,m,ai,bi;
vector<int> v[100001];
priority_queue<int> pq;
int main(){
    cin>>n>>m;
    rep(i,n){
        cin>>ai>>bi;
        --ai;
        v[ai].pb(bi);
    }
    int ans=0;
    rep(i,m){
        int pi;
        rep(j,v[i].size()) pq.push(v[i][j]);
        if(!pq.empty()){
            pi=pq.top();pq.pop();
            ans+=pi;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5632
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left

#======================================================#

def main():
    x = II()
    n = x//100
    m = set([i for i in range(100*n, (105*n)+1)])
    if x in m:
        print(1)
    else:
        print(0)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3700
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <functional>

using namespace std;

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

bool is_kaibun(string s)
{
	bool f = true;

	int n = s.size();

	rep(i, n) {
		if (s[i] != s[n-1-i]) f = false;
	}

	return f;
}

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

	int n = S.size();

	string a = S.substr(0, (n-1)/2);
	string b = "";
	for (int i = (n + 3)/2 - 1; i < n; ++i) {
		b += S[i];
	}

	if (0) {
		cout << "a: " << a << endl;
		cout << "b: " << b << endl;
	}

	if (is_kaibun(S) and is_kaibun(a) and is_kaibun(b)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    string s;
    cin >> s;
    sort(ALL(s));
    if(s == "abc")cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define YES cout << "Yes" << endl;
#define NO cout << "No" << endl;
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    long k,n;
    cin >> k >> n;
    vector<long> a(n);
    rep(i,n){
        cin >> a.at(i);
    }
    sort(all(a));
    long dmax = 0;
    rep(i,n-1){
        dmax = max(dmax,a.at(i+1) - a.at(i));
    }
    dmax = max(dmax,a.at(0)+k - a.at(n-1));
    cout << k - dmax << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using namespace std;

int main(){
	ll N;
	cin >> N;
	ll c[5];
	rep(i,5) cin >> c[i];
	ll t = 1e15+1;
	rep(i,5) t = min(t, c[i]);
	ll ans = (N+t-1)/t + 4;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main()
{
int x,y,z,N,Y;
cin>>N>>Y;
for(int x=0;x<=Y/10000;x++)
  for(int y=0;y<=(Y-x*10000)/5000;y++)
  {z=N-x-y;
  if(z>=0 and x*10000+y*5000+z*1000==Y)
     {cout<<x<<" "<<y<<" "<<z;
      system ("pause");
      return 0;
      }
   }
cout<<"-1 -1 -1";
system ("pause");
return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    REP(i,n){
        cin >> s[i];
    }
    int ans = 0, xa = 0, bx = 0, ba = 0;
    REP(i,n){
        REP(j,s[i].length()-1){
            if (s[i].substr(j, 2) == "AB") ans++;
        }
        if (s[i][0] == 'B' && s[i].back() == 'A') ba++;
        else if (s[i][0] == 'B') bx++;
        else if (s[i].back() == 'A') xa++;
    }
    if (xa > 0 || bx > 0){
        ans += min(xa, bx) + ba;
    }else{
        ans += max(0, ba - 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
N = gets.to_i
h = {}
N.times{
  a = gets[0]
  h[a] = (h[a] || 0) + 1
}
p (0..2).map{ |i|
  (i+1..3).map{ |j|
    (j+1..4).map{ |k|
      [i,j,k].map{ |a| h["MARCH"[a]] || 0 }.inject(:*)
    }
  }
}.flatten.inject(:+)

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

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

    //数える
    int count;
    for (int i = 0; i < 3; i++) {
        if (sq.at(i) == '1') {
            count++;
        }
    }

    cout << count << endl;
}

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

int main(){
  int n, m;
  cin >> n >> m;

  int A[n][m] = {};
  int B[m] = {};

  for( int i = 0; i < n; i++){
    for( int j = 0; j < m; j++){
      int a;
      cin >> a;
      A[i][j] = a;
    }
  }

  for( int i = 0; i < m; i++){
    int a;
    cin >> a;
    B[i] = a;
  }

  for( int i = 0; i < n; i++){
    int s = 0;
    for(int j = 0; j < m; j++){
      s += A[i][j] * B[j];
    }
    cout << s << endl;  
  }

  return 0;
}

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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 500005
#define all(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

int32_t main(){
	IOS;
	int tt = 1; 
	// cin >> tt;
	while(tt--){
		long double x,y; cin >> x >> y;
		int a = x, b = y;
		x = x - (int)x;
		y = y - (int)y;
		long double ans = a * b + x * y + a * y + b * x;
		cout << (int)ans << endl;	
	}
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N, A;
  cin >> N >> A;
  cout << N*N-A << endl;
  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
march_count = {M: 0, A: 0, R: 0, C: 0, H: 0}
(0...n).each do |i|
  s = gets.chomp[0]
  march_count[s&.to_sym] += 1 unless march_count[s&.to_sym].nil?
end
x = march_count[:M] * march_count[:A] * march_count[:R] + march_count[:M] * march_count[:A] * march_count[:C] + march_count[:M] * march_count[:A] * march_count[:H] + march_count[:M] * march_count[:R] * march_count[:C] + march_count[:M] * march_count[:R] * march_count[:H] + march_count[:M] * march_count[:C] * march_count[:H] + march_count[:A] * march_count[:R] * march_count[:C] + march_count[:A] * march_count[:R] * march_count[:H] + march_count[:A] * march_count[:C] * march_count[:H] + march_count[:R] * march_count[:C] * march_count[:H]
puts x

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

bool check(const vi& A, const int m, const int i) {
    if (m == 0) { return true; }
    if (i == A.size() - 1) { return A[i] == m; }
    return check(A, m, i + 1) || check(A, m - A[i], i + 1);
}

int main() {
    int n, q;
    cin >> n;

    vi A(n);
    rep(i, 0, n) { cin >> A[i]; }

    cin >> q;
    rep(i, 0, q) {
        int m;
        cin >> m;
        bool ans = check(A, m, 0);
        cout << (ans ? "yes" : "no") << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// N, Mの入力
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		// PriorityQueの作成
		PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
		
		// 品物の値段の入力
		for (int i = 0; i < N; i++) {
			pq.offer(sc.nextInt());
		}
		
		// その時点で最も値段の高い品物に割引券を使う
		for (int i = 0; i < M; i++) {
			int max = pq.poll();
			pq.offer(max / 2);
		}
		
		// 割引後の価格の合計を計算
		long sum = 0;
		for (int price : pq) {
			sum += price;
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 57424
#include<bits/stdc++.h>
using namespace std;
long long dp[101][100001];
int main(){
	int n,W,w[100],u[100];
	cin>>n>>W;
	for(int i=0;i<n;i++)
		cin>>w[i]>>u[i];
	for(int i=1;i<=n;i++)
		for(int j=0;j<=W;j++)
			if(j<w[i-1])
				dp[i][j]=dp[i-1][j];
			else
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+u[i-1]);
	cout<<dp[n][W]<<endl;
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1,0)


int main()
{
   ll a,b;
   char c;
   cin>>a>>c>>b;
   if(c=='+'){
    cout<<a+b<<endl;
   }else{
    cout<<a-b<<endl;
   }
   return 0;
}


Measured memory_bytes: 256
import * as fs from 'fs'
import {debug} from '../../../util'

const input = fs.readFileSync('/dev/stdin', 'utf8').trim()

const output = (x: string | number | boolean) => console.log(x)
const splitLine = (string: string): string[] => string.split('\n')
const splitBlank = (string: string): string[] => string.split(' ')
const toNumbers = (array: string[]): number[] => array.map(v => Number(v))
const createSerialNumber = (n: number): number[] => [...Array(n).keys()]

// debug(input)

/* ここから */
const m = input.slice(-1)
if (m == '2' || m == '4' || m == '5' || m == '7' || m  == '9') {
    output('hon')
} else if (m == '3') {
    output('bon')
} else {
    output('pon')
}

Measured memory_bytes: 29584
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef long long llint;
typedef vector<long long int> vint;
typedef vector< vector<int> > vvint;
typedef vector<string> vstr;

int ans = 10000;


void dfs(string X, int n, int A, int B, int C,vint l) {
	if (n == 0) {
		int mp = 0;
		int leng = X.length();
		int Alon = 0;
		int Blon = 0;
		int Clon = 0;
		int Acou=0;
		int Bcou=0;
		int Ccou=0;
		for (int i = 0; i < leng; i++) {
			if (X[i] == 'A') {
			    Acou++;
				if (Alon > 0)mp += 10;
				Alon += l[i];
			}
			if (X[i] == 'B') {
			    Bcou++;
				if (Blon > 0)mp += 10;
				Blon += l[i];
			}
			if (X[i] == 'C') {
			    Ccou++;
				if (Clon > 0)mp += 10;
				Clon += l[i];
			}
		}
		mp += abs(A - Alon);
		mp += abs(B - Blon);
		mp += abs(C - Clon);
		if(Acou>0&&Bcou>0&&Ccou>0)ans = min(ans, mp);
	
		return;
	}
	else {
		dfs('A' + X, n - 1, A, B, C,l);
		dfs('B' + X, n - 1, A, B, C, l);
		dfs('C' + X, n - 1, A, B, C, l);
		dfs('N' + X, n - 1, A, B, C, l);
	}
}

int main(void) {
	int N, A, B, C;

	cin >> N >> A >> B >> C;
	vint l(N);
	for (int i = 0; i < N; i++) cin >> l[i];

	dfs("", N, A, B, C,l);
	cout << ans << endl;
}


Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BCountBalls solver = new BCountBalls();
        solver.solve(1, in, out);
        out.close();
    }

    static class BCountBalls {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            long n = s.nextLong();
            long a = s.nextLong();
            long b = s.nextLong();

            long div = n / (a + b);
            long ans = div * a;

            n %= (a + b);
            if (n <= a) {
                ans += n;
            } else {
                ans += a;
            }

            out.println(ans);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 23508
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] x = new int[n];
		int l, r;
		int min = Integer.MAX_VALUE;
		for(int i = 0;i < n;i++){
			x[i] = sc.nextInt();
		}
 
 
		for(int i = 0;i < n - k + 1;i++){
			l = Math.abs(x[i]) + Math.abs(x[i + k - 1]-x[i]);
			r = Math.abs(x[i + k - 1]) + Math.abs(x[i]-x[i + k - 1]);
			if(min > l) min = l;
			if(min > r) min = r;
		}
 
		System.out.println(min);
	}
}

Measured memory_bytes: 49636
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    int a[n][m];
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
            char x;
            cin>>x;
            if(x=='.') a[i][j]=1;
            if(x=='#') a[i][j]=0;
      }
    }
    int u[n][m],d[n][m],r[n][m],l[n][m];
    
    //Left
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
            if(!a[i][j]){
              l[i][j]=0;
            }else{
              if(j==0){
                l[i][j]=1;
              }else{
                l[i][j]=1+l[i][j-1];
              }
            }
      }
    }


    //Right

    for(int i=0;i<n;i++){
      for(int j=m-1;j>=0;j--){
        if(!a[i][j]){
          r[i][j]=0;
        }else{
          if(j==m-1){
            r[i][j]=1;
          }else{
            r[i][j]=1+r[i][j+1];
          }
        }
        
      }
    }
    //Up
    for(int i=0;i<m;i++){
      for(int j=0;j<n;j++){
        if(!a[j][i]){
          u[j][i]=0;
        }else{
          if(j==0){
            u[j][i]=1;
          }else{
            u[j][i]=1+u[j-1][i];
          }
        }
      }
    }

    //Down
    for(int i=0;i<m;i++){
      for(int j=n-1;j>=0;j--){
        if(!a[j][i]){
          d[j][i]=0;
        }else{
          if(j==n-1){
            d[j][i]=1;
          }else{
            d[j][i]=1+d[j+1][i];
          }
        }
      }
    }
    int ans=0;
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
        if(a[i][j]){
          ans=max(u[i][j]+d[i][j]+r[i][j]+l[i][j]-3,ans);  
        }
      }
    }
    cout<<ans<<endl;

    // for(int i=0;i<n;i++){
    //   for(int j=0;j<m;j++){
    //         //cerr<<i<<" "<<j<<endl;
    //         cout<<d[i][j]<<" ";
    //   }
    //   cout<<endl;
    // }
    // for(int i=0;i<m;i++){
    //   for(int j=0;j<n;j++){
    //         cerr<<i<<" "<<j<<endl;
    //         cout<<a[j][i]<<" ";
    //   }
    //   cout<<endl;
    // }

    
    return 0;
    
}


Measured memory_bytes: 156544
import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def solve():
    n = getN()
    # s = getS()
    print(n + n * n + n * n* n)
def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

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

int main()
{
  int W, D;
  while (cin >> W >> D && W != 0) {
    vector<int> ws(W), ds(D);
    for (int i = 0; i < W; i++) {
      cin >> ws[i];
    }
    for (int i = 0; i < D; i++) {
      cin >> ds[i];
    }
    sort(ws.rbegin(), ws.rend());
    sort(ds.rbegin(), ds.rend());

    int ans = 0;
    int i = 0, j = 0;
    while (true) {
      ans += min(ws[i], ds[j]);
      if (i == W-1 && j == D-1) {
        break;
      } else if (i == W-1) {
        j++;
      } else if (j == D-1) {
        i++;
      } else if (ws[i+1] > ds[j+1]) {
        i++;
      } else if (ws[i+1] < ds[j+1]) {
        j++;
      } else if (ws[i+1] == ds[j+1]) {
        i++;
        j++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
///   ***   ---   |||         In the name of ALLAH        |||   ---   ***   ///



#include<bits/stdc++.h>
using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }

const int mx = 1e5+123;
int a[mx][4], dp[mx][4], n;

int solve ( int i, int f1 )
{
    if ( i > n ) return 0;

    if ( dp[i][f1] != -1 ) return dp[i][f1];

    int ret = 0;

    for ( int j = 1; j <= 3; j++ ) {
        if ( j != f1 ) ret = max ( ret, a[i][j] + solve ( i+1, j ) );
    }

    return dp[i][f1] = ret;
}

int main()
{
    optimize();

    cin >> n;
    for ( int i = 1; i <= n; i++ ) {
        cin >> a[i][1] >> a[i][2] >> a[i][3];
    }

    mem ( dp, -1 );
    cout << solve ( 1, 0 ) << endl;

    return 0;
}


















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

int main() {
  int a,b,k;cin>>a>>b>>k;
  if((b-a+1)/2>=k){
    for(int i=a;i<a+k;i++)cout<<i<<endl;
    for(int i=b-k+1;i<=b;i++)cout<<i<<endl;
  }
  else {
    for(int i=a;i<=b;i++)cout<<i<<endl;
  }
}

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

#include<vector>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
const int INF = 1e9+1;
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 H, W;
char G[51][51];

int main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++) cin >> G[i];

    
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (G[i][j] == '#') {
                bool flag = false;
                if (i > 0 && G[i-1][j] == '#') flag = true; 
                if (i < H-1 && G[i+1][j] == '#') flag = true; 
                if (j > 0 && G[i][j-1] == '#') flag = true; 
                if (j < W-1 && G[i][j+1] == '#') flag = true; 
                if (!flag) {
                    cout << "No\n";
                    return 0;
                }
            }
        }
    }    
    cout << "Yes\n";
}


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

const ll LINF = 1LL<<60;

int main() {
  string s; cin >> s;
  string sr = s;
  reverse(sr.begin(), sr.end());
  string s1 = s.substr(0, s.size()/2);
  string s2 = sr.substr(0, sr.size()/2);

  int cnt=0;
  for(int i=0; i<s1.size(); i++){
    if(s1[i] != s2[i]) cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 n, k; string s;
  cin >> n >> s >> k;
  char c = s[k - 1];
  for (i64 i = 0; i < n; ++i) {
    if (s[i] != c) s[i] = '*';
  }
  cout << s << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

// ユーザ入力として長方形の縦と横の長さを受け取り、
// 長方形を#で表現して表示する
int main()
{
	// 変数定義
	int iTate;		// 縦の長さ
	int iYoko;		// 横の長さ
	int iTimes;		// 何回目の入力か
	int iCountA;	// ループカウンタA
	int iCountB;	// ループカウンタB

	// 変数初期化
	iTate = -1;
	iYoko = -1;
	iTimes = 0;

	// 縦横の値が0でない限り入力と出力を繰り返す
	while (iTate + iYoko != 0)
	{
		iTimes++;

		// 入力：長方形の縦の長さ, 横の長さ
		scanf("%d %d", &iTate, &iYoko);

		// 出力：長方形を模した#列
		//// 2回目以降の長方形表示は、空行を挟んでから行う
		if (iTimes != 1)
		{
			printf("\n");
		}
		//// 長方形の表示
		for (iCountA = 0; iCountA < iTate; iCountA++)
		{
			for (iCountB = 0; iCountB < iYoko; iCountB++)
			{
				printf("#");
			}
			printf("\n");
		}
	}

	return 0;
}


Measured memory_bytes: 2044