akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>

using namespace std;

int n;
vector<string> d;
stack<int> stk;

int solve(int level,int i,char op) {
	//serch
	int kazu = 0;
	while (1) {
		if (d[i].size() - 1 < level)break;

		if (d[i][level] >= '0' && d[i][level] <= '9') {
			stk.push(d[i][level]-48);
			kazu++;
			i++;
		}
		else {
			i=solve(level+1,i+1, d[i][level]);
			kazu++;
		}

		if (i == n)break;
	}

	int sum=0;
	for (int j = 0; j < kazu; j++) {
		int t = stk.top();
		stk.pop();
		//cout << t << endl;

		if (j == 0) {
			sum += t;
			continue;
		}

		else {
			if (op == '*')sum *= t;
			else if (op == '+')sum += t;
		}
	}
	stk.push(sum);
	return i;
}

int main() {
	
	while (1) {
		d.clear();
		if (!stk.empty())stk.pop();

		cin >> n;

		if (n == 0)break;

		if (n == 1) {
			int f;
			cin >> f;
			cout << f << endl;
			continue;
		}

		for (int i = 0; i < n; i++) {
			string str;
			cin >> str;
			d.push_back(str);
		}

		solve(1, 1, d[0][0]);
		/*if (stk.size() != 1)cout << "err" << endl;
		else cout << stk.top() << endl;*/
		cout << stk.top() << endl;
	}

	return 0;
}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(a-b)<=d && abs(b-c)<=d){
        cout << "Yes" << endl;
    }else if(abs(a-c)<=d){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

const INF: usize = 1 << 60;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let A: Vec<Vec<usize>> = sc.mat(N, N);
    let mut connected = vec![vec![true; N]; N];
    for k in 0..N {
        for i in 0..N {
            for j in 0..N {
                if i == j || i == k || j == k {
                    continue;
                }
                if A[i][j] == A[i][k] + A[k][j] {
                    connected[i][j] = false;
                } else if A[i][j] > A[i][k] + A[k][j] {
                    println!("-1");
                    return;
                }
            }
        }
    }
    let mut ans = 0;
    for i in 0..N-1 {
        for j in i+1..N {
            if connected[i][j] {
                ans += A[i][j];
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

n,k,q = m()

po = [-1 * q for i in range(n)]

for i in range(q):
    aaa = onem()
    po[aaa-1] += 1

for i in range(n):
    if k + po[i] > 0:
        print("Yes")
    else:
        print("No")










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

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

  int i = 0;
  while (N > 0)
  {
    N /= K;
    i++;
  }
  cout << i << endl;
}

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

#define INF INT_MAX
#define ll long long

using namespace std;

int main(){
	while(true){
		int w,h;
		cin >> w >> h;
		if(w == 0 && h == 0)
			break;
		int c[h][w];
		//??\???
		for(int j = 0;j < h;j++){
			for(int i = 0;i < w;i++){
				cin >> c[j][i];
			}
		}

		//??????????????°????????????
		int ans = 0;
		for(int j = 0;j < h;j++){
			for(int i = 0;i < w;i++){
				if(c[j][i] == 1){
					ans++;
					vector< pair<int,int> > v;
					v.push_back(make_pair(j,i));
					while(!v.empty()){
						int y = v.back().first, x = v.back().second;
						c[y][x] = 0;	//????????¶????????????
						v.pop_back();
						for(int dirY = -1;dirY < 2;dirY++){
							for(int dirX = -1;dirX < 2;dirX++){
								int yy = y + dirY,xx = x + dirX;
								if((0 <= yy && yy < h) && (0 <= xx && xx < w) && (c[yy][xx] == 1)){
									v.push_back(make_pair(yy,xx));
								}
							}
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using pi = pair<int, int>;
using lint = long long;
const int MAXN = 100005;

int n, x, a[MAXN];

lint ret;

void decr(int &x, int y){
	ret += x - y;
	x = y;
}

int main(){
	scanf("%d %d",&n,&x);
	for(int i=1; i<=n; i++) scanf("%d",&a[i]);
	if(a[1] >= x) decr(a[1], x);
	for(int i=2; i<=n; i++){
		if(a[i] + a[i-1] > x){
			decr(a[i], x - a[i-1]);
		}
	}
	cout << ret << endl;
}




Measured memory_bytes: 640
package main

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

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func main() {
	defer w.Flush()

	var a, b int
	fmt.Fscanf(r, "%d %d\n", &a, &b)
	xaLow := int(math.Ceil(float64(a) * 12.5))
	xaHigh := int(math.Ceil(float64(a+1)*12.5)) - 1
	xbLow := b * 10
	xbHigh := b*10 + 9
	if xaLow > xbHigh || xbLow > xaHigh {
		fmt.Fprintln(w, -1)
		return
	}
	if xaLow >= xbLow {
		fmt.Fprintln(w, xaLow)
		return
	}
	fmt.Fprintln(w, xbLow)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll a, b;
  cin >> a >> b;
  ll g = __gcd(a, b);

  int ans = 1;
  for (ll i = 2; i*i < g; i++) {
    if (g%i == 0) {
      ans++;
      while (g%i == 0) {
        g /= i;
      }
    }
  }
  if (g != 1) ans++;

  cout << ans << endl;
}


Measured memory_bytes: 256
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
[n,m]=i2()
p=i2()

import sys
sys.setrecursionlimit(10000)

par=[i for i in range(n)]
rank=[0 for i in range(n)]

def rt(x):
 if par[x]==x:
    return x
 else:
    par[x]=rt(par[x])
    return par[x]

def un(x,y):
    x=rt(x)
    y=rt(y)
    if x==y:
       return
    else:
       if rank[x]<rank[y]:
          par[x]=y
       else:
          par[y]=x
          if rank[x]==rank[y]:
             rank[x]+=1
xy=[]
for i in range(m):
 xy.append(i2())
 
for i,j in xy:
 un(i-1,j-1)
for i,j in xy:
 un(i-1,j-1)
s=0
for i in range(n):
 if par[i]==par[p[i]-1]:
   s+=1
print(s)

Measured memory_bytes: 103148
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
  int N;
  vector<int> A;
  string buf;
  
  cin >> N;
  while(getline(cin, buf, ' ')) {
    A.push_back(atoi(buf.c_str()));
  }
  
  bool ok = true;
  for (int i = 0; i < N; i++) {
    if (A[i] % 2 == 0) {
      if ((A[i] % 3) != 0 && (A[i] % 5) != 0) {
        ok = false;
      }
    }
  }
  
  if (ok) {
    cout << "APPROVED" << endl;
  } else {
    cout << "DENIED" << endl;
  }
  
  
  return 0;
}

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

int main() {
    string s; cin >> s;
    const int n = s.size();

    int ans = 0;
    int J = -1, O = -1, I = -1;
    for(int i = 0; i < n; ++i) {
        if(s[i] == 'J') {
            J = (J == -1 || O != -1 ? 1 : J + 1);
            O = I = -1;
        } else if(s[i] == 'O') {
            if(J == -1) continue;
            if(I != -1) {
                J = -1, O = -1, I = -1;
                continue;
            } else {
                O = (O == -1 ? 1 : O + 1);
                I = -1;
            }
        } else {
            if(O == -1) {
                J = -1;
                continue;
            }
            I = (I == -1 ? 1 : I + 1);
            if(O <= J && O == I) {
                ans = max(ans, I);
            }
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 3980
#include <stdio.h>
#include <string.h>
char word[110];
int isPa(int l,int r,char *s){
	int i,len;
	len=r-l+1;
	for(i=0;i<len/2;i++)
		if(s[l+i]!=s[l+len-1-i])
			return 0;
	return 1;
}
int main(){
	int i,len;
	scanf("%s",word);
	len=strlen(word);
	if(!isPa(0,len-1,word)){
		printf("No\n");
		return 0;
	}
	if(!isPa(0,len/2-1,word)){
		printf("No\n");
		return 0;
	}
	if(!isPa(len/2+1,len-1,word)){
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	return 0;}


Measured memory_bytes: 128
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 入力
		int n = sc.nextInt();// N
		int k = sc.nextInt();// K

		// 計算
		int pattern = 1;
		for(int i = 0; i < n; i++){
			if(i == 0){
				pattern = pattern * k;
			}else{
				pattern = pattern * (k - 1);
			}
		}
		// 出力
		System.out.println(pattern);
	}
}




Measured memory_bytes: 21332
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var NMP = Sarray();
            var N = NMP[0];
            var M = NMP[1];
            var P = NMP[2];
            var graph = Enumerable.Range(0, (int)N).Select(_ => new List<(long t, long c)>()).ToArray();

            for(var i=0;i<M;++i)
            {
                var abc = Sarray();
                var a = abc[0] - 1;
                var b = abc[1] - 1;
                var c = abc[2];
                graph[a].Add((b, c - P));
            }
            var INI = long.MinValue / 2;
            var dst = Enumerable.Repeat(INI, (int)N).ToArray();
            var isC = new bool[N];
            dst[0] = 0;
            for (var r = 0; r < N; ++r)
            {
                for (var v = 0; v < N; ++v)
                    foreach (var g in graph[v])
                    {
                        if (dst[v] != INI && dst[g.t] < dst[v] + g.c)
                        {
                            if (r == N - 1)
                                isC[g.t] = true;
                            dst[g.t] = dst[v] + g.c;
                        }
                    }
            }
            for (var r = 0; r < N; ++r)
            {
                for (var v = 0; v < N; ++v)
                    foreach (var g in graph[v])
                    {
                        if (isC[v])
                            isC[g.t] = true;
                    }
            }
            if (isC[N - 1])
                WriteLine(-1);
            else
                WriteLine(Max(0, dst[N - 1]));
        }        
    }
}

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

int jump(int ind, vector<int> &stone, vector<int> &dp, int k) {

	if (ind <= 0) {
		return 0;
	}

	if (dp[ind] != -1) {
		return dp[ind];
	}

	long low = abs(stone[ind] - stone[ind - 1]) + jump(ind - 1, stone, dp, k);
	long high = INT_MAX;

	for (int j = 2; j <= k; j++) {

		if (ind - j >= 0) {
			long temp = abs(stone[ind] - stone[ind - j]) + jump(ind - j, stone, dp, k);
			high = min(high, temp);
		}
	}

	dp[ind] = min(low, high);

	return dp[ind];
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input1.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output1.txt", "w", stdout);
#endif

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

	vector<int>stone(n);
	vector<int>dp(n, -1);

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

	int answer = jump(n - 1, stone, dp, k);

	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <atcoder/all>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using namespace atcoder;

const int MAX_A = 3e5 + 5;

int op(int a, int b) { return max(a, b); }
int e() { return 0; }

int main() {
	int n, k; cin >> n >> k;
	vector<int> a(n);
	REP(i, n) cin >> a[i];

	segtree<int, op, e> dp(MAX_A);

	REP(i, n) {
		int x = a[i];
		int l = max(0, x - k);
		int r = min(x + k + 1, MAX_A);
		// dp.prod(l, r) は設計の時に，
		// [l, r) の半開区間になっている(閉区間でも良かったけど，
		// 半開区間の方が何かと便利なので)ので +1 をして，
		// 閉区間にする
		int now = dp.prod(l, r) + 1;
		dp.set(x, now);
	}

	cout << dp.all_prod() << '\n';
	return 0;
}

Measured memory_bytes: 9636
#include <iostream>
 
int main(){
    int a, b;
     
    while(std::cin >> a >> b){
        int n = a + b;
        int count = 1;
        //10??§?????£???0??§???????????°?????°????¢???????
        while(n / 10 != 0){
            ++count;
            n /= 10;
        }
        std::cout << count << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
using namespace std;

typedef long long ll;
int N, M;
ll X;
vector<ll> C;
vector<vector<ll>> A;
ll cnt = 1300000;

void dfs(vector<int> choose){
    if(choose.size()==N){
        vector<ll> algorithm(12,0);
        ll cost = 0;
        for (int i = 0; i < N; i++)
        {
            if (choose[i]==1)
            {
                cost += C[i];
                for (int j = 0; j < M; j++)
                {
                    algorithm[j] += A[i][j];
                }          
            }
        }
        int target = 0;
        for (int i = 0; i < M; i++)
        {
            if (algorithm[i]>=X)
            {
                target++;
            }   
        }
        if (target==M)
        {
            cnt = min(cnt,cost);
        }
        return;
    }

    choose.push_back(0);
    dfs(choose);
    choose.back()++;
    dfs(choose);
}

int main(int argc, char const *argv[])
{
    ll c,a;
    cin >> N >> M >> X;
    for (int i = 0; i < N; i++)
    {
        cin >> c;
        C.push_back(c);
        vector<ll> as;
        for (size_t j = 0; j < M; j++)
        {
            cin >> a;
            as.push_back(a);
        }
        A.push_back(as);
    }
    
    dfs(vector<int>(0));

    if (cnt<1300000)
    {
        cout << cnt;
    }
    else
    {
        cout << -1;
    }
     
    return 0;
}


Measured memory_bytes: 3636
n,x = map(int,input().split())
a = list(map(int,input().split()))
if sum(a) == x:
    print(n)
elif sum(a) < x:
    print(n - 1)
else:
    ans = 0
    a.sort()
    for i in range(n):
        if a[i] > x:
            break
        else:
            x -= a[i]
            ans += 1
    print(ans)

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

#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()

const int NAX = 2e5 + 5, MOD = 1000000007;

class Solution
{
private:
public:
    Solution() {}
    ~Solution() {}
    void solveCase()
    {
        ll n;
        cin >> n;
        string res = "";
        while (n)
        {
            n--;
            res += 'a' + n % 26;
            n /= 26;
        }
        db(res);
        reverse(all(res));
        cout << res << '\n';
    }
};

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
    // cin >> t;
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef LOCAL
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


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

int main(){
  int a[3];

  for(int i=0;i < 3;i++){
    cin >> a[i];
  }
  sort(a,a+3);

  cout << a[1]-a[0] + a[2]-a[1] << endl;
  return 0;
}

Measured memory_bytes: 256
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    K = int(input())
    S = input().rstrip()

    if K >= len(S):
        res = S
    else:
        res = S[:K] + '...'

    print(res)



main()


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int n;
	cin >> n;
	map<ll, ll> b;

	ll ans = 0;
	for(ll i = 0; i < n; ++i)
	{
		ll a;
		cin >> a;
		b[i+1+a]++;
		if (b[i + 1 - a] > 0)
		{
			ans += b[i + 1 - a];
		}
	}
	cout << ans << endl;
}

int main()
{
	fastio;
	solve();

	return 0;
}

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

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

    for (int i=N; i<=1000; ++i) {
        string tmp = to_string(i);
        bool ok = true;
        rep(j, tmp.size()) {
            if (tmp[0] != tmp[j]) ok = false;
        }
        if (ok) {
            cout << tmp << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 384
#%%
W, H, x, y = map(int, input().split())

# 最大はちょうど半分に切ったとき = x, yがどこにあっても中心を通ればちょうど半分
s = W * H / 2
# x, yが中心の時は無限に切り方がある
if W / 2 == x and  H / 2 == y:
    w = 1
else:
    w = 0

print(s, w)

Measured memory_bytes: 38384
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    char a;
    cin >> a;
    if(a <= 'Z') cout << "A" << endl;
    else cout << "a" << endl;
    return 0;
}


Measured memory_bytes: 3580
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
b=0
c=0
for i in range(x,0,-1):
	if i in a:
		b+=1
for j in range(x,n+1):
	if j in a:
		c+=1
print(min(b,c))

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

class Union_Find{
  vector<int> par; vector<int> rank; vector<int> num;
public:
  Union_Find(int n) {
    par = vector<int>(n); rank = vector<int>(n,0); num = vector<int>(n,1);
    rep(i,n) par[i] = i;
  }
  int find(int x) {
    if(par[x] == x) return x;
    else  return par[x] = find(par[x]);
  }
  int number(int x) {
    return num[find(x)];
  }
  void unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) swap(x, y);
    if (rank[x] == rank[y]) rank[x]++;
    par[y] = x;
    num[x] += num[y];
  } 
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main(){
  int n;
  cin >> n;
  P p[n];
  rep(i,n) cin >> p[i].first;
  rep(i,n) cin >> p[i].second;
  sort(p,p+n);
  int a[n], b[n];
  rep(i,n) a[i] = p[i].first, b[i] = p[i].second;
  P c[n];
  rep(i,n) c[i] = P(b[i],i);
  sort(c,c+n);
  rep(i,n) {
    if(c[i].first < a[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  Union_Find uf(n);
  rep(i,n) uf.unite(i,c[i].second);
  int cnt = 0;
  rep(i,n) if(uf.find(i) == i) cnt++;
  if(cnt >= 2) {
    cout << "Yes" << endl;
    return 0;
  } 
  rep(i,n-1) {
    if(c[i].first >= a[i+1]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 6656
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

vector<int>C;
ll mod = 1e9 + 7;
int N;
ll dp[202020];
ll sum[202020];

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

	cin >> N;
	vector<int>Cpre(N);
	for (int i = 0; i < N; i++) {
		cin >> Cpre[i];
		if (i == 0 || Cpre[i - 1] != Cpre[i])C.pb(Cpre[i]);
	}
	N = C.size();


	dp[0] = 1;
	for (int i = 1; i <= N; i++) {
		dp[i] = dp[i - 1] + sum[C[i-1]];
      	dp[i] %= mod;
		sum[C[i - 1]] = dp[i];
	}
	puts(dp[N]);

	return 0;
}

Measured memory_bytes: 5108
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>

#define sci(n) scanf("%d",&n)
#define msci(m,n) scanf("%d %d",&m,&n)
#define mod 1000000007

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


using namespace std;

int Iterbinarysearch(int a[],int n,int x)
{
    int l=0,h=n-1;
	int res=-1;
    while(l<=h)
    {
        int mid=l+(h-l)/2;
        if(x>=a[mid])
		{
			res=mid;
			l=mid+1;
		}
		else
		h=mid-1;
    }
    return res;

}
// int Recurbinarysearch(int a[],int n,int x,int i,int j)
// {
//     if(i>j) return-1;
//     if(n>0)
//     {
//         int mid=i+(j-i)/2;
//         if(x==a[mid]) return mid;
//         else if(x>a[mid]) return Recurbinarysearch(a,n,x,mid+1,j);
//         else return Recurbinarysearch(a,n,x,i,mid-1);
//     }
    
// }

// int* func(int a[],int n)
// {
//     int k=1;
//     for(int i=0;i<n;i++)
//     a[i] +=k;
//     return a;
// } 



// bool isPossibleTriangle(int arr[], int n) 
//    {
//     if (n < 3) 
//     return false; 
  
   
//     sort(arr, arr + n); 
  
//     for (int i = 0; i < n - 2; i++) 
  
    
//         if (arr[i] + arr[i + 1] > arr[i + 2]) 
//         {
//             s1.insert(arr[i]);
//             s1.insert(arr[i+1]);
//             s1.insert(arr[i+2]);

            
//         }
       

//           cout<<"\n";
//         if(s1.size()!=0)
             
//         return true;
    
//         else
//      return false; 
// } 
int gcd (int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
int lcm (int a, int b) {
    return a / gcd(a, b) * b;
}


int main()
{
 /*int k=Recurbinarysearch(a,n,x,0,n-1);
(k==-1)?cout<<"Not found":cout<<"found at "<<k;*/
////////////////////////////////////////////////////////////////
//  if (__cplusplus == 201703L)
//       std::cout << "C++17" << endl;
//    else if (__cplusplus == 201402L)
//       std::cout << "C++14" << endl;
//    else if (__cplusplus == 201103L)
//       std::cout << "C++11" << endl;
//    else if (__cplusplus == 199711L)
//       std::cout << "C++98" << endl;
//    else
//       std::cout << "pre-standard C++" << endl;




	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);


	int t ;
	cin >> t ;
		if(t==0)
		cout<<1<<"\n";
		else
		{
			cout<<0<<"\n";
		}
		
 return 0;
    }





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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)
#define allof(v) (v).begin(), (v).end()

li plus_table[50];
li minus_table[50];

inline void calc(li x, vector<li>& ans) {
	/*
	cout << "calc " << x << endl;
	rep(i, ans.size()) {
		cout << ans[i];
	} cout << endl;
	*/
	if (x == 0) {
		return;
	}
	if (x > 0) {
		li now = 0;
		while (plus_table[now] < x) {
			now++;
		}
		ans[now] = 1;
		return calc(x - (1ll << now), ans);
	} else {
		li now = 0;
		while (minus_table[now] > x) {
			now++;
		}
		ans[now] = 1;
		return calc(x + (1ll << now), ans);
	}
}

int main(void)
{

	plus_table[0] = 1;
	plus_table[1] = 1;
	minus_table[0] = 0;
	minus_table[1] = -2;
	repp(i, 2, 50) {
		if (i % 2 == 0) {
			plus_table[i] = plus_table[i - 2] + (1ll << i);
			minus_table[i] = minus_table[i - 1];
		} else {
			minus_table[i] = minus_table[i - 2] - (1ll << i);
			plus_table[i] = plus_table[i - 1];
		}
	}

	li n;
	cin >> n;
	vector<li> res(51, 0);
	calc(n, res);

	bool msb = false;
	for (li i = 50; i >= 0; --i) {
		if (res[i] == 0 && msb) {
			cout << 0;
		} else if (res[i] == 1) {
			msb = true;
			cout << 1;
		}
	}
	if (!msb) {
		cout << 0;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  int min=a[0];
  int cnt=1;
  for(int i=1;i<n;i++)
  {
    if(min>a[i])
    {
      cnt++;
      min=a[i];
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define VECCIN(vec) const int size = (vec).size(); REP(i,size) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int X, A, B;
    cin >> X >> A >> B;
    if (-A + B <= 0) {
        cout << "delicious" << endl;
    }
    else if (-A + B <= X) {
        cout << "safe" << endl;
    }
    else {
        cout << "dangerous" << endl;
    }

    return 0;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s, t; cin >> s >> t;
  rep(i, s.size()) {
    if(s[i] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 3652
def is_even(num):
    if num % 2 == 0:
        return True
    else:
        return False

n = int(input())
a = [int(i) for i in input().split()]
a.sort()


if is_even(n):
    print(a[int(n/2)]-a[int(n/2)-1])
else:
    print(1)

Measured memory_bytes: 14396
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>

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

int main() {
    int l, r, d;
    cin >> l >> r >> d;

    int ans = 0;
    for(int i = l; i <= r; i++) {
        if(i%d == 0)
            ans++;
    }

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

Measured memory_bytes: 3224
# -*- coding:utf-8 -*-

def solve():
    import sys

    N, M = list(map(int, sys.stdin.readline().split()))
    Cs = list(map(int, sys.stdin.readline().split()))

    dp = [float("inf") for _ in range(N+1)]  # dp[i] := i円を作ることができるコインの最小枚数
    dp[0] = 0

    for c in Cs:
        for i in range(c, N+1):
            dp[i] = min(dp[i], dp[i-c]+1)
    print(dp[N])


if __name__ == "__main__":
    solve()



Measured memory_bytes: 7656
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
  int a, b;
  cin >> a >> b;
  a--;
  int k;
  if(a%4==0)k=a;
  else if(a%4==1)k=1;
  else if(a%4==2)k=a+1;
  else k=0;
  int l;
  if(b%4==0)l=b;
  else if(b%4==1)l=1;
  else if(b%4==2)l=b+1;
  else l=0;
  cout << (k^l) << endl;
  return 0;
}

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

using namespace std;
const int N = 2e5;

char s[N];

int main(void)
{
	int cnt = 0, n;
	cin >> n >> s + 1;
	for (int i=1;i<=n;++i)
		if (i == 1 || s[i] != s[i-1]) cnt ++;
	cout << cnt << endl;
	return 0; 
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n,l,r,ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>l>>r;
		ans+=r-l+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
# 煉瓦の個数N
N = int(input())

A = list(map(int, input().split()))
# 砕いた後の煉瓦数 K

cost = 0
cnt = 1
# i番目の数字がiだと嬉しい
for a in A:
    # index番号の不一致
    if a != cnt:
        # 壊すして次へ
        cost +=1
        
    # index番号が一致していたら、次のindex番号を比較
    elif a==cnt:
        cnt +=1

if cost==len(A):
    print(-1)
else:
    print(cost)
    
    

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

struct UnionFind {
  vector<int> par;
  vector<int> rank;

  UnionFind(int n):par(n),rank(n){
    rep(i,n){
      par[i]=i;
      rank[i]=0;
    }
  }

  int find(int x){
    if(par[x]==x){
      return x;
    }else{
      return par[x]=find(par[x]);
    }
  }

  void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y) return;

    if(rank[x]<rank[y]){
      par[x]=y;
    }else{
      par[y]=x;
      if(rank[x]==rank[y]) rank[x]++;
    }
  }

  bool same(int x,int y){
    return find(x)==find(y);
  }

  void body(){
    rep(i,par.size()){
      cout <<par[i]<<" "<<rank[i]<<endl;
    }
  }
};

int main() {
  int n,m,count=0;
  cin >>n>>m;
  vector<int> p(n);
  UnionFind uni(n);
  rep(i,n){
    int w;
    cin >> w;
    p[i]=w-1;
  }
  rep(i,m){
    int x,y;
    cin >>x>>y;
    uni.unite(x-1,y-1);
  }
  rep(i,n){
    if(uni.same(p[i],i)){
      count++;
    }
  }
  cout << count<<endl;
}

Measured memory_bytes: 4240
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)

def main():
    s = input()
    print(s[0:3])

main()


Measured memory_bytes: 9360
#include <bits/stdc++.h>
#define ff(i, x, y) for(int i = x;i <= y;i++)
#define fs(i, x, y) for(int i = x;i >= y;i--)
using namespace std;
int main() {
    int n, sum = 0;
    scanf("%d", &n);
    printf("%d", (n - 1) / 2);
    return  0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int m1, m2, d1, d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;
    if (m1 == m2)
        cout << 0 << endl;
    else
        cout << 1 << endl;

    return 0;
}


Measured memory_bytes: 764
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    N = int(input())
    ans = [0] * (N + 1)
    for i in range(1,101):
        for j in range(1,101):
            for k in range(1,101):
                x = i*i + j*j + k*k + i*j + j*k + k*i 
                if x <= N:
                    ans[x] += 1
    for i in range(1,N + 1):
        print(ans[i])
if __name__ == '__main__':
    main()

Measured memory_bytes: 68364
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

  int n;
  cin>>n;
    if(n==0){
    cout<<0<<endl;
    return 0;
  }
  bool isMinus = false;
  if(n <0){
    isMinus = true;
    n *= -1;
  }
  int a[33];
  REP(i,33){
    if(n%2==1){
      if(isMinus==false && i%2==0 || isMinus==true && i%2 == 1){
        a[i] = 1;
      }else{
        a[i] = -1;
      }
    }else{
      a[i] = 0;
    }
    n /= 2;
  }


  REP(i,33){
    if(a[i]==2){
      a[i] -= 2;
      a[i+1]--;
    }else if(a[i] <= -1){
      a[i] += 2;
      a[i+1]++;
    }
  }

  bool b = false;
  REPR(i,32){
    if(a[i] == 1)b = true;
    if(b){
      cout<<a[i];
    }
  }
  cout<<endl;




  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n,k,ans=0; cin>>n>>k;
	vi vec(n);
	rep(i,0,n) cin>>vec[i];
	sort(all(vec));
	reverse(all(vec));
	rep(i,0,k) ans+=vec[i];
	cout<<ans;
		
		
	
	return 0;
}

Measured memory_bytes: 256
n=int(input())
S=input().split( )
q=int(input())
T=input().split( )
C=[0 for i in range(q)]

for j in range(q):
    S=S+[T[j]]
    i=0
    while S[i]!=T[j]:
        i+=1
        if i==n:
            C[j]=1
c=0
for j in range(q):
    if C[j]==0:
        c+=1
print(c)



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

char s[100005];
int c[3];

int main() {
	scanf("%s", s);
	for (char* p = s; *p; c[*(p++) - 'a']++);
	sort(c, c + 3);
	puts((c[2] - c[0] <= 1) ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 384
import queue

K = int(input())
q = queue.Queue()
for i in range(1,10):
    q.put(i)
for i in range(K-1):
    x = q.get()
    if x%10 != 0: q.put(x*10 + x%10 - 1)
    q.put(x*10 + x%10)
    if x%10 != 9: q.put(x*10 + x%10 + 1)
print(q.get())


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

long long f( long long n, long long b ) {
    if( n < b )
        return n;
    else
        return f( n / b, b ) + n % b;
}

inline long long check( long long n, long long s, long long b ) {
    if( b >= 2 && f( n, b ) == s )
        return b;
    else
        return numeric_limits<long long> :: max();
}

int main( void ) {
    
    long long n, s;
    cin >> n >> s;
    
    long long ans = numeric_limits<long long> :: max();
    
    if( s == 1 )
        ans = n;
    if( n == s )
        ans = n + 1;
    
    for( int i = 1; 1LL * i * i <= n; i ++ ) {
        ans = min( ans, check( n, s, i ) );
        
        if( ( n - s ) % i == 0 && ( n - s ) / i + 1 >= 2 )
            ans = min( ans, check( n, s, ( n - s ) / i + 1 ) );
    }
   
    ans = min( ans, check( n, s, n - s ) );
    
    if( ans == numeric_limits<long long> :: max() )
        cout << -1 << endl;
    else
        cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception addd) {
					addd.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception addd) {
				addd.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	
	public static FastReader sc = new FastReader();
 
	static int mod = (int) (1e9+7),MAX=(int) (3e5);
    static List<Integer>[] edges;
    static int n;
    static double[] p;
    static Double[][][] dp;
    
    
	public static void main(String[] args) {
		n = sc.nextInt();
		p = new double[n+1];
		int[] map = new int[4];
		for(int i=1;i<=n;++i)	map[sc.nextInt()]++;
		
		dp = new Double[n+1][n+1][n+1];
		out.print(f(map[1],map[2],map[3]));
		out.close();
   }
	 
    private static double f(int i, int j, int k) {
    	if(i == 0 && j == 0 && k == 0) return 0;
    	if(dp[i][j][k] != null) return dp[i][j][k];
		double ans = n;
		if(i > 0) ans+=i*f(i-1,j,k);
		if(j > 0) ans+=j*f(i+1,j-1,k);
		if(k > 0) ans+=k*f(i,j+1,k-1);
		ans/=i+j+k;
		return dp[i][j][k] = ans;
	}

}

Measured memory_bytes: 289528
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	int n ; cin >> n ;
	string s,t ;
	cin >> s >> t ;
	for(int i=0;i<n;i++) cout << s.at(i) << t.at(i) ;
	cout << endl ;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m,ans=0;
    string s;
    map<string,int> mp;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        mp[s]++;
    }
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>s;
        mp[s]--;
    }
    for(auto i:mp){
        ans=max(ans,i.second);
    }
    cout<<ans;
}

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

bool isPrime(int n){
	if(n <= 1){
		return false;
	}
	for(int i = 2; i*i <= n; i++){
		if(n%i == 0){
			return false;
		}
	}
	return true;
}

int main(){
	int n,c = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		int D;
		cin >> D;
		if(isPrime(D)){
			c++;
		}
	}
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 1160
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
a = [input().split() for l in range(n)]
sum = 0
ans = 0

for i in range(n):
  for j in range(m):
    sum += b[j]*int(a[i][j])
  if sum+c > 0:
    ans += 1
  sum = 0

print(ans)


Measured memory_bytes: 38384
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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 MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N;
   ll K;
   cin >> N >> K;
   map<int, ll> log;
   vector<int> id;
   int a;
   ll b;
   for (int i = 0; i < N; i++) {
      cin >> a >> b;
      log[a] += b;
      id.push_back(a);
   }
   sort(id.begin(), id.end());
   id.erase(unique(id.begin(), id.end()), id.end());

   ll cnt = 0;
   for (auto &v: id) {
      if (cnt < K && K <= cnt + log[v]) {
         cout << v << endl;
         return 0;
      }
      cnt += log[v];
   }
}


Measured memory_bytes: 4600
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,p = LI()
    p += 3*a
    print(p>>1)
    return

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


Measured memory_bytes: 39024
fun main(args:Array<String>) {
    val hanaCount = readLine()!!.toInt()
    val hana = mutableListOf(readLine()!!.split(" ").map { it.toInt() }.toMutableList())
    var current = conv(hana)

    var ans = 0
    while (current.isNotEmpty()) {
        ans += current.size
        current = current.map { a-> a.map { it - 1 }.toMutableList() }.toMutableList()
        current = conv(current)
    }
    println(ans)
}

fun conv(list:MutableList<MutableList<Int>>):MutableList<MutableList<Int>> {
    val ret = mutableListOf<MutableList<Int>>()

    list.forEach{a->
        var temp = mutableListOf<Int>()
        for(i in a) {
            if(i <= 0) {
                if(temp.isNotEmpty()) {
                    ret.add(temp)
                    temp = mutableListOf()
                }
            } else {
                temp.add(i)
            }
        }
        if(temp.isNotEmpty()) {
            ret.add(temp)
        }
    }
    return ret
}


Measured memory_bytes: 37748